xpeditis2.0/apps/backend/src/application/dto/csv-rate-upload.dto.ts
2025-10-27 20:54:01 +01:00

202 lines
4.1 KiB
TypeScript

import { ApiProperty } from '@nestjs/swagger';
import { IsNotEmpty, IsString, MaxLength } from 'class-validator';
/**
* CSV Rate Upload DTO
*
* Request DTO for uploading CSV rate files (ADMIN only)
*/
export class CsvRateUploadDto {
@ApiProperty({
description: 'Name of the carrier company',
example: 'SSC Consolidation',
maxLength: 255,
})
@IsNotEmpty()
@IsString()
@MaxLength(255)
companyName: string;
@ApiProperty({
description: 'CSV file containing shipping rates',
type: 'string',
format: 'binary',
})
file: any; // Will be handled by multer
}
/**
* CSV Rate Upload Response DTO
*/
export class CsvRateUploadResponseDto {
@ApiProperty({
description: 'Upload success status',
example: true,
})
success: boolean;
@ApiProperty({
description: 'Number of rate rows parsed from CSV',
example: 25,
})
ratesCount: number;
@ApiProperty({
description: 'Path where CSV file was saved',
example: 'ssc-consolidation.csv',
})
csvFilePath: string;
@ApiProperty({
description: 'Company name for which rates were uploaded',
example: 'SSC Consolidation',
})
companyName: string;
@ApiProperty({
description: 'Upload timestamp',
example: '2025-10-23T10:30:00Z',
})
uploadedAt: Date;
}
/**
* CSV Rate Config Response DTO
*
* Configuration entry for a company's CSV rates
*/
export class CsvRateConfigDto {
@ApiProperty({
description: 'Configuration ID',
example: '123e4567-e89b-12d3-a456-426614174000',
})
id: string;
@ApiProperty({
description: 'Company name',
example: 'SSC Consolidation',
})
companyName: string;
@ApiProperty({
description: 'CSV file path',
example: 'ssc-consolidation.csv',
})
csvFilePath: string;
@ApiProperty({
description: 'Integration type',
enum: ['CSV_ONLY', 'CSV_AND_API'],
example: 'CSV_ONLY',
})
type: 'CSV_ONLY' | 'CSV_AND_API';
@ApiProperty({
description: 'Whether company has API connector',
example: false,
})
hasApi: boolean;
@ApiProperty({
description: 'API connector name if hasApi is true',
example: null,
nullable: true,
})
apiConnector: string | null;
@ApiProperty({
description: 'Whether configuration is active',
example: true,
})
isActive: boolean;
@ApiProperty({
description: 'When CSV was last uploaded',
example: '2025-10-23T10:30:00Z',
})
uploadedAt: Date;
@ApiProperty({
description: 'Number of rate rows in CSV',
example: 25,
nullable: true,
})
rowCount: number | null;
@ApiProperty({
description: 'Additional metadata',
example: { description: 'LCL rates for Europe to US', coverage: 'Global' },
nullable: true,
})
metadata: Record<string, any> | null;
}
/**
* CSV File Validation Result DTO
*/
export class CsvFileValidationDto {
@ApiProperty({
description: 'Whether CSV file is valid',
example: true,
})
valid: boolean;
@ApiProperty({
description: 'Validation errors if any',
type: [String],
example: [],
})
errors: string[];
@ApiProperty({
description: 'Number of rows in CSV file',
example: 25,
required: false,
})
rowCount?: number;
}
/**
* Available Companies Response DTO
*/
export class AvailableCompaniesDto {
@ApiProperty({
description: 'List of available company names',
type: [String],
example: ['SSC Consolidation', 'ECU Worldwide', 'TCC Logistics', 'NVO Consolidation'],
})
companies: string[];
@ApiProperty({
description: 'Total number of companies',
example: 4,
})
total: number;
}
/**
* Filter Options Response DTO
*/
export class FilterOptionsDto {
@ApiProperty({
description: 'Available company names',
type: [String],
example: ['SSC Consolidation', 'ECU Worldwide', 'TCC Logistics', 'NVO Consolidation'],
})
companies: string[];
@ApiProperty({
description: 'Available container types',
type: [String],
example: ['LCL', '20DRY', '40HC', '40DRY'],
})
containerTypes: string[];
@ApiProperty({
description: 'Supported currencies',
type: [String],
example: ['USD', 'EUR'],
})
currencies: string[];
}