refactor: generate ids for new rundowns

This commit is contained in:
Carlos Valente
2025-12-11 18:22:28 +01:00
committed by Carlos Valente
parent b70ef80320
commit f2b78e0f32
13 changed files with 146 additions and 73 deletions
+3 -9
View File
@@ -49,15 +49,9 @@ export async function patchPartialProjectFile(req: Request, res: Response<Databa
*/
export async function createProjectFile(req: Request, res: Response<{ filename: string } | ErrorResponse>) {
try {
const newFileName = await projectService.createProject(req.body.filename || 'untitled', {
project: {
title: req.body?.title ?? '',
description: req.body?.description ?? '',
url: req.body?.url ?? '',
info: req.body?.info ?? '',
logo: req.body?.logo ?? null,
custom: req.body?.custom ?? [],
},
const { filename, ...project } = req.body;
const newFileName = await projectService.createProjectWithPatch(filename, {
project,
});
res.status(200).send({
@@ -17,11 +17,12 @@ import {
URLPreset,
ViewSettings,
} from 'ontime-types';
import { is } from '../../../utils/is.js';
import { dbModel } from '../../../models/dataModel.js';
import { customFieldLabelToKey, checkRegex, isKnownTimerType, validateEndAction } from 'ontime-utils';
import { is } from '../../../utils/is.js';
import { event as eventModel } from '../../../models/eventsDefinition.js';
import { ONTIME_VERSION } from '../../../ONTIME_VERSION.js';
import { getPartialProject } from '../../../models/dataModel.js';
// the methodology of the migrations is to just change the necessary keys to match with v4
// and then let the normal project parser handle ensuring the the file is correct
@@ -148,8 +149,8 @@ export function migrateProjectData(jsonData: object): ProjectData | undefined {
description,
url: backstageUrl,
info: backstageInfo,
logo: logo ?? dbModel.project.logo,
custom: custom ?? dbModel.project.custom,
logo: logo ?? null,
custom: custom ?? [],
};
}
}
@@ -244,7 +245,7 @@ export function migrateAutomations(jsonData: object): AutomationSettings | undef
}
let foundOldSetting = false;
const migratedOldStuff = structuredClone(dbModel.automation);
const migratedOldStuff: AutomationSettings = getPartialProject('automation');
const migratedAutomations: NormalisedAutomation = {};
const migratedTriggers: Trigger[] = [];
@@ -14,7 +14,7 @@ import {
ViewSettings,
} from 'ontime-types';
import * as v3 from './db.migration.v3.js';
import { dbModel } from '../../../models/dataModel.js';
import { ONTIME_VERSION } from '../../../ONTIME_VERSION.js';
describe('v3 to v4', () => {
@@ -469,7 +469,7 @@ describe('v3 to v4', () => {
const expectedAutomation: AutomationSettings = {
enabledAutomations: true,
enabledOscIn: true,
oscPortIn: dbModel.automation.oscPortIn,
oscPortIn: 8888,
triggers: [
{
id: '1ge4r8-T',