feat: export package to help api consumers (#1624)

This commit is contained in:
Alex Christoffer Rasmussen
2025-09-21 06:53:11 +02:00
committed by Carlos Valente
parent a5d628af0c
commit 5716fc31cf
22 changed files with 773 additions and 49 deletions
+20
View File
@@ -0,0 +1,20 @@
// api
export { MessageTag, RefetchKey } from 'ontime-types';
export type { ApiAction, ApiActionTag, ApiResponse } from 'ontime-types';
export type { WsPacketToClient, WsPacketToServer } from 'ontime-types';
// stores
export type { RuntimeStore, TimerState, MessageState, RundownState, Offset } from 'ontime-types';
export { TimerPhase, Playback, runtimeStorePlaceholder, OffsetMode } from 'ontime-types';
// aux timer
export type { SimpleTimerState } from 'ontime-types';
export { SimplePlayback, SimpleDirection } from 'ontime-types';
// entries
export type { OntimeEvent, OntimeGroup, EntryCustomFields, CustomFields, Rundown } from 'ontime-types';
export { SupportedEntry, isOntimeEvent, isOntimeGroup, isOntimeDelay, isOntimeMilestone } from 'ontime-types';
// functions
export { isWsPacketToClient } from './websocket.js';
export type { SocketSender } from './websocket.js';
+18
View File
@@ -0,0 +1,18 @@
import { ApiAction, ApiActionTag, MessageTag, WsPacketToClient, WsPacketToServer } from 'ontime-types';
/**
* A helper type for sending correct websocket messages to ontime
*/
export type SocketSender = <T extends MessageTag | ApiActionTag>(
tag: T,
payload: T extends MessageTag
? Pick<WsPacketToServer & { tag: T }, 'payload'>['payload']
: Pick<ApiAction & { tag: T }, 'payload'>['payload'],
) => void;
/**
* a soft type guard for WS packets
*/
export function isWsPacketToClient(data: unknown): data is WsPacketToClient {
return typeof data === 'object' && data !== null && 'tag' in data && 'payload' in data;
}