This repository has been archived on 2026-04-01. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
Inventory_backend/src/shared/dto/machine.dto.ts
Matthieu 6cf2b566ce 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
2025-11-05 15:34:42 +01:00

295 lines
5.0 KiB
TypeScript

import {
IsString,
IsOptional,
IsDecimal,
IsArray,
IsObject,
} from 'class-validator';
import { Type } from 'class-transformer';
import { ValidateNested } from 'class-validator';
export class MachineComponentLinkPayloadDto {
@IsOptional()
@IsString()
id?: string;
@IsOptional()
@IsString()
linkId?: string;
@IsString()
requirementId: string;
@IsOptional()
@IsString()
typeComposantId?: string;
@IsOptional()
@IsString()
composantId?: string;
@IsOptional()
@IsString()
productId?: string;
@IsOptional()
@IsString()
componentId?: string;
@IsOptional()
@IsString()
parentLinkId?: string;
@IsOptional()
@IsString()
parentComponentLinkId?: string;
@IsOptional()
@IsString()
parentRequirementId?: string;
@IsOptional()
@IsString()
parentComponentRequirementId?: string;
@IsOptional()
@IsString()
parentPieceRequirementId?: string;
@IsOptional()
@IsString()
parentMachineComponentRequirementId?: string;
@IsOptional()
@IsString()
parentMachinePieceRequirementId?: string;
@IsOptional()
@IsString()
parentComponentId?: string;
@IsOptional()
@IsString()
parentPieceId?: string;
@IsOptional()
@IsObject()
overrides?: Record<string, unknown>;
}
export class MachinePieceLinkPayloadDto {
@IsOptional()
@IsString()
id?: string;
@IsOptional()
@IsString()
linkId?: string;
@IsString()
requirementId: string;
@IsOptional()
@IsString()
typePieceId?: string;
@IsOptional()
@IsString()
pieceId?: string;
@IsOptional()
@IsString()
composantId?: string;
@IsOptional()
@IsString()
productId?: string;
@IsOptional()
@IsString()
parentLinkId?: string;
@IsOptional()
@IsString()
parentComponentLinkId?: string;
@IsOptional()
@IsString()
parentPieceLinkId?: string;
@IsOptional()
@IsString()
parentRequirementId?: string;
@IsOptional()
@IsString()
parentComponentRequirementId?: string;
@IsOptional()
@IsString()
parentPieceRequirementId?: string;
@IsOptional()
@IsString()
parentMachineComponentRequirementId?: string;
@IsOptional()
@IsString()
parentMachinePieceRequirementId?: string;
@IsOptional()
@IsString()
parentComponentId?: string;
@IsOptional()
@IsString()
parentPieceId?: string;
@IsOptional()
@IsObject()
overrides?: Record<string, unknown>;
}
export class MachineProductLinkPayloadDto {
@IsOptional()
@IsString()
id?: string;
@IsOptional()
@IsString()
linkId?: string;
@IsString()
requirementId: string;
@IsOptional()
@IsString()
productId?: string;
@IsOptional()
@IsString()
typeProductId?: string;
@IsOptional()
@IsString()
parentLinkId?: string;
@IsOptional()
@IsString()
parentComponentLinkId?: string;
@IsOptional()
@IsString()
parentPieceLinkId?: string;
@IsOptional()
@IsString()
parentRequirementId?: string;
@IsOptional()
@IsString()
parentComponentRequirementId?: string;
@IsOptional()
@IsString()
parentPieceRequirementId?: string;
@IsOptional()
@IsString()
parentMachineComponentRequirementId?: string;
@IsOptional()
@IsString()
parentMachinePieceRequirementId?: string;
}
export class CreateMachineDto {
@IsString()
name: string;
@IsString()
siteId: string;
@IsOptional()
@IsString()
reference?: string;
@IsOptional()
@IsArray()
@IsString({ each: true })
constructeurIds?: string[];
@IsOptional()
@IsDecimal()
prix?: string;
@IsOptional()
@IsString()
typeMachineId?: string;
@IsOptional()
@IsArray()
@ValidateNested({ each: true })
@Type(() => MachineComponentLinkPayloadDto)
componentLinks?: MachineComponentLinkPayloadDto[];
@IsOptional()
@IsArray()
@ValidateNested({ each: true })
@Type(() => MachinePieceLinkPayloadDto)
pieceLinks?: MachinePieceLinkPayloadDto[];
@IsOptional()
@IsArray()
@ValidateNested({ each: true })
@Type(() => MachineProductLinkPayloadDto)
productLinks?: MachineProductLinkPayloadDto[];
}
export class UpdateMachineDto {
@IsOptional()
@IsString()
name?: string;
@IsOptional()
@IsString()
reference?: string;
@IsOptional()
@IsArray()
@IsString({ each: true })
constructeurIds?: string[];
@IsOptional()
@IsDecimal()
prix?: string;
@IsOptional()
@IsString()
typeMachineId?: string;
}
export class ReconfigureMachineDto {
@IsOptional()
@IsArray()
@ValidateNested({ each: true })
@Type(() => MachineComponentLinkPayloadDto)
componentLinks?: MachineComponentLinkPayloadDto[];
@IsOptional()
@IsArray()
@ValidateNested({ each: true })
@Type(() => MachinePieceLinkPayloadDto)
pieceLinks?: MachinePieceLinkPayloadDto[];
@IsOptional()
@IsArray()
@ValidateNested({ each: true })
@Type(() => MachineProductLinkPayloadDto)
productLinks?: MachineProductLinkPayloadDto[];
}
export type MachineComponentLinkInput = MachineComponentLinkPayloadDto;
export type MachinePieceLinkInput = MachinePieceLinkPayloadDto;
export type MachineProductLinkInput = MachineProductLinkPayloadDto;