feat: count to group completion

This commit is contained in:
Carlos Valente
2026-09-05 08:36:57 +02:00
parent 9ec12f4927
commit 9d2c86d6be
39 changed files with 715 additions and 70 deletions
+8 -1
View File
@@ -34,7 +34,14 @@ export {
group as groupDef,
milestone as milestoneDef,
} from './src/rundown-utils/entryDefinitions.js';
export { createDelay, createEvent, createGroup, createMilestone, makeString } from './src/rundown-utils/entryUtils.js';
export {
createDelay,
createEvent,
createGroup,
createMilestone,
makeString,
validateGroupTimerType,
} from './src/rundown-utils/entryUtils.js';
// time format utils
export {
@@ -52,6 +52,8 @@ export const group: Omit<OntimeGroup, 'id'> = {
note: '',
entries: [],
targetDuration: null,
useGroupTimer: false,
timerType: TimerType.CountDown,
colour: '',
custom: {},
// !==== RUNTIME METADATA ====! //
+13 -1
View File
@@ -1,5 +1,5 @@
import type { OntimeDelay, OntimeEvent, OntimeGroup, OntimeMilestone } from 'ontime-types';
import { SupportedEntry, TimeStrategy } from 'ontime-types';
import { SupportedEntry, TimeStrategy, TimerType } from 'ontime-types';
import { generateId } from '../generate-id/generateId.js';
import { validateEndAction, validateTimerType } from '../validate-events/validateEvent.js';
@@ -67,6 +67,8 @@ export function createGroup(patch?: Partial<OntimeGroup>): OntimeGroup {
note: patch.note ?? '',
entries: patch.entries ?? [],
targetDuration: patch.targetDuration ?? null,
useGroupTimer: patch.useGroupTimer === true,
timerType: validateGroupTimerType(patch.timerType),
colour: makeString(patch.colour, ''),
custom: patch.custom ?? {},
revision: 0,
@@ -77,6 +79,16 @@ export function createGroup(patch?: Partial<OntimeGroup>): OntimeGroup {
};
}
export function validateGroupTimerType(
value: unknown,
fallback: unknown = TimerType.CountDown,
): TimerType.CountDown | TimerType.CountUp {
if (value === TimerType.CountDown || value === TimerType.CountUp) {
return value;
}
return fallback === TimerType.CountUp ? TimerType.CountUp : TimerType.CountDown;
}
/**
* Creates a new milestone from an optional patch
*/