Make initial circuit creation atomic

This commit is contained in:
2026-07-23 18:46:50 +02:00
parent 30c7555c68
commit a6837d7242
9 changed files with 234 additions and 169 deletions
@@ -20,7 +20,35 @@ export interface CreateCircuitDeviceRowTransactionInput {
overriddenFields?: string;
}
export interface CreateCircuitTransactionInput {
circuitListId: string;
sectionId: string;
equipmentIdentifier: string;
displayName?: string;
sortOrder: number;
protectionType?: string;
protectionRatedCurrent?: number;
protectionCharacteristic?: string;
cableType?: string;
cableCrossSection?: string;
cableLength?: number;
voltage?: number;
controlRequirement?: string;
remark?: string;
rcdAssignment?: string;
terminalDesignation?: string;
status?: string;
}
export interface CreateCircuitWithDeviceRowsTransactionInput {
circuit: CreateCircuitTransactionInput;
deviceRows: Array<Omit<CreateCircuitDeviceRowTransactionInput, "circuitId">>;
}
export interface CircuitDeviceRowTransactionStore {
createInCircuit(input: CreateCircuitDeviceRowTransactionInput): string;
createCircuitWithDeviceRows(
input: CreateCircuitWithDeviceRowsTransactionInput
): { circuitId: string; rowIds: string[] };
deleteFromCircuit(rowId: string, expectedCircuitId: string): void;
}
+1 -2
View File
@@ -164,11 +164,10 @@ export class CircuitWriteService {
);
}
const created = this.deviceRowRepository.createCircuitWithDeviceRowsTransactional({
const created = this.getDeviceRowTransactionStore().createCircuitWithDeviceRows({
circuit: {
circuitListId,
...input.circuit,
isReserve: false,
},
deviceRows: input.deviceRows,
});