mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-14 03:43:50 +00:00
refactor: restructure model to contain an object of rundowns
This commit is contained in:
@@ -1,17 +1,8 @@
|
||||
import type { OntimeBlock, OntimeDelay, OntimeEvent } from '../../definitions/core/OntimeEvent.type.js';
|
||||
import type { OntimeRundownEntry } from '../../definitions/core/Rundown.type.js';
|
||||
|
||||
type EventId = string;
|
||||
export type NormalisedRundown = Record<EventId, OntimeRundownEntry>;
|
||||
|
||||
export interface RundownCached {
|
||||
rundown: NormalisedRundown;
|
||||
order: EventId[];
|
||||
revision: number;
|
||||
}
|
||||
import type { OntimeEntry } from '../../definitions/core/Rundown.type.js';
|
||||
|
||||
export type PatchWithId = Partial<OntimeEvent | OntimeDelay | OntimeBlock> & { id: string };
|
||||
export type EventPostPayload = Partial<OntimeRundownEntry> & {
|
||||
export type EventPostPayload = Partial<OntimeEntry> & {
|
||||
after?: string;
|
||||
before?: string;
|
||||
};
|
||||
@@ -20,3 +11,10 @@ export type TransientEventPayload = Partial<OntimeEvent | OntimeDelay | OntimeBl
|
||||
after?: string;
|
||||
before?: string;
|
||||
};
|
||||
|
||||
export type ProjectRundownsList = {
|
||||
id: string;
|
||||
title: string;
|
||||
numEntries: number;
|
||||
revision: number;
|
||||
}[];
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
import type {
|
||||
AutomationSettings,
|
||||
CustomFields,
|
||||
OntimeRundown,
|
||||
ProjectData,
|
||||
ProjectRundowns,
|
||||
Settings,
|
||||
URLPreset,
|
||||
ViewSettings,
|
||||
} from '../index.js';
|
||||
|
||||
export type DatabaseModel = {
|
||||
rundown: OntimeRundown;
|
||||
rundowns: ProjectRundowns;
|
||||
project: ProjectData;
|
||||
settings: Settings;
|
||||
viewSettings: ViewSettings;
|
||||
|
||||
@@ -7,4 +7,4 @@ export type CustomField = {
|
||||
};
|
||||
|
||||
export type CustomFields = Record<CustomFieldLabel, CustomField>;
|
||||
export type EventCustomFields = Record<CustomFieldLabel, string>;
|
||||
export type EntryCustomFields = Record<CustomFieldLabel, string>;
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import type { EndAction, EventCustomFields, MaybeString, TimerType, TimeStrategy, Trigger } from '../../index.js';
|
||||
import type { EndAction, EntryCustomFields, MaybeNumber, MaybeString, TimerType, TimeStrategy, Trigger } from '../../index.js';
|
||||
|
||||
export type EntryId = string;
|
||||
|
||||
export enum SupportedEvent {
|
||||
Event = 'event',
|
||||
@@ -8,7 +10,7 @@ export enum SupportedEvent {
|
||||
|
||||
export type OntimeBaseEvent = {
|
||||
type: SupportedEvent;
|
||||
id: string;
|
||||
id: EntryId;
|
||||
};
|
||||
|
||||
export type OntimeDelay = OntimeBaseEvent & {
|
||||
@@ -19,6 +21,18 @@ export type OntimeDelay = OntimeBaseEvent & {
|
||||
export type OntimeBlock = OntimeBaseEvent & {
|
||||
type: SupportedEvent.Block;
|
||||
title: string;
|
||||
note: string;
|
||||
events: EntryId[];
|
||||
skip: boolean;
|
||||
colour: string;
|
||||
custom: EntryCustomFields;
|
||||
// !==== RUNTIME METADATA ====! //
|
||||
revision: number;
|
||||
startTime: MaybeNumber; // calculated at runtime
|
||||
endTime: MaybeNumber; // calculated at runtime
|
||||
duration: number; // calculated at runtime
|
||||
isFirstLinked: boolean; // calculated at runtime, whether the first event is linked
|
||||
numEvents: number; // calculated at runtime
|
||||
};
|
||||
|
||||
export type OntimeEvent = OntimeBaseEvent & {
|
||||
@@ -37,14 +51,16 @@ export type OntimeEvent = OntimeBaseEvent & {
|
||||
isPublic: boolean;
|
||||
skip: boolean;
|
||||
colour: string;
|
||||
timeWarning: number;
|
||||
timeDanger: number;
|
||||
custom: EntryCustomFields;
|
||||
triggers?: Trigger[];
|
||||
// !==== RUNTIME METADATA ====! //
|
||||
currentBlock: EntryId | null;
|
||||
revision: number;
|
||||
delay: number; // calculated at runtime
|
||||
dayOffset: number; // calculated at runtime
|
||||
gap: number; // calculated at runtime
|
||||
timeWarning: number;
|
||||
timeDanger: number;
|
||||
custom: EventCustomFields;
|
||||
triggers?: Trigger[];
|
||||
};
|
||||
|
||||
export type PlayableEvent = OntimeEvent & { skip: false };
|
||||
|
||||
@@ -1,7 +1,17 @@
|
||||
import type { OntimeBlock, OntimeDelay, OntimeEvent } from './OntimeEvent.type.js';
|
||||
import type { EntryId, OntimeBlock, OntimeDelay, OntimeEvent } from './OntimeEvent.type.js';
|
||||
|
||||
export type OntimeRundownEntry = OntimeDelay | OntimeBlock | OntimeEvent;
|
||||
export type OntimeRundown = OntimeRundownEntry[];
|
||||
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;
|
||||
|
||||
export type ProjectRundowns = Record<string, Rundown>;
|
||||
|
||||
export type Rundown = {
|
||||
id: string;
|
||||
title: string;
|
||||
order: EntryId[];
|
||||
entries: RundownEntries;
|
||||
revision: number;
|
||||
};
|
||||
|
||||
@@ -4,6 +4,7 @@ export type { DatabaseModel } from './definitions/DataModel.type.js';
|
||||
// ---> Rundown
|
||||
export { EndAction } from './definitions/EndAction.type.js';
|
||||
export {
|
||||
type EntryId,
|
||||
type OntimeBaseEvent,
|
||||
type OntimeDelay,
|
||||
type OntimeBlock,
|
||||
@@ -12,7 +13,13 @@ export {
|
||||
type TimeField,
|
||||
SupportedEvent,
|
||||
} from './definitions/core/OntimeEvent.type.js';
|
||||
export type { OntimeEntryCommonKeys, OntimeRundown, OntimeRundownEntry } from './definitions/core/Rundown.type.js';
|
||||
export type {
|
||||
OntimeEntryCommonKeys,
|
||||
OntimeEntry,
|
||||
RundownEntries,
|
||||
Rundown,
|
||||
ProjectRundowns,
|
||||
} from './definitions/core/Rundown.type.js';
|
||||
export { TimeStrategy } from './definitions/TimeStrategy.type.js';
|
||||
export { TimerType } from './definitions/TimerType.type.js';
|
||||
|
||||
@@ -53,7 +60,7 @@ export type {
|
||||
CustomFields,
|
||||
CustomField,
|
||||
CustomFieldLabel,
|
||||
EventCustomFields,
|
||||
EntryCustomFields,
|
||||
} from './definitions/core/CustomFields.type.js';
|
||||
|
||||
// SERVER RESPONSES
|
||||
@@ -73,9 +80,8 @@ export type {
|
||||
export type { QuickStartData } from './api/db/db.type.js';
|
||||
export type {
|
||||
EventPostPayload,
|
||||
NormalisedRundown,
|
||||
PatchWithId,
|
||||
RundownCached,
|
||||
ProjectRundownsList,
|
||||
TransientEventPayload,
|
||||
} from './api/rundown-controller/BackendResponse.type.js';
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
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 { SupportedEvent } from '../definitions/core/OntimeEvent.type.js';
|
||||
import type { OntimeRundownEntry } from '../definitions/core/Rundown.type.js';
|
||||
import type { OntimeEntry } from '../definitions/core/Rundown.type.js';
|
||||
import { type TimerLifeCycle, timerLifecycleValues } from '../definitions/core/TimerLifecycle.type.js';
|
||||
|
||||
type MaybeEvent = OntimeRundownEntry | Partial<OntimeRundownEntry> | null | undefined;
|
||||
type MaybeEvent = OntimeEntry | Partial<OntimeEntry> | null | undefined;
|
||||
|
||||
export function isOntimeEvent(event: MaybeEvent): event is OntimeEvent {
|
||||
return event?.type === SupportedEvent.Event;
|
||||
|
||||
Reference in New Issue
Block a user