refactor: create transaction system and apply to adding entry (#1620)

* refactor: create transaction system and apply to adding entry

* refactor: migrate edit mutations to transaction

* refactor: migrate delete mutation to transaction

* refactor: migrate reorder mutation to transaction

* refactor: migrate apply delay to transaction

* refactor: migrate swapEvents to transaction

* refactor: migrate clone to transaction

* refactor: migrate group/ungroup transactions

* refactor: simplify mutations

* refactor: migrate getters

* chore: add tests to processRundown()
This commit is contained in:
Carlos Valente
2025-06-05 06:14:29 +02:00
committed by arc-alex
parent 33ac05ebee
commit aebf949883
37 changed files with 3204 additions and 2704 deletions
@@ -1,8 +1,6 @@
import { EndAction, OntimeEvent, TimerType, isKeyOfType, isOntimeEvent } from 'ontime-types';
import { EndAction, TimerType, isKeyOfType } from 'ontime-types';
import { MILLIS_PER_SECOND, maxDuration } from 'ontime-utils';
import { editEvent } from '../services/rundown-service/RundownService.js';
import { getEntryWithId } from '../services/rundown-service/rundownUtils.js';
import { coerceBoolean, coerceColour, coerceEnum, coerceNumber, coerceString } from '../utils/coerceType.js';
import { getDataProvider } from '../classes/data-provider/DataProvider.js';
@@ -58,19 +56,3 @@ export function parseProperty(property: string, value: unknown) {
const parserFn = propertyConversion[property];
return { [property]: parserFn(value) };
}
/**
* Updates a property of the event with the given id
* @param {Partial<OntimeEvent>} patchEvent
*/
export function updateEvent(patchEvent: Partial<OntimeEvent> & { id: string }) {
const event = getEntryWithId(patchEvent?.id ?? '');
if (!event) {
throw new Error(`Event with ID ${patchEvent?.id} not found`);
}
if (!isOntimeEvent(event)) {
throw new Error('Can only update events');
}
editEvent(patchEvent);
}