@uploadcare/upload-client 6.14.1-alpha.0 → 6.14.1

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.
@@ -405,7 +405,7 @@ const getUrl = (base, path, query) => {
405
405
  return url.toString();
406
406
  };
407
407
 
408
- var version = '6.14.0';
408
+ var version = '6.14.1';
409
409
 
410
410
  const LIBRARY_NAME = 'UploadcareUploadClient';
411
411
  const LIBRARY_VERSION = version;
@@ -700,7 +700,7 @@ function multipartStart(size, { publicKey, contentType, fileName, multipartChunk
700
700
  }
701
701
  else {
702
702
  // convert to array
703
- response.parts = Object.keys(response.parts).map((key) => response.parts[key]);
703
+ response.parts = Object.keys(response.parts).map((key) => response.parts[Number(key)]);
704
704
  return response;
705
705
  }
706
706
  }), { retryThrottledRequestMaxTimes, retryNetworkErrorMaxTimes });
@@ -1306,9 +1306,7 @@ const sliceChunk = (file, index, fileSize, chunkSize) => {
1306
1306
  };
1307
1307
 
1308
1308
  const prepareChunks = async (file, fileSize, chunkSize) => {
1309
- return {
1310
- getChunk: (index) => sliceChunk(file, index, fileSize, chunkSize)
1311
- };
1309
+ return (index) => sliceChunk(file, index, fileSize, chunkSize);
1312
1310
  };
1313
1311
 
1314
1312
  const uploadPart = (chunk, url, { publicKey, contentType, onProgress, signal, integration, retryThrottledRequestMaxTimes, retryNetworkErrorMaxTimes }) => multipartUpload(chunk, url, {
@@ -1359,10 +1357,10 @@ const uploadMultipart = async (file, { publicKey, fileName, fileSize, baseURL, s
1359
1357
  metadata
1360
1358
  })
1361
1359
  .then(async ({ uuid, parts }) => {
1362
- const { getChunk, disposeChunks, disposeChunk } = await prepareChunks(file, size, multipartChunkSize);
1363
- await runWithConcurrency(maxConcurrentRequests, parts.map((url, index) => async () => {
1364
- const chunk = getChunk(index);
1365
- return uploadPart(chunk, url, {
1360
+ const getChunk = await prepareChunks(file, size, multipartChunkSize);
1361
+ return Promise.all([
1362
+ uuid,
1363
+ runWithConcurrency(maxConcurrentRequests, parts.map((url, index) => () => uploadPart(getChunk(index), url, {
1366
1364
  publicKey,
1367
1365
  contentType,
1368
1366
  onProgress: createProgressHandler(parts.length, index),
@@ -1370,11 +1368,10 @@ const uploadMultipart = async (file, { publicKey, fileName, fileSize, baseURL, s
1370
1368
  integration,
1371
1369
  retryThrottledRequestMaxTimes,
1372
1370
  retryNetworkErrorMaxTimes
1373
- }).finally(() => disposeChunk?.(chunk));
1374
- })).finally(() => disposeChunks?.());
1375
- return uuid;
1371
+ })))
1372
+ ]);
1376
1373
  })
1377
- .then((uuid) => multipartComplete(uuid, {
1374
+ .then(([uuid]) => multipartComplete(uuid, {
1378
1375
  publicKey,
1379
1376
  baseURL,
1380
1377
  source,
@@ -267,7 +267,6 @@ const request = (params) => {
267
267
  req.on('response', (res) => {
268
268
  if (aborted)
269
269
  return;
270
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
271
270
  const resChunks = [];
272
271
  res.on('data', (data) => {
273
272
  resChunks.push(data);
@@ -436,7 +435,7 @@ const getUrl = (base, path, query) => {
436
435
  return url.toString();
437
436
  };
438
437
 
439
- var version = '6.14.0';
438
+ var version = '6.14.1';
440
439
 
441
440
  const LIBRARY_NAME = 'UploadcareUploadClient';
442
441
  const LIBRARY_VERSION = version;
@@ -731,7 +730,7 @@ function multipartStart(size, { publicKey, contentType, fileName, multipartChunk
731
730
  }
732
731
  else {
733
732
  // convert to array
734
- response.parts = Object.keys(response.parts).map((key) => response.parts[key]);
733
+ response.parts = Object.keys(response.parts).map((key) => response.parts[Number(key)]);
735
734
  return response;
736
735
  }
737
736
  }), { retryThrottledRequestMaxTimes, retryNetworkErrorMaxTimes });
@@ -1338,9 +1337,7 @@ const sliceChunk = (file, index, fileSize, chunkSize) => {
1338
1337
  };
1339
1338
 
1340
1339
  const prepareChunks = async (file, fileSize, chunkSize) => {
1341
- return {
1342
- getChunk: (index) => sliceChunk(file, index, fileSize, chunkSize)
1343
- };
1340
+ return (index) => sliceChunk(file, index, fileSize, chunkSize);
1344
1341
  };
1345
1342
 
1346
1343
  const uploadPart = (chunk, url, { publicKey, contentType, onProgress, signal, integration, retryThrottledRequestMaxTimes, retryNetworkErrorMaxTimes }) => multipartUpload(chunk, url, {
@@ -1391,10 +1388,10 @@ const uploadMultipart = async (file, { publicKey, fileName, fileSize, baseURL, s
1391
1388
  metadata
1392
1389
  })
1393
1390
  .then(async ({ uuid, parts }) => {
1394
- const { getChunk, disposeChunks, disposeChunk } = await prepareChunks(file, size, multipartChunkSize);
1395
- await runWithConcurrency(maxConcurrentRequests, parts.map((url, index) => async () => {
1396
- const chunk = getChunk(index);
1397
- return uploadPart(chunk, url, {
1391
+ const getChunk = await prepareChunks(file, size, multipartChunkSize);
1392
+ return Promise.all([
1393
+ uuid,
1394
+ runWithConcurrency(maxConcurrentRequests, parts.map((url, index) => () => uploadPart(getChunk(index), url, {
1398
1395
  publicKey,
1399
1396
  contentType,
1400
1397
  onProgress: createProgressHandler(parts.length, index),
@@ -1402,11 +1399,10 @@ const uploadMultipart = async (file, { publicKey, fileName, fileSize, baseURL, s
1402
1399
  integration,
1403
1400
  retryThrottledRequestMaxTimes,
1404
1401
  retryNetworkErrorMaxTimes
1405
- }).finally(() => disposeChunk?.(chunk));
1406
- })).finally(() => disposeChunks?.());
1407
- return uuid;
1402
+ })))
1403
+ ]);
1408
1404
  })
1409
- .then((uuid) => multipartComplete(uuid, {
1405
+ .then(([uuid]) => multipartComplete(uuid, {
1410
1406
  publicKey,
1411
1407
  baseURL,
1412
1408
  source,
@@ -413,7 +413,7 @@ const getUrl = (base, path, query) => {
413
413
  return url.toString();
414
414
  };
415
415
 
416
- var version = '6.14.0';
416
+ var version = '6.14.1';
417
417
 
418
418
  const LIBRARY_NAME = 'UploadcareUploadClient';
419
419
  const LIBRARY_VERSION = version;
@@ -708,7 +708,7 @@ function multipartStart(size, { publicKey, contentType, fileName, multipartChunk
708
708
  }
709
709
  else {
710
710
  // convert to array
711
- response.parts = Object.keys(response.parts).map((key) => response.parts[key]);
711
+ response.parts = Object.keys(response.parts).map((key) => response.parts[Number(key)]);
712
712
  return response;
713
713
  }
714
714
  }), { retryThrottledRequestMaxTimes, retryNetworkErrorMaxTimes });
@@ -1331,27 +1331,9 @@ const prepareChunks = async (file, fileSize, chunkSize) => {
1331
1331
  else {
1332
1332
  blob = file;
1333
1333
  }
1334
- const chunks = new Set();
1335
- return {
1336
- getChunk: (index) => {
1337
- const chunk = sliceChunk(blob, index, fileSize, chunkSize);
1338
- chunks.add(chunk);
1339
- return chunk;
1340
- },
1341
- /**
1342
- * Remove references to all the chunks from the memory to make able
1343
- * react-native to deallocate it
1344
- */
1345
- disposeChunks: () => {
1346
- chunks.clear();
1347
- },
1348
- /**
1349
- * Remove specific chunk reference from the memory to make able react-native
1350
- * to deallocate it
1351
- */
1352
- disposeChunk: (chunk) => {
1353
- chunks.delete(chunk);
1354
- }
1334
+ return (index) => {
1335
+ const chunk = sliceChunk(blob, index, fileSize, chunkSize);
1336
+ return chunk;
1355
1337
  };
1356
1338
  };
1357
1339
 
@@ -1403,10 +1385,10 @@ const uploadMultipart = async (file, { publicKey, fileName, fileSize, baseURL, s
1403
1385
  metadata
1404
1386
  })
1405
1387
  .then(async ({ uuid, parts }) => {
1406
- const { getChunk, disposeChunks, disposeChunk } = await prepareChunks(file, size, multipartChunkSize);
1407
- await runWithConcurrency(maxConcurrentRequests, parts.map((url, index) => async () => {
1408
- const chunk = getChunk(index);
1409
- return uploadPart(chunk, url, {
1388
+ const getChunk = await prepareChunks(file, size, multipartChunkSize);
1389
+ return Promise.all([
1390
+ uuid,
1391
+ runWithConcurrency(maxConcurrentRequests, parts.map((url, index) => () => uploadPart(getChunk(index), url, {
1410
1392
  publicKey,
1411
1393
  contentType,
1412
1394
  onProgress: createProgressHandler(parts.length, index),
@@ -1414,11 +1396,10 @@ const uploadMultipart = async (file, { publicKey, fileName, fileSize, baseURL, s
1414
1396
  integration,
1415
1397
  retryThrottledRequestMaxTimes,
1416
1398
  retryNetworkErrorMaxTimes
1417
- }).finally(() => disposeChunk?.(chunk));
1418
- })).finally(() => disposeChunks?.());
1419
- return uuid;
1399
+ })))
1400
+ ]);
1420
1401
  })
1421
- .then((uuid) => multipartComplete(uuid, {
1402
+ .then(([uuid]) => multipartComplete(uuid, {
1422
1403
  publicKey,
1423
1404
  baseURL,
1424
1405
  source,
@@ -403,7 +403,7 @@ const getUrl = (base, path, query) => {
403
403
  return url.toString();
404
404
  };
405
405
 
406
- var version = '6.14.0';
406
+ var version = '6.14.1';
407
407
 
408
408
  const LIBRARY_NAME = 'UploadcareUploadClient';
409
409
  const LIBRARY_VERSION = version;
@@ -698,7 +698,7 @@ function multipartStart(size, { publicKey, contentType, fileName, multipartChunk
698
698
  }
699
699
  else {
700
700
  // convert to array
701
- response.parts = Object.keys(response.parts).map((key) => response.parts[key]);
701
+ response.parts = Object.keys(response.parts).map((key) => response.parts[Number(key)]);
702
702
  return response;
703
703
  }
704
704
  }), { retryThrottledRequestMaxTimes, retryNetworkErrorMaxTimes });
@@ -1304,9 +1304,7 @@ const sliceChunk = (file, index, fileSize, chunkSize) => {
1304
1304
  };
1305
1305
 
1306
1306
  const prepareChunks = async (file, fileSize, chunkSize) => {
1307
- return {
1308
- getChunk: (index) => sliceChunk(file, index, fileSize, chunkSize)
1309
- };
1307
+ return (index) => sliceChunk(file, index, fileSize, chunkSize);
1310
1308
  };
1311
1309
 
1312
1310
  const uploadPart = (chunk, url, { publicKey, contentType, onProgress, signal, integration, retryThrottledRequestMaxTimes, retryNetworkErrorMaxTimes }) => multipartUpload(chunk, url, {
@@ -1357,10 +1355,10 @@ const uploadMultipart = async (file, { publicKey, fileName, fileSize, baseURL, s
1357
1355
  metadata
1358
1356
  })
1359
1357
  .then(async ({ uuid, parts }) => {
1360
- const { getChunk, disposeChunks, disposeChunk } = await prepareChunks(file, size, multipartChunkSize);
1361
- await runWithConcurrency(maxConcurrentRequests, parts.map((url, index) => async () => {
1362
- const chunk = getChunk(index);
1363
- return uploadPart(chunk, url, {
1358
+ const getChunk = await prepareChunks(file, size, multipartChunkSize);
1359
+ return Promise.all([
1360
+ uuid,
1361
+ runWithConcurrency(maxConcurrentRequests, parts.map((url, index) => () => uploadPart(getChunk(index), url, {
1364
1362
  publicKey,
1365
1363
  contentType,
1366
1364
  onProgress: createProgressHandler(parts.length, index),
@@ -1368,11 +1366,10 @@ const uploadMultipart = async (file, { publicKey, fileName, fileSize, baseURL, s
1368
1366
  integration,
1369
1367
  retryThrottledRequestMaxTimes,
1370
1368
  retryNetworkErrorMaxTimes
1371
- }).finally(() => disposeChunk?.(chunk));
1372
- })).finally(() => disposeChunks?.());
1373
- return uuid;
1369
+ })))
1370
+ ]);
1374
1371
  })
1375
- .then((uuid) => multipartComplete(uuid, {
1372
+ .then(([uuid]) => multipartComplete(uuid, {
1376
1373
  publicKey,
1377
1374
  baseURL,
1378
1375
  source,
@@ -265,7 +265,6 @@ const request = (params) => {
265
265
  req.on('response', (res) => {
266
266
  if (aborted)
267
267
  return;
268
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
269
268
  const resChunks = [];
270
269
  res.on('data', (data) => {
271
270
  resChunks.push(data);
@@ -434,7 +433,7 @@ const getUrl = (base, path, query) => {
434
433
  return url.toString();
435
434
  };
436
435
 
437
- var version = '6.14.0';
436
+ var version = '6.14.1';
438
437
 
439
438
  const LIBRARY_NAME = 'UploadcareUploadClient';
440
439
  const LIBRARY_VERSION = version;
@@ -729,7 +728,7 @@ function multipartStart(size, { publicKey, contentType, fileName, multipartChunk
729
728
  }
730
729
  else {
731
730
  // convert to array
732
- response.parts = Object.keys(response.parts).map((key) => response.parts[key]);
731
+ response.parts = Object.keys(response.parts).map((key) => response.parts[Number(key)]);
733
732
  return response;
734
733
  }
735
734
  }), { retryThrottledRequestMaxTimes, retryNetworkErrorMaxTimes });
@@ -1336,9 +1335,7 @@ const sliceChunk = (file, index, fileSize, chunkSize) => {
1336
1335
  };
1337
1336
 
1338
1337
  const prepareChunks = async (file, fileSize, chunkSize) => {
1339
- return {
1340
- getChunk: (index) => sliceChunk(file, index, fileSize, chunkSize)
1341
- };
1338
+ return (index) => sliceChunk(file, index, fileSize, chunkSize);
1342
1339
  };
1343
1340
 
1344
1341
  const uploadPart = (chunk, url, { publicKey, contentType, onProgress, signal, integration, retryThrottledRequestMaxTimes, retryNetworkErrorMaxTimes }) => multipartUpload(chunk, url, {
@@ -1389,10 +1386,10 @@ const uploadMultipart = async (file, { publicKey, fileName, fileSize, baseURL, s
1389
1386
  metadata
1390
1387
  })
1391
1388
  .then(async ({ uuid, parts }) => {
1392
- const { getChunk, disposeChunks, disposeChunk } = await prepareChunks(file, size, multipartChunkSize);
1393
- await runWithConcurrency(maxConcurrentRequests, parts.map((url, index) => async () => {
1394
- const chunk = getChunk(index);
1395
- return uploadPart(chunk, url, {
1389
+ const getChunk = await prepareChunks(file, size, multipartChunkSize);
1390
+ return Promise.all([
1391
+ uuid,
1392
+ runWithConcurrency(maxConcurrentRequests, parts.map((url, index) => () => uploadPart(getChunk(index), url, {
1396
1393
  publicKey,
1397
1394
  contentType,
1398
1395
  onProgress: createProgressHandler(parts.length, index),
@@ -1400,11 +1397,10 @@ const uploadMultipart = async (file, { publicKey, fileName, fileSize, baseURL, s
1400
1397
  integration,
1401
1398
  retryThrottledRequestMaxTimes,
1402
1399
  retryNetworkErrorMaxTimes
1403
- }).finally(() => disposeChunk?.(chunk));
1404
- })).finally(() => disposeChunks?.());
1405
- return uuid;
1400
+ })))
1401
+ ]);
1406
1402
  })
1407
- .then((uuid) => multipartComplete(uuid, {
1403
+ .then(([uuid]) => multipartComplete(uuid, {
1408
1404
  publicKey,
1409
1405
  baseURL,
1410
1406
  source,
@@ -411,7 +411,7 @@ const getUrl = (base, path, query) => {
411
411
  return url.toString();
412
412
  };
413
413
 
414
- var version = '6.14.0';
414
+ var version = '6.14.1';
415
415
 
416
416
  const LIBRARY_NAME = 'UploadcareUploadClient';
417
417
  const LIBRARY_VERSION = version;
@@ -706,7 +706,7 @@ function multipartStart(size, { publicKey, contentType, fileName, multipartChunk
706
706
  }
707
707
  else {
708
708
  // convert to array
709
- response.parts = Object.keys(response.parts).map((key) => response.parts[key]);
709
+ response.parts = Object.keys(response.parts).map((key) => response.parts[Number(key)]);
710
710
  return response;
711
711
  }
712
712
  }), { retryThrottledRequestMaxTimes, retryNetworkErrorMaxTimes });
@@ -1329,27 +1329,9 @@ const prepareChunks = async (file, fileSize, chunkSize) => {
1329
1329
  else {
1330
1330
  blob = file;
1331
1331
  }
1332
- const chunks = new Set();
1333
- return {
1334
- getChunk: (index) => {
1335
- const chunk = sliceChunk(blob, index, fileSize, chunkSize);
1336
- chunks.add(chunk);
1337
- return chunk;
1338
- },
1339
- /**
1340
- * Remove references to all the chunks from the memory to make able
1341
- * react-native to deallocate it
1342
- */
1343
- disposeChunks: () => {
1344
- chunks.clear();
1345
- },
1346
- /**
1347
- * Remove specific chunk reference from the memory to make able react-native
1348
- * to deallocate it
1349
- */
1350
- disposeChunk: (chunk) => {
1351
- chunks.delete(chunk);
1352
- }
1332
+ return (index) => {
1333
+ const chunk = sliceChunk(blob, index, fileSize, chunkSize);
1334
+ return chunk;
1353
1335
  };
1354
1336
  };
1355
1337
 
@@ -1401,10 +1383,10 @@ const uploadMultipart = async (file, { publicKey, fileName, fileSize, baseURL, s
1401
1383
  metadata
1402
1384
  })
1403
1385
  .then(async ({ uuid, parts }) => {
1404
- const { getChunk, disposeChunks, disposeChunk } = await prepareChunks(file, size, multipartChunkSize);
1405
- await runWithConcurrency(maxConcurrentRequests, parts.map((url, index) => async () => {
1406
- const chunk = getChunk(index);
1407
- return uploadPart(chunk, url, {
1386
+ const getChunk = await prepareChunks(file, size, multipartChunkSize);
1387
+ return Promise.all([
1388
+ uuid,
1389
+ runWithConcurrency(maxConcurrentRequests, parts.map((url, index) => () => uploadPart(getChunk(index), url, {
1408
1390
  publicKey,
1409
1391
  contentType,
1410
1392
  onProgress: createProgressHandler(parts.length, index),
@@ -1412,11 +1394,10 @@ const uploadMultipart = async (file, { publicKey, fileName, fileSize, baseURL, s
1412
1394
  integration,
1413
1395
  retryThrottledRequestMaxTimes,
1414
1396
  retryNetworkErrorMaxTimes
1415
- }).finally(() => disposeChunk?.(chunk));
1416
- })).finally(() => disposeChunks?.());
1417
- return uuid;
1397
+ })))
1398
+ ]);
1418
1399
  })
1419
- .then((uuid) => multipartComplete(uuid, {
1400
+ .then(([uuid]) => multipartComplete(uuid, {
1420
1401
  publicKey,
1421
1402
  baseURL,
1422
1403
  source,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uploadcare/upload-client",
3
- "version": "6.14.1-alpha.0",
3
+ "version": "6.14.1",
4
4
  "description": "Library for work with Uploadcare Upload API",
5
5
  "type": "module",
6
6
  "module": "./dist/esm/index.node.mjs",
@@ -80,7 +80,11 @@
80
80
  "@koa/router": "10.1.1",
81
81
  "@types/express-serve-static-core": "^4.17.28",
82
82
  "@types/koa": "2.13.4",
83
+ "@types/koa__cors": "^5.0.0",
84
+ "@types/koa__router": "^12.0.4",
83
85
  "@types/ws": "8.5.3",
86
+ "@uploadcare/api-client-utils": "^6.14.1",
87
+ "chalk": "^4.1.2",
84
88
  "data-uri-to-buffer": "3.0.1",
85
89
  "dataurl-to-blob": "0.0.1",
86
90
  "jest-environment-jsdom": "29.3.1",
@@ -89,9 +93,7 @@
89
93
  "koa-add-trailing-slashes": "2.0.1",
90
94
  "koa-body": "5.0.0",
91
95
  "mock-socket": "9.0.3",
92
- "start-server-and-test": "1.14.0",
93
- "@uploadcare/api-client-utils": "^6.14.0",
94
- "chalk": "^4.1.2"
96
+ "start-server-and-test": "1.14.0"
95
97
  },
96
98
  "dependencies": {
97
99
  "form-data": "^4.0.0",