forked from jappel/leistungsbilanz-ts
Verify Revit reference CSV
This commit is contained in:
parent
bfe8b790b2
commit
da689af518
8 changed files with 149 additions and 11 deletions
|
|
@ -19,7 +19,6 @@ const requiredColumnKeys = [
|
|||
"selectionMarker",
|
||||
"circuitIdentifier",
|
||||
"power",
|
||||
"quantity",
|
||||
] as const;
|
||||
|
||||
export function assertExternalCsvConfiguration(
|
||||
|
|
@ -56,6 +55,16 @@ export function assertExternalCsvConfiguration(
|
|||
}
|
||||
mappedColumns.add(columnName);
|
||||
}
|
||||
if (value.columns.quantity !== null) {
|
||||
const quantityColumn = assertTrimmedString(
|
||||
value.columns.quantity,
|
||||
"columns.quantity"
|
||||
);
|
||||
if (mappedColumns.has(quantityColumn)) {
|
||||
throw new Error(`External CSV column is mapped more than once: ${quantityColumn}`);
|
||||
}
|
||||
mappedColumns.add(quantityColumn);
|
||||
}
|
||||
|
||||
if (!Array.isArray(value.additionalSourceMappings)) {
|
||||
throw new Error("External CSV additional source mappings must be an array.");
|
||||
|
|
@ -115,6 +124,11 @@ export function assertExternalCsvConfiguration(
|
|||
throw new Error(`familyTypeRules.${index}.category is unsupported.`);
|
||||
}
|
||||
assertQuantityRule(rule.quantityRule, index);
|
||||
if (rule.quantityRule.kind === "mapped-column" && value.columns.quantity === null) {
|
||||
throw new Error(
|
||||
`familyTypeRules.${index}.quantityRule requires a configured quantity column.`
|
||||
);
|
||||
}
|
||||
assertDisplayNameSuggestion(rule.displayNameSuggestion, index);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ export interface ExternalCsvColumnMapping {
|
|||
selectionMarker: string;
|
||||
circuitIdentifier: string;
|
||||
power: string;
|
||||
quantity: string;
|
||||
quantity: string | null;
|
||||
}
|
||||
|
||||
export interface ExternalCsvAdditionalSourceMapping {
|
||||
|
|
|
|||
|
|
@ -59,7 +59,9 @@ export function parseExternalCsv(
|
|||
|
||||
const headerRowIndex = headerMatches[0];
|
||||
const configuredColumnNames = [
|
||||
...Object.values(configuration.columns),
|
||||
...Object.values(configuration.columns).filter(
|
||||
(column): column is string => column !== null
|
||||
),
|
||||
...configuration.additionalSourceMappings.map((mapping) => mapping.sourceColumn),
|
||||
];
|
||||
const headerValues = parsed.rows[headerRowIndex].map((cell) => cell.value);
|
||||
|
|
@ -81,7 +83,9 @@ export function parseExternalCsv(
|
|||
configuration.columns.familyAndType,
|
||||
configuration.columns.selectionMarker,
|
||||
configuration.columns.power,
|
||||
configuration.columns.quantity,
|
||||
...(configuration.columns.quantity === null
|
||||
? []
|
||||
: [configuration.columns.quantity]),
|
||||
...configuration.additionalSourceMappings.map((mapping) => mapping.sourceColumn),
|
||||
].map((column) => headerLookup.get(column)!);
|
||||
const seenIfcGuids = new Set<string>();
|
||||
|
|
@ -274,7 +278,9 @@ function findHeaderRows(
|
|||
configuration: ExternalCsvConfiguration
|
||||
) {
|
||||
const requiredColumns = new Set([
|
||||
...Object.values(configuration.columns),
|
||||
...Object.values(configuration.columns).filter(
|
||||
(column): column is string => column !== null
|
||||
),
|
||||
...configuration.additionalSourceMappings.map((mapping) => mapping.sourceColumn),
|
||||
]);
|
||||
const matches: number[] = [];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue