xpeditis2.0/apps/backend/src/infrastructure/carriers/maersk/maersk-request.mapper.ts
David 4b00ee2601
Some checks failed
CI/CD Pipeline - Xpeditis PreProd / Frontend - Docker Build & Push (push) Blocked by required conditions
CI/CD Pipeline - Xpeditis PreProd / Deploy to PreProd Server (push) Blocked by required conditions
CI/CD Pipeline - Xpeditis PreProd / Run Smoke Tests (push) Blocked by required conditions
CI/CD Pipeline - Xpeditis PreProd / Backend - Build & Test (push) Failing after 5m53s
CI/CD Pipeline - Xpeditis PreProd / Backend - Docker Build & Push (push) Has been skipped
CI/CD Pipeline - Xpeditis PreProd / Frontend - Build & Test (push) Has been cancelled
fix: replace relative domain imports with TypeScript path aliases
- Replace all ../../domain/ imports with @domain/ across 67 files
- Configure NestJS to use tsconfig.build.json with rootDir
- Add tsc-alias to resolve path aliases after build
- This fixes 'Cannot find module' TypeScript compilation errors

Fixed files:
- 30 files in application layer
- 37 files in infrastructure layer
2025-11-16 19:20:58 +01:00

55 lines
1.6 KiB
TypeScript

/**
* Maersk Request Mapper
*
* Maps internal domain format to Maersk API format
*/
import { CarrierRateSearchInput } from '@domain/ports/out/carrier-connector.port';
import { MaerskRateSearchRequest } from './maersk.types';
export class MaerskRequestMapper {
/**
* Map domain rate search input to Maersk API request
*/
static toMaerskRateSearchRequest(input: CarrierRateSearchInput): MaerskRateSearchRequest {
const { size, type } = this.parseContainerType(input.containerType);
return {
originPortCode: input.origin,
destinationPortCode: input.destination,
containerSize: size,
containerType: type,
cargoMode: (input.mode as 'FCL' | 'LCL') || 'FCL',
estimatedDepartureDate: input.departureDate.toISOString(),
numberOfContainers: input.quantity || 1,
cargoWeight: input.weight,
cargoVolume: input.volume,
isDangerousGoods: input.isHazmat || false,
imoClass: input.imoClass,
};
}
/**
* Parse container type (e.g., '40HC' -> { size: '40', type: 'DRY' })
*/
private static parseContainerType(containerType: string): { size: string; type: string } {
// Extract size (first 2 digits)
const sizeMatch = containerType.match(/^(\d{2})/);
const size = sizeMatch ? sizeMatch[1] : '40';
// Determine type
let type = 'DRY';
if (containerType.includes('REEFER')) {
type = 'REEFER';
} else if (containerType.includes('OT')) {
type = 'OPEN_TOP';
} else if (containerType.includes('FR')) {
type = 'FLAT_RACK';
} else if (containerType.includes('TANK')) {
type = 'TANK';
}
return { size, type };
}
}