forked from jappel/leistungsbilanz-ts
Replace Revit CSV backend with Linear XLSX
This commit is contained in:
parent
52d3b1a270
commit
1cfeb06ec7
65 changed files with 4764 additions and 3717 deletions
|
|
@ -30,7 +30,7 @@ import { ProjectDeviceRowSyncProjectCommandRepository } from "../src/db/reposito
|
|||
import { ProjectDeviceStructureProjectCommandRepository } from "../src/db/repositories/project-device-structure-project-command.repository.js";
|
||||
import { ProjectStateRestoreCommandRepository } from "../src/db/repositories/project-state-restore-command.repository.js";
|
||||
import { ProjectSettingsProjectCommandRepository } from "../src/db/repositories/project-settings-project-command.repository.js";
|
||||
import { ExternalCsvConfigurationProjectCommandRepository } from "../src/db/repositories/external-csv-configuration-project-command.repository.js";
|
||||
import { ExternalModelConfigurationProjectCommandRepository } from "../src/db/repositories/external-model-configuration-project-command.repository.js";
|
||||
import { circuitDeviceRows } from "../src/db/schema/circuit-device-rows.js";
|
||||
import { circuitProtectionDevices } from "../src/db/schema/circuit-protection-devices.js";
|
||||
import { circuitSections } from "../src/db/schema/circuit-sections.js";
|
||||
|
|
@ -44,7 +44,7 @@ import { projects } from "../src/db/schema/projects.js";
|
|||
import { buildings } from "../src/db/schema/buildings.js";
|
||||
import { floors } from "../src/db/schema/floors.js";
|
||||
import { rooms } from "../src/db/schema/rooms.js";
|
||||
import { externalCsvConfigurations } from "../src/db/schema/external-csv-configurations.js";
|
||||
import { externalModelConfigurations } from "../src/db/schema/external-model-configurations.js";
|
||||
import { createCircuitProtectionUpdateProjectCommand } from "../src/domain/models/circuit-protection-project-command.model.js";
|
||||
import { ProjectHistoryOperationUnavailableError } from "../src/domain/errors/project-history-operation-unavailable.error.js";
|
||||
import { ProjectRevisionConflictError } from "../src/domain/errors/project-revision-conflict.error.js";
|
||||
|
|
@ -90,9 +90,8 @@ import { createProjectDeviceRowSyncProjectCommand } from "../src/domain/models/p
|
|||
import { createProjectDeviceUpdateProjectCommand } from "../src/domain/models/project-device-project-command.model.js";
|
||||
import { createProjectDeviceInsertProjectCommand } from "../src/domain/models/project-device-structure-project-command.model.js";
|
||||
import { createProjectSettingsUpdateProjectCommand } from "../src/domain/models/project-settings-project-command.model.js";
|
||||
import { createExternalCsvConfigurationUpdateProjectCommand } from "../src/domain/models/external-csv-configuration-project-command.model.js";
|
||||
import { createDefaultExternalCsvConfiguration } from "../src/external-model/csv/external-csv-contracts.js";
|
||||
import { externalCsvTestColumns } from "./fixtures/revit-csv-fixtures.js";
|
||||
import { createExternalModelConfigurationUpdateProjectCommand } from "../src/domain/models/external-model-configuration-project-command.model.js";
|
||||
import { createDefaultExternalModelConfiguration } from "../src/external-model/configuration/external-model-configuration.js";
|
||||
import { ProjectCommandService } from "../src/domain/services/project-command.service.js";
|
||||
|
||||
function createTestDatabase(): DatabaseContext {
|
||||
|
|
@ -166,7 +165,7 @@ function createService(context: DatabaseContext) {
|
|||
new CircuitGroupSubtreeProjectCommandRepository(context.db),
|
||||
new CircuitProtectionProjectCommandRepository(context.db),
|
||||
new ProjectHistoryRepository(context.db),
|
||||
new ExternalCsvConfigurationProjectCommandRepository(context.db)
|
||||
new ExternalModelConfigurationProjectCommandRepository(context.db)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -1127,31 +1126,62 @@ describe("project command service", () => {
|
|||
}
|
||||
});
|
||||
|
||||
it("dispatches external CSV configuration updates through persistent history", () => {
|
||||
it("dispatches external XLSX configuration updates through persistent history", () => {
|
||||
const context = createTestDatabase();
|
||||
try {
|
||||
const service = createService(context);
|
||||
const target = {
|
||||
id: "external-config-1",
|
||||
projectId: "project-1",
|
||||
configurationVersion: 1,
|
||||
configuration: createDefaultExternalCsvConfiguration(externalCsvTestColumns),
|
||||
configuration: createDefaultExternalModelConfiguration(),
|
||||
};
|
||||
const updated = service.executeUser({
|
||||
projectId: "project-1",
|
||||
expectedRevision: 0,
|
||||
command: createExternalCsvConfigurationUpdateProjectCommand(null, target),
|
||||
command: createExternalModelConfigurationUpdateProjectCommand(null, target),
|
||||
});
|
||||
assert.equal(updated.history.currentRevision, 1);
|
||||
assert.equal(context.db.select().from(externalCsvConfigurations).all().length, 1);
|
||||
assert.equal(context.db.select().from(externalModelConfigurations).all().length, 1);
|
||||
|
||||
const undone = service.undo({ projectId: "project-1", expectedRevision: 1 });
|
||||
assert.equal(undone.history.currentRevision, 2);
|
||||
assert.equal(context.db.select().from(externalCsvConfigurations).all().length, 0);
|
||||
assert.equal(context.db.select().from(externalModelConfigurations).all().length, 0);
|
||||
|
||||
const redone = service.redo({ projectId: "project-1", expectedRevision: 2 });
|
||||
assert.equal(redone.history.currentRevision, 3);
|
||||
assert.equal(context.db.select().from(externalCsvConfigurations).all().length, 1);
|
||||
assert.equal(context.db.select().from(externalModelConfigurations).all().length, 1);
|
||||
} finally {
|
||||
context.close();
|
||||
}
|
||||
});
|
||||
|
||||
it("rejects legacy CSV commands stored in project history with a clear error", () => {
|
||||
const context = createTestDatabase();
|
||||
try {
|
||||
const service = createService(context);
|
||||
service.executeUser({
|
||||
projectId: "project-1",
|
||||
expectedRevision: 0,
|
||||
command: createExternalModelConfigurationUpdateProjectCommand(null, {
|
||||
id: "external-config-1",
|
||||
projectId: "project-1",
|
||||
configuration: createDefaultExternalModelConfiguration(),
|
||||
}),
|
||||
});
|
||||
context.db.update(projectChangeSets).set({
|
||||
inversePayloadJson: JSON.stringify({
|
||||
schemaVersion: 1,
|
||||
type: "external-import.apply-initial",
|
||||
payload: {},
|
||||
}),
|
||||
}).run();
|
||||
|
||||
assert.throws(
|
||||
() => service.undo({ projectId: "project-1", expectedRevision: 1 }),
|
||||
/alten Revit-CSV-Anbindung/
|
||||
);
|
||||
assert.equal(context.db.select().from(externalModelConfigurations).all().length, 1);
|
||||
assert.equal(context.db.select({ revision: projects.currentRevision }).from(projects).get()?.revision, 1);
|
||||
} finally {
|
||||
context.close();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue