feat: normalize and validate component model structure
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user