Schemas
Zod schemas and inferred types exported from @workspace/bridge/schemas/*, one file per concern.
Schemas are exported per file through the ./schemas/* wildcard: import @workspace/bridge/schemas/<file>. There is no aggregate entry point. Each file exports its Zod objects and a z.infer type for each one. The same modules are reachable at runtime through engine.schemas.
playerSchema.parse("N"); // "N"
cardSchema.parse("SA"); // "SA"
bidSchema.parse("3NT"); // "3NT"
bidSchema.safeParse("8NT").success; // false
contractSchema.parse({ level: 4, suit: "H", declarer: "S", doubled: "none" });bid
@workspace/bridge/schemas/bid. regularBidSchema and bidSchema are z.custom guards built on the bid parser, so they infer RegularBid and Bid rather than string.
| Schema | Inferred type | Validates |
|---|---|---|
bidLevelSchema | BidLevelSchema | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
denominationSchema | DenominationSchema | "C" | "D" | "H" | "S" | "NT" |
specialBidSchema | SpecialBidSchema | "Pass" | "X" | "XX" | "Alert" |
counterStatusSchema | CounterStatusSchema | "none" | "X" | "XX" |
regularBidSchema | RegularBidSchema | Level plus denomination, "1C" to "7NT" |
bidSchema | BidSchema | Any regular or special bid |
regularBidCompositeSchema | RegularBidCompositeSchema | { player, level, suit, type: "regular", index } |
specialBidCompositeSchema | SpecialBidCompositeSchema | { player, value, type: "special", index } |
bidCompositeSchema | BidCompositeSchema | Union of the two composites |
contractSchema | ContractSchema | { level, suit, declarer, doubled } |
card
@workspace/bridge/schemas/card. cardSchema is a z.custom guard and infers Card.
| Schema | Inferred type | Validates |
|---|---|---|
suitSchema | SuitSchema | "S" | "H" | "D" | "C" |
rankSchema | RankSchema | "A" to "2", with "T" for ten |
cardSchema | CardSchema | Suit then rank, "SA" |
deal
@workspace/bridge/schemas/deal validates the stored Deal shape (rank strings per suit, flat move lists). playMoveSchema.card is a plain string, not a cardSchema.
| Schema | Inferred type | Validates |
|---|---|---|
handSchema | HandSchema | { S, H, D, C } rank strings, 16 characters max each |
handsSchema | HandsSchema | Four handSchema keyed by seat |
auctionMoveSchema | AuctionMoveSchema | { bid, isAlerted?, comment? } |
auctionSchema | AuctionSchema | { first, moves: AuctionMove[] } |
playMoveSchema | PlayMoveSchema | { card: string, comment? } |
playSchema | PlaySchema | { first, moves: PlayMove[] } |
suitCountSchema | SuitCountSchema | { S, H, D, C } numbers |
handAnalysisSchema | HandAnalysisSchema | { points, suitCount } |
dealAnalysisSchema | DealAnalysisSchema | Four handAnalysisSchema keyed by seat |
const deal = makeDeal();
const cards = handsSchema.parse(deal.cards);
const auction = auctionSchema.parse(new AuctionBuilder().fromCompact("S / 1NT pass 3NT AP").build());game-params
@workspace/bridge/schemas/game-params
| Schema | Inferred type | Validates |
|---|---|---|
gameParamsSchema | GameParams | { vulnerability, scoringMode, resultExpected }, defaults "UNSET", "UNSET", null |
hands
@workspace/bridge/schemas/hands validates the in-memory HandsData shape, one string per card. The stored rank-string shape (Hand / Hands) is validated by handSchema / handsSchema in deal.
| Schema | Inferred type | Validates |
|---|---|---|
handDataSchema | HandDataSchema | Record<Suit, string[]> |
handsDataSchema | HandsDataSchema | Record<Player, HandDataSchema> |
const hands = handsDataSchema.parse({
N: { S: ["SA", "SK"], H: [], D: [], C: [] },
E: { S: [], H: ["HA"], D: [], C: [] },
S: { S: [], H: [], D: ["DA"], C: [] },
W: { S: [], H: [], D: [], C: ["CA"] },
});play
@workspace/bridge/schemas/play parses form data into the Trick shape that buildTricks returns.
| Schema | Inferred type | Validates |
|---|---|---|
playEntrySchema | PlayEntrySchema | { card: Card, player }, the card checked by cardSchema |
trickSchema | TrickSchema | { lead, cards, winner }, winner is null on an incomplete trick |
const trick = trickSchema.parse({ lead: "W", cards: [{ player: "W", card: "S9" }], winner: null });player
@workspace/bridge/schemas/player
| Schema | Inferred type | Validates |
|---|---|---|
playerSchema | PlayerSchema | "N" | "E" | "S" | "W" |
partnershipSchema | PartnershipSchema | "NS" | "EW" |
scoring
@workspace/bridge/schemas/scoring
| Schema | Inferred type | Validates |
|---|---|---|
scoringModeSchema | ScoringModeSchema | "UNSET" | "TPP" | "IMP" |
teach-params
@workspace/bridge/schemas/teach-params. Two mode schemas coexist: auctionModeSchema is built from the auction-picker groups and infers a plain string; teachingModeSchema matches the TeachingMode union exactly and is the one to use for stored or transported deal modes.
| Schema | Inferred type | Validates |
|---|---|---|
auctionModeSchema | AuctionMode (a string) | Picker mode values |
teachingModeSchema | none exported | The 12 TeachingMode values |
teachParamsSchema | TeachParams | { auctionMode, teachDummy }, defaults "auction", true |
const gameParams = gameParamsSchema.parse({});
// => { vulnerability: "UNSET", scoringMode: "UNSET", resultExpected: null }
const teachParams = teachParamsSchema.parse({});
// => { auctionMode: "auction", teachDummy: true }
teachingModeSchema.parse("petit-bridge");vulnerability
@workspace/bridge/schemas/vulnerability. No inferred type is exported; use Vulnerability from @workspace/bridge/types.
| Schema | Validates |
|---|---|
vulnerabilitySchema | "UNSET" | "NONE" | "NS" | "EW" | "ALL" |
engine.schemas
The engine exposes the same modules as namespaces, keyed player, card, bid, hands, auction, play, scoring, vulnerability, gameParams and teachParams. The deal file is not part of engine.schemas.
const engine = createBridgeEngine(createBridgeContext({ teachingMode: "auction" }));
engine.schemas.bid.bidSchema.parse("1C");
engine.schemas.hands.handsDataSchema.safeParse(new HandsBuilder().fromCompact("AKQ2.KQ3.A54.K32 JT98.JT9.KQJ.QJ9 7654.A87.T98.AT8 3.6542.7632.7654").build());Constants
Everything exported by @workspace/bridge/constants, grouped by theme — cards, bids, players, vulnerability, scoring, defaults, locales, board numbering, PBN tags, game facts, core configs, teaching.
Factories
Compact-string factories that build hands, auctions, contracts, plays and whole boards for seeds and tests.