@composable-os/pack-memberships 0.1.0-beta.11 → 0.1.0-beta.13
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/blocks/memberships-mine/mine.d.ts +6 -4
- package/dist/blocks/memberships-mine/mine.js +66 -34
- package/dist/blocks/memberships-native-mine/mine-screen.d.ts +6 -2
- package/dist/blocks/memberships-native-mine/mine-screen.js +30 -6
- package/dist/blocks/memberships-passes/passes.d.ts +6 -1
- package/dist/blocks/memberships-passes/passes.js +75 -8
- package/dist/blocks/memberships-plans/plans.d.ts +6 -1
- package/dist/blocks/memberships-plans/plans.js +71 -6
- package/dist/blocks/memberships-staff-holdings/holdings.d.ts +9 -0
- package/dist/blocks/memberships-staff-holdings/holdings.js +15 -0
- package/dist/client/index.d.ts +338 -27
- package/dist/client/index.js +157 -6
- package/dist/index.d.ts +218 -20
- package/dist/index.js +173 -27
- package/dist/tools.d.ts +1 -4
- package/dist/tools.js +28 -20
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -21,6 +21,9 @@
|
|
|
21
21
|
// (`recurring.pause`): the host's `subscription.change` and `subscription.pause`, asked of the
|
|
22
22
|
// provider, followed from its verified events (ADRs 0530, 0531). The membership's terms follow
|
|
23
23
|
// the plan when the change takes effect; while paused it gives and spends nothing;
|
|
24
|
+
// - a new member may end their membership in the business's cooling-off period
|
|
25
|
+
// (`recurring.coolingOff`, the `coolingOffDays` setting, ADR 0647): the host's
|
|
26
|
+
// `subscription.coolOff`, every paid period owed back, each refund approved by a person;
|
|
24
27
|
// - every term of a membership or a pass is read-only: only the host (and this pack's own staff
|
|
25
28
|
// tools, which a person calls) writes it, never a caller of the generic record operations.
|
|
26
29
|
// The tools in tools.ts compose the host's operations and hold no rule of their own.
|
|
@@ -37,17 +40,58 @@ const WEEKDAYS = [
|
|
|
37
40
|
{ value: "6", label: "Saturday" },
|
|
38
41
|
{ value: "7", label: "Sunday" },
|
|
39
42
|
];
|
|
43
|
+
const PER = [
|
|
44
|
+
{ value: "week", label: "A week" },
|
|
45
|
+
{ value: "month", label: "A month" },
|
|
46
|
+
];
|
|
47
|
+
/**
|
|
48
|
+
* Gym dues (the provider's "Fitness Centers - Dues and Membership Fees"): taxed only once a human
|
|
49
|
+
* admin turns tax on (ADR 0479). Whether the provider needs the gym's address as the place is an
|
|
50
|
+
* open check of the test-mode runbook.
|
|
51
|
+
*/
|
|
52
|
+
const GYM_DUES = { code: "txcd_50021001" };
|
|
53
|
+
/**
|
|
54
|
+
* Where agreement may be needed (stage 44, ADR 0641): the business attaches its documents (its
|
|
55
|
+
* terms, a waiver) to "membership"; nothing is needed until it does. The plans and passes blocks
|
|
56
|
+
* show what is due and let a person agree (stage 44 step 5).
|
|
57
|
+
*/
|
|
58
|
+
const BUYING = {
|
|
59
|
+
point: "membership",
|
|
60
|
+
label: "Buying a membership or a pass",
|
|
61
|
+
suggests: ["terms", "waiver", "health", "guardian"],
|
|
62
|
+
};
|
|
40
63
|
const ON_SALE = [
|
|
41
64
|
{ value: "draft", label: "Draft" },
|
|
42
65
|
{ value: "on_sale", label: "On sale" },
|
|
43
66
|
{ value: "retired", label: "No longer sold" },
|
|
44
67
|
];
|
|
68
|
+
/** What a plan or a pass type pays for: classes, one-to-one sessions (stage 49), or both. */
|
|
69
|
+
const COVERS = [
|
|
70
|
+
{ value: "classes", label: "Classes" },
|
|
71
|
+
{ value: "sessions", label: "One-to-one sessions" },
|
|
72
|
+
];
|
|
45
73
|
/**
|
|
46
|
-
* What a plan or a pass type allows, copied onto the membership or the pass it grants:
|
|
47
|
-
*
|
|
48
|
-
*
|
|
74
|
+
* What a plan or a pass type allows, copied onto the membership or the pass it grants: what it
|
|
75
|
+
* pays for (empty: classes only, as before sessions existed), the class types (empty: every one)
|
|
76
|
+
* and the services (empty: every one) it pays for, weekdays (empty: every day) and a time of day,
|
|
77
|
+
* in minutes after local midnight (empty: no bound).
|
|
49
78
|
*/
|
|
50
79
|
const limits = (readOnly) => ({
|
|
80
|
+
covers: {
|
|
81
|
+
type: "multiSelect",
|
|
82
|
+
label: "Pays for",
|
|
83
|
+
options: COVERS,
|
|
84
|
+
description: "Classes, one-to-one sessions (Bookings' appointments), or both. Empty: classes only.",
|
|
85
|
+
...(readOnly ? { readOnly: true } : {}),
|
|
86
|
+
},
|
|
87
|
+
services: {
|
|
88
|
+
type: "relation",
|
|
89
|
+
label: "Services",
|
|
90
|
+
to: "bookings.service",
|
|
91
|
+
many: true,
|
|
92
|
+
description: "The one-to-one sessions it pays for, when it pays for sessions. Empty: every one.",
|
|
93
|
+
...(readOnly ? { readOnly: true } : {}),
|
|
94
|
+
},
|
|
51
95
|
classTypes: {
|
|
52
96
|
type: "relation",
|
|
53
97
|
label: "Class types",
|
|
@@ -86,15 +130,33 @@ const limits = (readOnly) => ({
|
|
|
86
130
|
* What a holder pays for: stage 31's bookings (`bookings.booking`, whose `paidBy` lists this pack),
|
|
87
131
|
* by the class type, the local weekday and the local minute the host copies onto the booking.
|
|
88
132
|
*/
|
|
89
|
-
const
|
|
133
|
+
const SPENDS_ON_CLASSES = {
|
|
90
134
|
object: "bookings.booking",
|
|
91
135
|
when: [
|
|
136
|
+
// A booking is a class: paid for unless the holder pays for sessions only (empty: classes).
|
|
137
|
+
{ value: "classes", in: "covers" },
|
|
92
138
|
{ field: "classType", in: "classTypes" },
|
|
93
139
|
{ field: "weekday", in: "weekdays" },
|
|
94
140
|
{ field: "minute", atLeast: "fromMinute" },
|
|
95
141
|
{ field: "minute", below: "untilMinute" },
|
|
96
142
|
],
|
|
97
143
|
};
|
|
144
|
+
/**
|
|
145
|
+
* Stage 49's appointments (`bookings.appointment`, whose `paidBy` lists this pack), by the service
|
|
146
|
+
* the host copies onto the appointment and its local weekday and minute. Only a holder that says
|
|
147
|
+
* it pays for sessions does (`empty: "none"`): a class pass never pays for a session (ADR 0764).
|
|
148
|
+
*/
|
|
149
|
+
const SPENDS_ON_SESSIONS = {
|
|
150
|
+
object: "bookings.appointment",
|
|
151
|
+
when: [
|
|
152
|
+
{ value: "sessions", in: "covers", empty: "none" },
|
|
153
|
+
{ field: "serviceId", in: "services" },
|
|
154
|
+
{ field: "weekday", in: "weekdays" },
|
|
155
|
+
{ field: "minute", atLeast: "fromMinute" },
|
|
156
|
+
{ field: "minute", below: "untilMinute" },
|
|
157
|
+
],
|
|
158
|
+
};
|
|
159
|
+
const SPENDS_ON = [SPENDS_ON_CLASSES, SPENDS_ON_SESSIONS];
|
|
98
160
|
const RUNNING = ["trialing", "active", "past_due", "unpaid", "paused"];
|
|
99
161
|
/** A membership follows its subscription: the host moves it from any running state to another. */
|
|
100
162
|
const followMoves = [
|
|
@@ -112,20 +174,16 @@ export default defineExtension({
|
|
|
112
174
|
label: "Memberships",
|
|
113
175
|
description: "Membership plans paid every month and class passes bought once, with what each allows " +
|
|
114
176
|
"and what a member has left.",
|
|
115
|
-
// A plan and a pass name the class types they pay for: Programs' (stage 31 extends them)
|
|
116
|
-
|
|
177
|
+
// A plan and a pass name the class types they pay for: Programs' (stage 31 extends them); and
|
|
178
|
+
// the services (Bookings' one-to-one sessions, stage 49), so Bookings is installed first. What
|
|
179
|
+
// they pay for, classes and sessions, is Bookings' anyway.
|
|
180
|
+
requires: ["programs", "bookings"],
|
|
117
181
|
permissions: {
|
|
118
182
|
read: ["person", "programs.classtype"],
|
|
183
|
+
// record.* and my.* are not listed: they are granted by object (Memberships' own, and the
|
|
184
|
+
// read list above), and a listed one would reach every object.
|
|
119
185
|
operations: [
|
|
120
186
|
"public.list",
|
|
121
|
-
"public.get",
|
|
122
|
-
"my.list",
|
|
123
|
-
"my.get",
|
|
124
|
-
"record.create",
|
|
125
|
-
"record.update",
|
|
126
|
-
"record.get",
|
|
127
|
-
"record.list",
|
|
128
|
-
"allowance.get",
|
|
129
187
|
"allowance.list",
|
|
130
188
|
"order.start",
|
|
131
189
|
// The member's own id and the children staff linked to them (ADR 0540).
|
|
@@ -165,10 +223,7 @@ export default defineExtension({
|
|
|
165
223
|
label: "Per",
|
|
166
224
|
required: true,
|
|
167
225
|
default: "week",
|
|
168
|
-
options:
|
|
169
|
-
{ value: "week", label: "A week" },
|
|
170
|
-
{ value: "month", label: "A month" },
|
|
171
|
-
],
|
|
226
|
+
options: PER,
|
|
172
227
|
},
|
|
173
228
|
...limits(false),
|
|
174
229
|
trialDays: {
|
|
@@ -215,16 +270,18 @@ export default defineExtension({
|
|
|
215
270
|
},
|
|
216
271
|
sellable: {
|
|
217
272
|
price: "price",
|
|
218
|
-
|
|
219
|
-
//
|
|
220
|
-
|
|
221
|
-
tax: { code: "txcd_50021001" },
|
|
273
|
+
tax: GYM_DUES,
|
|
274
|
+
// In the finance reports (ADR 0792): a paid period is earned day by day over it.
|
|
275
|
+
finance: { category: { key: "memberships", label: "Memberships" }, earned: "over_period" },
|
|
222
276
|
recurring: {
|
|
223
277
|
interval: "month",
|
|
224
278
|
trialDays: "trialDays",
|
|
225
279
|
// Staff pause a membership for a set time (decision 10, ADR 0531): nothing charged, no
|
|
226
280
|
// classes, until the provider resumes it on its date.
|
|
227
281
|
pause: { minDays: "pauseMinDays", maxDays: "pauseMaxDays" },
|
|
282
|
+
// A new member may end it within the business's cooling-off days for a full refund,
|
|
283
|
+
// each refund approved by a person (stage 44 step 7, decision 11, ADR 0647).
|
|
284
|
+
coolingOff: { setting: "coolingOffDays" },
|
|
228
285
|
// What a subscription to it gives its holder, kept in step by the host (ADR 0510).
|
|
229
286
|
grants: {
|
|
230
287
|
object: "membership",
|
|
@@ -236,6 +293,8 @@ export default defineExtension({
|
|
|
236
293
|
title: "item.title",
|
|
237
294
|
uses: "item.uses",
|
|
238
295
|
per: "item.per",
|
|
296
|
+
covers: "item.covers",
|
|
297
|
+
services: "item.services",
|
|
239
298
|
classTypes: "item.classTypes",
|
|
240
299
|
weekdays: "item.weekdays",
|
|
241
300
|
fromMinute: "item.fromMinute",
|
|
@@ -254,6 +313,8 @@ export default defineExtension({
|
|
|
254
313
|
},
|
|
255
314
|
},
|
|
256
315
|
},
|
|
316
|
+
// The host asks when a subscription to a plan or an order for a pass type starts (ADR 0644).
|
|
317
|
+
agreements: { ...BUYING, inlineStep: true },
|
|
257
318
|
},
|
|
258
319
|
membership: {
|
|
259
320
|
label: "Membership",
|
|
@@ -282,10 +343,7 @@ export default defineExtension({
|
|
|
282
343
|
type: "select",
|
|
283
344
|
label: "Per",
|
|
284
345
|
readOnly: true,
|
|
285
|
-
options:
|
|
286
|
-
{ value: "week", label: "A week" },
|
|
287
|
-
{ value: "month", label: "A month" },
|
|
288
|
-
],
|
|
346
|
+
options: PER,
|
|
289
347
|
},
|
|
290
348
|
...limits(true),
|
|
291
349
|
from: { type: "datetime", label: "From", readOnly: true },
|
|
@@ -404,7 +462,7 @@ export default defineExtension({
|
|
|
404
462
|
},
|
|
405
463
|
sellable: {
|
|
406
464
|
price: "price",
|
|
407
|
-
tax:
|
|
465
|
+
tax: GYM_DUES,
|
|
408
466
|
grants: {
|
|
409
467
|
object: "pass",
|
|
410
468
|
set: {
|
|
@@ -413,6 +471,8 @@ export default defineExtension({
|
|
|
413
471
|
title: "line.title",
|
|
414
472
|
order: "order",
|
|
415
473
|
uses: "item.uses",
|
|
474
|
+
covers: "item.covers",
|
|
475
|
+
services: "item.services",
|
|
416
476
|
classTypes: "item.classTypes",
|
|
417
477
|
weekdays: "item.weekdays",
|
|
418
478
|
fromMinute: "item.fromMinute",
|
|
@@ -422,7 +482,11 @@ export default defineExtension({
|
|
|
422
482
|
valid: { from: "from", until: "until", days: "item.validDays" },
|
|
423
483
|
},
|
|
424
484
|
onePerPerson: "onePerPerson",
|
|
485
|
+
// In the finance reports (ADR 0792, decision 4): earned class by class as the pass is
|
|
486
|
+
// used, the rest when it expires.
|
|
487
|
+
finance: { category: { key: "passes", label: "Class passes" }, earned: "per_use" },
|
|
425
488
|
},
|
|
489
|
+
agreements: { ...BUYING, inlineStep: true },
|
|
426
490
|
},
|
|
427
491
|
pass: {
|
|
428
492
|
label: "Pass",
|
|
@@ -477,6 +541,10 @@ export default defineExtension({
|
|
|
477
541
|
{ from: "active", to: "void", by: ["host"], tools: ["voidPass"], final: true },
|
|
478
542
|
],
|
|
479
543
|
},
|
|
544
|
+
// A pass given by staff by hand (givePass) starts a pass as buying one does: the same point,
|
|
545
|
+
// asked by the engine when a caller makes one (stage 44, ADR 0644). A pass a paid order
|
|
546
|
+
// grants is the host's, asked when the order started.
|
|
547
|
+
agreements: { ...BUYING, enter: ["active"], person: "person", inlineStep: true },
|
|
480
548
|
// As a membership: their own, and a linked child's for a guardian, read only (ADR 0540).
|
|
481
549
|
customer: {
|
|
482
550
|
field: "person",
|
|
@@ -609,6 +677,84 @@ export default defineExtension({
|
|
|
609
677
|
// Giving or voiding a pass by hand: a person on the staff, with this permission, which admins
|
|
610
678
|
// and members hold and a human admin may grant to anyone else (ADR 0449).
|
|
611
679
|
grantable: ["memberships:passes"],
|
|
680
|
+
// What a journey can start or stop on (stage 53, ADR 0802): the host records the last time each
|
|
681
|
+
// member had each, in the write's batch. A trial that turns into a paid membership is not a
|
|
682
|
+
// trial ended: that is the member joining. A payment caught up, or a pause ended, is neither.
|
|
683
|
+
journeySignals: {
|
|
684
|
+
started: {
|
|
685
|
+
label: "Membership started",
|
|
686
|
+
description: "A membership begins, on trial or paid.",
|
|
687
|
+
object: "membership",
|
|
688
|
+
},
|
|
689
|
+
joined: {
|
|
690
|
+
label: "Joined after a trial",
|
|
691
|
+
description: "A trial becomes a paid membership.",
|
|
692
|
+
object: "membership",
|
|
693
|
+
enters: ["active"],
|
|
694
|
+
from: ["trialing"],
|
|
695
|
+
created: false,
|
|
696
|
+
},
|
|
697
|
+
ended: {
|
|
698
|
+
label: "Membership ended",
|
|
699
|
+
description: "A membership ends.",
|
|
700
|
+
object: "membership",
|
|
701
|
+
enters: ["ended"],
|
|
702
|
+
},
|
|
703
|
+
trialEnded: {
|
|
704
|
+
label: "Trial ended without joining",
|
|
705
|
+
description: "A trial stops without becoming a paid membership.",
|
|
706
|
+
object: "membership",
|
|
707
|
+
enters: ["past_due", "unpaid", "paused", "ended"],
|
|
708
|
+
from: ["trialing"],
|
|
709
|
+
created: false,
|
|
710
|
+
},
|
|
711
|
+
passStarted: {
|
|
712
|
+
label: "Pass started",
|
|
713
|
+
description: "A member gets a pass: bought, or given by staff.",
|
|
714
|
+
object: "pass",
|
|
715
|
+
},
|
|
716
|
+
},
|
|
717
|
+
// Cooling off (stage 44 step 7, decision 11, ADR 0647): the business's own number, for every
|
|
718
|
+
// plan. Off until a person sets it; what any law requires is the business's to confirm.
|
|
719
|
+
settings: {
|
|
720
|
+
coolingOffDays: {
|
|
721
|
+
type: "number",
|
|
722
|
+
label: "Cooling-off period (days)",
|
|
723
|
+
description: "A new member may end their membership within this many days of joining, counted to " +
|
|
724
|
+
"the end of the last day, for a full refund of what they paid; each refund is approved " +
|
|
725
|
+
"by a person who may refund. Not for passes, or for members moving over with a " +
|
|
726
|
+
"continuation offer; once per member. 0: none. Say it in your membership terms; " +
|
|
727
|
+
"whether a law asks for one, and how long, is for your lawyer. Shortening it never " +
|
|
728
|
+
"shortens the period of someone who joined before.",
|
|
729
|
+
default: 0,
|
|
730
|
+
min: 0,
|
|
731
|
+
max: 30,
|
|
732
|
+
personApproves: true,
|
|
733
|
+
},
|
|
734
|
+
},
|
|
612
735
|
tools: { plans, passTypes, buy, mine, holdings, givePass, voidPass },
|
|
613
736
|
dashboards: membershipsDashboards,
|
|
737
|
+
// Staff screens in the product's admin (stage 47, ADR 0660): a person's memberships and passes,
|
|
738
|
+
// a tab on the Person, for whoever may read them and give and void a pass by hand (any member
|
|
739
|
+
// of staff; a viewer reads no further than the record page).
|
|
740
|
+
screens: {
|
|
741
|
+
holdings: {
|
|
742
|
+
label: "Memberships",
|
|
743
|
+
block: "memberships-staff-holdings",
|
|
744
|
+
export: "PersonMemberships",
|
|
745
|
+
opens: ["holdings", "givePass"],
|
|
746
|
+
record: { object: "person", as: "personId" },
|
|
747
|
+
},
|
|
748
|
+
},
|
|
749
|
+
// Its section of My account (stage 48, ADR 0710): a member's memberships and passes, and a linked
|
|
750
|
+
// child's (both open to guardians), shown once they or the child hold one.
|
|
751
|
+
portal: {
|
|
752
|
+
memberships: {
|
|
753
|
+
label: "Memberships and passes",
|
|
754
|
+
web: { block: "memberships-mine", export: "MyMemberships" },
|
|
755
|
+
native: { block: "memberships-native-mine", export: "MyMembershipsScreen" },
|
|
756
|
+
order: 20,
|
|
757
|
+
has: ["memberships.membership", "memberships.pass"],
|
|
758
|
+
},
|
|
759
|
+
},
|
|
614
760
|
});
|
package/dist/tools.d.ts
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
import { z } from "@composable-os/sdk";
|
|
2
|
-
export declare const PLAN = "memberships.plan";
|
|
3
|
-
export declare const MEMBERSHIP = "memberships.membership";
|
|
4
|
-
export declare const PASSTYPE = "memberships.passtype";
|
|
5
|
-
export declare const PASS = "memberships.pass";
|
|
6
2
|
export declare const plans: import("@composable-os/sdk").ToolSpec<z.ZodObject<{}, z.core.$strip>, z.ZodObject<{
|
|
7
3
|
plans: z.ZodArray<z.ZodObject<{
|
|
8
4
|
classTypes: z.ZodArray<z.ZodString>;
|
|
@@ -43,6 +39,7 @@ export declare const passTypes: import("@composable-os/sdk").ToolSpec<z.ZodObjec
|
|
|
43
39
|
export declare const buy: import("@composable-os/sdk").ToolSpec<z.ZodObject<{
|
|
44
40
|
passTypeId: z.ZodString;
|
|
45
41
|
email: z.ZodOptional<z.ZodString>;
|
|
42
|
+
agreements: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
46
43
|
}, z.core.$strip>, z.ZodObject<{
|
|
47
44
|
id: z.ZodString;
|
|
48
45
|
state: z.ZodString;
|
package/dist/tools.js
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
// on are the host's (`sellable`, `recurring.grants`, `allowance`). What is left is the host's
|
|
5
5
|
// count (`allowance.get`). A tool asks, and reports what the host answered.
|
|
6
6
|
import { defineTool, OpsCallError, z } from "@composable-os/sdk";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
const PLAN = "memberships.plan";
|
|
8
|
+
const MEMBERSHIP = "memberships.membership";
|
|
9
|
+
const PASSTYPE = "memberships.passtype";
|
|
10
|
+
const PASS = "memberships.pass";
|
|
11
11
|
const id = z.string().min(1).max(64);
|
|
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);
|
|
@@ -33,6 +33,16 @@ const limitsOf = (v) => ({
|
|
|
33
33
|
untilMinute: num(v.untilMinute),
|
|
34
34
|
});
|
|
35
35
|
// --- What is on sale -----------------------------------------------------------------------------
|
|
36
|
+
/** What a plan and a pass type on sale both say of themselves. */
|
|
37
|
+
const onSale = (p) => ({
|
|
38
|
+
id: p.id,
|
|
39
|
+
title: text(p.values.title),
|
|
40
|
+
summary: text(p.values.summary),
|
|
41
|
+
description: text(p.values.description),
|
|
42
|
+
price: num(p.values.price),
|
|
43
|
+
uses: num(p.values.uses),
|
|
44
|
+
...limitsOf(p.values),
|
|
45
|
+
});
|
|
36
46
|
export const plans = defineTool({
|
|
37
47
|
description: "The membership plans on sale: each plan's title, a line on what it gives, description, " +
|
|
38
48
|
"price per month (in the major unit of `currency`), classes per week or month (null: " +
|
|
@@ -63,15 +73,9 @@ export const plans = defineTool({
|
|
|
63
73
|
});
|
|
64
74
|
return {
|
|
65
75
|
plans: page.items.map((p) => ({
|
|
66
|
-
|
|
67
|
-
title: text(p.values.title),
|
|
68
|
-
summary: text(p.values.summary),
|
|
69
|
-
description: text(p.values.description),
|
|
70
|
-
price: num(p.values.price),
|
|
71
|
-
uses: num(p.values.uses),
|
|
76
|
+
...onSale(p),
|
|
72
77
|
per: p.values.per === "month" ? "month" : p.values.per ? "week" : null,
|
|
73
78
|
trialDays: num(p.values.trialDays),
|
|
74
|
-
...limitsOf(p.values),
|
|
75
79
|
})),
|
|
76
80
|
currency: page.currency ?? null,
|
|
77
81
|
};
|
|
@@ -107,15 +111,9 @@ export const passTypes = defineTool({
|
|
|
107
111
|
});
|
|
108
112
|
return {
|
|
109
113
|
passTypes: page.items.map((p) => ({
|
|
110
|
-
|
|
111
|
-
title: text(p.values.title),
|
|
112
|
-
summary: text(p.values.summary),
|
|
113
|
-
description: text(p.values.description),
|
|
114
|
-
price: num(p.values.price),
|
|
115
|
-
uses: num(p.values.uses),
|
|
114
|
+
...onSale(p),
|
|
116
115
|
validDays: num(p.values.validDays),
|
|
117
116
|
onePerPerson: p.values.onePerPerson === true,
|
|
118
|
-
...limitsOf(p.values),
|
|
119
117
|
})),
|
|
120
118
|
currency: page.currency ?? null,
|
|
121
119
|
};
|
|
@@ -132,6 +130,13 @@ export const buy = defineTool({
|
|
|
132
130
|
input: z.object({
|
|
133
131
|
passTypeId: id,
|
|
134
132
|
email: z.string().trim().max(320).optional().describe("A guest's email address"),
|
|
133
|
+
agreements: z
|
|
134
|
+
.array(z.record(z.string(), z.unknown()))
|
|
135
|
+
.max(20)
|
|
136
|
+
.optional()
|
|
137
|
+
.describe("A guest only: their acceptances of what is due, passed on to the host as they are (each " +
|
|
138
|
+
"{ versionId, typedName, signature?, answers? }); the host checks and records them. A " +
|
|
139
|
+
"signed-in member agrees first."),
|
|
135
140
|
}),
|
|
136
141
|
output: z.object({
|
|
137
142
|
id: z.string(),
|
|
@@ -147,6 +152,7 @@ export const buy = defineTool({
|
|
|
147
152
|
lines: [{ object: PASSTYPE, id: input.passTypeId, quantity: 1 }],
|
|
148
153
|
pay: "full",
|
|
149
154
|
...(input.email === undefined ? {} : { email: input.email }),
|
|
155
|
+
...(input.agreements === undefined ? {} : { agreements: input.agreements }),
|
|
150
156
|
});
|
|
151
157
|
return {
|
|
152
158
|
id: order.id,
|
|
@@ -183,10 +189,9 @@ const holding = limitsOut.extend({
|
|
|
183
189
|
/** At most this many of each: what one call reads (review of 32b step 6). */
|
|
184
190
|
const HOLDINGS_MAX = 50;
|
|
185
191
|
async function holdingsOf(ctx, read, personId) {
|
|
186
|
-
const filter = personId ? { filter: { field: "person", op: "eq", value: personId } } : {};
|
|
187
192
|
const list = (object) => ctx.ops.call(read, {
|
|
188
193
|
object,
|
|
189
|
-
|
|
194
|
+
filter: { field: "person", op: "eq", value: personId },
|
|
190
195
|
sort: { field: "from", direction: "desc" },
|
|
191
196
|
limit: HOLDINGS_MAX,
|
|
192
197
|
});
|
|
@@ -303,6 +308,9 @@ export const givePass = defineTool({
|
|
|
303
308
|
passtype: input.passTypeId,
|
|
304
309
|
uses: input.uses ?? most,
|
|
305
310
|
...limitsOf(v),
|
|
311
|
+
// What it pays for: classes, one-to-one sessions and which services (stage 49).
|
|
312
|
+
covers: list(v.covers),
|
|
313
|
+
services: list(v.services),
|
|
306
314
|
source: "staff",
|
|
307
315
|
reason: signed(input.reason, ctx),
|
|
308
316
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@composable-os/pack-memberships",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.13",
|
|
4
4
|
"license": "FSL-1.1-ALv2",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"description": "Membership plans paid every month and class passes bought once, with what each allows and what is left. Requires Programs."
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@composable-os/client": "0.1.0-beta.
|
|
36
|
-
"@composable-os/sdk": "0.1.0-beta.
|
|
35
|
+
"@composable-os/client": "0.1.0-beta.13",
|
|
36
|
+
"@composable-os/sdk": "0.1.0-beta.13"
|
|
37
37
|
}
|
|
38
38
|
}
|