@uploadcare/upload-client 3.1.2-alpha.0 → 4.1.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/dist/types.d.ts CHANGED
@@ -1,6 +1,4 @@
1
- // Generated by dts-bundle-generator v5.4.0
2
-
3
- /// <reference types="node" />
1
+ // Generated by dts-bundle-generator v6.12.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
- declare function base(file: NodeFile | BrowserFile, { publicKey, fileName, contentType, baseURL, secureSignature, secureExpire, store, signal, onProgress, source, integration, userAgent, retryThrottledRequestMaxTimes, metadata }: BaseOptions): Promise<BaseResponse>;
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
- declare function fromUrl(sourceUrl: Url, { publicKey, baseURL, store, fileName, checkForUrlDuplicates, saveUrlForRecurrentUploads, secureSignature, secureExpire, source, signal, integration, userAgent, retryThrottledRequestMaxTimes, metadata }: FromUrlOptions): Promise<FromUrlSuccessResponse>;
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
- declare function fromUrlStatus(token: Token, { publicKey, baseURL, signal, integration, userAgent, retryThrottledRequestMaxTimes }?: FromUrlStatusOptions): Promise<FromUrlStatusResponse>;
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
- declare function group(uuids: Uuid[], { publicKey, baseURL, jsonpCallback, secureSignature, secureExpire, signal, source, integration, userAgent, retryThrottledRequestMaxTimes }: GroupOptions): Promise<GroupInfo>;
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
- declare function groupInfo(id: GroupId, { publicKey, baseURL, signal, source, integration, userAgent, retryThrottledRequestMaxTimes }: GroupInfoOptions): Promise<GroupInfo>;
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
- declare function info(uuid: Uuid, { publicKey, baseURL, signal, source, integration, userAgent, retryThrottledRequestMaxTimes }: InfoOptions): Promise<FileInfo>;
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
- declare function multipartStart(size: number, { publicKey, contentType, fileName, multipartChunkSize, baseURL, secureSignature, secureExpire, store, signal, source, integration, userAgent, retryThrottledRequestMaxTimes, metadata }: MultipartStartOptions): Promise<MultipartStartResponse>;
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
- declare function multipartUpload(part: NodeFile | BrowserFile, url: MultipartPart, { signal, onProgress }: MultipartUploadOptions): Promise<MultipartUploadResponse>;
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
- declare function multipartComplete(uuid: Uuid, { publicKey, baseURL, source, signal, integration, userAgent, retryThrottledRequestMaxTimes }: MultipartCompleteOptions): Promise<FileInfo>;
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 cdnUrlModifiers: null | string;
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
- constructor(fileInfo: FileInfo, { baseCDN, defaultEffects, fileName }: {
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 FromObjectOptions = {
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 uploadFromObject: (file: NodeFile | BrowserFile, { publicKey, fileName, baseURL, secureSignature, secureExpire, store, contentType, signal, onProgress, source, integration, userAgent, retryThrottledRequestMaxTimes, baseCDN, metadata }: FromObjectOptions) => Promise<UploadcareFile>;
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
- declare function uploadFileGroup(data: (NodeFile | BrowserFile)[] | Url[] | Uuid[], { publicKey, fileName, baseURL, secureSignature, secureExpire, store, signal, onProgress, source, integration, userAgent, retryThrottledRequestMaxTimes, contentType, multipartChunkSize, baseCDN, jsonpCallback, defaultEffects }: FileFromOptions & GroupFromOptions): Promise<UploadcareGroup>;
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,39 +1,29 @@
1
1
  {
2
2
  "name": "@uploadcare/upload-client",
3
- "version": "3.1.2-alpha.0",
3
+ "version": "4.1.0",
4
4
  "description": "Library for work with Uploadcare Upload API",
5
5
  "type": "module",
6
- "main": "dist/index.cjs",
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
- "files": [
11
- "dist/*"
12
- ],
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"
12
+ "files": ["dist/*"],
13
+ "engines": {
14
+ "node": ">=16"
22
15
  },
23
16
  "scripts": {
24
- "check-env-vars": "node ./checkvars.js",
17
+ "check-env-vars": "node ../../checkvars.js",
25
18
  "mock:start": "node --loader ts-node/esm ./mock-server/server.ts --silent",
26
19
  "clean": "rimraf dist",
27
- "lint": "eslint ./src ./mock-server --ext=ts",
28
20
  "test": "start-server-and-test mock:start :3000 test:jest",
29
- "test:production": "npm run check-env-vars && TEST_ENV=production jest",
30
- "test:jest": "jest",
21
+ "test:production": "npm run check-env-vars && TEST_ENV=production npm run test:jest",
22
+ "test:jest": "node --experimental-vm-modules ../../node_modules/jest/bin/jest.js",
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",
34
- "build:compile": "rollup -c",
35
- "release:prepare": "shipjs prepare",
36
- "release:trigger": "shipjs trigger"
25
+ "build:types": "dts-bundle-generator --project tsconfig.dts.json -o dist/types.d.ts src/index.ts",
26
+ "build:compile": "rollup -c"
37
27
  },
38
28
  "repository": {
39
29
  "type": "git",
@@ -55,46 +45,24 @@
55
45
  "cdn"
56
46
  ],
57
47
  "devDependencies": {
58
- "@rollup/plugin-alias": "^3.1.1",
59
- "@rollup/plugin-node-resolve": "^8.4.0",
60
- "@types/ws": "8.2.0",
61
- "dts-bundle-generator": "5.4.0",
62
- "prettier": "2.2.1",
63
- "rollup": "^2.23.0",
64
- "rollup-plugin-typescript2": "^0.27.1",
65
- "typescript": "^3.9.7",
66
- "@koa/cors": "3.1.0",
67
- "@koa/router": "10.0.0",
68
- "@types/form-data": "2.5.0",
69
- "@types/jest": "26.0.14",
70
- "@types/koa": "2.11.4",
71
- "@types/node": "12.12.67",
72
- "@types/promise": "7.1.30",
73
- "@typescript-eslint/eslint-plugin": "5.3.1",
74
- "@typescript-eslint/parser": "5.3.1",
75
- "chalk": "4.1.0",
48
+ "@koa/cors": "3.3.0",
49
+ "@koa/router": "10.1.1",
50
+ "@types/express-serve-static-core": "^4.17.28",
51
+ "@types/koa": "2.13.4",
52
+ "@types/ws": "8.5.3",
76
53
  "data-uri-to-buffer": "3.0.1",
77
54
  "dataurl-to-blob": "0.0.1",
78
55
  "dotenv": "8.2.0",
79
- "eslint": "8.2.0",
80
- "eslint-config-prettier": "8.3.0",
81
- "eslint-plugin-prettier": "4.0.0",
82
- "jest": "26.5.3",
83
- "jest-environment-jsdom": "26.5.2",
84
- "jest-websocket-mock": "2.2.0",
85
- "koa": "2.13.0",
56
+ "jest-environment-jsdom": "28.1.0",
57
+ "jest-websocket-mock": "2.3.0",
58
+ "koa": "2.13.4",
86
59
  "koa-add-trailing-slashes": "2.0.1",
87
- "koa-body": "4.2.0",
60
+ "koa-body": "5.0.0",
88
61
  "mock-socket": "9.0.3",
89
- "prettier-config-standard": "4.0.0",
90
- "rimraf": "3.0.2",
91
- "shipjs": "0.24.0",
92
62
  "start-server-and-test": "1.11.7",
93
- "ts-jest": "26.4.1",
94
- "ts-node": "10.5.0"
63
+ "@uploadcare/api-client-utils": "^4.1.0"
95
64
  },
96
65
  "dependencies": {
97
- "abort-controller": "^3.0.0",
98
66
  "form-data": "^4.0.0",
99
67
  "ws": "^8.2.3"
100
68
  }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2019 Uploadcare Inc.
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.