forked from jappel/leistungsbilanz-ts
Add per-project socket limit and Revit socket device-type flag
- Project setting maxSocketsPerCircuit (migration 0018, project.update-settings schema 4, snapshot schema 11); older command and snapshot versions keep or upgrade the value to null. - Revit configuration schema 2 marks device types as socket; version 1 stays readable and derives the flag from socketCount family rules. - Settings dialog field and device-type card on the Revit page. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
85cbdbf8e0
commit
e48042bde3
35 changed files with 3781 additions and 41 deletions
|
|
@ -14,6 +14,10 @@ import {
|
|||
assertExternalModelConfiguration,
|
||||
createDefaultExternalModelConfiguration,
|
||||
} from "../src/external-model/configuration/external-model-configuration.js";
|
||||
import {
|
||||
resolveSocketDeviceTypeIds,
|
||||
withSocketDeviceTypeFlags,
|
||||
} from "../src/shared/revit/socket-device-types.js";
|
||||
|
||||
const deviceTypeId = "10000000-0000-4000-8000-000000000001";
|
||||
const ruleId = "20000000-0000-4000-8000-000000000001";
|
||||
|
|
@ -25,6 +29,7 @@ function configuration() {
|
|||
name: "Steckdose",
|
||||
category: "single_phase",
|
||||
defaults: { powerPerUnitW: 200, simultaneityFactor: null, cosPhi: 0.95, costGroup: "440" },
|
||||
isSocket: true,
|
||||
});
|
||||
value.familyTypeRules.push({
|
||||
id: ruleId,
|
||||
|
|
@ -61,6 +66,27 @@ describe("external model configuration", () => {
|
|||
assert.throws(() => assertExternalModelConfiguration(unknownType), /unbekannte Ger.*teart/);
|
||||
});
|
||||
|
||||
it("requires the socket flag in version 2 and keeps version 1 readable", () => {
|
||||
const missingFlag = configuration();
|
||||
delete missingFlag.deviceTypes[0]!.isSocket;
|
||||
assert.throws(() => assertExternalModelConfiguration(missingFlag), /unbekannte oder fehlende Felder/);
|
||||
|
||||
const legacy = { ...configuration(), schemaVersion: 1 as const };
|
||||
assert.throws(() => assertExternalModelConfiguration(legacy), /unbekannte oder fehlende Felder/);
|
||||
delete legacy.deviceTypes[0]!.isSocket;
|
||||
assert.doesNotThrow(() => assertExternalModelConfiguration(legacy));
|
||||
|
||||
assert.deepEqual([...resolveSocketDeviceTypeIds(legacy)], [deviceTypeId]);
|
||||
const upgraded = withSocketDeviceTypeFlags(legacy);
|
||||
assert.equal(upgraded.schemaVersion, 2);
|
||||
assert.equal(upgraded.deviceTypes[0]!.isSocket, true);
|
||||
assert.doesNotThrow(() => assertExternalModelConfiguration(upgraded));
|
||||
|
||||
const notSocket = configuration();
|
||||
notSocket.deviceTypes[0]!.isSocket = false;
|
||||
assert.equal(resolveSocketDeviceTypeIds(notSocket).size, 0);
|
||||
});
|
||||
|
||||
it("persists changes without an independent configuration revision", () => {
|
||||
const context = createTestDatabase();
|
||||
try {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue