feat: add product domain and machine integration

- extend Prisma schema with products, product constructs and link tables\n- introduce product service, DTOs and includes with constructeur support\n- integrate product selections across model type skeletons, composants, pièces and machines\n- validate product requirements when building machine skeletons and payloads
This commit is contained in:
Matthieu
2025-11-05 15:34:42 +01:00
parent e81f71e3e7
commit 6cf2b566ce
38 changed files with 2601 additions and 120 deletions

View File

@@ -76,6 +76,59 @@ export function normalizeComponentModelStructure(
},
);
const products = toArray((structure as any)?.products).map((product) => {
const candidate = product as Record<string, unknown> | null | undefined;
if (candidate?.typeProductId) {
const normalized: ComponentModelStructure['products'][number] = {
typeProductId:
ensureString(candidate.typeProductId).trim() || 'UNKNOWN',
role: sanitizeRole(candidate.role),
};
if (candidate?.familyCode) {
const familyCode = ensureString(candidate.familyCode).trim();
if (familyCode) {
(normalized as Record<string, unknown>).familyCode = familyCode;
}
}
if (candidate?.typeProductLabel) {
const label = ensureString(candidate.typeProductLabel).trim();
if (label) {
(normalized as Record<string, unknown>).typeProductLabel = label;
}
}
if (candidate?.reference) {
const reference = ensureString(candidate.reference).trim();
if (reference) {
(normalized as Record<string, unknown>).reference = reference;
}
}
return normalized;
}
if (candidate?.familyCode) {
return {
familyCode: ensureString(candidate.familyCode).trim() || 'UNKNOWN',
role: sanitizeRole(candidate.role),
} as ComponentModelStructure['products'][number];
}
return {
familyCode:
ensureString(
candidate?.familyCode ??
candidate?.name ??
candidate?.typeProductLabel ??
'UNKNOWN',
).trim() || 'UNKNOWN',
role: sanitizeRole(candidate?.role),
} as ComponentModelStructure['products'][number];
});
const rawSubcomponents = toArray(
(structure as any)?.subcomponents ?? (structure as any)?.subComponents,
);
@@ -115,6 +168,7 @@ export function normalizeComponentModelStructure(
return {
pieces,
products,
customFields,
subcomponents,
};