@benchme/scenarios 0.9.1 → 0.11.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 (138) 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/cuj-v1/accounts.d.ts +14 -0
  8. package/dist/cuj-v1/accounts.js +52 -0
  9. package/dist/cuj-v1/accounts.js.map +1 -0
  10. package/dist/cuj-v1/index.d.ts +10 -0
  11. package/dist/cuj-v1/index.js +21 -0
  12. package/dist/cuj-v1/index.js.map +1 -0
  13. package/dist/guide-v1/index.js +2 -0
  14. package/dist/guide-v1/index.js.map +1 -1
  15. package/dist/index.d.ts +16 -2
  16. package/dist/index.js +18 -2
  17. package/dist/index.js.map +1 -1
  18. package/dist/prng.d.ts +7 -0
  19. package/dist/prng.js +12 -0
  20. package/dist/prng.js.map +1 -1
  21. package/dist/scenario.d.ts +78 -0
  22. package/dist/scenario.js.map +1 -1
  23. package/dist/shops-v1/index.js +2 -0
  24. package/dist/shops-v1/index.js.map +1 -1
  25. package/dist/sites/cinema/generate.d.ts +22 -0
  26. package/dist/sites/cinema/generate.js +258 -0
  27. package/dist/sites/cinema/generate.js.map +1 -0
  28. package/dist/sites/cinema/index.d.ts +3 -0
  29. package/dist/sites/cinema/index.js +4 -0
  30. package/dist/sites/cinema/index.js.map +1 -0
  31. package/dist/sites/cinema/rules.d.ts +142 -0
  32. package/dist/sites/cinema/rules.js +191 -0
  33. package/dist/sites/cinema/rules.js.map +1 -0
  34. package/dist/sites/cinema/types.d.ts +93 -0
  35. package/dist/sites/cinema/types.js +2 -0
  36. package/dist/sites/cinema/types.js.map +1 -0
  37. package/dist/sites/clinic/generate.d.ts +28 -0
  38. package/dist/sites/clinic/generate.js +282 -0
  39. package/dist/sites/clinic/generate.js.map +1 -0
  40. package/dist/sites/clinic/index.d.ts +3 -0
  41. package/dist/sites/clinic/index.js +3 -0
  42. package/dist/sites/clinic/index.js.map +1 -0
  43. package/dist/sites/clinic/rules.d.ts +96 -0
  44. package/dist/sites/clinic/rules.js +154 -0
  45. package/dist/sites/clinic/rules.js.map +1 -0
  46. package/dist/sites/clinic/types.d.ts +125 -0
  47. package/dist/sites/clinic/types.js +2 -0
  48. package/dist/sites/clinic/types.js.map +1 -0
  49. package/dist/sites/dining/generate.d.ts +15 -0
  50. package/dist/sites/dining/generate.js +146 -0
  51. package/dist/sites/dining/generate.js.map +1 -0
  52. package/dist/sites/dining/index.d.ts +3 -0
  53. package/dist/sites/dining/index.js +4 -0
  54. package/dist/sites/dining/index.js.map +1 -0
  55. package/dist/sites/dining/rules.d.ts +92 -0
  56. package/dist/sites/dining/rules.js +156 -0
  57. package/dist/sites/dining/rules.js.map +1 -0
  58. package/dist/sites/dining/types.d.ts +69 -0
  59. package/dist/sites/dining/types.js +14 -0
  60. package/dist/sites/dining/types.js.map +1 -0
  61. package/dist/sites/events/generate.d.ts +27 -0
  62. package/dist/sites/events/generate.js +197 -0
  63. package/dist/sites/events/generate.js.map +1 -0
  64. package/dist/sites/events/index.d.ts +3 -0
  65. package/dist/sites/events/index.js +4 -0
  66. package/dist/sites/events/index.js.map +1 -0
  67. package/dist/sites/events/rules.d.ts +99 -0
  68. package/dist/sites/events/rules.js +172 -0
  69. package/dist/sites/events/rules.js.map +1 -0
  70. package/dist/sites/events/types.d.ts +78 -0
  71. package/dist/sites/events/types.js +10 -0
  72. package/dist/sites/events/types.js.map +1 -0
  73. package/dist/sites/flights/generate.d.ts +21 -0
  74. package/dist/sites/flights/generate.js +210 -0
  75. package/dist/sites/flights/generate.js.map +1 -0
  76. package/dist/sites/flights/index.d.ts +3 -0
  77. package/dist/sites/flights/index.js +3 -0
  78. package/dist/sites/flights/index.js.map +1 -0
  79. package/dist/sites/flights/rules.d.ts +79 -0
  80. package/dist/sites/flights/rules.js +125 -0
  81. package/dist/sites/flights/rules.js.map +1 -0
  82. package/dist/sites/flights/types.d.ts +69 -0
  83. package/dist/sites/flights/types.js +2 -0
  84. package/dist/sites/flights/types.js.map +1 -0
  85. package/dist/sites/homes/generate.d.ts +19 -0
  86. package/dist/sites/homes/generate.js +180 -0
  87. package/dist/sites/homes/generate.js.map +1 -0
  88. package/dist/sites/homes/index.d.ts +3 -0
  89. package/dist/sites/homes/index.js +3 -0
  90. package/dist/sites/homes/index.js.map +1 -0
  91. package/dist/sites/homes/rules.d.ts +68 -0
  92. package/dist/sites/homes/rules.js +94 -0
  93. package/dist/sites/homes/rules.js.map +1 -0
  94. package/dist/sites/homes/types.d.ts +62 -0
  95. package/dist/sites/homes/types.js +2 -0
  96. package/dist/sites/homes/types.js.map +1 -0
  97. package/dist/sites/hotels/generate.d.ts +16 -0
  98. package/dist/sites/hotels/generate.js +134 -0
  99. package/dist/sites/hotels/generate.js.map +1 -0
  100. package/dist/sites/pizza/catalog.d.ts +34 -0
  101. package/dist/sites/pizza/catalog.js +65 -0
  102. package/dist/sites/pizza/catalog.js.map +1 -0
  103. package/dist/sites/pizza/generate.d.ts +19 -0
  104. package/dist/sites/pizza/generate.js +203 -0
  105. package/dist/sites/pizza/generate.js.map +1 -0
  106. package/dist/sites/pizza/index.d.ts +4 -0
  107. package/dist/sites/pizza/index.js +4 -0
  108. package/dist/sites/pizza/index.js.map +1 -0
  109. package/dist/sites/pizza/rules.d.ts +134 -0
  110. package/dist/sites/pizza/rules.js +217 -0
  111. package/dist/sites/pizza/rules.js.map +1 -0
  112. package/dist/sites/pizza/types.d.ts +114 -0
  113. package/dist/sites/pizza/types.js +2 -0
  114. package/dist/sites/pizza/types.js.map +1 -0
  115. package/dist/sites/rows.d.ts +14 -0
  116. package/dist/sites/rows.js +45 -0
  117. package/dist/sites/rows.js.map +1 -0
  118. package/dist/sites/sports/generate.d.ts +18 -0
  119. package/dist/sites/sports/generate.js +247 -0
  120. package/dist/sites/sports/generate.js.map +1 -0
  121. package/dist/sites/sports/index.d.ts +3 -0
  122. package/dist/sites/sports/index.js +3 -0
  123. package/dist/sites/sports/index.js.map +1 -0
  124. package/dist/sites/sports/rules.d.ts +110 -0
  125. package/dist/sites/sports/rules.js +139 -0
  126. package/dist/sites/sports/rules.js.map +1 -0
  127. package/dist/sites/sports/types.d.ts +91 -0
  128. package/dist/sites/sports/types.js +8 -0
  129. package/dist/sites/sports/types.js.map +1 -0
  130. package/dist/stays.d.ts +63 -0
  131. package/dist/stays.js +96 -0
  132. package/dist/stays.js.map +1 -0
  133. package/dist/web-v1/index.js +2 -0
  134. package/dist/web-v1/index.js.map +1 -1
  135. package/dist/webmcp-v1/index.d.ts +11 -0
  136. package/dist/webmcp-v1/index.js +26 -0
  137. package/dist/webmcp-v1/index.js.map +1 -0
  138. package/package.json +1 -1
@@ -0,0 +1,156 @@
1
+ import { isDate } from "../../stays.js";
2
+ import { DINING_AREAS, DINING_WEEKDAYS } from "./types.js";
3
+ /**
4
+ * The reservation site's rules, as pure functions over rows. apps/dining
5
+ * enforces them on every write and answers every search with them, and the
6
+ * intent corpus derives its answer keys from them, so the site and the keys
7
+ * cannot disagree about what is free or what a deposit is.
8
+ */
9
+ /** The dates the site takes reservations for. Fixed, not "from today", so a seed means the same evenings forever. */
10
+ export const DINING_WINDOW = { first: "2027-01-01", last: "2027-12-31" };
11
+ /** How long a reservation holds its table. */
12
+ export const DINING_HOLD_MINUTES = 120;
13
+ /** Seating times are on the hour and the half hour. */
14
+ export const DINING_SLOT_MINUTES = 30;
15
+ /** Larger parties are not booked online. */
16
+ export const DINING_MAX_PARTY = 12;
17
+ const TIME = /^([01]\d|2[0-3]):([0-5]\d)$/;
18
+ const AREA_LABEL = { indoor: "indoor", terrace: "terrace", bar: "bar", private: "private room" };
19
+ /** "HH:MM" with a real hour and minute (any minute; seating times are checked separately). */
20
+ export function diningIsTime(s) {
21
+ return TIME.test(s);
22
+ }
23
+ export function diningMinutes(time) {
24
+ const [h, m] = time.split(":").map(Number);
25
+ return (h ?? 0) * 60 + (m ?? 0);
26
+ }
27
+ export function diningClock(minutes) {
28
+ return `${String(Math.floor(minutes / 60)).padStart(2, "0")}:${String(minutes % 60).padStart(2, "0")}`;
29
+ }
30
+ export function diningAreaLabel(area) {
31
+ return AREA_LABEL[area];
32
+ }
33
+ export function diningWeekdayOf(date) {
34
+ const sundayFirst = new Date(`${date}T00:00:00Z`).getUTCDay();
35
+ return DINING_WEEKDAYS[(sundayFirst + 6) % 7];
36
+ }
37
+ /** The latest seating of a day: the table is held two hours, and the meal ends by closing time. */
38
+ export function diningLastSeating(h) {
39
+ return diningClock(diningMinutes(h.closes) - DINING_HOLD_MINUTES);
40
+ }
41
+ /** Every seating time on a date: each half hour from opening to the last seating. None on the closed day. */
42
+ export function diningSeatingTimes(r, date) {
43
+ if (!isDate(date))
44
+ return [];
45
+ const h = r.hours[diningWeekdayOf(date)];
46
+ if (!h)
47
+ return [];
48
+ const out = [];
49
+ for (let m = diningMinutes(h.opens); m <= diningMinutes(h.closes) - DINING_HOLD_MINUTES; m += DINING_SLOT_MINUTES)
50
+ out.push(diningClock(m));
51
+ return out;
52
+ }
53
+ /**
54
+ * Tables of the area still free for the WHOLE two hours from `time` on `date`:
55
+ * the area's tables less the most reservations holding one at any half hour of
56
+ * that span. Cancelled reservations hold nothing; `exceptNo` leaves one
57
+ * reservation out (a change is checked against the others).
58
+ */
59
+ export function diningTablesLeft(seating, reservations, date, time, exceptNo) {
60
+ const held = reservations.filter((r) => r.restaurantCode === seating.restaurantCode && r.area === seating.area && r.date === date && r.status === "confirmed" && r.reservationNo !== exceptNo);
61
+ const start = diningMinutes(time);
62
+ let least = seating.tables;
63
+ for (let at = start; at < start + DINING_HOLD_MINUTES; at += DINING_SLOT_MINUTES) {
64
+ const taken = held.filter((r) => diningMinutes(r.time) <= at && at < diningMinutes(r.time) + DINING_HOLD_MINUTES).length;
65
+ least = Math.min(least, seating.tables - taken);
66
+ }
67
+ return Math.max(0, least);
68
+ }
69
+ /** Deposit taken when the reservation is made: per guest, plus the private-room fee for the private room. */
70
+ export function diningDepositCents(r, area, partySize) {
71
+ return partySize * r.depositPerGuestCents + (area === "private" ? (r.privateRoomFeeCents ?? 0) : 0);
72
+ }
73
+ const day = (d) => `${d[0].toUpperCase()}${d.slice(1)}s`;
74
+ /** Why the restaurant cannot seat the request at all, before availability: date, time, party, opening hours, area, table size. */
75
+ export function diningFitProblem(r, seating, q) {
76
+ if (!isDate(q.date))
77
+ return { code: "BAD_DATE", message: `${q.date} is not a date (YYYY-MM-DD)` };
78
+ if (q.date < DINING_WINDOW.first || q.date > DINING_WINDOW.last)
79
+ return { code: "OUTSIDE_WINDOW", message: `reservations are taken for dates from ${DINING_WINDOW.first} to ${DINING_WINDOW.last}` };
80
+ if (!diningIsTime(q.time) || diningMinutes(q.time) % DINING_SLOT_MINUTES !== 0)
81
+ return { code: "BAD_TIME", message: `seating times are on the hour or the half hour (HH:00 or HH:30), not ${q.time}` };
82
+ if (!Number.isInteger(q.partySize) || q.partySize < 1)
83
+ return { code: "BAD_PARTY", message: "a reservation is for at least one guest" };
84
+ if (q.partySize > DINING_MAX_PARTY)
85
+ return { code: "PARTY_LIMIT", message: `parties of more than ${DINING_MAX_PARTY} are not booked online` };
86
+ const weekday = diningWeekdayOf(q.date);
87
+ const h = r.hours[weekday];
88
+ if (!h)
89
+ return { code: "CLOSED", message: `${r.name} is closed on ${day(weekday)}` };
90
+ if (diningMinutes(q.time) < diningMinutes(h.opens) || diningMinutes(q.time) > diningMinutes(h.closes) - DINING_HOLD_MINUTES) {
91
+ return { code: "OUTSIDE_HOURS", message: `${r.name} seats guests from ${h.opens} to ${diningLastSeating(h)} on ${day(weekday)}: it closes at ${h.closes} and a table is held for 2 hours` };
92
+ }
93
+ if (!seating)
94
+ return { code: "NO_AREA", message: `${r.name} has no ${AREA_LABEL[q.area]} seating` };
95
+ if (q.partySize > seating.seats)
96
+ return { code: "TABLE_TOO_SMALL", message: `the ${AREA_LABEL[q.area]} tables at ${r.name} seat at most ${seating.seats}` };
97
+ return null;
98
+ }
99
+ /** diningFitProblem, then whether a table of the area is free for the two hours. The rule every reservation write is held to. */
100
+ export function diningReservationProblem(r, seating, q, reservations, exceptNo) {
101
+ const fit = diningFitProblem(r, seating, q);
102
+ if (fit)
103
+ return fit;
104
+ if (diningTablesLeft(seating, reservations, q.date, q.time, exceptNo) < 1) {
105
+ return { code: "FULL", message: `no ${AREA_LABEL[q.area]} table is free at ${r.name} on ${q.date} for 2 hours from ${q.time}` };
106
+ }
107
+ return null;
108
+ }
109
+ const areaOrder = (a) => DINING_AREAS.indexOf(a);
110
+ const seatingOf = (rows, code) => rows.seating.filter((s) => s.restaurantCode === code).sort((x, y) => areaOrder(x.area) - areaOrder(y.area));
111
+ /**
112
+ * Every area of every restaurant in the city — of the cuisine, offering every
113
+ * asked menu, at no more than the price level — with a table that seats the
114
+ * party and is free for the two hours from the asked time. Restaurant code
115
+ * order, then area order.
116
+ */
117
+ export function diningSearch(rows, q) {
118
+ const city = q.city.trim().toLowerCase();
119
+ const cuisine = q.cuisine?.trim().toLowerCase();
120
+ const menus = (q.menus ?? []).map((m) => m.trim().toLowerCase()).filter(Boolean);
121
+ const offers = [];
122
+ for (const r of [...rows.restaurants].sort((x, y) => x.code.localeCompare(y.code))) {
123
+ if (r.city.toLowerCase() !== city || (cuisine && r.cuisine !== cuisine))
124
+ continue;
125
+ if (!menus.every((m) => r.menus.includes(m)) || (q.maxPriceLevel !== undefined && r.priceLevel > q.maxPriceLevel))
126
+ continue;
127
+ for (const s of seatingOf(rows, r.code)) {
128
+ if (q.area && s.area !== q.area)
129
+ continue;
130
+ if (diningFitProblem(r, s, { date: q.date, time: q.time, partySize: q.partySize, area: s.area }))
131
+ continue;
132
+ const left = diningTablesLeft(s, rows.reservations, q.date, q.time);
133
+ if (left < 1)
134
+ continue;
135
+ offers.push({ restaurantCode: r.code, restaurantName: r.name, cuisine: r.cuisine, priceLevel: r.priceLevel, area: s.area, seats: s.seats, tablesLeft: left, depositCents: diningDepositCents(r, s.area, q.partySize) });
136
+ }
137
+ }
138
+ return offers;
139
+ }
140
+ /**
141
+ * One restaurant's day for a party: for each area whose tables seat it, every
142
+ * seating time and how many of its tables are free for the two hours from it
143
+ * (0 when full). Empty on the closed day or a date the site does not take.
144
+ */
145
+ export function diningAvailability(r, rows, date, partySize) {
146
+ const slots = [];
147
+ for (const s of seatingOf(rows, r.code)) {
148
+ for (const time of diningSeatingTimes(r, date)) {
149
+ if (diningFitProblem(r, s, { date, time, partySize, area: s.area }))
150
+ continue;
151
+ slots.push({ area: s.area, time, tablesLeft: diningTablesLeft(s, rows.reservations, date, time) });
152
+ }
153
+ }
154
+ return slots;
155
+ }
156
+ //# sourceMappingURL=rules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rules.js","sourceRoot":"","sources":["../../../src/sites/dining/rules.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,eAAe,EAAgJ,MAAM,YAAY,CAAC;AAEzM;;;;;GAKG;AAEH,qHAAqH;AACrH,MAAM,CAAC,MAAM,aAAa,GAAG,EAAE,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,YAAY,EAAW,CAAC;AAClF,8CAA8C;AAC9C,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,CAAC;AACvC,uDAAuD;AACvD,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,CAAC;AACtC,4CAA4C;AAC5C,MAAM,CAAC,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAoBnC,MAAM,IAAI,GAAG,6BAA6B,CAAC;AAC3C,MAAM,UAAU,GAA+B,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,CAAC;AAE7H,8FAA8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,CAAC;YAC/C,IAAI,gBAAgB,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;gBAAE,SAAS;YAC9E,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,gBAAgB,CAAC,CAAC,EAAE,IAAI,CAAC,YAAY,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;QACrG,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,69 @@
1
+ /**
2
+ * The restaurant reservation site (apps/dining). Restaurants in the cities of
3
+ * CITY_LIST, their seating (tables per area), and reservations already made.
4
+ * A reservation holds one table of its area for two hours from a half-hour
5
+ * seating time. Rules: ./rules.ts.
6
+ */
7
+ /** Seating areas, in the order the site lists them. */
8
+ export declare const DINING_AREAS: readonly ["indoor", "terrace", "bar", "private"];
9
+ export type DiningArea = (typeof DINING_AREAS)[number];
10
+ /** Dietary menus a restaurant may offer besides its regular one. */
11
+ export declare const DINING_MENUS: readonly ["vegetarian", "vegan", "gluten-free"];
12
+ export type DiningMenu = (typeof DINING_MENUS)[number];
13
+ export declare const DINING_CUISINES: readonly ["french", "italian", "japanese", "indian", "mexican", "greek", "thai", "lebanese"];
14
+ /** Monday first, as the site lists opening hours. */
15
+ export declare const DINING_WEEKDAYS: readonly ["monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"];
16
+ export type DiningWeekday = (typeof DINING_WEEKDAYS)[number];
17
+ /** One day's opening hours, "HH:MM" on the half hour. */
18
+ export type DiningDayHours = {
19
+ opens: string;
20
+ closes: string;
21
+ };
22
+ export type DiningRestaurant = {
23
+ code: string;
24
+ name: string;
25
+ city: string;
26
+ cuisine: string;
27
+ /** 1 (inexpensive) to 4 (expensive); the pages print it as $ to $$$$. */
28
+ priceLevel: number;
29
+ description: string;
30
+ menus: string[];
31
+ /** The one weekday it is closed; `hours[closedDay]` is null. */
32
+ closedDay: DiningWeekday;
33
+ hours: Record<DiningWeekday, DiningDayHours | null>;
34
+ /** Charged per guest when the reservation is made; 0 where no deposit is asked. */
35
+ depositPerGuestCents: number;
36
+ /** A flat fee added to the deposit of a private-room reservation; null where there is no private room. */
37
+ privateRoomFeeCents: number | null;
38
+ };
39
+ /** A restaurant's tables in one area: `tables` tables, each seating up to `seats`. */
40
+ export type DiningSeating = {
41
+ restaurantCode: string;
42
+ area: DiningArea;
43
+ seats: number;
44
+ tables: number;
45
+ };
46
+ export type DiningReservationStatus = "confirmed" | "cancelled";
47
+ export type DiningReservation = {
48
+ reservationNo: string;
49
+ restaurantCode: string;
50
+ area: DiningArea;
51
+ /** "YYYY-MM-DD". */
52
+ date: string;
53
+ /** The seating time, "HH:MM" on the half hour; the table is held for two hours from it. */
54
+ time: string;
55
+ partySize: number;
56
+ guestName: string;
57
+ guestEmail: string;
58
+ guestPhone: string;
59
+ /** The special request, "" when there is none. */
60
+ note: string;
61
+ status: DiningReservationStatus;
62
+ depositCents: number;
63
+ createdAt: string;
64
+ };
65
+ export type DiningRows = {
66
+ restaurants: DiningRestaurant[];
67
+ seating: DiningSeating[];
68
+ reservations: DiningReservation[];
69
+ };
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The restaurant reservation site (apps/dining). Restaurants in the cities of
3
+ * CITY_LIST, their seating (tables per area), and reservations already made.
4
+ * A reservation holds one table of its area for two hours from a half-hour
5
+ * seating time. Rules: ./rules.ts.
6
+ */
7
+ /** Seating areas, in the order the site lists them. */
8
+ export const DINING_AREAS = ["indoor", "terrace", "bar", "private"];
9
+ /** Dietary menus a restaurant may offer besides its regular one. */
10
+ export const DINING_MENUS = ["vegetarian", "vegan", "gluten-free"];
11
+ export const DINING_CUISINES = ["french", "italian", "japanese", "indian", "mexican", "greek", "thai", "lebanese"];
12
+ /** Monday first, as the site lists opening hours. */
13
+ export const DINING_WEEKDAYS = ["monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"];
14
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/sites/dining/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,uDAAuD;AACvD,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,CAAU,CAAC;AAG7E,oEAAoE;AACpE,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,YAAY,EAAE,OAAO,EAAE,aAAa,CAAU,CAAC;AAG5E,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,CAAU,CAAC;AAE5H,qDAAqD;AACrD,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,CAAU,CAAC"}
@@ -0,0 +1,27 @@
1
+ import { type EventRows } from "./types.js";
2
+ /**
3
+ * The office events site's rows: an office in each of the six cities with 4–6
4
+ * meeting rooms, a staff directory, events between March and June 2027, and
5
+ * registrations for the open ones. Drawn from a stream of its own
6
+ * (`substream(seed, "events")`), so adding the site moved no other site's row.
7
+ *
8
+ * Some state is there on purpose: a few rooms are booked from opening to
9
+ * closing on one day, the earliest session of every training course at every
10
+ * office is full, some other open events are full, some events and
11
+ * registrations are cancelled, and most people hold several registrations.
12
+ */
13
+ export declare const EVENT_SIZES: {
14
+ readonly roomsPerOffice: readonly [4, 6];
15
+ readonly people: 36;
16
+ readonly visitors: 14;
17
+ readonly events: 70;
18
+ readonly courses: 4;
19
+ readonly sessionsPerOffice: 3;
20
+ readonly solidDays: 8;
21
+ };
22
+ /** Seeded events fall in this span, so the rest of 2027 is free in every room. */
23
+ export declare const EVENT_BUSY: {
24
+ readonly from: "2027-03-01";
25
+ readonly days: 122;
26
+ };
27
+ export declare function eventRows(seed: number): EventRows;
@@ -0,0 +1,197 @@
1
+ import { CITY_LIST, FIRST_NAMES, LAST_NAMES, word } from "../../acme-v1/names.js";
2
+ import { int, pick, shuffle, substream } from "../../prng.js";
3
+ import { addDays } from "../../stays.js";
4
+ import { eventDraftProblem, eventGuestList, eventMinutes, eventRegisterProblem, eventTimeOf, eventTimeProblem } from "./rules.js";
5
+ import { EVENT_EQUIPMENT } from "./types.js";
6
+ /**
7
+ * The office events site's rows: an office in each of the six cities with 4–6
8
+ * meeting rooms, a staff directory, events between March and June 2027, and
9
+ * registrations for the open ones. Drawn from a stream of its own
10
+ * (`substream(seed, "events")`), so adding the site moved no other site's row.
11
+ *
12
+ * Some state is there on purpose: a few rooms are booked from opening to
13
+ * closing on one day, the earliest session of every training course at every
14
+ * office is full, some other open events are full, some events and
15
+ * registrations are cancelled, and most people hold several registrations.
16
+ */
17
+ export const EVENT_SIZES = { roomsPerOffice: [4, 6], people: 36, visitors: 14, events: 70, courses: 4, sessionsPerOffice: 3, solidDays: 8 };
18
+ /** Seeded events fall in this span, so the rest of 2027 is free in every room. */
19
+ export const EVENT_BUSY = { from: "2027-03-01", days: 122 };
20
+ const CAPACITIES = [4, 6, 8, 10, 12, 16, 20, 30];
21
+ const EQUIPMENT_ODDS = { projector: 0.55, "video conferencing": 0.5, whiteboard: 0.65 };
22
+ const TEAMS = ["Finance", "Sales", "Engineering", "Operations", "Legal", "People", "Design", "Support"];
23
+ const TOPICS = ["Budget", "Roadmap", "Hiring", "Vendor", "Release", "Pricing", "Inventory", "Logistics", "Quality", "Customer"];
24
+ const KINDS = ["review", "planning", "sync", "workshop", "briefing", "retrospective", "check-in", "demo"];
25
+ const PURPOSES = ["Agree the next steps and who owns them.", "Go through the figures for the quarter.", "Collect questions before the deadline.", "Share progress and blockers.", "Decide on the open proposals.", "Walk through the changes and their dates."];
26
+ const COURSES = ["First-aid course", "Fire warden training", "Data privacy basics", "Expense tool walkthrough", "Presentation skills", "Negotiation basics"];
27
+ const WEEKDAYS_ONLY = ["mon", "tue", "wed", "thu", "fri"];
28
+ const stamp = (rng) => new Date(Date.UTC(2027, 0, 2 + int(rng, 0, 50), int(rng, 7, 21), int(rng, 0, 59))).toISOString();
29
+ function makeOffices(rng) {
30
+ return CITY_LIST.map((city) => ({
31
+ code: `OF-${city.slice(0, 3).toUpperCase()}`,
32
+ name: `${city} office`,
33
+ city,
34
+ address: `${int(rng, 2, 180)} ${word(rng)} Street, ${city}`,
35
+ opensAt: pick(rng, ["07:30", "08:00", "08:30", "09:00"]),
36
+ closesAt: pick(rng, ["17:30", "18:00", "18:30", "19:00", "20:00"]),
37
+ openDays: rng() < 0.3 ? [...WEEKDAYS_ONLY, "sat"] : [...WEEKDAYS_ONLY],
38
+ }));
39
+ }
40
+ /** Capacities differ within an office, so "the larger of two rooms" is never a tie. */
41
+ function makeRooms(rng, offices) {
42
+ const names = new Set();
43
+ return offices.flatMap((o) => {
44
+ const caps = shuffle(rng, CAPACITIES).slice(0, int(rng, EVENT_SIZES.roomsPerOffice[0], EVENT_SIZES.roomsPerOffice[1])).sort((a, b) => a - b);
45
+ return caps.map((capacity, i) => {
46
+ let name = "";
47
+ do
48
+ name = `${word(rng, 2)} room`;
49
+ while (names.has(name));
50
+ names.add(name);
51
+ return {
52
+ code: `${o.code.slice(3)}-R${i + 1}`,
53
+ officeCode: o.code,
54
+ name,
55
+ floor: int(rng, 0, 4),
56
+ capacity,
57
+ equipment: EVENT_EQUIPMENT.filter((e) => rng() < EQUIPMENT_ODDS[e]),
58
+ accessible: rng() < 0.6,
59
+ };
60
+ });
61
+ });
62
+ }
63
+ function makePeople(rng, offices) {
64
+ const names = shuffle(rng, FIRST_NAMES.flatMap((f) => LAST_NAMES.map((l) => [f, l])));
65
+ const people = names.slice(0, EVENT_SIZES.people).map(([f, l], i) => ({
66
+ email: `${f}.${l}@staff.example`.toLowerCase(),
67
+ name: `${f} ${l}`,
68
+ officeCode: offices[i % offices.length].code,
69
+ team: pick(rng, TEAMS),
70
+ }));
71
+ const visitors = names.slice(EVENT_SIZES.people, EVENT_SIZES.people + EVENT_SIZES.visitors).map(([f, l]) => ({ name: `${f} ${l}`, email: `${f}.${l}@visitor.example`.toLowerCase() }));
72
+ return { people, visitors };
73
+ }
74
+ export function eventRows(seed) {
75
+ const rng = substream(seed, "events");
76
+ const offices = makeOffices(rng);
77
+ const rooms = makeRooms(rng, offices);
78
+ const { people, visitors } = makePeople(rng, offices);
79
+ const rows = { offices, rooms, people, events: [], registrations: [] };
80
+ const officeOf = new Map(offices.map((o) => [o.code, o]));
81
+ const staffOf = (officeCode) => people.filter((p) => p.officeCode === officeCode);
82
+ const day = () => addDays(EVENT_BUSY.from, int(rng, 0, EVENT_BUSY.days - 1));
83
+ /** Adds the event when the rules take it; returns it, or null when they refuse (a taken room, a closed day). */
84
+ const add = (room, d, status = "scheduled") => {
85
+ const draft = { ...d, roomCode: room.code };
86
+ if (eventDraftProblem(rows, draft))
87
+ return null;
88
+ const event = {
89
+ code: `EV-${1001 + rows.events.length}`,
90
+ title: draft.title,
91
+ description: draft.description,
92
+ date: draft.date,
93
+ startTime: draft.startTime,
94
+ endTime: draft.endTime,
95
+ officeCode: room.officeCode,
96
+ roomCode: room.code,
97
+ organiserEmail: draft.organiserEmail,
98
+ guestEmails: eventGuestList(draft.guestEmails, draft.organiserEmail),
99
+ registration: draft.registration,
100
+ places: draft.places,
101
+ status,
102
+ createdAt: stamp(rng),
103
+ };
104
+ rows.events.push(event);
105
+ return event;
106
+ };
107
+ const guestsFor = (room, organiser, most) => {
108
+ const guests = shuffle(rng, people.filter((p) => p.email !== organiser.email)).slice(0, int(rng, 0, Math.min(most, room.capacity - 1))).map((p) => p.email);
109
+ if (guests.length < room.capacity - 1 && rng() < 0.15)
110
+ guests.push(`${word(rng, 2).toLowerCase()}@partner.example`);
111
+ return guests;
112
+ };
113
+ const slotIn = (office, minutes) => {
114
+ const open = eventMinutes(office.opensAt);
115
+ const start = open + 30 * int(rng, 0, Math.floor((eventMinutes(office.closesAt) - open - minutes) / 30));
116
+ return { startTime: eventTimeOf(start), endTime: eventTimeOf(start + minutes) };
117
+ };
118
+ // Meetings: a room, a day, a slot in the office's hours; some open to registration, a few cancelled.
119
+ for (let i = 0; i < EVENT_SIZES.events; i++) {
120
+ const room = pick(rng, rooms);
121
+ const office = officeOf.get(room.officeCode);
122
+ const organiser = rng() < 0.8 ? pick(rng, staffOf(office.code)) : pick(rng, people);
123
+ const guestEmails = guestsFor(room, organiser, 6);
124
+ const free = room.capacity - 1 - guestEmails.length;
125
+ const open = free >= 2 && rng() < 0.35;
126
+ const title = `${pick(rng, TOPICS)} ${pick(rng, KINDS)}`;
127
+ add(room, { title, description: pick(rng, PURPOSES), date: day(), ...slotIn(office, pick(rng, [30, 45, 60, 90, 120])), organiserEmail: organiser.email, guestEmails, registration: open ? "open" : "invite-only", places: open ? int(rng, 2, Math.min(free, 8)) : null }, rng() < 0.08 ? "cancelled" : "scheduled");
128
+ }
129
+ // Courses: one title, three open sessions at each of two or three offices. The earliest at each office fills up below.
130
+ const earliest = new Set();
131
+ for (const title of shuffle(rng, COURSES).slice(0, EVENT_SIZES.courses)) {
132
+ const trainer = pick(rng, people);
133
+ for (const office of shuffle(rng, offices).slice(0, int(rng, 2, 3))) {
134
+ const sessions = [];
135
+ for (let tries = 0; sessions.length < EVENT_SIZES.sessionsPerOffice && tries < 40; tries++) {
136
+ const places = int(rng, 3, 6);
137
+ const fits = rooms.filter((r) => r.officeCode === office.code && r.capacity >= places + 1);
138
+ if (fits.length === 0)
139
+ break;
140
+ const room = pick(rng, fits);
141
+ const made = add(room, { title, description: `${title}: one of several sessions, register for one.`, date: day(), ...slotIn(office, pick(rng, [60, 90, 120])), organiserEmail: trainer.email, guestEmails: [], registration: "open", places });
142
+ if (made)
143
+ sessions.push(made);
144
+ }
145
+ const first = [...sessions].sort((a, b) => a.date.localeCompare(b.date) || a.startTime.localeCompare(b.startTime))[0];
146
+ if (first)
147
+ earliest.add(first.code);
148
+ }
149
+ }
150
+ // Booked solid on purpose: a room taken by back-to-back meetings from opening to closing on one day.
151
+ for (let i = 0; i < EVENT_SIZES.solidDays; i++) {
152
+ const room = pick(rng, rooms);
153
+ const office = officeOf.get(room.officeCode);
154
+ let date = day();
155
+ while (eventTimeProblem(office, { date, startTime: office.opensAt, endTime: eventTimeOf(eventMinutes(office.opensAt) + 60) }))
156
+ date = addDays(date, 1);
157
+ const close = eventMinutes(office.closesAt);
158
+ for (let t = eventMinutes(office.opensAt); t < close;) {
159
+ const held = rows.events.filter((e) => e.roomCode === room.code && e.date === date && e.status === "scheduled");
160
+ const over = held.find((e) => eventMinutes(e.startTime) <= t && t < eventMinutes(e.endTime));
161
+ if (over) {
162
+ t = eventMinutes(over.endTime);
163
+ continue;
164
+ }
165
+ const next = Math.min(close, ...held.map((e) => eventMinutes(e.startTime)).filter((s) => s > t));
166
+ const length = Math.min(pick(rng, [60, 90, 120]), next - t);
167
+ const organiser = pick(rng, staffOf(office.code));
168
+ const made = add(room, { title: `${pick(rng, TOPICS)} ${pick(rng, KINDS)}`, description: pick(rng, PURPOSES), date, startTime: eventTimeOf(t), endTime: eventTimeOf(t + length), organiserEmail: organiser.email, guestEmails: guestsFor(room, organiser, 4), registration: "invite-only", places: null });
169
+ if (!made)
170
+ break;
171
+ t += length;
172
+ }
173
+ }
174
+ // Registrations, held to the same rule as the site's: places left, no second registration, no overlap.
175
+ const registrants = [...people.map((p) => ({ name: p.name, email: p.email })), ...visitors];
176
+ const register = (event, who, status) => rows.registrations.push({ regNo: `RG-${3001 + rows.registrations.length}`, eventCode: event.code, name: who.name, email: who.email, status, createdAt: stamp(rng) });
177
+ for (const event of rows.events.filter((e) => e.status === "scheduled" && e.registration === "open")) {
178
+ const places = event.places;
179
+ const target = earliest.has(event.code) || rng() < 0.2 ? places : int(rng, 0, places - 1);
180
+ let taken = 0;
181
+ for (const who of shuffle(rng, registrants)) {
182
+ if (taken >= target)
183
+ break;
184
+ if (eventRegisterProblem(rows, event, who))
185
+ continue;
186
+ // A cancelled registration now and then: it holds no place.
187
+ if (rng() < 0.1)
188
+ register(event, who, "cancelled");
189
+ else {
190
+ register(event, who, "registered");
191
+ taken++;
192
+ }
193
+ }
194
+ }
195
+ return rows;
196
+ }
197
+ //# sourceMappingURL=generate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.js","sourceRoot":"","sources":["../../../src/sites/events/generate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAClF,OAAO,EAAY,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACxE,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,YAAY,EAAE,oBAAoB,EAAE,WAAW,EAAE,gBAAgB,EAAyC,MAAM,YAAY,CAAC;AACzK,OAAO,EAAE,eAAe,EAAgH,MAAM,YAAY,CAAC;AAE3J;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,EAAE,cAAc,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,iBAAiB,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAW,CAAC;AAErJ,kFAAkF;AAClF,MAAM,CAAC,MAAM,UAAU,GAAG,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,GAAG,EAAW,CAAC;AACrE,MAAM,UAAU,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,E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AAE,MAAM,EAAE,SAAS,EAAE,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACvK,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,WAAW,IAAI,CAAC,CAAC,YAAY,KAAK,MAAM,CAAC,EAAE,CAAC;QACrG,MAAM,MAAM,GAAG,KAAK,CAAC,MAAgB,CAAC;QACtC,MAAM,MAAM,GAAG,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,CAAC;QAC1F,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,KAAK,MAAM,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,WAAW,CAAC,EAAE,CAAC;YAC5C,IAAI,KAAK,IAAI,MAAM;gBAAE,MAAM;YAC3B,IAAI,oBAAoB,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC;gBAAE,SAAS;YACrD,4DAA4D;YAC5D,IAAI,GAAG,EAAE,GAAG,GAAG;gBAAE,QAAQ,CAAC,KAAK,EAAE,GAAG,EAAE,WAAW,CAAC,CAAC;iBAC9C,CAAC;gBACJ,QAAQ,CAAC,KAAK,EAAE,GAAG,EAAE,YAAY,CAAC,CAAC;gBACnC,KAAK,EAAE,CAAC;YACV,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { EVENT_BUSY, EVENT_SIZES, eventRows } from "./generate.js";
2
+ export { EVENT_MAX_MINUTES, EVENT_STEP_MINUTES, EVENT_WINDOW, eventCancelProblem, eventChangeProblem, eventDraftProblem, eventFreeRooms, eventGuestList, eventHeadcount, eventMinutes, eventOfficeOf, eventPlacesLeft, eventRegisterProblem, eventRegisteredCount, eventRoomClash, eventTimeOf, eventTimeProblem, eventWeekday, eventsOverlap, isEventEmail, isEventTime, type EventDraft, type EventFreeRoom, type EventProblem, type EventRegistrant, type EventRoomQuery, } from "./rules.js";
3
+ export { EVENT_EQUIPMENT, EVENT_WEEKDAYS, type EventEquipment, type EventOffice, type EventPerson, type EventRegistration, type EventRegistrationMode, type EventRegistrationStatus, type EventRoom, type EventRows, type EventStatus, type EventWeekday, type OfficeEvent, } from "./types.js";
@@ -0,0 +1,4 @@
1
+ export { EVENT_BUSY, EVENT_SIZES, eventRows } from "./generate.js";
2
+ export { EVENT_MAX_MINUTES, EVENT_STEP_MINUTES, EVENT_WINDOW, eventCancelProblem, eventChangeProblem, eventDraftProblem, eventFreeRooms, eventGuestList, eventHeadcount, eventMinutes, eventOfficeOf, eventPlacesLeft, eventRegisterProblem, eventRegisteredCount, eventRoomClash, eventTimeOf, eventTimeProblem, eventWeekday, eventsOverlap, isEventEmail, isEventTime, } from "./rules.js";
3
+ export { EVENT_EQUIPMENT, EVENT_WEEKDAYS, } from "./types.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/sites/events/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,YAAY,EACZ,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,cAAc,EACd,cAAc,EACd,cAAc,EACd,YAAY,EACZ,aAAa,EACb,eAAe,EACf,oBAAoB,EACpB,oBAAoB,EACpB,cAAc,EACd,WAAW,EACX,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,WAAW,GAMZ,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,eAAe,EACf,cAAc,GAYf,MAAM,YAAY,CAAC"}
@@ -0,0 +1,99 @@
1
+ import { type EventOffice, type EventRegistrationMode, type EventRows, type EventWeekday, type OfficeEvent } from "./types.js";
2
+ /**
3
+ * The office events site's rules, as pure functions over rows. apps/events
4
+ * enforces them inside every write's transaction and answers every room
5
+ * search with them, and the intent corpus derives its answer keys with them,
6
+ * so the site and the keys cannot disagree about what is free, what fits or
7
+ * who can register.
8
+ */
9
+ /** The dates events can be held on. Fixed, not "from today", so a seed means the same calendar forever. */
10
+ export declare const EVENT_WINDOW: {
11
+ readonly first: "2027-01-01";
12
+ readonly last: "2027-12-31";
13
+ };
14
+ /** Start and end times fall on the quarter hour. */
15
+ export declare const EVENT_STEP_MINUTES = 15;
16
+ export declare const EVENT_MAX_MINUTES: number;
17
+ export type EventProblem = {
18
+ code: string;
19
+ message: string;
20
+ };
21
+ export type EventDraft = {
22
+ title: string;
23
+ description: string;
24
+ date: string;
25
+ startTime: string;
26
+ endTime: string;
27
+ roomCode: string;
28
+ organiserEmail: string;
29
+ guestEmails: readonly string[];
30
+ registration: EventRegistrationMode;
31
+ places: number | null;
32
+ };
33
+ export type EventRoomQuery = {
34
+ officeCode: string;
35
+ date: string;
36
+ startTime: string;
37
+ endTime: string;
38
+ people: number;
39
+ equipment?: readonly string[];
40
+ accessible?: boolean;
41
+ };
42
+ /** A room that is free for the whole time asked and fits the query. */
43
+ export type EventFreeRoom = {
44
+ roomCode: string;
45
+ roomName: string;
46
+ officeCode: string;
47
+ floor: number;
48
+ capacity: number;
49
+ equipment: string[];
50
+ accessible: boolean;
51
+ };
52
+ export type EventRegistrant = {
53
+ name: string;
54
+ email: string;
55
+ };
56
+ type Slot = {
57
+ date: string;
58
+ startTime: string;
59
+ endTime: string;
60
+ };
61
+ /** "HH:MM", 24-hour, on the quarter hour. */
62
+ export declare function isEventTime(s: string): boolean;
63
+ export declare function isEventEmail(s: string): boolean;
64
+ export declare const eventMinutes: (t: string) => number;
65
+ export declare const eventTimeOf: (minutes: number) => string;
66
+ export declare function eventWeekday(date: string): EventWeekday;
67
+ /** Two slots overlap when they share a date and some minute: back to back (one ends as the other starts) is not an overlap. */
68
+ export declare function eventsOverlap(a: Slot, b: Slot): boolean;
69
+ /** A guest list as the site stores it: trimmed, lowercased, each email once, the organiser left out, sorted. */
70
+ export declare function eventGuestList(emails: readonly string[], organiserEmail: string): string[];
71
+ /** An office by its code or its city, case-insensitive. */
72
+ export declare function eventOfficeOf<O extends EventOffice>(offices: readonly O[], key: string): O | undefined;
73
+ /** The scheduled event holding the room for any part of the slot, other than `exceptCode`. Cancelled events hold nothing. */
74
+ export declare function eventRoomClash(rows: Pick<EventRows, "events">, roomCode: string, slot: Slot, exceptCode?: string): OfficeEvent | null;
75
+ export declare function eventRegisteredCount(rows: Pick<EventRows, "registrations">, eventCode: string): number;
76
+ /** Places still open to registration: the place limit less the active registrations; null for an invitation-only event. */
77
+ export declare function eventPlacesLeft(rows: Pick<EventRows, "registrations">, event: OfficeEvent): number | null;
78
+ /** Why an office cannot hold anything at that time: the date, the window, the times, the length, the open days, the hours. */
79
+ export declare function eventTimeProblem(office: EventOffice, slot: Slot): EventProblem | null;
80
+ /** Everyone the room must hold: the organiser, each invited guest, and every place open to registration. */
81
+ export declare function eventHeadcount(draft: Pick<EventDraft, "guestEmails" | "organiserEmail" | "places">): number;
82
+ /**
83
+ * The rule every new or changed event is held to: a title, a room, a time the
84
+ * office is open, a directory organiser, valid guest emails, places only on an
85
+ * open event, a room that holds everyone, and a room free for the whole time.
86
+ */
87
+ export declare function eventDraftProblem(rows: EventRows, draft: EventDraft, exceptCode?: string): EventProblem | null;
88
+ /** Only the organiser changes an event, a cancelled one never, and never down to fewer places than people registered. */
89
+ export declare function eventChangeProblem(rows: EventRows, event: OfficeEvent, actingEmail: string, next: EventDraft): EventProblem | null;
90
+ export declare function eventCancelProblem(event: OfficeEvent, actingEmail: string): EventProblem | null;
91
+ /**
92
+ * Who can register for an event: it is scheduled and open to registration, the
93
+ * person is not registered for it already, a place is left, and they are not
94
+ * registered for another scheduled event at an overlapping time.
95
+ */
96
+ export declare function eventRegisterProblem(rows: EventRows, event: OfficeEvent, who: EventRegistrant): EventProblem | null;
97
+ /** Rooms in the office that hold the people, have every piece of equipment asked, are step-free when asked, and are free the whole time — smallest first. */
98
+ export declare function eventFreeRooms(rows: EventRows, q: EventRoomQuery): EventFreeRoom[];
99
+ export {};