mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-14 11:53:49 +00:00
feat: export package to help api consumers (#1624)
This commit is contained in:
committed by
Carlos Valente
parent
a5d628af0c
commit
5716fc31cf
@@ -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';
|
||||
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user