Skip to main content

Overview

The OrderRepository interface defines the contract for all order data operations in the application layer. It provides methods for retrieving order lists, updating order statuses, and fetching detailed order information. Source: application/order/order-repository.ts

Interface Definition

interface OrderRepository {
  listBoard(): Promise<OrderListDto[]>;
  updateStatus(id: string, toStatus: OrderStatus): Promise<void>;
  getDetail(id: string): Promise<OrderDetailDto>;
}

Methods

listBoard()

Retrieves the list of all orders for the order board display.
listBoard(): Promise<OrderListDto[]>

Returns

Promise<OrderListDto[]>
Promise
A promise that resolves to an array of order list DTOs.

OrderListDto Structure

id
string
required
Unique identifier for the order
partnerName
string
Name of the partner/restaurant
partnerImage
string
URL to the partner’s image
displayNumber
string
required
Human-readable order number for display
status
OrderStatus
required
Current status of the order (RECEIVED, CONFIRMED, PREPARING, READY, PICKED_UP, DELIVERED, CANCELLED)
priority
OrderPriority
required
Order priority level (NORMAL or HIGH)
activeTimer
string
Active timer value for the order
courierName
string
Name of the assigned courier

Example

const orders = await orderRepository.listBoard();
console.log(`Found ${orders.length} orders`);

updateStatus()

Updates the status of a specific order.
updateStatus(id: string, toStatus: OrderStatus): Promise<void>

Parameters

id
string
required
The unique identifier of the order to update
toStatus
OrderStatus
required
The new status to set for the order. Must be one of:
  • RECEIVED
  • CONFIRMED
  • PREPARING
  • READY
  • PICKED_UP
  • DELIVERED
  • CANCELLED

Returns

Promise<void>
Promise
A promise that resolves when the status update is complete

Example

await orderRepository.updateStatus('order-123', 'CONFIRMED');
console.log('Order status updated successfully');
Status transitions should follow the natural order flow. Attempting invalid status transitions may result in errors depending on the implementation.

getDetail()

Retrieves detailed information about a specific order.
getDetail(id: string): Promise<OrderDetailDto>

Parameters

id
string
required
The unique identifier of the order to retrieve

Returns

Promise<OrderDetailDto>
Promise
A promise that resolves to the order detail DTO

OrderDetailDto Structure

customerName
string
Name of the customer who placed the order
customerPhone
string
Phone number of the customer
deliveryAddress
string
Delivery address for the order
notes
string
Special instructions or notes for the order
courierName
string
Name of the assigned courier
items
array
required
Array of order items
id
string
required
Unique identifier for the item
name
string
required
Name of the item
image
string
required
URL to the item image
price
number
required
Price of a single unit
currency
string
required
Currency code (e.g., USD, EUR)
qty
number
required
Quantity ordered

Example

const detail = await orderRepository.getDetail('order-123');
console.log(`Order for ${detail.customerName}`);
console.log(`Items: ${detail.items.length}`);

Type Definitions

OrderStatus

type OrderStatus =
  | "RECEIVED"
  | "CONFIRMED"
  | "PREPARING"
  | "READY"
  | "PICKED_UP"
  | "DELIVERED"
  | "CANCELLED";

OrderPriority

type OrderPriority = "NORMAL" | "HIGH";

Implementation Notes

The OrderRepository is an interface and requires a concrete implementation. The actual data source (HTTP API, local storage, etc.) is determined by the implementation class.

Build docs developers (and LLMs) love