abysshub 0.1.2-dev.7 → 0.1.2-dev.9

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/client.d.ts CHANGED
@@ -1,5 +1,15 @@
1
1
  import { Run } from "./run.js";
2
2
  import type { Input, Key, RunList, Upload, Widget } from "./types.js";
3
+ /** The pause between two re-attaches that both ended without the run's ending. */
4
+ export declare const REATTACH_PAUSE_MS = 1000;
5
+ /** The first pause before a retry after a drop or a 5xx; it doubles with each retry. */
6
+ export declare const RETRY_PAUSE_MS = 500;
7
+ /** The longest pause between two tries, which only re-attaching, with no limit, reaches. */
8
+ export declare const RETRY_PAUSE_CEILING_MS = 10000;
9
+ /** How the client waits out every pause between two tries. Only the tests replace `sleep`, so as not to wait the real pauses. */
10
+ export declare const pausing: {
11
+ sleep: typeof sleep;
12
+ };
3
13
  export interface AbyssOptions {
4
14
  /** Defaults to `ABYSS_API_KEY`. */
5
15
  apiKey?: string;
@@ -76,3 +86,6 @@ export declare class Abyss {
76
86
  /** Answers the API Key making the call, with `GET /v1/key`. */
77
87
  key(options?: CallOptions): Promise<Key>;
78
88
  }
89
+ /** Waits `ms`, or rejects as soon as `signal` aborts. */
90
+ declare function sleep(ms: number, signal: AbortSignal | null): Promise<void>;
91
+ export {};
package/dist/client.js CHANGED
@@ -9,11 +9,13 @@ const DEV_KEY_PREFIX = "abyss_sk_dev_";
9
9
  /** A `Location` naming a run, `…/v1/runs/{id}`, with the id as its group. */
10
10
  const RUN_LOCATION = /\/v1\/runs\/([^/?#]+)\/?(?:[?#]|$)/;
11
11
  /** The pause between two re-attaches that both ended without the run's ending. */
12
- const REATTACH_PAUSE_MS = 1_000;
12
+ export const REATTACH_PAUSE_MS = 1_000;
13
13
  /** The first pause before a retry after a drop or a 5xx; it doubles with each retry. */
14
- const RETRY_PAUSE_MS = 500;
14
+ export const RETRY_PAUSE_MS = 500;
15
15
  /** The longest pause between two tries, which only re-attaching, with no limit, reaches. */
16
- const RETRY_PAUSE_CEILING_MS = 10_000;
16
+ export const RETRY_PAUSE_CEILING_MS = 10_000;
17
+ /** How the client waits out every pause between two tries. Only the tests replace `sleep`, so as not to wait the real pauses. */
18
+ export const pausing = { sleep };
17
19
  const BROWSER_REFUSAL = "An Abyss API key is a server-side secret. Call the API from your server.";
18
20
  const USER_AGENT = `abysshub-js/${VERSION} (${runtime()})`;
19
21
  export class Abyss {
@@ -194,7 +196,7 @@ export class Abyss {
194
196
  async #hold(call, url, done) {
195
197
  let reply = await this.#send(call, "GET", url, {}, undefined, Infinity);
196
198
  while (!done(reply)) {
197
- await sleep(REATTACH_PAUSE_MS, call.signal);
199
+ await pausing.sleep(REATTACH_PAUSE_MS, call.signal);
198
200
  reply = await this.#send(call, "GET", url, {}, undefined, Infinity);
199
201
  }
200
202
  return reply;
@@ -249,7 +251,7 @@ export class Abyss {
249
251
  cause: error,
250
252
  });
251
253
  }
252
- await sleep(backoff(attempt), call.signal);
254
+ await pausing.sleep(backoff(attempt), call.signal);
253
255
  continue;
254
256
  }
255
257
  const requestId = answer.headers.get("request-id");
@@ -266,7 +268,7 @@ export class Abyss {
266
268
  const pause = retryPause(answer, attempt);
267
269
  if (pause === null || attempt >= retries)
268
270
  throw refusal(answer.status, parsed, requestId, call.runId);
269
- await sleep(pause, call.signal);
271
+ await pausing.sleep(pause, call.signal);
270
272
  }
271
273
  }
272
274
  }
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  /** This package's version, written from package.json by scripts/version.js at build. */
2
- export declare const VERSION = "0.1.2-dev.7";
2
+ export declare const VERSION = "0.1.2-dev.9";
package/dist/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  /** This package's version, written from package.json by scripts/version.js at build. */
2
- export const VERSION = "0.1.2-dev.7";
2
+ export const VERSION = "0.1.2-dev.9";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "abysshub",
3
- "version": "0.1.2-dev.7",
3
+ "version": "0.1.2-dev.9",
4
4
  "description": "The official JavaScript library for the Abyss API.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/Abysshub/abysshub-sdk/tree/main/js#readme",