mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-26 18:42:49 +00:00
47 lines
2.8 KiB
TypeScript
47 lines
2.8 KiB
TypeScript
import { IsString, IsInt, IsNumber, IsOptional, IsArray, ValidateNested, IsBoolean, IsDateString, Min } from 'class-validator';
|
||
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
||
import { Type } from 'class-transformer';
|
||
|
||
export class RouteStopInputDto {
|
||
@ApiProperty({ example: 'station-uuid', description: 'Station UUID' }) @IsString() stationId: string;
|
||
@ApiProperty({ example: 1, description: 'Stop order (1 = origin, ascending)' }) @IsInt() @Min(1) sequence: number;
|
||
@ApiPropertyOptional({ example: 120.5, description: 'Distance in km from previous stop' }) @IsOptional() @IsNumber() distanceKm?: number;
|
||
}
|
||
|
||
export class CreateRouteDto {
|
||
@ApiProperty({ example: 'ADD-DJI', description: 'Unique route code' }) @IsString() code: string;
|
||
@ApiProperty({ example: 'Addis Ababa – Djibouti' }) @IsString() name: string;
|
||
@ApiPropertyOptional({ example: 'Main corridor via Dire Dawa' }) @IsOptional() @IsString() description?: string;
|
||
@ApiProperty({ example: '2026-01-01T00:00:00Z', description: 'Date from which this route is effective' }) @IsDateString() effectiveFrom: string;
|
||
@ApiPropertyOptional({ example: '2027-12-31T23:59:59Z' }) @IsOptional() @IsDateString() effectiveUntil?: string;
|
||
@ApiPropertyOptional({ example: true, description: 'Whether the route is active (defaults to true)' }) @IsOptional() @IsBoolean() active?: boolean;
|
||
@ApiProperty({
|
||
type: [RouteStopInputDto],
|
||
description: 'Ordered stops for this route. Sequence 1 = origin, last sequence = destination.',
|
||
example: [
|
||
{ stationId: 'uuid-ADD', sequence: 1 },
|
||
{ stationId: 'uuid-ADM', sequence: 2, distanceKm: 99 },
|
||
{ stationId: 'uuid-AWS', sequence: 3, distanceKm: 120 },
|
||
{ stationId: 'uuid-DDW', sequence: 4, distanceKm: 180 },
|
||
{ stationId: 'uuid-AYS', sequence: 5, distanceKm: 95 },
|
||
{ stationId: 'uuid-DJI', sequence: 6, distanceKm: 60 },
|
||
],
|
||
})
|
||
@IsArray() @ValidateNested({ each: true }) @Type(() => RouteStopInputDto)
|
||
stops: RouteStopInputDto[];
|
||
}
|
||
|
||
export class AddRouteStopDto {
|
||
@ApiProperty({ example: 'station-uuid' }) @IsString() stationId: string;
|
||
@ApiProperty({ example: 3 }) @IsInt() @Min(1) sequence: number;
|
||
@ApiPropertyOptional({ example: 75.5 }) @IsOptional() @IsNumber() distanceKm?: number;
|
||
}
|
||
|
||
export class UpdateRouteDto {
|
||
@ApiPropertyOptional({ example: 'Addis Ababa – Djibouti Express' }) @IsOptional() @IsString() name?: string;
|
||
@ApiPropertyOptional() @IsOptional() @IsString() description?: string;
|
||
@ApiPropertyOptional({ example: true }) @IsOptional() @IsBoolean() active?: boolean;
|
||
@ApiPropertyOptional({ example: '2027-12-31T23:59:59Z' }) @IsOptional() @IsDateString() effectiveUntil?: string;
|
||
@ApiPropertyOptional({ type: [RouteStopInputDto] }) @IsOptional() @IsArray() @ValidateNested({ each: true }) @Type(() => RouteStopInputDto) stops?: RouteStopInputDto[];
|
||
}
|