UNPKG

flight-planner

Version:
64 lines (63 loc) 2.44 kB
import { Aircraft } from "../aircraft.js"; import { AircraftRepository } from "../repositories/aircraft.repository.js"; /** * AircraftService class provides methods to manage and retrieve aircraft data. * Acts as a service layer that handles business logic and validation. */ declare class AircraftService { private repository; /** * Creates a new instance of the AircraftService class. * * @param repository - The aircraft repository for data operations. * @throws Error if the repository is not provided. */ constructor(repository: AircraftRepository); /** * Retrieves an aircraft by its registration. * * @param registration - The registration of the aircraft to retrieve. * @returns A promise that resolves to the Aircraft object. * @throws Error if the registration is invalid or aircraft is not found. */ findByRegistration(registration: string): Promise<Aircraft>; /** * Creates a new aircraft in the service. * * @param aircraft - The Aircraft object to create. * @returns A promise that resolves to the created Aircraft object. * @throws Error if the registration is invalid. */ create(aircraft: Aircraft): Promise<Aircraft>; /** * Retrieves all aircraft. * * @returns A promise that resolves to an array of Aircraft objects. */ findAll(): Promise<Aircraft[]>; /** * Updates an existing aircraft in the service. * * @param aircraft - The Aircraft object to update. * @returns A promise that resolves to the updated Aircraft object. * @throws Error if the registration is invalid. */ update(aircraft: Aircraft): Promise<Aircraft>; /** * Deletes an aircraft from the service. * * @param registration - The registration of the aircraft to delete. * @returns A promise that resolves to true if the aircraft was deleted, false if not found. * @throws Error if the registration is invalid. */ delete(registration: string): Promise<boolean>; /** * Checks if an aircraft exists in the service. * * @param registration - The registration of the aircraft to check. * @returns A promise that resolves to true if the aircraft exists, false otherwise. * @throws Error if the registration is invalid. */ exists(registration: string): Promise<boolean>; } export default AircraftService;