@benchme/scenarios 0.9.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/dist/acme-v1/index.d.ts +2 -1
  2. package/dist/acme-v1/index.js +4 -1
  3. package/dist/acme-v1/index.js.map +1 -1
  4. package/dist/acme-v1/names.d.ts +3 -0
  5. package/dist/acme-v1/names.js +3 -0
  6. package/dist/acme-v1/names.js.map +1 -1
  7. package/dist/guide-v1/index.js +2 -0
  8. package/dist/guide-v1/index.js.map +1 -1
  9. package/dist/index.d.ts +14 -2
  10. package/dist/index.js +15 -2
  11. package/dist/index.js.map +1 -1
  12. package/dist/prng.d.ts +7 -0
  13. package/dist/prng.js +12 -0
  14. package/dist/prng.js.map +1 -1
  15. package/dist/scenario.d.ts +68 -0
  16. package/dist/scenario.js.map +1 -1
  17. package/dist/shops-v1/index.js +2 -0
  18. package/dist/shops-v1/index.js.map +1 -1
  19. package/dist/sites/cinema/generate.d.ts +22 -0
  20. package/dist/sites/cinema/generate.js +258 -0
  21. package/dist/sites/cinema/generate.js.map +1 -0
  22. package/dist/sites/cinema/index.d.ts +3 -0
  23. package/dist/sites/cinema/index.js +4 -0
  24. package/dist/sites/cinema/index.js.map +1 -0
  25. package/dist/sites/cinema/rules.d.ts +142 -0
  26. package/dist/sites/cinema/rules.js +191 -0
  27. package/dist/sites/cinema/rules.js.map +1 -0
  28. package/dist/sites/cinema/types.d.ts +93 -0
  29. package/dist/sites/cinema/types.js +2 -0
  30. package/dist/sites/cinema/types.js.map +1 -0
  31. package/dist/sites/clinic/generate.d.ts +28 -0
  32. package/dist/sites/clinic/generate.js +282 -0
  33. package/dist/sites/clinic/generate.js.map +1 -0
  34. package/dist/sites/clinic/index.d.ts +3 -0
  35. package/dist/sites/clinic/index.js +3 -0
  36. package/dist/sites/clinic/index.js.map +1 -0
  37. package/dist/sites/clinic/rules.d.ts +96 -0
  38. package/dist/sites/clinic/rules.js +154 -0
  39. package/dist/sites/clinic/rules.js.map +1 -0
  40. package/dist/sites/clinic/types.d.ts +125 -0
  41. package/dist/sites/clinic/types.js +2 -0
  42. package/dist/sites/clinic/types.js.map +1 -0
  43. package/dist/sites/dining/generate.d.ts +15 -0
  44. package/dist/sites/dining/generate.js +146 -0
  45. package/dist/sites/dining/generate.js.map +1 -0
  46. package/dist/sites/dining/index.d.ts +3 -0
  47. package/dist/sites/dining/index.js +4 -0
  48. package/dist/sites/dining/index.js.map +1 -0
  49. package/dist/sites/dining/rules.d.ts +92 -0
  50. package/dist/sites/dining/rules.js +156 -0
  51. package/dist/sites/dining/rules.js.map +1 -0
  52. package/dist/sites/dining/types.d.ts +69 -0
  53. package/dist/sites/dining/types.js +14 -0
  54. package/dist/sites/dining/types.js.map +1 -0
  55. package/dist/sites/events/generate.d.ts +27 -0
  56. package/dist/sites/events/generate.js +197 -0
  57. package/dist/sites/events/generate.js.map +1 -0
  58. package/dist/sites/events/index.d.ts +3 -0
  59. package/dist/sites/events/index.js +4 -0
  60. package/dist/sites/events/index.js.map +1 -0
  61. package/dist/sites/events/rules.d.ts +99 -0
  62. package/dist/sites/events/rules.js +172 -0
  63. package/dist/sites/events/rules.js.map +1 -0
  64. package/dist/sites/events/types.d.ts +78 -0
  65. package/dist/sites/events/types.js +10 -0
  66. package/dist/sites/events/types.js.map +1 -0
  67. package/dist/sites/flights/generate.d.ts +21 -0
  68. package/dist/sites/flights/generate.js +210 -0
  69. package/dist/sites/flights/generate.js.map +1 -0
  70. package/dist/sites/flights/index.d.ts +3 -0
  71. package/dist/sites/flights/index.js +3 -0
  72. package/dist/sites/flights/index.js.map +1 -0
  73. package/dist/sites/flights/rules.d.ts +79 -0
  74. package/dist/sites/flights/rules.js +125 -0
  75. package/dist/sites/flights/rules.js.map +1 -0
  76. package/dist/sites/flights/types.d.ts +69 -0
  77. package/dist/sites/flights/types.js +2 -0
  78. package/dist/sites/flights/types.js.map +1 -0
  79. package/dist/sites/homes/generate.d.ts +19 -0
  80. package/dist/sites/homes/generate.js +180 -0
  81. package/dist/sites/homes/generate.js.map +1 -0
  82. package/dist/sites/homes/index.d.ts +3 -0
  83. package/dist/sites/homes/index.js +3 -0
  84. package/dist/sites/homes/index.js.map +1 -0
  85. package/dist/sites/homes/rules.d.ts +68 -0
  86. package/dist/sites/homes/rules.js +94 -0
  87. package/dist/sites/homes/rules.js.map +1 -0
  88. package/dist/sites/homes/types.d.ts +62 -0
  89. package/dist/sites/homes/types.js +2 -0
  90. package/dist/sites/homes/types.js.map +1 -0
  91. package/dist/sites/hotels/generate.d.ts +16 -0
  92. package/dist/sites/hotels/generate.js +134 -0
  93. package/dist/sites/hotels/generate.js.map +1 -0
  94. package/dist/sites/pizza/catalog.d.ts +34 -0
  95. package/dist/sites/pizza/catalog.js +65 -0
  96. package/dist/sites/pizza/catalog.js.map +1 -0
  97. package/dist/sites/pizza/generate.d.ts +19 -0
  98. package/dist/sites/pizza/generate.js +203 -0
  99. package/dist/sites/pizza/generate.js.map +1 -0
  100. package/dist/sites/pizza/index.d.ts +4 -0
  101. package/dist/sites/pizza/index.js +4 -0
  102. package/dist/sites/pizza/index.js.map +1 -0
  103. package/dist/sites/pizza/rules.d.ts +134 -0
  104. package/dist/sites/pizza/rules.js +217 -0
  105. package/dist/sites/pizza/rules.js.map +1 -0
  106. package/dist/sites/pizza/types.d.ts +114 -0
  107. package/dist/sites/pizza/types.js +2 -0
  108. package/dist/sites/pizza/types.js.map +1 -0
  109. package/dist/sites/rows.d.ts +14 -0
  110. package/dist/sites/rows.js +45 -0
  111. package/dist/sites/rows.js.map +1 -0
  112. package/dist/sites/sports/generate.d.ts +18 -0
  113. package/dist/sites/sports/generate.js +247 -0
  114. package/dist/sites/sports/generate.js.map +1 -0
  115. package/dist/sites/sports/index.d.ts +3 -0
  116. package/dist/sites/sports/index.js +3 -0
  117. package/dist/sites/sports/index.js.map +1 -0
  118. package/dist/sites/sports/rules.d.ts +110 -0
  119. package/dist/sites/sports/rules.js +139 -0
  120. package/dist/sites/sports/rules.js.map +1 -0
  121. package/dist/sites/sports/types.d.ts +91 -0
  122. package/dist/sites/sports/types.js +8 -0
  123. package/dist/sites/sports/types.js.map +1 -0
  124. package/dist/stays.d.ts +63 -0
  125. package/dist/stays.js +96 -0
  126. package/dist/stays.js.map +1 -0
  127. package/dist/web-v1/index.js +2 -0
  128. package/dist/web-v1/index.js.map +1 -1
  129. package/dist/webmcp-v1/index.d.ts +11 -0
  130. package/dist/webmcp-v1/index.js +26 -0
  131. package/dist/webmcp-v1/index.js.map +1 -0
  132. package/package.json +1 -1
@@ -0,0 +1,134 @@
1
+ import type { PizzaMenuItem, PizzaAllergen, PizzaBranch, PizzaConfig, PizzaFulfilment, PizzaOrder, PizzaOrderLine, PizzaRows, PizzaSize, PizzaStockout } from "./types.js";
2
+ /**
3
+ * The pizza site's rules, as pure functions over rows. apps/pizza enforces them
4
+ * inside every write's transaction and answers every search with them, and the
5
+ * intent corpus derives its answer keys with them, so the site and the keys
6
+ * cannot disagree about what can be ordered, when, or what it costs.
7
+ */
8
+ export type PizzaProblem = {
9
+ code: string;
10
+ message: string;
11
+ };
12
+ export type PizzaCatalog = Pick<PizzaRows, "sizes" | "toppings">;
13
+ /** One line of an order as a caller asks for it: a menu pizza (with any option named in its place), or a pizza from scratch. */
14
+ export type PizzaLineInput = {
15
+ pizzaCode?: string | null;
16
+ size: string;
17
+ crust?: string;
18
+ sauce?: string;
19
+ cheese?: string;
20
+ toppings?: readonly string[];
21
+ quantity: number;
22
+ };
23
+ export type PizzaQuoteInput = {
24
+ branchCode: string;
25
+ fulfilment: PizzaFulfilment;
26
+ lines: readonly PizzaLineInput[];
27
+ };
28
+ export type PizzaOrderInput = PizzaQuoteInput & {
29
+ address?: string | null;
30
+ slotDate: string;
31
+ slotTime: string;
32
+ };
33
+ export type PizzaQuote = {
34
+ branchCode: string;
35
+ fulfilment: PizzaFulfilment;
36
+ lines: PizzaOrderLine[];
37
+ subtotalCents: number;
38
+ deliveryFeeCents: number;
39
+ totalCents: number;
40
+ outOfStock: string[];
41
+ };
42
+ export type PizzaDiet = {
43
+ vegetarian: boolean;
44
+ vegan: boolean;
45
+ allergens: PizzaAllergen[];
46
+ };
47
+ export type PizzaMenuQuery = {
48
+ size: string;
49
+ branchCode?: string;
50
+ vegetarian?: boolean;
51
+ vegan?: boolean;
52
+ without?: readonly string[];
53
+ maxPriceCents?: number;
54
+ toppings?: readonly string[];
55
+ };
56
+ export type PizzaMenuOffer = PizzaDiet & {
57
+ pizzaCode: string;
58
+ name: string;
59
+ size: string;
60
+ priceCents: number;
61
+ crust: string;
62
+ sauce: string;
63
+ cheese: string;
64
+ toppings: string[];
65
+ };
66
+ export type PizzaSlot = {
67
+ time: string;
68
+ capacity: number;
69
+ left: number;
70
+ };
71
+ export type PizzaSlotQuery = {
72
+ branchCode: string;
73
+ date: string;
74
+ pizzas?: number;
75
+ from?: string;
76
+ };
77
+ /** A change to one line of a received order: options replaced, toppings replaced, added or removed, quantity. */
78
+ export type PizzaLineChange = {
79
+ size?: string;
80
+ crust?: string;
81
+ sauce?: string;
82
+ cheese?: string;
83
+ toppings?: readonly string[];
84
+ addToppings?: readonly string[];
85
+ removeToppings?: readonly string[];
86
+ quantity?: number;
87
+ };
88
+ /** A topping set as one comparable string: the keys sorted and comma-joined. */
89
+ export declare const pizzaToppingsKey: (toppings: readonly string[]) => string;
90
+ /** The smallest size that serves `people`, or null when none does. */
91
+ export declare function pizzaSizeFor(sizes: readonly PizzaSize[], people: number): PizzaSize | null;
92
+ /** The configuration a line asks for: its menu pizza's, with each option it names in its place; from scratch, a classic crust, tomato sauce, mozzarella and the toppings it names. */
93
+ export declare function pizzaResolveLine(pizzas: readonly PizzaMenuItem[], item: PizzaLineInput): {
94
+ config: PizzaConfig;
95
+ pizzaCode: string | null;
96
+ } | {
97
+ problem: PizzaProblem;
98
+ };
99
+ /** Why a configuration cannot be made at all: an unknown option, a crust not made in the size, a topping twice, too many, or nothing on it. */
100
+ export declare function pizzaConfigProblem(catalog: PizzaCatalog, c: PizzaConfig): PizzaProblem | null;
101
+ /** One pizza's price: the size's base, the crust and cheese surcharges in that size, and each topping's price in that size. The configuration must be valid. */
102
+ export declare function pizzaUnitCents(catalog: PizzaCatalog, c: PizzaConfig): number;
103
+ /** Vegetarian or vegan when every part is; the allergens of every part, in PIZZA_ALLERGENS order. */
104
+ export declare function pizzaDiet(catalog: PizzaCatalog, c: Omit<PizzaConfig, "size">): PizzaDiet;
105
+ /** The toppings in `toppings` that the branch has run out of, sorted. */
106
+ export declare function pizzaOutOfStock(stockouts: readonly PizzaStockout[], branchCode: string, toppings: readonly string[]): string[];
107
+ /** No fee for pickup; for delivery the branch's fee, unless the subtotal reaches its free-delivery threshold. */
108
+ export declare function pizzaDeliveryFeeCents(branch: PizzaBranch, fulfilment: PizzaFulfilment, subtotalCents: number): number;
109
+ /** Pizzas the branch can still make in one slot: its capacity less every pizza of the orders that hold it (all but cancelled), `exceptOrderNo` left out. */
110
+ export declare function pizzaSlotLeft(branch: PizzaBranch, orders: readonly PizzaOrder[], date: string, time: string, exceptOrderNo?: string): number;
111
+ /** A branch's slots on a date, from `from` on, each with what it can still make — only those with room for `pizzas` when it is given. */
112
+ export declare function pizzaSlots(rows: Pick<PizzaRows, "branches" | "orders">, q: PizzaSlotQuery): PizzaSlot[];
113
+ /** Every line resolved, checked and priced at the branch, and the order's subtotal, delivery fee and total. Stock is reported, not refused. */
114
+ export declare function pizzaQuote(rows: Omit<PizzaRows, "orders">, input: PizzaQuoteInput): {
115
+ quote: PizzaQuote;
116
+ } | {
117
+ problem: PizzaProblem;
118
+ };
119
+ /** The rule every new order is held to: the slot, the address, the lines (pizzaQuote), stock at the branch, then room in the slot. On success, the priced order. */
120
+ export declare function pizzaPlaceOrder(rows: PizzaRows, input: PizzaOrderInput): {
121
+ quote: PizzaQuote;
122
+ } | {
123
+ problem: PizzaProblem;
124
+ };
125
+ /** Only a received order can be changed or cancelled. */
126
+ export declare function pizzaLockProblem(order: Pick<PizzaOrder, "orderNo" | "status">): PizzaProblem | null;
127
+ /** One line of a received order changed: the new configuration checked, its toppings in stock, the slot's room for the new quantities, the order re-priced. */
128
+ export declare function pizzaChangeLine(rows: PizzaRows, order: PizzaOrder, line: number, change: PizzaLineChange): {
129
+ order: PizzaOrder;
130
+ } | {
131
+ problem: PizzaProblem;
132
+ };
133
+ /** Every menu pizza that can be made in the size (at the branch, when one is named: none of its toppings out there) and meets each filter, cheapest first. */
134
+ export declare function pizzaMenuSearch(rows: Omit<PizzaRows, "orders">, q: PizzaMenuQuery): PizzaMenuOffer[];
@@ -0,0 +1,217 @@
1
+ import { isDate } from "../../stays.js";
2
+ import { PIZZA_ALLERGENS, PIZZA_CHEESES, PIZZA_CRUSTS, PIZZA_HOLDING, PIZZA_MAX_LINES, PIZZA_MAX_QUANTITY, PIZZA_MAX_TOPPINGS, PIZZA_SAUCES, PIZZA_SLOT_TIMES, PIZZA_WINDOW } from "./catalog.js";
3
+ const norm = (s) => s.trim().toLowerCase();
4
+ const code = (s) => s.trim().toUpperCase();
5
+ const byKey = (xs, key) => xs.find((x) => x.key === key);
6
+ const listed = (xs) => (xs.length <= 1 ? (xs[0] ?? "") : `${xs.slice(0, -1).join(", ")} and ${xs[xs.length - 1]}`);
7
+ const fail = (c, message) => ({ problem: { code: c, message } });
8
+ /** A topping set as one comparable string: the keys sorted and comma-joined. */
9
+ export const pizzaToppingsKey = (toppings) => [...toppings].sort().join(",");
10
+ /** The smallest size that serves `people`, or null when none does. */
11
+ export function pizzaSizeFor(sizes, people) {
12
+ return [...sizes].sort((x, y) => x.serves - y.serves).find((s) => s.serves >= people) ?? null;
13
+ }
14
+ /** The configuration a line asks for: its menu pizza's, with each option it names in its place; from scratch, a classic crust, tomato sauce, mozzarella and the toppings it names. */
15
+ export function pizzaResolveLine(pizzas, item) {
16
+ const base = item.pizzaCode ? pizzas.find((p) => p.code === code(item.pizzaCode)) : undefined;
17
+ if (item.pizzaCode && !base)
18
+ return fail("UNKNOWN_PIZZA", `no menu pizza ${item.pizzaCode}`);
19
+ const from = base ?? { crust: "classic", sauce: "tomato", cheese: "regular", toppings: [] };
20
+ return {
21
+ pizzaCode: base?.code ?? null,
22
+ config: { size: norm(item.size), crust: norm(item.crust ?? from.crust), sauce: norm(item.sauce ?? from.sauce), cheese: norm(item.cheese ?? from.cheese), toppings: (item.toppings ?? from.toppings).map(norm).sort() },
23
+ };
24
+ }
25
+ /** Why a configuration cannot be made at all: an unknown option, a crust not made in the size, a topping twice, too many, or nothing on it. */
26
+ export function pizzaConfigProblem(catalog, c) {
27
+ const size = byKey(catalog.sizes, c.size);
28
+ if (!size)
29
+ return { code: "UNKNOWN_SIZE", message: `no size ${c.size}; the sizes are ${listed(catalog.sizes.map((s) => s.key))}` };
30
+ const crust = byKey(PIZZA_CRUSTS, c.crust);
31
+ if (!crust)
32
+ return { code: "UNKNOWN_CRUST", message: `no crust ${c.crust}; the crusts are ${listed(PIZZA_CRUSTS.map((x) => x.key))}` };
33
+ if (!crust.sizes.includes(size.key))
34
+ return { code: "CRUST_NOT_IN_SIZE", message: `the ${crust.name} crust is made in ${listed(crust.sizes)} only, not ${size.key}` };
35
+ if (!byKey(PIZZA_SAUCES, c.sauce))
36
+ return { code: "UNKNOWN_SAUCE", message: `no sauce ${c.sauce}; the sauces are ${listed(PIZZA_SAUCES.map((x) => x.key))}` };
37
+ if (!byKey(PIZZA_CHEESES, c.cheese))
38
+ return { code: "UNKNOWN_CHEESE", message: `no cheese ${c.cheese}; the cheeses are ${listed(PIZZA_CHEESES.map((x) => x.key))}` };
39
+ const unknown = c.toppings.find((t) => !byKey(catalog.toppings, t));
40
+ if (unknown !== undefined)
41
+ return { code: "UNKNOWN_TOPPING", message: `no topping ${unknown}` };
42
+ if (new Set(c.toppings).size !== c.toppings.length)
43
+ return { code: "DUPLICATE_TOPPING", message: "each topping can be on a pizza once" };
44
+ if (c.toppings.length > PIZZA_MAX_TOPPINGS)
45
+ return { code: "TOO_MANY_TOPPINGS", message: `a pizza has at most ${PIZZA_MAX_TOPPINGS} toppings` };
46
+ if (c.sauce === "none" && c.cheese === "none" && c.toppings.length === 0)
47
+ return { code: "EMPTY_PIZZA", message: "a pizza needs a sauce, a cheese or a topping" };
48
+ return null;
49
+ }
50
+ /** One pizza's price: the size's base, the crust and cheese surcharges in that size, and each topping's price in that size. The configuration must be valid. */
51
+ export function pizzaUnitCents(catalog, c) {
52
+ const size = byKey(catalog.sizes, c.size);
53
+ const crust = byKey(PIZZA_CRUSTS, c.crust);
54
+ const cheese = byKey(PIZZA_CHEESES, c.cheese);
55
+ const toppings = c.toppings.reduce((sum, t) => sum + (byKey(catalog.toppings, t)?.pricesCents[size.key] ?? 0), 0);
56
+ return size.baseCents + (crust?.surchargeCents[size.key] ?? 0) + (cheese?.surchargeCents[size.key] ?? 0) + toppings;
57
+ }
58
+ /** Vegetarian or vegan when every part is; the allergens of every part, in PIZZA_ALLERGENS order. */
59
+ export function pizzaDiet(catalog, c) {
60
+ const parts = [byKey(PIZZA_CRUSTS, c.crust), byKey(PIZZA_SAUCES, c.sauce), byKey(PIZZA_CHEESES, c.cheese), ...c.toppings.map((t) => byKey(catalog.toppings, t))].filter((p) => !!p);
61
+ return { vegetarian: parts.every((p) => p.vegetarian), vegan: parts.every((p) => p.vegan), allergens: PIZZA_ALLERGENS.filter((a) => parts.some((p) => p.allergens.includes(a))) };
62
+ }
63
+ /** The toppings in `toppings` that the branch has run out of, sorted. */
64
+ export function pizzaOutOfStock(stockouts, branchCode, toppings) {
65
+ const out = new Set(stockouts.filter((s) => s.branchCode === code(branchCode)).map((s) => s.toppingKey));
66
+ return [...new Set(toppings.filter((t) => out.has(t)))].sort();
67
+ }
68
+ /** No fee for pickup; for delivery the branch's fee, unless the subtotal reaches its free-delivery threshold. */
69
+ export function pizzaDeliveryFeeCents(branch, fulfilment, subtotalCents) {
70
+ if (fulfilment === "pickup")
71
+ return 0;
72
+ return branch.freeDeliveryFromCents !== null && subtotalCents >= branch.freeDeliveryFromCents ? 0 : (branch.deliveryFeeCents ?? 0);
73
+ }
74
+ /** Pizzas the branch can still make in one slot: its capacity less every pizza of the orders that hold it (all but cancelled), `exceptOrderNo` left out. */
75
+ export function pizzaSlotLeft(branch, orders, date, time, exceptOrderNo) {
76
+ const held = orders
77
+ .filter((o) => o.branchCode === branch.code && o.slotDate === date && o.slotTime === time && PIZZA_HOLDING.includes(o.status) && o.orderNo !== exceptOrderNo)
78
+ .reduce((sum, o) => sum + o.lines.reduce((n, i) => n + i.quantity, 0), 0);
79
+ return Math.max(0, branch.slotCapacity - held);
80
+ }
81
+ /** A branch's slots on a date, from `from` on, each with what it can still make — only those with room for `pizzas` when it is given. */
82
+ export function pizzaSlots(rows, q) {
83
+ const branch = rows.branches.find((b) => b.code === code(q.branchCode));
84
+ if (!branch || !isDate(q.date) || q.date < PIZZA_WINDOW.first || q.date > PIZZA_WINDOW.last)
85
+ return [];
86
+ return PIZZA_SLOT_TIMES.filter((t) => !q.from || t >= q.from)
87
+ .map((time) => ({ time, capacity: branch.slotCapacity, left: pizzaSlotLeft(branch, rows.orders, q.date, time) }))
88
+ .filter((s) => s.left >= (q.pizzas ?? 0));
89
+ }
90
+ /** Every line resolved, checked and priced at the branch, and the order's subtotal, delivery fee and total. Stock is reported, not refused. */
91
+ export function pizzaQuote(rows, input) {
92
+ const branch = rows.branches.find((b) => b.code === code(input.branchCode));
93
+ if (!branch)
94
+ return fail("UNKNOWN_BRANCH", `no branch ${input.branchCode}`);
95
+ if (input.fulfilment === "delivery" && !branch.delivers)
96
+ return fail("NO_DELIVERY", `${branch.name} does not deliver; order for pickup`);
97
+ if (input.lines.length === 0)
98
+ return fail("NO_LINES", "an order needs at least one pizza");
99
+ if (input.lines.length > PIZZA_MAX_LINES)
100
+ return fail("TOO_MANY_LINES", `an order has at most ${PIZZA_MAX_LINES} lines`);
101
+ const lines = [];
102
+ for (const [i, item] of input.lines.entries()) {
103
+ if (!Number.isInteger(item.quantity) || item.quantity < 1 || item.quantity > PIZZA_MAX_QUANTITY)
104
+ return fail("BAD_QUANTITY", `a line is 1 to ${PIZZA_MAX_QUANTITY} pizzas`);
105
+ const r = pizzaResolveLine(rows.pizzas, item);
106
+ if ("problem" in r)
107
+ return r;
108
+ const p = pizzaConfigProblem(rows, r.config);
109
+ if (p)
110
+ return { problem: p };
111
+ const unitCents = pizzaUnitCents(rows, r.config);
112
+ lines.push({ line: i + 1, pizzaCode: r.pizzaCode, ...r.config, quantity: item.quantity, unitCents, lineCents: unitCents * item.quantity });
113
+ }
114
+ const subtotalCents = lines.reduce((sum, i) => sum + i.lineCents, 0);
115
+ const deliveryFeeCents = pizzaDeliveryFeeCents(branch, input.fulfilment, subtotalCents);
116
+ const outOfStock = pizzaOutOfStock(rows.stockouts, branch.code, lines.flatMap((i) => i.toppings));
117
+ return { quote: { branchCode: branch.code, fulfilment: input.fulfilment, lines, subtotalCents, deliveryFeeCents, totalCents: subtotalCents + deliveryFeeCents, outOfStock } };
118
+ }
119
+ /** The slot rules: a date in the window, one of the slot times. */
120
+ function slotProblem(date, time) {
121
+ if (!isDate(date))
122
+ return { code: "BAD_DATE", message: `slot date ${date} is not a date (YYYY-MM-DD)` };
123
+ if (date < PIZZA_WINDOW.first || date > PIZZA_WINDOW.last)
124
+ return { code: "OUTSIDE_WINDOW", message: `orders are taken for slots from ${PIZZA_WINDOW.first} to ${PIZZA_WINDOW.last}` };
125
+ if (!PIZZA_SLOT_TIMES.includes(time))
126
+ return { code: "BAD_SLOT_TIME", message: `slots start every 30 minutes from ${PIZZA_SLOT_TIMES[0]} to ${PIZZA_SLOT_TIMES[PIZZA_SLOT_TIMES.length - 1]}` };
127
+ return null;
128
+ }
129
+ const outMessage = (rows, branch, out) => `the ${branch} branch is out of ${listed(out.map((t) => rows.toppings.find((x) => x.key === t)?.name.toLowerCase() ?? t))}`;
130
+ /** The rule every new order is held to: the slot, the address, the lines (pizzaQuote), stock at the branch, then room in the slot. On success, the priced order. */
131
+ export function pizzaPlaceOrder(rows, input) {
132
+ if (!rows.branches.some((b) => b.code === code(input.branchCode)))
133
+ return fail("UNKNOWN_BRANCH", `no branch ${input.branchCode}`);
134
+ const slot = slotProblem(input.slotDate, input.slotTime);
135
+ if (slot)
136
+ return { problem: slot };
137
+ if (input.fulfilment === "delivery" && !(input.address ?? "").trim())
138
+ return fail("NO_ADDRESS", "a delivery needs an address");
139
+ const q = pizzaQuote(rows, input);
140
+ if ("problem" in q)
141
+ return q;
142
+ const branch = rows.branches.find((b) => b.code === q.quote.branchCode);
143
+ if (q.quote.outOfStock.length)
144
+ return fail("TOPPING_OUT", outMessage(rows, branch.name, q.quote.outOfStock));
145
+ const need = q.quote.lines.reduce((n, i) => n + i.quantity, 0);
146
+ const left = pizzaSlotLeft(branch, rows.orders, input.slotDate, input.slotTime);
147
+ if (need > left)
148
+ return fail("SLOT_FULL", `${branch.name} can make ${left} more pizza(s) in the ${input.slotTime} slot on ${input.slotDate}; this order has ${need}`);
149
+ return q;
150
+ }
151
+ /** Only a received order can be changed or cancelled. */
152
+ export function pizzaLockProblem(order) {
153
+ if (order.status === "cancelled")
154
+ return { code: "ALREADY_CANCELLED", message: `order ${order.orderNo} is already cancelled` };
155
+ if (order.status !== "received")
156
+ return { code: "ORDER_LOCKED", message: `order ${order.orderNo} is ${order.status.replace(/_/g, " ")}; only a received order can be changed or cancelled` };
157
+ return null;
158
+ }
159
+ /** One line of a received order changed: the new configuration checked, its toppings in stock, the slot's room for the new quantities, the order re-priced. */
160
+ export function pizzaChangeLine(rows, order, line, change) {
161
+ const lock = pizzaLockProblem(order);
162
+ if (lock)
163
+ return { problem: lock };
164
+ const item = order.lines.find((i) => i.line === line);
165
+ if (!item)
166
+ return fail("UNKNOWN_LINE", `order ${order.orderNo} has no line ${line}`);
167
+ let toppings = (change.toppings ?? item.toppings).map(norm);
168
+ for (const t of (change.removeToppings ?? []).map(norm)) {
169
+ if (!toppings.includes(t))
170
+ return fail("TOPPING_NOT_ON_PIZZA", `line ${line} has no ${t} to remove`);
171
+ toppings = toppings.filter((x) => x !== t);
172
+ }
173
+ toppings = [...toppings, ...(change.addToppings ?? []).map(norm)];
174
+ const asInput = (i) => ({ size: i.size, crust: i.crust, sauce: i.sauce, cheese: i.cheese, toppings: i.toppings, quantity: i.quantity });
175
+ const changed = { size: change.size ?? item.size, crust: change.crust ?? item.crust, sauce: change.sauce ?? item.sauce, cheese: change.cheese ?? item.cheese, toppings, quantity: change.quantity ?? item.quantity };
176
+ const q = pizzaQuote(rows, { branchCode: order.branchCode, fulfilment: order.fulfilment, lines: order.lines.map((i) => (i.line === line ? changed : asInput(i))) });
177
+ if ("problem" in q)
178
+ return q;
179
+ const branch = rows.branches.find((b) => b.code === order.branchCode);
180
+ const now = q.quote.lines[order.lines.indexOf(item)];
181
+ const out = pizzaOutOfStock(rows.stockouts, branch.code, now.toppings);
182
+ if (out.length)
183
+ return fail("TOPPING_OUT", outMessage(rows, branch.name, out));
184
+ const need = q.quote.lines.reduce((n, i) => n + i.quantity, 0);
185
+ const left = pizzaSlotLeft(branch, rows.orders, order.slotDate, order.slotTime, order.orderNo);
186
+ if (need > left)
187
+ return fail("SLOT_FULL", `${branch.name} can make ${left} more pizza(s) for this order's slot; it would have ${need}`);
188
+ const lines = q.quote.lines.map((i, n) => ({ ...i, pizzaCode: order.lines[n]?.pizzaCode ?? null, line: order.lines[n]?.line ?? i.line }));
189
+ return { order: { ...order, lines, subtotalCents: q.quote.subtotalCents, deliveryFeeCents: q.quote.deliveryFeeCents, totalCents: q.quote.totalCents } };
190
+ }
191
+ /** Every menu pizza that can be made in the size (at the branch, when one is named: none of its toppings out there) and meets each filter, cheapest first. */
192
+ export function pizzaMenuSearch(rows, q) {
193
+ const size = norm(q.size);
194
+ const without = (q.without ?? []).map(norm).filter(Boolean);
195
+ const must = (q.toppings ?? []).map(norm).filter(Boolean);
196
+ if (q.branchCode && !rows.branches.some((b) => b.code === code(q.branchCode)))
197
+ return [];
198
+ const offers = [];
199
+ for (const p of rows.pizzas) {
200
+ const config = { size, crust: p.crust, sauce: p.sauce, cheese: p.cheese, toppings: p.toppings };
201
+ if (pizzaConfigProblem(rows, config))
202
+ continue;
203
+ if (q.branchCode && pizzaOutOfStock(rows.stockouts, q.branchCode, p.toppings).length)
204
+ continue;
205
+ const diet = pizzaDiet(rows, config);
206
+ if ((q.vegetarian && !diet.vegetarian) || (q.vegan && !diet.vegan) || without.some((a) => diet.allergens.includes(a)))
207
+ continue;
208
+ if (must.some((t) => !p.toppings.includes(t)))
209
+ continue;
210
+ const priceCents = pizzaUnitCents(rows, config);
211
+ if (q.maxPriceCents !== undefined && priceCents > q.maxPriceCents)
212
+ continue;
213
+ offers.push({ pizzaCode: p.code, name: p.name, size, priceCents, crust: p.crust, sauce: p.sauce, cheese: p.cheese, toppings: p.toppings, ...diet });
214
+ }
215
+ return offers.sort((x, y) => x.priceCents - y.priceCents || x.pizzaCode.localeCompare(y.pizzaCode));
216
+ }
217
+ //# sourceMappingURL=rules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rules.js","sourceRoot":"","sources":["../../../src/sites/pizza/rules.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,YAAY,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAyBlM,MAAM,IAAI,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;AACnD,MAAM,IAAI,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;AACnD,MAAM,KAAK,GAAG,CAA4B,EAAgB,EAAE,GAAW,EAAiB,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CA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ACD,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,GAAG,CAAC,CAAC,UAAU,IAAI,CAAC,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;AACtG,CAAC"}
@@ -0,0 +1,114 @@
1
+ /**
2
+ * The pizza ordering site (apps/pizza): a chain with branches in six cities, a
3
+ * menu of named pizzas (each one a base configuration) and a builder. Prices
4
+ * are per pizza; an order's total adds the branch's delivery fee unless the
5
+ * subtotal reaches its free-delivery threshold. Rules: ./rules.ts.
6
+ */
7
+ export type PizzaSizeKey = "small" | "medium" | "large" | "xlarge";
8
+ export type PizzaAllergen = "gluten" | "dairy" | "nuts" | "fish";
9
+ /** A size and the price of a plain pizza (crust, sauce, cheese) in it. `serves` is how many people it feeds. */
10
+ export type PizzaSize = {
11
+ key: PizzaSizeKey;
12
+ name: string;
13
+ inches: number;
14
+ serves: number;
15
+ baseCents: number;
16
+ };
17
+ /** One topping; its price depends on the pizza's size. */
18
+ export type PizzaTopping = {
19
+ key: string;
20
+ name: string;
21
+ vegetarian: boolean;
22
+ vegan: boolean;
23
+ allergens: PizzaAllergen[];
24
+ pricesCents: Record<PizzaSizeKey, number>;
25
+ };
26
+ /** Crusts, sauces and cheeses are the chain's fixed options (./catalog.ts); a surcharge depends on the size. */
27
+ export type PizzaOption = {
28
+ key: string;
29
+ name: string;
30
+ vegetarian: boolean;
31
+ vegan: boolean;
32
+ allergens: PizzaAllergen[];
33
+ };
34
+ export type PizzaCrust = PizzaOption & {
35
+ sizes: PizzaSizeKey[];
36
+ surchargeCents: Partial<Record<PizzaSizeKey, number>>;
37
+ };
38
+ export type PizzaSauce = PizzaOption;
39
+ export type PizzaCheese = PizzaOption & {
40
+ surchargeCents: Record<PizzaSizeKey, number>;
41
+ };
42
+ /** What a pizza is made of. `toppings` is a set (each at most once), kept sorted. */
43
+ export type PizzaConfig = {
44
+ size: string;
45
+ crust: string;
46
+ sauce: string;
47
+ cheese: string;
48
+ toppings: string[];
49
+ };
50
+ /** A named pizza on the menu: a base configuration without a size. */
51
+ export type PizzaMenuItem = {
52
+ code: string;
53
+ name: string;
54
+ description: string;
55
+ crust: string;
56
+ sauce: string;
57
+ cheese: string;
58
+ toppings: string[];
59
+ };
60
+ export type PizzaBranch = {
61
+ code: string;
62
+ name: string;
63
+ city: string;
64
+ address: string;
65
+ delivers: boolean;
66
+ /** Null where the branch is pickup only. */
67
+ deliveryFeeCents: number | null;
68
+ /** Delivery is free when the subtotal is at least this; null where the branch is pickup only. */
69
+ freeDeliveryFromCents: number | null;
70
+ /** Pizzas the branch makes per 30-minute slot. */
71
+ slotCapacity: number;
72
+ };
73
+ /** A topping a branch has run out of: no order there may use it. */
74
+ export type PizzaStockout = {
75
+ branchCode: string;
76
+ toppingKey: string;
77
+ };
78
+ export type PizzaOrderStatus = "received" | "preparing" | "out_for_delivery" | "delivered" | "cancelled";
79
+ export type PizzaFulfilment = "pickup" | "delivery";
80
+ export type PizzaOrderLine = PizzaConfig & {
81
+ line: number;
82
+ /** The menu pizza the line started from; null for a pizza built from scratch. */
83
+ pizzaCode: string | null;
84
+ quantity: number;
85
+ unitCents: number;
86
+ lineCents: number;
87
+ };
88
+ export type PizzaOrder = {
89
+ orderNo: string;
90
+ branchCode: string;
91
+ customerName: string;
92
+ customerEmail: string;
93
+ fulfilment: PizzaFulfilment;
94
+ /** The delivery address; null for pickup. */
95
+ address: string | null;
96
+ /** "YYYY-MM-DD" */
97
+ slotDate: string;
98
+ /** "HH:MM", one of PIZZA_SLOT_TIMES */
99
+ slotTime: string;
100
+ status: PizzaOrderStatus;
101
+ lines: PizzaOrderLine[];
102
+ subtotalCents: number;
103
+ deliveryFeeCents: number;
104
+ totalCents: number;
105
+ createdAt: string;
106
+ };
107
+ export type PizzaRows = {
108
+ sizes: PizzaSize[];
109
+ toppings: PizzaTopping[];
110
+ pizzas: PizzaMenuItem[];
111
+ branches: PizzaBranch[];
112
+ stockouts: PizzaStockout[];
113
+ orders: PizzaOrder[];
114
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/sites/pizza/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,14 @@
1
+ import type { ScenarioRows } from "../scenario.js";
2
+ /**
3
+ * The nine sites shaped on GoogleChromeLabs/webmcp-tools (README § Sites from
4
+ * webmcp-tools), by app key. Each draws its rows from a stream of its own
5
+ * (`substream(seed, "<app>")`), so the scenario that carries them — webmcp-v1 —
6
+ * moves none of them, and their answer keys are the same whichever scenario
7
+ * derives them.
8
+ */
9
+ export declare const SITE_APPS: readonly ["hotels", "flights", "dining", "pizza", "cinema", "sports", "homes", "clinic", "events"];
10
+ export type SiteApp = (typeof SITE_APPS)[number];
11
+ export type SiteRows = Pick<ScenarioRows, SiteApp>;
12
+ export declare function siteRows(seed: number): SiteRows;
13
+ /** Every site with no rows: what a scenario that does not carry them seeds into them. */
14
+ export declare function noSiteRows(): SiteRows;
@@ -0,0 +1,45 @@
1
+ import { cinemaRows } from "./cinema/generate.js";
2
+ import { clinicRows } from "./clinic/generate.js";
3
+ import { diningRows } from "./dining/generate.js";
4
+ import { eventRows } from "./events/generate.js";
5
+ import { flightRows } from "./flights/generate.js";
6
+ import { homeRows } from "./homes/generate.js";
7
+ import { hotelRows } from "./hotels/generate.js";
8
+ import { pizzaRows } from "./pizza/generate.js";
9
+ import { sportsRows } from "./sports/generate.js";
10
+ /**
11
+ * The nine sites shaped on GoogleChromeLabs/webmcp-tools (README § Sites from
12
+ * webmcp-tools), by app key. Each draws its rows from a stream of its own
13
+ * (`substream(seed, "<app>")`), so the scenario that carries them — webmcp-v1 —
14
+ * moves none of them, and their answer keys are the same whichever scenario
15
+ * derives them.
16
+ */
17
+ export const SITE_APPS = ["hotels", "flights", "dining", "pizza", "cinema", "sports", "homes", "clinic", "events"];
18
+ export function siteRows(seed) {
19
+ return {
20
+ hotels: hotelRows(seed),
21
+ flights: flightRows(seed),
22
+ dining: diningRows(seed),
23
+ pizza: pizzaRows(seed),
24
+ cinema: cinemaRows(seed),
25
+ sports: sportsRows(seed),
26
+ homes: homeRows(seed),
27
+ clinic: clinicRows(seed),
28
+ events: eventRows(seed),
29
+ };
30
+ }
31
+ /** Every site with no rows: what a scenario that does not carry them seeds into them. */
32
+ export function noSiteRows() {
33
+ return {
34
+ hotels: { hotels: [], rooms: [], bookings: [] },
35
+ flights: { airports: [], carriers: [], flights: [], cabins: [], bookings: [] },
36
+ dining: { restaurants: [], seating: [], reservations: [] },
37
+ pizza: { sizes: [], toppings: [], pizzas: [], branches: [], stockouts: [], orders: [] },
38
+ cinema: { cinemas: [], screens: [], films: [], prices: [], showtimes: [], bookings: [] },
39
+ sports: { categories: [], shipping: { feeCents: 0, freeFromCents: 0 }, products: [], variants: [], customers: [], addresses: [], orders: [], lines: [], returns: [] },
40
+ homes: { agents: [], listings: [], agentDays: [], viewings: [] },
41
+ clinic: { clinics: [], doctors: [], plans: [], procedures: [], coverage: [], medications: [], prices: [], patients: [], appointments: [], prescriptions: [], refills: [] },
42
+ events: { offices: [], rooms: [], people: [], events: [], registrations: [] },
43
+ };
44
+ }
45
+ //# sourceMappingURL=rows.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rows.js","sourceRoot":"","sources":["../../src/sites/rows.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAA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n ONLY from `substream(seed, "sports")` so
4
+ * adding the site moved no other row. Some variants are out of stock on
5
+ * purpose: one in about a third of the products, a few at random, and the traps
6
+ * below. Five customers have two orders still processing and one shipped,
7
+ * seven more have a latest order that is shipped or cancelled rather than
8
+ * delivered, and some delivered lines were already returned, in part or in full.
9
+ */
10
+ export declare const SPORTS_SIZES: {
11
+ readonly customers: 18;
12
+ readonly busyCustomers: 5;
13
+ readonly notDeliveredLatest: 7;
14
+ readonly seededReturns: 10;
15
+ readonly stockTraps: 6;
16
+ };
17
+ export declare const SPORTS_COLOURS: readonly ["black", "blue", "red", "grey"];
18
+ export declare function sportsRows(seed: number): SportsRows;