feat: normalize and validate component model structure

This commit is contained in:
MatthieuTD
2025-10-01 11:47:45 +02:00
parent f48e7aad30
commit 1a4cedb431
8 changed files with 383 additions and 25 deletions

View File

@@ -123,7 +123,8 @@ export class ComposantsService {
include: COMPONENT_WITH_RELATIONS_INCLUDE,
})) as ComposantWithRelations;
return this.getComponentWithHierarchy(created.id);
const component = await this.getComponentWithHierarchy(created.id);
return component ?? created;
}
async findAll() {
@@ -244,9 +245,13 @@ export class ComposantsService {
}
}
const subComponents = Array.isArray(structure?.subComponents)
? structure.subComponents
: [];
const rawSubcomponents =
(structure as any)?.subcomponents ?? structure?.subComponents;
const subComponents = Array.isArray(rawSubcomponents)
? rawSubcomponents
: rawSubcomponents
? [rawSubcomponents]
: [];
for (const sub of subComponents) {
const subTypeId = this.extractTypeComposantId(sub);
if (!subTypeId) {