Persist Revit CSV configuration

This commit is contained in:
Julian Appel 2026-08-02 16:33:18 +02:00
parent da689af518
commit 219da5ec3b
22 changed files with 2508 additions and 27 deletions

View file

@ -26,6 +26,7 @@ import { projectDevices } from "../schema/project-devices.js";
import { projectChangeSets } from "../schema/project-change-sets.js";
import { projects } from "../schema/projects.js";
import { rooms } from "../schema/rooms.js";
import { externalCsvConfigurations } from "../schema/external-csv-configurations.js";
import { executeProjectCommandTransaction } from "./project-command-transaction.persistence.js";
import {
readProjectStateSnapshot,
@ -161,6 +162,7 @@ function canonicalProjectState(state: ProjectStateSnapshot) {
projectDevices: byId(state.projectDevices),
floors: byId(state.floors),
rooms: byId(state.rooms),
externalCsvConfiguration: state.externalCsvConfiguration,
});
}
@ -183,6 +185,10 @@ function replaceProjectState(
database: AppDatabase,
state: ProjectStateSnapshot
) {
database
.delete(externalCsvConfigurations)
.where(eq(externalCsvConfigurations.projectId, state.project.id))
.run();
database
.delete(distributionBoards)
.where(eq(distributionBoards.projectId, state.project.id))
@ -218,6 +224,12 @@ function replaceProjectState(
.run();
insertMany(database, floors, state.floors);
if (state.externalCsvConfiguration !== null) {
database
.insert(externalCsvConfigurations)
.values(state.externalCsvConfiguration)
.run();
}
insertMany(database, rooms, state.rooms);
insertMany(database, projectDevices, state.projectDevices);
insertMany(database, distributionBoards, state.distributionBoards);