chore: improve convention entry <> event

This commit is contained in:
Carlos Valente
2025-04-17 12:40:32 +02:00
committed by arc-alex
parent 3754c374c3
commit 3118c20719
28 changed files with 245 additions and 245 deletions
@@ -1,7 +1,7 @@
/* eslint-disable no-console -- we are mocking the console */
import { assertType, vi } from 'vitest';
import { CustomFields, DatabaseModel, OntimeEvent, SupportedEvent, TimerType } from 'ontime-types';
import { CustomFields, DatabaseModel, OntimeEvent, SupportedEntry, TimerType } from 'ontime-types';
import { ImportMap, MILLIS_PER_MINUTE } from 'ontime-utils';
import { dbModel } from '../../models/dataModel.js';
@@ -537,7 +537,7 @@ describe('parseExcel()', () => {
const firstEvent = result.rundown.entries[result.rundown.order[0]];
expect(result.rundown.order.length).toBe(2);
expect((firstEvent as OntimeEvent).type).toBe(SupportedEvent.Block);
expect((firstEvent as OntimeEvent).type).toBe(SupportedEntry.Block);
});
it('imports as events if there is no timer type column', () => {
@@ -553,12 +553,12 @@ describe('parseExcel()', () => {
expect(result.rundown.order.length).toBe(2);
expect(firstEvent).toMatchObject({
type: SupportedEvent.Event,
type: SupportedEntry.Event,
timerType: TimerType.CountDown,
});
expect(secondEvent).toMatchObject({
type: SupportedEvent.Event,
type: SupportedEntry.Event,
timerType: TimerType.CountDown,
});
});
@@ -580,9 +580,9 @@ describe('parseExcel()', () => {
const secondEvent = result.rundown.entries[result.rundown.order[1]];
const thirdEvent = result.rundown.entries[result.rundown.order[2]];
expect(result.rundown.order.length).toBe(3);
expect(firstEvent).toMatchObject({ title: 'first', type: SupportedEvent.Event, timerType: TimerType.CountDown });
expect(secondEvent).toMatchObject({ title: 'second', type: SupportedEvent.Event, timerType: TimerType.CountDown });
expect(thirdEvent).toMatchObject({ title: 'third', type: SupportedEvent.Event, timerType: TimerType.CountUp });
expect(firstEvent).toMatchObject({ title: 'first', type: SupportedEntry.Event, timerType: TimerType.CountDown });
expect(secondEvent).toMatchObject({ title: 'second', type: SupportedEntry.Event, timerType: TimerType.CountDown });
expect(thirdEvent).toMatchObject({ title: 'third', type: SupportedEntry.Event, timerType: TimerType.CountUp });
});
it('am/pm conversion to 24h', () => {
@@ -697,7 +697,7 @@ describe('parseExcel()', () => {
linkStart: false,
},
BLOCK: {
type: SupportedEvent.Block,
type: SupportedEntry.Block,
},
E: {
linkStart: true,
@@ -1,4 +1,4 @@
import { CustomFields, OntimeBlock, OntimeEvent, Rundown, Settings, SupportedEvent, URLPreset } from 'ontime-types';
import { CustomFields, OntimeBlock, OntimeEvent, Rundown, Settings, SupportedEntry, URLPreset } from 'ontime-types';
import { defaultRundown } from '../../models/dataModel.js';
@@ -56,8 +56,8 @@ describe('parseRundown()', () => {
order: ['1', '2', '3', '4'],
flatOrder: ['1', '2', '3', '4'],
entries: {
'1': { id: '1', type: SupportedEvent.Event, title: 'test', skip: false } as OntimeEvent, // OK
'2': { id: '1', type: SupportedEvent.Block, title: 'test 2', skip: false } as OntimeBlock, // duplicate ID
'1': { id: '1', type: SupportedEntry.Event, title: 'test', skip: false } as OntimeEvent, // OK
'2': { id: '1', type: SupportedEntry.Block, title: 'test 2', skip: false } as OntimeBlock, // duplicate ID
'3': {} as OntimeEvent, // no data
'4': { id: '4', title: 'test 2', skip: false } as OntimeEvent, // no type
},
@@ -72,7 +72,7 @@ describe('parseRundown()', () => {
expect(parsedRundown.entries).toMatchObject({
'1': {
id: '1',
type: SupportedEvent.Event,
type: SupportedEntry.Event,
title: 'test',
skip: false,
},
@@ -88,9 +88,9 @@ describe('parseRundown()', () => {
flatOrder: ['1', '2'],
entries: {
// @ts-expect-error -- testing external data which could be incorrect
'1': { id: '1', type: SupportedEvent.Event, cue: 101 } as OntimeEvent,
'1': { id: '1', type: SupportedEntry.Event, cue: 101 } as OntimeEvent,
// @ts-expect-error -- testing external data which could be incorrect
'2': { id: '2', type: SupportedEvent.Event, cue: 101.1 } as OntimeEvent,
'2': { id: '2', type: SupportedEntry.Event, cue: 101.1 } as OntimeEvent,
},
revision: 1,
} as Rundown;
@@ -114,8 +114,8 @@ describe('parseRundown()', () => {
order: ['1', '1'],
flatOrder: ['1', '1'],
entries: {
'1': { id: '1', type: SupportedEvent.Event } as OntimeEvent,
'2': { id: '2', type: SupportedEvent.Event } as OntimeEvent,
'1': { id: '1', type: SupportedEntry.Event } as OntimeEvent,
'2': { id: '2', type: SupportedEntry.Event } as OntimeEvent,
},
revision: 1,
} as Rundown;
@@ -132,8 +132,8 @@ describe('parseRundown()', () => {
order: ['1', '2'],
flatOrder: ['1', '2'],
entries: {
'1': { id: '1', type: SupportedEvent.Event } as OntimeEvent,
'2': { id: '2', type: SupportedEvent.Event } as OntimeEvent,
'1': { id: '1', type: SupportedEntry.Event } as OntimeEvent,
'2': { id: '2', type: SupportedEntry.Event } as OntimeEvent,
},
revision: 1,
} as Rundown;
@@ -161,8 +161,8 @@ describe('parseRundown()', () => {
order: ['1', '2', '3', '4'],
flatOrder: ['1', '2', '3', '4'],
entries: {
'1': { id: '1', type: SupportedEvent.Event } as OntimeEvent,
'2': { id: '2', type: SupportedEvent.Event } as OntimeEvent,
'1': { id: '1', type: SupportedEntry.Event } as OntimeEvent,
'2': { id: '2', type: SupportedEntry.Event } as OntimeEvent,
'not-mentioned': {} as OntimeEvent,
},
revision: 1,
@@ -180,8 +180,8 @@ describe('parseRundown()', () => {
order: ['1', '2', '3', '4'],
flatOrder: ['1', '2', '3', '4'],
entries: {
'1': { id: '1', type: SupportedEvent.Event } as OntimeEvent,
'2': { id: '2', type: SupportedEvent.Event } as OntimeEvent,
'1': { id: '1', type: SupportedEntry.Event } as OntimeEvent,
'2': { id: '2', type: SupportedEntry.Event } as OntimeEvent,
'not-mentioned': {} as OntimeEvent,
},
revision: 1,
+5 -5
View File
@@ -18,7 +18,7 @@ import {
OntimeBlock,
OntimeEvent,
Rundown,
SupportedEvent,
SupportedEntry,
TimerType,
TimeStrategy,
} from 'ontime-types';
@@ -232,10 +232,10 @@ export const parseExcel = (
const maybeTimeType = makeString(column, '');
if (maybeTimeType === 'block') {
// we leave this as a clue for the object filtering later on
entry.type = SupportedEvent.Block;
entry.type = SupportedEntry.Block;
} else if (maybeTimeType === '' || maybeTimeType === 'event' || isKnownTimerType(maybeTimeType)) {
// @ts-expect-error -- we leave this as a clue for the object filtering later on
entry.type = SupportedEvent.Event;
entry.type = SupportedEntry.Event;
entry.timerType = validateTimerType(maybeTimeType);
} else {
// if it is not a block or a known type, we dont import it
@@ -320,7 +320,7 @@ export const parseExcel = (
const event = {
...entry,
custom: { ...entryCustomFields },
type: SupportedEvent.Event,
type: SupportedEntry.Event,
} as OntimeEvent;
if (timerTypeIndex === null) {
@@ -407,7 +407,7 @@ export function createPatch(originalEvent: OntimeEvent, patchEvent: Partial<Onti
return {
id: originalEvent.id,
type: SupportedEvent.Event,
type: SupportedEntry.Event,
title: makeString(patchEvent.title, originalEvent.title),
timeStart,
timeEnd,