@uploadcare/upload-client 3.1.0 → 4.0.0
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/README.md +5 -3
- package/dist/index.browser.js +1441 -1451
- package/dist/{index.js → index.node.js} +1468 -1463
- package/dist/index.react-native.js +1546 -0
- package/dist/types.d.ts +47 -37
- package/package.json +30 -37
- package/dist/index.browser.cjs +0 -1743
- package/dist/index.cjs +0 -1775
package/dist/types.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
// Generated by dts-bundle-generator
|
|
2
|
-
|
|
3
|
-
/// <reference types="node" />
|
|
1
|
+
// Generated by dts-bundle-generator v6.9.0
|
|
4
2
|
|
|
5
3
|
import NodeFormData from 'form-data';
|
|
6
4
|
|
|
@@ -152,6 +150,7 @@ export declare type BaseOptions = {
|
|
|
152
150
|
secureSignature?: string;
|
|
153
151
|
secureExpire?: string;
|
|
154
152
|
store?: boolean;
|
|
153
|
+
contentType?: string;
|
|
155
154
|
signal?: AbortSignal;
|
|
156
155
|
onProgress?: ProgressCallback;
|
|
157
156
|
source?: string;
|
|
@@ -160,7 +159,11 @@ export declare type BaseOptions = {
|
|
|
160
159
|
retryThrottledRequestMaxTimes?: number;
|
|
161
160
|
metadata?: Metadata;
|
|
162
161
|
};
|
|
163
|
-
|
|
162
|
+
/**
|
|
163
|
+
* Performs file uploading request to Uploadcare Upload API.
|
|
164
|
+
* Can be canceled and has progress.
|
|
165
|
+
*/
|
|
166
|
+
export function base(file: NodeFile | BrowserFile, { publicKey, fileName, contentType, baseURL, secureSignature, secureExpire, store, signal, onProgress, source, integration, userAgent, retryThrottledRequestMaxTimes, metadata }: BaseOptions): Promise<BaseResponse>;
|
|
164
167
|
declare enum TypeEnum {
|
|
165
168
|
Token = "token",
|
|
166
169
|
FileInfo = "file_info"
|
|
@@ -190,7 +193,10 @@ export declare type FromUrlOptions = {
|
|
|
190
193
|
retryThrottledRequestMaxTimes?: number;
|
|
191
194
|
metadata?: Metadata;
|
|
192
195
|
};
|
|
193
|
-
|
|
196
|
+
/**
|
|
197
|
+
* Uploading files from URL.
|
|
198
|
+
*/
|
|
199
|
+
export function fromUrl(sourceUrl: Url, { publicKey, baseURL, store, fileName, checkForUrlDuplicates, saveUrlForRecurrentUploads, secureSignature, secureExpire, source, signal, integration, userAgent, retryThrottledRequestMaxTimes, metadata }: FromUrlOptions): Promise<FromUrlSuccessResponse>;
|
|
194
200
|
declare enum Status {
|
|
195
201
|
Unknown = "unknown",
|
|
196
202
|
Waiting = "waiting",
|
|
@@ -227,7 +233,10 @@ export declare type FromUrlStatusOptions = {
|
|
|
227
233
|
userAgent?: CustomUserAgent;
|
|
228
234
|
retryThrottledRequestMaxTimes?: number;
|
|
229
235
|
};
|
|
230
|
-
|
|
236
|
+
/**
|
|
237
|
+
* Checking upload status and working with file tokens.
|
|
238
|
+
*/
|
|
239
|
+
export function fromUrlStatus(token: Token, { publicKey, baseURL, signal, integration, userAgent, retryThrottledRequestMaxTimes }?: FromUrlStatusOptions): Promise<FromUrlStatusResponse>;
|
|
231
240
|
export declare type GroupOptions = {
|
|
232
241
|
publicKey: string;
|
|
233
242
|
baseURL?: string;
|
|
@@ -240,7 +249,10 @@ export declare type GroupOptions = {
|
|
|
240
249
|
userAgent?: CustomUserAgent;
|
|
241
250
|
retryThrottledRequestMaxTimes?: number;
|
|
242
251
|
};
|
|
243
|
-
|
|
252
|
+
/**
|
|
253
|
+
* Create files group.
|
|
254
|
+
*/
|
|
255
|
+
export function group(uuids: Uuid[], { publicKey, baseURL, jsonpCallback, secureSignature, secureExpire, signal, source, integration, userAgent, retryThrottledRequestMaxTimes }: GroupOptions): Promise<GroupInfo>;
|
|
244
256
|
export declare type GroupInfoOptions = {
|
|
245
257
|
publicKey: string;
|
|
246
258
|
baseURL?: string;
|
|
@@ -250,7 +262,10 @@ export declare type GroupInfoOptions = {
|
|
|
250
262
|
userAgent?: CustomUserAgent;
|
|
251
263
|
retryThrottledRequestMaxTimes?: number;
|
|
252
264
|
};
|
|
253
|
-
|
|
265
|
+
/**
|
|
266
|
+
* Get info about group.
|
|
267
|
+
*/
|
|
268
|
+
export function groupInfo(id: GroupId, { publicKey, baseURL, signal, source, integration, userAgent, retryThrottledRequestMaxTimes }: GroupInfoOptions): Promise<GroupInfo>;
|
|
254
269
|
export declare type InfoOptions = {
|
|
255
270
|
publicKey: string;
|
|
256
271
|
baseURL?: string;
|
|
@@ -260,7 +275,10 @@ export declare type InfoOptions = {
|
|
|
260
275
|
userAgent?: CustomUserAgent;
|
|
261
276
|
retryThrottledRequestMaxTimes?: number;
|
|
262
277
|
};
|
|
263
|
-
|
|
278
|
+
/**
|
|
279
|
+
* Returns a JSON dictionary holding file info.
|
|
280
|
+
*/
|
|
281
|
+
export function info(uuid: Uuid, { publicKey, baseURL, signal, source, integration, userAgent, retryThrottledRequestMaxTimes }: InfoOptions): Promise<FileInfo>;
|
|
264
282
|
export declare type MultipartStartOptions = {
|
|
265
283
|
publicKey: string;
|
|
266
284
|
contentType?: string;
|
|
@@ -282,7 +300,10 @@ export declare type MultipartStartResponse = {
|
|
|
282
300
|
parts: MultipartPart[];
|
|
283
301
|
uuid: Uuid;
|
|
284
302
|
};
|
|
285
|
-
|
|
303
|
+
/**
|
|
304
|
+
* Start multipart uploading.
|
|
305
|
+
*/
|
|
306
|
+
export function multipartStart(size: number, { publicKey, contentType, fileName, multipartChunkSize, baseURL, secureSignature, secureExpire, store, signal, source, integration, userAgent, retryThrottledRequestMaxTimes, metadata }: MultipartStartOptions): Promise<MultipartStartResponse>;
|
|
286
307
|
export declare type MultipartUploadOptions = {
|
|
287
308
|
publicKey?: string;
|
|
288
309
|
signal?: AbortSignal;
|
|
@@ -293,7 +314,10 @@ export declare type MultipartUploadOptions = {
|
|
|
293
314
|
export declare type MultipartUploadResponse = {
|
|
294
315
|
code?: number;
|
|
295
316
|
};
|
|
296
|
-
|
|
317
|
+
/**
|
|
318
|
+
* Complete multipart uploading.
|
|
319
|
+
*/
|
|
320
|
+
export function multipartUpload(part: NodeFile | BrowserFile, url: MultipartPart, { signal, onProgress }: MultipartUploadOptions): Promise<MultipartUploadResponse>;
|
|
297
321
|
export declare type MultipartCompleteOptions = {
|
|
298
322
|
publicKey: string;
|
|
299
323
|
baseURL?: string;
|
|
@@ -303,7 +327,10 @@ export declare type MultipartCompleteOptions = {
|
|
|
303
327
|
userAgent?: CustomUserAgent;
|
|
304
328
|
retryThrottledRequestMaxTimes?: number;
|
|
305
329
|
};
|
|
306
|
-
|
|
330
|
+
/**
|
|
331
|
+
* Complete multipart uploading.
|
|
332
|
+
*/
|
|
333
|
+
export function multipartComplete(uuid: Uuid, { publicKey, baseURL, source, signal, integration, userAgent, retryThrottledRequestMaxTimes }: MultipartCompleteOptions): Promise<FileInfo>;
|
|
307
334
|
export declare class UploadcareFile {
|
|
308
335
|
readonly uuid: Uuid;
|
|
309
336
|
readonly name: null | string;
|
|
@@ -312,26 +339,26 @@ export declare class UploadcareFile {
|
|
|
312
339
|
readonly isImage: null | boolean;
|
|
313
340
|
readonly mimeType: null | string;
|
|
314
341
|
readonly cdnUrl: null | string;
|
|
315
|
-
readonly
|
|
316
|
-
readonly originalUrl: null | string;
|
|
342
|
+
readonly s3Url: null | string;
|
|
317
343
|
readonly originalFilename: null | string;
|
|
318
344
|
readonly imageInfo: null | ImageInfo;
|
|
319
345
|
readonly videoInfo: null | VideoInfo;
|
|
320
346
|
readonly contentInfo: null | ContentInfo;
|
|
321
347
|
readonly metadata: null | Metadata;
|
|
322
|
-
|
|
348
|
+
readonly s3Bucket: null | string;
|
|
349
|
+
constructor(fileInfo: FileInfo, { baseCDN, fileName }: {
|
|
323
350
|
baseCDN?: string;
|
|
324
|
-
defaultEffects?: string;
|
|
325
351
|
fileName?: string;
|
|
326
352
|
});
|
|
327
353
|
}
|
|
328
|
-
export declare type
|
|
354
|
+
export declare type DirectOptions = {
|
|
329
355
|
publicKey: string;
|
|
330
356
|
fileName?: string;
|
|
331
357
|
baseURL?: string;
|
|
332
358
|
secureSignature?: string;
|
|
333
359
|
secureExpire?: string;
|
|
334
360
|
store?: boolean;
|
|
361
|
+
contentType?: string;
|
|
335
362
|
signal?: AbortSignal;
|
|
336
363
|
onProgress?: ProgressCallback;
|
|
337
364
|
source?: string;
|
|
@@ -341,7 +368,7 @@ export declare type FromObjectOptions = {
|
|
|
341
368
|
baseCDN?: string;
|
|
342
369
|
metadata?: Metadata;
|
|
343
370
|
};
|
|
344
|
-
declare const
|
|
371
|
+
export declare const uploadDirect: (file: NodeFile | BrowserFile, { publicKey, fileName, baseURL, secureSignature, secureExpire, store, contentType, signal, onProgress, source, integration, userAgent, retryThrottledRequestMaxTimes, baseCDN, metadata }: DirectOptions) => Promise<UploadcareFile>;
|
|
345
372
|
export declare type UploadFromUrlOptions = {
|
|
346
373
|
baseCDN?: string;
|
|
347
374
|
onProgress?: ProgressCallback;
|
|
@@ -424,11 +451,10 @@ export declare class UploadcareGroup {
|
|
|
424
451
|
constructor(groupInfo: GroupInfo, files: UploadcareFile[]);
|
|
425
452
|
}
|
|
426
453
|
export declare type GroupFromOptions = {
|
|
427
|
-
defaultEffects?: string;
|
|
428
454
|
jsonpCallback?: string;
|
|
429
455
|
};
|
|
430
|
-
|
|
431
|
-
declare class UploadClient {
|
|
456
|
+
export function uploadFileGroup(data: (NodeFile | BrowserFile)[] | Url[] | Uuid[], { publicKey, fileName, baseURL, secureSignature, secureExpire, store, signal, onProgress, source, integration, userAgent, retryThrottledRequestMaxTimes, contentType, multipartChunkSize, baseCDN, jsonpCallback }: FileFromOptions & GroupFromOptions): Promise<UploadcareGroup>;
|
|
457
|
+
export declare class UploadClient {
|
|
432
458
|
private settings;
|
|
433
459
|
constructor(settings: Settings);
|
|
434
460
|
updateSettings(newSettings: Settings): void;
|
|
@@ -460,21 +486,5 @@ export declare class UploadClientError extends Error {
|
|
|
460
486
|
readonly headers?: Headers;
|
|
461
487
|
constructor(message: string, code?: string, request?: ErrorRequestInfo, response?: ErrorResponseInfo, headers?: Headers);
|
|
462
488
|
}
|
|
463
|
-
export { AbortController } from "abort-controller";
|
|
464
|
-
|
|
465
|
-
export {
|
|
466
|
-
UploadClient as UploadClient,
|
|
467
|
-
base as base,
|
|
468
|
-
fromUrl as fromUrl,
|
|
469
|
-
fromUrlStatus as fromUrlStatus,
|
|
470
|
-
group as group,
|
|
471
|
-
groupInfo as groupInfo,
|
|
472
|
-
info as info,
|
|
473
|
-
multipartComplete as multipartComplete,
|
|
474
|
-
multipartStart as multipartStart,
|
|
475
|
-
multipartUpload as multipartUpload,
|
|
476
|
-
uploadFileGroup as uploadFileGroup,
|
|
477
|
-
uploadFromObject as uploadBase,
|
|
478
|
-
};
|
|
479
489
|
|
|
480
490
|
export {};
|
package/package.json
CHANGED
|
@@ -1,25 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uploadcare/upload-client",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "Library for work with Uploadcare Upload API",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "dist/index.
|
|
7
|
-
"module": "dist/index.js",
|
|
6
|
+
"main": "dist/index.node.js",
|
|
7
|
+
"module": "dist/index.node.js",
|
|
8
|
+
"browser": "dist/index.browser.js",
|
|
9
|
+
"react-native": "dist/index.react-native.js",
|
|
8
10
|
"types": "dist/types.d.ts",
|
|
9
11
|
"sideEffects": false,
|
|
10
12
|
"files": [
|
|
11
13
|
"dist/*"
|
|
12
14
|
],
|
|
13
|
-
"browser": {
|
|
14
|
-
"./dist/index.cjs": "./dist/index.browser.cjs",
|
|
15
|
-
"./dist/index.js": "./dist/index.browser.js"
|
|
16
|
-
},
|
|
17
|
-
"react-native": {
|
|
18
|
-
"./lib/request/request.node.js": "./lib/request/request.browser.js",
|
|
19
|
-
"./lib/tools/getFormData.node.js": "./lib/tools/getFormData.react-native.js",
|
|
20
|
-
"./lib/tools/sockets.node.js": "./lib/tools/sockets.browser.js",
|
|
21
|
-
"./lib/uploadFile/prepareChunks.node.js": "./lib/uploadFile/prepareChunks.react-native.js"
|
|
22
|
-
},
|
|
23
15
|
"scripts": {
|
|
24
16
|
"check-env-vars": "node ./checkvars.js",
|
|
25
17
|
"mock:start": "node --loader ts-node/esm ./mock-server/server.ts --silent",
|
|
@@ -30,7 +22,7 @@
|
|
|
30
22
|
"test:jest": "jest",
|
|
31
23
|
"prebuild": "npm run clean",
|
|
32
24
|
"build": "npm run build:types && npm run build:compile",
|
|
33
|
-
"build:types": "dts-bundle-generator -o dist/types.d.ts src/index.ts",
|
|
25
|
+
"build:types": "dts-bundle-generator --project tsconfig.dts.json -o dist/types.d.ts src/index.ts",
|
|
34
26
|
"build:compile": "rollup -c",
|
|
35
27
|
"release:prepare": "shipjs prepare",
|
|
36
28
|
"release:trigger": "shipjs trigger"
|
|
@@ -55,46 +47,47 @@
|
|
|
55
47
|
"cdn"
|
|
56
48
|
],
|
|
57
49
|
"devDependencies": {
|
|
58
|
-
"@
|
|
59
|
-
"@
|
|
60
|
-
"@
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"rollup-plugin-typescript2": "^0.27.1",
|
|
65
|
-
"typescript": "^3.9.7",
|
|
66
|
-
"@koa/cors": "3.1.0",
|
|
67
|
-
"@koa/router": "10.0.0",
|
|
50
|
+
"@koa/cors": "3.3.0",
|
|
51
|
+
"@koa/router": "10.1.1",
|
|
52
|
+
"@rollup/plugin-alias": "^3.1.9",
|
|
53
|
+
"@rollup/plugin-node-resolve": "^13.3.0",
|
|
54
|
+
"@rollup/plugin-typescript": "^8.3.2",
|
|
55
|
+
"@types/express-serve-static-core": "^4.17.28",
|
|
68
56
|
"@types/form-data": "2.5.0",
|
|
69
|
-
"@types/jest": "
|
|
70
|
-
"@types/koa": "2.
|
|
71
|
-
"@types/node": "
|
|
57
|
+
"@types/jest": "27.0.0",
|
|
58
|
+
"@types/koa": "2.13.4",
|
|
59
|
+
"@types/node": "17.0.38",
|
|
72
60
|
"@types/promise": "7.1.30",
|
|
73
|
-
"@
|
|
74
|
-
"@typescript-eslint/
|
|
61
|
+
"@types/ws": "8.5.3",
|
|
62
|
+
"@typescript-eslint/eslint-plugin": "5.27.0",
|
|
63
|
+
"@typescript-eslint/parser": "5.27.0",
|
|
75
64
|
"chalk": "4.1.0",
|
|
76
65
|
"data-uri-to-buffer": "3.0.1",
|
|
77
66
|
"dataurl-to-blob": "0.0.1",
|
|
78
67
|
"dotenv": "8.2.0",
|
|
68
|
+
"dts-bundle-generator": "6.9.0",
|
|
79
69
|
"eslint": "8.2.0",
|
|
80
70
|
"eslint-config-prettier": "8.3.0",
|
|
81
71
|
"eslint-plugin-prettier": "4.0.0",
|
|
82
|
-
"jest": "
|
|
83
|
-
"jest-environment-jsdom": "
|
|
84
|
-
"jest-websocket-mock": "2.
|
|
85
|
-
"koa": "2.13.
|
|
72
|
+
"jest": "^28.1.0",
|
|
73
|
+
"jest-environment-jsdom": "28.1.0",
|
|
74
|
+
"jest-websocket-mock": "2.3.0",
|
|
75
|
+
"koa": "2.13.4",
|
|
86
76
|
"koa-add-trailing-slashes": "2.0.1",
|
|
87
|
-
"koa-body": "
|
|
77
|
+
"koa-body": "5.0.0",
|
|
88
78
|
"mock-socket": "9.0.3",
|
|
79
|
+
"prettier": "2.2.1",
|
|
89
80
|
"prettier-config-standard": "4.0.0",
|
|
90
81
|
"rimraf": "3.0.2",
|
|
82
|
+
"rollup": "^2.75.5",
|
|
91
83
|
"shipjs": "0.24.0",
|
|
92
84
|
"start-server-and-test": "1.11.7",
|
|
93
|
-
"ts-jest": "
|
|
94
|
-
"ts-node": "10.
|
|
85
|
+
"ts-jest": "28.0.3",
|
|
86
|
+
"ts-node": "^10.8.0",
|
|
87
|
+
"tslib": "^2.4.0",
|
|
88
|
+
"typescript": "^4.7.2"
|
|
95
89
|
},
|
|
96
90
|
"dependencies": {
|
|
97
|
-
"abort-controller": "^3.0.0",
|
|
98
91
|
"form-data": "^4.0.0",
|
|
99
92
|
"ws": "^8.2.3"
|
|
100
93
|
}
|