mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-16 04:43:35 +00:00
1849b4d39f
* chore: migrate eslint to oxlint * chore: migrate prettier to oxfmt * chore: migrate typescript * chore: toThrow should have a expected value * chore: cast test value as Day * chore: small title fix * chore: mocks should be hoisted * chore: incorrect async useage * chore: test should be inside description * chore: test sohuld include an expeced * chore: oxfmt --------- Co-authored-by: alex-Arc <omnivox@LAPTOP-RC5SNBVV.localdomain>
86 lines
1.8 KiB
TypeScript
86 lines
1.8 KiB
TypeScript
import {
|
|
CustomField,
|
|
OntimeDelay,
|
|
OntimeEvent,
|
|
OntimeGroup,
|
|
OntimeMilestone,
|
|
Rundown,
|
|
SupportedEntry,
|
|
} from 'ontime-types';
|
|
|
|
import { makeNewRundown } from '../../../models/dataModel.js';
|
|
|
|
const baseEvent = {
|
|
type: SupportedEntry.Event,
|
|
skip: false,
|
|
revision: 1,
|
|
};
|
|
|
|
const baseGroup = {
|
|
type: SupportedEntry.Group,
|
|
entries: [],
|
|
};
|
|
|
|
const baseMilestone = {
|
|
type: SupportedEntry.Milestone,
|
|
cue: '',
|
|
title: '',
|
|
};
|
|
|
|
/**
|
|
* Utility to create an Ontime event
|
|
*/
|
|
export function makeOntimeEvent(patch: Partial<OntimeEvent>): OntimeEvent {
|
|
return {
|
|
...baseEvent,
|
|
...patch,
|
|
} as OntimeEvent;
|
|
}
|
|
|
|
/**
|
|
* Utility to create a delay entry
|
|
*/
|
|
export function makeOntimeDelay(patch: Partial<OntimeDelay>): OntimeDelay {
|
|
return { id: 'delay', type: SupportedEntry.Delay, duration: 0, ...patch } as OntimeDelay;
|
|
}
|
|
|
|
/**
|
|
* Utility to create a group entry
|
|
*/
|
|
export function makeOntimeGroup(patch: Partial<OntimeGroup>): OntimeGroup {
|
|
return { id: 'group', ...baseGroup, ...patch } as OntimeGroup;
|
|
}
|
|
|
|
/**
|
|
* Utility to create a milestone entry
|
|
*/
|
|
export function makeOntimeMilestone(patch: Partial<OntimeMilestone>): OntimeMilestone {
|
|
return { id: 'milestone', ...baseMilestone, ...patch } as OntimeMilestone;
|
|
}
|
|
|
|
/**
|
|
* Utility to create a rundown object
|
|
*/
|
|
export function makeRundown(patch: Partial<Rundown>): Rundown {
|
|
return {
|
|
...makeNewRundown(),
|
|
...patch,
|
|
};
|
|
}
|
|
|
|
export function makeCustomField(patch: Partial<CustomField>): CustomField {
|
|
return {
|
|
type: 'text',
|
|
colour: '#000000',
|
|
label: 'Custom Field',
|
|
...patch,
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Utility to generate a rundown of OntimeEvents form partial objects
|
|
*/
|
|
export function prepareTimedEvents(events: Partial<OntimeEvent>[]): OntimeEvent[] {
|
|
return events.map(makeOntimeEvent);
|
|
}
|