@tribulnation/terminal 0.0.0-stage → 0.1.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/dist/errors.js ADDED
@@ -0,0 +1,143 @@
1
+ const SECRET_RE = /tn_(?:key|pat)_[A-Za-z0-9_-]+/g;
2
+ // C0 and C1 control characters but tab and newline: a server string printed as is could
3
+ // drive a terminal.
4
+ // eslint-disable-next-line no-control-regex
5
+ const CONTROL_RE = /[\x00-\x08\x0b-\x1f\x7f-\x9f]/g;
6
+ /** Text with anything shaped like a key or token cut out, and no control characters. */
7
+ export function scrub(text) {
8
+ return text.replace(SECRET_RE, 'tn_…[hidden]').replace(CONTROL_RE, '');
9
+ }
10
+ /** The base of every error this client throws. */
11
+ export class TerminalError extends Error {
12
+ constructor(message) {
13
+ super(scrub(message));
14
+ this.name = new.target.name;
15
+ }
16
+ }
17
+ /** The API answered an error (`status` 4xx or 5xx). */
18
+ export class ApiError extends TerminalError {
19
+ /** The HTTP status. */
20
+ status;
21
+ /** The envelope's `error.code` (`'error'` when the body had none). */
22
+ code;
23
+ /** Per-parameter complaints of a 400. */
24
+ details;
25
+ /** `Retry-After`, seconds (429, 503 `warming`). */
26
+ retryAfter;
27
+ constructor(message, init) {
28
+ super(message);
29
+ this.status = init.status;
30
+ this.code = init.code ?? 'error';
31
+ if (init.details)
32
+ this.details = init.details;
33
+ if (init.retryAfter !== undefined)
34
+ this.retryAfter = init.retryAfter;
35
+ }
36
+ toString() {
37
+ return `${this.name}(${this.status} ${this.code}: ${this.message})`;
38
+ }
39
+ }
40
+ /** 400: a parameter the API refuses (`details` names it). */
41
+ export class BadRequest extends ApiError {
42
+ }
43
+ /** 401: no key, or the key is invalid, expired or revoked. */
44
+ export class AuthError extends ApiError {
45
+ }
46
+ /** 403: the key lacks the scope (`market:read`), or the plan leaves the data out. An
47
+ * `AuthError`, as in the Python client. */
48
+ export class Forbidden extends AuthError {
49
+ }
50
+ /** 404: no such route or resource (someone else's plot is 404 too). */
51
+ export class NotFound extends ApiError {
52
+ }
53
+ /** 429: too many requests; `retryAfter` says how long to wait. */
54
+ export class RateLimited extends ApiError {
55
+ }
56
+ /** 502, 503 or 504: the service (or what it reads) did not answer; `warming` is a live
57
+ * snapshot being built. */
58
+ export class Unavailable extends ApiError {
59
+ }
60
+ /** No answer: unreachable, timed out, or not JSON. */
61
+ export class NetworkError extends TerminalError {
62
+ }
63
+ /** The API answered a redirect. It is never followed: the key would go along. A
64
+ * `NetworkError`, as in the Python client. */
65
+ export class Redirected extends NetworkError {
66
+ }
67
+ /** No key: none passed and no `TN_API_KEY`. Thrown before anything is sent; an `AuthError`
68
+ * (`status` 401, `code` `'unauthorized'`), as in the Python client. */
69
+ export class NotLoggedIn extends AuthError {
70
+ constructor(message) {
71
+ super(message, { status: 401, code: 'unauthorized' });
72
+ }
73
+ }
74
+ /** The live socket was ended for good: `code` 4401 (revoked key), 4003 (topic not in the
75
+ * plan) or 4004 (unknown topic). */
76
+ export class LiveClosed extends TerminalError {
77
+ code;
78
+ reason;
79
+ constructor(code, reason) {
80
+ super(`live socket closed ${code}: ${reason}`);
81
+ this.code = code;
82
+ this.reason = reason;
83
+ }
84
+ }
85
+ /** The error class of an HTTP status. */
86
+ export function errorClass(status) {
87
+ switch (status) {
88
+ case 400:
89
+ return BadRequest;
90
+ case 401:
91
+ return AuthError;
92
+ case 403:
93
+ return Forbidden;
94
+ case 404:
95
+ return NotFound;
96
+ case 429:
97
+ return RateLimited;
98
+ case 502:
99
+ case 503:
100
+ case 504:
101
+ return Unavailable;
102
+ default:
103
+ return ApiError;
104
+ }
105
+ }
106
+ /** `Retry-After` in seconds, or undefined (a date or garbage is ignored). */
107
+ export function retryAfterSeconds(header) {
108
+ if (header == null || header.trim() === '')
109
+ return undefined;
110
+ const n = Number(header);
111
+ return Number.isFinite(n) && n >= 0 ? n : undefined;
112
+ }
113
+ /** The error an error answer means: this API's envelope, or an OAuth error body. */
114
+ export function apiErrorFrom(status, body, retryAfter) {
115
+ let code = 'error';
116
+ let message = `HTTP ${status}`;
117
+ let details;
118
+ if (body !== null && typeof body === 'object') {
119
+ const b = body;
120
+ const error = b.error;
121
+ if (error !== null && typeof error === 'object') {
122
+ const e = error;
123
+ if (e.code)
124
+ code = String(e.code);
125
+ if (e.message)
126
+ message = String(e.message);
127
+ if (e.details && typeof e.details === 'object') {
128
+ details = Object.fromEntries(Object.entries(e.details).map(([k, v]) => [
129
+ k,
130
+ scrub(String(v))
131
+ ]));
132
+ }
133
+ }
134
+ else if (typeof error === 'string') {
135
+ code = error;
136
+ const text = b.error_description ?? b.detail;
137
+ if (text)
138
+ message = String(text);
139
+ }
140
+ }
141
+ const Cls = errorClass(status);
142
+ return new Cls(message, { status, code, details, retryAfter: retryAfterSeconds(retryAfter) });
143
+ }
@@ -0,0 +1,51 @@
1
+ /**
2
+ * `@tribulnation/terminal`: the Tribulnation Terminal API, typed. Read-only; one `tn_key_`
3
+ * key; the wire JSON as the API sends it (a decimal is a string, `Decimal`).
4
+ *
5
+ * ```ts
6
+ * import { Terminal } from '@tribulnation/terminal'
7
+ * const t = new Terminal() // reads TN_API_KEY
8
+ * const prices = await t.v1.prices.latest({ assets: ['bitcoin', 'ethereum'] })
9
+ * ```
10
+ */
11
+ import { type Params, type TerminalOptions } from './client.js';
12
+ import { type LiveApi } from './live.js';
13
+ import { type MeApi } from './me.js';
14
+ import { type V1Api } from './v1.js';
15
+ import { type V2Api } from './v2.js';
16
+ /** The Terminal API client: your own data (`me`, scope `me:read`) and market data (`v1`,
17
+ * `v2`, `live`, scope `market:read`, Ultra), read-only, with one `tn_key_` key. */
18
+ export declare class Terminal {
19
+ #private;
20
+ /** `/me`: the key, your accounts, profiles, portfolio, positions, saved plots. */
21
+ readonly me: MeApi;
22
+ /** `/v1`: assets, prices, candles, market data, earn, directories, search. */
23
+ readonly v1: V1Api;
24
+ /** `/v2`: published series and snapshots. */
25
+ readonly v2: V2Api;
26
+ /** `/live`: funding profile, fresh order books and asset snapshots, the live socket. */
27
+ readonly live: LiveApi;
28
+ constructor(opts?: TerminalOptions);
29
+ /** A client (as `new Terminal(opts)`; mirrors Python's `Terminal.new()`). */
30
+ static new(opts?: TerminalOptions): Terminal;
31
+ /** The API host this client reads. */
32
+ get baseUrl(): string;
33
+ /** Any read the API serves to this key, by path (`/me…`, `/v1/…`, `/v2/…`, `/live/…`), as
34
+ * the JSON the server sent: for endpoints this client has no method for.
35
+ *
36
+ * ```ts
37
+ * await t.get('/v2/series/corrections')
38
+ * ``` */
39
+ get<T = unknown>(path: string, params?: Params): Promise<T>;
40
+ }
41
+ export type { Answer } from './answer.js';
42
+ export { DEFAULT_BASE_URL, VERSION, type Instant, type Params, type QueryValue, type TerminalOptions } from './client.js';
43
+ export { ApiError, AuthError, BadRequest, Forbidden, LiveClosed, NetworkError, NotFound, NotLoggedIn, RateLimited, Redirected, TerminalError, Unavailable, scrub } from './errors.js';
44
+ export { WARMING_WAIT_S, type LiveApi, type LiveFundingApi, type Pair } from './live.js';
45
+ export { DEFAULT_BACKOFF, type Backoff, type StreamOptions, type WebSocketInstance, type WebSocketLike } from './livestream.js';
46
+ export type { ActivityOptions, ChartsApi, MeApi, PortfolioApi, Window } from './me.js';
47
+ export { nextCursor, pages } from './pages.js';
48
+ export type * from './types.gen.js';
49
+ export { API_ERROR_STATUS, LIVE_CLOSE } from './types.gen.js';
50
+ export type { AssetsApi, CandlesOptions, Currency, DirectoryApi, EarnApi, Ids, MarketApi, PricesApi, V1Api } from './v1.js';
51
+ export type { AnySeriesId, AnySnapshotId, SeriesApi, SeriesContract, SeriesInstance, SeriesRecord, SnapshotContract, SnapshotRecord, SnapshotsApi, V2Api, V2Filters, V2Page, V2Read } from './v2.js';
package/dist/index.js ADDED
@@ -0,0 +1,58 @@
1
+ /**
2
+ * `@tribulnation/terminal`: the Tribulnation Terminal API, typed. Read-only; one `tn_key_`
3
+ * key; the wire JSON as the API sends it (a decimal is a string, `Decimal`).
4
+ *
5
+ * ```ts
6
+ * import { Terminal } from '@tribulnation/terminal'
7
+ * const t = new Terminal() // reads TN_API_KEY
8
+ * const prices = await t.v1.prices.latest({ assets: ['bitcoin', 'ethereum'] })
9
+ * ```
10
+ */
11
+ import { checkPath, Transport } from "./client.js";
12
+ import { liveApi } from "./live.js";
13
+ import { meApi } from "./me.js";
14
+ import { v1Api } from "./v1.js";
15
+ import { v2Api } from "./v2.js";
16
+ /** The Terminal API client: your own data (`me`, scope `me:read`) and market data (`v1`,
17
+ * `v2`, `live`, scope `market:read`, Ultra), read-only, with one `tn_key_` key. */
18
+ export class Terminal {
19
+ #http;
20
+ /** `/me`: the key, your accounts, profiles, portfolio, positions, saved plots. */
21
+ me;
22
+ /** `/v1`: assets, prices, candles, market data, earn, directories, search. */
23
+ v1;
24
+ /** `/v2`: published series and snapshots. */
25
+ v2;
26
+ /** `/live`: funding profile, fresh order books and asset snapshots, the live socket. */
27
+ live;
28
+ constructor(opts = {}) {
29
+ this.#http = new Transport(opts);
30
+ this.me = meApi(this.#http);
31
+ this.v1 = v1Api(this.#http);
32
+ this.v2 = v2Api(this.#http);
33
+ this.live = liveApi(this.#http);
34
+ }
35
+ /** A client (as `new Terminal(opts)`; mirrors Python's `Terminal.new()`). */
36
+ static new(opts = {}) {
37
+ return new Terminal(opts);
38
+ }
39
+ /** The API host this client reads. */
40
+ get baseUrl() {
41
+ return this.#http.baseUrl;
42
+ }
43
+ /** Any read the API serves to this key, by path (`/me…`, `/v1/…`, `/v2/…`, `/live/…`), as
44
+ * the JSON the server sent: for endpoints this client has no method for.
45
+ *
46
+ * ```ts
47
+ * await t.get('/v2/series/corrections')
48
+ * ``` */
49
+ get(path, params) {
50
+ return this.#http.get(checkPath(path), params);
51
+ }
52
+ }
53
+ export { DEFAULT_BASE_URL, VERSION } from "./client.js";
54
+ export { ApiError, AuthError, BadRequest, Forbidden, LiveClosed, NetworkError, NotFound, NotLoggedIn, RateLimited, Redirected, TerminalError, Unavailable, scrub } from "./errors.js";
55
+ export { WARMING_WAIT_S } from "./live.js";
56
+ export { DEFAULT_BACKOFF } from "./livestream.js";
57
+ export { nextCursor, pages } from "./pages.js";
58
+ export { API_ERROR_STATUS, LIVE_CLOSE } from "./types.gen.js";
package/dist/live.d.ts ADDED
@@ -0,0 +1,74 @@
1
+ /**
2
+ * `/live`: live market data on the API host (scope `market:read`, Ultra): reads, fresh
3
+ * order book and asset snapshots, and the live socket (`stream`, `livestream.ts`).
4
+ */
5
+ import type { Answer } from './answer.js';
6
+ import { type Instant, type Transport } from './client.js';
7
+ import { type StreamOptions } from './livestream.js';
8
+ import type { LiveFrame, LiveTopic } from './types.gen.js';
9
+ /** How long `book` and `asset` retry a `warming` answer by default, seconds. */
10
+ export declare const WARMING_WAIT_S = 10;
11
+ /** A `pair` of the funding and spread reads: `<asset>|<exchange A>|<exchange B>`. */
12
+ export type Pair = string;
13
+ export type LiveFundingApi = {
14
+ /** Funding spreads of the perp pairs the plan sees (`GET /live/funding`). */
15
+ (): Promise<Answer<'get_live_funding'>>;
16
+ /** One pair's hourly funding, spread and cumulative carry over 30 days
17
+ * (`GET /live/funding/history`). */
18
+ history(pair: Pair): Promise<Answer<'get_live_funding_history'>>;
19
+ /** Per asset, the perp whose funding pays a short the most (`GET /live/funding/perps`). */
20
+ perps(): Promise<Answer<'get_live_funding_perps'>>;
21
+ };
22
+ export type LiveApi = {
23
+ /** How a perpetual's funding, index and mark work and where they stand
24
+ * (`GET /live/profile`). `window` (with `venue` and `market`) adds one market's history. */
25
+ profile(asset: string, opts?: {
26
+ venue?: string;
27
+ market?: string;
28
+ window?: '1d' | '7d' | '30d';
29
+ }): Promise<Answer<'get_live_profile'>>;
30
+ /** One asset's order books now, at most 30 s old (`GET /live/book/{asset}`). The read
31
+ * starts the build when nobody watches the asset; `warming` (503) is retried for up to
32
+ * `wait` seconds (default 10; 0 throws it at once). */
33
+ book(asset: string, opts?: {
34
+ depth?: number;
35
+ wait?: number;
36
+ }): Promise<Answer<'get_live_book_asset'>>;
37
+ /** One asset's markets (fees, depth curve, maker ladder), rate and rows now
38
+ * (`GET /live/asset/{asset}`), fresh as `book`. */
39
+ asset(asset: string, opts?: {
40
+ wait?: number;
41
+ }): Promise<Answer<'get_live_asset_asset'>>;
42
+ /** Every opportunity the plan sees, ranked (`GET /live/opportunities`); with an asset,
43
+ * its markets with fees, depth and maker ladder, and its rows
44
+ * (`GET /live/opportunities/{asset}`). */
45
+ opportunities(): Promise<Answer<'get_live_opportunities'>>;
46
+ opportunities(asset: string): Promise<Answer<'get_live_opportunities_asset'>>;
47
+ /** Funding spreads, one pair's history, and the best perp per asset. */
48
+ funding: LiveFundingApi;
49
+ spreads: {
50
+ /** A pair's edges, basis, funding and index prices over a window
51
+ * (`GET /live/spreads/history`); `start` inclusive (default 7 days ago), `end`
52
+ * exclusive (default now). */
53
+ history(pair: Pair, opts?: {
54
+ start?: Instant;
55
+ end?: Instant;
56
+ }): Promise<Answer<'get_live_spreads_history'>>;
57
+ };
58
+ /** The exchanges covered, with their type, names and paired markets
59
+ * (`GET /live/exchanges`). */
60
+ exchanges(): Promise<Answer<'get_live_exchanges'>>;
61
+ /**
62
+ * The live socket `wss://<API host>/live/<topic>`: frames for as long as you iterate.
63
+ * Reconnects at once on the server's once-a-minute close (4001), pings every 20 s, backs
64
+ * off on other closes, and stops with `LiveClosed` on 4401 (key revoked), 4003, 4004.
65
+ *
66
+ * ```ts
67
+ * for await (const frame of t.live.stream('book:bitcoin', { depth: 10 })) {
68
+ * if (frame.t === 'view') console.log(frame.books?.[0]?.bid)
69
+ * }
70
+ * ```
71
+ */
72
+ stream(topic: LiveTopic, opts?: StreamOptions): AsyncIterable<LiveFrame>;
73
+ };
74
+ export declare function liveApi(http: Transport): LiveApi;
package/dist/live.js ADDED
@@ -0,0 +1,60 @@
1
+ import { instant, segment } from "./client.js";
2
+ import { Unavailable } from "./errors.js";
3
+ import { defaultConnect, openStream } from "./livestream.js";
4
+ /** How long `book` and `asset` retry a `warming` answer by default, seconds. */
5
+ export const WARMING_WAIT_S = 10;
6
+ const pause = (ms) => new Promise((r) => setTimeout(r, ms));
7
+ /** GET `path`, retrying `warming` until `waitS` seconds have passed. */
8
+ async function fresh(http, path, params, waitS) {
9
+ const end = Date.now() + Math.max(0, waitS) * 1000;
10
+ for (;;) {
11
+ try {
12
+ return await http.get(path, params);
13
+ }
14
+ catch (e) {
15
+ const left = end - Date.now();
16
+ if (!(e instanceof Unavailable) || e.code !== 'warming' || left <= 0)
17
+ throw e;
18
+ await pause(Math.min(left, Math.max(200, (e.retryAfter ?? 2) * 1000)));
19
+ }
20
+ }
21
+ }
22
+ export function liveApi(http) {
23
+ const funding = Object.assign(() => http.get('/live/funding'), {
24
+ history: (pair) => http.get('/live/funding/history', {
25
+ pair
26
+ }),
27
+ perps: () => http.get('/live/funding/perps')
28
+ });
29
+ return {
30
+ profile: (asset, o = {}) => http.get('/live/profile', {
31
+ asset,
32
+ venue: o.venue,
33
+ market: o.market,
34
+ window: o.window
35
+ }),
36
+ book: (asset, o = {}) => fresh(http, `/live/book/${segment(asset)}`, { depth: o.depth }, o.wait ?? WARMING_WAIT_S),
37
+ asset: (asset, o = {}) => fresh(http, `/live/asset/${segment(asset)}`, {}, o.wait ?? WARMING_WAIT_S),
38
+ opportunities: ((asset) => asset === undefined
39
+ ? http.get('/live/opportunities')
40
+ : http.get(`/live/opportunities/${segment(asset)}`)),
41
+ funding,
42
+ spreads: {
43
+ history: (pair, o = {}) => http.get('/live/spreads/history', {
44
+ pair,
45
+ from: instant(o.start),
46
+ to: instant(o.end)
47
+ })
48
+ },
49
+ exchanges: () => http.get('/live/exchanges'),
50
+ stream: (topic, o = {}) => ({
51
+ [Symbol.asyncIterator]: () => openStream({
52
+ ...o,
53
+ baseUrl: http.baseUrl,
54
+ key: http.key(),
55
+ topic,
56
+ connect: defaultConnect(http.webSocket, () => http.fetch())
57
+ })
58
+ })
59
+ };
60
+ }
@@ -0,0 +1,99 @@
1
+ import { type LiveFrame, type LiveTopic } from './types.gen.js';
2
+ /** A `WebSocket` constructor that takes headers: Node 22+'s, Deno's, Bun's, or the `ws`
3
+ * package's. */
4
+ export type WebSocketLike = new (url: string, init?: {
5
+ headers?: Record<string, string>;
6
+ }) => WebSocketInstance;
7
+ /** What the stream uses of a socket (the WHATWG `WebSocket` and Workers' alike). */
8
+ export type WebSocketInstance = {
9
+ send(data: string): void;
10
+ close(code?: number, reason?: string): void;
11
+ addEventListener(type: string, listener: (event: any) => void): void;
12
+ accept?: () => void;
13
+ };
14
+ /** Waits between reconnects after a close other than 4001: `base * 2**attempt` seconds,
15
+ * at most `cap`, with up to `jitter` of it added at random. */
16
+ export type Backoff = {
17
+ base: number;
18
+ cap: number;
19
+ jitter: number;
20
+ };
21
+ export declare const DEFAULT_BACKOFF: Backoff;
22
+ /** How often `ping` is sent, so proxies do not idle the socket out. */
23
+ export declare const PING_EVERY_MS = 20000;
24
+ export type StreamOptions = {
25
+ /** Book topics: levels per side, 1 to 50 (default: every level). */
26
+ depth?: number;
27
+ /** Ends the stream (the iteration returns) and closes the socket. */
28
+ signal?: AbortSignal;
29
+ /** Waits between reconnects after other closes. */
30
+ backoff?: Partial<Backoff>;
31
+ };
32
+ /** The wait before reconnect number `attempt` (0: the first after a failure), seconds. */
33
+ export declare function backoffDelay(b: Backoff, attempt: number, random?: () => number): number;
34
+ /** `wss://<API host>/live/<topic>[?depth=n]` for an `https://` host; `ws://` only for a
35
+ * local `http://` one (the key would travel in clear text otherwise). */
36
+ export declare function socketUrl(baseUrl: string, topic: string, depth?: number): string;
37
+ /** The upgrade was answered with an HTTP status. */
38
+ export declare class Refused extends Error {
39
+ readonly status: number;
40
+ readonly body: string | null;
41
+ readonly retryAfter: string | null;
42
+ constructor(status: number, body: string | null, retryAfter: string | null);
43
+ }
44
+ /** The socket closed (`code`; null without a close frame) or could not be opened. */
45
+ export declare class Dropped extends Error {
46
+ readonly code: number | null;
47
+ readonly reason: string;
48
+ constructor(code: number | null, reason?: string);
49
+ }
50
+ /** The upgrade failed, yet the same request over `node:http` is upgraded: this runtime's
51
+ * `WebSocket` does not send the `authorization` header. */
52
+ export declare class HeadersLost extends Dropped {
53
+ constructor();
54
+ }
55
+ /** Failed opens in a row after which a stream that never opened gives up. */
56
+ export declare const MAX_FAILED_FIRST_OPENS = 5;
57
+ /** Opens in a row refused for a missing header after which the stream gives up. */
58
+ export declare const MAX_HEADERS_LOST = 3;
59
+ /** An open socket as the loop reads it. */
60
+ export type Conn = {
61
+ /** The next text frame; `Dropped` once closed. */
62
+ recv(): Promise<string>;
63
+ send(text: string): void;
64
+ close(): void;
65
+ };
66
+ /** Open a socket on `url` with `headers`; throws `Refused` or `Dropped`. */
67
+ export type Connect = (url: string, headers: Record<string, string>) => Promise<Conn>;
68
+ /** What a refused upgrade answered; `'upgraded'` when the probe's own upgrade (with the
69
+ * headers) succeeds; null when it cannot tell. */
70
+ export type Probe = (url: string, headers: Record<string, string>) => Promise<{
71
+ status: number;
72
+ body: string | null;
73
+ retryAfter: string | null;
74
+ } | 'upgraded' | null>;
75
+ /** Ask the upgrade again over `node:http(s)` to learn why it was refused (a WHATWG
76
+ * `WebSocket` hides the status). `'upgraded'` when the upgrade now succeeds (that socket is
77
+ * dropped at once), null where the runtime has no `node:http` or nothing answered. */
78
+ export declare const nodeProbe: Probe;
79
+ /** Open with a `WebSocket` constructor; a failure before the open is probed for a status. */
80
+ export declare function constructorConnect(Ctor: WebSocketLike, probe?: Probe): Connect;
81
+ /** Open with a fetch upgrade (Cloudflare Workers: `res.webSocket.accept()`). */
82
+ export declare function fetchConnect(fetchFn: typeof fetch): Connect;
83
+ /** The default way to open a socket in this runtime. */
84
+ export declare function defaultConnect(webSocket: WebSocketLike | 'fetch' | undefined, fetchFn: () => typeof fetch): Connect;
85
+ export type StreamArgs = StreamOptions & {
86
+ baseUrl: string;
87
+ key: string;
88
+ topic: LiveTopic | (string & {});
89
+ connect: Connect;
90
+ /** Overrides for tests. */
91
+ pingEveryMs?: number;
92
+ sleep?: (ms: number, signal?: AbortSignal) => Promise<void>;
93
+ random?: () => number;
94
+ };
95
+ /** Frames of `topic` for as long as the caller iterates; `pong` is not yielded.
96
+ *
97
+ * @throws LiveClosed: the server ended the stream (4401, 4003, 4004).
98
+ * @throws ApiError: the upgrade was refused for good (401, 403, 404, 400, 410). */
99
+ export declare function openStream(args: StreamArgs): AsyncGenerator<LiveFrame, void, undefined>;