mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-10 18:03:47 +00:00
refactor: remove legacy service
This commit is contained in:
committed by
Carlos Valente
parent
1f71d4578c
commit
2cc434b0e9
@@ -3,11 +3,40 @@ import { DatabaseModel, AutomationSettings, Automation, NormalisedAutomationBlue
|
||||
import { dbModel } from '../../models/dataModel.js';
|
||||
import type { ErrorEmitter } from '../../utils/parser.js';
|
||||
|
||||
export function parseAutomationSettings(data: Partial<DatabaseModel>, emitError?: ErrorEmitter): AutomationSettings {
|
||||
interface LegacyData extends Partial<DatabaseModel> {
|
||||
http?: unknown;
|
||||
osc?: {
|
||||
enabledIn?: boolean;
|
||||
portIn?: number;
|
||||
};
|
||||
}
|
||||
|
||||
export function parseAutomationSettings(data: LegacyData, emitError?: ErrorEmitter): AutomationSettings {
|
||||
/**
|
||||
* Leaving a path for migrating users to the new automations
|
||||
* This should be removed after a few releases
|
||||
*/
|
||||
if (data.http || data.osc) {
|
||||
emitError?.('Found legacy integrations');
|
||||
console.log('Found legacy integrations...');
|
||||
if (data.osc) {
|
||||
return {
|
||||
enabledAutomations: dbModel.automation.enabledAutomations,
|
||||
enabledOscIn: data.osc?.enabledIn ?? dbModel.automation.enabledOscIn,
|
||||
oscPortIn: data.osc?.portIn ?? dbModel.automation.oscPortIn,
|
||||
automations: [],
|
||||
blueprints: {},
|
||||
};
|
||||
} else {
|
||||
return { ...dbModel.automation };
|
||||
}
|
||||
}
|
||||
|
||||
if (!data.automation) {
|
||||
emitError?.('No data found to import');
|
||||
return { ...dbModel.automation };
|
||||
}
|
||||
console.log('Found Automation settings, importing...');
|
||||
|
||||
return {
|
||||
enabledAutomations: data.automation.enabledAutomations ?? dbModel.automation.enabledAutomations,
|
||||
|
||||
Reference in New Issue
Block a user