- 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
295 lines
5.0 KiB
TypeScript
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;
|