Make initial circuit creation atomic
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user