@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
package/dist/index.d.ts
CHANGED
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
import NodeFormData from 'form-data';
|
|
4
4
|
|
|
5
|
-
export
|
|
5
|
+
export type CustomUserAgentOptions = {
|
|
6
6
|
publicKey: string;
|
|
7
7
|
libraryName: string;
|
|
8
8
|
libraryVersion: string;
|
|
9
9
|
languageName: string;
|
|
10
10
|
integration?: string;
|
|
11
11
|
};
|
|
12
|
-
export
|
|
13
|
-
export
|
|
14
|
-
export
|
|
12
|
+
export type CustomUserAgentFn = (options: CustomUserAgentOptions) => string;
|
|
13
|
+
export type CustomUserAgent = string | CustomUserAgentFn;
|
|
14
|
+
export type GetUserAgentOptions = {
|
|
15
15
|
libraryName: string;
|
|
16
16
|
libraryVersion: string;
|
|
17
17
|
publicKey?: string;
|
|
@@ -23,11 +23,11 @@ export declare class UploadcareNetworkError extends Error {
|
|
|
23
23
|
originalProgressEvent: ProgressEvent;
|
|
24
24
|
constructor(progressEvent: ProgressEvent);
|
|
25
25
|
}
|
|
26
|
-
export
|
|
26
|
+
export type GeoLocation = {
|
|
27
27
|
latitude: number;
|
|
28
28
|
longitude: number;
|
|
29
29
|
};
|
|
30
|
-
export
|
|
30
|
+
export type ImageInfo = {
|
|
31
31
|
height: number;
|
|
32
32
|
width: number;
|
|
33
33
|
geoLocation: GeoLocation | null;
|
|
@@ -41,13 +41,13 @@ export declare type ImageInfo = {
|
|
|
41
41
|
orientation: number | null;
|
|
42
42
|
sequence: boolean | null;
|
|
43
43
|
};
|
|
44
|
-
export
|
|
44
|
+
export type AudioInfo = {
|
|
45
45
|
bitrate: number | null;
|
|
46
46
|
codec: string | null;
|
|
47
47
|
sampleRate: number | null;
|
|
48
48
|
channels: string | null;
|
|
49
49
|
};
|
|
50
|
-
export
|
|
50
|
+
export type VideoInfo = {
|
|
51
51
|
duration: number;
|
|
52
52
|
format: string;
|
|
53
53
|
bitrate: number;
|
|
@@ -60,18 +60,18 @@ export declare type VideoInfo = {
|
|
|
60
60
|
codec: string;
|
|
61
61
|
};
|
|
62
62
|
};
|
|
63
|
-
export
|
|
63
|
+
export type MimeInfo = {
|
|
64
64
|
mime: string;
|
|
65
65
|
type: string;
|
|
66
66
|
subtype: string;
|
|
67
67
|
};
|
|
68
|
-
export
|
|
68
|
+
export type ContentInfo = {
|
|
69
69
|
mime?: MimeInfo;
|
|
70
70
|
image?: ImageInfo;
|
|
71
71
|
video?: VideoInfo;
|
|
72
72
|
};
|
|
73
|
-
export
|
|
74
|
-
export
|
|
73
|
+
export type Metadata = Record<string, string>;
|
|
74
|
+
export type StoreValue = "auto" | boolean;
|
|
75
75
|
export interface DefaultSettings {
|
|
76
76
|
baseCDN: string;
|
|
77
77
|
baseURL: string;
|
|
@@ -99,16 +99,16 @@ export interface Settings extends Partial<DefaultSettings> {
|
|
|
99
99
|
source?: string;
|
|
100
100
|
jsonpCallback?: string;
|
|
101
101
|
}
|
|
102
|
-
export
|
|
103
|
-
export
|
|
104
|
-
export
|
|
102
|
+
export type BrowserFile = Blob | File;
|
|
103
|
+
export type NodeFile = Buffer;
|
|
104
|
+
export type ReactNativeAsset = {
|
|
105
105
|
type: string;
|
|
106
106
|
uri: string;
|
|
107
107
|
name?: string;
|
|
108
108
|
};
|
|
109
|
-
export
|
|
110
|
-
export
|
|
111
|
-
export
|
|
109
|
+
export type SupportedFileInput = BrowserFile | NodeFile | ReactNativeAsset;
|
|
110
|
+
export type Sliceable = BrowserFile | NodeFile;
|
|
111
|
+
export type FileInfo = {
|
|
112
112
|
size: number;
|
|
113
113
|
done: number;
|
|
114
114
|
total: number;
|
|
@@ -126,7 +126,7 @@ export declare type FileInfo = {
|
|
|
126
126
|
s3Bucket?: string;
|
|
127
127
|
metadata?: Metadata;
|
|
128
128
|
};
|
|
129
|
-
export
|
|
129
|
+
export type GroupInfo = {
|
|
130
130
|
datetimeCreated: string;
|
|
131
131
|
datetimeStored: string | null;
|
|
132
132
|
filesCount: string;
|
|
@@ -135,22 +135,22 @@ export declare type GroupInfo = {
|
|
|
135
135
|
url: string;
|
|
136
136
|
id: GroupId;
|
|
137
137
|
};
|
|
138
|
-
export
|
|
139
|
-
export
|
|
140
|
-
export
|
|
141
|
-
export
|
|
142
|
-
export
|
|
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
143
|
isComputable: true;
|
|
144
144
|
value: number;
|
|
145
145
|
};
|
|
146
|
-
export
|
|
146
|
+
export type UnknownProgressInfo = {
|
|
147
147
|
isComputable: false;
|
|
148
148
|
};
|
|
149
|
-
export
|
|
150
|
-
export
|
|
149
|
+
export type ProgressCallback<T = ComputableProgressInfo | UnknownProgressInfo> = (arg: T) => void;
|
|
150
|
+
export type BaseResponse = {
|
|
151
151
|
file: Uuid;
|
|
152
152
|
};
|
|
153
|
-
export
|
|
153
|
+
export type BaseOptions = {
|
|
154
154
|
publicKey: string;
|
|
155
155
|
fileName?: string;
|
|
156
156
|
baseURL?: string;
|
|
@@ -176,16 +176,16 @@ export declare enum TypeEnum {
|
|
|
176
176
|
Token = "token",
|
|
177
177
|
FileInfo = "file_info"
|
|
178
178
|
}
|
|
179
|
-
export
|
|
179
|
+
export type TokenResponse = {
|
|
180
180
|
type: TypeEnum.Token;
|
|
181
181
|
token: string;
|
|
182
182
|
};
|
|
183
|
-
export
|
|
183
|
+
export type FileInfoResponse = {
|
|
184
184
|
type: TypeEnum.FileInfo;
|
|
185
185
|
} & FileInfo;
|
|
186
|
-
export
|
|
187
|
-
export
|
|
188
|
-
export
|
|
186
|
+
export type FromUrlSuccessResponse = FileInfoResponse | TokenResponse;
|
|
187
|
+
export type FromUrlResponse = FromUrlSuccessResponse;
|
|
188
|
+
export type FromUrlOptions = {
|
|
189
189
|
publicKey: string;
|
|
190
190
|
baseURL?: string;
|
|
191
191
|
store?: StoreValue;
|
|
@@ -211,28 +211,28 @@ export declare enum Status {
|
|
|
211
211
|
Error = "error",
|
|
212
212
|
Success = "success"
|
|
213
213
|
}
|
|
214
|
-
export
|
|
214
|
+
export type StatusUnknownResponse = {
|
|
215
215
|
status: Status.Unknown;
|
|
216
216
|
};
|
|
217
|
-
export
|
|
217
|
+
export type StatusWaitingResponse = {
|
|
218
218
|
status: Status.Waiting;
|
|
219
219
|
};
|
|
220
|
-
export
|
|
220
|
+
export type StatusProgressResponse = {
|
|
221
221
|
status: Status.Progress;
|
|
222
222
|
size: number;
|
|
223
223
|
done: number;
|
|
224
224
|
total: number | "unknown";
|
|
225
225
|
};
|
|
226
|
-
export
|
|
226
|
+
export type StatusErrorResponse = {
|
|
227
227
|
status: Status.Error;
|
|
228
228
|
error: string;
|
|
229
229
|
errorCode: string;
|
|
230
230
|
};
|
|
231
|
-
export
|
|
231
|
+
export type StatusSuccessResponse = {
|
|
232
232
|
status: Status.Success;
|
|
233
233
|
} & FileInfo;
|
|
234
|
-
export
|
|
235
|
-
export
|
|
234
|
+
export type FromUrlStatusResponse = StatusUnknownResponse | StatusWaitingResponse | StatusProgressResponse | StatusErrorResponse | StatusSuccessResponse;
|
|
235
|
+
export type FromUrlStatusOptions = {
|
|
236
236
|
publicKey?: string;
|
|
237
237
|
baseURL?: string;
|
|
238
238
|
signal?: AbortSignal;
|
|
@@ -243,7 +243,7 @@ export declare type FromUrlStatusOptions = {
|
|
|
243
243
|
};
|
|
244
244
|
/** Checking upload status and working with file tokens. */
|
|
245
245
|
export function fromUrlStatus(token: Token, { publicKey, baseURL, signal, integration, userAgent, retryThrottledRequestMaxTimes, retryNetworkErrorMaxTimes }?: FromUrlStatusOptions): Promise<FromUrlStatusResponse>;
|
|
246
|
-
export
|
|
246
|
+
export type GroupOptions = {
|
|
247
247
|
publicKey: string;
|
|
248
248
|
baseURL?: string;
|
|
249
249
|
jsonpCallback?: string;
|
|
@@ -258,7 +258,7 @@ export declare type GroupOptions = {
|
|
|
258
258
|
};
|
|
259
259
|
/** Create files group. */
|
|
260
260
|
export function group(uuids: Uuid[], { publicKey, baseURL, jsonpCallback, secureSignature, secureExpire, signal, source, integration, userAgent, retryThrottledRequestMaxTimes, retryNetworkErrorMaxTimes }: GroupOptions): Promise<GroupInfo>;
|
|
261
|
-
export
|
|
261
|
+
export type GroupInfoOptions = {
|
|
262
262
|
publicKey: string;
|
|
263
263
|
baseURL?: string;
|
|
264
264
|
signal?: AbortSignal;
|
|
@@ -270,7 +270,7 @@ export declare type GroupInfoOptions = {
|
|
|
270
270
|
};
|
|
271
271
|
/** Get info about group. */
|
|
272
272
|
export function groupInfo(id: GroupId, { publicKey, baseURL, signal, source, integration, userAgent, retryThrottledRequestMaxTimes, retryNetworkErrorMaxTimes }: GroupInfoOptions): Promise<GroupInfo>;
|
|
273
|
-
export
|
|
273
|
+
export type InfoOptions = {
|
|
274
274
|
publicKey: string;
|
|
275
275
|
baseURL?: string;
|
|
276
276
|
signal?: AbortSignal;
|
|
@@ -282,7 +282,7 @@ export declare type InfoOptions = {
|
|
|
282
282
|
};
|
|
283
283
|
/** Returns a JSON dictionary holding file info. */
|
|
284
284
|
export function info(uuid: Uuid, { publicKey, baseURL, signal, source, integration, userAgent, retryThrottledRequestMaxTimes, retryNetworkErrorMaxTimes }: InfoOptions): Promise<FileInfo>;
|
|
285
|
-
export
|
|
285
|
+
export type MultipartStartOptions = {
|
|
286
286
|
publicKey: string;
|
|
287
287
|
contentType?: string;
|
|
288
288
|
fileName?: string;
|
|
@@ -299,14 +299,14 @@ export declare type MultipartStartOptions = {
|
|
|
299
299
|
retryNetworkErrorMaxTimes?: number;
|
|
300
300
|
metadata?: Metadata;
|
|
301
301
|
};
|
|
302
|
-
export
|
|
303
|
-
export
|
|
302
|
+
export type MultipartPart = string;
|
|
303
|
+
export type MultipartStartResponse = {
|
|
304
304
|
parts: MultipartPart[];
|
|
305
305
|
uuid: Uuid;
|
|
306
306
|
};
|
|
307
307
|
/** Start multipart uploading. */
|
|
308
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
|
|
309
|
+
export type MultipartUploadOptions = {
|
|
310
310
|
publicKey?: string;
|
|
311
311
|
contentType?: string;
|
|
312
312
|
signal?: AbortSignal;
|
|
@@ -315,12 +315,12 @@ export declare type MultipartUploadOptions = {
|
|
|
315
315
|
retryThrottledRequestMaxTimes?: number;
|
|
316
316
|
retryNetworkErrorMaxTimes?: number;
|
|
317
317
|
};
|
|
318
|
-
export
|
|
318
|
+
export type MultipartUploadResponse = {
|
|
319
319
|
code?: number;
|
|
320
320
|
};
|
|
321
321
|
/** Complete multipart uploading. */
|
|
322
322
|
export function multipartUpload(part: SupportedFileInput, url: MultipartPart, { contentType, signal, onProgress, retryThrottledRequestMaxTimes, retryNetworkErrorMaxTimes }: MultipartUploadOptions): Promise<MultipartUploadResponse>;
|
|
323
|
-
export
|
|
323
|
+
export type MultipartCompleteOptions = {
|
|
324
324
|
publicKey: string;
|
|
325
325
|
baseURL?: string;
|
|
326
326
|
signal?: AbortSignal;
|
|
@@ -352,7 +352,7 @@ export declare class UploadcareFile {
|
|
|
352
352
|
fileName?: string;
|
|
353
353
|
});
|
|
354
354
|
}
|
|
355
|
-
export
|
|
355
|
+
export type FileFromOptions = {
|
|
356
356
|
publicKey: string;
|
|
357
357
|
fileName?: string;
|
|
358
358
|
baseURL?: string;
|
|
@@ -378,7 +378,7 @@ export declare type FileFromOptions = {
|
|
|
378
378
|
};
|
|
379
379
|
/** Uploads file from provided data. */
|
|
380
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
|
|
381
|
+
export type DirectOptions = {
|
|
382
382
|
publicKey: string;
|
|
383
383
|
fileName?: string;
|
|
384
384
|
baseURL?: string;
|
|
@@ -397,7 +397,7 @@ export declare type DirectOptions = {
|
|
|
397
397
|
metadata?: Metadata;
|
|
398
398
|
};
|
|
399
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
|
|
400
|
+
export type FromUploadedOptions = {
|
|
401
401
|
publicKey: string;
|
|
402
402
|
fileName?: string;
|
|
403
403
|
baseURL?: string;
|
|
@@ -411,13 +411,13 @@ export declare type FromUploadedOptions = {
|
|
|
411
411
|
baseCDN?: string;
|
|
412
412
|
};
|
|
413
413
|
export declare const uploadFromUploaded: (uuid: Uuid, { publicKey, fileName, baseURL, signal, onProgress, source, integration, userAgent, retryThrottledRequestMaxTimes, retryNetworkErrorMaxTimes, baseCDN }: FromUploadedOptions) => Promise<UploadcareFile>;
|
|
414
|
-
export
|
|
414
|
+
export type UploadFromUrlOptions = {
|
|
415
415
|
baseCDN?: string;
|
|
416
416
|
onProgress?: ProgressCallback;
|
|
417
417
|
pusherKey?: string;
|
|
418
418
|
} & FromUrlOptions;
|
|
419
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
|
|
420
|
+
export type MultipartOptions = {
|
|
421
421
|
publicKey: string;
|
|
422
422
|
contentType?: string;
|
|
423
423
|
multipartChunkSize?: number;
|
|
@@ -451,10 +451,10 @@ export declare class UploadcareGroup {
|
|
|
451
451
|
readonly storedAt: string | null;
|
|
452
452
|
constructor(groupInfo: GroupInfo, files: UploadcareFile[]);
|
|
453
453
|
}
|
|
454
|
-
export
|
|
454
|
+
export type GroupFromOptions = {
|
|
455
455
|
jsonpCallback?: string;
|
|
456
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, jsonpCallback }: FileFromOptions & GroupFromOptions): Promise<UploadcareGroup>;
|
|
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
458
|
export declare class UploadClient {
|
|
459
459
|
private settings;
|
|
460
460
|
constructor(settings: Settings);
|
|
@@ -472,17 +472,17 @@ export declare class UploadClient {
|
|
|
472
472
|
uploadFile(data: SupportedFileInput | Url | Uuid, options?: Partial<FileFromOptions>): Promise<UploadcareFile>;
|
|
473
473
|
uploadFileGroup(data: SupportedFileInput[] | Url[] | Uuid[], options?: Partial<FileFromOptions & GroupFromOptions>): Promise<UploadcareGroup>;
|
|
474
474
|
}
|
|
475
|
-
export
|
|
475
|
+
export type Headers = {
|
|
476
476
|
[key: string]: string | string[] | undefined;
|
|
477
477
|
};
|
|
478
|
-
export
|
|
478
|
+
export type ErrorRequestInfo = {
|
|
479
479
|
method?: string;
|
|
480
480
|
url: string;
|
|
481
481
|
query?: string;
|
|
482
482
|
data?: NodeFormData | FormData | SupportedFileInput;
|
|
483
483
|
headers?: Headers;
|
|
484
484
|
};
|
|
485
|
-
export
|
|
485
|
+
export type ErrorResponseInfo = {
|
|
486
486
|
error?: {
|
|
487
487
|
statusCode: number;
|
|
488
488
|
content: string;
|
package/package.json
CHANGED
|
@@ -1,34 +1,46 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uploadcare/upload-client",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.5.0-alpha.2",
|
|
4
4
|
"description": "Library for work with Uploadcare Upload API",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"module": "./dist/index.node.
|
|
7
|
-
"browser": "./dist/index.browser.
|
|
6
|
+
"module": "./dist/esm/index.node.mjs",
|
|
7
|
+
"browser": "./dist/esm/index.browser.mjs",
|
|
8
8
|
"react-native": "./dist/index.react-native.js",
|
|
9
9
|
"types": "./dist/index.d.ts",
|
|
10
10
|
"exports": {
|
|
11
11
|
".": {
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
"node": {
|
|
13
|
+
"import": "./dist/esm/index.node.mjs",
|
|
14
|
+
"require": "./dist/cjs/index.node.cjs"
|
|
15
|
+
},
|
|
16
|
+
"browser": {
|
|
17
|
+
"import": "./dist/esm/index.browser.mjs",
|
|
18
|
+
"require": "./dist/cjs/index.browser.cjs"
|
|
19
|
+
},
|
|
20
|
+
"react-native": {
|
|
21
|
+
"import": "./dist/esm/index.react-native.mjs",
|
|
22
|
+
"require": "./dist/cjs/index.react-native.cjs"
|
|
23
|
+
}
|
|
16
24
|
},
|
|
17
25
|
"./browser": {
|
|
18
|
-
"
|
|
19
|
-
"
|
|
26
|
+
"import": "./dist/esm/index.browser.mjs",
|
|
27
|
+
"require": "./dist/cjs/index.browser.cjs"
|
|
20
28
|
},
|
|
21
29
|
"./node": {
|
|
22
|
-
"
|
|
23
|
-
"
|
|
30
|
+
"import": "./dist/esm/index.node.mjs",
|
|
31
|
+
"require": "./dist/cjs/index.node.cjs"
|
|
24
32
|
},
|
|
25
33
|
"./react-native": {
|
|
26
|
-
"
|
|
27
|
-
"
|
|
34
|
+
"import": "./dist/esm/index.react-native.mjs",
|
|
35
|
+
"require": "./dist/cjs/index.react-native.cjs"
|
|
28
36
|
}
|
|
29
37
|
},
|
|
30
38
|
"sideEffects": false,
|
|
31
|
-
"files": [
|
|
39
|
+
"files": [
|
|
40
|
+
"dist/*",
|
|
41
|
+
"README.md",
|
|
42
|
+
"LICENSE"
|
|
43
|
+
],
|
|
32
44
|
"engines": {
|
|
33
45
|
"node": ">=16"
|
|
34
46
|
},
|
|
@@ -78,7 +90,7 @@
|
|
|
78
90
|
"koa-body": "5.0.0",
|
|
79
91
|
"mock-socket": "9.0.3",
|
|
80
92
|
"start-server-and-test": "1.14.0",
|
|
81
|
-
"@uploadcare/api-client-utils": "^6.4.
|
|
93
|
+
"@uploadcare/api-client-utils": "^6.4.1",
|
|
82
94
|
"chalk": "^4.1.2"
|
|
83
95
|
},
|
|
84
96
|
"dependencies": {
|