xpeditis2.0/apps/backend/src/domain/ports/in/search-rates.port.ts
2025-10-20 12:30:08 +02:00

45 lines
1.2 KiB
TypeScript

/**
* SearchRatesPort (API Port - Input)
*
* Defines the interface for searching shipping rates
* This is the entry point for the rate search use case
*/
import { RateQuote } from '../../entities/rate-quote.entity';
export interface RateSearchInput {
origin: string; // Port code (UN/LOCODE)
destination: string; // Port code (UN/LOCODE)
containerType: string; // e.g., '20DRY', '40HC'
mode: 'FCL' | 'LCL';
departureDate: Date;
quantity?: number; // Number of containers (default: 1)
weight?: number; // For LCL (kg)
volume?: number; // For LCL (CBM)
isHazmat?: boolean;
imoClass?: string; // If hazmat
carrierPreferences?: string[]; // Specific carrier codes to query
}
export interface RateSearchOutput {
quotes: RateQuote[];
searchId: string;
searchedAt: Date;
totalResults: number;
carrierResults: {
carrierName: string;
status: 'success' | 'error' | 'timeout';
resultCount: number;
errorMessage?: string;
}[];
}
export interface SearchRatesPort {
/**
* Execute rate search across multiple carriers
* @param input - Rate search parameters
* @returns Rate quotes from available carriers
*/
execute(input: RateSearchInput): Promise<RateSearchOutput>;
}