@composable-os/pack-memberships 0.0.0-stage → 0.1.0-beta.11

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.
@@ -0,0 +1,1063 @@
1
+ import { type ClientHolding, type PackClient } from "@composable-os/client";
2
+ import type { z } from "@composable-os/sdk";
3
+ import type { buy, givePass, holdings, mine, passTypes, plans, voidPass } from "../tools.ts";
4
+ type Io<T extends {
5
+ input: z.ZodType;
6
+ output: z.ZodType;
7
+ }> = {
8
+ input: z.input<T["input"]>;
9
+ output: z.output<T["output"]>;
10
+ };
11
+ export declare const PLAN = "memberships.plan";
12
+ export declare const MEMBERSHIP = "memberships.membership";
13
+ export declare const PASS = "memberships.pass";
14
+ /** A subscription as its payer reads it (`subscription.list`, stage 32a). */
15
+ export interface MembershipSubscription {
16
+ id: string;
17
+ state: "incomplete" | "expired" | "trialing" | "active" | "past_due" | "unpaid" | "paused" | "ended";
18
+ planObject: string;
19
+ planId: string;
20
+ planTitle: string;
21
+ /** One period's price, in the currency's minor unit, tax included. */
22
+ amount: number;
23
+ currency: string;
24
+ interval: "week" | "month" | "year";
25
+ trialEnd: string | null;
26
+ currentPeriodEnd: string | null;
27
+ cancelAtPeriodEnd: boolean;
28
+ cancelAt: string | null;
29
+ endedAt: string | null;
30
+ actionUrl: string | null;
31
+ createdAt: string;
32
+ /** A plan change or a pause asked for and not over, or the pause it is in (stage 32b). */
33
+ change?: SubscriptionChange | null;
34
+ holderPersonId?: string | null;
35
+ }
36
+ /** A plan change or a pause, as the host shows it on the subscription (ADRs 0530, 0531). */
37
+ export interface SubscriptionChange {
38
+ id: string;
39
+ kind: "upgrade" | "downgrade" | "pause";
40
+ state: "requested" | "waiting" | "applied" | "lapsed" | "withdrawn";
41
+ toPlanId: string | null;
42
+ toPlanTitle: string | null;
43
+ toAmount: number | null;
44
+ pauseFrom: string | null;
45
+ pauseUntil: string | null;
46
+ effectiveAt: string | null;
47
+ requestedAt: string;
48
+ /** What came of asking the provider; `unknown`: its next event decides. */
49
+ callOutcome?: "sent" | "pending" | "unknown" | "refused" | null;
50
+ /** The provider's page to confirm an upgrade's charge (3D Secure), while it waits. */
51
+ actionUrl?: string | null;
52
+ /** What came of ending a pause early: refused or unknown, staff ask again. */
53
+ endOutcome?: "sent" | "pending" | "unknown" | "refused" | null;
54
+ }
55
+ /** What subscription.change answers. */
56
+ export interface RequestedChange {
57
+ id: string;
58
+ changeId: string;
59
+ kind: "upgrade" | "downgrade";
60
+ effectiveAt: string | null;
61
+ amount: number;
62
+ currency: string;
63
+ asked: "sent" | "pending" | "unknown" | "not_needed";
64
+ requested: true;
65
+ }
66
+ /** Why the host gave no free trial (subscription.start's `noTrial`). */
67
+ export type NoTrial = "sign_in" | "used" | "permission" | "held" | "unconfirmed" | "continuation";
68
+ /** What subscription.start answers. */
69
+ export interface StartedSubscription {
70
+ subscriptionId: string;
71
+ url: string;
72
+ amount: number;
73
+ currency: string;
74
+ interval: "week" | "month" | "year";
75
+ trialDays: number | null;
76
+ freeUntil: string | null;
77
+ noTrial: NoTrial | null;
78
+ expiresAt: string | null;
79
+ }
80
+ /** The operations this entry calls, as the generated client types them. */
81
+ export type MembershipsOperations = {
82
+ "x.memberships.plans": {
83
+ kind: "query";
84
+ } & Io<typeof plans>;
85
+ "x.memberships.passTypes": {
86
+ kind: "query";
87
+ } & Io<typeof passTypes>;
88
+ "x.memberships.buy": {
89
+ kind: "mutation";
90
+ } & Io<typeof buy>;
91
+ "x.memberships.mine": {
92
+ kind: "query";
93
+ } & Io<typeof mine>;
94
+ "x.memberships.holdings": {
95
+ kind: "query";
96
+ } & Io<typeof holdings>;
97
+ "x.memberships.givePass": {
98
+ kind: "mutation";
99
+ } & Io<typeof givePass>;
100
+ "x.memberships.voidPass": {
101
+ kind: "mutation";
102
+ } & Io<typeof voidPass>;
103
+ "order.checkout": {
104
+ kind: "mutation";
105
+ input: {
106
+ id: string;
107
+ token?: string;
108
+ returnUrl: string;
109
+ };
110
+ output: {
111
+ url: string;
112
+ };
113
+ };
114
+ "subscription.start": {
115
+ kind: "mutation";
116
+ input: {
117
+ plan: {
118
+ object: string;
119
+ id: string;
120
+ };
121
+ returnUrl: string;
122
+ email?: string;
123
+ offerId?: string;
124
+ };
125
+ output: StartedSubscription;
126
+ };
127
+ "subscription.list": {
128
+ kind: "query";
129
+ input: {
130
+ filter?: unknown;
131
+ limit?: number;
132
+ };
133
+ output: {
134
+ items: MembershipSubscription[];
135
+ nextCursor: string | null;
136
+ };
137
+ };
138
+ "subscription.cancel": {
139
+ kind: "mutation";
140
+ input: {
141
+ id: string;
142
+ reason?: string;
143
+ };
144
+ output: {
145
+ id: string;
146
+ requested: true;
147
+ };
148
+ };
149
+ "subscription.resume": {
150
+ kind: "mutation";
151
+ input: {
152
+ id: string;
153
+ };
154
+ output: {
155
+ id: string;
156
+ requested: true;
157
+ };
158
+ };
159
+ "subscription.portal": {
160
+ kind: "mutation";
161
+ input: {
162
+ returnUrl: string;
163
+ };
164
+ output: {
165
+ url: string;
166
+ };
167
+ };
168
+ "subscription.change": {
169
+ kind: "mutation";
170
+ input: {
171
+ id: string;
172
+ planId: string;
173
+ reason?: string;
174
+ };
175
+ output: RequestedChange;
176
+ };
177
+ "subscription.pause": {
178
+ kind: "mutation";
179
+ input: {
180
+ id: string;
181
+ from?: string;
182
+ until: string;
183
+ reason: string;
184
+ };
185
+ output: {
186
+ id: string;
187
+ changeId: string;
188
+ from: string | null;
189
+ until: string;
190
+ asked: "sent" | "pending" | "unknown";
191
+ requested: true;
192
+ };
193
+ };
194
+ "subscription.unpause": {
195
+ kind: "mutation";
196
+ input: {
197
+ id: string;
198
+ reason?: string;
199
+ };
200
+ output: {
201
+ id: string;
202
+ asked: "sent" | "pending" | "unknown";
203
+ requested: true;
204
+ };
205
+ };
206
+ };
207
+ export type MembershipsClient = PackClient<MembershipsOperations>;
208
+ type Out<N extends keyof MembershipsOperations> = MembershipsOperations[N]["output"];
209
+ /** One membership or pass of the member's, as `mine` gives it. */
210
+ export type Holding = Out<"x.memberships.mine">["holdings"][number];
211
+ /** A plan on sale, as `plans` gives it. */
212
+ export type Plan = Out<"x.memberships.plans">["plans"][number];
213
+ /** A pass type on sale, as `passTypes` gives it. */
214
+ export type PassType = Out<"x.memberships.passTypes">["passTypes"][number];
215
+ /** A price as the host gave it, in its currency (`99.00 AUD`). Display only: never worked out. */
216
+ export declare function formatPrice(price: number | null | undefined, currency: string | null | undefined): string;
217
+ /** A date as a reader sees it (`3 Dec 2026`), from the host's ISO timestamp. Display only. */
218
+ export declare function day(iso: string | null | undefined): string;
219
+ /** What a plan or pass allows, in words: `3 classes a week · Mon, Wed · 09:00 to 16:00`. */
220
+ export declare function allowsWords(item: {
221
+ uses: number | null;
222
+ per?: "total" | "week" | "month" | null;
223
+ weekdays: readonly string[];
224
+ fromMinute: number | null;
225
+ untilMinute: number | null;
226
+ }): string;
227
+ /**
228
+ * What is left of a holding, in words, from the host's count: `2 of 3 left this week`. Display
229
+ * only: whether it can pay for a class is the host's, at booking.
230
+ */
231
+ export declare function leftWords(h: Holding): string;
232
+ /** What a membership's subscription means to its payer, in words. Display only. */
233
+ export declare function subscriptionStatus(sub: MembershipSubscription): string;
234
+ /**
235
+ * A plan change or a pause waiting, in words, from the host's record: `Changing to Unlimited once
236
+ * its charge is paid`, `Changes to One a week on 3 Dec 2026`, `Paused from 1 Dec to 21 Dec`.
237
+ * Display only: null when nothing waits.
238
+ */
239
+ export declare function changeWords(sub: MembershipSubscription): string | null;
240
+ /** Whether the payer may ask for a plan change now: active, not ending, nothing else waiting. */
241
+ export declare const canChangePlan: (sub: MembershipSubscription) => boolean;
242
+ /** What a member is told when the host refuses a plan change (its `rule`). Display only. */
243
+ export declare function changeRefusalWords(details: {
244
+ rule?: unknown;
245
+ } | undefined): string;
246
+ /** Whether a subscription is still the payer's to cancel, resume or pay (not ended). */
247
+ export declare const isLive: (sub: MembershipSubscription) => boolean;
248
+ /** What a member is told when the host refuses a pass (its `rule` and `reason`). Display only. */
249
+ export declare function refusalWords(details: {
250
+ rule?: unknown;
251
+ reason?: unknown;
252
+ } | undefined): string;
253
+ /** The app's `useQuery`, as far as these hooks use it. */
254
+ export type UseQuery = <T>(options: {
255
+ queryKey: readonly unknown[];
256
+ queryFn: () => Promise<T>;
257
+ enabled?: boolean;
258
+ }) => {
259
+ data: T | undefined;
260
+ isPending: boolean;
261
+ error: unknown;
262
+ };
263
+ /** The app's `useMutation`, as far as these hooks use it. */
264
+ export type UseMutation = <I, O>(options: {
265
+ mutationKey: readonly unknown[];
266
+ mutationFn: (input: I) => Promise<O>;
267
+ }) => {
268
+ mutate(input: I): void;
269
+ mutateAsync(input: I): Promise<O>;
270
+ data: O | undefined;
271
+ isPending: boolean;
272
+ error: unknown;
273
+ };
274
+ /**
275
+ * The operations each hook calls (ADR 0453). The public's client gets the plans, the pass types,
276
+ * buying and subscribing; a customer's client also what they hold and their subscriptions; the
277
+ * staff client a person's holdings and giving or voiding a pass.
278
+ */
279
+ export declare const MEMBERSHIPS_HOOKS_CALL: {
280
+ readonly usePlans: readonly ["x.memberships.plans"];
281
+ readonly usePassTypes: readonly ["x.memberships.passTypes"];
282
+ readonly useBuyPass: readonly ["x.memberships.buy", "order.checkout"];
283
+ readonly useMine: readonly ["x.memberships.mine"];
284
+ readonly useHoldings: readonly ["x.memberships.holdings"];
285
+ readonly useGivePass: readonly ["x.memberships.givePass"];
286
+ readonly useVoidPass: readonly ["x.memberships.voidPass"];
287
+ readonly useSubscribe: readonly ["subscription.start"];
288
+ readonly useMySubscriptions: readonly ["subscription.list"];
289
+ readonly useCancelSubscription: readonly ["subscription.cancel"];
290
+ readonly useResumeSubscription: readonly ["subscription.resume"];
291
+ readonly useBillingPortal: readonly ["subscription.portal"];
292
+ readonly useChangePlan: readonly ["subscription.change"];
293
+ readonly usePauseSubscription: readonly ["subscription.pause"];
294
+ readonly useUnpauseSubscription: readonly ["subscription.unpause"];
295
+ readonly useSubscriptionsOf: readonly ["subscription.list"];
296
+ };
297
+ /**
298
+ * Hooks for a React or React Native app:
299
+ * `const memberships = createMembershipsHooks({ useQuery, useMutation }, api)`. The hooks a client
300
+ * cannot back are not there, and calling one does not compile.
301
+ */
302
+ export declare function createMembershipsHooks<C extends ClientHolding>(react: {
303
+ useQuery: UseQuery;
304
+ useMutation: UseMutation;
305
+ }, client: C): import("@composable-os/client").HooksFor<{
306
+ /** The membership plans on sale, with the host's prices and trial days. */
307
+ usePlans(): {
308
+ data: {
309
+ plans: {
310
+ classTypes: string[];
311
+ weekdays: string[];
312
+ fromMinute: number | null;
313
+ untilMinute: number | null;
314
+ id: string;
315
+ title: string | null;
316
+ summary: string | null;
317
+ description: string | null;
318
+ price: number | null;
319
+ uses: number | null;
320
+ per: "week" | "month" | null;
321
+ trialDays: number | null;
322
+ }[];
323
+ currency: string | null;
324
+ } | undefined;
325
+ isPending: boolean;
326
+ error: unknown;
327
+ };
328
+ /** The passes on sale, with the host's prices. */
329
+ usePassTypes(): {
330
+ data: {
331
+ passTypes: {
332
+ classTypes: string[];
333
+ weekdays: string[];
334
+ fromMinute: number | null;
335
+ untilMinute: number | null;
336
+ id: string;
337
+ title: string | null;
338
+ summary: string | null;
339
+ description: string | null;
340
+ price: number | null;
341
+ uses: number | null;
342
+ validDays: number | null;
343
+ onePerPerson: boolean;
344
+ }[];
345
+ currency: string | null;
346
+ } | undefined;
347
+ isPending: boolean;
348
+ error: unknown;
349
+ };
350
+ /** Start an order for a pass; then `checkout` it on the provider's page (web only). */
351
+ useBuyPass(): {
352
+ start: {
353
+ mutate(input: {
354
+ passTypeId: string;
355
+ email?: string | undefined;
356
+ }): void;
357
+ mutateAsync(input: {
358
+ passTypeId: string;
359
+ email?: string | undefined;
360
+ }): Promise<{
361
+ id: string;
362
+ state: string;
363
+ currency: string;
364
+ total: number;
365
+ token: string | null;
366
+ }>;
367
+ data: {
368
+ id: string;
369
+ state: string;
370
+ currency: string;
371
+ total: number;
372
+ token: string | null;
373
+ } | undefined;
374
+ isPending: boolean;
375
+ error: unknown;
376
+ };
377
+ checkout: {
378
+ mutate(input: {
379
+ id: string;
380
+ token?: string;
381
+ returnUrl: string;
382
+ }): void;
383
+ mutateAsync(input: {
384
+ id: string;
385
+ token?: string;
386
+ returnUrl: string;
387
+ }): Promise<{
388
+ url: string;
389
+ }>;
390
+ data: {
391
+ url: string;
392
+ } | undefined;
393
+ isPending: boolean;
394
+ error: unknown;
395
+ };
396
+ };
397
+ /** The signed-in member's memberships and passes, with the host's count of what is left. */
398
+ useMine(): {
399
+ data: {
400
+ holdings: {
401
+ classTypes: string[];
402
+ weekdays: string[];
403
+ fromMinute: number | null;
404
+ untilMinute: number | null;
405
+ id: string;
406
+ kind: "membership" | "pass";
407
+ title: string | null;
408
+ status: string;
409
+ uses: number | null;
410
+ per: "week" | "month" | "total";
411
+ from: string | null;
412
+ until: string | null;
413
+ live: boolean;
414
+ period: {
415
+ key: string;
416
+ startsAt: string;
417
+ endsAt: string;
418
+ used: number;
419
+ left: number | null;
420
+ } | null;
421
+ }[];
422
+ } | undefined;
423
+ isPending: boolean;
424
+ error: unknown;
425
+ };
426
+ /** Staff: one person's memberships and passes. */
427
+ useHoldings(personId: string): {
428
+ data: {
429
+ holdings: {
430
+ classTypes: string[];
431
+ weekdays: string[];
432
+ fromMinute: number | null;
433
+ untilMinute: number | null;
434
+ id: string;
435
+ kind: "membership" | "pass";
436
+ title: string | null;
437
+ status: string;
438
+ uses: number | null;
439
+ per: "week" | "month" | "total";
440
+ from: string | null;
441
+ until: string | null;
442
+ live: boolean;
443
+ period: {
444
+ key: string;
445
+ startsAt: string;
446
+ endsAt: string;
447
+ used: number;
448
+ left: number | null;
449
+ } | null;
450
+ }[];
451
+ } | undefined;
452
+ isPending: boolean;
453
+ error: unknown;
454
+ };
455
+ /** Staff (a person): give a pass by hand, with a reason. */
456
+ useGivePass(): {
457
+ mutate(input: {
458
+ personId: string;
459
+ passTypeId: string;
460
+ reason: string;
461
+ uses?: number | undefined;
462
+ }): void;
463
+ mutateAsync(input: {
464
+ personId: string;
465
+ passTypeId: string;
466
+ reason: string;
467
+ uses?: number | undefined;
468
+ }): Promise<{
469
+ passId: string;
470
+ status: string;
471
+ source: string;
472
+ }>;
473
+ data: {
474
+ passId: string;
475
+ status: string;
476
+ source: string;
477
+ } | undefined;
478
+ isPending: boolean;
479
+ error: unknown;
480
+ };
481
+ /** Staff (a person): void a pass given by hand, with a reason. */
482
+ useVoidPass(): {
483
+ mutate(input: {
484
+ passId: string;
485
+ reason: string;
486
+ }): void;
487
+ mutateAsync(input: {
488
+ passId: string;
489
+ reason: string;
490
+ }): Promise<{
491
+ passId: string;
492
+ status: string;
493
+ source: string;
494
+ }>;
495
+ data: {
496
+ passId: string;
497
+ status: string;
498
+ source: string;
499
+ } | undefined;
500
+ isPending: boolean;
501
+ error: unknown;
502
+ };
503
+ /** Start a membership: the host opens the provider's page (web only); the trial is the host's. */
504
+ useSubscribe(): {
505
+ mutate(input: {
506
+ plan: {
507
+ object: string;
508
+ id: string;
509
+ };
510
+ returnUrl: string;
511
+ email?: string;
512
+ offerId?: string;
513
+ }): void;
514
+ mutateAsync(input: {
515
+ plan: {
516
+ object: string;
517
+ id: string;
518
+ };
519
+ returnUrl: string;
520
+ email?: string;
521
+ offerId?: string;
522
+ }): Promise<StartedSubscription>;
523
+ data: StartedSubscription | undefined;
524
+ isPending: boolean;
525
+ error: unknown;
526
+ };
527
+ /** The signed-in payer's own membership subscriptions, newest first. */
528
+ useMySubscriptions(): {
529
+ data: {
530
+ items: MembershipSubscription[];
531
+ nextCursor: string | null;
532
+ } | undefined;
533
+ isPending: boolean;
534
+ error: unknown;
535
+ };
536
+ /** End their own membership when its period ends (web only). */
537
+ useCancelSubscription(): {
538
+ mutate(input: {
539
+ id: string;
540
+ reason?: string;
541
+ }): void;
542
+ mutateAsync(input: {
543
+ id: string;
544
+ reason?: string;
545
+ }): Promise<{
546
+ id: string;
547
+ requested: true;
548
+ }>;
549
+ data: {
550
+ id: string;
551
+ requested: true;
552
+ } | undefined;
553
+ isPending: boolean;
554
+ error: unknown;
555
+ };
556
+ /** Undo that, before the period ends (web only). */
557
+ useResumeSubscription(): {
558
+ mutate(input: {
559
+ id: string;
560
+ }): void;
561
+ mutateAsync(input: {
562
+ id: string;
563
+ }): Promise<{
564
+ id: string;
565
+ requested: true;
566
+ }>;
567
+ data: {
568
+ id: string;
569
+ requested: true;
570
+ } | undefined;
571
+ isPending: boolean;
572
+ error: unknown;
573
+ };
574
+ /** The provider's portal for their card and past invoices (web only, never in a frame). */
575
+ useBillingPortal(): {
576
+ mutate(input: {
577
+ returnUrl: string;
578
+ }): void;
579
+ mutateAsync(input: {
580
+ returnUrl: string;
581
+ }): Promise<{
582
+ url: string;
583
+ }>;
584
+ data: {
585
+ url: string;
586
+ } | undefined;
587
+ isPending: boolean;
588
+ error: unknown;
589
+ };
590
+ /**
591
+ * Move their own membership to another plan (web only): the host decides an upgrade (now,
592
+ * prorated, applied once paid) or a downgrade (from the next period).
593
+ */
594
+ useChangePlan(): {
595
+ mutate(input: {
596
+ id: string;
597
+ planId: string;
598
+ reason?: string;
599
+ }): void;
600
+ mutateAsync(input: {
601
+ id: string;
602
+ planId: string;
603
+ reason?: string;
604
+ }): Promise<RequestedChange>;
605
+ data: RequestedChange | undefined;
606
+ isPending: boolean;
607
+ error: unknown;
608
+ };
609
+ /** Staff (a person): pause a membership from now or a date until a date, with a reason. */
610
+ usePauseSubscription(): {
611
+ mutate(input: {
612
+ id: string;
613
+ from?: string;
614
+ until: string;
615
+ reason: string;
616
+ }): void;
617
+ mutateAsync(input: {
618
+ id: string;
619
+ from?: string;
620
+ until: string;
621
+ reason: string;
622
+ }): Promise<{
623
+ id: string;
624
+ changeId: string;
625
+ from: string | null;
626
+ until: string;
627
+ asked: "sent" | "pending" | "unknown";
628
+ requested: true;
629
+ }>;
630
+ data: {
631
+ id: string;
632
+ changeId: string;
633
+ from: string | null;
634
+ until: string;
635
+ asked: "sent" | "pending" | "unknown";
636
+ requested: true;
637
+ } | undefined;
638
+ isPending: boolean;
639
+ error: unknown;
640
+ };
641
+ /** Staff (a person): end a pause now, or withdraw one not yet started. */
642
+ useUnpauseSubscription(): {
643
+ mutate(input: {
644
+ id: string;
645
+ reason?: string;
646
+ }): void;
647
+ mutateAsync(input: {
648
+ id: string;
649
+ reason?: string;
650
+ }): Promise<{
651
+ id: string;
652
+ asked: "sent" | "pending" | "unknown";
653
+ requested: true;
654
+ }>;
655
+ data: {
656
+ id: string;
657
+ asked: "sent" | "pending" | "unknown";
658
+ requested: true;
659
+ } | undefined;
660
+ isPending: boolean;
661
+ error: unknown;
662
+ };
663
+ /** Staff: the membership subscriptions one person holds. */
664
+ useSubscriptionsOf(personId: string): {
665
+ data: {
666
+ items: MembershipSubscription[];
667
+ nextCursor: string | null;
668
+ } | undefined;
669
+ isPending: boolean;
670
+ error: unknown;
671
+ };
672
+ }, {
673
+ readonly usePlans: readonly ["x.memberships.plans"];
674
+ readonly usePassTypes: readonly ["x.memberships.passTypes"];
675
+ readonly useBuyPass: readonly ["x.memberships.buy", "order.checkout"];
676
+ readonly useMine: readonly ["x.memberships.mine"];
677
+ readonly useHoldings: readonly ["x.memberships.holdings"];
678
+ readonly useGivePass: readonly ["x.memberships.givePass"];
679
+ readonly useVoidPass: readonly ["x.memberships.voidPass"];
680
+ readonly useSubscribe: readonly ["subscription.start"];
681
+ readonly useMySubscriptions: readonly ["subscription.list"];
682
+ readonly useCancelSubscription: readonly ["subscription.cancel"];
683
+ readonly useResumeSubscription: readonly ["subscription.resume"];
684
+ readonly useBillingPortal: readonly ["subscription.portal"];
685
+ readonly useChangePlan: readonly ["subscription.change"];
686
+ readonly usePauseSubscription: readonly ["subscription.pause"];
687
+ readonly useUnpauseSubscription: readonly ["subscription.unpause"];
688
+ readonly useSubscriptionsOf: readonly ["subscription.list"];
689
+ }, import("@composable-os/client").OperationsOf<C>>;
690
+ declare function allMembershipsHooks(react: {
691
+ useQuery: UseQuery;
692
+ useMutation: UseMutation;
693
+ }, api: MembershipsClient): {
694
+ /** The membership plans on sale, with the host's prices and trial days. */
695
+ usePlans(): {
696
+ data: {
697
+ plans: {
698
+ classTypes: string[];
699
+ weekdays: string[];
700
+ fromMinute: number | null;
701
+ untilMinute: number | null;
702
+ id: string;
703
+ title: string | null;
704
+ summary: string | null;
705
+ description: string | null;
706
+ price: number | null;
707
+ uses: number | null;
708
+ per: "week" | "month" | null;
709
+ trialDays: number | null;
710
+ }[];
711
+ currency: string | null;
712
+ } | undefined;
713
+ isPending: boolean;
714
+ error: unknown;
715
+ };
716
+ /** The passes on sale, with the host's prices. */
717
+ usePassTypes(): {
718
+ data: {
719
+ passTypes: {
720
+ classTypes: string[];
721
+ weekdays: string[];
722
+ fromMinute: number | null;
723
+ untilMinute: number | null;
724
+ id: string;
725
+ title: string | null;
726
+ summary: string | null;
727
+ description: string | null;
728
+ price: number | null;
729
+ uses: number | null;
730
+ validDays: number | null;
731
+ onePerPerson: boolean;
732
+ }[];
733
+ currency: string | null;
734
+ } | undefined;
735
+ isPending: boolean;
736
+ error: unknown;
737
+ };
738
+ /** Start an order for a pass; then `checkout` it on the provider's page (web only). */
739
+ useBuyPass(): {
740
+ start: {
741
+ mutate(input: {
742
+ passTypeId: string;
743
+ email?: string | undefined;
744
+ }): void;
745
+ mutateAsync(input: {
746
+ passTypeId: string;
747
+ email?: string | undefined;
748
+ }): Promise<{
749
+ id: string;
750
+ state: string;
751
+ currency: string;
752
+ total: number;
753
+ token: string | null;
754
+ }>;
755
+ data: {
756
+ id: string;
757
+ state: string;
758
+ currency: string;
759
+ total: number;
760
+ token: string | null;
761
+ } | undefined;
762
+ isPending: boolean;
763
+ error: unknown;
764
+ };
765
+ checkout: {
766
+ mutate(input: {
767
+ id: string;
768
+ token?: string;
769
+ returnUrl: string;
770
+ }): void;
771
+ mutateAsync(input: {
772
+ id: string;
773
+ token?: string;
774
+ returnUrl: string;
775
+ }): Promise<{
776
+ url: string;
777
+ }>;
778
+ data: {
779
+ url: string;
780
+ } | undefined;
781
+ isPending: boolean;
782
+ error: unknown;
783
+ };
784
+ };
785
+ /** The signed-in member's memberships and passes, with the host's count of what is left. */
786
+ useMine(): {
787
+ data: {
788
+ holdings: {
789
+ classTypes: string[];
790
+ weekdays: string[];
791
+ fromMinute: number | null;
792
+ untilMinute: number | null;
793
+ id: string;
794
+ kind: "membership" | "pass";
795
+ title: string | null;
796
+ status: string;
797
+ uses: number | null;
798
+ per: "week" | "month" | "total";
799
+ from: string | null;
800
+ until: string | null;
801
+ live: boolean;
802
+ period: {
803
+ key: string;
804
+ startsAt: string;
805
+ endsAt: string;
806
+ used: number;
807
+ left: number | null;
808
+ } | null;
809
+ }[];
810
+ } | undefined;
811
+ isPending: boolean;
812
+ error: unknown;
813
+ };
814
+ /** Staff: one person's memberships and passes. */
815
+ useHoldings(personId: string): {
816
+ data: {
817
+ holdings: {
818
+ classTypes: string[];
819
+ weekdays: string[];
820
+ fromMinute: number | null;
821
+ untilMinute: number | null;
822
+ id: string;
823
+ kind: "membership" | "pass";
824
+ title: string | null;
825
+ status: string;
826
+ uses: number | null;
827
+ per: "week" | "month" | "total";
828
+ from: string | null;
829
+ until: string | null;
830
+ live: boolean;
831
+ period: {
832
+ key: string;
833
+ startsAt: string;
834
+ endsAt: string;
835
+ used: number;
836
+ left: number | null;
837
+ } | null;
838
+ }[];
839
+ } | undefined;
840
+ isPending: boolean;
841
+ error: unknown;
842
+ };
843
+ /** Staff (a person): give a pass by hand, with a reason. */
844
+ useGivePass(): {
845
+ mutate(input: {
846
+ personId: string;
847
+ passTypeId: string;
848
+ reason: string;
849
+ uses?: number | undefined;
850
+ }): void;
851
+ mutateAsync(input: {
852
+ personId: string;
853
+ passTypeId: string;
854
+ reason: string;
855
+ uses?: number | undefined;
856
+ }): Promise<{
857
+ passId: string;
858
+ status: string;
859
+ source: string;
860
+ }>;
861
+ data: {
862
+ passId: string;
863
+ status: string;
864
+ source: string;
865
+ } | undefined;
866
+ isPending: boolean;
867
+ error: unknown;
868
+ };
869
+ /** Staff (a person): void a pass given by hand, with a reason. */
870
+ useVoidPass(): {
871
+ mutate(input: {
872
+ passId: string;
873
+ reason: string;
874
+ }): void;
875
+ mutateAsync(input: {
876
+ passId: string;
877
+ reason: string;
878
+ }): Promise<{
879
+ passId: string;
880
+ status: string;
881
+ source: string;
882
+ }>;
883
+ data: {
884
+ passId: string;
885
+ status: string;
886
+ source: string;
887
+ } | undefined;
888
+ isPending: boolean;
889
+ error: unknown;
890
+ };
891
+ /** Start a membership: the host opens the provider's page (web only); the trial is the host's. */
892
+ useSubscribe(): {
893
+ mutate(input: {
894
+ plan: {
895
+ object: string;
896
+ id: string;
897
+ };
898
+ returnUrl: string;
899
+ email?: string;
900
+ offerId?: string;
901
+ }): void;
902
+ mutateAsync(input: {
903
+ plan: {
904
+ object: string;
905
+ id: string;
906
+ };
907
+ returnUrl: string;
908
+ email?: string;
909
+ offerId?: string;
910
+ }): Promise<StartedSubscription>;
911
+ data: StartedSubscription | undefined;
912
+ isPending: boolean;
913
+ error: unknown;
914
+ };
915
+ /** The signed-in payer's own membership subscriptions, newest first. */
916
+ useMySubscriptions(): {
917
+ data: {
918
+ items: MembershipSubscription[];
919
+ nextCursor: string | null;
920
+ } | undefined;
921
+ isPending: boolean;
922
+ error: unknown;
923
+ };
924
+ /** End their own membership when its period ends (web only). */
925
+ useCancelSubscription(): {
926
+ mutate(input: {
927
+ id: string;
928
+ reason?: string;
929
+ }): void;
930
+ mutateAsync(input: {
931
+ id: string;
932
+ reason?: string;
933
+ }): Promise<{
934
+ id: string;
935
+ requested: true;
936
+ }>;
937
+ data: {
938
+ id: string;
939
+ requested: true;
940
+ } | undefined;
941
+ isPending: boolean;
942
+ error: unknown;
943
+ };
944
+ /** Undo that, before the period ends (web only). */
945
+ useResumeSubscription(): {
946
+ mutate(input: {
947
+ id: string;
948
+ }): void;
949
+ mutateAsync(input: {
950
+ id: string;
951
+ }): Promise<{
952
+ id: string;
953
+ requested: true;
954
+ }>;
955
+ data: {
956
+ id: string;
957
+ requested: true;
958
+ } | undefined;
959
+ isPending: boolean;
960
+ error: unknown;
961
+ };
962
+ /** The provider's portal for their card and past invoices (web only, never in a frame). */
963
+ useBillingPortal(): {
964
+ mutate(input: {
965
+ returnUrl: string;
966
+ }): void;
967
+ mutateAsync(input: {
968
+ returnUrl: string;
969
+ }): Promise<{
970
+ url: string;
971
+ }>;
972
+ data: {
973
+ url: string;
974
+ } | undefined;
975
+ isPending: boolean;
976
+ error: unknown;
977
+ };
978
+ /**
979
+ * Move their own membership to another plan (web only): the host decides an upgrade (now,
980
+ * prorated, applied once paid) or a downgrade (from the next period).
981
+ */
982
+ useChangePlan(): {
983
+ mutate(input: {
984
+ id: string;
985
+ planId: string;
986
+ reason?: string;
987
+ }): void;
988
+ mutateAsync(input: {
989
+ id: string;
990
+ planId: string;
991
+ reason?: string;
992
+ }): Promise<RequestedChange>;
993
+ data: RequestedChange | undefined;
994
+ isPending: boolean;
995
+ error: unknown;
996
+ };
997
+ /** Staff (a person): pause a membership from now or a date until a date, with a reason. */
998
+ usePauseSubscription(): {
999
+ mutate(input: {
1000
+ id: string;
1001
+ from?: string;
1002
+ until: string;
1003
+ reason: string;
1004
+ }): void;
1005
+ mutateAsync(input: {
1006
+ id: string;
1007
+ from?: string;
1008
+ until: string;
1009
+ reason: string;
1010
+ }): Promise<{
1011
+ id: string;
1012
+ changeId: string;
1013
+ from: string | null;
1014
+ until: string;
1015
+ asked: "sent" | "pending" | "unknown";
1016
+ requested: true;
1017
+ }>;
1018
+ data: {
1019
+ id: string;
1020
+ changeId: string;
1021
+ from: string | null;
1022
+ until: string;
1023
+ asked: "sent" | "pending" | "unknown";
1024
+ requested: true;
1025
+ } | undefined;
1026
+ isPending: boolean;
1027
+ error: unknown;
1028
+ };
1029
+ /** Staff (a person): end a pause now, or withdraw one not yet started. */
1030
+ useUnpauseSubscription(): {
1031
+ mutate(input: {
1032
+ id: string;
1033
+ reason?: string;
1034
+ }): void;
1035
+ mutateAsync(input: {
1036
+ id: string;
1037
+ reason?: string;
1038
+ }): Promise<{
1039
+ id: string;
1040
+ asked: "sent" | "pending" | "unknown";
1041
+ requested: true;
1042
+ }>;
1043
+ data: {
1044
+ id: string;
1045
+ asked: "sent" | "pending" | "unknown";
1046
+ requested: true;
1047
+ } | undefined;
1048
+ isPending: boolean;
1049
+ error: unknown;
1050
+ };
1051
+ /** Staff: the membership subscriptions one person holds. */
1052
+ useSubscriptionsOf(personId: string): {
1053
+ data: {
1054
+ items: MembershipSubscription[];
1055
+ nextCursor: string | null;
1056
+ } | undefined;
1057
+ isPending: boolean;
1058
+ error: unknown;
1059
+ };
1060
+ };
1061
+ /** Every hook of this entry. A block takes the ones it calls: `Pick<MembershipsHooks, "useMine">`. */
1062
+ export type MembershipsHooks = ReturnType<typeof allMembershipsHooks>;
1063
+ export {};