Deps migration (#1988)

* 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>
This commit is contained in:
Carlos Valente
2026-03-08 16:22:12 +01:00
committed by GitHub
parent 9516ac21bb
commit 1849b4d39f
501 changed files with 2678 additions and 4654 deletions
@@ -1,24 +1,20 @@
import { dayInMs, MILLIS_PER_HOUR, MILLIS_PER_MINUTE } from 'ontime-utils';
import { PlayableEvent } from 'ontime-types';
import { MILLIS_PER_HOUR, MILLIS_PER_MINUTE, dayInMs } from 'ontime-utils';
import { initRundown } from '../../api-data/rundown/rundown.service.js';
import { processRundown, rundownCache } from '../../api-data/rundown/rundown.dao.js';
import { makeOntimeEvent, makeRundown } from '../../api-data/rundown/__mocks__/rundown.mocks.js';
import { processRundown, rundownCache } from '../../api-data/rundown/rundown.dao.js';
import { initRundown } from '../../api-data/rundown/rundown.service.js';
import { loadRoll } from '../rollUtils.js';
beforeAll(() => {
vi.mock('../../classes/data-provider/DataProvider.js', () => {
return {
getDataProvider: vi.fn().mockImplementation(() => {
return {
setCustomFields: vi.fn().mockImplementation((newData) => newData),
setRundown: vi.fn().mockImplementation((newData) => newData),
};
}),
};
});
vi.mock('../../classes/data-provider/DataProvider.js', () => {
return {
getDataProvider: vi.fn().mockImplementation(() => {
return {
setCustomFields: vi.fn().mockImplementation((newData) => newData),
setRundown: vi.fn().mockImplementation((newData) => newData),
};
}),
};
});
const mockEvent = {
@@ -727,7 +723,7 @@ describe('loadRoll() test that roll behaviour multi day event edge cases', () =>
id: '2',
timeStart: 11 * MILLIS_PER_HOUR,
timeEnd: 2 * MILLIS_PER_HOUR,
duration: 14 * MILLIS_PER_HOUR
duration: 14 * MILLIS_PER_HOUR,
},
},
}),
@@ -782,7 +778,7 @@ describe('loadRoll() test that roll behaviour multi day event edge cases', () =>
});
describe('loadRoll() should not roll skipped events', () => {
test('', async () => {
test('load roll', async () => {
vi.useFakeTimers();
await initRundown(
makeRundown({
@@ -1,6 +1,7 @@
import { dayInMs, MILLIS_PER_HOUR, MILLIS_PER_MINUTE, MILLIS_PER_SECOND, millisToString } from 'ontime-utils';
import { EndAction, Playback, TimeOfDay, TimeStrategy, TimerPhase, TimerType } from 'ontime-types';
import { MILLIS_PER_HOUR, MILLIS_PER_MINUTE, MILLIS_PER_SECOND, dayInMs, millisToString } from 'ontime-utils';
import type { RuntimeState } from '../../stores/runtimeState.js';
import {
findDayOffset,
getCurrent,
@@ -11,7 +12,8 @@ import {
normaliseEndTime,
skippedOutOfEvent,
} from '../timerUtils.js';
import type { RuntimeState } from '../../stores/runtimeState.js';
const asTimeOfDay = (value: number): RuntimeState['clock'] => value as RuntimeState['clock'];
describe('getExpectedFinish()', () => {
it('is null if we havent started', () => {
@@ -574,7 +576,7 @@ describe('skippedOutOfEvent()', () => {
expect(skippedOutOfEvent(state, previousTime, testSkipLimit)).toBe(false);
state.clock += testSkipLimit;
state.clock = asTimeOfDay(state.clock + testSkipLimit);
expect(skippedOutOfEvent(state, previousTime, testSkipLimit)).toBe(false);
});
@@ -594,7 +596,7 @@ describe('skippedOutOfEvent()', () => {
expect(skippedOutOfEvent(state, previousTime, testSkipLimit)).toBe(false);
state.clock += testSkipLimit;
state.clock = asTimeOfDay(state.clock + testSkipLimit);
expect(skippedOutOfEvent(state, previousTime, testSkipLimit)).toBe(false);
});
@@ -613,7 +615,7 @@ describe('skippedOutOfEvent()', () => {
expect(skippedOutOfEvent(state, previousTime, testSkipLimit)).toBe(false);
state.clock = testSkipLimit - 2;
state.clock = asTimeOfDay(testSkipLimit - 2);
expect(skippedOutOfEvent(state, previousTime, testSkipLimit)).toBe(false);
});
@@ -632,7 +634,7 @@ describe('skippedOutOfEvent()', () => {
expect(skippedOutOfEvent(state, previousTime, testSkipLimit)).toBe(false);
state.clock -= testSkipLimit;
state.clock = asTimeOfDay(state.clock - testSkipLimit);
expect(skippedOutOfEvent(state, previousTime, testSkipLimit)).toBe(false);
});
@@ -652,7 +654,7 @@ describe('skippedOutOfEvent()', () => {
expect(skippedOutOfEvent(state, previousTime, testSkipLimit)).toBe(false);
state.clock += testSkipLimit + 1;
state.clock = asTimeOfDay(state.clock + testSkipLimit + 1);
expect(skippedOutOfEvent(state, previousTime, testSkipLimit)).toBe(true);
});
@@ -672,7 +674,7 @@ describe('skippedOutOfEvent()', () => {
expect(skippedOutOfEvent(state, previousTime, testSkipLimit)).toBe(false);
state.clock -= testSkipLimit + 1;
state.clock = asTimeOfDay(state.clock - testSkipLimit - 1);
expect(skippedOutOfEvent(state, previousTime, testSkipLimit)).toBe(true);
});
@@ -691,7 +693,7 @@ describe('skippedOutOfEvent()', () => {
expect(skippedOutOfEvent(state, previousTime, testSkipLimit)).toBe(false);
state.clock = testSkipLimit - 2;
state.clock = asTimeOfDay(testSkipLimit - 2);
expect(skippedOutOfEvent(state, previousTime, testSkipLimit)).toBe(true);
});
@@ -710,7 +712,7 @@ describe('skippedOutOfEvent()', () => {
expect(skippedOutOfEvent(state, previousTime, testSkipLimit)).toBe(false);
state.clock -= testSkipLimit + 1;
state.clock = asTimeOfDay(state.clock - testSkipLimit - 1);
expect(skippedOutOfEvent(state, previousTime, testSkipLimit)).toBe(true);
});
@@ -1253,7 +1255,7 @@ describe('getTimerPhase()', () => {
expect(phase).toBe(TimerPhase.Warning);
});
it('it default if the timer is playing and there is none of the above', () => {
it('is default if the timer is playing and there is none of the above', () => {
const state = {
timer: {
addedTime: 0,
@@ -1,10 +1,10 @@
import { Low } from 'lowdb';
import { JSONFile } from 'lowdb/node';
import { publicFiles } from '../../setup/index.js';
import { isTest } from '../../setup/environment.js';
import { isPath } from '../../utils/fileManagement.js';
import { publicFiles } from '../../setup/index.js';
import { shouldCrashDev } from '../../utils/development.js';
import { isPath } from '../../utils/fileManagement.js';
interface AppState {
projectName?: string;
@@ -1,8 +1,8 @@
import { RuntimeStore, SimpleDirection, SimplePlayback } from 'ontime-types';
import { SimpleTimer } from '../../classes/simple-timer/SimpleTimer.js';
import { eventStore } from '../../stores/EventStore.js';
import { timerConfig } from '../../setup/config.js';
import { eventStore } from '../../stores/EventStore.js';
type AuxTimerStateUpdate = Partial<Pick<RuntimeStore, 'auxtimer1' | 'auxtimer2' | 'auxtimer3'>>;
type EmitFn = (state: AuxTimerStateUpdate) => void;
@@ -2,8 +2,8 @@ import { MessageState, runtimeStorePlaceholder } from 'ontime-types';
import { withoutUndefinedValues } from 'ontime-utils';
import { DeepPartial } from 'ts-essentials';
import type { PublishFn, StoreGetter } from '../../stores/EventStore.js';
import { throttle } from '../../utils/throttle.js';
import type { StoreGetter, PublishFn } from '../../stores/EventStore.js';
/**
* Create a throttled version of the set function
@@ -1,11 +1,22 @@
import { DatabaseModel, LogOrigin, ProjectFileListResponse } from 'ontime-types';
import { getErrorMessage, getFirstRundown } from 'ontime-utils';
import { copyFile } from 'fs/promises';
import { join } from 'path';
import { DatabaseModel, LogOrigin, ProjectFileListResponse } from 'ontime-types';
import { getErrorMessage, getFirstRundown } from 'ontime-utils';
import { parseCustomFields } from '../../api-data/custom-fields/customFields.parser.js';
import { parseDatabaseModel } from '../../api-data/db/db.parser.js';
import { getCurrentRundown } from '../../api-data/rundown/rundown.dao.js';
import { parseRundowns } from '../../api-data/rundown/rundown.parser.js';
import { initRundown } from '../../api-data/rundown/rundown.service.js';
import { getDataProvider, initPersistence } from '../../classes/data-provider/DataProvider.js';
import { safeMerge } from '../../classes/data-provider/DataProvider.utils.js';
import { logger } from '../../classes/Logger.js';
import { makeNewProject } from '../../models/dataModel.js';
import { demoDb } from '../../models/demoProject.js';
import { config } from '../../setup/config.js';
import { publicDir } from '../../setup/index.js';
import { populateOntimeLogo } from '../../setup/loadOntimeLogo.js';
import {
appendToName,
deleteFile,
@@ -16,20 +27,8 @@ import {
getFileNameFromPath,
removeFileExtension,
} from '../../utils/fileManagement.js';
import { parseRundowns } from '../../api-data/rundown/rundown.parser.js';
import { demoDb } from '../../models/demoProject.js';
import { config } from '../../setup/config.js';
import { getDataProvider, initPersistence } from '../../classes/data-provider/DataProvider.js';
import { initRundown } from '../../api-data/rundown/rundown.service.js';
import { parseDatabaseModel } from '../../api-data/db/db.parser.js';
import { parseCustomFields } from '../../api-data/custom-fields/customFields.parser.js';
import { makeNewProject } from '../../models/dataModel.js';
import { safeMerge } from '../../classes/data-provider/DataProvider.utils.js';
import { getCurrentRundown } from '../../api-data/rundown/rundown.dao.js';
import { getLastLoaded, isLastLoadedProject, setLastLoaded } from '../app-state-service/AppStateService.js';
import { runtimeService } from '../runtime-service/runtime.service.js';
import {
doesProjectExist,
getPathToProject,
@@ -37,7 +36,6 @@ import {
moveCorruptFile,
parseJsonFile,
} from './projectServiceUtils.js';
import { populateOntimeLogo } from '../../setup/loadOntimeLogo.js';
type ProjectState =
| {
@@ -1,7 +1,6 @@
import { Mock } from 'vitest';
import { isLastLoadedProject } from '../../app-state-service/AppStateService.js';
import { deleteProjectFile, duplicateProjectFile, renameProjectFile } from '../ProjectService.js';
import { doesProjectExist } from '../projectServiceUtils.js';
@@ -1,9 +1,9 @@
import { DatabaseModel, MaybeString, ProjectFile } from 'ontime-types';
import { existsSync } from 'fs';
import { readFile, stat } from 'fs/promises';
import { extname, join } from 'path';
import { DatabaseModel, MaybeString, ProjectFile } from 'ontime-types';
import { publicDir } from '../../setup/index.js';
import { dockerSafeRename, getFilesFromFolder, removeFileExtension } from '../../utils/fileManagement.js';
@@ -1,8 +1,11 @@
import { Playback } from 'ontime-types';
import type { Instant } from 'ontime-types';
import { isRestorePoint } from '../restore.parser.js';
import { RestorePoint } from '../restore.type.js';
const asInstant = (value: number): Instant => value as Instant;
describe('isRestorePoint()', () => {
it('validates a well defined object', () => {
let restorePoint: RestorePoint = {
@@ -12,7 +15,7 @@ describe('isRestorePoint()', () => {
addedTime: 2,
pausedAt: 3,
firstStart: 1,
startEpoch: 1,
startEpoch: asInstant(1),
currentDay: 0,
};
expect(isRestorePoint(restorePoint)).toBe(true);
@@ -24,7 +27,7 @@ describe('isRestorePoint()', () => {
addedTime: 0,
pausedAt: null,
firstStart: 1,
startEpoch: 1,
startEpoch: asInstant(1),
currentDay: 2,
};
expect(isRestorePoint(restorePoint)).toBe(true);
@@ -1,10 +1,12 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { Playback } from 'ontime-types';
import type { Instant } from 'ontime-types';
import { vi } from 'vitest';
import { RestorePoint } from '../restore.type.js';
import { restoreService } from '../restore.service.js';
import { RestorePoint } from '../restore.type.js';
const asInstant = (value: number): Instant => value as Instant;
describe('restoreService', () => {
describe('load()', () => {
@@ -16,7 +18,7 @@ describe('restoreService', () => {
addedTime: 5678,
pausedAt: 9087,
firstStart: 1234,
startEpoch: 1234,
startEpoch: asInstant(1234),
currentDay: 0,
};
@@ -35,7 +37,7 @@ describe('restoreService', () => {
addedTime: 0,
pausedAt: null,
firstStart: 1234,
startEpoch: 1234,
startEpoch: asInstant(1234),
currentDay: null,
};
@@ -83,7 +85,7 @@ describe('restoreService', () => {
addedTime: 1234,
pausedAt: 1234,
firstStart: 1234,
startEpoch: 1234,
startEpoch: asInstant(1234),
currentDay: 0,
};
@@ -101,7 +103,7 @@ describe('restoreService', () => {
addedTime: 2345,
pausedAt: 2345,
firstStart: 2345,
startEpoch: 2345,
startEpoch: asInstant(2345),
currentDay: 0,
};
@@ -112,7 +114,7 @@ describe('restoreService', () => {
addedTime: 3456,
pausedAt: 3456,
firstStart: 3456,
startEpoch: 3456,
startEpoch: asInstant(3456),
currentDay: 1,
};
@@ -134,7 +136,7 @@ describe('restoreService', () => {
addedTime: 5678,
pausedAt: 5678,
firstStart: 5678,
startEpoch: 5678,
startEpoch: asInstant(5678),
currentDay: 0,
};
@@ -1,7 +1,6 @@
import { Playback } from 'ontime-types';
import { is } from '../../utils/is.js';
import type { RestorePoint } from './restore.type.js';
/**
@@ -1,8 +1,7 @@
import { JSONFile } from 'lowdb/node';
import { deepEqual } from 'fast-equals';
import { JSONFile } from 'lowdb/node';
import { publicFiles } from '../../setup/index.js';
import { isRestorePoint } from './restore.parser.js';
import type { RestorePoint } from './restore.type.js';
@@ -1,4 +1,4 @@
import { Playback, MaybeString, MaybeNumber, Maybe, Instant } from 'ontime-types';
import { Instant, Maybe, MaybeNumber, MaybeString, Playback } from 'ontime-types';
export type RestorePoint = {
playback: Playback;
+2 -2
View File
@@ -1,9 +1,9 @@
import { checkIsNow, dayInMs } from 'ontime-utils';
import { MaybeNumber, PlayableEvent, Rundown } from 'ontime-types';
import { checkIsNow, dayInMs } from 'ontime-utils';
import { normaliseEndTime } from './timerUtils.js';
import { RundownMetadata } from '../api-data/rundown/rundown.types.js';
import { getTimedIndexFromPlayableIndex } from '../api-data/rundown/rundown.utils.js';
import { normaliseEndTime } from './timerUtils.js';
/**
* Finds current event in a rolling rundown
@@ -1,8 +1,7 @@
import { deepEqual } from 'fast-equals';
import {
EndAction,
EntryId,
isOntimeEvent,
isPlayableEvent,
LogOrigin,
Offset,
OffsetMode,
@@ -12,25 +11,24 @@ import {
TimerLifeCycle,
TimerPhase,
TimerState,
isOntimeEvent,
isPlayableEvent,
} from 'ontime-types';
import { millisToString, validatePlayback } from 'ontime-utils';
import { deepEqual } from 'fast-equals';
import { triggerAutomations } from '../../api-data/automation/automation.service.js';
import { triggerReportEntry } from '../../api-data/report/report.service.js';
import { getCurrentRundown, getEntryWithId, getRundownMetadata } from '../../api-data/rundown/rundown.dao.js';
import { RundownMetadata } from '../../api-data/rundown/rundown.types.js';
import { logger } from '../../classes/Logger.js';
import { timerConfig } from '../../setup/config.js';
import { eventStore } from '../../stores/EventStore.js';
import * as runtimeState from '../../stores/runtimeState.js';
import type { RuntimeState } from '../../stores/runtimeState.js';
import { eventStore } from '../../stores/EventStore.js';
import { triggerReportEntry } from '../../api-data/report/report.service.js';
import { timerConfig } from '../../setup/config.js';
import { triggerAutomations } from '../../api-data/automation/automation.service.js';
import { getCurrentRundown, getEntryWithId, getRundownMetadata } from '../../api-data/rundown/rundown.dao.js';
import { EventTimer } from '../EventTimer.js';
import type { RestorePoint } from '../restore-service/restore.type.js';
import { restoreService } from '../restore-service/restore.service.js';
import type { RestorePoint } from '../restore-service/restore.type.js';
import { skippedOutOfEvent } from '../timerUtils.js';
import {
findNextPlayableId,
findNextPlayableWithCue,
@@ -41,7 +39,6 @@ import {
getShouldTimerUpdate,
isNewSecond,
} from './runtime.utils.js';
import { RundownMetadata } from '../../api-data/rundown/rundown.types.js';
/**
* Service manages runtime status of app
@@ -1,17 +1,16 @@
import { millisToSeconds } from 'ontime-utils';
import { deepEqual } from 'fast-equals';
import {
EntryId,
isOntimeEvent,
isPlayableEvent,
MaybeNumber,
Offset,
OntimeEvent,
Rundown,
Offset,
TimerState,
TimerType,
isOntimeEvent,
isPlayableEvent,
} from 'ontime-types';
import { deepEqual } from 'fast-equals';
import { millisToSeconds } from 'ontime-utils';
export function isNewSecond(
previousValue: MaybeNumber | undefined,
+1 -1
View File
@@ -1,5 +1,5 @@
import { Day, MaybeNumber, TimeOfDay, TimerPhase } from 'ontime-types';
import { checkIsNow, dayInMs, isPlaybackActive, MILLIS_PER_HOUR } from 'ontime-utils';
import { MILLIS_PER_HOUR, checkIsNow, dayInMs, isPlaybackActive } from 'ontime-utils';
import type { RuntimeState } from '../stores/runtimeState.js';