feat: milestones

This commit is contained in:
Carlos Valente
2025-07-07 15:37:54 +02:00
committed by Carlos Valente
parent a7ae8598db
commit f2913971db
26 changed files with 610 additions and 77 deletions
@@ -1,4 +1,4 @@
import type { OntimeEntry } from '../../definitions/core/Rundown.type.js';
import type { OntimeEntry } from '../../definitions/core/OntimeEntry.js';
export type PatchWithId<T extends OntimeEntry = OntimeEntry> = Partial<T> & { id: string };
@@ -6,6 +6,7 @@ export enum SupportedEntry {
Event = 'event',
Delay = 'delay',
Block = 'block',
Milestone = 'milestone',
}
export type OntimeBaseEvent = {
@@ -19,6 +20,18 @@ export type OntimeDelay = OntimeBaseEvent & {
parent: EntryId | null;
};
export type OntimeMilestone = OntimeBaseEvent & {
type: SupportedEntry.Milestone;
cue: string;
title: string;
note: string;
colour: string;
custom: EntryCustomFields;
parent: EntryId | null;
// !==== RUNTIME METADATA ====! //
revision: number;
};
export type OntimeBlock = OntimeBaseEvent & {
type: SupportedEntry.Block;
title: string;
@@ -65,3 +78,7 @@ export type OntimeEvent = OntimeBaseEvent & {
export type PlayableEvent = OntimeEvent & { skip: false };
export type TimeField = 'timeStart' | 'timeEnd' | 'duration';
export type OntimeEntry = OntimeDelay | OntimeBlock | OntimeEvent | OntimeMilestone;
// we need to create a manual union type since keys cannot be used in type unions
export type OntimeEntryCommonKeys = keyof OntimeEvent | keyof OntimeDelay | keyof OntimeBlock | keyof OntimeMilestone;
@@ -1,11 +1,7 @@
import type { EntryId, OntimeBlock, OntimeDelay, OntimeEvent } from './OntimeEvent.type.js';
import type { EntryId, OntimeEntry } from './OntimeEntry.js';
export type OntimeEntry = OntimeDelay | OntimeBlock | OntimeEvent;
export type RundownEntries = Record<EntryId, OntimeEntry>;
// we need to create a manual union type since keys cannot be used in type unions
export type OntimeEntryCommonKeys = keyof OntimeEvent | keyof OntimeDelay | keyof OntimeBlock;
type RundownId = string;
export type ProjectRundowns = Record<RundownId, Rundown>;
@@ -1,5 +1,5 @@
import type { MaybeNumber } from '../../utils/utils.type.js';
import type { EntryId } from '../core/OntimeEvent.type.js';
import type { EntryId } from '../core/OntimeEntry.js';
export type BlockState = {
id: EntryId;
@@ -1,4 +1,4 @@
import type { OntimeEvent } from '../core/OntimeEvent.type.js';
import type { OntimeEvent } from '../core/OntimeEntry.js';
import type { SimpleTimerState } from './AuxTimer.type.js';
import type { BlockState } from './CurrentBlockState.type.js';
import type { MessageState } from './MessageControl.type.js';
+6 -8
View File
@@ -8,18 +8,15 @@ export {
type OntimeBaseEvent,
type OntimeDelay,
type OntimeBlock,
type OntimeEntryCommonKeys,
type OntimeEntry,
type OntimeMilestone,
type OntimeEvent,
type PlayableEvent,
type TimeField,
SupportedEntry as SupportedEntry,
} from './definitions/core/OntimeEvent.type.js';
export type {
OntimeEntryCommonKeys,
OntimeEntry,
RundownEntries,
Rundown,
ProjectRundowns,
} from './definitions/core/Rundown.type.js';
} from './definitions/core/OntimeEntry.js';
export type { RundownEntries, Rundown, ProjectRundowns } from './definitions/core/Rundown.type.js';
export { TimeStrategy } from './definitions/TimeStrategy.type.js';
export { TimerType } from './definitions/TimerType.type.js';
@@ -114,6 +111,7 @@ export {
isOntimeBlock,
isOntimeDelay,
isOntimeEvent,
isOntimeMilestone,
isPlayableEvent,
isKeyOfType,
isOSCOutput,
+13 -3
View File
@@ -1,7 +1,13 @@
import type { AutomationOutput, HTTPOutput, OntimeAction, OSCOutput } from '../definitions/core/Automation.type.js';
import type { OntimeBlock, OntimeDelay, OntimeEvent, PlayableEvent } from '../definitions/core/OntimeEvent.type.js';
import { SupportedEntry } from '../definitions/core/OntimeEvent.type.js';
import type { OntimeEntry } from '../definitions/core/Rundown.type.js';
import type {
OntimeBlock,
OntimeDelay,
OntimeEntry,
OntimeEvent,
OntimeMilestone,
PlayableEvent,
} from '../definitions/core/OntimeEntry.js';
import { SupportedEntry } from '../definitions/core/OntimeEntry.js';
import { type TimerLifeCycle, timerLifecycleValues } from '../definitions/core/TimerLifecycle.type.js';
type MaybeEvent = OntimeEntry | Partial<OntimeEntry> | null | undefined;
@@ -22,6 +28,10 @@ export function isOntimeBlock(event: MaybeEvent): event is OntimeBlock {
return event?.type === SupportedEntry.Block;
}
export function isOntimeMilestone(event: MaybeEvent): event is OntimeMilestone {
return event?.type === SupportedEntry.Milestone;
}
type AnyKeys<T> = keyof T;
export function isKeyOfType<T extends object>(key: PropertyKey, obj: T): key is AnyKeys<T> {