Types
Core domain types for bridge game modeling.
All types are available from @workspace/bridge-core/types or from the root export.
Player & Position
type Player = "N" | "E" | "S" | "W";
type Partnership = "NS" | "EW";
type PlayerSide = "attack" | "defense";Cards
type Suit = "S" | "H" | "D" | "C";
type Rank = "A" | "K" | "Q" | "J" | "T" | "9" | "8" | "7" | "6" | "5" | "4" | "3" | "2";
/** Suit followed by rank, e.g. "SA" (Ace of Spades), "H7" (Seven of Hearts) */
type Card = `${Suit}${Rank}`;Hands
Hand
A single player's hand organized by suit.
Prop
Type
Hands
All four hands at the table, keyed by player position.
Prop
Type
type HandData<TCard extends string = string> = Record<Suit, TCard[]>;
type HandsData<TCard extends string = string> = Record<Player, HandData<TCard>>;Bids
type BidLevel = 1 | 2 | 3 | 4 | 5 | 6 | 7;
type BidSuit = Suit | "NT";
type SpecialBid = "Pass" | "X" | "XX" | "Alert";
/** e.g. "1H", "3NT", "7S" */
type RegularBid = `${BidLevel}${BidSuit}`;
type Bid = RegularBid | SpecialBid;
type CounterStatus = "none" | "X" | "XX";
/** The level and suit extracted from a regular bid. */
type RegularBidParts = { level: BidLevel; suit: BidSuit };Bid Composites
RegularBidComposite
A regular bid with full context in the auction sequence.
Prop
Type
SpecialBidComposite
A special bid with full context in the auction sequence.
Prop
Type
type BidComposite = RegularBidComposite | SpecialBidComposite;Contract
Contract
Final contract determined after the auction.
Prop
Type
DisplayContract
Contract for display purposes (without declarer information).
Prop
Type
ContractResult
Result of calculating the contract from a bid sequence.
Prop
Type
type ContractLevel = "partial" | "game" | "small_slam" | "grand_slam";Auction
BidInfo
Information about a single bid in the auction sequence.
Prop
Type
AuctionState
Complete auction state tracking the bidding sequence.
Prop
Type
type Auction = { N: Bid[]; E: Bid[]; S: Bid[]; W: Bid[] };
type AuctionSequence = BidComposite[];Deal
Deal
A complete deal with identifier.
Prop
Type
DealData
Complete deal data including cards, auction, play, and metadata.
Prop
Type
DealMetadata
Complete deal metadata (event info, results, annotations, technical data).
Prop
Type
DealAuction
Auction data in deal format.
Prop
Type
DealPlay
Card play data in deal format.
Prop
Type
Note
An annotation note attached to a deal.
Prop
Type
type PlayerHand = Record<Suit, string>;
type AllHands = Record<Player, PlayerHand>;Play
PlayEntry
A single card played by a player.
Prop
Type
Trick
A complete trick (4 cards played, one per player).
Prop
Type
TrickEntry
Generic trick entry with card as string (flexible for form data).
Prop
Type
GenericTrick
Generic trick structure (flexible for form data).
Prop
Type
PlayState
State of the card play phase.
Prop
Type
PlayAnnotation
An annotation on a specific point in the card play.
Prop
Type
Configuration
type AuctionMode = "trump" | "goal" | "contract" | "sequence" | "interactive";
type SuitVariant = "classic" | "petit-bridge";CoreConfig
Minimal configuration for core services (game rules). Discriminated union: validBidSuits only exists when auctions is not false.
Prop
Type
ParsingConfig
Minimal configuration for parsing functions.
Prop
Type
Other Types
type Vulnerability = "ALL" | "NS" | "EW" | "NONE" | "UNSET";
/** Resolved vulnerability status for a specific player. */
type VulnerabilityStatus = "vulnerable" | "non-vulnerable" | "unset";
type ScoringMode = "UNSET" | "TPP" | "IMP";
type TeachingMode =
| "auction"
| "show-trump-goal"
| "no-auction"
| "show-trump"
| "show-contract"
| "h"
| "hd"
| "hld"
| "sequence"
| "petit-bridge"
| "no-dummy";Analysis
HandAnalysis
HCP and distribution analysis for a single hand.
Prop
Type
type SuitCount = Record<Suit, number>;
type DealAnalysis = Record<Player, HandAnalysis>;HandCardCounts
HCP and suit distribution counts for a single hand.
Prop
Type
/** HCP and suit distribution counts for all hands. */
type CardCounts = Record<Player, HandCardCounts>;PBN
/** e.g. "N:AKQ.JT.9876.5432 AKQ.JT.9876.5432 AKQ.JT.9876.5432 AKQ.JT.9876.5432" */
type PBN<TPlayer extends Player = Player> =
`${TPlayer}:${string}.${string}.${string}.${string} ${string}.${string}.${string}.${string} ${string}.${string}.${string}.${string} ${string}.${string}.${string}.${string}`;Utilities
/** Deterministic pseudo-random number generator based on a seed. */
type SeededRandom = {
next(): number;
};