@composable-os/pack-bookings 0.0.0-stage → 0.1.0-beta.9

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.
package/dist/index.js ADDED
@@ -0,0 +1,670 @@
1
+ // Bookings (stage 31a, build step 3: the spine; ADR 0504): a gym's or studio's timetable and the
2
+ // bookings members make on it. Staff set a weekly timetable once (series), the host makes each
3
+ // week's classes from it, and members book and cancel them on the web and in the app.
4
+ //
5
+ // Everything that is a rule is the host's, declared here as behaviours (ADR 0404):
6
+ // - a series makes its classes ahead in local time across clock changes (`recurring`, ADR 0500),
7
+ // never less far ahead than the longest booking window a class type sets (`horizonAtLeast`),
8
+ // never on a closure's dates, and never over a class staff changed by hand;
9
+ // - a class has places (`capacity`), and a booking holds one by its state (`claims`, ADR 0501),
10
+ // refused by the database past the places, for every actor;
11
+ // - one live booking per Person per class (`unique`, ADR 0502);
12
+ // - when a customer may book (from the class type's "opens" days before, else the
13
+ // organisation's; until its "closes" minutes before) and cancel in time (until its "late from"
14
+ // minutes before; late until the start; then not at all), and which class types only staff
15
+ // book, are windows and staff-only rules on the booking's states (ADR 0503), worked out from
16
+ // the class type's own value or the organisation's setting (ADR 0505). A member's "cancel" is
17
+ // a requested move the host resolves to `cancelled` or `late_cancelled` by its clock;
18
+ // - a booking entering `booked` spends a use of its Person's membership or pass and an in-time
19
+ // cancel gives it back (`allowance`, ADRs 0493 and 0494), unless staff booked it paid at the
20
+ // desk (`waived`, ADR 0506). The holders are the Memberships pack's (stage 32b);
21
+ // - members read the timetable and how many places are left, never who is booked (decision 13).
22
+ // The tools in tools.ts compose the host's operations and add no rules of their own.
23
+ import { defineExtension } from "@composable-os/sdk";
24
+ import { book, bookFor, cancel, cancelFor, classGet, classList, day, findPeople, mine, returnUse, timetable, } from "./tools.js";
25
+ /** Weekday values a series' `weekdays` uses (ADR 0500). */
26
+ const WEEKDAYS = [
27
+ { value: "mon", label: "Monday" },
28
+ { value: "tue", label: "Tuesday" },
29
+ { value: "wed", label: "Wednesday" },
30
+ { value: "thu", label: "Thursday" },
31
+ { value: "fri", label: "Friday" },
32
+ { value: "sat", label: "Saturday" },
33
+ { value: "sun", label: "Sunday" },
34
+ ];
35
+ /** A booking's states (spec 31, "Booking states"). Only some are reachable at this step. */
36
+ const BOOKING_STATES = [
37
+ { value: "booked", label: "Booked" },
38
+ { value: "pending", label: "Held while paying" },
39
+ { value: "waiting", label: "Waiting" },
40
+ { value: "left", label: "Left the waitlist" },
41
+ { value: "cancelled", label: "Cancelled" },
42
+ { value: "late_cancelled", label: "Cancelled late" },
43
+ { value: "excused", label: "Cancelled, class given back" },
44
+ { value: "attended", label: "Attended" },
45
+ { value: "no_show", label: "No-show" },
46
+ { value: "cancelled_by_us", label: "Cancelled by the gym" },
47
+ { value: "moved", label: "Moved" },
48
+ { value: "expired", label: "Expired" },
49
+ ];
50
+ /** A booking that holds or takes a place, and so counts as the Person's one for its class. */
51
+ const ACTIVE = ["pending", "booked", "waiting", "attended", "no_show"];
52
+ /** When a customer may book, and when a cancel is late, from the class type or the org. */
53
+ const opens = {
54
+ at: "class.startsAt",
55
+ daysBefore: { field: "class.classType.opensDays", setting: "opensDays" },
56
+ zone: "class.timezone",
57
+ };
58
+ const closes = {
59
+ at: "class.startsAt",
60
+ minutesBefore: { field: "class.classType.closesMinutes", setting: "closesMinutes" },
61
+ };
62
+ const lateFrom = {
63
+ at: "class.startsAt",
64
+ minutesBefore: { field: "class.classType.lateMinutes", setting: "lateMinutes" },
65
+ };
66
+ // A booking rule is a person's to change (spec 31: "Change the booking rules: a person only"):
67
+ // set by the assistant, an MCP client, an automation or extension code, it waits for a person's
68
+ // approval (`personApproves`, ADR 0507).
69
+ const minutes = (label, description) => ({
70
+ type: "number",
71
+ label,
72
+ description,
73
+ min: 0,
74
+ max: 10_080,
75
+ step: 1,
76
+ personApproves: true,
77
+ });
78
+ export default defineExtension({
79
+ id: "bookings",
80
+ version: "0.1.0",
81
+ contractVersion: 1,
82
+ label: "Bookings",
83
+ description: "A timetable of classes made from weekly series, rooms and coaches, and the bookings members " +
84
+ "make and cancel within the gym's rules. Class types are Programs'.",
85
+ // The class type is Programs' (spec 31): the host installs Bookings only beside Programs.
86
+ requires: ["programs"],
87
+ permissions: {
88
+ // person.get / person.create: a booking's person on a class list, and a walk-in staff book.
89
+ // programs.classtype: a class type's name and booking rules on staff's day view.
90
+ read: ["person", "programs.classtype"],
91
+ write: ["person"],
92
+ // record.*, my.* and state.resolve are not listed: they are granted by object (Bookings'
93
+ // own, and the read and write lists above), and a listed one would reach every object.
94
+ // duplicate.check: a walk-in is checked against the People on file before one is made.
95
+ operations: ["public.list", "public.get", "capacity.get", "duplicate.check"],
96
+ modules: ["ops"],
97
+ },
98
+ // Bookings' fields on Programs' class type: how it shows, and its booking rules when they
99
+ // differ from the organisation's (Settings → Extensions → Bookings). Empty: the organisation's.
100
+ fields: {
101
+ "programs.classtype": {
102
+ colour: {
103
+ type: "text",
104
+ label: "Colour",
105
+ description: "How its classes show on the timetable, e.g. #2f6fed.",
106
+ },
107
+ opensDays: {
108
+ type: "number",
109
+ label: "Booking opens (days before)",
110
+ description: "Members may book this many days before a class, at the same time of day. Empty: the " +
111
+ "organisation's setting.",
112
+ min: 0,
113
+ max: 365,
114
+ step: 1,
115
+ personApproves: true,
116
+ },
117
+ closesMinutes: minutes("Booking closes (minutes before)", "Members may book until this many minutes before a class starts (0: until it starts). " +
118
+ "Empty: the organisation's setting."),
119
+ lateMinutes: minutes("Late cancel from (minutes before)", "A cancel this close to the start or closer is late and keeps the class it used. Empty: " +
120
+ "the organisation's setting."),
121
+ promotionMinutes: minutes("Waitlist stops (minutes before)", "Nobody is moved in from the waitlist after this. Empty: the organisation's setting. " +
122
+ "(The waitlist comes in a later release.)"),
123
+ reminderMinutes: minutes("Reminder (minutes before)", "When members are reminded of a class. Empty: the organisation's setting. (Reminders " +
124
+ "come in a later release.)"),
125
+ staffOnly: {
126
+ type: "boolean",
127
+ label: "Booked by staff only",
128
+ description: "Members cannot book its classes themselves; staff book them in.",
129
+ personApproves: true,
130
+ },
131
+ },
132
+ },
133
+ objects: {
134
+ room: {
135
+ label: "Room",
136
+ plural: "Rooms",
137
+ icon: "door-open",
138
+ titleField: "name",
139
+ description: "Where classes are held.",
140
+ navigation: "settings",
141
+ fields: {
142
+ name: { type: "text", label: "Name", required: true },
143
+ places: {
144
+ type: "number",
145
+ label: "Places",
146
+ description: "The most the room holds: a guide for staff, not a limit on a class.",
147
+ min: 0,
148
+ step: 1,
149
+ },
150
+ notes: { type: "longText", label: "Notes" },
151
+ },
152
+ public: { read: ["name"] },
153
+ },
154
+ coach: {
155
+ label: "Coach",
156
+ plural: "Coaches",
157
+ icon: "user-round",
158
+ titleField: "name",
159
+ description: "Who teaches classes. Name, photo and bio are shown on the timetable.",
160
+ navigation: "settings",
161
+ fields: {
162
+ name: { type: "text", label: "Name", required: true },
163
+ photo: { type: "url", label: "Photo" },
164
+ bio: { type: "longText", label: "Short bio" },
165
+ user: {
166
+ type: "user",
167
+ label: "Staff account",
168
+ description: "Their staff account, if they have one (a visiting coach may not).",
169
+ },
170
+ active: { type: "boolean", label: "Active", default: true },
171
+ },
172
+ public: { read: ["name", "photo", "bio"] },
173
+ },
174
+ series: {
175
+ label: "Series",
176
+ plural: "Series",
177
+ icon: "calendar-sync",
178
+ titleField: "title",
179
+ titleDefault: { from: ["classType"] },
180
+ description: "One line of the timetable: a class type on chosen weekdays at a local time, from a " +
181
+ "date. The host makes its classes ahead.",
182
+ navigation: "main",
183
+ navigationOrder: 31,
184
+ fields: {
185
+ title: { type: "text", label: "Title" },
186
+ classType: {
187
+ type: "relation",
188
+ label: "Class type",
189
+ to: "programs.classtype",
190
+ required: true,
191
+ },
192
+ weekdays: { type: "multiSelect", label: "Weekdays", options: WEEKDAYS, required: true },
193
+ time: {
194
+ type: "text",
195
+ label: "Starts at (local time)",
196
+ description: "HH:MM in the series' time zone, e.g. 06:00.",
197
+ required: true,
198
+ },
199
+ length: {
200
+ type: "number",
201
+ label: "Length (minutes)",
202
+ required: true,
203
+ min: 5,
204
+ max: 1440,
205
+ step: 1,
206
+ },
207
+ room: { type: "relation", label: "Room", to: "bookings.room" },
208
+ coach: { type: "relation", label: "Coach", to: "bookings.coach" },
209
+ places: { type: "number", label: "Places", required: true, min: 0, step: 1 },
210
+ firstDate: { type: "date", label: "First date", required: true },
211
+ lastDate: { type: "date", label: "Last date", description: "Empty: ongoing." },
212
+ timezone: { type: "timezone", label: "Time zone" },
213
+ state: {
214
+ type: "select",
215
+ label: "State",
216
+ track: "timeline",
217
+ options: [
218
+ { value: "active", label: "Active" },
219
+ { value: "ended", label: "Ended" },
220
+ ],
221
+ },
222
+ },
223
+ states: {
224
+ field: "state",
225
+ initial: "active",
226
+ moves: [{ from: "active", to: "ended", by: ["staff"], final: true }],
227
+ },
228
+ recurring: {
229
+ generates: "class",
230
+ link: "series",
231
+ rule: {
232
+ weekdays: "weekdays",
233
+ time: "time",
234
+ length: "length",
235
+ from: "firstDate",
236
+ until: "lastDate",
237
+ zone: "timezone",
238
+ },
239
+ into: { starts: "startsAt", ends: "endsAt", zone: "timezone", changed: "changed" },
240
+ copy: {
241
+ title: "title",
242
+ classType: "classType",
243
+ room: "room",
244
+ coach: "coach",
245
+ places: "places",
246
+ },
247
+ cancel: "cancelled",
248
+ ended: { field: "state", in: ["ended"] },
249
+ closures: { object: "closure", from: "fromDate", until: "untilDate" },
250
+ // The organisation's "opens" setting is at most 56 days; a class 56 days out must exist
251
+ // when its booking opens, so one day more (as horizonAtLeast adds for a class type's).
252
+ horizonDays: 57,
253
+ // Never less than the longest window a class type opens booking (ADR 0500, 0505).
254
+ horizonAtLeast: { object: "programs.classtype", field: "opensDays" },
255
+ },
256
+ indexes: [["state"], ["classType"]],
257
+ },
258
+ class: {
259
+ label: "Class",
260
+ plural: "Classes",
261
+ icon: "calendar-clock",
262
+ titleField: "title",
263
+ titleDefault: { from: ["classType"] },
264
+ description: "One dated class: made by a series, or a one-off. Members book its places; its record " +
265
+ "page is its list.",
266
+ navigation: "main",
267
+ navigationOrder: 30,
268
+ fields: {
269
+ title: { type: "text", label: "Title" },
270
+ series: {
271
+ type: "relation",
272
+ label: "Series",
273
+ to: "bookings.series",
274
+ readOnly: true,
275
+ description: "The series that made it. Empty for a one-off class.",
276
+ },
277
+ classType: {
278
+ type: "relation",
279
+ label: "Class type",
280
+ to: "programs.classtype",
281
+ required: true,
282
+ },
283
+ startsAt: { type: "datetime", label: "Starts", required: true },
284
+ endsAt: { type: "datetime", label: "Ends" },
285
+ // Left empty, the organisation's zone (ADR 0460): a class always has one.
286
+ timezone: { type: "timezone", label: "Time zone", required: true },
287
+ room: { type: "relation", label: "Room", to: "bookings.room" },
288
+ coach: { type: "relation", label: "Coach", to: "bookings.coach" },
289
+ // Required: a class is never unlimited by leaving its places empty.
290
+ places: { type: "number", label: "Places", required: true, min: 0, step: 1 },
291
+ notes: { type: "longText", label: "Notes for members" },
292
+ state: {
293
+ type: "select",
294
+ label: "State",
295
+ track: "timeline",
296
+ options: [
297
+ { value: "scheduled", label: "Scheduled" },
298
+ { value: "cancelled", label: "Cancelled" },
299
+ { value: "done", label: "Done" },
300
+ ],
301
+ },
302
+ changed: {
303
+ type: "boolean",
304
+ label: "Changed from its series",
305
+ readOnly: true,
306
+ description: "Edited by hand: its series no longer changes it.",
307
+ },
308
+ // A class that is not scheduled cannot be booked by a member (the booking's create rule).
309
+ closed: {
310
+ type: "formula",
311
+ label: "Closed to members",
312
+ expression: 'coalesce(state, "scheduled") != "scheduled"',
313
+ },
314
+ },
315
+ states: {
316
+ field: "state",
317
+ initial: "scheduled",
318
+ moves: [
319
+ // Only the host cancels a class at this step (a closure, a series ended, each confirmed
320
+ // by a person, ADR 0500). Staff cancelling a class, with its bookings cancelled in the
321
+ // same batch, is step 7's cascade.
322
+ { from: "scheduled", to: "cancelled", by: ["host"], final: true },
323
+ { from: "scheduled", to: "done", by: ["staff", "host"], final: true },
324
+ ],
325
+ },
326
+ // Members see how many places are left (decision 13), never who has them.
327
+ capacity: { places: "places", show: "exact" },
328
+ public: {
329
+ read: [
330
+ "title",
331
+ "classType",
332
+ "startsAt",
333
+ "endsAt",
334
+ "timezone",
335
+ "room",
336
+ "coach",
337
+ "notes",
338
+ "state",
339
+ ],
340
+ when: { field: "state", in: ["scheduled"] },
341
+ },
342
+ // A booking's member reads their class whatever its state (a cancelled one says so).
343
+ customerVia: {
344
+ from: "bookings.booking",
345
+ field: "class",
346
+ read: [
347
+ "title",
348
+ "classType",
349
+ "startsAt",
350
+ "endsAt",
351
+ "timezone",
352
+ "room",
353
+ "coach",
354
+ "notes",
355
+ "state",
356
+ ],
357
+ },
358
+ indexes: [["startsAt"], ["state", "startsAt"], ["series"], ["classType", "startsAt"]],
359
+ },
360
+ closure: {
361
+ label: "Closure",
362
+ plural: "Closures",
363
+ icon: "calendar-x",
364
+ titleField: "name",
365
+ description: "Dates the gym is closed (holidays): no classes are made on them, and classes already " +
366
+ "made are cancelled (a person confirms when any have bookings).",
367
+ navigation: "settings",
368
+ fields: {
369
+ name: { type: "text", label: "Reason", required: true },
370
+ fromDate: { type: "date", label: "From", required: true },
371
+ untilDate: { type: "date", label: "Until", required: true },
372
+ },
373
+ },
374
+ booking: {
375
+ label: "Booking",
376
+ plural: "Bookings",
377
+ icon: "calendar-check",
378
+ titleField: "title",
379
+ titleDefault: { from: ["person"] },
380
+ description: "One person's place in one class.",
381
+ navigation: "main",
382
+ navigationOrder: 32,
383
+ fields: {
384
+ title: { type: "text", label: "Title" },
385
+ class: { type: "relation", label: "Class", to: "bookings.class", required: true },
386
+ person: { type: "relation", label: "Person", to: "person", required: true },
387
+ state: { type: "select", label: "State", track: "timeline", options: BOOKING_STATES },
388
+ holder: {
389
+ type: "text",
390
+ label: "Paid from",
391
+ description: "The membership or pass the booking spent a use of (its id). Left empty, the host " +
392
+ "chooses the one whose use would lapse first.",
393
+ },
394
+ classType: {
395
+ type: "relation",
396
+ label: "Class type",
397
+ to: "programs.classtype",
398
+ readOnly: true,
399
+ description: "The class's type, copied by the host: what a membership's limits read.",
400
+ },
401
+ weekday: {
402
+ type: "number",
403
+ label: "Weekday",
404
+ readOnly: true,
405
+ description: "The class's local weekday (1 Monday to 7 Sunday), set by the host.",
406
+ },
407
+ minute: {
408
+ type: "number",
409
+ label: "Local minute",
410
+ readOnly: true,
411
+ description: "The class's local start, in minutes after midnight, set by the host.",
412
+ },
413
+ paidOtherwise: {
414
+ type: "boolean",
415
+ label: "Paid at the desk",
416
+ readOnly: true,
417
+ description: "Booked by staff for someone who paid another way (a walk-in at the desk): it " +
418
+ "spends no use. Set when it is made.",
419
+ },
420
+ bookedBy: {
421
+ type: "user",
422
+ label: "Booked by",
423
+ readOnly: true,
424
+ description: "The staff account that booked it. Empty when the member booked.",
425
+ },
426
+ movedFrom: {
427
+ type: "relation",
428
+ label: "Moved from",
429
+ to: "bookings.booking",
430
+ readOnly: true,
431
+ description: "The booking this one replaced when staff moved it to this class.",
432
+ },
433
+ note: { type: "longText", label: "Staff note" },
434
+ },
435
+ states: {
436
+ field: "state",
437
+ initial: "booked",
438
+ create: {
439
+ // Waiting (step 5) and held while paying (step 8) are not reachable by anyone but the
440
+ // host yet: nothing a customer does lands a booking in them.
441
+ in: { waiting: ["host"], pending: ["host"] },
442
+ window: { from: opens, until: closes },
443
+ // A class type booked by staff only (staff may book it).
444
+ staffOnly: "class.classType.staffOnly",
445
+ // A class that is not scheduled (cancelled or done): nobody books it, staff included.
446
+ closed: "class.closed",
447
+ },
448
+ // A class the host cancels (a closure, a series changed, ended or trashed) cancels its
449
+ // live bookings in the same batch: places released, uses given back (ADR 0507).
450
+ follows: {
451
+ relation: "class",
452
+ when: { cancelled: "cancelled_by_us" },
453
+ from: ["booked", "waiting", "pending"],
454
+ },
455
+ // A member asks to cancel; the host picks in time or late by its clock (ADR 0503).
456
+ requests: { cancel: ["cancelled", "late_cancelled"] },
457
+ moves: [
458
+ { from: "pending", to: "booked", by: ["host"] },
459
+ { from: "pending", to: "expired", by: ["host"], final: true },
460
+ { from: "waiting", to: "booked", by: ["host"] },
461
+ { from: "waiting", to: "left", by: ["staff", "customer"], final: true },
462
+ {
463
+ from: "booked",
464
+ to: "cancelled",
465
+ by: ["staff", "customer"],
466
+ final: true,
467
+ window: { until: lateFrom },
468
+ // In time for everyone, staff included (ADR 0507): giving a use back later is a
469
+ // person's own act, the move below.
470
+ bindsStaff: true,
471
+ },
472
+ {
473
+ from: "booked",
474
+ to: "late_cancelled",
475
+ by: ["staff", "customer"],
476
+ final: true,
477
+ window: { from: lateFrom, until: "class.startsAt" },
478
+ },
479
+ // A person on the staff gives the use back whatever the time, with a reason, through
480
+ // returnUse alone (ADR 0513's `tools`: humanOnly, with its permission).
481
+ { from: "booked", to: "excused", by: ["host"], tools: ["returnUse"], final: true },
482
+ { from: "booked", to: "attended", by: ["staff"] },
483
+ { from: "attended", to: "booked", by: ["staff"] },
484
+ { from: "booked", to: "no_show", by: ["staff", "host"] },
485
+ { from: "no_show", to: "attended", by: ["staff"] },
486
+ {
487
+ from: ["booked", "waiting", "pending"],
488
+ to: "cancelled_by_us",
489
+ by: ["host"],
490
+ final: true,
491
+ },
492
+ { from: "booked", to: "moved", by: ["staff"], final: true },
493
+ ],
494
+ },
495
+ // A place on the class while held, booked, attended or a no-show (ADR 0501).
496
+ claims: { on: "class", held: ["pending"], confirmed: ["booked", "attended", "no_show"] },
497
+ unique: [{ fields: ["person", "class"], states: ACTIVE }],
498
+ // A spender of the Memberships pack's holders (stage 32b's ids, spec 32): booked spends,
499
+ // an in-time cancel, a class the gym cancels and a move give back; a late cancel and a
500
+ // no-show keep it. The period is the class's, and its type and local time are what a
501
+ // membership's limits read (ADRs 0493 and 0494).
502
+ allowance: {
503
+ spends: {
504
+ person: "person",
505
+ holder: "holder",
506
+ spendIn: ["booked"],
507
+ returnIn: ["cancelled", "excused", "cancelled_by_us", "moved"],
508
+ at: "class.startsAt",
509
+ copy: { classType: "class.classType" },
510
+ local: { weekday: "weekday", minute: "minute", zone: "class.timezone" },
511
+ movedFrom: { field: "movedFrom", state: "moved" },
512
+ paidBy: ["memberships.membership", "memberships.pass"],
513
+ waived: "paidOtherwise",
514
+ },
515
+ },
516
+ // A member reads and changes only their own bookings; never anyone else's (decision 13).
517
+ customer: {
518
+ field: "person",
519
+ read: ["class", "state", "holder", "classType"],
520
+ write: ["class", "state", "holder"],
521
+ // Which class and which holder are chosen when it is made, never after (ADR 0507).
522
+ createOnly: ["class", "holder"],
523
+ },
524
+ timelineLinks: ["person"],
525
+ indexes: [["class", "state"], ["person", "state"], ["state"]],
526
+ },
527
+ },
528
+ views: {
529
+ todaysClasses: {
530
+ label: "Today's classes",
531
+ object: "bookings.class",
532
+ filter: {
533
+ and: [
534
+ { field: "startsAt", op: "gte", value: { $relative: "today" } },
535
+ { field: "startsAt", op: "lt", value: { $relative: "tomorrow" } },
536
+ ],
537
+ },
538
+ sort: { field: "startsAt", direction: "asc" },
539
+ columns: ["title", "startsAt", "coach", "room", "places", "taken", "available", "state"],
540
+ },
541
+ thisWeeksClasses: {
542
+ label: "This week's classes",
543
+ object: "bookings.class",
544
+ filter: {
545
+ and: [
546
+ { field: "startsAt", op: "gte", value: { $relative: "startOfWeek" } },
547
+ { field: "startsAt", op: "lt", value: { $relative: "startOfNextWeek" } },
548
+ ],
549
+ },
550
+ sort: { field: "startsAt", direction: "asc" },
551
+ columns: ["title", "startsAt", "coach", "room", "taken", "available", "state"],
552
+ },
553
+ activeSeries: {
554
+ label: "Timetable",
555
+ object: "bookings.series",
556
+ filter: { field: "state", op: "eq", value: "active" },
557
+ sort: { field: "time", direction: "asc" },
558
+ columns: ["title", "weekdays", "time", "length", "coach", "room", "places", "firstDate"],
559
+ },
560
+ lateCancels: {
561
+ label: "Late cancels",
562
+ object: "bookings.booking",
563
+ filter: { field: "state", op: "eq", value: "late_cancelled" },
564
+ sort: { field: "updatedAt", direction: "desc" },
565
+ columns: ["title", "class", "person", "updatedAt"],
566
+ },
567
+ },
568
+ recordTabs: {
569
+ // A class's list: who is booked, on its record page.
570
+ classBookings: {
571
+ label: "Bookings",
572
+ on: "bookings.class",
573
+ view: {
574
+ type: "table",
575
+ object: "bookings.booking",
576
+ relation: "class",
577
+ columns: ["person", "state", "holder", "paidOtherwise", "bookedBy", "createdAt"],
578
+ sort: { field: "createdAt", direction: "asc" },
579
+ },
580
+ order: 10,
581
+ },
582
+ seriesClasses: {
583
+ label: "Classes",
584
+ on: "bookings.series",
585
+ view: {
586
+ type: "table",
587
+ object: "bookings.class",
588
+ relation: "series",
589
+ columns: ["startsAt", "coach", "room", "places", "taken", "state", "changed"],
590
+ sort: { field: "startsAt", direction: "asc" },
591
+ },
592
+ order: 10,
593
+ },
594
+ personBookings: {
595
+ label: "Bookings",
596
+ on: "person",
597
+ view: {
598
+ type: "table",
599
+ object: "bookings.booking",
600
+ relation: "person",
601
+ columns: ["class", "state", "holder", "createdAt"],
602
+ sort: { field: "createdAt", direction: "desc" },
603
+ },
604
+ order: 35,
605
+ },
606
+ },
607
+ // The organisation's booking rules, which a class type's own values override. Changed by a
608
+ // person with the extensions permission (Settings → Extensions → Bookings).
609
+ settings: {
610
+ opensDays: {
611
+ type: "number",
612
+ label: "Booking opens (days before)",
613
+ description: "Members may book a class this many days before it, at the same time of day. At most " +
614
+ "56, the timetable's horizon; a class type may open further ahead.",
615
+ default: 7,
616
+ min: 0,
617
+ max: 56,
618
+ personApproves: true,
619
+ },
620
+ closesMinutes: {
621
+ type: "number",
622
+ label: "Booking closes (minutes before)",
623
+ description: "Members may book until this many minutes before a class (0: until it starts).",
624
+ default: 0,
625
+ min: 0,
626
+ max: 10_080,
627
+ personApproves: true,
628
+ },
629
+ lateMinutes: {
630
+ type: "number",
631
+ label: "Late cancel from (minutes before)",
632
+ description: "A cancel this close to the start is late: it keeps the class it used.",
633
+ default: 60,
634
+ min: 0,
635
+ max: 10_080,
636
+ personApproves: true,
637
+ },
638
+ promotionMinutes: {
639
+ type: "number",
640
+ label: "Waitlist stops (minutes before)",
641
+ description: "Nobody is moved in from the waitlist after this (a later release).",
642
+ default: 120,
643
+ min: 0,
644
+ max: 10_080,
645
+ personApproves: true,
646
+ },
647
+ reminderMinutes: {
648
+ type: "number",
649
+ label: "Reminder (minutes before)",
650
+ description: "When members are reminded of a class (a later release).",
651
+ default: 180,
652
+ min: 0,
653
+ max: 10_080,
654
+ personApproves: true,
655
+ },
656
+ },
657
+ tools: {
658
+ timetable,
659
+ classGet,
660
+ book,
661
+ cancel,
662
+ mine,
663
+ findPeople,
664
+ bookFor,
665
+ cancelFor,
666
+ returnUse,
667
+ day,
668
+ classList,
669
+ },
670
+ });