@composable-os/pack-memberships 0.1.0-beta.10 → 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.
@@ -1,4 +1,4 @@
1
- import { type ClientHolding, type PackClient } from "@composable-os/client";
1
+ import { type ClientHolding, formatMinor, type PackClient, type UseMutation, type UseQuery } from "@composable-os/client";
2
2
  import type { z } from "@composable-os/sdk";
3
3
  import type { buy, givePass, holdings, mine, passTypes, plans, voidPass } from "../tools.ts";
4
4
  type Io<T extends {
@@ -11,6 +11,7 @@ type Io<T extends {
11
11
  export declare const PLAN = "memberships.plan";
12
12
  export declare const MEMBERSHIP = "memberships.membership";
13
13
  export declare const PASS = "memberships.pass";
14
+ export declare const PASSTYPE = "memberships.passtype";
14
15
  /** A subscription as its payer reads it (`subscription.list`, stage 32a). */
15
16
  export interface MembershipSubscription {
16
17
  id: string;
@@ -29,6 +30,89 @@ export interface MembershipSubscription {
29
30
  endedAt: string | null;
30
31
  actionUrl: string | null;
31
32
  createdAt: string;
33
+ /** A plan change or a pause asked for and not over, or the pause it is in (stage 32b). */
34
+ change?: SubscriptionChange | null;
35
+ holderPersonId?: string | null;
36
+ }
37
+ /** A plan change or a pause, as the host shows it on the subscription (ADRs 0530, 0531). */
38
+ export interface SubscriptionChange {
39
+ id: string;
40
+ kind: "upgrade" | "downgrade" | "pause";
41
+ state: "requested" | "waiting" | "applied" | "lapsed" | "withdrawn";
42
+ toPlanId: string | null;
43
+ toPlanTitle: string | null;
44
+ toAmount: number | null;
45
+ pauseFrom: string | null;
46
+ pauseUntil: string | null;
47
+ effectiveAt: string | null;
48
+ requestedAt: string;
49
+ /** What came of asking the provider; `unknown`: its next event decides. */
50
+ callOutcome?: "sent" | "pending" | "unknown" | "refused" | null;
51
+ /** The provider's page to confirm an upgrade's charge (3D Secure), while it waits. */
52
+ actionUrl?: string | null;
53
+ /** What came of ending a pause early: refused or unknown, staff ask again. */
54
+ endOutcome?: "sent" | "pending" | "unknown" | "refused" | null;
55
+ }
56
+ /** Why cooling off is not offered (`subscription.coolingOff`'s `why`). */
57
+ export type NotOffered = "not_covered" | "off" | "continuation" | "ended" | "window_passed" | "used" | "nothing_paid";
58
+ /** Whether a subscription may be cooled off, as the host says (stage 44 step 7, ADR 0647). */
59
+ export interface CoolingOffStatus {
60
+ subscriptionId: string;
61
+ /** The host says the payer may end it now for a full refund: the only reason to show the button. */
62
+ offered: boolean;
63
+ why: NotOffered | null;
64
+ days: number;
65
+ /** The last day of the window, `YYYY-MM-DD` in the business's time zone. */
66
+ until: string | null;
67
+ endsAt: string | null;
68
+ /** Paid and not refunded, in minor units. */
69
+ refund: number;
70
+ currency: string;
71
+ coolOff: {
72
+ state: "asked" | "ended" | "lapsed";
73
+ asked: "sent" | "pending" | "unknown" | "refused" | null;
74
+ askedBy: "payer" | "staff";
75
+ askedAt: string;
76
+ /** Open until then; if nothing ended by it, it lapses and the ordinary cancel works. */
77
+ deadline: string;
78
+ endedAt: string | null;
79
+ finished: boolean;
80
+ /** Staff asked to finish a lapsed one, not yet confirmed by the payment provider. */
81
+ finishing: "asked" | "sent" | "pending" | "unknown" | "stuck" | null;
82
+ /** A cancel of it waits for a person at the payments gatekeeper: nobody may ask again. */
83
+ waiting: boolean;
84
+ lapsedBecause: "deadline" | "action" | "end_time" | "used" | null;
85
+ /** The host says this caller may ask the provider again now. */
86
+ askAgain: boolean;
87
+ /** Under way: the ordinary cancel waits. */
88
+ open: boolean;
89
+ /** Admins were told it is stuck. */
90
+ staffTold: boolean;
91
+ /** What it owes back (owed, once ended), and what has been refunded of that. */
92
+ paid: number;
93
+ refunded: number;
94
+ refunds: "waiting" | "refunded" | "held" | null;
95
+ } | null;
96
+ }
97
+ /** What subscription.coolOff answers. */
98
+ export interface CooledOff {
99
+ id: string;
100
+ /** lapsed: staff asked to finish one, not yet confirmed. */
101
+ state: "asked" | "ended" | "lapsed";
102
+ asked: "sent" | "pending" | "unknown" | null;
103
+ refund: number;
104
+ currency: string;
105
+ }
106
+ /** What subscription.change answers. */
107
+ export interface RequestedChange {
108
+ id: string;
109
+ changeId: string;
110
+ kind: "upgrade" | "downgrade";
111
+ effectiveAt: string | null;
112
+ amount: number;
113
+ currency: string;
114
+ asked: "sent" | "pending" | "unknown" | "not_needed";
115
+ requested: true;
32
116
  }
33
117
  /** Why the host gave no free trial (subscription.start's `noTrial`). */
34
118
  export type NoTrial = "sign_in" | "used" | "permission" | "held" | "unconfirmed" | "continuation";
@@ -67,6 +151,42 @@ export type MembershipsOperations = {
67
151
  "x.memberships.voidPass": {
68
152
  kind: "mutation";
69
153
  } & Io<typeof voidPass>;
154
+ "me.family": {
155
+ kind: "query";
156
+ input: Record<string, never>;
157
+ output: {
158
+ self: {
159
+ personId: string;
160
+ name: string;
161
+ };
162
+ dependants: {
163
+ personId: string;
164
+ name: string;
165
+ }[];
166
+ guardians: {
167
+ personId: string;
168
+ name: string;
169
+ }[];
170
+ };
171
+ };
172
+ "record.list": {
173
+ kind: "query";
174
+ input: {
175
+ object: string;
176
+ sort?: {
177
+ field: string;
178
+ direction?: "asc" | "desc";
179
+ };
180
+ limit?: number;
181
+ };
182
+ output: {
183
+ items: {
184
+ id: string;
185
+ values: Record<string, unknown>;
186
+ }[];
187
+ nextCursor: string | null;
188
+ };
189
+ };
70
190
  "order.checkout": {
71
191
  kind: "mutation";
72
192
  input: {
@@ -88,6 +208,11 @@ export type MembershipsOperations = {
88
208
  returnUrl: string;
89
209
  email?: string;
90
210
  offerId?: string;
211
+ /**
212
+ * A guest only: what they agreed to on the way (stage 44, ADR 0644), each
213
+ * { versionId, typedName, signature?, answers? }, as the host's refusal asked.
214
+ */
215
+ agreements?: Record<string, unknown>[];
91
216
  };
92
217
  output: StartedSubscription;
93
218
  };
@@ -132,6 +257,60 @@ export type MembershipsOperations = {
132
257
  url: string;
133
258
  };
134
259
  };
260
+ "subscription.change": {
261
+ kind: "mutation";
262
+ input: {
263
+ id: string;
264
+ planId: string;
265
+ reason?: string;
266
+ };
267
+ output: RequestedChange;
268
+ };
269
+ "subscription.coolingOff": {
270
+ kind: "query";
271
+ input: {
272
+ ids: string[];
273
+ };
274
+ output: {
275
+ items: CoolingOffStatus[];
276
+ };
277
+ };
278
+ "subscription.coolOff": {
279
+ kind: "mutation";
280
+ input: {
281
+ id: string;
282
+ };
283
+ output: CooledOff;
284
+ };
285
+ "subscription.pause": {
286
+ kind: "mutation";
287
+ input: {
288
+ id: string;
289
+ from?: string;
290
+ until: string;
291
+ reason: string;
292
+ };
293
+ output: {
294
+ id: string;
295
+ changeId: string;
296
+ from: string | null;
297
+ until: string;
298
+ asked: "sent" | "pending" | "unknown";
299
+ requested: true;
300
+ };
301
+ };
302
+ "subscription.unpause": {
303
+ kind: "mutation";
304
+ input: {
305
+ id: string;
306
+ reason?: string;
307
+ };
308
+ output: {
309
+ id: string;
310
+ asked: "sent" | "pending" | "unknown";
311
+ requested: true;
312
+ };
313
+ };
135
314
  };
136
315
  export type MembershipsClient = PackClient<MembershipsOperations>;
137
316
  type Out<N extends keyof MembershipsOperations> = MembershipsOperations[N]["output"];
@@ -160,6 +339,48 @@ export declare function allowsWords(item: {
160
339
  export declare function leftWords(h: Holding): string;
161
340
  /** What a membership's subscription means to its payer, in words. Display only. */
162
341
  export declare function subscriptionStatus(sub: MembershipSubscription): string;
342
+ /**
343
+ * A plan change or a pause waiting, in words, from the host's record: `Changing to Unlimited once
344
+ * its charge is paid`, `Changes to One a week on 3 Dec 2026`, `Paused from 1 Dec to 21 Dec`.
345
+ * Display only: null when nothing waits.
346
+ */
347
+ export declare function changeWords(sub: MembershipSubscription): string | null;
348
+ /** Whether the payer may ask for a plan change now: active, not ending, nothing else waiting. */
349
+ export declare const canChangePlan: (sub: MembershipSubscription) => boolean;
350
+ /** What a member is told when the host refuses a plan change (its `rule`). Display only. */
351
+ export declare function changeRefusalWords(details: {
352
+ rule?: unknown;
353
+ } | undefined): string;
354
+ /** A price in minor units as the host gave it (`1999` AUD is `$19.99`). Display only. */
355
+ export { formatMinor };
356
+ /** A `YYYY-MM-DD` day as a reader sees it (`3 Dec 2026`), never shifted by the reader's zone. */
357
+ export declare function localDay(date: string | null | undefined): string;
358
+ /**
359
+ * The words beside the cancel button while the host offers cooling off: "You can cancel for a
360
+ * full refund until 3 Dec 2026". Null when it is not offered. Display only: the window is the
361
+ * host's (`subscription.coolingOff`), never worked out here.
362
+ */
363
+ export declare function coolingOffWords(status: CoolingOffStatus | undefined): string | null;
364
+ /**
365
+ * Why a member who might have expected it cannot cool off, in words: the period has passed, or
366
+ * they cooled off before. Null otherwise (no cooling off on the plan or for them, or a free trial,
367
+ * where the ordinary cancel ends it at no charge). Display only, from the host's `why`.
368
+ */
369
+ export declare function coolingOffClosedWords(status: CoolingOffStatus | undefined): string | null;
370
+ /**
371
+ * Where a cooling off asked for has got, in words, from the host's record. Null when none was
372
+ * asked.
373
+ */
374
+ export declare function coolOffProgressWords(status: CoolingOffStatus | undefined,
375
+ /** Name the amounts (the web); the app, which shows no money, leaves them out. */
376
+ { amounts }?: {
377
+ amounts?: boolean;
378
+ }): string | null;
379
+ /** What a payer is told when the host refuses cooling off (its `reason`). Display only. */
380
+ export declare function coolOffRefusalWords(details: {
381
+ rule?: unknown;
382
+ reason?: unknown;
383
+ } | undefined): string;
163
384
  /** Whether a subscription is still the payer's to cancel, resume or pay (not ended). */
164
385
  export declare const isLive: (sub: MembershipSubscription) => boolean;
165
386
  /** What a member is told when the host refuses a pass (its `rule` and `reason`). Display only. */
@@ -167,27 +388,7 @@ export declare function refusalWords(details: {
167
388
  rule?: unknown;
168
389
  reason?: unknown;
169
390
  } | undefined): string;
170
- /** The app's `useQuery`, as far as these hooks use it. */
171
- export type UseQuery = <T>(options: {
172
- queryKey: readonly unknown[];
173
- queryFn: () => Promise<T>;
174
- enabled?: boolean;
175
- }) => {
176
- data: T | undefined;
177
- isPending: boolean;
178
- error: unknown;
179
- };
180
- /** The app's `useMutation`, as far as these hooks use it. */
181
- export type UseMutation = <I, O>(options: {
182
- mutationKey: readonly unknown[];
183
- mutationFn: (input: I) => Promise<O>;
184
- }) => {
185
- mutate(input: I): void;
186
- mutateAsync(input: I): Promise<O>;
187
- data: O | undefined;
188
- isPending: boolean;
189
- error: unknown;
190
- };
391
+ export type { UseMutation, UseQuery } from "@composable-os/client";
191
392
  /**
192
393
  * The operations each hook calls (ADR 0453). The public's client gets the plans, the pass types,
193
394
  * buying and subscribing; a customer's client also what they hold and their subscriptions; the
@@ -198,14 +399,22 @@ export declare const MEMBERSHIPS_HOOKS_CALL: {
198
399
  readonly usePassTypes: readonly ["x.memberships.passTypes"];
199
400
  readonly useBuyPass: readonly ["x.memberships.buy", "order.checkout"];
200
401
  readonly useMine: readonly ["x.memberships.mine"];
402
+ readonly useFamily: readonly ["me.family"];
201
403
  readonly useHoldings: readonly ["x.memberships.holdings"];
202
404
  readonly useGivePass: readonly ["x.memberships.givePass"];
203
405
  readonly useVoidPass: readonly ["x.memberships.voidPass"];
406
+ readonly useStaffPassTypes: readonly ["record.list"];
204
407
  readonly useSubscribe: readonly ["subscription.start"];
205
408
  readonly useMySubscriptions: readonly ["subscription.list"];
206
409
  readonly useCancelSubscription: readonly ["subscription.cancel"];
207
410
  readonly useResumeSubscription: readonly ["subscription.resume"];
208
411
  readonly useBillingPortal: readonly ["subscription.portal"];
412
+ readonly useChangePlan: readonly ["subscription.change"];
413
+ readonly usePauseSubscription: readonly ["subscription.pause"];
414
+ readonly useUnpauseSubscription: readonly ["subscription.unpause"];
415
+ readonly useSubscriptionsOf: readonly ["subscription.list"];
416
+ readonly useCoolingOff: readonly ["subscription.coolingOff"];
417
+ readonly useCoolOff: readonly ["subscription.coolOff"];
209
418
  };
210
419
  /**
211
420
  * Hooks for a React or React Native app:
@@ -237,6 +446,7 @@ export declare function createMembershipsHooks<C extends ClientHolding>(react: {
237
446
  } | undefined;
238
447
  isPending: boolean;
239
448
  error: unknown;
449
+ refetch?: () => unknown;
240
450
  };
241
451
  /** The passes on sale, with the host's prices. */
242
452
  usePassTypes(): {
@@ -259,6 +469,23 @@ export declare function createMembershipsHooks<C extends ClientHolding>(react: {
259
469
  } | undefined;
260
470
  isPending: boolean;
261
471
  error: unknown;
472
+ refetch?: () => unknown;
473
+ };
474
+ /**
475
+ * Staff: every pass type, by title, for giving one by hand (stage 47). The staff client's
476
+ * record read; a customer's client cannot back it.
477
+ */
478
+ useStaffPassTypes(): {
479
+ data: {
480
+ items: {
481
+ id: string;
482
+ values: Record<string, unknown>;
483
+ }[];
484
+ nextCursor: string | null;
485
+ } | undefined;
486
+ isPending: boolean;
487
+ error: unknown;
488
+ refetch?: () => unknown;
262
489
  };
263
490
  /** Start an order for a pass; then `checkout` it on the provider's page (web only). */
264
491
  useBuyPass(): {
@@ -266,10 +493,12 @@ export declare function createMembershipsHooks<C extends ClientHolding>(react: {
266
493
  mutate(input: {
267
494
  passTypeId: string;
268
495
  email?: string | undefined;
496
+ agreements?: Record<string, unknown>[] | undefined;
269
497
  }): void;
270
498
  mutateAsync(input: {
271
499
  passTypeId: string;
272
500
  email?: string | undefined;
501
+ agreements?: Record<string, unknown>[] | undefined;
273
502
  }): Promise<{
274
503
  id: string;
275
504
  state: string;
@@ -286,6 +515,7 @@ export declare function createMembershipsHooks<C extends ClientHolding>(react: {
286
515
  } | undefined;
287
516
  isPending: boolean;
288
517
  error: unknown;
518
+ reset?: () => void;
289
519
  };
290
520
  checkout: {
291
521
  mutate(input: {
@@ -305,10 +535,14 @@ export declare function createMembershipsHooks<C extends ClientHolding>(react: {
305
535
  } | undefined;
306
536
  isPending: boolean;
307
537
  error: unknown;
538
+ reset?: () => void;
308
539
  };
309
540
  };
310
- /** The signed-in member's memberships and passes, with the host's count of what is left. */
311
- useMine(): {
541
+ /**
542
+ * The signed-in member's memberships and passes, with the host's count of what is left; with
543
+ * a child's id (from `useFamily`), that child's, where the host shows them to a guardian.
544
+ */
545
+ useMine(personId?: string): {
312
546
  data: {
313
547
  holdings: {
314
548
  classTypes: string[];
@@ -335,6 +569,27 @@ export declare function createMembershipsHooks<C extends ClientHolding>(react: {
335
569
  } | undefined;
336
570
  isPending: boolean;
337
571
  error: unknown;
572
+ refetch?: () => unknown;
573
+ };
574
+ /** Who the member acts for: themselves and the children the gym linked to them. */
575
+ useFamily(): {
576
+ data: {
577
+ self: {
578
+ personId: string;
579
+ name: string;
580
+ };
581
+ dependants: {
582
+ personId: string;
583
+ name: string;
584
+ }[];
585
+ guardians: {
586
+ personId: string;
587
+ name: string;
588
+ }[];
589
+ } | undefined;
590
+ isPending: boolean;
591
+ error: unknown;
592
+ refetch?: () => unknown;
338
593
  };
339
594
  /** Staff: one person's memberships and passes. */
340
595
  useHoldings(personId: string): {
@@ -364,6 +619,7 @@ export declare function createMembershipsHooks<C extends ClientHolding>(react: {
364
619
  } | undefined;
365
620
  isPending: boolean;
366
621
  error: unknown;
622
+ refetch?: () => unknown;
367
623
  };
368
624
  /** Staff (a person): give a pass by hand, with a reason. */
369
625
  useGivePass(): {
@@ -390,6 +646,7 @@ export declare function createMembershipsHooks<C extends ClientHolding>(react: {
390
646
  } | undefined;
391
647
  isPending: boolean;
392
648
  error: unknown;
649
+ reset?: () => void;
393
650
  };
394
651
  /** Staff (a person): void a pass given by hand, with a reason. */
395
652
  useVoidPass(): {
@@ -412,6 +669,7 @@ export declare function createMembershipsHooks<C extends ClientHolding>(react: {
412
669
  } | undefined;
413
670
  isPending: boolean;
414
671
  error: unknown;
672
+ reset?: () => void;
415
673
  };
416
674
  /** Start a membership: the host opens the provider's page (web only); the trial is the host's. */
417
675
  useSubscribe(): {
@@ -423,6 +681,11 @@ export declare function createMembershipsHooks<C extends ClientHolding>(react: {
423
681
  returnUrl: string;
424
682
  email?: string;
425
683
  offerId?: string;
684
+ /**
685
+ * A guest only: what they agreed to on the way (stage 44, ADR 0644), each
686
+ * { versionId, typedName, signature?, answers? }, as the host's refusal asked.
687
+ */
688
+ agreements?: Record<string, unknown>[];
426
689
  }): void;
427
690
  mutateAsync(input: {
428
691
  plan: {
@@ -432,10 +695,16 @@ export declare function createMembershipsHooks<C extends ClientHolding>(react: {
432
695
  returnUrl: string;
433
696
  email?: string;
434
697
  offerId?: string;
698
+ /**
699
+ * A guest only: what they agreed to on the way (stage 44, ADR 0644), each
700
+ * { versionId, typedName, signature?, answers? }, as the host's refusal asked.
701
+ */
702
+ agreements?: Record<string, unknown>[];
435
703
  }): Promise<StartedSubscription>;
436
704
  data: StartedSubscription | undefined;
437
705
  isPending: boolean;
438
706
  error: unknown;
707
+ reset?: () => void;
439
708
  };
440
709
  /** The signed-in payer's own membership subscriptions, newest first. */
441
710
  useMySubscriptions(): {
@@ -445,6 +714,7 @@ export declare function createMembershipsHooks<C extends ClientHolding>(react: {
445
714
  } | undefined;
446
715
  isPending: boolean;
447
716
  error: unknown;
717
+ refetch?: () => unknown;
448
718
  };
449
719
  /** End their own membership when its period ends (web only). */
450
720
  useCancelSubscription(): {
@@ -465,6 +735,7 @@ export declare function createMembershipsHooks<C extends ClientHolding>(react: {
465
735
  } | undefined;
466
736
  isPending: boolean;
467
737
  error: unknown;
738
+ reset?: () => void;
468
739
  };
469
740
  /** Undo that, before the period ends (web only). */
470
741
  useResumeSubscription(): {
@@ -483,6 +754,7 @@ export declare function createMembershipsHooks<C extends ClientHolding>(react: {
483
754
  } | undefined;
484
755
  isPending: boolean;
485
756
  error: unknown;
757
+ reset?: () => void;
486
758
  };
487
759
  /** The provider's portal for their card and past invoices (web only, never in a frame). */
488
760
  useBillingPortal(): {
@@ -499,20 +771,140 @@ export declare function createMembershipsHooks<C extends ClientHolding>(react: {
499
771
  } | undefined;
500
772
  isPending: boolean;
501
773
  error: unknown;
774
+ reset?: () => void;
775
+ };
776
+ /**
777
+ * Move their own membership to another plan (web only): the host decides an upgrade (now,
778
+ * prorated, applied once paid) or a downgrade (from the next period).
779
+ */
780
+ useChangePlan(): {
781
+ mutate(input: {
782
+ id: string;
783
+ planId: string;
784
+ reason?: string;
785
+ }): void;
786
+ mutateAsync(input: {
787
+ id: string;
788
+ planId: string;
789
+ reason?: string;
790
+ }): Promise<RequestedChange>;
791
+ data: RequestedChange | undefined;
792
+ isPending: boolean;
793
+ error: unknown;
794
+ reset?: () => void;
795
+ };
796
+ /** Staff (a person): pause a membership from now or a date until a date, with a reason. */
797
+ usePauseSubscription(): {
798
+ mutate(input: {
799
+ id: string;
800
+ from?: string;
801
+ until: string;
802
+ reason: string;
803
+ }): void;
804
+ mutateAsync(input: {
805
+ id: string;
806
+ from?: string;
807
+ until: string;
808
+ reason: string;
809
+ }): Promise<{
810
+ id: string;
811
+ changeId: string;
812
+ from: string | null;
813
+ until: string;
814
+ asked: "sent" | "pending" | "unknown";
815
+ requested: true;
816
+ }>;
817
+ data: {
818
+ id: string;
819
+ changeId: string;
820
+ from: string | null;
821
+ until: string;
822
+ asked: "sent" | "pending" | "unknown";
823
+ requested: true;
824
+ } | undefined;
825
+ isPending: boolean;
826
+ error: unknown;
827
+ reset?: () => void;
828
+ };
829
+ /** Staff (a person): end a pause now, or withdraw one not yet started. */
830
+ useUnpauseSubscription(): {
831
+ mutate(input: {
832
+ id: string;
833
+ reason?: string;
834
+ }): void;
835
+ mutateAsync(input: {
836
+ id: string;
837
+ reason?: string;
838
+ }): Promise<{
839
+ id: string;
840
+ asked: "sent" | "pending" | "unknown";
841
+ requested: true;
842
+ }>;
843
+ data: {
844
+ id: string;
845
+ asked: "sent" | "pending" | "unknown";
846
+ requested: true;
847
+ } | undefined;
848
+ isPending: boolean;
849
+ error: unknown;
850
+ reset?: () => void;
851
+ };
852
+ /**
853
+ * Whether each of these subscriptions may be ended in its cooling-off period, and how far one
854
+ * asked for has got. The host decides; a block shows the button only when `offered`.
855
+ */
856
+ useCoolingOff(ids: readonly string[]): {
857
+ data: {
858
+ items: CoolingOffStatus[];
859
+ } | undefined;
860
+ isPending: boolean;
861
+ error: unknown;
862
+ refetch?: () => unknown;
863
+ };
864
+ /** End their own membership in its cooling-off period, for a full refund (web only). */
865
+ useCoolOff(): {
866
+ mutate(input: {
867
+ id: string;
868
+ }): void;
869
+ mutateAsync(input: {
870
+ id: string;
871
+ }): Promise<CooledOff>;
872
+ data: CooledOff | undefined;
873
+ isPending: boolean;
874
+ error: unknown;
875
+ reset?: () => void;
876
+ };
877
+ /** Staff: the membership subscriptions one person holds. */
878
+ useSubscriptionsOf(personId: string): {
879
+ data: {
880
+ items: MembershipSubscription[];
881
+ nextCursor: string | null;
882
+ } | undefined;
883
+ isPending: boolean;
884
+ error: unknown;
885
+ refetch?: () => unknown;
502
886
  };
503
887
  }, {
504
888
  readonly usePlans: readonly ["x.memberships.plans"];
505
889
  readonly usePassTypes: readonly ["x.memberships.passTypes"];
506
890
  readonly useBuyPass: readonly ["x.memberships.buy", "order.checkout"];
507
891
  readonly useMine: readonly ["x.memberships.mine"];
892
+ readonly useFamily: readonly ["me.family"];
508
893
  readonly useHoldings: readonly ["x.memberships.holdings"];
509
894
  readonly useGivePass: readonly ["x.memberships.givePass"];
510
895
  readonly useVoidPass: readonly ["x.memberships.voidPass"];
896
+ readonly useStaffPassTypes: readonly ["record.list"];
511
897
  readonly useSubscribe: readonly ["subscription.start"];
512
898
  readonly useMySubscriptions: readonly ["subscription.list"];
513
899
  readonly useCancelSubscription: readonly ["subscription.cancel"];
514
900
  readonly useResumeSubscription: readonly ["subscription.resume"];
515
901
  readonly useBillingPortal: readonly ["subscription.portal"];
902
+ readonly useChangePlan: readonly ["subscription.change"];
903
+ readonly usePauseSubscription: readonly ["subscription.pause"];
904
+ readonly useUnpauseSubscription: readonly ["subscription.unpause"];
905
+ readonly useSubscriptionsOf: readonly ["subscription.list"];
906
+ readonly useCoolingOff: readonly ["subscription.coolingOff"];
907
+ readonly useCoolOff: readonly ["subscription.coolOff"];
516
908
  }, import("@composable-os/client").OperationsOf<C>>;
517
909
  declare function allMembershipsHooks(react: {
518
910
  useQuery: UseQuery;
@@ -539,6 +931,7 @@ declare function allMembershipsHooks(react: {
539
931
  } | undefined;
540
932
  isPending: boolean;
541
933
  error: unknown;
934
+ refetch?: () => unknown;
542
935
  };
543
936
  /** The passes on sale, with the host's prices. */
544
937
  usePassTypes(): {
@@ -561,6 +954,23 @@ declare function allMembershipsHooks(react: {
561
954
  } | undefined;
562
955
  isPending: boolean;
563
956
  error: unknown;
957
+ refetch?: () => unknown;
958
+ };
959
+ /**
960
+ * Staff: every pass type, by title, for giving one by hand (stage 47). The staff client's
961
+ * record read; a customer's client cannot back it.
962
+ */
963
+ useStaffPassTypes(): {
964
+ data: {
965
+ items: {
966
+ id: string;
967
+ values: Record<string, unknown>;
968
+ }[];
969
+ nextCursor: string | null;
970
+ } | undefined;
971
+ isPending: boolean;
972
+ error: unknown;
973
+ refetch?: () => unknown;
564
974
  };
565
975
  /** Start an order for a pass; then `checkout` it on the provider's page (web only). */
566
976
  useBuyPass(): {
@@ -568,10 +978,12 @@ declare function allMembershipsHooks(react: {
568
978
  mutate(input: {
569
979
  passTypeId: string;
570
980
  email?: string | undefined;
981
+ agreements?: Record<string, unknown>[] | undefined;
571
982
  }): void;
572
983
  mutateAsync(input: {
573
984
  passTypeId: string;
574
985
  email?: string | undefined;
986
+ agreements?: Record<string, unknown>[] | undefined;
575
987
  }): Promise<{
576
988
  id: string;
577
989
  state: string;
@@ -588,6 +1000,7 @@ declare function allMembershipsHooks(react: {
588
1000
  } | undefined;
589
1001
  isPending: boolean;
590
1002
  error: unknown;
1003
+ reset?: () => void;
591
1004
  };
592
1005
  checkout: {
593
1006
  mutate(input: {
@@ -607,10 +1020,14 @@ declare function allMembershipsHooks(react: {
607
1020
  } | undefined;
608
1021
  isPending: boolean;
609
1022
  error: unknown;
1023
+ reset?: () => void;
610
1024
  };
611
1025
  };
612
- /** The signed-in member's memberships and passes, with the host's count of what is left. */
613
- useMine(): {
1026
+ /**
1027
+ * The signed-in member's memberships and passes, with the host's count of what is left; with
1028
+ * a child's id (from `useFamily`), that child's, where the host shows them to a guardian.
1029
+ */
1030
+ useMine(personId?: string): {
614
1031
  data: {
615
1032
  holdings: {
616
1033
  classTypes: string[];
@@ -637,6 +1054,27 @@ declare function allMembershipsHooks(react: {
637
1054
  } | undefined;
638
1055
  isPending: boolean;
639
1056
  error: unknown;
1057
+ refetch?: () => unknown;
1058
+ };
1059
+ /** Who the member acts for: themselves and the children the gym linked to them. */
1060
+ useFamily(): {
1061
+ data: {
1062
+ self: {
1063
+ personId: string;
1064
+ name: string;
1065
+ };
1066
+ dependants: {
1067
+ personId: string;
1068
+ name: string;
1069
+ }[];
1070
+ guardians: {
1071
+ personId: string;
1072
+ name: string;
1073
+ }[];
1074
+ } | undefined;
1075
+ isPending: boolean;
1076
+ error: unknown;
1077
+ refetch?: () => unknown;
640
1078
  };
641
1079
  /** Staff: one person's memberships and passes. */
642
1080
  useHoldings(personId: string): {
@@ -666,6 +1104,7 @@ declare function allMembershipsHooks(react: {
666
1104
  } | undefined;
667
1105
  isPending: boolean;
668
1106
  error: unknown;
1107
+ refetch?: () => unknown;
669
1108
  };
670
1109
  /** Staff (a person): give a pass by hand, with a reason. */
671
1110
  useGivePass(): {
@@ -692,6 +1131,7 @@ declare function allMembershipsHooks(react: {
692
1131
  } | undefined;
693
1132
  isPending: boolean;
694
1133
  error: unknown;
1134
+ reset?: () => void;
695
1135
  };
696
1136
  /** Staff (a person): void a pass given by hand, with a reason. */
697
1137
  useVoidPass(): {
@@ -714,6 +1154,7 @@ declare function allMembershipsHooks(react: {
714
1154
  } | undefined;
715
1155
  isPending: boolean;
716
1156
  error: unknown;
1157
+ reset?: () => void;
717
1158
  };
718
1159
  /** Start a membership: the host opens the provider's page (web only); the trial is the host's. */
719
1160
  useSubscribe(): {
@@ -725,6 +1166,11 @@ declare function allMembershipsHooks(react: {
725
1166
  returnUrl: string;
726
1167
  email?: string;
727
1168
  offerId?: string;
1169
+ /**
1170
+ * A guest only: what they agreed to on the way (stage 44, ADR 0644), each
1171
+ * { versionId, typedName, signature?, answers? }, as the host's refusal asked.
1172
+ */
1173
+ agreements?: Record<string, unknown>[];
728
1174
  }): void;
729
1175
  mutateAsync(input: {
730
1176
  plan: {
@@ -734,10 +1180,16 @@ declare function allMembershipsHooks(react: {
734
1180
  returnUrl: string;
735
1181
  email?: string;
736
1182
  offerId?: string;
1183
+ /**
1184
+ * A guest only: what they agreed to on the way (stage 44, ADR 0644), each
1185
+ * { versionId, typedName, signature?, answers? }, as the host's refusal asked.
1186
+ */
1187
+ agreements?: Record<string, unknown>[];
737
1188
  }): Promise<StartedSubscription>;
738
1189
  data: StartedSubscription | undefined;
739
1190
  isPending: boolean;
740
1191
  error: unknown;
1192
+ reset?: () => void;
741
1193
  };
742
1194
  /** The signed-in payer's own membership subscriptions, newest first. */
743
1195
  useMySubscriptions(): {
@@ -747,6 +1199,7 @@ declare function allMembershipsHooks(react: {
747
1199
  } | undefined;
748
1200
  isPending: boolean;
749
1201
  error: unknown;
1202
+ refetch?: () => unknown;
750
1203
  };
751
1204
  /** End their own membership when its period ends (web only). */
752
1205
  useCancelSubscription(): {
@@ -767,6 +1220,7 @@ declare function allMembershipsHooks(react: {
767
1220
  } | undefined;
768
1221
  isPending: boolean;
769
1222
  error: unknown;
1223
+ reset?: () => void;
770
1224
  };
771
1225
  /** Undo that, before the period ends (web only). */
772
1226
  useResumeSubscription(): {
@@ -785,6 +1239,7 @@ declare function allMembershipsHooks(react: {
785
1239
  } | undefined;
786
1240
  isPending: boolean;
787
1241
  error: unknown;
1242
+ reset?: () => void;
788
1243
  };
789
1244
  /** The provider's portal for their card and past invoices (web only, never in a frame). */
790
1245
  useBillingPortal(): {
@@ -801,8 +1256,119 @@ declare function allMembershipsHooks(react: {
801
1256
  } | undefined;
802
1257
  isPending: boolean;
803
1258
  error: unknown;
1259
+ reset?: () => void;
1260
+ };
1261
+ /**
1262
+ * Move their own membership to another plan (web only): the host decides an upgrade (now,
1263
+ * prorated, applied once paid) or a downgrade (from the next period).
1264
+ */
1265
+ useChangePlan(): {
1266
+ mutate(input: {
1267
+ id: string;
1268
+ planId: string;
1269
+ reason?: string;
1270
+ }): void;
1271
+ mutateAsync(input: {
1272
+ id: string;
1273
+ planId: string;
1274
+ reason?: string;
1275
+ }): Promise<RequestedChange>;
1276
+ data: RequestedChange | undefined;
1277
+ isPending: boolean;
1278
+ error: unknown;
1279
+ reset?: () => void;
1280
+ };
1281
+ /** Staff (a person): pause a membership from now or a date until a date, with a reason. */
1282
+ usePauseSubscription(): {
1283
+ mutate(input: {
1284
+ id: string;
1285
+ from?: string;
1286
+ until: string;
1287
+ reason: string;
1288
+ }): void;
1289
+ mutateAsync(input: {
1290
+ id: string;
1291
+ from?: string;
1292
+ until: string;
1293
+ reason: string;
1294
+ }): Promise<{
1295
+ id: string;
1296
+ changeId: string;
1297
+ from: string | null;
1298
+ until: string;
1299
+ asked: "sent" | "pending" | "unknown";
1300
+ requested: true;
1301
+ }>;
1302
+ data: {
1303
+ id: string;
1304
+ changeId: string;
1305
+ from: string | null;
1306
+ until: string;
1307
+ asked: "sent" | "pending" | "unknown";
1308
+ requested: true;
1309
+ } | undefined;
1310
+ isPending: boolean;
1311
+ error: unknown;
1312
+ reset?: () => void;
1313
+ };
1314
+ /** Staff (a person): end a pause now, or withdraw one not yet started. */
1315
+ useUnpauseSubscription(): {
1316
+ mutate(input: {
1317
+ id: string;
1318
+ reason?: string;
1319
+ }): void;
1320
+ mutateAsync(input: {
1321
+ id: string;
1322
+ reason?: string;
1323
+ }): Promise<{
1324
+ id: string;
1325
+ asked: "sent" | "pending" | "unknown";
1326
+ requested: true;
1327
+ }>;
1328
+ data: {
1329
+ id: string;
1330
+ asked: "sent" | "pending" | "unknown";
1331
+ requested: true;
1332
+ } | undefined;
1333
+ isPending: boolean;
1334
+ error: unknown;
1335
+ reset?: () => void;
1336
+ };
1337
+ /**
1338
+ * Whether each of these subscriptions may be ended in its cooling-off period, and how far one
1339
+ * asked for has got. The host decides; a block shows the button only when `offered`.
1340
+ */
1341
+ useCoolingOff(ids: readonly string[]): {
1342
+ data: {
1343
+ items: CoolingOffStatus[];
1344
+ } | undefined;
1345
+ isPending: boolean;
1346
+ error: unknown;
1347
+ refetch?: () => unknown;
1348
+ };
1349
+ /** End their own membership in its cooling-off period, for a full refund (web only). */
1350
+ useCoolOff(): {
1351
+ mutate(input: {
1352
+ id: string;
1353
+ }): void;
1354
+ mutateAsync(input: {
1355
+ id: string;
1356
+ }): Promise<CooledOff>;
1357
+ data: CooledOff | undefined;
1358
+ isPending: boolean;
1359
+ error: unknown;
1360
+ reset?: () => void;
1361
+ };
1362
+ /** Staff: the membership subscriptions one person holds. */
1363
+ useSubscriptionsOf(personId: string): {
1364
+ data: {
1365
+ items: MembershipSubscription[];
1366
+ nextCursor: string | null;
1367
+ } | undefined;
1368
+ isPending: boolean;
1369
+ error: unknown;
1370
+ refetch?: () => unknown;
804
1371
  };
805
1372
  };
806
1373
  /** Every hook of this entry. A block takes the ones it calls: `Pick<MembershipsHooks, "useMine">`. */
807
1374
  export type MembershipsHooks = ReturnType<typeof allMembershipsHooks>;
808
- export {};