@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,258 @@
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 { CINEMA_ADULT_RATINGS, CINEMA_FORMATS, CINEMA_MAX_SEATS, CINEMA_WINDOW, cinemaFreeRuns, cinemaFreeSeats, cinemaQuote, cinemaTakenSeats } from "./rules.js";
5
+ /**
6
+ * The cinema site's rows: one cinema in each city, 2–3 screens each (half the
7
+ * cinemas have a large-format screen), invented films, three days of
8
+ * showtimes (four a day on every screen; each cinema's headliner plays most),
9
+ * and bookings already made. Drawn from a stream of its own
10
+ * (`substream(seed, "cinema")`), so adding the site moved no other row. Some
11
+ * showtimes are sold out on purpose, and some are nearly full with only
12
+ * single seats left (no two side by side): a search has to read free seats,
13
+ * not just the programme.
14
+ */
15
+ export const CINEMA_SIZES = { films: 16, screensPerCinema: [2, 3], filmsPerCinema: 6, customers: 30, bookings: 50, soldOut: 5, nearlyFull: 12 };
16
+ export const CINEMA_GENRES = ["action", "animation", "comedy", "drama", "horror", "science fiction"];
17
+ const RATINGS = {
18
+ action: ["12", "15"], animation: ["U", "PG"], comedy: ["PG", "12", "15"], drama: ["12", "15"], horror: ["15", "18"], "science fiction": ["PG", "12", "15"],
19
+ };
20
+ /** How often each film of a programme is scheduled, by its place in it: the first is the cinema's headliner. */
21
+ const PROGRAMME_WEIGHTS = [5, 3, 2, 1, 1, 1];
22
+ const LANGUAGES = ["French", "Spanish", "Japanese", "Korean", "German", "Hindi"];
23
+ const NOUNS = ["Crossing", "Harbour", "Signal", "Orchard", "Lantern", "Divide", "Archive", "Tide", "Garden", "Frontier", "Echo", "Compass", "Winter", "Engine", "Summit", "Island"];
24
+ const SETTINGS = ["a mountain town", "a port city", "a research station", "a farm", "an old theatre", "a night train", "a coastal village", "a desert outpost"];
25
+ const CINEMA_SUFFIXES = ["Cinema", "Picturehouse", "Film Theatre", "Screens"];
26
+ const STREETS = ["Street", "Road", "Square", "Avenue"];
27
+ function weighted(rng, items, weights) {
28
+ const total = items.reduce((s, _, i) => s + (weights[i] ?? 1), 0);
29
+ let r = rng() * total;
30
+ for (let i = 0; i < items.length; i++) {
31
+ r -= weights[i] ?? 1;
32
+ if (r < 0)
33
+ return items[i];
34
+ }
35
+ return items[items.length - 1];
36
+ }
37
+ /** A screen's day: these four start times, shifted by 0, 20 or 40 minutes by screen so no two screens of a cinema start together. */
38
+ const SLOTS = ["12:30", "15:30", "18:30", "21:30"];
39
+ const TYPE_FACTOR = { adult: 1, child: 0.6, senior: 0.7, student: 0.8 };
40
+ const to25 = (cents) => Math.round(cents / 25) * 25;
41
+ const shift = (time, minutes) => {
42
+ const [h, m] = time.split(":").map(Number);
43
+ const t = h * 60 + m + minutes;
44
+ return `${String(Math.floor(t / 60)).padStart(2, "0")}:${String(t % 60).padStart(2, "0")}`;
45
+ };
46
+ function makeFilms(rng) {
47
+ const genres = shuffle(rng, CINEMA_GENRES);
48
+ const titles = new Set();
49
+ const films = [];
50
+ for (let i = 0; i < CINEMA_SIZES.films; i++) {
51
+ const genre = genres[i % genres.length];
52
+ let title = "";
53
+ do {
54
+ const w = word(rng);
55
+ const n = pick(rng, NOUNS);
56
+ title = pick(rng, [`The ${w} ${n}`, `${n} of ${w}`, `${w} ${n}`, `Beyond ${w}`, `Return to ${w}`]);
57
+ } while (titles.has(title));
58
+ titles.add(title);
59
+ const bright = genre === "action" || genre === "animation" || genre === "science fiction";
60
+ const formats = ["2d"];
61
+ if (rng() < (bright ? 0.75 : 0.25))
62
+ formats.push("3d");
63
+ if (rng() < (bright || genre === "drama" ? 0.6 : 0.15))
64
+ formats.push("large");
65
+ films.push({
66
+ code: `FM-${101 + i}`,
67
+ title,
68
+ genre,
69
+ rating: pick(rng, RATINGS[genre]),
70
+ runtimeMinutes: int(rng, 85, 150),
71
+ language: rng() < 0.6 ? "English" : pick(rng, LANGUAGES),
72
+ synopsis: `A ${genre} film set in ${pick(rng, SETTINGS)}.`,
73
+ formats,
74
+ });
75
+ }
76
+ // Every seed gets at least three films in each extra format, so a large screen always has a choice.
77
+ for (const format of ["3d", "large"]) {
78
+ for (const f of films)
79
+ if (films.filter((x) => x.formats.includes(format)).length < 3 && !f.formats.includes(format))
80
+ f.formats.push(format);
81
+ }
82
+ for (const f of films)
83
+ f.formats.sort((x, y) => CINEMA_FORMATS.indexOf(x) - CINEMA_FORMATS.indexOf(y));
84
+ return films;
85
+ }
86
+ function makeCinemas(rng) {
87
+ const largeIn = new Set(shuffle(rng, CITY_LIST).slice(0, 3));
88
+ const names = new Set();
89
+ const cinemas = [];
90
+ const screens = [];
91
+ const prices = [];
92
+ CITY_LIST.forEach((city, i) => {
93
+ let name = "";
94
+ do
95
+ name = `${word(rng)} ${pick(rng, CINEMA_SUFFIXES)}`;
96
+ while (names.has(name));
97
+ names.add(name);
98
+ const code = `CN-${101 + i}`;
99
+ cinemas.push({ code, name, city, address: `${int(rng, 2, 240)} ${word(rng)} ${pick(rng, STREETS)}, ${city}`, bookingFeeCents: int(rng, 3, 6) * 25, premiumSurchargeCents: int(rng, 8, 14) * 25 });
100
+ const large = largeIn.has(city);
101
+ const count = int(rng, CINEMA_SIZES.screensPerCinema[0], CINEMA_SIZES.screensPerCinema[1]);
102
+ for (let s = 1; s <= count; s++) {
103
+ if (large && s === 1)
104
+ screens.push({ cinemaCode: code, code: `${code}-S1`, name: "Screen 1", kind: "large", rows: 8, seatsPerRow: int(rng, 10, 12), premiumRows: ["G", "H"] });
105
+ else {
106
+ const rows = int(rng, 6, 8);
107
+ screens.push({ cinemaCode: code, code: `${code}-S${s}`, name: `Screen ${s}`, kind: "standard", rows, seatsPerRow: int(rng, 6, 9), premiumRows: ["ABCDEFGH"[rows - 1]] });
108
+ }
109
+ }
110
+ const adult2d = int(rng, 40, 56) * 25;
111
+ const base = { "2d": adult2d, "3d": adult2d + int(rng, 10, 16) * 25, ...(large ? { large: adult2d + int(rng, 20, 28) * 25 } : {}) };
112
+ for (const [format, adult] of Object.entries(base)) {
113
+ for (const ticketType of Object.keys(TYPE_FACTOR))
114
+ prices.push({ cinemaCode: code, format, ticketType, priceCents: to25(adult * TYPE_FACTOR[ticketType]) });
115
+ }
116
+ });
117
+ return { cinemas, screens, prices };
118
+ }
119
+ function makeShowtimes(rng, cinemas, screens, films) {
120
+ const programme = new Map();
121
+ for (const c of cinemas) {
122
+ const picked = shuffle(rng, films).slice(0, CINEMA_SIZES.filmsPerCinema);
123
+ if (screens.some((s) => s.cinemaCode === c.code && s.kind === "large")) {
124
+ // A large screen needs at least two large-format films to choose from.
125
+ for (const f of shuffle(rng, films.filter((x) => x.formats.includes("large")))) {
126
+ if (picked.filter((x) => x.formats.includes("large")).length >= 2)
127
+ break;
128
+ if (!picked.includes(f))
129
+ picked[picked.findIndex((x) => !x.formats.includes("large"))] = f;
130
+ }
131
+ }
132
+ programme.set(c.code, picked);
133
+ }
134
+ const out = [];
135
+ for (let date = CINEMA_WINDOW.first; date <= CINEMA_WINDOW.last; date = addDays(date, 1)) {
136
+ for (const c of cinemas) {
137
+ const mine = programme.get(c.code);
138
+ screens.filter((s) => s.cinemaCode === c.code).forEach((s, i) => {
139
+ SLOTS.forEach((slot) => {
140
+ const film = s.kind === "large" ? pick(rng, mine.filter((f) => f.formats.includes("large"))) : weighted(rng, mine, PROGRAMME_WEIGHTS);
141
+ const format = s.kind === "large" ? "large" : film.formats.includes("3d") && rng() < 0.5 ? "3d" : "2d";
142
+ out.push({ code: `ST-${2001 + out.length}`, cinemaCode: c.code, screenCode: s.code, filmCode: film.code, date, time: shift(slot, i * 20), format });
143
+ });
144
+ });
145
+ }
146
+ }
147
+ return out;
148
+ }
149
+ function makeCustomers(rng) {
150
+ const out = new Map();
151
+ while (out.size < CINEMA_SIZES.customers) {
152
+ const first = pick(rng, FIRST_NAMES);
153
+ const last = pick(rng, LAST_NAMES);
154
+ const email = `${first}.${last}${int(rng, 1, 9)}@example.com`.toLowerCase();
155
+ if (!out.has(email))
156
+ out.set(email, { name: `${first} ${last}`, email });
157
+ }
158
+ return [...out.values()];
159
+ }
160
+ export function cinemaRows(seed) {
161
+ const rng = substream(seed, "cinema");
162
+ const films = makeFilms(rng);
163
+ const { cinemas, screens, prices } = makeCinemas(rng);
164
+ const showtimes = makeShowtimes(rng, cinemas, screens, films);
165
+ const customers = makeCustomers(rng);
166
+ const cinemaOf = new Map(cinemas.map((c) => [c.code, c]));
167
+ const screenOf = new Map(screens.map((s) => [s.code, s]));
168
+ const filmOf = new Map(films.map((f) => [f.code, f]));
169
+ const bookings = [];
170
+ const mix = (n, film) => {
171
+ const c = { adult: 0, child: 0, senior: 0, student: 0 };
172
+ const kids = !CINEMA_ADULT_RATINGS.includes(film.rating);
173
+ for (let i = 0; i < n; i++) {
174
+ const r = rng();
175
+ c[r < 0.6 ? "adult" : r < 0.75 ? (kids ? "child" : "adult") : r < 0.87 ? "senior" : "student"]++;
176
+ }
177
+ return c;
178
+ };
179
+ const book = (s, seats, status) => {
180
+ const customer = pick(rng, customers);
181
+ const q = cinemaQuote({ cinema: cinemaOf.get(s.cinemaCode), screen: screenOf.get(s.screenCode), showtime: s, prices }, seats, mix(seats.length, filmOf.get(s.filmCode)));
182
+ bookings.push({
183
+ bookingNo: `TK-${30001 + bookings.length}`,
184
+ showtimeCode: s.code,
185
+ customerName: customer.name,
186
+ customerEmail: customer.email,
187
+ tickets: q.tickets,
188
+ feesCents: q.feesCents,
189
+ totalCents: q.totalCents,
190
+ status,
191
+ createdAt: new Date(Date.UTC(2027, 3, 1 + int(rng, 0, 40), int(rng, 8, 22), int(rng, 0, 59))).toISOString(),
192
+ });
193
+ };
194
+ const runsOf = (s) => cinemaFreeRuns(screenOf.get(s.screenCode), cinemaTakenSeats(bookings, s.code));
195
+ /** Books every free seat of the showtime except `keep`, a row's run at a time (at most CINEMA_MAX_SEATS a booking). */
196
+ const fill = (s, keep) => {
197
+ for (const run of runsOf(s)) {
198
+ const seats = run.filter((x) => !keep.has(x));
199
+ for (let i = 0; i < seats.length;) {
200
+ let j = i + 1;
201
+ while (j < seats.length && j - i < CINEMA_MAX_SEATS && Number(seats[j].slice(1)) === Number(seats[j - 1].slice(1)) + 1)
202
+ j++;
203
+ book(s, seats.slice(i, j), "confirmed");
204
+ i = j;
205
+ }
206
+ }
207
+ };
208
+ for (let i = 0; i < CINEMA_SIZES.bookings; i++) {
209
+ const s = pick(rng, showtimes);
210
+ const n = pick(rng, [1, 2, 2, 2, 3, 3, 4, 5, 6]);
211
+ const runs = runsOf(s).filter((r) => r.length >= n);
212
+ if (runs.length === 0)
213
+ continue;
214
+ const run = pick(rng, runs);
215
+ const start = int(rng, 0, run.length - n);
216
+ book(s, run.slice(start, start + n), rng() < 0.12 ? "cancelled" : "confirmed");
217
+ }
218
+ // Sold out on purpose: every seat of a few standard-screen showtimes taken, each on a day its cinema shows the
219
+ // film's genre at least four times — so a search by genre, day, time and format has a near miss to step over.
220
+ const standard = showtimes.filter((s) => screenOf.get(s.screenCode)?.kind === "standard");
221
+ const dayOf = (s) => `${s.cinemaCode}:${s.date}:${filmOf.get(s.filmCode)?.genre}`;
222
+ const perDay = new Map();
223
+ for (const s of showtimes)
224
+ perDay.set(dayOf(s), (perDay.get(dayOf(s)) ?? 0) + 1);
225
+ const busy = standard.filter((s) => (perDay.get(dayOf(s)) ?? 0) >= 4);
226
+ const soldOut = shuffle(rng, busy).slice(0, CINEMA_SIZES.soldOut);
227
+ for (const s of soldOut)
228
+ fill(s, new Set());
229
+ // Nearly full on purpose: only 3–5 single seats left, no two side by side. Half are the first showing of their
230
+ // film at their cinema (so "the earliest showing with seats together" is a later one), half on busy genre days.
231
+ const firsts = new Map();
232
+ for (const s of showtimes)
233
+ if (!firsts.has(`${s.cinemaCode}:${s.filmCode}`))
234
+ firsts.set(`${s.cinemaCode}:${s.filmCode}`, s);
235
+ const pool = (list) => shuffle(rng, list.filter((s) => screenOf.get(s.screenCode)?.kind === "standard" && !soldOut.includes(s)));
236
+ const nearly = [];
237
+ for (const s of [...pool([...firsts.values()]).slice(0, CINEMA_SIZES.nearlyFull / 2), ...pool(busy), ...pool(standard)]) {
238
+ if (nearly.length >= CINEMA_SIZES.nearlyFull)
239
+ break;
240
+ if (!nearly.includes(s))
241
+ nearly.push(s);
242
+ }
243
+ for (const s of nearly) {
244
+ const screen = screenOf.get(s.screenCode);
245
+ const keep = new Set();
246
+ const want = int(rng, 3, 5);
247
+ for (const seat of shuffle(rng, cinemaFreeSeats(screen, cinemaTakenSeats(bookings, s.code)))) {
248
+ if (keep.size >= want)
249
+ break;
250
+ const n = Number(seat.slice(1));
251
+ if (!keep.has(`${seat[0]}${n - 1}`) && !keep.has(`${seat[0]}${n + 1}`))
252
+ keep.add(seat);
253
+ }
254
+ fill(s, keep);
255
+ }
256
+ return { cinemas, screens, films, prices, showtimes, bookings };
257
+ }
258
+ //# sourceMappingURL=generate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.js","sourceRoot":"","sources":["../../../src/sites/cinema/generate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,WAAW,EA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AG,CAAC,GAAG,CAAC,EAAE,CAAC;gBAAE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACzF,CAAC;QACD,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IAChB,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC;AAClE,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from "./types.js";
2
+ export * from "./rules.js";
3
+ export { CINEMA_GENRES, CINEMA_SIZES, cinemaRows } from "./generate.js";
@@ -0,0 +1,4 @@
1
+ export * from "./types.js";
2
+ export * from "./rules.js";
3
+ export { CINEMA_GENRES, CINEMA_SIZES, cinemaRows } from "./generate.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/sites/cinema/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC"}
@@ -0,0 +1,142 @@
1
+ import type { Cinema, CinemaBooking, CinemaFilm, CinemaFormat, CinemaPrice, CinemaRows, CinemaScreen, CinemaShowtime, CinemaTicket, CinemaTicketType } from "./types.js";
2
+ /**
3
+ * The cinema site's booking rules, as pure functions over rows. apps/cinema
4
+ * enforces them on every write and answers every search with them, and the
5
+ * intent corpus derives its answer keys from them, so the site and the keys
6
+ * cannot disagree about which seats are free or what tickets cost.
7
+ */
8
+ /** The dates showtimes run on. Fixed, not "from today", so a seed means the same programme forever. */
9
+ export declare const CINEMA_WINDOW: {
10
+ readonly first: "2027-05-14";
11
+ readonly last: "2027-05-16";
12
+ };
13
+ export declare const CINEMA_MAX_SEATS = 10;
14
+ export declare const CINEMA_FORMATS: readonly CinemaFormat[];
15
+ export declare const CINEMA_TICKET_TYPES: readonly CinemaTicketType[];
16
+ /** Child tickets are not sold for films with these ratings. */
17
+ export declare const CINEMA_ADULT_RATINGS: readonly string[];
18
+ export declare const CINEMA_ROW_LETTERS = "ABCDEFGH";
19
+ export type CinemaTicketCounts = Record<CinemaTicketType, number>;
20
+ export type CinemaProblem = {
21
+ code: string;
22
+ message: string;
23
+ };
24
+ export type CinemaBookingContext = {
25
+ cinema: Cinema;
26
+ screen: CinemaScreen;
27
+ film: CinemaFilm;
28
+ showtime: CinemaShowtime;
29
+ prices: readonly CinemaPrice[];
30
+ };
31
+ export type CinemaBookingRequest = {
32
+ seats: readonly string[];
33
+ counts?: Partial<CinemaTicketCounts> | undefined;
34
+ };
35
+ export type CinemaQuote = {
36
+ tickets: CinemaTicket[];
37
+ feesCents: number;
38
+ totalCents: number;
39
+ };
40
+ export type CinemaSeatRow = {
41
+ row: string;
42
+ premium: boolean;
43
+ seats: {
44
+ seat: string;
45
+ free: boolean;
46
+ }[];
47
+ free: string[];
48
+ };
49
+ export type CinemaShowtimeQuery = {
50
+ city?: string | undefined;
51
+ cinemaCode?: string | undefined;
52
+ date?: string | undefined;
53
+ genre?: string | undefined;
54
+ filmCode?: string | undefined;
55
+ format?: CinemaFormat | undefined;
56
+ /** Start time at or after this "HH:MM". */
57
+ after?: string | undefined;
58
+ /** At least this many free seats. */
59
+ seats?: number | undefined;
60
+ /** With `seats`: that many free seats side by side in one row. */
61
+ together?: boolean | undefined;
62
+ };
63
+ export type CinemaShowtimeOffer = {
64
+ showtimeCode: string;
65
+ cinemaCode: string;
66
+ cinemaName: string;
67
+ city: string;
68
+ screenCode: string;
69
+ screenName: string;
70
+ filmCode: string;
71
+ filmTitle: string;
72
+ genre: string;
73
+ rating: string;
74
+ language: string;
75
+ date: string;
76
+ time: string;
77
+ format: CinemaFormat;
78
+ seatsTotal: number;
79
+ freeSeats: number;
80
+ /** The most free seats side by side in any one row. */
81
+ bestRun: number;
82
+ adultPriceCents: number | null;
83
+ };
84
+ /** A booking as the site serves it: the stored row plus its showtime and the seat facts a check reads. */
85
+ export type CinemaBookingView = CinemaBooking & {
86
+ cinemaCode: string;
87
+ filmCode: string;
88
+ date: string;
89
+ time: string;
90
+ format: CinemaFormat;
91
+ /** Seat codes in seat order, comma-separated: "F4,F5,F6". */
92
+ seats: string;
93
+ seatCount: number;
94
+ /** All seats in one row with consecutive numbers. */
95
+ together: boolean;
96
+ ticketCounts: CinemaTicketCounts;
97
+ };
98
+ export declare const cinemaIsTime: (s: string) => boolean;
99
+ export declare function cinemaParseSeat(seat: string): {
100
+ row: string;
101
+ number: number;
102
+ } | null;
103
+ /** "f4, F5 f6", ["f4", "F5"] → ["F4", "F5", "F6"]: trimmed, upper-cased, in the order given. */
104
+ export declare function cinemaNormalizeSeats(input: string | readonly string[]): string[];
105
+ /** Seat order: row, then number (A1, A2, …, A10, B1). */
106
+ export declare const cinemaSortSeats: (seats: readonly string[]) => string[];
107
+ export declare const cinemaRowsOf: (screen: CinemaScreen) => string[];
108
+ export declare const cinemaSeatsOf: (screen: CinemaScreen) => string[];
109
+ export declare const cinemaIsPremiumSeat: (screen: CinemaScreen, seat: string) => boolean;
110
+ /** Seats held by confirmed bookings of the showtime. Cancelled bookings hold nothing. */
111
+ export declare function cinemaTakenSeats(bookings: readonly CinemaBooking[], showtimeCode: string): Set<string>;
112
+ export declare const cinemaFreeSeats: (screen: CinemaScreen, taken: ReadonlySet<string>) => string[];
113
+ /** Each row's maximal runs of free seats side by side, in seat order. */
114
+ export declare function cinemaFreeRuns(screen: CinemaScreen, taken: ReadonlySet<string>): string[][];
115
+ export declare const cinemaBestRun: (screen: CinemaScreen, taken: ReadonlySet<string>) => number;
116
+ export declare function cinemaSeatMap(screen: CinemaScreen, taken: ReadonlySet<string>): CinemaSeatRow[];
117
+ /** One row, consecutive numbers. */
118
+ export declare function cinemaSeatsTogether(seats: readonly string[]): boolean;
119
+ /** The ticket mix asked for; none given at all means every seat is an adult ticket. */
120
+ export declare function cinemaResolveCounts(seatCount: number, counts?: Partial<CinemaTicketCounts>): CinemaTicketCounts;
121
+ export declare function cinemaCountsOf(tickets: readonly {
122
+ ticketType: CinemaTicketType;
123
+ }[]): CinemaTicketCounts;
124
+ export declare function cinemaPriceOf(prices: readonly CinemaPrice[], cinemaCode: string, format: CinemaFormat, ticketType: CinemaTicketType): number | null;
125
+ /** Seats in seat order get ticket types in this order: adults, then children, seniors, students. */
126
+ export declare function cinemaAssignTypes(seats: readonly string[], counts: CinemaTicketCounts): {
127
+ seat: string;
128
+ ticketType: CinemaTicketType;
129
+ }[];
130
+ /** What a valid request costs: each ticket's price for the showtime's format, plus the premium surcharge on premium-row seats, plus the booking fee per ticket. */
131
+ export declare function cinemaQuote(ctx: Omit<CinemaBookingContext, "film">, seats: readonly string[], counts?: Partial<CinemaTicketCounts>): CinemaQuote;
132
+ /** Why the request cannot be booked, before availability: seat count, seat codes, the ticket mix, the film's rating, prices. */
133
+ export declare function cinemaRequestProblem(ctx: CinemaBookingContext, req: CinemaBookingRequest): CinemaProblem | null;
134
+ /** cinemaRequestProblem, then whether every seat is free. The rule every booking write is held to. */
135
+ export declare function cinemaBookingProblem(ctx: CinemaBookingContext, req: CinemaBookingRequest, bookings: readonly CinemaBooking[]): CinemaProblem | null;
136
+ export declare function cinemaBookingView(b: CinemaBooking, s: CinemaShowtime): CinemaBookingView;
137
+ /**
138
+ * Showtimes matching every given filter (city, cinema, date, genre, film,
139
+ * format, starting at or after a time, with enough free seats — side by side
140
+ * when `together`), by date, then start time, then code.
141
+ */
142
+ export declare function cinemaSearchShowtimes(rows: CinemaRows, q: CinemaShowtimeQuery): CinemaShowtimeOffer[];
@@ -0,0 +1,191 @@
1
+ /**
2
+ * The cinema site's booking rules, as pure functions over rows. apps/cinema
3
+ * enforces them on every write and answers every search with them, and the
4
+ * intent corpus derives its answer keys from them, so the site and the keys
5
+ * cannot disagree about which seats are free or what tickets cost.
6
+ */
7
+ /** The dates showtimes run on. Fixed, not "from today", so a seed means the same programme forever. */
8
+ export const CINEMA_WINDOW = { first: "2027-05-14", last: "2027-05-16" };
9
+ export const CINEMA_MAX_SEATS = 10;
10
+ export const CINEMA_FORMATS = ["2d", "3d", "large"];
11
+ export const CINEMA_TICKET_TYPES = ["adult", "child", "senior", "student"];
12
+ /** Child tickets are not sold for films with these ratings. */
13
+ export const CINEMA_ADULT_RATINGS = ["15", "18"];
14
+ export const CINEMA_ROW_LETTERS = "ABCDEFGH";
15
+ const SEAT = /^([A-H])(\d{1,2})$/;
16
+ const TIME = /^([01]\d|2[0-3]):[0-5]\d$/;
17
+ export const cinemaIsTime = (s) => TIME.test(s);
18
+ export function cinemaParseSeat(seat) {
19
+ const m = SEAT.exec(seat.trim().toUpperCase());
20
+ return m ? { row: m[1], number: Number(m[2]) } : null;
21
+ }
22
+ /** "f4, F5 f6", ["f4", "F5"] → ["F4", "F5", "F6"]: trimmed, upper-cased, in the order given. */
23
+ export function cinemaNormalizeSeats(input) {
24
+ const parts = typeof input === "string" ? input.split(/[\s,;]+/) : input.flatMap((s) => s.split(/[\s,;]+/));
25
+ return parts.map((s) => s.trim().toUpperCase()).filter(Boolean);
26
+ }
27
+ const seatKey = (seat) => {
28
+ const p = cinemaParseSeat(seat);
29
+ return p ? CINEMA_ROW_LETTERS.indexOf(p.row) * 100 + p.number : 10_000;
30
+ };
31
+ /** Seat order: row, then number (A1, A2, …, A10, B1). */
32
+ export const cinemaSortSeats = (seats) => [...seats].sort((x, y) => seatKey(x) - seatKey(y) || x.localeCompare(y));
33
+ export const cinemaRowsOf = (screen) => CINEMA_ROW_LETTERS.slice(0, screen.rows).split("");
34
+ export const cinemaSeatsOf = (screen) => cinemaRowsOf(screen).flatMap((r) => Array.from({ length: screen.seatsPerRow }, (_, i) => `${r}${i + 1}`));
35
+ export const cinemaIsPremiumSeat = (screen, seat) => screen.premiumRows.includes(cinemaParseSeat(seat)?.row ?? "");
36
+ /** Seats held by confirmed bookings of the showtime. Cancelled bookings hold nothing. */
37
+ export function cinemaTakenSeats(bookings, showtimeCode) {
38
+ return new Set(bookings.filter((b) => b.showtimeCode === showtimeCode && b.status === "confirmed").flatMap((b) => b.tickets.map((t) => t.seat)));
39
+ }
40
+ export const cinemaFreeSeats = (screen, taken) => cinemaSeatsOf(screen).filter((s) => !taken.has(s));
41
+ /** Each row's maximal runs of free seats side by side, in seat order. */
42
+ export function cinemaFreeRuns(screen, taken) {
43
+ const runs = [];
44
+ for (const row of cinemaRowsOf(screen)) {
45
+ let run = [];
46
+ for (let n = 1; n <= screen.seatsPerRow; n++) {
47
+ const seat = `${row}${n}`;
48
+ if (taken.has(seat)) {
49
+ if (run.length)
50
+ runs.push(run);
51
+ run = [];
52
+ }
53
+ else
54
+ run.push(seat);
55
+ }
56
+ if (run.length)
57
+ runs.push(run);
58
+ }
59
+ return runs;
60
+ }
61
+ export const cinemaBestRun = (screen, taken) => Math.max(0, ...cinemaFreeRuns(screen, taken).map((r) => r.length));
62
+ export function cinemaSeatMap(screen, taken) {
63
+ return cinemaRowsOf(screen).map((row) => {
64
+ const seats = Array.from({ length: screen.seatsPerRow }, (_, i) => ({ seat: `${row}${i + 1}`, free: !taken.has(`${row}${i + 1}`) }));
65
+ return { row, premium: screen.premiumRows.includes(row), seats, free: seats.filter((s) => s.free).map((s) => s.seat) };
66
+ });
67
+ }
68
+ /** One row, consecutive numbers. */
69
+ export function cinemaSeatsTogether(seats) {
70
+ const parsed = cinemaSortSeats(seats).map(cinemaParseSeat);
71
+ if (parsed.length === 0 || parsed.some((p) => !p))
72
+ return false;
73
+ return parsed.every((p, i) => i === 0 || (p.row === parsed[0].row && p.number === parsed[i - 1].number + 1));
74
+ }
75
+ /** The ticket mix asked for; none given at all means every seat is an adult ticket. */
76
+ export function cinemaResolveCounts(seatCount, counts) {
77
+ const c = { adult: counts?.adult ?? 0, child: counts?.child ?? 0, senior: counts?.senior ?? 0, student: counts?.student ?? 0 };
78
+ return c.adult + c.child + c.senior + c.student === 0 ? { adult: seatCount, child: 0, senior: 0, student: 0 } : c;
79
+ }
80
+ export function cinemaCountsOf(tickets) {
81
+ const c = { adult: 0, child: 0, senior: 0, student: 0 };
82
+ for (const t of tickets)
83
+ c[t.ticketType]++;
84
+ return c;
85
+ }
86
+ export function cinemaPriceOf(prices, cinemaCode, format, ticketType) {
87
+ return prices.find((p) => p.cinemaCode === cinemaCode && p.format === format && p.ticketType === ticketType)?.priceCents ?? null;
88
+ }
89
+ /** Seats in seat order get ticket types in this order: adults, then children, seniors, students. */
90
+ export function cinemaAssignTypes(seats, counts) {
91
+ const types = CINEMA_TICKET_TYPES.flatMap((t) => Array.from({ length: counts[t] }, () => t));
92
+ return cinemaSortSeats(seats).map((seat, i) => ({ seat, ticketType: types[i] ?? "adult" }));
93
+ }
94
+ /** What a valid request costs: each ticket's price for the showtime's format, plus the premium surcharge on premium-row seats, plus the booking fee per ticket. */
95
+ export function cinemaQuote(ctx, seats, counts) {
96
+ const all = cinemaNormalizeSeats(seats);
97
+ const tickets = cinemaAssignTypes(all, cinemaResolveCounts(all.length, counts)).map((t) => ({
98
+ ...t,
99
+ priceCents: (cinemaPriceOf(ctx.prices, ctx.cinema.code, ctx.showtime.format, t.ticketType) ?? 0) + (cinemaIsPremiumSeat(ctx.screen, t.seat) ? ctx.cinema.premiumSurchargeCents : 0),
100
+ }));
101
+ const feesCents = ctx.cinema.bookingFeeCents * tickets.length;
102
+ return { tickets, feesCents, totalCents: tickets.reduce((s, t) => s + t.priceCents, 0) + feesCents };
103
+ }
104
+ /** Why the request cannot be booked, before availability: seat count, seat codes, the ticket mix, the film's rating, prices. */
105
+ export function cinemaRequestProblem(ctx, req) {
106
+ const seats = cinemaNormalizeSeats(req.seats);
107
+ const { screen, film } = ctx;
108
+ if (seats.length === 0)
109
+ return { code: "NO_SEATS", message: "a booking needs at least one seat" };
110
+ if (seats.length > CINEMA_MAX_SEATS)
111
+ return { code: "TOO_MANY_SEATS", message: `one booking takes at most ${CINEMA_MAX_SEATS} seats` };
112
+ const onMap = new Set(cinemaSeatsOf(screen));
113
+ const bad = seats.find((s) => !onMap.has(s));
114
+ if (bad)
115
+ return { code: "BAD_SEAT", message: `seat ${bad} is not in ${screen.name} (rows A–${CINEMA_ROW_LETTERS[screen.rows - 1]}, seats 1–${screen.seatsPerRow})` };
116
+ const dup = seats.find((s, i) => seats.indexOf(s) !== i);
117
+ if (dup)
118
+ return { code: "DUPLICATE_SEAT", message: `seat ${dup} is listed twice` };
119
+ const given = req.counts ?? {};
120
+ if (CINEMA_TICKET_TYPES.some((t) => given[t] !== undefined && (!Number.isInteger(given[t]) || given[t] < 0)))
121
+ return { code: "BAD_TICKET_COUNT", message: "ticket counts are whole numbers, 0 or more" };
122
+ const counts = cinemaResolveCounts(seats.length, given);
123
+ const tickets = CINEMA_TICKET_TYPES.reduce((s, t) => s + counts[t], 0);
124
+ if (tickets !== seats.length)
125
+ return { code: "BAD_TICKET_COUNT", message: `${seats.length} seat(s) but ${tickets} ticket(s): give one ticket type per seat` };
126
+ if (counts.child > 0 && CINEMA_ADULT_RATINGS.includes(film.rating))
127
+ return { code: "CHILD_NOT_ALLOWED", message: `child tickets are not sold for ${film.title}, rated ${film.rating}` };
128
+ const unpriced = CINEMA_TICKET_TYPES.find((t) => counts[t] > 0 && cinemaPriceOf(ctx.prices, ctx.cinema.code, ctx.showtime.format, t) === null);
129
+ if (unpriced)
130
+ return { code: "NO_PRICE", message: `${ctx.cinema.name} has no ${unpriced} price for ${ctx.showtime.format}` };
131
+ return null;
132
+ }
133
+ /** cinemaRequestProblem, then whether every seat is free. The rule every booking write is held to. */
134
+ export function cinemaBookingProblem(ctx, req, bookings) {
135
+ const fit = cinemaRequestProblem(ctx, req);
136
+ if (fit)
137
+ return fit;
138
+ const taken = cinemaTakenSeats(bookings, ctx.showtime.code);
139
+ if (cinemaFreeSeats(ctx.screen, taken).length === 0)
140
+ return { code: "SOLD_OUT", message: `the ${ctx.showtime.time} showing of ${ctx.film.title} on ${ctx.showtime.date} is sold out` };
141
+ const busy = cinemaSortSeats(cinemaNormalizeSeats(req.seats)).filter((s) => taken.has(s));
142
+ if (busy.length)
143
+ return { code: "SEAT_TAKEN", message: `seat(s) ${busy.join(", ")} already booked for the ${ctx.showtime.time} showing on ${ctx.showtime.date}` };
144
+ return null;
145
+ }
146
+ export function cinemaBookingView(b, s) {
147
+ const seats = cinemaSortSeats(b.tickets.map((t) => t.seat));
148
+ return { ...b, cinemaCode: s.cinemaCode, filmCode: s.filmCode, date: s.date, time: s.time, format: s.format, seats: seats.join(","), seatCount: seats.length, together: cinemaSeatsTogether(seats), ticketCounts: cinemaCountsOf(b.tickets) };
149
+ }
150
+ /**
151
+ * Showtimes matching every given filter (city, cinema, date, genre, film,
152
+ * format, starting at or after a time, with enough free seats — side by side
153
+ * when `together`), by date, then start time, then code.
154
+ */
155
+ export function cinemaSearchShowtimes(rows, q) {
156
+ const cinema = new Map(rows.cinemas.map((c) => [c.code, c]));
157
+ const screen = new Map(rows.screens.map((s) => [s.code, s]));
158
+ const film = new Map(rows.films.map((f) => [f.code, f]));
159
+ const lc = (s) => s?.trim().toLowerCase();
160
+ const out = [];
161
+ for (const s of rows.showtimes) {
162
+ const c = cinema.get(s.cinemaCode);
163
+ const f = film.get(s.filmCode);
164
+ const sc = screen.get(s.screenCode);
165
+ if (q.city && c.city.toLowerCase() !== lc(q.city))
166
+ continue;
167
+ if (q.cinemaCode && s.cinemaCode !== q.cinemaCode)
168
+ continue;
169
+ if (q.date && s.date !== q.date)
170
+ continue;
171
+ if (q.genre && f.genre !== lc(q.genre))
172
+ continue;
173
+ if (q.filmCode && s.filmCode !== q.filmCode)
174
+ continue;
175
+ if (q.format && s.format !== q.format)
176
+ continue;
177
+ if (q.after && s.time < q.after)
178
+ continue;
179
+ const taken = cinemaTakenSeats(rows.bookings, s.code);
180
+ const freeSeats = cinemaFreeSeats(sc, taken).length;
181
+ const bestRun = cinemaBestRun(sc, taken);
182
+ if (q.seats !== undefined && (freeSeats < q.seats || (q.together && bestRun < q.seats)))
183
+ continue;
184
+ out.push({
185
+ showtimeCode: s.code, cinemaCode: c.code, cinemaName: c.name, city: c.city, screenCode: sc.code, screenName: sc.name, filmCode: f.code, filmTitle: f.title, genre: f.genre, rating: f.rating,
186
+ language: f.language, date: s.date, time: s.time, format: s.format, seatsTotal: sc.rows * sc.seatsPerRow, freeSeats, bestRun, adultPriceCents: cinemaPriceOf(rows.prices, c.code, s.format, "adult"),
187
+ });
188
+ }
189
+ return out.sort((x, y) => x.date.localeCompare(y.date) || x.time.localeCompare(y.time) || x.showtimeCode.localeCompare(y.showtimeCode));
190
+ }
191
+ //# sourceMappingURL=rules.js.map