Skip to main content
This page documents every type used across the Effect Coffee Shop API — from primitive enumerations through composite schemas and the error hierarchy. All definitions are derived directly from the TypeScript source using Effect’s Schema module.

DrinkId

Valid identifiers for drinks on the menu.
type DrinkId =
  | "espresso"
  | "americano"
  | "latte"
  | "cappuccino"
  | "cold-brew"
  | "tea";
ValueDrink
espressoEspresso
americanoAmericano
latteLatte
cappuccinoCappuccino
cold-brewCold Brew
teaTea

DrinkSize

Cup size options, each with a price multiplier applied to basePriceCents.
type DrinkSize = "small" | "medium" | "large";
ValuePrice multiplier
small1.00×
medium1.15×
large1.30×

Milk

Milk options available for drinks that support customization.
type Milk = "whole" | "oat" | "almond" | "none";
Not every drink supports every milk type. Check MenuItem.availableMilks for the valid set per drink.

Temperature

Serving temperature options.
type Temperature = "hot" | "iced" | "extra-hot";
As with milk, temperature availability depends on the specific drink. Check MenuItem.availableTemperatures.

OrderStatus

The complete set of lifecycle states for a coffee order.
type OrderStatus =
  | "pending"
  | "brewing"
  | "ready"
  | "picked-up"
  | "cancelled";

Transition diagram

Only the following status transitions are valid. Attempting any other transition produces an InvalidOrderStatusTransitionError (409).
pending ──► brewing ──► ready ──► picked-up
   │            │
   └────────────┴──► cancelled
FromAllowed transitions
pendingbrewing, cancelled
brewingready, cancelled
readypicked-up
picked-up(terminal — no transitions)
cancelled(terminal — no transitions)

OrderId

A string identifier for a specific order, constrained to the pattern order-{N}.
// Validated against /^order-\d+$/
type OrderId = string; // e.g. "order-1", "order-42"
The orderId parameter on all tools and the coffee://orders/:orderId resource URI both validate against this pattern at runtime.

Describes a single drink offering on the menu.
interface MenuItem {
  id: DrinkId;
  name: string;
  kind: "espresso" | "tea";
  basePriceCents: number;           // integer, US cents
  availableMilks: Milk[];
  availableTemperatures: Temperature[];
  maxShots: number;                 // integer; 0 for tea
}
id
DrinkId
Unique drink identifier.
name
string
Human-readable display name shown to customers.
kind
"espresso" | "tea"
Internal drink category used for business logic (e.g., default shot count).
basePriceCents
integer
Base price in US cents before the size multiplier and extra-shot surcharges are applied. Extra shots beyond the default cost 75 cents each.
availableMilks
Milk[]
The subset of milk options supported by this drink.
availableTemperatures
Temperature[]
The subset of temperature options supported by this drink.
maxShots
integer
Maximum number of espresso shots that may be added. Always 0 for tea.

CoffeeOrder

The full persisted record for a single order.
interface CoffeeOrder {
  id: OrderId;
  customerName: string;
  drinkId: DrinkId;
  drinkName: string;
  size: DrinkSize;
  milk: Milk;
  temperature: Temperature;
  shots: number;            // integer
  notes?: string;
  status: OrderStatus;
  priceCents: number;       // integer, US cents
  createdAt: Date;          // UTC
}
id
OrderId
Unique order identifier matching order-{N}.
customerName
string
Name supplied when the order was placed.
drinkId
DrinkId
The ordered drink’s identifier.
drinkName
string
Human-readable drink name resolved from the menu at order time.
size
DrinkSize
The chosen cup size.
milk
Milk
The resolved milk preference (defaulted from the menu if not provided).
temperature
Temperature
The resolved serving temperature (defaulted from the menu if not provided).
shots
integer
Number of espresso shots included in the order.
notes
string
Optional free-text instructions from the customer.
status
OrderStatus
Current lifecycle status of the order.
priceCents
integer
Final price in US cents: round(basePriceCents × sizeMultiplier) + max(shots − defaultShots, 0) × 75.
createdAt
DateTime (UTC)
ISO 8601 UTC timestamp recorded when the order was persisted.

PlaceOrderRequest

Input schema accepted by the place_order tool.
interface PlaceOrderRequest {
  customerName: string;
  drinkId: string;
  size: string;
  milk?: string;
  temperature?: string;
  shots?: number;   // integer
  notes?: string;
}
customerName
string
required
Name of the customer placing the order.
drinkId
string
required
Must resolve to a valid DrinkId. Validated against the menu at the service layer.
size
string
required
Must resolve to a valid DrinkSize (small, medium, or large).
milk
string
Optional milk preference. Defaults to the drink’s primary available milk when omitted.
temperature
string
Optional temperature preference. Defaults to the drink’s first available temperature when omitted.
shots
integer
Optional shot count. Defaults to 1 for espresso-based drinks and 0 for tea.
notes
string
Optional free-text special instructions.

ListOrdersRequest

Input schema accepted by the list_orders tool.
interface ListOrdersRequest {
  status?: string;
}
status
string
Optional status filter. Must resolve to a valid OrderStatus when provided. Omitting this field returns all orders regardless of status.

Errors

All errors are tagged Effect Schema.TaggedErrorClass instances. Every tool response may fail with any member of the AppError union.

DrinkNotFoundError

Returned when drinkId does not match any item in the menu.
PropertyValue
HTTP status404
Tag"DrinkNotFoundError"
class DrinkNotFoundError {
  readonly _tag: "DrinkNotFoundError";
  readonly drinkId: string;
}
drinkId
string
The unrecognized drink identifier that was supplied.

InvalidOrderInputError

Returned when order input fails business-rule validation (e.g., milk not available for the chosen drink).
PropertyValue
HTTP status400
Tag"InvalidOrderInputError"
class InvalidOrderInputError {
  readonly _tag: "InvalidOrderInputError";
  readonly message: string;
}
message
string
Human-readable description of the validation failure.

OrderNotFoundError

Returned when an orderId does not correspond to any persisted order.
PropertyValue
HTTP status404
Tag"OrderNotFoundError"
class OrderNotFoundError {
  readonly _tag: "OrderNotFoundError";
  readonly orderId: OrderId;
}
orderId
OrderId
The order ID that was not found.

InvalidOrderStatusTransitionError

Returned when a status-change tool is called on an order that is not in the required source status.
PropertyValue
HTTP status409
Tag"InvalidOrderStatusTransitionError"
class InvalidOrderStatusTransitionError {
  readonly _tag: "InvalidOrderStatusTransitionError";
  readonly orderId: OrderId;
  readonly from: OrderStatus;
  readonly to: OrderStatus;
}
orderId
OrderId
The order on which the transition was attempted.
from
OrderStatus
The order’s current (source) status.
to
OrderStatus
The target status that was requested but is not permitted from from.

PersistenceError

Returned when a storage operation fails unexpectedly.
PropertyValue
HTTP status500
Tag"PersistenceError"
class PersistenceError {
  readonly _tag: "PersistenceError";
  readonly message: string;
  readonly cause?: unknown;
}
message
string
Description of the failed storage operation.
cause
unknown
The underlying defect, if available. Populated by PersistenceError.refail.

InternalAppError

Returned when an unexpected application-level error occurs, including errors surfaced from PersistenceError through the service layer.
PropertyValue
HTTP status500
Tag"InternalAppError"
class InternalAppError {
  readonly _tag: "InternalAppError";
  readonly message: string;
  readonly cause?: unknown;
}
message
string
Description of the internal failure.
cause
unknown
The underlying defect, if available.

Build docs developers (and LLMs) love