@the-open-engine/zeroshot 6.28.0 → 6.29.1
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 +3 -3
- package/cli/index.js +20 -224
- package/docker/zeroshot-cluster/Dockerfile +2 -3
- package/lib/cluster/client.cjs +30 -7
- package/lib/cluster/client.d.cts +52 -0
- package/lib/cluster/client.d.mts +52 -0
- package/lib/cluster/client.d.ts +4 -6
- package/lib/cluster/client.mjs +32 -9
- package/lib/cluster/connection-state.cjs +25 -0
- package/lib/cluster/connection-state.d.cts +13 -0
- package/lib/cluster/connection-state.d.mts +13 -0
- package/lib/cluster/connection-state.d.ts +13 -0
- package/lib/cluster/connection-state.mjs +21 -0
- package/lib/cluster/connection-types.cjs +2 -0
- package/lib/cluster/connection-types.d.cts +33 -0
- package/lib/cluster/connection-types.d.mts +33 -0
- package/lib/cluster/connection-types.d.ts +33 -0
- package/lib/cluster/connection-types.mjs +1 -0
- package/lib/cluster/connection.cjs +18 -46
- package/lib/cluster/connection.d.cts +26 -0
- package/lib/cluster/connection.d.mts +26 -0
- package/lib/cluster/connection.d.ts +7 -25
- package/lib/cluster/connection.mjs +12 -42
- package/lib/cluster/errors.cjs +9 -1
- package/lib/cluster/errors.d.cts +29 -0
- package/lib/cluster/errors.d.mts +29 -0
- package/lib/cluster/errors.d.ts +4 -0
- package/lib/cluster/errors.mjs +7 -0
- package/lib/cluster/frames.d.cts +12 -0
- package/lib/cluster/frames.d.mts +12 -0
- package/lib/cluster/generated/protocol-schema.d.cts +1 -0
- package/lib/cluster/generated/protocol-schema.d.mts +1 -0
- package/lib/cluster/generated/protocol.d.cts +781 -0
- package/lib/cluster/generated/protocol.d.mts +781 -0
- package/lib/cluster/index.cjs +2 -2
- package/lib/cluster/index.d.cts +13 -0
- package/lib/cluster/index.d.mts +13 -0
- package/lib/cluster/index.d.ts +3 -3
- package/lib/cluster/index.mjs +2 -2
- package/lib/cluster/json-source.cjs +1 -0
- package/lib/cluster/json-source.d.cts +5 -0
- package/lib/cluster/json-source.d.mts +5 -0
- package/lib/cluster/json-source.d.ts +1 -0
- package/lib/cluster/json-source.mjs +1 -0
- package/lib/cluster/payload-value.cjs +1 -0
- package/lib/cluster/payload-value.d.cts +8 -0
- package/lib/cluster/payload-value.d.mts +8 -0
- package/lib/cluster/payload-value.d.ts +1 -0
- package/lib/cluster/payload-value.mjs +1 -0
- package/lib/cluster/queue.d.cts +15 -0
- package/lib/cluster/queue.d.mts +15 -0
- package/lib/cluster/socket.cjs +8 -0
- package/lib/cluster/socket.d.cts +13 -0
- package/lib/cluster/socket.d.mts +13 -0
- package/lib/cluster/socket.d.ts +2 -0
- package/lib/cluster/socket.mjs +7 -0
- package/lib/cluster/subscriptions.d.cts +73 -0
- package/lib/cluster/subscriptions.d.mts +73 -0
- package/lib/cluster/subscriptions.d.ts +5 -1
- package/lib/cluster/validators.cjs +1 -0
- package/lib/cluster/validators.d.cts +7 -0
- package/lib/cluster/validators.d.mts +7 -0
- package/lib/cluster/validators.d.ts +1 -0
- package/lib/cluster/validators.mjs +1 -0
- package/lib/cluster-worker/engine-adapter.js +1 -11
- package/lib/cluster-worker/engine-input.js +14 -0
- package/lib/hosted-session/authority.cjs +61 -0
- package/lib/hosted-session/authority.d.cts +3 -0
- package/lib/hosted-session/authority.d.mts +3 -0
- package/lib/hosted-session/authority.d.ts +3 -0
- package/lib/hosted-session/authority.mjs +57 -0
- package/lib/hosted-session/coordinator.cjs +78 -51
- package/lib/hosted-session/coordinator.d.cts +11 -0
- package/lib/hosted-session/coordinator.d.mts +11 -0
- package/lib/hosted-session/coordinator.d.ts +4 -2
- package/lib/hosted-session/coordinator.mjs +75 -51
- package/lib/hosted-session/errors.cjs +25 -0
- package/lib/hosted-session/errors.d.cts +10 -0
- package/lib/hosted-session/errors.d.mts +10 -0
- package/lib/hosted-session/errors.d.ts +10 -0
- package/lib/hosted-session/errors.mjs +19 -0
- package/lib/hosted-session/index.cjs +4 -1
- package/lib/hosted-session/index.d.cts +2 -0
- package/lib/hosted-session/index.d.mts +2 -0
- package/lib/hosted-session/index.d.ts +2 -2
- package/lib/hosted-session/index.mjs +1 -1
- package/lib/hosted-session/reconnecting-watch.cjs +131 -0
- package/lib/hosted-session/reconnecting-watch.d.cts +13 -0
- package/lib/hosted-session/reconnecting-watch.d.mts +13 -0
- package/lib/hosted-session/reconnecting-watch.d.ts +13 -0
- package/lib/hosted-session/reconnecting-watch.mjs +127 -0
- package/lib/hosted-session/types.d.cts +32 -0
- package/lib/hosted-session/types.d.mts +32 -0
- package/lib/hosted-session/types.d.ts +19 -7
- package/lib/hosted-target/access-url.cjs +44 -0
- package/lib/hosted-target/access-url.d.cts +2 -0
- package/lib/hosted-target/access-url.d.mts +2 -0
- package/lib/hosted-target/access-url.d.ts +2 -0
- package/lib/hosted-target/access-url.mjs +41 -0
- package/lib/hosted-target/adapter-request.cjs +12 -0
- package/lib/hosted-target/adapter-request.d.cts +17 -0
- package/lib/hosted-target/adapter-request.d.mts +17 -0
- package/lib/hosted-target/adapter-request.d.ts +17 -0
- package/lib/hosted-target/adapter-request.mjs +9 -0
- package/lib/hosted-target/adapter-types.cjs +2 -0
- package/lib/hosted-target/adapter-types.d.cts +27 -0
- package/lib/hosted-target/adapter-types.d.mts +27 -0
- package/lib/hosted-target/adapter-types.d.ts +27 -0
- package/lib/hosted-target/adapter-types.mjs +1 -0
- package/lib/hosted-target/bounds.cjs +10 -0
- package/lib/hosted-target/bounds.d.cts +7 -0
- package/lib/hosted-target/bounds.d.mts +7 -0
- package/lib/hosted-target/bounds.d.ts +7 -0
- package/lib/hosted-target/bounds.mjs +7 -0
- package/lib/hosted-target/capsule-error-response.cjs +76 -0
- package/lib/hosted-target/capsule-error-response.d.cts +2 -0
- package/lib/hosted-target/capsule-error-response.d.mts +2 -0
- package/lib/hosted-target/capsule-error-response.d.ts +2 -0
- package/lib/hosted-target/capsule-error-response.mjs +73 -0
- package/lib/hosted-target/errors.cjs +88 -0
- package/lib/hosted-target/errors.d.cts +36 -0
- package/lib/hosted-target/errors.d.mts +36 -0
- package/lib/hosted-target/errors.d.ts +36 -0
- package/lib/hosted-target/errors.mjs +75 -0
- package/lib/hosted-target/index.cjs +16 -0
- package/lib/hosted-target/index.d.cts +3 -0
- package/lib/hosted-target/index.d.mts +3 -0
- package/lib/hosted-target/index.d.ts +3 -0
- package/lib/hosted-target/index.mjs +2 -0
- package/lib/hosted-target/response-validation.cjs +169 -0
- package/lib/hosted-target/response-validation.d.cts +5 -0
- package/lib/hosted-target/response-validation.d.mts +5 -0
- package/lib/hosted-target/response-validation.d.ts +5 -0
- package/lib/hosted-target/response-validation.mjs +163 -0
- package/lib/hosted-target/retry-executor.cjs +51 -0
- package/lib/hosted-target/retry-executor.d.cts +8 -0
- package/lib/hosted-target/retry-executor.d.mts +8 -0
- package/lib/hosted-target/retry-executor.d.ts +8 -0
- package/lib/hosted-target/retry-executor.mjs +48 -0
- package/lib/hosted-target/retry.cjs +78 -0
- package/lib/hosted-target/retry.d.cts +9 -0
- package/lib/hosted-target/retry.d.mts +9 -0
- package/lib/hosted-target/retry.d.ts +9 -0
- package/lib/hosted-target/retry.mjs +73 -0
- package/lib/hosted-target/target-adapter.cjs +10 -0
- package/lib/hosted-target/target-adapter.d.cts +3 -0
- package/lib/hosted-target/target-adapter.d.mts +3 -0
- package/lib/hosted-target/target-adapter.d.ts +3 -0
- package/lib/hosted-target/target-adapter.mjs +7 -0
- package/lib/hosted-target/types.cjs +4 -0
- package/lib/hosted-target/types.d.cts +50 -0
- package/lib/hosted-target/types.d.mts +50 -0
- package/lib/hosted-target/types.d.ts +50 -0
- package/lib/hosted-target/types.mjs +1 -0
- package/lib/hosted-target/zero-cloud-v1-adapter.cjs +185 -0
- package/lib/hosted-target/zero-cloud-v1-adapter.d.cts +13 -0
- package/lib/hosted-target/zero-cloud-v1-adapter.d.mts +13 -0
- package/lib/hosted-target/zero-cloud-v1-adapter.d.ts +13 -0
- package/lib/hosted-target/zero-cloud-v1-adapter.mjs +181 -0
- package/lib/target/bounded-response.cjs +51 -0
- package/lib/target/bounded-response.d.cts +1 -0
- package/lib/target/bounded-response.d.mts +1 -0
- package/lib/target/bounded-response.d.ts +1 -0
- package/lib/target/bounded-response.js +51 -0
- package/lib/target/bounded-response.mjs +48 -0
- package/lib/target/credential-lock.js +1 -3
- package/lib/target/credential-store.js +9 -4
- package/lib/target/device-flow.cjs +213 -0
- package/lib/target/device-flow.d.cts +54 -0
- package/lib/target/device-flow.d.mts +54 -0
- package/lib/target/device-flow.d.ts +26 -10
- package/lib/target/device-flow.js +162 -53
- package/lib/target/device-flow.mjs +203 -0
- package/lib/target/discovery-errors.cjs +10 -0
- package/lib/target/discovery-errors.d.cts +3 -0
- package/lib/target/discovery-errors.d.mts +3 -0
- package/lib/target/discovery-errors.d.ts +3 -0
- package/lib/target/discovery-errors.js +10 -0
- package/lib/target/discovery-errors.mjs +6 -0
- package/lib/target/discovery-sections.cjs +191 -0
- package/lib/target/discovery-sections.d.cts +52 -0
- package/lib/target/discovery-sections.d.mts +52 -0
- package/lib/target/discovery-sections.d.ts +52 -0
- package/lib/target/discovery-sections.js +191 -0
- package/lib/target/discovery-sections.mjs +179 -0
- package/lib/target/discovery-validation.cjs +109 -0
- package/lib/target/discovery-validation.d.cts +28 -0
- package/lib/target/discovery-validation.d.mts +28 -0
- package/lib/target/discovery-validation.d.ts +28 -0
- package/lib/target/discovery-validation.js +109 -0
- package/lib/target/discovery-validation.mjs +99 -0
- package/lib/target/discovery.cjs +112 -0
- package/lib/target/discovery.d.cts +74 -0
- package/lib/target/discovery.d.mts +74 -0
- package/lib/target/discovery.d.ts +68 -5
- package/lib/target/discovery.js +93 -101
- package/lib/target/discovery.mjs +105 -0
- package/lib/target/index.d.ts +6 -6
- package/lib/target/index.js +36 -36
- package/lib/target/oauth-http.d.ts +2 -0
- package/lib/target/oauth-http.js +25 -0
- package/lib/target/refresh-exchange.d.ts +11 -0
- package/lib/target/refresh-exchange.js +24 -0
- package/lib/target/refresh-revocation.d.ts +8 -0
- package/lib/target/refresh-revocation.js +19 -0
- package/lib/target/route-template.cjs +85 -0
- package/lib/target/route-template.d.cts +7 -0
- package/lib/target/route-template.d.mts +7 -0
- package/lib/target/route-template.d.ts +7 -0
- package/lib/target/route-template.js +85 -0
- package/lib/target/route-template.mjs +81 -0
- package/lib/target/session-errors.d.ts +4 -0
- package/lib/target/session-errors.js +12 -0
- package/lib/target/session-verification.d.ts +10 -0
- package/lib/target/session-verification.js +42 -0
- package/lib/target/target-registry.d.ts +7 -3
- package/lib/target/target-registry.js +41 -10
- package/lib/target/target-session-manager.d.ts +48 -0
- package/lib/target/target-session-manager.js +226 -0
- package/lib/target/target-session.d.ts +39 -31
- package/lib/target/target-session.js +63 -150
- package/lib/target/token-response.cjs +51 -0
- package/lib/target/token-response.d.cts +7 -0
- package/lib/target/token-response.d.mts +7 -0
- package/lib/target/token-response.d.ts +7 -0
- package/lib/target/token-response.js +51 -0
- package/lib/target/token-response.mjs +48 -0
- package/package.json +16 -6
- package/scripts/audit-production-dependencies.js +150 -0
- package/scripts/build-cluster.js +23 -3
- package/scripts/opcore-agent-gate.js +159 -0
- package/scripts/opcore-agent-tool-overlays.js +154 -0
- package/scripts/opcore-introduced-check.js +288 -0
- package/src/cluster/client.ts +42 -15
- package/src/cluster/connection-state.ts +33 -0
- package/src/cluster/connection-types.ts +28 -0
- package/src/cluster/connection.ts +37 -68
- package/src/cluster/errors.ts +5 -0
- package/src/cluster/index.ts +3 -1
- package/src/cluster/json-source.ts +1 -0
- package/src/cluster/payload-value.ts +1 -0
- package/src/cluster/socket.ts +13 -0
- package/src/cluster/subscriptions.ts +7 -2
- package/src/cluster/validators.ts +1 -0
- package/src/cluster/ws.d.ts +1 -1
- package/src/hosted-session/authority.ts +77 -0
- package/src/hosted-session/coordinator.ts +113 -56
- package/src/hosted-session/errors.ts +21 -0
- package/src/hosted-session/index.ts +14 -2
- package/src/hosted-session/reconnecting-watch.ts +148 -0
- package/src/hosted-session/types.ts +22 -8
- package/src/hosted-target/access-url.ts +46 -0
- package/src/hosted-target/adapter-request.ts +28 -0
- package/src/hosted-target/adapter-types.ts +39 -0
- package/src/hosted-target/bounds.ts +1 -0
- package/src/hosted-target/capsule-error-response.ts +107 -0
- package/src/hosted-target/errors.ts +36 -35
- package/src/hosted-target/index.ts +10 -23
- package/src/hosted-target/response-validation.ts +170 -62
- package/src/hosted-target/retry-executor.ts +62 -0
- package/src/hosted-target/retry.ts +47 -11
- package/src/hosted-target/target-adapter.ts +12 -8
- package/src/hosted-target/types.ts +19 -18
- package/src/hosted-target/zero-cloud-v1-adapter.ts +229 -316
- package/src/target/bounded-response.ts +68 -0
- package/src/target/credential-lock.ts +1 -3
- package/src/target/credential-store.ts +14 -10
- package/src/target/device-flow.ts +206 -71
- package/src/target/discovery-errors.ts +6 -0
- package/src/target/discovery-sections.ts +251 -0
- package/src/target/discovery-validation.ts +144 -0
- package/src/target/discovery.ts +163 -115
- package/src/target/index.ts +15 -11
- package/src/target/oauth-http.ts +27 -0
- package/src/target/refresh-exchange.ts +36 -0
- package/src/target/refresh-revocation.ts +29 -0
- package/src/target/route-template.ts +105 -0
- package/src/target/session-errors.ts +9 -0
- package/src/target/session-verification.ts +51 -0
- package/src/target/target-registry.ts +60 -27
- package/src/target/target-session-manager.ts +285 -0
- package/src/target/target-session.ts +105 -222
- package/src/target/token-response.ts +62 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type ConnectionState = 'OPEN' | 'CLOSING' | 'CLOSED';
|
|
2
|
+
export declare const CONNECTION_TRANSITIONS: Readonly<Record<ConnectionState, readonly ConnectionState[]>>;
|
|
3
|
+
export declare const PROTOCOL_DIAGNOSTIC_CAPACITY = 128;
|
|
4
|
+
export interface ConnectionCloseSnapshot {
|
|
5
|
+
readonly code: number | null;
|
|
6
|
+
readonly reason: null;
|
|
7
|
+
}
|
|
8
|
+
export type Deferred<T> = {
|
|
9
|
+
readonly promise: Promise<T>;
|
|
10
|
+
readonly resolve: (value: T) => void;
|
|
11
|
+
readonly reject: (reason: unknown) => void;
|
|
12
|
+
};
|
|
13
|
+
export declare function deferred<T>(): Deferred<T>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type ConnectionState = 'OPEN' | 'CLOSING' | 'CLOSED';
|
|
2
|
+
export declare const CONNECTION_TRANSITIONS: Readonly<Record<ConnectionState, readonly ConnectionState[]>>;
|
|
3
|
+
export declare const PROTOCOL_DIAGNOSTIC_CAPACITY = 128;
|
|
4
|
+
export interface ConnectionCloseSnapshot {
|
|
5
|
+
readonly code: number | null;
|
|
6
|
+
readonly reason: null;
|
|
7
|
+
}
|
|
8
|
+
export type Deferred<T> = {
|
|
9
|
+
readonly promise: Promise<T>;
|
|
10
|
+
readonly resolve: (value: T) => void;
|
|
11
|
+
readonly reject: (reason: unknown) => void;
|
|
12
|
+
};
|
|
13
|
+
export declare function deferred<T>(): Deferred<T>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
if (!Object.prototype.hasOwnProperty.call(Symbol, 'asyncDispose')) {
|
|
2
|
+
Object.defineProperty(Symbol, 'asyncDispose', {
|
|
3
|
+
configurable: false, enumerable: false,
|
|
4
|
+
value: Symbol.for('Symbol.asyncDispose'), writable: false,
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
export const CONNECTION_TRANSITIONS = Object.freeze({
|
|
8
|
+
OPEN: Object.freeze(['CLOSING']),
|
|
9
|
+
CLOSING: Object.freeze(['CLOSED']),
|
|
10
|
+
CLOSED: Object.freeze([]),
|
|
11
|
+
});
|
|
12
|
+
export const PROTOCOL_DIAGNOSTIC_CAPACITY = 128;
|
|
13
|
+
export function deferred() {
|
|
14
|
+
let resolve;
|
|
15
|
+
let reject;
|
|
16
|
+
const promise = new Promise((onResolve, onReject) => {
|
|
17
|
+
resolve = onResolve;
|
|
18
|
+
reject = onReject;
|
|
19
|
+
});
|
|
20
|
+
return { promise, resolve, reject };
|
|
21
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { FrameRecord } from './frames.js';
|
|
2
|
+
import type { BoundedQueue } from './queue.js';
|
|
3
|
+
import type { ClusterMethod } from './generated/protocol.js';
|
|
4
|
+
export interface CallOptions {
|
|
5
|
+
readonly signal?: AbortSignal;
|
|
6
|
+
readonly requestTimeoutMs?: number;
|
|
7
|
+
}
|
|
8
|
+
export type SubscriptionKind = 'watch' | 'logs' | 'agent/attach';
|
|
9
|
+
export type SubscriptionRegistration = {
|
|
10
|
+
readonly id: string;
|
|
11
|
+
readonly kind: SubscriptionKind;
|
|
12
|
+
readonly queue: BoundedQueue<FrameRecord>;
|
|
13
|
+
overflowed: boolean;
|
|
14
|
+
cancelSent: boolean;
|
|
15
|
+
abortHandler?: () => void;
|
|
16
|
+
abortSignal?: AbortSignal;
|
|
17
|
+
};
|
|
18
|
+
export type EstablishedSubscription<R> = {
|
|
19
|
+
readonly result: R;
|
|
20
|
+
readonly registration: SubscriptionRegistration;
|
|
21
|
+
};
|
|
22
|
+
export type PendingEntry = {
|
|
23
|
+
readonly id: string;
|
|
24
|
+
readonly method: ClusterMethod;
|
|
25
|
+
readonly expectedId: string;
|
|
26
|
+
readonly resolve: (value: unknown) => void;
|
|
27
|
+
readonly reject: (reason: unknown) => void;
|
|
28
|
+
readonly subscriptionKind?: SubscriptionKind;
|
|
29
|
+
settled: boolean;
|
|
30
|
+
abortHandler?: () => void;
|
|
31
|
+
signal?: AbortSignal;
|
|
32
|
+
timeout?: ReturnType<typeof setTimeout>;
|
|
33
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { FrameRecord } from './frames.js';
|
|
2
|
+
import type { BoundedQueue } from './queue.js';
|
|
3
|
+
import type { ClusterMethod } from './generated/protocol.js';
|
|
4
|
+
export interface CallOptions {
|
|
5
|
+
readonly signal?: AbortSignal;
|
|
6
|
+
readonly requestTimeoutMs?: number;
|
|
7
|
+
}
|
|
8
|
+
export type SubscriptionKind = 'watch' | 'logs' | 'agent/attach';
|
|
9
|
+
export type SubscriptionRegistration = {
|
|
10
|
+
readonly id: string;
|
|
11
|
+
readonly kind: SubscriptionKind;
|
|
12
|
+
readonly queue: BoundedQueue<FrameRecord>;
|
|
13
|
+
overflowed: boolean;
|
|
14
|
+
cancelSent: boolean;
|
|
15
|
+
abortHandler?: () => void;
|
|
16
|
+
abortSignal?: AbortSignal;
|
|
17
|
+
};
|
|
18
|
+
export type EstablishedSubscription<R> = {
|
|
19
|
+
readonly result: R;
|
|
20
|
+
readonly registration: SubscriptionRegistration;
|
|
21
|
+
};
|
|
22
|
+
export type PendingEntry = {
|
|
23
|
+
readonly id: string;
|
|
24
|
+
readonly method: ClusterMethod;
|
|
25
|
+
readonly expectedId: string;
|
|
26
|
+
readonly resolve: (value: unknown) => void;
|
|
27
|
+
readonly reject: (reason: unknown) => void;
|
|
28
|
+
readonly subscriptionKind?: SubscriptionKind;
|
|
29
|
+
settled: boolean;
|
|
30
|
+
abortHandler?: () => void;
|
|
31
|
+
signal?: AbortSignal;
|
|
32
|
+
timeout?: ReturnType<typeof setTimeout>;
|
|
33
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { FrameRecord } from './frames.js';
|
|
2
|
+
import type { BoundedQueue } from './queue.js';
|
|
3
|
+
import type { ClusterMethod } from './generated/protocol.js';
|
|
4
|
+
export interface CallOptions {
|
|
5
|
+
readonly signal?: AbortSignal;
|
|
6
|
+
readonly requestTimeoutMs?: number;
|
|
7
|
+
}
|
|
8
|
+
export type SubscriptionKind = 'watch' | 'logs' | 'agent/attach';
|
|
9
|
+
export type SubscriptionRegistration = {
|
|
10
|
+
readonly id: string;
|
|
11
|
+
readonly kind: SubscriptionKind;
|
|
12
|
+
readonly queue: BoundedQueue<FrameRecord>;
|
|
13
|
+
overflowed: boolean;
|
|
14
|
+
cancelSent: boolean;
|
|
15
|
+
abortHandler?: () => void;
|
|
16
|
+
abortSignal?: AbortSignal;
|
|
17
|
+
};
|
|
18
|
+
export type EstablishedSubscription<R> = {
|
|
19
|
+
readonly result: R;
|
|
20
|
+
readonly registration: SubscriptionRegistration;
|
|
21
|
+
};
|
|
22
|
+
export type PendingEntry = {
|
|
23
|
+
readonly id: string;
|
|
24
|
+
readonly method: ClusterMethod;
|
|
25
|
+
readonly expectedId: string;
|
|
26
|
+
readonly resolve: (value: unknown) => void;
|
|
27
|
+
readonly reject: (reason: unknown) => void;
|
|
28
|
+
readonly subscriptionKind?: SubscriptionKind;
|
|
29
|
+
settled: boolean;
|
|
30
|
+
abortHandler?: () => void;
|
|
31
|
+
signal?: AbortSignal;
|
|
32
|
+
timeout?: ReturnType<typeof setTimeout>;
|
|
33
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,48 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Connection = exports.
|
|
3
|
+
exports.Connection = exports.PROTOCOL_DIAGNOSTIC_CAPACITY = exports.CONNECTION_TRANSITIONS = void 0;
|
|
4
4
|
const protocol_js_1 = require("./generated/protocol.cjs");
|
|
5
5
|
const errors_js_1 = require("./errors.cjs");
|
|
6
6
|
const frames_js_1 = require("./frames.cjs");
|
|
7
7
|
const queue_js_1 = require("./queue.cjs");
|
|
8
8
|
const socket_js_1 = require("./socket.cjs");
|
|
9
9
|
const validators_js_1 = require("./validators.cjs");
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
exports.CONNECTION_TRANSITIONS = Object.freeze({
|
|
17
|
-
OPEN: Object.freeze(['CLOSING']),
|
|
18
|
-
CLOSING: Object.freeze(['CLOSED']),
|
|
19
|
-
CLOSED: Object.freeze([]),
|
|
20
|
-
});
|
|
21
|
-
exports.PROTOCOL_DIAGNOSTIC_CAPACITY = 128;
|
|
22
|
-
exports.CLOSE_REASON_MAX_BYTES = 123;
|
|
23
|
-
const CLOSE_REASON_ENCODER = new TextEncoder();
|
|
24
|
-
function boundedCloseReason(reason) {
|
|
25
|
-
const retained = [];
|
|
26
|
-
const scratch = new Uint8Array(4);
|
|
27
|
-
let bytes = 0;
|
|
28
|
-
for (const codePoint of reason) {
|
|
29
|
-
const { written } = CLOSE_REASON_ENCODER.encodeInto(codePoint, scratch);
|
|
30
|
-
if (bytes + written > exports.CLOSE_REASON_MAX_BYTES)
|
|
31
|
-
break;
|
|
32
|
-
retained.push(codePoint);
|
|
33
|
-
bytes += written;
|
|
34
|
-
}
|
|
35
|
-
return retained.join('');
|
|
36
|
-
}
|
|
37
|
-
function deferred() {
|
|
38
|
-
let resolve;
|
|
39
|
-
let reject;
|
|
40
|
-
const promise = new Promise((onResolve, onReject) => {
|
|
41
|
-
resolve = onResolve;
|
|
42
|
-
reject = onReject;
|
|
43
|
-
});
|
|
44
|
-
return { promise, resolve, reject };
|
|
45
|
-
}
|
|
10
|
+
const connection_state_js_1 = require("./connection-state.cjs");
|
|
11
|
+
var connection_state_js_2 = require("./connection-state.cjs");
|
|
12
|
+
Object.defineProperty(exports, "CONNECTION_TRANSITIONS", { enumerable: true, get: function () { return connection_state_js_2.CONNECTION_TRANSITIONS; } });
|
|
13
|
+
Object.defineProperty(exports, "PROTOCOL_DIAGNOSTIC_CAPACITY", { enumerable: true, get: function () { return connection_state_js_2.PROTOCOL_DIAGNOSTIC_CAPACITY; } });
|
|
46
14
|
class Connection {
|
|
47
15
|
#state = 'OPEN';
|
|
48
16
|
#sequence = 1;
|
|
@@ -53,7 +21,9 @@ class Connection {
|
|
|
53
21
|
#ownedSubscriptions = new WeakSet();
|
|
54
22
|
#closePromise;
|
|
55
23
|
#closeCode;
|
|
56
|
-
#
|
|
24
|
+
#closedCompletion = (0, connection_state_js_1.deferred)();
|
|
25
|
+
closed = this.#closedCompletion.promise;
|
|
26
|
+
#closeSnapshot;
|
|
57
27
|
closeDiagnostics = [];
|
|
58
28
|
protocolDiagnostics = [];
|
|
59
29
|
#socket;
|
|
@@ -67,7 +37,8 @@ class Connection {
|
|
|
67
37
|
get pendingSize() { return this.#pending.size; }
|
|
68
38
|
get subscriptionCount() { return this.#subscriptions.size; }
|
|
69
39
|
get closeCode() { return this.#closeCode; }
|
|
70
|
-
get closeReason() { return
|
|
40
|
+
get closeReason() { return undefined; }
|
|
41
|
+
get closeSnapshot() { return this.#closeSnapshot; }
|
|
71
42
|
call(method, params, options = {}) {
|
|
72
43
|
if (!protocol_js_1.UNARY_METHODS.includes(method)) {
|
|
73
44
|
throw new errors_js_1.ClusterConfigError(`${method} is a subscription method`, 'INVALID_METHOD');
|
|
@@ -104,7 +75,7 @@ class Connection {
|
|
|
104
75
|
if (options.requestTimeoutMs !== undefined && options.requestTimeoutMs < 0)
|
|
105
76
|
return Promise.reject(new errors_js_1.ClusterConfigError('requestTimeoutMs must be non-negative', 'INVALID_TIMEOUT'));
|
|
106
77
|
const id = this.#allocateId();
|
|
107
|
-
const result = deferred();
|
|
78
|
+
const result = (0, connection_state_js_1.deferred)();
|
|
108
79
|
const entry = { id, method, expectedId: id, resolve: result.resolve, reject: result.reject, settled: false, ...(subscriptionKind === undefined ? {} : { subscriptionKind }) };
|
|
109
80
|
this.#pending.set(id, entry);
|
|
110
81
|
if (options.signal) {
|
|
@@ -337,7 +308,7 @@ class Connection {
|
|
|
337
308
|
}
|
|
338
309
|
}
|
|
339
310
|
#recordProtocolError(message, cause) {
|
|
340
|
-
if (this.protocolDiagnostics.length ===
|
|
311
|
+
if (this.protocolDiagnostics.length === connection_state_js_1.PROTOCOL_DIAGNOSTIC_CAPACITY)
|
|
341
312
|
this.protocolDiagnostics.shift();
|
|
342
313
|
this.protocolDiagnostics.push(new errors_js_1.ClusterProtocolError(message, 'INVALID_PEER_FRAME', cause === undefined ? undefined : { cause }));
|
|
343
314
|
}
|
|
@@ -347,15 +318,11 @@ class Connection {
|
|
|
347
318
|
const first = args[0];
|
|
348
319
|
if (typeof first === 'number') {
|
|
349
320
|
this.#closeCode = first;
|
|
350
|
-
const raw = args.length > 1 ? String(args[1]) : undefined;
|
|
351
|
-
this.#closeReason = raw === undefined ? undefined : boundedCloseReason(raw);
|
|
352
321
|
}
|
|
353
322
|
else if (first !== null && typeof first === 'object') {
|
|
354
323
|
const event = first;
|
|
355
324
|
if (typeof event.code === 'number')
|
|
356
325
|
this.#closeCode = event.code;
|
|
357
|
-
if (typeof event.reason === 'string')
|
|
358
|
-
this.#closeReason = boundedCloseReason(event.reason);
|
|
359
326
|
}
|
|
360
327
|
}
|
|
361
328
|
#startClose(sendCancels) {
|
|
@@ -405,9 +372,14 @@ class Connection {
|
|
|
405
372
|
}
|
|
406
373
|
}
|
|
407
374
|
this.#transition('CLOSED');
|
|
375
|
+
this.#closeSnapshot = Object.freeze({
|
|
376
|
+
code: this.#closeCode ?? null,
|
|
377
|
+
reason: null,
|
|
378
|
+
});
|
|
379
|
+
this.#closedCompletion.resolve(this.#closeSnapshot);
|
|
408
380
|
}
|
|
409
381
|
#transition(to) {
|
|
410
|
-
if (!
|
|
382
|
+
if (!connection_state_js_1.CONNECTION_TRANSITIONS[this.#state].includes(to))
|
|
411
383
|
throw new errors_js_1.ClusterInternalError(`illegal connection transition ${this.#state} -> ${to}`, 'ILLEGAL_STATE_TRANSITION');
|
|
412
384
|
this.#state = to;
|
|
413
385
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ClusterMethodParams, ClusterMethodResults, SubscriptionMethod, UnaryClusterMethod } from './generated/protocol.js';
|
|
2
|
+
import { ClusterProtocolError } from './errors.js';
|
|
3
|
+
import type { WebSocketLike } from './socket.js';
|
|
4
|
+
import { type ConnectionCloseSnapshot, type ConnectionState } from './connection-state.js';
|
|
5
|
+
export { CONNECTION_TRANSITIONS, PROTOCOL_DIAGNOSTIC_CAPACITY, type ConnectionCloseSnapshot, type ConnectionState, } from './connection-state.js';
|
|
6
|
+
import type { CallOptions, EstablishedSubscription, SubscriptionRegistration } from './connection-types.js';
|
|
7
|
+
export type { CallOptions, EstablishedSubscription, SubscriptionKind, SubscriptionRegistration, } from './connection-types.js';
|
|
8
|
+
export declare class Connection {
|
|
9
|
+
#private;
|
|
10
|
+
readonly closed: Promise<ConnectionCloseSnapshot>;
|
|
11
|
+
readonly closeDiagnostics: unknown[];
|
|
12
|
+
readonly protocolDiagnostics: ClusterProtocolError[];
|
|
13
|
+
constructor(socket: WebSocketLike);
|
|
14
|
+
get state(): ConnectionState;
|
|
15
|
+
get pendingSize(): number;
|
|
16
|
+
get subscriptionCount(): number;
|
|
17
|
+
get closeCode(): number | undefined;
|
|
18
|
+
get closeReason(): undefined;
|
|
19
|
+
get closeSnapshot(): ConnectionCloseSnapshot | undefined;
|
|
20
|
+
call<M extends UnaryClusterMethod>(method: M, params: ClusterMethodParams[M], options?: CallOptions): Promise<ClusterMethodResults[M]>;
|
|
21
|
+
cancelSubscription(registration: SubscriptionRegistration): Promise<void>;
|
|
22
|
+
openSubscription<M extends SubscriptionMethod>(method: M, params: ClusterMethodParams[M], options?: CallOptions): Promise<EstablishedSubscription<ClusterMethodResults[M]>>;
|
|
23
|
+
unregisterSubscription(id: string, registration: SubscriptionRegistration): void;
|
|
24
|
+
recordDiagnostic(error: unknown): void;
|
|
25
|
+
close(): Promise<void>;
|
|
26
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ClusterMethodParams, ClusterMethodResults, SubscriptionMethod, UnaryClusterMethod } from './generated/protocol.js';
|
|
2
|
+
import { ClusterProtocolError } from './errors.js';
|
|
3
|
+
import type { WebSocketLike } from './socket.js';
|
|
4
|
+
import { type ConnectionCloseSnapshot, type ConnectionState } from './connection-state.js';
|
|
5
|
+
export { CONNECTION_TRANSITIONS, PROTOCOL_DIAGNOSTIC_CAPACITY, type ConnectionCloseSnapshot, type ConnectionState, } from './connection-state.js';
|
|
6
|
+
import type { CallOptions, EstablishedSubscription, SubscriptionRegistration } from './connection-types.js';
|
|
7
|
+
export type { CallOptions, EstablishedSubscription, SubscriptionKind, SubscriptionRegistration, } from './connection-types.js';
|
|
8
|
+
export declare class Connection {
|
|
9
|
+
#private;
|
|
10
|
+
readonly closed: Promise<ConnectionCloseSnapshot>;
|
|
11
|
+
readonly closeDiagnostics: unknown[];
|
|
12
|
+
readonly protocolDiagnostics: ClusterProtocolError[];
|
|
13
|
+
constructor(socket: WebSocketLike);
|
|
14
|
+
get state(): ConnectionState;
|
|
15
|
+
get pendingSize(): number;
|
|
16
|
+
get subscriptionCount(): number;
|
|
17
|
+
get closeCode(): number | undefined;
|
|
18
|
+
get closeReason(): undefined;
|
|
19
|
+
get closeSnapshot(): ConnectionCloseSnapshot | undefined;
|
|
20
|
+
call<M extends UnaryClusterMethod>(method: M, params: ClusterMethodParams[M], options?: CallOptions): Promise<ClusterMethodResults[M]>;
|
|
21
|
+
cancelSubscription(registration: SubscriptionRegistration): Promise<void>;
|
|
22
|
+
openSubscription<M extends SubscriptionMethod>(method: M, params: ClusterMethodParams[M], options?: CallOptions): Promise<EstablishedSubscription<ClusterMethodResults[M]>>;
|
|
23
|
+
unregisterSubscription(id: string, registration: SubscriptionRegistration): void;
|
|
24
|
+
recordDiagnostic(error: unknown): void;
|
|
25
|
+
close(): Promise<void>;
|
|
26
|
+
}
|
|
@@ -1,32 +1,13 @@
|
|
|
1
1
|
import type { ClusterMethodParams, ClusterMethodResults, SubscriptionMethod, UnaryClusterMethod } from './generated/protocol.js';
|
|
2
2
|
import { ClusterProtocolError } from './errors.js';
|
|
3
|
-
import type { FrameRecord } from './frames.js';
|
|
4
|
-
import { BoundedQueue } from './queue.js';
|
|
5
3
|
import type { WebSocketLike } from './socket.js';
|
|
6
|
-
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
export
|
|
10
|
-
export interface CallOptions {
|
|
11
|
-
readonly signal?: AbortSignal;
|
|
12
|
-
readonly requestTimeoutMs?: number;
|
|
13
|
-
}
|
|
14
|
-
export type SubscriptionKind = 'watch' | 'logs' | 'agent/attach';
|
|
15
|
-
export type SubscriptionRegistration = {
|
|
16
|
-
readonly id: string;
|
|
17
|
-
readonly kind: SubscriptionKind;
|
|
18
|
-
readonly queue: BoundedQueue<FrameRecord>;
|
|
19
|
-
overflowed: boolean;
|
|
20
|
-
cancelSent: boolean;
|
|
21
|
-
abortHandler?: () => void;
|
|
22
|
-
abortSignal?: AbortSignal;
|
|
23
|
-
};
|
|
24
|
-
export type EstablishedSubscription<R> = {
|
|
25
|
-
readonly result: R;
|
|
26
|
-
readonly registration: SubscriptionRegistration;
|
|
27
|
-
};
|
|
4
|
+
import { type ConnectionCloseSnapshot, type ConnectionState } from './connection-state.js';
|
|
5
|
+
export { CONNECTION_TRANSITIONS, PROTOCOL_DIAGNOSTIC_CAPACITY, type ConnectionCloseSnapshot, type ConnectionState, } from './connection-state.js';
|
|
6
|
+
import type { CallOptions, EstablishedSubscription, SubscriptionRegistration } from './connection-types.js';
|
|
7
|
+
export type { CallOptions, EstablishedSubscription, SubscriptionKind, SubscriptionRegistration, } from './connection-types.js';
|
|
28
8
|
export declare class Connection {
|
|
29
9
|
#private;
|
|
10
|
+
readonly closed: Promise<ConnectionCloseSnapshot>;
|
|
30
11
|
readonly closeDiagnostics: unknown[];
|
|
31
12
|
readonly protocolDiagnostics: ClusterProtocolError[];
|
|
32
13
|
constructor(socket: WebSocketLike);
|
|
@@ -34,7 +15,8 @@ export declare class Connection {
|
|
|
34
15
|
get pendingSize(): number;
|
|
35
16
|
get subscriptionCount(): number;
|
|
36
17
|
get closeCode(): number | undefined;
|
|
37
|
-
get closeReason():
|
|
18
|
+
get closeReason(): undefined;
|
|
19
|
+
get closeSnapshot(): ConnectionCloseSnapshot | undefined;
|
|
38
20
|
call<M extends UnaryClusterMethod>(method: M, params: ClusterMethodParams[M], options?: CallOptions): Promise<ClusterMethodResults[M]>;
|
|
39
21
|
cancelSubscription(registration: SubscriptionRegistration): Promise<void>;
|
|
40
22
|
openSubscription<M extends SubscriptionMethod>(method: M, params: ClusterMethodParams[M], options?: CallOptions): Promise<EstablishedSubscription<ClusterMethodResults[M]>>;
|
|
@@ -4,42 +4,8 @@ import { boundedFrameText, isRecord } from './frames.mjs';
|
|
|
4
4
|
import { BoundedQueue } from './queue.mjs';
|
|
5
5
|
import { addSocketListener } from './socket.mjs';
|
|
6
6
|
import { assertDefinition, assertMethodResult } from './validators.mjs';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
configurable: false, enumerable: false,
|
|
10
|
-
value: Symbol.for('Symbol.asyncDispose'), writable: false,
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
export const CONNECTION_TRANSITIONS = Object.freeze({
|
|
14
|
-
OPEN: Object.freeze(['CLOSING']),
|
|
15
|
-
CLOSING: Object.freeze(['CLOSED']),
|
|
16
|
-
CLOSED: Object.freeze([]),
|
|
17
|
-
});
|
|
18
|
-
export const PROTOCOL_DIAGNOSTIC_CAPACITY = 128;
|
|
19
|
-
export const CLOSE_REASON_MAX_BYTES = 123;
|
|
20
|
-
const CLOSE_REASON_ENCODER = new TextEncoder();
|
|
21
|
-
function boundedCloseReason(reason) {
|
|
22
|
-
const retained = [];
|
|
23
|
-
const scratch = new Uint8Array(4);
|
|
24
|
-
let bytes = 0;
|
|
25
|
-
for (const codePoint of reason) {
|
|
26
|
-
const { written } = CLOSE_REASON_ENCODER.encodeInto(codePoint, scratch);
|
|
27
|
-
if (bytes + written > CLOSE_REASON_MAX_BYTES)
|
|
28
|
-
break;
|
|
29
|
-
retained.push(codePoint);
|
|
30
|
-
bytes += written;
|
|
31
|
-
}
|
|
32
|
-
return retained.join('');
|
|
33
|
-
}
|
|
34
|
-
function deferred() {
|
|
35
|
-
let resolve;
|
|
36
|
-
let reject;
|
|
37
|
-
const promise = new Promise((onResolve, onReject) => {
|
|
38
|
-
resolve = onResolve;
|
|
39
|
-
reject = onReject;
|
|
40
|
-
});
|
|
41
|
-
return { promise, resolve, reject };
|
|
42
|
-
}
|
|
7
|
+
import { CONNECTION_TRANSITIONS, PROTOCOL_DIAGNOSTIC_CAPACITY, deferred, } from './connection-state.mjs';
|
|
8
|
+
export { CONNECTION_TRANSITIONS, PROTOCOL_DIAGNOSTIC_CAPACITY, } from './connection-state.mjs';
|
|
43
9
|
export class Connection {
|
|
44
10
|
#state = 'OPEN';
|
|
45
11
|
#sequence = 1;
|
|
@@ -50,7 +16,9 @@ export class Connection {
|
|
|
50
16
|
#ownedSubscriptions = new WeakSet();
|
|
51
17
|
#closePromise;
|
|
52
18
|
#closeCode;
|
|
53
|
-
#
|
|
19
|
+
#closedCompletion = deferred();
|
|
20
|
+
closed = this.#closedCompletion.promise;
|
|
21
|
+
#closeSnapshot;
|
|
54
22
|
closeDiagnostics = [];
|
|
55
23
|
protocolDiagnostics = [];
|
|
56
24
|
#socket;
|
|
@@ -64,7 +32,8 @@ export class Connection {
|
|
|
64
32
|
get pendingSize() { return this.#pending.size; }
|
|
65
33
|
get subscriptionCount() { return this.#subscriptions.size; }
|
|
66
34
|
get closeCode() { return this.#closeCode; }
|
|
67
|
-
get closeReason() { return
|
|
35
|
+
get closeReason() { return undefined; }
|
|
36
|
+
get closeSnapshot() { return this.#closeSnapshot; }
|
|
68
37
|
call(method, params, options = {}) {
|
|
69
38
|
if (!UNARY_METHODS.includes(method)) {
|
|
70
39
|
throw new ClusterConfigError(`${method} is a subscription method`, 'INVALID_METHOD');
|
|
@@ -344,15 +313,11 @@ export class Connection {
|
|
|
344
313
|
const first = args[0];
|
|
345
314
|
if (typeof first === 'number') {
|
|
346
315
|
this.#closeCode = first;
|
|
347
|
-
const raw = args.length > 1 ? String(args[1]) : undefined;
|
|
348
|
-
this.#closeReason = raw === undefined ? undefined : boundedCloseReason(raw);
|
|
349
316
|
}
|
|
350
317
|
else if (first !== null && typeof first === 'object') {
|
|
351
318
|
const event = first;
|
|
352
319
|
if (typeof event.code === 'number')
|
|
353
320
|
this.#closeCode = event.code;
|
|
354
|
-
if (typeof event.reason === 'string')
|
|
355
|
-
this.#closeReason = boundedCloseReason(event.reason);
|
|
356
321
|
}
|
|
357
322
|
}
|
|
358
323
|
#startClose(sendCancels) {
|
|
@@ -402,6 +367,11 @@ export class Connection {
|
|
|
402
367
|
}
|
|
403
368
|
}
|
|
404
369
|
this.#transition('CLOSED');
|
|
370
|
+
this.#closeSnapshot = Object.freeze({
|
|
371
|
+
code: this.#closeCode ?? null,
|
|
372
|
+
reason: null,
|
|
373
|
+
});
|
|
374
|
+
this.#closedCompletion.resolve(this.#closeSnapshot);
|
|
405
375
|
}
|
|
406
376
|
#transition(to) {
|
|
407
377
|
if (!CONNECTION_TRANSITIONS[this.#state].includes(to))
|
package/lib/cluster/errors.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ClusterRpcError = exports.ClusterRequestError = exports.ClusterTimeoutError = exports.ClusterTransportError = exports.ClusterProtocolError = exports.ClusterInternalError = exports.ClusterStateError = exports.ClusterConfigError = exports.ClusterError = void 0;
|
|
3
|
+
exports.ClusterRpcError = exports.ClusterUpgradeError = exports.ClusterRequestError = exports.ClusterTimeoutError = exports.ClusterTransportError = exports.ClusterProtocolError = exports.ClusterInternalError = exports.ClusterStateError = exports.ClusterConfigError = exports.ClusterError = void 0;
|
|
4
4
|
exports.requestAbortError = requestAbortError;
|
|
5
5
|
class ClusterError extends Error {
|
|
6
6
|
code;
|
|
@@ -32,6 +32,14 @@ exports.ClusterTimeoutError = ClusterTimeoutError;
|
|
|
32
32
|
class ClusterRequestError extends ClusterError {
|
|
33
33
|
}
|
|
34
34
|
exports.ClusterRequestError = ClusterRequestError;
|
|
35
|
+
class ClusterUpgradeError extends ClusterTransportError {
|
|
36
|
+
status;
|
|
37
|
+
constructor(status) {
|
|
38
|
+
super(`WebSocket upgrade rejected with HTTP ${status}`, 'UPGRADE_REJECTED');
|
|
39
|
+
this.status = status;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.ClusterUpgradeError = ClusterUpgradeError;
|
|
35
43
|
function requestAbortError(method) {
|
|
36
44
|
return new DOMException(`${method} aborted locally; the server may still have committed this request`, 'AbortError');
|
|
37
45
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { DomainErrorData } from './generated/protocol.js';
|
|
2
|
+
export declare class ClusterError extends Error {
|
|
3
|
+
readonly code: string;
|
|
4
|
+
constructor(message: string, code: string, options?: ErrorOptions);
|
|
5
|
+
}
|
|
6
|
+
export declare class ClusterConfigError extends ClusterError {
|
|
7
|
+
}
|
|
8
|
+
export declare class ClusterStateError extends ClusterError {
|
|
9
|
+
}
|
|
10
|
+
export declare class ClusterInternalError extends ClusterError {
|
|
11
|
+
}
|
|
12
|
+
export declare class ClusterProtocolError extends ClusterError {
|
|
13
|
+
}
|
|
14
|
+
export declare class ClusterTransportError extends ClusterError {
|
|
15
|
+
}
|
|
16
|
+
export declare class ClusterTimeoutError extends ClusterError {
|
|
17
|
+
}
|
|
18
|
+
export declare class ClusterRequestError extends ClusterError {
|
|
19
|
+
}
|
|
20
|
+
export declare class ClusterUpgradeError extends ClusterTransportError {
|
|
21
|
+
readonly status: number;
|
|
22
|
+
constructor(status: number);
|
|
23
|
+
}
|
|
24
|
+
export declare function requestAbortError(method: string): DOMException;
|
|
25
|
+
export declare class ClusterRpcError extends ClusterError {
|
|
26
|
+
readonly rpcCode: number;
|
|
27
|
+
readonly data?: DomainErrorData | undefined;
|
|
28
|
+
constructor(rpcCode: number, message: string, data?: DomainErrorData | undefined);
|
|
29
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { DomainErrorData } from './generated/protocol.js';
|
|
2
|
+
export declare class ClusterError extends Error {
|
|
3
|
+
readonly code: string;
|
|
4
|
+
constructor(message: string, code: string, options?: ErrorOptions);
|
|
5
|
+
}
|
|
6
|
+
export declare class ClusterConfigError extends ClusterError {
|
|
7
|
+
}
|
|
8
|
+
export declare class ClusterStateError extends ClusterError {
|
|
9
|
+
}
|
|
10
|
+
export declare class ClusterInternalError extends ClusterError {
|
|
11
|
+
}
|
|
12
|
+
export declare class ClusterProtocolError extends ClusterError {
|
|
13
|
+
}
|
|
14
|
+
export declare class ClusterTransportError extends ClusterError {
|
|
15
|
+
}
|
|
16
|
+
export declare class ClusterTimeoutError extends ClusterError {
|
|
17
|
+
}
|
|
18
|
+
export declare class ClusterRequestError extends ClusterError {
|
|
19
|
+
}
|
|
20
|
+
export declare class ClusterUpgradeError extends ClusterTransportError {
|
|
21
|
+
readonly status: number;
|
|
22
|
+
constructor(status: number);
|
|
23
|
+
}
|
|
24
|
+
export declare function requestAbortError(method: string): DOMException;
|
|
25
|
+
export declare class ClusterRpcError extends ClusterError {
|
|
26
|
+
readonly rpcCode: number;
|
|
27
|
+
readonly data?: DomainErrorData | undefined;
|
|
28
|
+
constructor(rpcCode: number, message: string, data?: DomainErrorData | undefined);
|
|
29
|
+
}
|
package/lib/cluster/errors.d.ts
CHANGED
|
@@ -17,6 +17,10 @@ export declare class ClusterTimeoutError extends ClusterError {
|
|
|
17
17
|
}
|
|
18
18
|
export declare class ClusterRequestError extends ClusterError {
|
|
19
19
|
}
|
|
20
|
+
export declare class ClusterUpgradeError extends ClusterTransportError {
|
|
21
|
+
readonly status: number;
|
|
22
|
+
constructor(status: number);
|
|
23
|
+
}
|
|
20
24
|
export declare function requestAbortError(method: string): DOMException;
|
|
21
25
|
export declare class ClusterRpcError extends ClusterError {
|
|
22
26
|
readonly rpcCode: number;
|
package/lib/cluster/errors.mjs
CHANGED
|
@@ -20,6 +20,13 @@ export class ClusterTimeoutError extends ClusterError {
|
|
|
20
20
|
}
|
|
21
21
|
export class ClusterRequestError extends ClusterError {
|
|
22
22
|
}
|
|
23
|
+
export class ClusterUpgradeError extends ClusterTransportError {
|
|
24
|
+
status;
|
|
25
|
+
constructor(status) {
|
|
26
|
+
super(`WebSocket upgrade rejected with HTTP ${status}`, 'UPGRADE_REJECTED');
|
|
27
|
+
this.status = status;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
23
30
|
export function requestAbortError(method) {
|
|
24
31
|
return new DOMException(`${method} aborted locally; the server may still have committed this request`, 'AbortError');
|
|
25
32
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type FrameRecord = Readonly<Record<string, unknown>>;
|
|
2
|
+
export type BoundedFrameText = {
|
|
3
|
+
readonly kind: 'frame';
|
|
4
|
+
readonly text: string;
|
|
5
|
+
readonly bytes: number;
|
|
6
|
+
} | {
|
|
7
|
+
readonly kind: 'oversized';
|
|
8
|
+
} | {
|
|
9
|
+
readonly kind: 'unsupported';
|
|
10
|
+
};
|
|
11
|
+
export declare function boundedFrameText(event: unknown, maximum: number): BoundedFrameText;
|
|
12
|
+
export declare function isRecord(value: unknown): value is FrameRecord;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type FrameRecord = Readonly<Record<string, unknown>>;
|
|
2
|
+
export type BoundedFrameText = {
|
|
3
|
+
readonly kind: 'frame';
|
|
4
|
+
readonly text: string;
|
|
5
|
+
readonly bytes: number;
|
|
6
|
+
} | {
|
|
7
|
+
readonly kind: 'oversized';
|
|
8
|
+
} | {
|
|
9
|
+
readonly kind: 'unsupported';
|
|
10
|
+
};
|
|
11
|
+
export declare function boundedFrameText(event: unknown, maximum: number): BoundedFrameText;
|
|
12
|
+
export declare function isRecord(value: unknown): value is FrameRecord;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const CLUSTER_PROTOCOL_SCHEMA: unknown;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const CLUSTER_PROTOCOL_SCHEMA: unknown;
|