@composable-os/pack-bookings 0.1.0-beta.14 → 0.1.0-beta.16

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.
@@ -17,7 +17,7 @@
17
17
  import { defineAutomation, } from "@composable-os/sdk";
18
18
  const CLASS = "bookings.class";
19
19
  const BOOKING = "bookings.booking";
20
- const CLASS_TYPE = "programs.classtype";
20
+ const CLASS_TYPE = "bookings.classtype";
21
21
  /**
22
22
  * The email-send connection the host sends from: a person binds it to each automation, which is
23
23
  * their consent to the pack's mail going out from that address.
@@ -200,7 +200,7 @@ async function cutOff(ctx, cls) {
200
200
  const type = await ctx.ops
201
201
  .call("record.get", { object: CLASS_TYPE, id: cls.classType })
202
202
  .catch(() => null);
203
- const own = type?.values["bookings.promotionMinutes"] ?? type?.values.promotionMinutes;
203
+ const own = type?.values.promotionMinutes;
204
204
  if (typeof own === "number")
205
205
  minutes = own;
206
206
  }
@@ -65,7 +65,7 @@ WHERE ${IN_PERIOD}`,
65
65
  sql: `SELECT t.id AS type_id, coalesce(t.name, 'No class type') AS type,
66
66
  sum(CASE WHEN b.state = 'attended' THEN 1 ELSE 0 END) AS came,
67
67
  sum(CASE WHEN ${HELD} THEN 1 ELSE 0 END) AS booked
68
- ${BOOKINGS.replace("WHERE", "LEFT JOIN rec_x_programs_classtype t ON t.id = c.class_type WHERE")}
68
+ ${BOOKINGS.replace("WHERE", "LEFT JOIN rec_x_bookings_classtype t ON t.id = c.class_type WHERE")}
69
69
  GROUP BY t.id, t.name ORDER BY came DESC, type LIMIT 20`,
70
70
  mapping: { x: "type", y: ["came", "booked"] },
71
71
  layout: { w: 6, h: 2 },
@@ -111,7 +111,7 @@ ${BOOKINGS} GROUP BY month ORDER BY month`,
111
111
  description: "Bookings that joined a waiting list, and how many were moved in from it, per class type.",
112
112
  sql: `SELECT coalesce(t.name, 'No class type') AS type, count(*) AS joined,
113
113
  sum(CASE WHEN b.promoted_at IS NOT NULL THEN 1 ELSE 0 END) AS got_in
114
- ${BOOKINGS.replace("WHERE", "LEFT JOIN rec_x_programs_classtype t ON t.id = c.class_type WHERE")} AND ${WAITED}
114
+ ${BOOKINGS.replace("WHERE", "LEFT JOIN rec_x_bookings_classtype t ON t.id = c.class_type WHERE")} AND ${WAITED}
115
115
  GROUP BY t.id, t.name ORDER BY joined DESC, type LIMIT 20`,
116
116
  mapping: { columns: ["type", "joined", "got_in"] },
117
117
  layout: { w: 6, h: 2 },
package/dist/index.d.ts CHANGED
@@ -4,101 +4,118 @@ declare const _default: import("@composable-os/sdk").Extension<{
4
4
  readonly contractVersion: 1;
5
5
  readonly label: "Bookings";
6
6
  readonly description: string;
7
- readonly requires: readonly ["programs"];
8
7
  readonly permissions: {
9
- readonly read: ["person", "programs.classtype"];
8
+ readonly read: ["person"];
10
9
  readonly write: ["person"];
11
10
  readonly operations: ["order.startHeld", "public.list", "public.get", "capacity.get", "duplicate.check", "waitlist.position", "me.family", "person.link.list", "order.get", "extensionSettings.list", "notification.send", "agreement.listHealthNotes", "staffing.free", "staffing.week"];
12
11
  readonly modules: ["ops", "routine-mail", "email-send", "storage"];
13
12
  };
14
- readonly fields: {
15
- readonly "programs.classtype": {
16
- readonly colour: {
17
- readonly type: "text";
18
- readonly label: "Colour";
19
- readonly description: "How its classes show on the timetable, e.g. #2f6fed.";
20
- };
21
- readonly opensDays: {
22
- readonly type: "number";
23
- readonly label: "Booking opens (days before)";
24
- readonly description: string;
25
- readonly min: 0;
26
- readonly max: 365;
27
- readonly step: 1;
28
- readonly personApproves: true;
29
- };
30
- readonly closesMinutes: {
31
- type: "number";
32
- label: string;
33
- description: string;
34
- min: number;
35
- max: number;
36
- step: number;
37
- personApproves: boolean;
38
- };
39
- readonly lateMinutes: {
40
- type: "number";
41
- label: string;
42
- description: string;
43
- min: number;
44
- max: number;
45
- step: number;
46
- personApproves: boolean;
47
- };
48
- readonly promotionMinutes: {
49
- type: "number";
50
- label: string;
51
- description: string;
52
- min: number;
53
- max: number;
54
- step: number;
55
- personApproves: boolean;
56
- };
57
- readonly reminderMinutes: {
58
- readonly max: 2880;
59
- readonly type: "number";
60
- readonly label: string;
61
- readonly description: string;
62
- readonly min: number;
63
- readonly step: number;
64
- readonly personApproves: boolean;
65
- };
66
- readonly dropInPrice: {
67
- readonly type: "number";
68
- readonly label: "Drop-in price";
69
- readonly description: string;
70
- readonly min: 0;
71
- readonly max: 100000;
72
- readonly step: 0.01;
73
- readonly personApproves: true;
74
- };
75
- readonly staffOnly: {
76
- readonly type: "boolean";
77
- readonly label: "Booked by staff only";
78
- readonly description: "Members cannot book its classes themselves; staff book them in.";
79
- readonly personApproves: true;
80
- };
81
- readonly rosterBeforeMinutes: {
82
- readonly type: "number";
83
- readonly label: "Set-up minutes (pay)";
84
- readonly description: string;
85
- readonly min: 0;
86
- readonly max: 240;
87
- readonly step: 1;
88
- readonly personApproves: true;
89
- };
90
- readonly rosterAfterMinutes: {
91
- readonly type: "number";
92
- readonly label: "Pack-down minutes (pay)";
93
- readonly description: string;
94
- readonly min: 0;
95
- readonly max: 240;
96
- readonly step: 1;
97
- readonly personApproves: true;
13
+ readonly objects: {
14
+ readonly classtype: {
15
+ readonly label: "Class type";
16
+ readonly plural: "Class types";
17
+ readonly icon: "users";
18
+ readonly titleField: "name";
19
+ readonly description: string;
20
+ readonly navigation: "settings";
21
+ readonly signedIn: {
22
+ readonly read: readonly ["name", "order"];
23
+ };
24
+ readonly fields: {
25
+ readonly name: {
26
+ readonly type: "text";
27
+ readonly label: "Name";
28
+ readonly required: true;
29
+ };
30
+ readonly order: {
31
+ readonly type: "number";
32
+ readonly label: "Order";
33
+ };
34
+ readonly colour: {
35
+ readonly type: "text";
36
+ readonly label: "Colour";
37
+ readonly description: "How its classes show on the timetable, e.g. #2f6fed.";
38
+ };
39
+ readonly opensDays: {
40
+ readonly type: "number";
41
+ readonly label: "Booking opens (days before)";
42
+ readonly description: string;
43
+ readonly min: 0;
44
+ readonly max: 365;
45
+ readonly step: 1;
46
+ readonly personApproves: true;
47
+ };
48
+ readonly closesMinutes: {
49
+ type: "number";
50
+ label: string;
51
+ description: string;
52
+ min: number;
53
+ max: number;
54
+ step: number;
55
+ personApproves: boolean;
56
+ };
57
+ readonly lateMinutes: {
58
+ type: "number";
59
+ label: string;
60
+ description: string;
61
+ min: number;
62
+ max: number;
63
+ step: number;
64
+ personApproves: boolean;
65
+ };
66
+ readonly promotionMinutes: {
67
+ type: "number";
68
+ label: string;
69
+ description: string;
70
+ min: number;
71
+ max: number;
72
+ step: number;
73
+ personApproves: boolean;
74
+ };
75
+ readonly reminderMinutes: {
76
+ readonly max: 2880;
77
+ readonly type: "number";
78
+ readonly label: string;
79
+ readonly description: string;
80
+ readonly min: number;
81
+ readonly step: number;
82
+ readonly personApproves: boolean;
83
+ };
84
+ readonly dropInPrice: {
85
+ readonly type: "number";
86
+ readonly label: "Drop-in price";
87
+ readonly description: string;
88
+ readonly min: 0;
89
+ readonly max: 100000;
90
+ readonly step: 0.01;
91
+ readonly personApproves: true;
92
+ };
93
+ readonly staffOnly: {
94
+ readonly type: "boolean";
95
+ readonly label: "Booked by staff only";
96
+ readonly description: "Members cannot book its classes themselves; staff book them in.";
97
+ readonly personApproves: true;
98
+ };
99
+ readonly rosterBeforeMinutes: {
100
+ readonly type: "number";
101
+ readonly label: "Set-up minutes (pay)";
102
+ readonly description: string;
103
+ readonly min: 0;
104
+ readonly max: 240;
105
+ readonly step: 1;
106
+ readonly personApproves: true;
107
+ };
108
+ readonly rosterAfterMinutes: {
109
+ readonly type: "number";
110
+ readonly label: "Pack-down minutes (pay)";
111
+ readonly description: string;
112
+ readonly min: 0;
113
+ readonly max: 240;
114
+ readonly step: 1;
115
+ readonly personApproves: true;
116
+ };
98
117
  };
99
118
  };
100
- };
101
- readonly objects: {
102
119
  readonly room: {
103
120
  readonly label: "Room";
104
121
  readonly plural: "Rooms";
@@ -192,7 +209,7 @@ declare const _default: import("@composable-os/sdk").Extension<{
192
209
  readonly classType: {
193
210
  readonly type: "relation";
194
211
  readonly label: "Class type";
195
- readonly to: "programs.classtype";
212
+ readonly to: "bookings.classtype";
196
213
  readonly required: true;
197
214
  };
198
215
  readonly weekdays: {
@@ -309,7 +326,7 @@ declare const _default: import("@composable-os/sdk").Extension<{
309
326
  };
310
327
  readonly horizonDays: 57;
311
328
  readonly horizonAtLeast: {
312
- readonly object: "programs.classtype";
329
+ readonly object: "classtype";
313
330
  readonly field: "opensDays";
314
331
  };
315
332
  };
@@ -341,7 +358,7 @@ declare const _default: import("@composable-os/sdk").Extension<{
341
358
  readonly classType: {
342
359
  readonly type: "relation";
343
360
  readonly label: "Class type";
344
- readonly to: "programs.classtype";
361
+ readonly to: "bookings.classtype";
345
362
  readonly required: true;
346
363
  };
347
364
  readonly startsAt: {
@@ -556,7 +573,7 @@ declare const _default: import("@composable-os/sdk").Extension<{
556
573
  readonly classType: {
557
574
  readonly type: "relation";
558
575
  readonly label: "Class type";
559
- readonly to: "programs.classtype";
576
+ readonly to: "bookings.classtype";
560
577
  readonly readOnly: true;
561
578
  readonly description: "The class's type, copied by the host: what a membership's limits read.";
562
579
  };
package/dist/index.js CHANGED
@@ -178,13 +178,10 @@ export default defineExtension({
178
178
  contractVersion: 1,
179
179
  label: "Bookings",
180
180
  description: "A timetable of classes made from weekly series, rooms and coaches, and the bookings members " +
181
- "make and cancel within the gym's rules. Class types are Programs'.",
182
- // The class type is Programs' (spec 31): the host installs Bookings only beside Programs.
183
- requires: ["programs"],
181
+ "make and cancel within the gym's rules, by class type.",
184
182
  permissions: {
185
183
  // person.get / person.createWith: a booking's person on a class list, and a walk-in staff book.
186
- // programs.classtype: a class type's name and booking rules on staff's day view.
187
- read: ["person", "programs.classtype"],
184
+ read: ["person"],
188
185
  write: ["person"],
189
186
  // record.*, my.* and state.resolve are not listed: they are granted by object (Bookings'
190
187
  // own, and the read and write lists above), and a listed one would reach every object.
@@ -222,78 +219,93 @@ export default defineExtension({
222
219
  ],
223
220
  modules: ["ops", "routine-mail", "email-send", "storage"],
224
221
  },
225
- // Bookings' fields on Programs' class type: how it shows, and its booking rules when they
226
- // differ from the organisation's (Settings → Extensions → Bookings). Empty: the organisation's.
227
- fields: {
228
- "programs.classtype": {
229
- colour: {
230
- type: "text",
231
- label: "Colour",
232
- description: "How its classes show on the timetable, e.g. #2f6fed.",
233
- },
234
- opensDays: {
235
- type: "number",
236
- label: "Booking opens (days before)",
237
- description: "Members may book this many days before a class, at the same time of day. Empty: the " +
238
- "organisation's setting.",
239
- min: 0,
240
- max: 365,
241
- step: 1,
242
- personApproves: true,
243
- },
244
- closesMinutes: minutes("Booking closes (minutes before)", "Members may book until this many minutes before a class starts (0: until it starts). " +
245
- "Empty: the organisation's setting."),
246
- 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: " +
247
- "the organisation's setting."),
248
- promotionMinutes: minutes("Waitlist stops (minutes before)", "Nobody is moved in from the waitlist after this: a place freed later goes to whoever " +
249
- "books first. Empty: the organisation's setting."),
250
- reminderMinutes: {
251
- ...minutes("Reminder (minutes before)", "When members booked into a class are emailed a reminder, at most two days before. " +
222
+ objects: {
223
+ // A kind of class (stage 78, ADR 0980): what a series and its classes are of, how it shows,
224
+ // and its booking rules when they differ from the organisation's (Settings → Extensions →
225
+ // Bookings; empty: the organisation's). It was Programs' object, with these rules added onto
226
+ // it by Bookings; it is Bookings' own so that Bookings installs without Programs. Programs,
227
+ // a domain pack, relates its class programs to it.
228
+ classtype: {
229
+ label: "Class type",
230
+ plural: "Class types",
231
+ icon: "users",
232
+ titleField: "name",
233
+ description: "A kind of class (Strength, Yoga, Kids): what a series and its classes are of, with its " +
234
+ "booking rules when they differ from the organisation's.",
235
+ navigation: "settings",
236
+ // Every signed-in member reads a class type's name and order (a class program assigned to
237
+ // it, a member's timetable); its rules are read through the class by the host.
238
+ signedIn: { read: ["name", "order"] },
239
+ fields: {
240
+ name: { type: "text", label: "Name", required: true },
241
+ order: { type: "number", label: "Order" },
242
+ colour: {
243
+ type: "text",
244
+ label: "Colour",
245
+ description: "How its classes show on the timetable, e.g. #2f6fed.",
246
+ },
247
+ opensDays: {
248
+ type: "number",
249
+ label: "Booking opens (days before)",
250
+ description: "Members may book this many days before a class, at the same time of day. Empty: the " +
251
+ "organisation's setting.",
252
+ min: 0,
253
+ max: 365,
254
+ step: 1,
255
+ personApproves: true,
256
+ },
257
+ closesMinutes: minutes("Booking closes (minutes before)", "Members may book until this many minutes before a class starts (0: until it starts). " +
252
258
  "Empty: the organisation's setting."),
253
- // At most two days: the reminder's minute scan reads the classes this far ahead (ADR 0570).
254
- max: 2_880,
255
- },
256
- dropInPrice: {
257
- type: "number",
258
- label: "Drop-in price",
259
- description: "What one class costs someone paying for it on the website, in the organisation's " +
260
- "currency. Empty: the organisation's setting; empty there too, no drop-ins.",
261
- min: 0,
262
- max: 100_000,
263
- step: 0.01,
264
- personApproves: true,
265
- },
266
- staffOnly: {
267
- type: "boolean",
268
- label: "Booked by staff only",
269
- description: "Members cannot book its classes themselves; staff book them in.",
270
- personApproves: true,
271
- },
272
- // Preparation and pack-down (stage 45 decision 19, ADR 0627): minutes added to the coach's
273
- // pay hours for each class of this type. Pay only: they never make two classes clash.
274
- rosterBeforeMinutes: {
275
- type: "number",
276
- label: "Set-up minutes (pay)",
277
- description: "Minutes before each class counted in its coach's pay hours (set-up). Empty: none. " +
278
- "They never stop a coach taking the class before.",
279
- min: 0,
280
- max: 240,
281
- step: 1,
282
- personApproves: true,
283
- },
284
- rosterAfterMinutes: {
285
- type: "number",
286
- label: "Pack-down minutes (pay)",
287
- description: "Minutes after each class counted in its coach's pay hours (pack-down). Empty: none. " +
288
- "They never stop a coach taking the class after.",
289
- min: 0,
290
- max: 240,
291
- step: 1,
292
- personApproves: true,
259
+ 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: " +
260
+ "the organisation's setting."),
261
+ promotionMinutes: minutes("Waitlist stops (minutes before)", "Nobody is moved in from the waitlist after this: a place freed later goes to whoever " +
262
+ "books first. Empty: the organisation's setting."),
263
+ reminderMinutes: {
264
+ ...minutes("Reminder (minutes before)", "When members booked into a class are emailed a reminder, at most two days before. " +
265
+ "Empty: the organisation's setting."),
266
+ // At most two days: the reminder's minute scan reads the classes this far ahead (ADR 0570).
267
+ max: 2_880,
268
+ },
269
+ dropInPrice: {
270
+ type: "number",
271
+ label: "Drop-in price",
272
+ description: "What one class costs someone paying for it on the website, in the organisation's " +
273
+ "currency. Empty: the organisation's setting; empty there too, no drop-ins.",
274
+ min: 0,
275
+ max: 100_000,
276
+ step: 0.01,
277
+ personApproves: true,
278
+ },
279
+ staffOnly: {
280
+ type: "boolean",
281
+ label: "Booked by staff only",
282
+ description: "Members cannot book its classes themselves; staff book them in.",
283
+ personApproves: true,
284
+ },
285
+ // Preparation and pack-down (stage 45 decision 19, ADR 0627): minutes added to the coach's
286
+ // pay hours for each class of this type. Pay only: they never make two classes clash.
287
+ rosterBeforeMinutes: {
288
+ type: "number",
289
+ label: "Set-up minutes (pay)",
290
+ description: "Minutes before each class counted in its coach's pay hours (set-up). Empty: none. " +
291
+ "They never stop a coach taking the class before.",
292
+ min: 0,
293
+ max: 240,
294
+ step: 1,
295
+ personApproves: true,
296
+ },
297
+ rosterAfterMinutes: {
298
+ type: "number",
299
+ label: "Pack-down minutes (pay)",
300
+ description: "Minutes after each class counted in its coach's pay hours (pack-down). Empty: none. " +
301
+ "They never stop a coach taking the class after.",
302
+ min: 0,
303
+ max: 240,
304
+ step: 1,
305
+ personApproves: true,
306
+ },
293
307
  },
294
308
  },
295
- },
296
- objects: {
297
309
  room: {
298
310
  label: "Room",
299
311
  plural: "Rooms",
@@ -361,7 +373,7 @@ export default defineExtension({
361
373
  classType: {
362
374
  type: "relation",
363
375
  label: "Class type",
364
- to: "programs.classtype",
376
+ to: "bookings.classtype",
365
377
  required: true,
366
378
  },
367
379
  weekdays: { type: "multiSelect", label: "Weekdays", options: WEEKDAYS, required: true },
@@ -428,7 +440,7 @@ export default defineExtension({
428
440
  // when its booking opens, so one day more (as horizonAtLeast adds for a class type's).
429
441
  horizonDays: 57,
430
442
  // Never less than the longest window a class type opens booking (ADR 0500, 0505).
431
- horizonAtLeast: { object: "programs.classtype", field: "opensDays" },
443
+ horizonAtLeast: { object: "classtype", field: "opensDays" },
432
444
  },
433
445
  indexes: [["state"], ["classType"]],
434
446
  },
@@ -454,7 +466,7 @@ export default defineExtension({
454
466
  classType: {
455
467
  type: "relation",
456
468
  label: "Class type",
457
- to: "programs.classtype",
469
+ to: "bookings.classtype",
458
470
  required: true,
459
471
  },
460
472
  startsAt: { type: "datetime", label: "Starts", required: true },
@@ -608,10 +620,15 @@ export default defineExtension({
608
620
  description: "The membership or pass the booking spent a use of (its id). Left empty, the host " +
609
621
  "chooses the one whose use would lapse first.",
610
622
  },
623
+ // Read-only does a second thing: routine mail's tie to the run's record ignores a read-only
624
+ // relation (ADRs 0590 and 0980), so two bookings sharing only a class type never tie. The
625
+ // tie that matters is `class` (the place-free mail goes about another booking of the same
626
+ // class); marking `class` read-only would silently refuse that mail
627
+ // (apps/runner/test/routine-mail.test.ts).
611
628
  classType: {
612
629
  type: "relation",
613
630
  label: "Class type",
614
- to: "programs.classtype",
631
+ to: "bookings.classtype",
615
632
  readOnly: true,
616
633
  description: "The class's type, copied by the host: what a membership's limits read.",
617
634
  },
package/dist/tools.js CHANGED
@@ -8,7 +8,7 @@ const CLASS = "bookings.class";
8
8
  const BOOKING = "bookings.booking";
9
9
  const COACH = "bookings.coach";
10
10
  const ROOM = "bookings.room";
11
- const CLASS_TYPE = "programs.classtype";
11
+ const CLASS_TYPE = "bookings.classtype";
12
12
  const text = (value) => value === null || value === undefined || value === "" ? null : String(value);
13
13
  const num = (value) => typeof value === "number" ? value : value == null || value === "" ? null : Number(value);
14
14
  const flag = (value) => value === true || value === 1 || value === "1";
@@ -1077,8 +1077,7 @@ async function staffClasses(ctx, classes) {
1077
1077
  held: num(v.held) ?? 0,
1078
1078
  available: num(v.available),
1079
1079
  state: text(v.state),
1080
- // Bookings' own field on Programs' class type (registry name `bookings.staffOnly`).
1081
- staffOnly: flag(type?.["bookings.staffOnly"] ?? type?.staffOnly),
1080
+ staffOnly: flag(type?.staffOnly),
1082
1081
  };
1083
1082
  });
1084
1083
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@composable-os/pack-bookings",
3
- "version": "0.1.0-beta.14",
3
+ "version": "0.1.0-beta.16",
4
4
  "license": "FSL-1.1-ALv2",
5
5
  "type": "module",
6
6
  "repository": {
@@ -12,7 +12,7 @@
12
12
  "access": "public",
13
13
  "provenance": true
14
14
  },
15
- "description": "Bookings: a gym's or studio's timetable (weekly series that make dated classes in local time), rooms, coaches, closures, and the bookings members make and cancel within the class type's rules, spending a membership's or pass's use (stage 31a). Requires Programs. Installed in every deployment of a product that lists it. Bundled as source into cos-runner.",
15
+ "description": "Bookings: a gym's or studio's timetable (weekly series that make dated classes in local time), rooms, coaches, closures, and the bookings members make and cancel within the class type's rules, spending a membership's or pass's use (stage 31a). Its class types are its own (stage 78). Installed in every deployment of a product that lists it. Bundled as source into cos-runner.",
16
16
  "exports": {
17
17
  ".": {
18
18
  "types": "./dist/index.d.ts",
@@ -29,10 +29,10 @@
29
29
  "composableOs": {
30
30
  "optional": true,
31
31
  "label": "Bookings",
32
- "description": "A timetable of classes made from weekly series, booked and cancelled by members on the web and in the app within the gym's rules. Requires Programs."
32
+ "description": "A timetable of classes made from weekly series, booked and cancelled by members on the web and in the app within the gym's rules."
33
33
  },
34
34
  "dependencies": {
35
- "@composable-os/client": "0.1.0-beta.14",
36
- "@composable-os/sdk": "0.1.0-beta.14"
35
+ "@composable-os/client": "0.1.0-beta.16",
36
+ "@composable-os/sdk": "0.1.0-beta.16"
37
37
  }
38
38
  }