feat(piece) : add quantity field to piece types, sanitization and hydration

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Matthieu
2026-03-12 12:08:43 +01:00
parent 5c31045e83
commit 695d56a6d3
5 changed files with 14 additions and 0 deletions

View File

@@ -162,6 +162,8 @@ export const sanitizePieces = (pieces: any[]): ComponentModelPiece[] => {
const rawRole = typeof piece?.role === 'string' ? piece.role.trim() : ''
const role = rawRole.length > 0 ? rawRole : undefined
const quantity = typeof piece?.quantity === 'number' && piece.quantity >= 1 ? piece.quantity : undefined
if (!typePieceId && !typePieceLabel && !reference && !familyCode) {
return null
}
@@ -182,6 +184,9 @@ export const sanitizePieces = (pieces: any[]): ComponentModelPiece[] => {
if (typePieceLabel) {
result.typePieceLabel = typePieceLabel
}
if (quantity !== undefined) {
result.quantity = quantity
}
return result
})
.filter((piece): piece is ComponentModelPiece => !!piece)