feat(): upgrade WebSocket layer to extend BaseWS abstraction. feat(): add promisified WS workflows, feat(): add WS API integration

This commit is contained in:
tiagosiebler
2025-01-16 16:47:09 +00:00
parent b613fd956d
commit 8a7c8ea274
9 changed files with 2512 additions and 1200 deletions

View File

@@ -4,6 +4,7 @@ import {
WebsocketSucceededTopicSubscriptionConfirmationEvent,
WebsocketTopicSubscriptionConfirmationEvent,
} from '../types/websockets/ws-confirmations';
import { WSAPIResponse, WS_API_Operations } from '../types/websockets/ws-api';
export interface RestClientOptions {
/** Your API key */
@@ -199,6 +200,20 @@ export function isTopicSubscriptionConfirmation(
return true;
}
export function isWSAPIResponse(
msg: unknown,
): msg is Omit<WSAPIResponse, 'wsKey'> {
if (typeof msg !== 'object' || !msg) {
return false;
}
if (typeof msg['op'] !== 'string') {
return false;
}
return (WS_API_Operations as string[]).includes(msg['op']);
}
export function isTopicSubscriptionSuccess(
msg: unknown,
): msg is WebsocketSucceededTopicSubscriptionConfirmationEvent {