Decouple legacy migration service
This commit is contained in:
@@ -0,0 +1,143 @@
|
||||
export interface LegacyConsumerMigrationCircuitListReader {
|
||||
findById(
|
||||
projectId: string,
|
||||
circuitListId: string
|
||||
): Promise<{ id: string } | null>;
|
||||
}
|
||||
|
||||
export interface LegacyConsumerMigrationSection {
|
||||
id: string;
|
||||
key: string;
|
||||
prefix: string;
|
||||
}
|
||||
|
||||
export interface LegacyConsumerMigrationSectionStore {
|
||||
createDefaults(circuitListId: string): Promise<void>;
|
||||
listByCircuitList(
|
||||
circuitListId: string
|
||||
): Promise<LegacyConsumerMigrationSection[]>;
|
||||
}
|
||||
|
||||
export interface LegacyConsumerMigrationCircuitReader {
|
||||
listByCircuitList(circuitListId: string): Promise<
|
||||
Array<{
|
||||
sectionId: string;
|
||||
equipmentIdentifier: string;
|
||||
sortOrder: number;
|
||||
}>
|
||||
>;
|
||||
}
|
||||
|
||||
export interface LegacyConsumerMigrationRoomReader {
|
||||
listByProject(projectId: string): Promise<
|
||||
Array<{
|
||||
id: string;
|
||||
roomNumber: string;
|
||||
roomName: string;
|
||||
}>
|
||||
>;
|
||||
}
|
||||
|
||||
export interface LegacyConsumerSource {
|
||||
id: string;
|
||||
projectDeviceId: string | null;
|
||||
roomId: string | null;
|
||||
circuitNumber: string | null;
|
||||
description: string | null;
|
||||
name: string;
|
||||
category: string | null;
|
||||
deviceType: string | null;
|
||||
phaseType: string | null;
|
||||
tradeOrCostGroup: string | null;
|
||||
protectionType: string | null;
|
||||
protectionRatedCurrent: number | null;
|
||||
protectionCharacteristic: string | null;
|
||||
cableType: string | null;
|
||||
cableCrossSection: string | null;
|
||||
comment: string | null;
|
||||
quantity: number;
|
||||
installedPowerPerUnitKw: number;
|
||||
demandFactor: number;
|
||||
voltageV: number | null;
|
||||
phaseCount: number | null;
|
||||
powerFactor: number | null;
|
||||
note: string | null;
|
||||
}
|
||||
|
||||
export interface LegacyMigrationDeviceRowInput {
|
||||
linkedProjectDeviceId?: string;
|
||||
legacyConsumerId: string;
|
||||
sortOrder: number;
|
||||
name: string;
|
||||
displayName: string;
|
||||
phaseType?: string;
|
||||
connectionKind?: string;
|
||||
costGroup?: string;
|
||||
category?: string;
|
||||
level?: string;
|
||||
roomId?: string;
|
||||
roomNumberSnapshot?: string;
|
||||
roomNameSnapshot?: string;
|
||||
quantity: number;
|
||||
powerPerUnit: number;
|
||||
simultaneityFactor: number;
|
||||
cosPhi?: number;
|
||||
remark?: string;
|
||||
overriddenFields?: string;
|
||||
}
|
||||
|
||||
export interface LegacyMigrationCircuitInput {
|
||||
circuit: {
|
||||
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;
|
||||
isReserve?: boolean;
|
||||
};
|
||||
deviceRows: LegacyMigrationDeviceRowInput[];
|
||||
}
|
||||
|
||||
export interface LegacyMigrationReportInput {
|
||||
legacyConsumerCount: number;
|
||||
createdCircuitCount: number;
|
||||
createdDeviceRowCount: number;
|
||||
duplicateGroupedCount: number;
|
||||
generatedIdentifierCount: number;
|
||||
unassignedRowCount: number;
|
||||
warningsJson: string;
|
||||
generatedIdentifiersJson: string;
|
||||
duplicateGroupsJson: string;
|
||||
}
|
||||
|
||||
export interface LegacyConsumerMigrationStore {
|
||||
listSourceConsumersByCircuitList(
|
||||
circuitListId: string
|
||||
): Promise<LegacyConsumerSource[]>;
|
||||
listMigratedConsumerIds(circuitListId: string): Promise<string[]>;
|
||||
persistCircuitListMigration(input: {
|
||||
circuitListId: string;
|
||||
circuits: LegacyMigrationCircuitInput[];
|
||||
report: LegacyMigrationReportInput;
|
||||
}): void;
|
||||
}
|
||||
|
||||
export interface LegacyConsumerMigrationDependencies {
|
||||
circuitListReader: LegacyConsumerMigrationCircuitListReader;
|
||||
sectionStore: LegacyConsumerMigrationSectionStore;
|
||||
circuitReader: LegacyConsumerMigrationCircuitReader;
|
||||
roomReader: LegacyConsumerMigrationRoomReader;
|
||||
migrationStore: LegacyConsumerMigrationStore;
|
||||
}
|
||||
Reference in New Issue
Block a user