yungle-client 0.3.1 → 0.3.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/README.md CHANGED
@@ -85,12 +85,12 @@ refused. No public URL? Create the endpoint with `url: null` and poll `listWebho
85
85
 
86
86
  Your vault and end-to-end encrypted transfers, because their keys are derived in
87
87
  the client and never sent to Yungle. See
88
- <https://yungle.co/developers/unsupported>.
88
+ <https://docs.yungle.co/unsupported>.
89
89
 
90
90
  ## Related
91
91
 
92
92
  - [`yungle-cli`](https://www.npmjs.com/package/yungle-cli) — resumable uploads from your terminal
93
93
  - [`yungle-mcp`](https://www.npmjs.com/package/yungle-mcp) — connect Claude or Cursor to Yungle
94
- - [API reference](https://yungle.co/developers/reference?ref=npm) · [OpenAPI spec](https://yungle.co/api/v1/openapi.json)
94
+ - [API reference](https://docs.yungle.co/api-reference?ref=npm) · [OpenAPI spec](https://yungle.co/api/v1/openapi.json)
95
95
 
96
96
  MIT
package/dist/index.mjs CHANGED
@@ -220,7 +220,7 @@ function pageQuery(page, extra = {}) {
220
220
  const q = params.toString();
221
221
  return q ? `?${q}` : "";
222
222
  }
223
- var CLIENT_VERSION = true ? "0.3.1" : "dev";
223
+ var CLIENT_VERSION = true ? "0.3.2" : "dev";
224
224
  var YungleClient = class {
225
225
  baseUrl;
226
226
  apiKey;
@@ -508,22 +508,31 @@ var YungleClient = class {
508
508
  const safe = method === "GET" || method === "DELETE" || idempotencyKey !== void 0 || opts?.idempotent === true;
509
509
  let attempt = 0;
510
510
  for (; ; ) {
511
- const res = await this.doFetch(`${this.baseUrl}${path}`, {
512
- method,
513
- headers: {
514
- Authorization: `Bearer ${this.apiKey}`,
515
- Accept: "application/json",
516
- "User-Agent": this.userAgent,
517
- ...idempotencyKey ? { "Idempotency-Key": idempotencyKey } : {},
518
- ...body === void 0 ? {} : { "Content-Type": "application/json" }
519
- },
520
- ...body === void 0 ? {} : { body: JSON.stringify(body) }
521
- });
511
+ let res;
512
+ try {
513
+ res = await this.doFetch(`${this.baseUrl}${path}`, {
514
+ method,
515
+ headers: {
516
+ Authorization: `Bearer ${this.apiKey}`,
517
+ Accept: "application/json",
518
+ "User-Agent": this.userAgent,
519
+ ...idempotencyKey ? { "Idempotency-Key": idempotencyKey } : {},
520
+ ...body === void 0 ? {} : { "Content-Type": "application/json" }
521
+ },
522
+ ...body === void 0 ? {} : { body: JSON.stringify(body) }
523
+ });
524
+ } catch (err) {
525
+ const aborted = err instanceof Error && (err.name === "AbortError" || err.name === "TimeoutError");
526
+ if (aborted || !safe || attempt >= this.maxRetries) throw err;
527
+ await sleep(backoffMs(attempt, null));
528
+ attempt++;
529
+ continue;
530
+ }
522
531
  if (res.ok) return await res.json();
523
532
  const error = await toError(res);
524
533
  const mayRetry = error.status === 429 || safe && error.retryable;
525
534
  if (!mayRetry || attempt >= this.maxRetries) throw error;
526
- await sleep(backoffMs(attempt, error));
535
+ await sleep(backoffMs(attempt, error.retryAfterSeconds));
527
536
  attempt++;
528
537
  }
529
538
  }
@@ -559,8 +568,7 @@ function parseRetryAfter(value, now = Date.now()) {
559
568
  const seconds = Math.ceil((at - now) / 1e3);
560
569
  return seconds >= 0 ? seconds : null;
561
570
  }
562
- function backoffMs(attempt, error) {
563
- const stated = error.retryAfterSeconds;
571
+ function backoffMs(attempt, stated) {
564
572
  if (stated !== null) return stated * 1e3;
565
573
  return Math.min(2 ** attempt * 500, 8e3) + Math.floor(Math.random() * 250);
566
574
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yungle-client",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -22,7 +22,7 @@
22
22
  "type": "git",
23
23
  "url": "git+https://github.com/heindewilde/yungle-clients.git"
24
24
  },
25
- "homepage": "https://yungle.co/developers/reference?ref=npm",
25
+ "homepage": "https://docs.yungle.co/api-reference?ref=npm",
26
26
  "bugs": {
27
27
  "url": "https://github.com/heindewilde/yungle-clients/issues"
28
28
  },