@uploadcare/upload-client 6.4.1 → 6.5.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/index.d.ts CHANGED
@@ -2,16 +2,16 @@
2
2
 
3
3
  import NodeFormData from 'form-data';
4
4
 
5
- export declare type CustomUserAgentOptions = {
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 declare type CustomUserAgentFn = (options: CustomUserAgentOptions) => string;
13
- export declare type CustomUserAgent = string | CustomUserAgentFn;
14
- export declare type GetUserAgentOptions = {
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 declare type GeoLocation = {
26
+ export type GeoLocation = {
27
27
  latitude: number;
28
28
  longitude: number;
29
29
  };
30
- export declare type ImageInfo = {
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 declare type AudioInfo = {
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 declare type VideoInfo = {
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 declare type MimeInfo = {
63
+ export type MimeInfo = {
64
64
  mime: string;
65
65
  type: string;
66
66
  subtype: string;
67
67
  };
68
- export declare type ContentInfo = {
68
+ export type ContentInfo = {
69
69
  mime?: MimeInfo;
70
70
  image?: ImageInfo;
71
71
  video?: VideoInfo;
72
72
  };
73
- export declare type Metadata = Record<string, string>;
74
- export declare type StoreValue = "auto" | boolean;
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 declare type BrowserFile = Blob | File;
103
- export declare type NodeFile = Buffer;
104
- export declare type ReactNativeAsset = {
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 declare type SupportedFileInput = BrowserFile | NodeFile | ReactNativeAsset;
110
- export declare type Sliceable = BrowserFile | NodeFile;
111
- export declare type FileInfo = {
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 declare type GroupInfo = {
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 declare type Token = string;
139
- export declare type Uuid = string;
140
- export declare type GroupId = string;
141
- export declare type Url = string;
142
- export declare type ComputableProgressInfo = {
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 declare type UnknownProgressInfo = {
146
+ export type UnknownProgressInfo = {
147
147
  isComputable: false;
148
148
  };
149
- export declare type ProgressCallback<T = ComputableProgressInfo | UnknownProgressInfo> = (arg: T) => void;
150
- export declare type BaseResponse = {
149
+ export type ProgressCallback<T = ComputableProgressInfo | UnknownProgressInfo> = (arg: T) => void;
150
+ export type BaseResponse = {
151
151
  file: Uuid;
152
152
  };
153
- export declare type BaseOptions = {
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 declare type TokenResponse = {
179
+ export type TokenResponse = {
180
180
  type: TypeEnum.Token;
181
181
  token: string;
182
182
  };
183
- export declare type FileInfoResponse = {
183
+ export type FileInfoResponse = {
184
184
  type: TypeEnum.FileInfo;
185
185
  } & FileInfo;
186
- export declare type FromUrlSuccessResponse = FileInfoResponse | TokenResponse;
187
- export declare type FromUrlResponse = FromUrlSuccessResponse;
188
- export declare type FromUrlOptions = {
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 declare type StatusUnknownResponse = {
214
+ export type StatusUnknownResponse = {
215
215
  status: Status.Unknown;
216
216
  };
217
- export declare type StatusWaitingResponse = {
217
+ export type StatusWaitingResponse = {
218
218
  status: Status.Waiting;
219
219
  };
220
- export declare type StatusProgressResponse = {
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 declare type StatusErrorResponse = {
226
+ export type StatusErrorResponse = {
227
227
  status: Status.Error;
228
228
  error: string;
229
229
  errorCode: string;
230
230
  };
231
- export declare type StatusSuccessResponse = {
231
+ export type StatusSuccessResponse = {
232
232
  status: Status.Success;
233
233
  } & FileInfo;
234
- export declare type FromUrlStatusResponse = StatusUnknownResponse | StatusWaitingResponse | StatusProgressResponse | StatusErrorResponse | StatusSuccessResponse;
235
- export declare type FromUrlStatusOptions = {
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 declare type GroupOptions = {
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 declare type GroupInfoOptions = {
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 declare type InfoOptions = {
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 declare type MultipartStartOptions = {
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 declare type MultipartPart = string;
303
- export declare type MultipartStartResponse = {
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 declare type MultipartUploadOptions = {
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 declare type MultipartUploadResponse = {
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 declare type MultipartCompleteOptions = {
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 declare type FileFromOptions = {
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 declare type DirectOptions = {
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 declare type FromUploadedOptions = {
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 declare type UploadFromUrlOptions = {
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 declare type MultipartOptions = {
420
+ export type MultipartOptions = {
421
421
  publicKey: string;
422
422
  contentType?: string;
423
423
  multipartChunkSize?: number;
@@ -451,7 +451,7 @@ export declare class UploadcareGroup {
451
451
  readonly storedAt: string | null;
452
452
  constructor(groupInfo: GroupInfo, files: UploadcareFile[]);
453
453
  }
454
- export declare type GroupFromOptions = {
454
+ export type GroupFromOptions = {
455
455
  jsonpCallback?: string;
456
456
  };
457
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>;
@@ -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 declare type Headers = {
475
+ export type Headers = {
476
476
  [key: string]: string | string[] | undefined;
477
477
  };
478
- export declare type ErrorRequestInfo = {
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 declare type ErrorResponseInfo = {
485
+ export type ErrorResponseInfo = {
486
486
  error?: {
487
487
  statusCode: number;
488
488
  content: string;
package/package.json CHANGED
@@ -1,30 +1,42 @@
1
1
  {
2
2
  "name": "@uploadcare/upload-client",
3
- "version": "6.4.1",
3
+ "version": "6.5.0",
4
4
  "description": "Library for work with Uploadcare Upload API",
5
5
  "type": "module",
6
- "module": "./dist/index.node.js",
7
- "browser": "./dist/index.browser.js",
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
- "types": "./dist/index.d.ts",
13
- "node": "./dist/index.node.js",
14
- "browser": "./dist/index.browser.js",
15
- "default": "./dist/index.browser.js"
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
+ },
24
+ "default": {
25
+ "import": "./dist/esm/index.browser.mjs",
26
+ "require": "./dist/cjs/index.browser.cjs"
27
+ }
16
28
  },
17
29
  "./browser": {
18
- "types": "./dist/index.d.ts",
19
- "default": "./dist/index.browser.js"
30
+ "import": "./dist/esm/index.browser.mjs",
31
+ "require": "./dist/cjs/index.browser.cjs"
20
32
  },
21
33
  "./node": {
22
- "types": "./dist/index.d.ts",
23
- "default": "./dist/index.node.js"
34
+ "import": "./dist/esm/index.node.mjs",
35
+ "require": "./dist/cjs/index.node.cjs"
24
36
  },
25
37
  "./react-native": {
26
- "types": "./dist/index.d.ts",
27
- "default": "./dist/index.react-native.js"
38
+ "import": "./dist/esm/index.react-native.mjs",
39
+ "require": "./dist/cjs/index.react-native.cjs"
28
40
  }
29
41
  },
30
42
  "sideEffects": false,
@@ -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.1",
93
+ "@uploadcare/api-client-utils": "^6.5.0",
82
94
  "chalk": "^4.1.2"
83
95
  },
84
96
  "dependencies": {