@uploadcare/upload-client 6.17.0 → 6.18.2

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2019 Uploadcare Inc.
3
+ Copyright (c) 2025 Uploadcare Inc.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -405,7 +405,7 @@ const getUrl = (base, path, query) => {
405
405
  return url.toString();
406
406
  };
407
407
 
408
- var version = '6.17.0';
408
+ var version = '6.18.2';
409
409
 
410
410
  const LIBRARY_NAME = 'UploadcareUploadClient';
411
411
  const LIBRARY_VERSION = version;
@@ -1689,7 +1689,8 @@ class Queue {
1689
1689
  constructor(concurrency) {
1690
1690
  this._concurrency = concurrency;
1691
1691
  }
1692
- _run() {
1692
+ /** Run tasks from the queue up to the concurrency limit */
1693
+ run() {
1693
1694
  const tasksLeft = this._concurrency - this._running;
1694
1695
  for (let i = 0; i < tasksLeft; i++) {
1695
1696
  const task = this._pending.shift();
@@ -1706,18 +1707,30 @@ class Queue {
1706
1707
  this._resolvers.delete(task);
1707
1708
  this._rejectors.delete(task);
1708
1709
  this._running -= 1;
1709
- this._run();
1710
+ this.run();
1710
1711
  })
1711
1712
  .then((value) => resolver(value))
1712
1713
  .catch((error) => rejector(error));
1713
1714
  }
1714
1715
  }
1715
- add(task) {
1716
+ /**
1717
+ * Add a task to the queue
1718
+ *
1719
+ * If you want to add a lot of tasks at once, consider setting `autoRun` to
1720
+ * false and calling `run()` manually after adding all tasks to avoid multiple
1721
+ * redundant calls to `run()`.
1722
+ *
1723
+ * @param task The task to add
1724
+ * @param autoRun Whether to automatically run the queue after adding the task
1725
+ * (default: true)
1726
+ * @returns A promise that resolves or rejects with the task's result
1727
+ */
1728
+ add(task, { autoRun } = { autoRun: true }) {
1716
1729
  return new Promise((resolve, reject) => {
1717
1730
  this._resolvers.set(task, resolve);
1718
1731
  this._rejectors.set(task, reject);
1719
1732
  this._pending.push(task);
1720
- this._run();
1733
+ autoRun && this.run();
1721
1734
  });
1722
1735
  }
1723
1736
  get pending() {
@@ -1728,7 +1741,7 @@ class Queue {
1728
1741
  }
1729
1742
  set concurrency(value) {
1730
1743
  this._concurrency = value;
1731
- this._run();
1744
+ this.run();
1732
1745
  }
1733
1746
  get concurrency() {
1734
1747
  return this._concurrency;
@@ -507,8 +507,23 @@ export declare class Queue {
507
507
  private _resolvers;
508
508
  private _rejectors;
509
509
  constructor(concurrency: number);
510
- private _run;
511
- add<T>(task: Task<T>): Promise<T>;
510
+ /** Run tasks from the queue up to the concurrency limit */
511
+ run(): void;
512
+ /**
513
+ * Add a task to the queue
514
+ *
515
+ * If you want to add a lot of tasks at once, consider setting `autoRun` to
516
+ * false and calling `run()` manually after adding all tasks to avoid multiple
517
+ * redundant calls to `run()`.
518
+ *
519
+ * @param task The task to add
520
+ * @param autoRun Whether to automatically run the queue after adding the task
521
+ * (default: true)
522
+ * @returns A promise that resolves or rejects with the task's result
523
+ */
524
+ add<T>(task: Task<T>, { autoRun }?: {
525
+ autoRun?: boolean;
526
+ }): Promise<T>;
512
527
  get pending(): number;
513
528
  get running(): number;
514
529
  set concurrency(value: number);
@@ -435,7 +435,7 @@ const getUrl = (base, path, query) => {
435
435
  return url.toString();
436
436
  };
437
437
 
438
- var version = '6.17.0';
438
+ var version = '6.18.2';
439
439
 
440
440
  const LIBRARY_NAME = 'UploadcareUploadClient';
441
441
  const LIBRARY_VERSION = version;
@@ -1720,7 +1720,8 @@ class Queue {
1720
1720
  constructor(concurrency) {
1721
1721
  this._concurrency = concurrency;
1722
1722
  }
1723
- _run() {
1723
+ /** Run tasks from the queue up to the concurrency limit */
1724
+ run() {
1724
1725
  const tasksLeft = this._concurrency - this._running;
1725
1726
  for (let i = 0; i < tasksLeft; i++) {
1726
1727
  const task = this._pending.shift();
@@ -1737,18 +1738,30 @@ class Queue {
1737
1738
  this._resolvers.delete(task);
1738
1739
  this._rejectors.delete(task);
1739
1740
  this._running -= 1;
1740
- this._run();
1741
+ this.run();
1741
1742
  })
1742
1743
  .then((value) => resolver(value))
1743
1744
  .catch((error) => rejector(error));
1744
1745
  }
1745
1746
  }
1746
- add(task) {
1747
+ /**
1748
+ * Add a task to the queue
1749
+ *
1750
+ * If you want to add a lot of tasks at once, consider setting `autoRun` to
1751
+ * false and calling `run()` manually after adding all tasks to avoid multiple
1752
+ * redundant calls to `run()`.
1753
+ *
1754
+ * @param task The task to add
1755
+ * @param autoRun Whether to automatically run the queue after adding the task
1756
+ * (default: true)
1757
+ * @returns A promise that resolves or rejects with the task's result
1758
+ */
1759
+ add(task, { autoRun } = { autoRun: true }) {
1747
1760
  return new Promise((resolve, reject) => {
1748
1761
  this._resolvers.set(task, resolve);
1749
1762
  this._rejectors.set(task, reject);
1750
1763
  this._pending.push(task);
1751
- this._run();
1764
+ autoRun && this.run();
1752
1765
  });
1753
1766
  }
1754
1767
  get pending() {
@@ -1759,7 +1772,7 @@ class Queue {
1759
1772
  }
1760
1773
  set concurrency(value) {
1761
1774
  this._concurrency = value;
1762
- this._run();
1775
+ this.run();
1763
1776
  }
1764
1777
  get concurrency() {
1765
1778
  return this._concurrency;
@@ -507,8 +507,23 @@ export declare class Queue {
507
507
  private _resolvers;
508
508
  private _rejectors;
509
509
  constructor(concurrency: number);
510
- private _run;
511
- add<T>(task: Task<T>): Promise<T>;
510
+ /** Run tasks from the queue up to the concurrency limit */
511
+ run(): void;
512
+ /**
513
+ * Add a task to the queue
514
+ *
515
+ * If you want to add a lot of tasks at once, consider setting `autoRun` to
516
+ * false and calling `run()` manually after adding all tasks to avoid multiple
517
+ * redundant calls to `run()`.
518
+ *
519
+ * @param task The task to add
520
+ * @param autoRun Whether to automatically run the queue after adding the task
521
+ * (default: true)
522
+ * @returns A promise that resolves or rejects with the task's result
523
+ */
524
+ add<T>(task: Task<T>, { autoRun }?: {
525
+ autoRun?: boolean;
526
+ }): Promise<T>;
512
527
  get pending(): number;
513
528
  get running(): number;
514
529
  set concurrency(value: number);
@@ -413,7 +413,7 @@ const getUrl = (base, path, query) => {
413
413
  return url.toString();
414
414
  };
415
415
 
416
- var version = '6.17.0';
416
+ var version = '6.18.2';
417
417
 
418
418
  const LIBRARY_NAME = 'UploadcareUploadClient';
419
419
  const LIBRARY_VERSION = version;
@@ -1717,7 +1717,8 @@ class Queue {
1717
1717
  constructor(concurrency) {
1718
1718
  this._concurrency = concurrency;
1719
1719
  }
1720
- _run() {
1720
+ /** Run tasks from the queue up to the concurrency limit */
1721
+ run() {
1721
1722
  const tasksLeft = this._concurrency - this._running;
1722
1723
  for (let i = 0; i < tasksLeft; i++) {
1723
1724
  const task = this._pending.shift();
@@ -1734,18 +1735,30 @@ class Queue {
1734
1735
  this._resolvers.delete(task);
1735
1736
  this._rejectors.delete(task);
1736
1737
  this._running -= 1;
1737
- this._run();
1738
+ this.run();
1738
1739
  })
1739
1740
  .then((value) => resolver(value))
1740
1741
  .catch((error) => rejector(error));
1741
1742
  }
1742
1743
  }
1743
- add(task) {
1744
+ /**
1745
+ * Add a task to the queue
1746
+ *
1747
+ * If you want to add a lot of tasks at once, consider setting `autoRun` to
1748
+ * false and calling `run()` manually after adding all tasks to avoid multiple
1749
+ * redundant calls to `run()`.
1750
+ *
1751
+ * @param task The task to add
1752
+ * @param autoRun Whether to automatically run the queue after adding the task
1753
+ * (default: true)
1754
+ * @returns A promise that resolves or rejects with the task's result
1755
+ */
1756
+ add(task, { autoRun } = { autoRun: true }) {
1744
1757
  return new Promise((resolve, reject) => {
1745
1758
  this._resolvers.set(task, resolve);
1746
1759
  this._rejectors.set(task, reject);
1747
1760
  this._pending.push(task);
1748
- this._run();
1761
+ autoRun && this.run();
1749
1762
  });
1750
1763
  }
1751
1764
  get pending() {
@@ -1756,7 +1769,7 @@ class Queue {
1756
1769
  }
1757
1770
  set concurrency(value) {
1758
1771
  this._concurrency = value;
1759
- this._run();
1772
+ this.run();
1760
1773
  }
1761
1774
  get concurrency() {
1762
1775
  return this._concurrency;
@@ -507,8 +507,23 @@ export declare class Queue {
507
507
  private _resolvers;
508
508
  private _rejectors;
509
509
  constructor(concurrency: number);
510
- private _run;
511
- add<T>(task: Task<T>): Promise<T>;
510
+ /** Run tasks from the queue up to the concurrency limit */
511
+ run(): void;
512
+ /**
513
+ * Add a task to the queue
514
+ *
515
+ * If you want to add a lot of tasks at once, consider setting `autoRun` to
516
+ * false and calling `run()` manually after adding all tasks to avoid multiple
517
+ * redundant calls to `run()`.
518
+ *
519
+ * @param task The task to add
520
+ * @param autoRun Whether to automatically run the queue after adding the task
521
+ * (default: true)
522
+ * @returns A promise that resolves or rejects with the task's result
523
+ */
524
+ add<T>(task: Task<T>, { autoRun }?: {
525
+ autoRun?: boolean;
526
+ }): Promise<T>;
512
527
  get pending(): number;
513
528
  get running(): number;
514
529
  set concurrency(value: number);
@@ -507,8 +507,23 @@ export declare class Queue {
507
507
  private _resolvers;
508
508
  private _rejectors;
509
509
  constructor(concurrency: number);
510
- private _run;
511
- add<T>(task: Task<T>): Promise<T>;
510
+ /** Run tasks from the queue up to the concurrency limit */
511
+ run(): void;
512
+ /**
513
+ * Add a task to the queue
514
+ *
515
+ * If you want to add a lot of tasks at once, consider setting `autoRun` to
516
+ * false and calling `run()` manually after adding all tasks to avoid multiple
517
+ * redundant calls to `run()`.
518
+ *
519
+ * @param task The task to add
520
+ * @param autoRun Whether to automatically run the queue after adding the task
521
+ * (default: true)
522
+ * @returns A promise that resolves or rejects with the task's result
523
+ */
524
+ add<T>(task: Task<T>, { autoRun }?: {
525
+ autoRun?: boolean;
526
+ }): Promise<T>;
512
527
  get pending(): number;
513
528
  get running(): number;
514
529
  set concurrency(value: number);
@@ -403,7 +403,7 @@ const getUrl = (base, path, query) => {
403
403
  return url.toString();
404
404
  };
405
405
 
406
- var version = '6.17.0';
406
+ var version = '6.18.2';
407
407
 
408
408
  const LIBRARY_NAME = 'UploadcareUploadClient';
409
409
  const LIBRARY_VERSION = version;
@@ -1687,7 +1687,8 @@ class Queue {
1687
1687
  constructor(concurrency) {
1688
1688
  this._concurrency = concurrency;
1689
1689
  }
1690
- _run() {
1690
+ /** Run tasks from the queue up to the concurrency limit */
1691
+ run() {
1691
1692
  const tasksLeft = this._concurrency - this._running;
1692
1693
  for (let i = 0; i < tasksLeft; i++) {
1693
1694
  const task = this._pending.shift();
@@ -1704,18 +1705,30 @@ class Queue {
1704
1705
  this._resolvers.delete(task);
1705
1706
  this._rejectors.delete(task);
1706
1707
  this._running -= 1;
1707
- this._run();
1708
+ this.run();
1708
1709
  })
1709
1710
  .then((value) => resolver(value))
1710
1711
  .catch((error) => rejector(error));
1711
1712
  }
1712
1713
  }
1713
- add(task) {
1714
+ /**
1715
+ * Add a task to the queue
1716
+ *
1717
+ * If you want to add a lot of tasks at once, consider setting `autoRun` to
1718
+ * false and calling `run()` manually after adding all tasks to avoid multiple
1719
+ * redundant calls to `run()`.
1720
+ *
1721
+ * @param task The task to add
1722
+ * @param autoRun Whether to automatically run the queue after adding the task
1723
+ * (default: true)
1724
+ * @returns A promise that resolves or rejects with the task's result
1725
+ */
1726
+ add(task, { autoRun } = { autoRun: true }) {
1714
1727
  return new Promise((resolve, reject) => {
1715
1728
  this._resolvers.set(task, resolve);
1716
1729
  this._rejectors.set(task, reject);
1717
1730
  this._pending.push(task);
1718
- this._run();
1731
+ autoRun && this.run();
1719
1732
  });
1720
1733
  }
1721
1734
  get pending() {
@@ -1726,7 +1739,7 @@ class Queue {
1726
1739
  }
1727
1740
  set concurrency(value) {
1728
1741
  this._concurrency = value;
1729
- this._run();
1742
+ this.run();
1730
1743
  }
1731
1744
  get concurrency() {
1732
1745
  return this._concurrency;
@@ -507,8 +507,23 @@ export declare class Queue {
507
507
  private _resolvers;
508
508
  private _rejectors;
509
509
  constructor(concurrency: number);
510
- private _run;
511
- add<T>(task: Task<T>): Promise<T>;
510
+ /** Run tasks from the queue up to the concurrency limit */
511
+ run(): void;
512
+ /**
513
+ * Add a task to the queue
514
+ *
515
+ * If you want to add a lot of tasks at once, consider setting `autoRun` to
516
+ * false and calling `run()` manually after adding all tasks to avoid multiple
517
+ * redundant calls to `run()`.
518
+ *
519
+ * @param task The task to add
520
+ * @param autoRun Whether to automatically run the queue after adding the task
521
+ * (default: true)
522
+ * @returns A promise that resolves or rejects with the task's result
523
+ */
524
+ add<T>(task: Task<T>, { autoRun }?: {
525
+ autoRun?: boolean;
526
+ }): Promise<T>;
512
527
  get pending(): number;
513
528
  get running(): number;
514
529
  set concurrency(value: number);
@@ -433,7 +433,7 @@ const getUrl = (base, path, query) => {
433
433
  return url.toString();
434
434
  };
435
435
 
436
- var version = '6.17.0';
436
+ var version = '6.18.2';
437
437
 
438
438
  const LIBRARY_NAME = 'UploadcareUploadClient';
439
439
  const LIBRARY_VERSION = version;
@@ -1718,7 +1718,8 @@ class Queue {
1718
1718
  constructor(concurrency) {
1719
1719
  this._concurrency = concurrency;
1720
1720
  }
1721
- _run() {
1721
+ /** Run tasks from the queue up to the concurrency limit */
1722
+ run() {
1722
1723
  const tasksLeft = this._concurrency - this._running;
1723
1724
  for (let i = 0; i < tasksLeft; i++) {
1724
1725
  const task = this._pending.shift();
@@ -1735,18 +1736,30 @@ class Queue {
1735
1736
  this._resolvers.delete(task);
1736
1737
  this._rejectors.delete(task);
1737
1738
  this._running -= 1;
1738
- this._run();
1739
+ this.run();
1739
1740
  })
1740
1741
  .then((value) => resolver(value))
1741
1742
  .catch((error) => rejector(error));
1742
1743
  }
1743
1744
  }
1744
- add(task) {
1745
+ /**
1746
+ * Add a task to the queue
1747
+ *
1748
+ * If you want to add a lot of tasks at once, consider setting `autoRun` to
1749
+ * false and calling `run()` manually after adding all tasks to avoid multiple
1750
+ * redundant calls to `run()`.
1751
+ *
1752
+ * @param task The task to add
1753
+ * @param autoRun Whether to automatically run the queue after adding the task
1754
+ * (default: true)
1755
+ * @returns A promise that resolves or rejects with the task's result
1756
+ */
1757
+ add(task, { autoRun } = { autoRun: true }) {
1745
1758
  return new Promise((resolve, reject) => {
1746
1759
  this._resolvers.set(task, resolve);
1747
1760
  this._rejectors.set(task, reject);
1748
1761
  this._pending.push(task);
1749
- this._run();
1762
+ autoRun && this.run();
1750
1763
  });
1751
1764
  }
1752
1765
  get pending() {
@@ -1757,7 +1770,7 @@ class Queue {
1757
1770
  }
1758
1771
  set concurrency(value) {
1759
1772
  this._concurrency = value;
1760
- this._run();
1773
+ this.run();
1761
1774
  }
1762
1775
  get concurrency() {
1763
1776
  return this._concurrency;
@@ -507,8 +507,23 @@ export declare class Queue {
507
507
  private _resolvers;
508
508
  private _rejectors;
509
509
  constructor(concurrency: number);
510
- private _run;
511
- add<T>(task: Task<T>): Promise<T>;
510
+ /** Run tasks from the queue up to the concurrency limit */
511
+ run(): void;
512
+ /**
513
+ * Add a task to the queue
514
+ *
515
+ * If you want to add a lot of tasks at once, consider setting `autoRun` to
516
+ * false and calling `run()` manually after adding all tasks to avoid multiple
517
+ * redundant calls to `run()`.
518
+ *
519
+ * @param task The task to add
520
+ * @param autoRun Whether to automatically run the queue after adding the task
521
+ * (default: true)
522
+ * @returns A promise that resolves or rejects with the task's result
523
+ */
524
+ add<T>(task: Task<T>, { autoRun }?: {
525
+ autoRun?: boolean;
526
+ }): Promise<T>;
512
527
  get pending(): number;
513
528
  get running(): number;
514
529
  set concurrency(value: number);
@@ -411,7 +411,7 @@ const getUrl = (base, path, query) => {
411
411
  return url.toString();
412
412
  };
413
413
 
414
- var version = '6.17.0';
414
+ var version = '6.18.2';
415
415
 
416
416
  const LIBRARY_NAME = 'UploadcareUploadClient';
417
417
  const LIBRARY_VERSION = version;
@@ -1715,7 +1715,8 @@ class Queue {
1715
1715
  constructor(concurrency) {
1716
1716
  this._concurrency = concurrency;
1717
1717
  }
1718
- _run() {
1718
+ /** Run tasks from the queue up to the concurrency limit */
1719
+ run() {
1719
1720
  const tasksLeft = this._concurrency - this._running;
1720
1721
  for (let i = 0; i < tasksLeft; i++) {
1721
1722
  const task = this._pending.shift();
@@ -1732,18 +1733,30 @@ class Queue {
1732
1733
  this._resolvers.delete(task);
1733
1734
  this._rejectors.delete(task);
1734
1735
  this._running -= 1;
1735
- this._run();
1736
+ this.run();
1736
1737
  })
1737
1738
  .then((value) => resolver(value))
1738
1739
  .catch((error) => rejector(error));
1739
1740
  }
1740
1741
  }
1741
- add(task) {
1742
+ /**
1743
+ * Add a task to the queue
1744
+ *
1745
+ * If you want to add a lot of tasks at once, consider setting `autoRun` to
1746
+ * false and calling `run()` manually after adding all tasks to avoid multiple
1747
+ * redundant calls to `run()`.
1748
+ *
1749
+ * @param task The task to add
1750
+ * @param autoRun Whether to automatically run the queue after adding the task
1751
+ * (default: true)
1752
+ * @returns A promise that resolves or rejects with the task's result
1753
+ */
1754
+ add(task, { autoRun } = { autoRun: true }) {
1742
1755
  return new Promise((resolve, reject) => {
1743
1756
  this._resolvers.set(task, resolve);
1744
1757
  this._rejectors.set(task, reject);
1745
1758
  this._pending.push(task);
1746
- this._run();
1759
+ autoRun && this.run();
1747
1760
  });
1748
1761
  }
1749
1762
  get pending() {
@@ -1754,7 +1767,7 @@ class Queue {
1754
1767
  }
1755
1768
  set concurrency(value) {
1756
1769
  this._concurrency = value;
1757
- this._run();
1770
+ this.run();
1758
1771
  }
1759
1772
  get concurrency() {
1760
1773
  return this._concurrency;
package/dist/index.d.ts CHANGED
@@ -507,8 +507,23 @@ export declare class Queue {
507
507
  private _resolvers;
508
508
  private _rejectors;
509
509
  constructor(concurrency: number);
510
- private _run;
511
- add<T>(task: Task<T>): Promise<T>;
510
+ /** Run tasks from the queue up to the concurrency limit */
511
+ run(): void;
512
+ /**
513
+ * Add a task to the queue
514
+ *
515
+ * If you want to add a lot of tasks at once, consider setting `autoRun` to
516
+ * false and calling `run()` manually after adding all tasks to avoid multiple
517
+ * redundant calls to `run()`.
518
+ *
519
+ * @param task The task to add
520
+ * @param autoRun Whether to automatically run the queue after adding the task
521
+ * (default: true)
522
+ * @returns A promise that resolves or rejects with the task's result
523
+ */
524
+ add<T>(task: Task<T>, { autoRun }?: {
525
+ autoRun?: boolean;
526
+ }): Promise<T>;
512
527
  get pending(): number;
513
528
  get running(): number;
514
529
  set concurrency(value: number);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uploadcare/upload-client",
3
- "version": "6.17.0",
3
+ "version": "6.18.2",
4
4
  "description": "Library for work with Uploadcare Upload API",
5
5
  "type": "module",
6
6
  "module": "./dist/esm/index.node.mjs",
@@ -83,7 +83,7 @@
83
83
  "@types/koa__cors": "^5.0.0",
84
84
  "@types/koa__router": "^12.0.4",
85
85
  "@types/ws": "8.5.3",
86
- "@uploadcare/api-client-utils": "^6.17.0",
86
+ "@uploadcare/api-client-utils": "^6.18.2",
87
87
  "chalk": "^4.1.2",
88
88
  "data-uri-to-buffer": "3.0.1",
89
89
  "dataurl-to-blob": "0.0.1",