felix-gateway-client 0.2.0 → 0.3.0
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/index.d.ts +7 -2
- package/dist/index.js +6 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -43,8 +43,9 @@ export type ServerMessage = {
|
|
|
43
43
|
id?: number;
|
|
44
44
|
stream?: string;
|
|
45
45
|
cache?: string;
|
|
46
|
-
code: "bad_request" | "unsupported" | "publish_failed" | "subscribe_failed" | "subscription_ended" | "counter_failed" | "cache_failed" | "trimmed" | "watch_failed" | "signed_out" | "forbidden" | "unavailable";
|
|
46
|
+
code: "bad_request" | "unsupported" | "publish_failed" | "subscribe_failed" | "subscription_ended" | "counter_failed" | "cache_failed" | "trimmed" | "watch_failed" | "signed_out" | "forbidden" | "unavailable" | "rate_limited";
|
|
47
47
|
oldest?: number;
|
|
48
|
+
retry_after_ms?: number;
|
|
48
49
|
message: string;
|
|
49
50
|
};
|
|
50
51
|
/**
|
|
@@ -90,8 +91,12 @@ export interface GatewayEvent {
|
|
|
90
91
|
/** Raised when the gateway reports that a request failed. */
|
|
91
92
|
export declare class GatewayError extends Error {
|
|
92
93
|
readonly code: string;
|
|
94
|
+
/** With `rate_limited`: milliseconds until the request would fit. */
|
|
95
|
+
readonly retryAfterMs?: number | undefined;
|
|
93
96
|
name: string;
|
|
94
|
-
constructor(code: string, message: string
|
|
97
|
+
constructor(code: string, message: string,
|
|
98
|
+
/** With `rate_limited`: milliseconds until the request would fit. */
|
|
99
|
+
retryAfterMs?: number | undefined);
|
|
95
100
|
}
|
|
96
101
|
/**
|
|
97
102
|
* Everything a {@link GatewayClient} offers, without its private state, so
|
package/dist/index.js
CHANGED
|
@@ -6,10 +6,14 @@ export const PROTOCOL = 1;
|
|
|
6
6
|
/** Raised when the gateway reports that a request failed. */
|
|
7
7
|
export class GatewayError extends Error {
|
|
8
8
|
code;
|
|
9
|
+
retryAfterMs;
|
|
9
10
|
name = "GatewayError";
|
|
10
|
-
constructor(code, message
|
|
11
|
+
constructor(code, message,
|
|
12
|
+
/** With `rate_limited`: milliseconds until the request would fit. */
|
|
13
|
+
retryAfterMs) {
|
|
11
14
|
super(message);
|
|
12
15
|
this.code = code;
|
|
16
|
+
this.retryAfterMs = retryAfterMs;
|
|
13
17
|
}
|
|
14
18
|
}
|
|
15
19
|
/**
|
|
@@ -163,7 +167,7 @@ export class GatewayClient {
|
|
|
163
167
|
this.#take(message.id)?.resolve(message.payload);
|
|
164
168
|
break;
|
|
165
169
|
case "error": {
|
|
166
|
-
const error = new GatewayError(message.code, message.message);
|
|
170
|
+
const error = new GatewayError(message.code, message.message, message.retry_after_ms);
|
|
167
171
|
const pending = this.#take(message.id);
|
|
168
172
|
if (pending) {
|
|
169
173
|
pending.reject(error);
|