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,41 +1,37 @@
import { TriggerDTO, TimerLifeCycle, AutomationDTO, Automation, ProjectRundowns } from 'ontime-types';
import { Automation, AutomationDTO, ProjectRundowns, TimerLifeCycle, TriggerDTO } from 'ontime-types';
import { makeOntimeEvent } from '../../rundown/__mocks__/rundown.mocks.js';
import {
addTrigger,
addAutomation,
addTrigger,
deleteAll,
deleteAllTriggers,
deleteTrigger,
deleteAutomation,
editTrigger,
deleteTrigger,
editAutomation,
editTrigger,
getAutomationTriggers,
getAutomations,
} from '../automation.dao.js';
import { makeHTTPAction, makeOSCAction } from './testUtils.js';
import { makeOSCAction, makeHTTPAction } from './testUtils.js';
beforeAll(() => {
vi.mock('../../../classes/data-provider/DataProvider.js', () => {
// Create a small mock store
let automations = {
enabledAutomations: true,
enabledOscIn: true,
oscPortIn: 8888,
triggers: [],
automations: {},
};
return {
getDataProvider: vi.fn().mockImplementation(() => {
return {
getAutomation: vi.fn().mockImplementation(() => automations),
setAutomation: vi.fn().mockImplementation((newData) => (automations = newData)),
};
}),
};
});
vi.mock('../../../classes/data-provider/DataProvider.js', () => {
// Create a small mock store
let automations = {
enabledAutomations: true,
enabledOscIn: true,
oscPortIn: 8888,
triggers: [],
automations: {},
};
return {
getDataProvider: vi.fn().mockImplementation(() => {
return {
getAutomation: vi.fn().mockImplementation(() => automations),
setAutomation: vi.fn().mockImplementation((newData) => (automations = newData)),
};
}),
};
});
afterAll(() => {
@@ -141,7 +137,7 @@ describe('addAutomation()', () => {
});
});
describe('editAutomation()', async () => {
describe('editAutomation()', () => {
// saving the ID of the added automation
let firstAutomation: Automation;
beforeEach(async () => {
@@ -1,35 +1,31 @@
import { PlayableEvent, TimerLifeCycle } from 'ontime-types';
import { makeRuntimeStoreData } from '../../../stores/__mocks__/runtimeStore.mocks.js';
import { deleteAllTriggers, addTrigger, addAutomation } from '../automation.dao.js';
import { testConditions, triggerAutomations } from '../automation.service.js';
import * as oscClient from '../clients/osc.client.js';
import * as httpClient from '../clients/http.client.js';
import { makeOSCAction, makeHTTPAction } from './testUtils.js';
import { RuntimeState } from '../../../stores/runtimeState.js';
import { makeOntimeEvent } from '../../rundown/__mocks__/rundown.mocks.js';
import { addAutomation, addTrigger, deleteAllTriggers } from '../automation.dao.js';
import { testConditions, triggerAutomations } from '../automation.service.js';
import * as httpClient from '../clients/http.client.js';
import * as oscClient from '../clients/osc.client.js';
import { makeHTTPAction, makeOSCAction } from './testUtils.js';
beforeAll(() => {
vi.mock('../../../classes/data-provider/DataProvider.js', () => {
// Create a small mock store
let automations = {
enabledAutomations: true,
enabledOscIn: true,
oscPortIn: 8888,
triggers: [],
automations: {},
};
return {
getDataProvider: vi.fn().mockImplementation(() => {
return {
getAutomation: vi.fn().mockImplementation(() => automations),
setAutomation: vi.fn().mockImplementation((newData) => (automations = newData)),
};
}),
};
});
vi.mock('../../../classes/data-provider/DataProvider.js', () => {
// Create a small mock store
let automations = {
enabledAutomations: true,
enabledOscIn: true,
oscPortIn: 8888,
triggers: [],
automations: {},
};
return {
getDataProvider: vi.fn().mockImplementation(() => {
return {
getAutomation: vi.fn().mockImplementation(() => automations),
setAutomation: vi.fn().mockImplementation((newData) => (automations = newData)),
};
}),
};
});
afterAll(() => {
@@ -41,7 +37,7 @@ describe('triggerAction()', () => {
let httpSpy = vi.spyOn(httpClient, 'emitHTTP');
beforeAll(() => {
vi.mock('../../../stores/EventStore.js', () => {
vi.doMock('../../../stores/EventStore.js', () => {
// Create a small mock store
return {
eventStore: {
@@ -49,11 +45,11 @@ describe('triggerAction()', () => {
},
};
});
})
});
beforeEach(async () => {
oscSpy = vi.spyOn(oscClient, 'emitOSC').mockImplementation(() => { });
httpSpy = vi.spyOn(httpClient, 'emitHTTP').mockImplementation(() => { });
oscSpy = vi.spyOn(oscClient, 'emitOSC').mockImplementation(() => {});
httpSpy = vi.spyOn(httpClient, 'emitHTTP').mockImplementation(() => {});
await deleteAllTriggers();
const oscAutomation = await addAutomation({
@@ -1,7 +1,6 @@
import { ProjectRundowns, TimerLifeCycle } from 'ontime-types';
import { makeOntimeEvent } from '../../rundown/__mocks__/rundown.mocks.js';
import { isAutomationUsed, parseTemplateNested, stringToOSCArgs } from '../automation.utils.js';
describe('parseTemplateNested()', () => {
@@ -22,7 +22,7 @@ describe('parseOutput', () => {
address: '/test',
args: 'test',
};
expect(() => parseOutput(payload)).toThrow();
expect(() => parseOutput(payload)).toThrow('Unexpected payload type:');
});
});
describe('handles HTTP outputs', () => {
@@ -39,7 +39,7 @@ describe('parseOutput', () => {
const payload = {
type: 'http',
};
expect(() => parseOutput(payload)).toThrow();
expect(() => parseOutput(payload)).toThrow('Unexpected payload type:');
});
});
describe('handles Ontime outputs', () => {
@@ -79,7 +79,7 @@ describe('parseOutput', () => {
type: 'ontime',
action: 'not-exist',
};
expect(() => parseOutput(payload)).toThrow();
expect(() => parseOutput(payload)).toThrow('Invalid Ontime action');
});
it('parses message-set', () => {
@@ -122,45 +122,46 @@ describe('parseOutput', () => {
text: 123,
visible: '',
}),
).toThrow();
).toThrow('Unexpected payload type:');
});
it('parses message-secondary', () => {});
expect(
parseOutput({
type: 'ontime',
action: 'message-secondary',
secondarySource: 'test',
}),
).toMatchObject({
secondarySource: null,
});
expect(
parseOutput({
type: 'ontime',
action: 'message-secondary',
secondarySource: '',
}),
).toMatchObject({
secondarySource: null,
});
expect(
parseOutput({
type: 'ontime',
action: 'message-secondary',
it('parses message-secondary', () => {
expect(
parseOutput({
type: 'ontime',
action: 'message-secondary',
secondarySource: 'test',
}),
).toMatchObject({
secondarySource: null,
});
expect(
parseOutput({
type: 'ontime',
action: 'message-secondary',
secondarySource: '',
}),
).toMatchObject({
secondarySource: null,
});
expect(
parseOutput({
type: 'ontime',
action: 'message-secondary',
secondarySource: 'aux1',
}),
).toMatchObject({
secondarySource: 'aux1',
}),
).toMatchObject({
secondarySource: 'aux1',
});
expect(
parseOutput({
type: 'ontime',
action: 'message-secondary',
});
expect(
parseOutput({
type: 'ontime',
action: 'message-secondary',
secondarySource: 'secondary',
}),
).toMatchObject({
secondarySource: 'secondary',
}),
).toMatchObject({
secondarySource: 'secondary',
});
});
});
});
@@ -1,4 +1,4 @@
import { OSCOutput, HTTPOutput } from 'ontime-types';
import { HTTPOutput, OSCOutput } from 'ontime-types';
export function makeOSCAction(action?: Partial<OSCOutput>): OSCOutput {
return {
@@ -1,11 +1,9 @@
import { getErrorMessage } from 'ontime-utils';
import { Automation, AutomationSettings, ErrorResponse, Trigger } from 'ontime-types';
import type { Request, Response } from 'express';
import { Automation, AutomationSettings, ErrorResponse, Trigger } from 'ontime-types';
import { getErrorMessage } from 'ontime-utils';
import { oscServer } from '../../adapters/OscAdapter.js';
import { getDataProvider } from '../../classes/data-provider/DataProvider.js';
import * as automationDao from './automation.dao.js';
import * as automationService from './automation.service.js';
import { parseOutput } from './automation.validation.js';
@@ -10,7 +10,6 @@ import type {
import { deleteAtIndex, generateId } from 'ontime-utils';
import { getDataProvider } from '../../classes/data-provider/DataProvider.js';
import { isAutomationUsed } from './automation.utils.js';
/**
@@ -1,7 +1,7 @@
import { DatabaseModel, AutomationSettings, NormalisedAutomation, Trigger } from 'ontime-types';
import { AutomationSettings, DatabaseModel, NormalisedAutomation, Trigger } from 'ontime-types';
import type { ErrorEmitter } from '../../utils/parserUtils.js';
import { getPartialProject } from '../../models/dataModel.js';
import type { ErrorEmitter } from '../../utils/parserUtils.js';
export function parseAutomationSettings(data: Partial<DatabaseModel>, emitError?: ErrorEmitter): AutomationSettings {
const defaultAutomation: AutomationSettings = getPartialProject('automation');
@@ -1,25 +1,25 @@
import express from 'express';
import { paramsWithId } from '../validation-utils/validationFunction.js';
import {
deleteTrigger,
deleteAutomation,
deleteTrigger,
editAutomation,
getAutomationSettings,
postTrigger,
postAutomation,
putTrigger,
postAutomationSettings,
postTrigger,
putTrigger,
testOutput,
} from './automation.controller.js';
import {
validateAutomationSettings,
validateAutomation,
validateAutomationPatch,
validateAutomationSettings,
validateTestPayload,
validateTrigger,
validateTriggerPatch,
} from './automation.validation.js';
import { paramsWithId } from '../validation-utils/validationFunction.js';
export const router = express.Router();
@@ -1,25 +1,24 @@
import {
isHTTPOutput,
isOntimeAction,
isOSCOutput,
LogOrigin,
RuntimeStore,
TimerLifeCycle,
type AutomationFilter,
type AutomationOutput,
type FilterRule,
LogOrigin,
RuntimeStore,
TimerLifeCycle,
isHTTPOutput,
isOSCOutput,
isOntimeAction,
} from 'ontime-types';
import { getPropertyFromPath } from 'ontime-utils';
import { emitOSC } from './clients/osc.client.js';
import { emitHTTP } from './clients/http.client.js';
import { getAutomationsEnabled, getAutomations, getAutomationTriggers } from './automation.dao.js';
import { isContained, isEquivalent, isGreaterThan, isLessThan } from './automation.utils.js';
import { toOntimeAction } from './clients/ontime.client.js';
import { logger } from '../../classes/Logger.js';
import { isOntimeCloud } from '../../setup/environment.js';
import { eventStore } from '../../stores/EventStore.js';
import { getAutomationTriggers, getAutomations, getAutomationsEnabled } from './automation.dao.js';
import { isContained, isEquivalent, isGreaterThan, isLessThan } from './automation.utils.js';
import { emitHTTP } from './clients/http.client.js';
import { toOntimeAction } from './clients/ontime.client.js';
import { emitOSC } from './clients/osc.client.js';
/**
* Exposes a method for triggering actions based on a TimerLifeCycle event
@@ -1,15 +1,15 @@
import {
EntryId,
FilterRule,
isOntimeEvent,
MaybeNumber,
OntimeAction,
ontimeActionKeyValues,
ProjectRundowns,
RundownEntries,
isOntimeEvent,
ontimeActionKeyValues,
} from 'ontime-types';
import { millisToString, removeLeadingZero, splitWhitespace, getPropertyFromPath } from 'ontime-utils';
import type { OscArgOrArrayInput, OscArgInput } from 'osc-min';
import { getPropertyFromPath, millisToString, removeLeadingZero, splitWhitespace } from 'ontime-utils';
import type { OscArgInput, OscArgOrArrayInput } from 'osc-min';
type FilterOperator = 'equals' | 'not_equals' | 'greater_than' | 'less_than' | 'contains';
@@ -1,20 +1,18 @@
import { body, oneOf, param } from 'express-validator';
import {
Automation,
AutomationFilter,
AutomationOutput,
HTTPOutput,
OntimeAction,
OSCOutput,
OntimeAction,
SecondarySource,
timerLifecycleValues,
} from 'ontime-types';
import { body, oneOf, param } from 'express-validator';
import * as assert from '../../utils/assert.js';
import { isFilterOperator, isFilterRule, isOntimeActionAction } from './automation.utils.js';
import { requestValidationFunction } from '../validation-utils/validationFunction.js';
import { isFilterOperator, isFilterRule, isOntimeActionAction } from './automation.utils.js';
export const validateAutomationSettings = [
body('enabledAutomations').isBoolean(),
@@ -1,8 +1,7 @@
import { DeepReadonly } from 'ts-essentials';
import { HTTPOutput, LogOrigin, RuntimeStore } from 'ontime-types';
import { DeepReadonly } from 'ts-essentials';
import { logger } from '../../../classes/Logger.js';
import { parseTemplateNested } from '../automation.utils.js';
/**
@@ -1,9 +1,9 @@
import { LogOrigin, OntimeAction } from 'ontime-types';
import { parseUserTime } from 'ontime-utils';
import { logger } from '../../../classes/Logger.js';
import { auxTimerService } from '../../../services/aux-timer-service/AuxTimerService.js';
import * as messageService from '../../../services/message-service/message.service.js';
import { parseUserTime } from 'ontime-utils';
export function toOntimeAction(action: OntimeAction) {
const actionType = action.action;
@@ -1,11 +1,11 @@
import { LogOrigin, OSCOutput, RuntimeStore } from 'ontime-types';
import { type OscPacketInput, toBuffer as oscPacketToBuffer } from 'osc-min';
import * as dgram from 'node:dgram';
import { LogOrigin, OSCOutput, RuntimeStore } from 'ontime-types';
import { type OscPacketInput, toBuffer as oscPacketToBuffer } from 'osc-min';
import { DeepReadonly } from 'ts-essentials';
import { logger } from '../../../classes/Logger.js';
import { parseTemplateNested, stringToOSCArgs } from '../automation.utils.js';
import { DeepReadonly } from 'ts-essentials';
const udpClient = dgram.createSocket('udp4');