mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-30 09:58:12 +00:00
56 lines
2.0 KiB
TypeScript
56 lines
2.0 KiB
TypeScript
import { IsString, IsArray, ValidateNested, IsOptional, IsEnum } from 'class-validator';
|
|
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
|
import { Type } from 'class-transformer';
|
|
|
|
export enum JourneyDirection {
|
|
ONE_WAY = 'ONE_WAY',
|
|
OUTBOUND = 'OUTBOUND',
|
|
RETURN = 'RETURN'
|
|
}
|
|
|
|
export class PassengerSeatDto {
|
|
@ApiProperty({ example: 'passenger-uuid', description: 'Passenger UUID' })
|
|
@IsString() passengerId: string;
|
|
|
|
@ApiProperty({ example: 'seat-uuid', description: 'Seat UUID assigned to this passenger' })
|
|
@IsString() seatId: string;
|
|
}
|
|
|
|
export class HoldSeatsDto {
|
|
@ApiProperty({ example: 'schedule-uuid', description: 'TrainSchedule UUID' })
|
|
@IsString() scheduleId: string;
|
|
|
|
@ApiProperty({ example: 'station-uuid', description: 'Origin station UUID — scopes the hold to a leg so the seat can be reused on non-overlapping legs' })
|
|
@IsString() originStationId: string;
|
|
|
|
@ApiProperty({ example: 'station-uuid', description: 'Destination station UUID for this leg' })
|
|
@IsString() destinationStationId: string;
|
|
|
|
@ApiPropertyOptional({
|
|
enum: JourneyDirection,
|
|
example: JourneyDirection.OUTBOUND,
|
|
description: 'Journey direction for round-trip bookings. ONE_WAY for single journeys, OUTBOUND/RETURN for round-trip legs. Allows same seats to be held for different directions.'
|
|
})
|
|
@IsOptional()
|
|
@IsEnum(JourneyDirection)
|
|
journeyDirection?: JourneyDirection;
|
|
|
|
@ApiProperty({
|
|
type: [PassengerSeatDto],
|
|
description: 'One entry per passenger. Each passenger is assigned exactly one seat. Duplicate passengerId or seatId within the same request is rejected.',
|
|
example: [
|
|
{ passengerId: 'passenger-uuid-1', seatId: 'seat-uuid-1' },
|
|
{ passengerId: 'passenger-uuid-2', seatId: 'seat-uuid-2' },
|
|
],
|
|
})
|
|
@IsArray()
|
|
@ValidateNested({ each: true })
|
|
@Type(() => PassengerSeatDto)
|
|
passengers: PassengerSeatDto[];
|
|
}
|
|
|
|
export class ReleaseHoldDto {
|
|
@ApiProperty({ example: 'hold-uuid', description: 'SeatHold UUID to release' })
|
|
@IsString() holdId: string;
|
|
}
|