xpeditis2.0/apps/backend/src/domain/services/booking.service.ts
David 3fc1091d31
Some checks failed
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 5m59s
CI/CD Pipeline - Xpeditis PreProd / Backend - Docker Build & Push (push) Has been skipped
CI/CD Pipeline - Xpeditis PreProd / Frontend - Build & Test (push) Successful in 11m1s
CI/CD Pipeline - Xpeditis PreProd / Frontend - Docker Build & Push (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:31:37 +01:00

66 lines
2.0 KiB
TypeScript

import { Injectable, Inject, NotFoundException } from '@nestjs/common';
import { Booking } from '../entities/booking.entity';
import { BookingRepository } from '@domain/ports/out/booking.repository';
import { RateQuoteRepository } from '@domain/ports/out/rate-quote.repository';
import { BOOKING_REPOSITORY } from '@domain/ports/out/booking.repository';
import { RATE_QUOTE_REPOSITORY } from '@domain/ports/out/rate-quote.repository';
import { v4 as uuidv4 } from 'uuid';
export interface CreateBookingInput {
rateQuoteId: string;
shipper: any;
consignee: any;
cargoDescription: string;
containers: any[];
specialInstructions?: string;
}
@Injectable()
export class BookingService {
constructor(
@Inject(BOOKING_REPOSITORY)
private readonly bookingRepository: BookingRepository,
@Inject(RATE_QUOTE_REPOSITORY)
private readonly rateQuoteRepository: RateQuoteRepository
) {}
/**
* Create a new booking
*/
async createBooking(input: CreateBookingInput): Promise<Booking> {
// Validate rate quote exists
const rateQuote = await this.rateQuoteRepository.findById(input.rateQuoteId);
if (!rateQuote) {
throw new NotFoundException(`Rate quote ${input.rateQuoteId} not found`);
}
// TODO: Get userId and organizationId from context
const userId = 'temp-user-id';
const organizationId = 'temp-org-id';
// Create booking entity
const booking = Booking.create({
id: uuidv4(),
userId,
organizationId,
rateQuoteId: input.rateQuoteId,
shipper: input.shipper,
consignee: input.consignee,
cargoDescription: input.cargoDescription,
containers: input.containers.map(c => ({
id: uuidv4(),
type: c.type,
containerNumber: c.containerNumber,
vgm: c.vgm,
temperature: c.temperature,
sealNumber: c.sealNumber,
})),
specialInstructions: input.specialInstructions,
});
// Persist booking
return this.bookingRepository.save(booking);
}
}