@uploadcare/upload-client 3.1.2-alpha.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 +2 -2
- package/dist/index.browser.js +1440 -1457
- package/dist/{index.js → index.node.js} +1467 -1474
- package/dist/index.react-native.js +1546 -0
- package/dist/types.d.ts +45 -37
- package/package.json +30 -37
- package/dist/index.browser.cjs +0 -1753
- package/dist/index.cjs +0 -1790
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
|
|
|
@@ -161,7 +159,11 @@ export declare type BaseOptions = {
|
|
|
161
159
|
retryThrottledRequestMaxTimes?: number;
|
|
162
160
|
metadata?: Metadata;
|
|
163
161
|
};
|
|
164
|
-
|
|
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>;
|
|
165
167
|
declare enum TypeEnum {
|
|
166
168
|
Token = "token",
|
|
167
169
|
FileInfo = "file_info"
|
|
@@ -191,7 +193,10 @@ export declare type FromUrlOptions = {
|
|
|
191
193
|
retryThrottledRequestMaxTimes?: number;
|
|
192
194
|
metadata?: Metadata;
|
|
193
195
|
};
|
|
194
|
-
|
|
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>;
|
|
195
200
|
declare enum Status {
|
|
196
201
|
Unknown = "unknown",
|
|
197
202
|
Waiting = "waiting",
|
|
@@ -228,7 +233,10 @@ export declare type FromUrlStatusOptions = {
|
|
|
228
233
|
userAgent?: CustomUserAgent;
|
|
229
234
|
retryThrottledRequestMaxTimes?: number;
|
|
230
235
|
};
|
|
231
|
-
|
|
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>;
|
|
232
240
|
export declare type GroupOptions = {
|
|
233
241
|
publicKey: string;
|
|
234
242
|
baseURL?: string;
|
|
@@ -241,7 +249,10 @@ export declare type GroupOptions = {
|
|
|
241
249
|
userAgent?: CustomUserAgent;
|
|
242
250
|
retryThrottledRequestMaxTimes?: number;
|
|
243
251
|
};
|
|
244
|
-
|
|
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>;
|
|
245
256
|
export declare type GroupInfoOptions = {
|
|
246
257
|
publicKey: string;
|
|
247
258
|
baseURL?: string;
|
|
@@ -251,7 +262,10 @@ export declare type GroupInfoOptions = {
|
|
|
251
262
|
userAgent?: CustomUserAgent;
|
|
252
263
|
retryThrottledRequestMaxTimes?: number;
|
|
253
264
|
};
|
|
254
|
-
|
|
265
|
+
/**
|
|
266
|
+
* Get info about group.
|
|
267
|
+
*/
|
|
268
|
+
export function groupInfo(id: GroupId, { publicKey, baseURL, signal, source, integration, userAgent, retryThrottledRequestMaxTimes }: GroupInfoOptions): Promise<GroupInfo>;
|
|
255
269
|
export declare type InfoOptions = {
|
|
256
270
|
publicKey: string;
|
|
257
271
|
baseURL?: string;
|
|
@@ -261,7 +275,10 @@ export declare type InfoOptions = {
|
|
|
261
275
|
userAgent?: CustomUserAgent;
|
|
262
276
|
retryThrottledRequestMaxTimes?: number;
|
|
263
277
|
};
|
|
264
|
-
|
|
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>;
|
|
265
282
|
export declare type MultipartStartOptions = {
|
|
266
283
|
publicKey: string;
|
|
267
284
|
contentType?: string;
|
|
@@ -283,7 +300,10 @@ export declare type MultipartStartResponse = {
|
|
|
283
300
|
parts: MultipartPart[];
|
|
284
301
|
uuid: Uuid;
|
|
285
302
|
};
|
|
286
|
-
|
|
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>;
|
|
287
307
|
export declare type MultipartUploadOptions = {
|
|
288
308
|
publicKey?: string;
|
|
289
309
|
signal?: AbortSignal;
|
|
@@ -294,7 +314,10 @@ export declare type MultipartUploadOptions = {
|
|
|
294
314
|
export declare type MultipartUploadResponse = {
|
|
295
315
|
code?: number;
|
|
296
316
|
};
|
|
297
|
-
|
|
317
|
+
/**
|
|
318
|
+
* Complete multipart uploading.
|
|
319
|
+
*/
|
|
320
|
+
export function multipartUpload(part: NodeFile | BrowserFile, url: MultipartPart, { signal, onProgress }: MultipartUploadOptions): Promise<MultipartUploadResponse>;
|
|
298
321
|
export declare type MultipartCompleteOptions = {
|
|
299
322
|
publicKey: string;
|
|
300
323
|
baseURL?: string;
|
|
@@ -304,7 +327,10 @@ export declare type MultipartCompleteOptions = {
|
|
|
304
327
|
userAgent?: CustomUserAgent;
|
|
305
328
|
retryThrottledRequestMaxTimes?: number;
|
|
306
329
|
};
|
|
307
|
-
|
|
330
|
+
/**
|
|
331
|
+
* Complete multipart uploading.
|
|
332
|
+
*/
|
|
333
|
+
export function multipartComplete(uuid: Uuid, { publicKey, baseURL, source, signal, integration, userAgent, retryThrottledRequestMaxTimes }: MultipartCompleteOptions): Promise<FileInfo>;
|
|
308
334
|
export declare class UploadcareFile {
|
|
309
335
|
readonly uuid: Uuid;
|
|
310
336
|
readonly name: null | string;
|
|
@@ -313,20 +339,19 @@ export declare class UploadcareFile {
|
|
|
313
339
|
readonly isImage: null | boolean;
|
|
314
340
|
readonly mimeType: null | string;
|
|
315
341
|
readonly cdnUrl: null | string;
|
|
316
|
-
readonly
|
|
317
|
-
readonly originalUrl: null | string;
|
|
342
|
+
readonly s3Url: null | string;
|
|
318
343
|
readonly originalFilename: null | string;
|
|
319
344
|
readonly imageInfo: null | ImageInfo;
|
|
320
345
|
readonly videoInfo: null | VideoInfo;
|
|
321
346
|
readonly contentInfo: null | ContentInfo;
|
|
322
347
|
readonly metadata: null | Metadata;
|
|
323
|
-
|
|
348
|
+
readonly s3Bucket: null | string;
|
|
349
|
+
constructor(fileInfo: FileInfo, { baseCDN, fileName }: {
|
|
324
350
|
baseCDN?: string;
|
|
325
|
-
defaultEffects?: string;
|
|
326
351
|
fileName?: string;
|
|
327
352
|
});
|
|
328
353
|
}
|
|
329
|
-
export declare type
|
|
354
|
+
export declare type DirectOptions = {
|
|
330
355
|
publicKey: string;
|
|
331
356
|
fileName?: string;
|
|
332
357
|
baseURL?: string;
|
|
@@ -343,7 +368,7 @@ export declare type FromObjectOptions = {
|
|
|
343
368
|
baseCDN?: string;
|
|
344
369
|
metadata?: Metadata;
|
|
345
370
|
};
|
|
346
|
-
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>;
|
|
347
372
|
export declare type UploadFromUrlOptions = {
|
|
348
373
|
baseCDN?: string;
|
|
349
374
|
onProgress?: ProgressCallback;
|
|
@@ -426,11 +451,10 @@ export declare class UploadcareGroup {
|
|
|
426
451
|
constructor(groupInfo: GroupInfo, files: UploadcareFile[]);
|
|
427
452
|
}
|
|
428
453
|
export declare type GroupFromOptions = {
|
|
429
|
-
defaultEffects?: string;
|
|
430
454
|
jsonpCallback?: string;
|
|
431
455
|
};
|
|
432
|
-
|
|
433
|
-
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 {
|
|
434
458
|
private settings;
|
|
435
459
|
constructor(settings: Settings);
|
|
436
460
|
updateSettings(newSettings: Settings): void;
|
|
@@ -462,21 +486,5 @@ export declare class UploadClientError extends Error {
|
|
|
462
486
|
readonly headers?: Headers;
|
|
463
487
|
constructor(message: string, code?: string, request?: ErrorRequestInfo, response?: ErrorResponseInfo, headers?: Headers);
|
|
464
488
|
}
|
|
465
|
-
export { AbortController } from "abort-controller";
|
|
466
|
-
|
|
467
|
-
export {
|
|
468
|
-
UploadClient as UploadClient,
|
|
469
|
-
base as base,
|
|
470
|
-
fromUrl as fromUrl,
|
|
471
|
-
fromUrlStatus as fromUrlStatus,
|
|
472
|
-
group as group,
|
|
473
|
-
groupInfo as groupInfo,
|
|
474
|
-
info as info,
|
|
475
|
-
multipartComplete as multipartComplete,
|
|
476
|
-
multipartStart as multipartStart,
|
|
477
|
-
multipartUpload as multipartUpload,
|
|
478
|
-
uploadFileGroup as uploadFileGroup,
|
|
479
|
-
uploadFromObject as uploadBase,
|
|
480
|
-
};
|
|
481
489
|
|
|
482
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
|
}
|