@composable-os/client 0.1.0-beta.11 → 0.1.0-beta.14

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,1461 @@
1
+ import type { ClientHolding, PackClient, UseMutation, UseQuery } from "./hooks.ts";
2
+ /** The signed-in customer's own Person and their sign-in address (`me.get`). */
3
+ export interface AccountMe {
4
+ id: string;
5
+ displayName: string;
6
+ givenName: string | null;
7
+ familyName: string | null;
8
+ primaryEmail: string | null;
9
+ primaryPhone: string | null;
10
+ /** The address they sign in with: the one the emailed code verified. */
11
+ signInEmail: string;
12
+ signInEmailVerified: boolean;
13
+ }
14
+ /** What `me.update` changes: only the fields passed; null clears one. */
15
+ export interface AccountDetailsInput {
16
+ displayName?: string;
17
+ givenName?: string | null;
18
+ familyName?: string | null;
19
+ primaryPhone?: string | null;
20
+ }
21
+ /** A birthday: day and month only, never a year (`me.birthday.get`, stage 53). */
22
+ export interface AccountBirthday {
23
+ day: number;
24
+ month: number;
25
+ }
26
+ /** One place the customer is signed in (`me.sessions.list`). */
27
+ export interface AccountSession {
28
+ id: string;
29
+ kind: "browser" | "device";
30
+ deviceName: string | null;
31
+ createdAt: string;
32
+ lastActiveAt: string;
33
+ expiresAt: string | null;
34
+ /** The session this call was made with. */
35
+ current: boolean;
36
+ }
37
+ /** Who the customer acts for and who acts for them (`me.family`, ADR 0540). */
38
+ export interface AccountFamily {
39
+ self: {
40
+ personId: string;
41
+ name: string;
42
+ };
43
+ dependants: {
44
+ personId: string;
45
+ name: string;
46
+ }[];
47
+ guardians: {
48
+ personId: string;
49
+ name: string;
50
+ }[];
51
+ }
52
+ /** A record as `my.list` answers it: only the fields the object lets its customer read. */
53
+ export interface MyRecord {
54
+ object: string;
55
+ id: string;
56
+ values: Record<string, unknown>;
57
+ }
58
+ export type OrderState = "pending" | "part_paid" | "paid" | "cancelled" | "expired" | "refunded";
59
+ /** One line of an order, as its customer reads it. Amounts in the currency's minor unit. */
60
+ export interface AccountOrderLine {
61
+ id: string;
62
+ position: number;
63
+ title: string;
64
+ quantity: number;
65
+ unitPrice: number;
66
+ total: number;
67
+ taxAmount: number;
68
+ }
69
+ /** One of the customer's orders with its lines. Amounts in the currency's minor unit. */
70
+ export interface AccountOrder {
71
+ id: string;
72
+ state: OrderState;
73
+ currency: string;
74
+ total: number;
75
+ paid: number;
76
+ balance: number;
77
+ refunded: number;
78
+ pay: "full" | "deposit";
79
+ deposit: number | null;
80
+ balanceDueAt: string | null;
81
+ expiresAt: string | null;
82
+ paidAt: string | null;
83
+ createdAt: string;
84
+ taxAmount: number;
85
+ taxRefunded: number;
86
+ /** Set on an order that paid one period of a subscription. */
87
+ subscriptionId: string | null;
88
+ lines: AccountOrderLine[];
89
+ /**
90
+ * A receipt document for the order: the seam stage 35 (Invoices) fills. Until then null, and
91
+ * the row says the payment provider emailed the receipt.
92
+ */
93
+ receiptUrl: string | null;
94
+ }
95
+ export type SubscriptionState = "incomplete" | "expired" | "trialing" | "active" | "past_due" | "unpaid" | "paused" | "ended";
96
+ /** A subscription as its payer reads it (`subscription.list`: a customer sees the ones they pay). */
97
+ export interface AccountSubscription {
98
+ id: string;
99
+ state: SubscriptionState;
100
+ planObject: string;
101
+ planId: string;
102
+ planTitle: string;
103
+ /** One period's price, in the currency's minor unit, tax included. */
104
+ amount: number;
105
+ currency: string;
106
+ interval: "week" | "month" | "year";
107
+ trialEnd: string | null;
108
+ currentPeriodEnd: string | null;
109
+ cancelAtPeriodEnd: boolean;
110
+ cancelAt: string | null;
111
+ endedAt: string | null;
112
+ /** The provider's page to confirm a payment on (3D Secure), while one waits. */
113
+ actionUrl: string | null;
114
+ createdAt: string;
115
+ /** Whom it is for, where the host says (a pack's own subscription read may leave it out). */
116
+ holderPersonId?: string | null;
117
+ }
118
+ /**
119
+ * What the subscriptions part reads and does (`web-account-subscriptions`,
120
+ * `native-account-subscriptions`): the account's own hooks, or a pack's hooks over the same
121
+ * operations (`subscription.list`, `.cancel`, `.resume`) for its own plans, so Memberships and
122
+ * Courses show their subscriptions with the one part.
123
+ */
124
+ export interface SubscriptionsPartHooks<S extends AccountSubscription = AccountSubscription> {
125
+ useSubscriptions(): {
126
+ data: {
127
+ items: S[];
128
+ } | undefined;
129
+ isPending: boolean;
130
+ error: unknown;
131
+ refetch?: () => unknown;
132
+ };
133
+ useCancelSubscription(): {
134
+ mutateAsync(input: {
135
+ id: string;
136
+ reason?: string;
137
+ }): Promise<unknown>;
138
+ isPending: boolean;
139
+ };
140
+ useResumeSubscription(): {
141
+ mutateAsync(input: {
142
+ id: string;
143
+ }): Promise<unknown>;
144
+ isPending: boolean;
145
+ };
146
+ }
147
+ /** A section of My account as the host lists it (`me.portal`, ADR 0710). */
148
+ export interface AccountPortalSection {
149
+ /** A base section's key (`orders`), or a pack's as `<pack>.<key>` (`memberships.memberships`). */
150
+ key: string;
151
+ /** The pack it is from; null for a base section. */
152
+ pack: string | null;
153
+ label: string;
154
+ order: number;
155
+ /** The blocks that draw a pack's section; null for a base one. */
156
+ web: {
157
+ block: string;
158
+ export: string;
159
+ } | null;
160
+ native: {
161
+ block: string;
162
+ export: string;
163
+ } | null;
164
+ }
165
+ /** Which sections of My account the customer has, in order (`me.portal`). */
166
+ export interface AccountPortal {
167
+ sections: AccountPortalSection[];
168
+ /** Whether they pay a subscription that has not ended: Payment method shows then. */
169
+ paysSubscription: boolean;
170
+ }
171
+ /**
172
+ * What can need a customer's attention (`me.attention`, ADR 0711): a fixed vocabulary in core.
173
+ * A newer host may answer a kind this entry does not know yet; it is shown by its record's title.
174
+ */
175
+ export declare const ATTENTION_KINDS: readonly ["agree", "card_failing", "confirm_payment", "balance_due", "finish_paying", "pass_expiring", "pass_used_up", "trial_ending", "form_to_fill"];
176
+ export type AttentionKind = (typeof ATTENTION_KINDS)[number];
177
+ /** One thing that needs the customer, or a child they act for (`me.attention`). */
178
+ export interface AttentionItem {
179
+ /** Stable for the same cause. */
180
+ key: string;
181
+ kind: AttentionKind;
182
+ /** Whose it is: the customer themselves, or a child they act for, by name. */
183
+ person: {
184
+ id: string;
185
+ name: string;
186
+ self: boolean;
187
+ };
188
+ /** The record it is about: `agreement`, `subscription`, `order`, or a pack's object. */
189
+ record: {
190
+ object: string;
191
+ id: string;
192
+ title: string;
193
+ };
194
+ /** The moment it is about: when it is due, ends or expires (the host's). */
195
+ at: string | null;
196
+ /** Money in the currency's minor unit, where there is some. */
197
+ amount: number | null;
198
+ currency: string | null;
199
+ /** A pass's uses left. */
200
+ usesLeft: number | null;
201
+ /** The personal link to answer a form by (form_to_fill): its id, never a token. */
202
+ link: string | null;
203
+ }
204
+ /** What needs the customer's attention, soonest first, and how far ahead it looks. */
205
+ export interface AccountAttention {
206
+ days: number;
207
+ items: AttentionItem[];
208
+ }
209
+ /** A subscription deleting the account ends, as the preview says (`me.deleteAccount`). */
210
+ export interface DeleteEnding {
211
+ id: string;
212
+ title: string;
213
+ amount: number;
214
+ currency: string;
215
+ interval: string;
216
+ endsAt: string | null;
217
+ /** Asked to end at the period's end now, already set to end, or ending with a cooling off. */
218
+ ending: "period_end" | "already" | "cooling_off";
219
+ }
220
+ /** What deleting the account will do, before anything is done (`me.deleteAccount` with `{}`). */
221
+ export interface DeletePreview {
222
+ deleted: false;
223
+ subscriptions: DeleteEnding[];
224
+ /** Their unpaid orders, cancelled. */
225
+ orders: {
226
+ id: string;
227
+ total: number;
228
+ currency: string;
229
+ createdAt: string;
230
+ lines: string[];
231
+ }[];
232
+ /** What stays for the business to decide when it erases their data. */
233
+ leftForStaff: {
234
+ records: {
235
+ object: string;
236
+ label: string;
237
+ count: number;
238
+ }[];
239
+ partPaidOrders: number;
240
+ moreUnpaidOrders: number;
241
+ subscriptions: {
242
+ id: string;
243
+ title: string;
244
+ state: string;
245
+ why: "end_date_later" | "state" | "more";
246
+ }[];
247
+ dependantsWithoutGuardian: number;
248
+ };
249
+ /** By when the business erases their data, or says why some must be kept. */
250
+ eraseDueAt: string;
251
+ /** The preview's fingerprint, sent back to confirm exactly this. */
252
+ expect: string;
253
+ }
254
+ /** The account deleted (`me.deleteAccount` with `confirm`). */
255
+ export interface DeleteDone {
256
+ deleted: true;
257
+ disabled: true;
258
+ sessionsEnded: number;
259
+ subscriptionsEnding: number;
260
+ ordersCancelled: number;
261
+ eraseRequest: {
262
+ requestedAt: string;
263
+ dueAt: string;
264
+ };
265
+ }
266
+ /** The operations this entry calls, as the generated client types them. */
267
+ export type AccountOperations = {
268
+ "me.portal": {
269
+ kind: "query";
270
+ input: Record<string, never>;
271
+ output: AccountPortal;
272
+ };
273
+ "me.attention": {
274
+ kind: "query";
275
+ input: Record<string, never>;
276
+ output: AccountAttention;
277
+ };
278
+ "me.email.change": {
279
+ kind: "mutation";
280
+ input: {
281
+ email: string;
282
+ };
283
+ output: {
284
+ newEmail: string;
285
+ expiresAt: string;
286
+ };
287
+ };
288
+ "me.email.confirm": {
289
+ kind: "mutation";
290
+ input: {
291
+ code: string;
292
+ };
293
+ output: {
294
+ signInEmail: string;
295
+ sessionsEnded: number;
296
+ };
297
+ };
298
+ "me.deleteAccount": {
299
+ kind: "mutation";
300
+ input: {
301
+ confirm?: boolean;
302
+ expect?: string;
303
+ };
304
+ output: DeletePreview | DeleteDone;
305
+ };
306
+ "me.get": {
307
+ kind: "query";
308
+ input: Record<string, never>;
309
+ output: AccountMe;
310
+ };
311
+ "me.update": {
312
+ kind: "mutation";
313
+ input: AccountDetailsInput;
314
+ output: Omit<AccountMe, "signInEmail" | "signInEmailVerified">;
315
+ };
316
+ "me.birthday.get": {
317
+ kind: "query";
318
+ input: Record<string, never>;
319
+ output: {
320
+ birthday: AccountBirthday | null;
321
+ };
322
+ };
323
+ "me.birthday.set": {
324
+ kind: "mutation";
325
+ input: {
326
+ birthday: AccountBirthday | null;
327
+ };
328
+ output: {
329
+ birthday: AccountBirthday | null;
330
+ };
331
+ };
332
+ "me.sessions.list": {
333
+ kind: "query";
334
+ input: Record<string, never>;
335
+ output: {
336
+ items: AccountSession[];
337
+ };
338
+ };
339
+ "me.sessions.revoke": {
340
+ kind: "mutation";
341
+ input: {
342
+ id: string;
343
+ };
344
+ output: {
345
+ id: string;
346
+ revoked: true;
347
+ };
348
+ };
349
+ "me.family": {
350
+ kind: "query";
351
+ input: Record<string, never>;
352
+ output: AccountFamily;
353
+ };
354
+ "my.list": {
355
+ kind: "query";
356
+ input: {
357
+ object: string;
358
+ filter?: {
359
+ field: string;
360
+ op: string;
361
+ value?: unknown;
362
+ };
363
+ sort?: {
364
+ field: string;
365
+ direction?: "asc" | "desc";
366
+ };
367
+ cursor?: string;
368
+ limit?: number;
369
+ };
370
+ output: {
371
+ items: MyRecord[];
372
+ nextCursor: string | null;
373
+ currency?: string | null;
374
+ };
375
+ };
376
+ "subscription.list": {
377
+ kind: "query";
378
+ input: {
379
+ limit?: number;
380
+ cursor?: string;
381
+ };
382
+ output: {
383
+ items: AccountSubscription[];
384
+ nextCursor: string | null;
385
+ };
386
+ };
387
+ "subscription.cancel": {
388
+ kind: "mutation";
389
+ input: {
390
+ id: string;
391
+ reason?: string;
392
+ };
393
+ output: {
394
+ id: string;
395
+ requested: true;
396
+ };
397
+ };
398
+ "subscription.resume": {
399
+ kind: "mutation";
400
+ input: {
401
+ id: string;
402
+ };
403
+ output: {
404
+ id: string;
405
+ requested: true;
406
+ };
407
+ };
408
+ "order.checkout": {
409
+ kind: "mutation";
410
+ input: {
411
+ id: string;
412
+ returnUrl: string;
413
+ };
414
+ output: {
415
+ url: string;
416
+ amount: number;
417
+ currency: string;
418
+ kind: "full" | "deposit" | "balance" | "part";
419
+ expiresAt: string | null;
420
+ };
421
+ };
422
+ "subscription.portal": {
423
+ kind: "mutation";
424
+ input: {
425
+ returnUrl: string;
426
+ };
427
+ output: {
428
+ url: string;
429
+ };
430
+ };
431
+ "me.contact.choices": {
432
+ kind: "query";
433
+ input: Record<string, never>;
434
+ output: {
435
+ people: ContactPerson[];
436
+ };
437
+ };
438
+ "me.contact.setChoices": {
439
+ kind: "mutation";
440
+ input: ContactChoicesInput;
441
+ output: {
442
+ changed: number;
443
+ };
444
+ };
445
+ };
446
+ /** A channel a message may reach someone on. */
447
+ export type ContactChannel = "email" | "text" | "push";
448
+ /** On or off; for news and offers, yes or no. */
449
+ export type ContactValue = "on" | "off" | "yes" | "no";
450
+ /** One channel of a kind of message, as the host says it is now (`me.contact.choices`). */
451
+ export interface ContactLineChannel {
452
+ channel: ContactChannel;
453
+ value: ContactValue;
454
+ /** Cannot be changed: an essential kind's email always goes. */
455
+ fixed: boolean;
456
+ /** Stopped by a stop link or a STOP reply (the person may turn it back on here). */
457
+ stopped: boolean;
458
+ since: string | null;
459
+ }
460
+ /** One kind of message a person may get, with each channel it goes by. */
461
+ export interface ContactLine {
462
+ /** A routine message kind (`bookings.reminder`), `follow_up` or `news_and_offers`. */
463
+ scope: string;
464
+ label: string;
465
+ description: string;
466
+ purpose: "account" | "follow_up" | "news_and_offers";
467
+ /** Its email always goes. */
468
+ essential: boolean;
469
+ channels: ContactLineChannel[];
470
+ }
471
+ /** The caller's own choices, or a child's they act for. */
472
+ export interface ContactPerson {
473
+ personId: string;
474
+ name: string;
475
+ self: boolean;
476
+ child: boolean;
477
+ lines: ContactLine[];
478
+ }
479
+ /** What `me.contact.setChoices` takes. */
480
+ export interface ContactChoicesInput {
481
+ /** A child they act for; default themselves. */
482
+ personId?: string;
483
+ choices: {
484
+ scope: string;
485
+ channel: ContactChannel;
486
+ value: ContactValue;
487
+ }[];
488
+ /** For a yes to news and offers: the words they were shown (`newsAndOffersWords`). */
489
+ wording?: string;
490
+ }
491
+ /** A channel's name, as a person reads it. */
492
+ export declare const CONTACT_CHANNEL_WORDS: Readonly<Record<ContactChannel, string>>;
493
+ /** Whether a channel's value lets messages go. */
494
+ export declare function contactAllows(value: ContactValue): boolean;
495
+ /** The words a person is shown when they say yes to news and offers on a channel (kept by the host). */
496
+ export declare function newsAndOffersWords(channel: ContactChannel): string;
497
+ /**
498
+ * The change that turns one channel of a line the other way: on and off, or for news and offers
499
+ * yes and no (with the words shown). Null for a channel that cannot change (an essential email).
500
+ */
501
+ export declare function contactToggle(personId: string, line: ContactLine, channel: ContactLineChannel): ContactChoicesInput | null;
502
+ /** A line's channel in words: "Email: on", "Email: always (about something you booked)". */
503
+ export declare function contactChannelWords(channel: ContactLineChannel): string;
504
+ export type AccountClient = PackClient<AccountOperations>;
505
+ /**
506
+ * A section of My account: a base one, or a pack's (its `portal` declaration, ADR 0710, keyed
507
+ * `<pack>.<key>`). Lower `order` first.
508
+ */
509
+ export interface AccountSection {
510
+ key: string;
511
+ label: string;
512
+ order: number;
513
+ }
514
+ /**
515
+ * A pack's section as the client app's generated `account-sections.gen.ts` lists it (`cos add
516
+ * web-account`, ADR 0710): the copied block's component and the pack's hooks factory. The shell
517
+ * renders `component` with the hooks under the pack's id (`{ memberships: hooks }`) and the page's
518
+ * `returnUrl`; `Component` is the app's component type.
519
+ */
520
+ export interface AccountSectionEntry<Component = unknown> {
521
+ /** `<pack>.<key>`, as `me.portal` names it. */
522
+ key: string;
523
+ pack: string;
524
+ label: string;
525
+ order: number;
526
+ component: Component;
527
+ /**
528
+ * The pack's hooks factory (`createMembershipsHooks`), called once with the app's React
529
+ * functions and its generated client. Typed loosely: each pack's factory takes its own types.
530
+ */
531
+ hooks: (react: never, client: never) => unknown;
532
+ }
533
+ /**
534
+ * The base sections, in the order they show after the packs' (a pack declares 10 to 50): what is
535
+ * the customer's to see and do, then their details and where they are signed in. Deleting the
536
+ * account joins them in a later step.
537
+ */
538
+ export declare const BASE_SECTIONS: readonly [{
539
+ readonly key: "orders";
540
+ readonly label: "Orders";
541
+ readonly order: 60;
542
+ }, {
543
+ readonly key: "agreements";
544
+ readonly label: "Agreements";
545
+ readonly order: 70;
546
+ }, {
547
+ readonly key: "family";
548
+ readonly label: "Family";
549
+ readonly order: 80;
550
+ }, {
551
+ readonly key: "payment";
552
+ readonly label: "Payment method";
553
+ readonly order: 85;
554
+ }, {
555
+ readonly key: "details";
556
+ readonly label: "Your details";
557
+ readonly order: 90;
558
+ }, {
559
+ readonly key: "contact";
560
+ readonly label: "Contact preferences";
561
+ readonly order: 92;
562
+ }, {
563
+ readonly key: "devices";
564
+ readonly label: "Sign-in and devices";
565
+ readonly order: 95;
566
+ }, {
567
+ readonly key: "delete";
568
+ readonly label: "Delete my account";
569
+ readonly order: 99;
570
+ }];
571
+ export type BaseSectionKey = (typeof BASE_SECTIONS)[number]["key"];
572
+ /**
573
+ * The sections to show, in order: the base ones and the packs' given, less those `hide` names
574
+ * (`payment` for a customer who pays no subscription: `showsPayment`). A pack section whose key
575
+ * is a base one's is left out: the base section is the one the host's reads stand behind.
576
+ */
577
+ export declare function accountSections(packs?: readonly AccountSection[], hide?: readonly string[]): AccountSection[];
578
+ /**
579
+ * The sections to show, as the host listed them (`me.portal`): every base section it lists, and a
580
+ * pack's only when the app has its block (`packs`, from `account-sections.gen.ts`), so a pack
581
+ * installed at the host before the app copied its block shows nothing rather than an empty
582
+ * section. Until the host answers, the base sections without Payment method.
583
+ *
584
+ * A shell passes `base`, the base sections it draws: a base section a newer host lists that the
585
+ * shell has no part for (one added to the platform after the shell was copied, as Contact
586
+ * preferences and Delete my account were) is left out too, rather than shown as a heading with
587
+ * nothing under it. Without `base`, every base section the host lists is kept.
588
+ */
589
+ export declare function portalSections(portal: AccountPortal | undefined, packs?: readonly AccountSection[], base?: readonly string[]): AccountSection[];
590
+ /** The base sections a shell hides for this customer, from what the host answered. */
591
+ export declare function hiddenSections(subscriptions: readonly AccountSubscription[] | undefined): string[];
592
+ /**
593
+ * An amount the host gave in the currency's minor unit, in that currency: `$29.00`. Display only:
594
+ * the minor unit's digits are the currency's own.
595
+ */
596
+ export declare function formatMinor(minor: number, currency: string, locale?: string): string;
597
+ /** A date as a reader sees it (`3 Dec 2026`), from the host's ISO timestamp. Display only. */
598
+ export declare function accountDay(iso: string | null | undefined, locale?: string): string;
599
+ /** A moment as a reader sees it (`3 Dec 2026, 09:30`). Display only. */
600
+ export declare function accountTime(iso: string | null | undefined, locale?: string): string;
601
+ /** A session in words: what it is, and when it began and was last used. */
602
+ export declare function sessionWords(session: AccountSession): {
603
+ title: string;
604
+ detail: string;
605
+ };
606
+ /** The customer's sessions, this one first, then the most recently used. */
607
+ export declare function orderedSessions(items: readonly AccountSession[]): AccountSession[];
608
+ /** An order's state in words, from what the host reports. */
609
+ export declare function orderStateWords(order: AccountOrder): string;
610
+ /**
611
+ * The money lines of an order to show, each the host's own figure: the total and its tax, then
612
+ * what was paid, what is still to pay (by when), the deposit and what was refunded. A figure the
613
+ * order does not have (no deposit, nothing refunded) is left out.
614
+ */
615
+ export declare function orderMoney(order: AccountOrder, locale?: string): {
616
+ key: string;
617
+ label: string;
618
+ value: string;
619
+ }[];
620
+ /**
621
+ * Whether an order's row offers to pay: it waits for payment, or has the rest of a deposit still
622
+ * to pay. Display only: what is charged, and whether it may be paid at all, is the host's
623
+ * (`order.checkout` refuses otherwise and says so).
624
+ */
625
+ export declare function showsPay(order: AccountOrder): boolean;
626
+ /** What an order's pay button says: the rest of a deposit, or the whole order. */
627
+ export declare function payWords(order: AccountOrder): string;
628
+ /** What an order's row in the app says instead: paying is on the website (ADR 0714). */
629
+ export declare const PAY_ON_WEBSITE_WORDS = "Pay on the website";
630
+ /**
631
+ * Whether an address the host gave (a provider's page to confirm a payment, a checkout) may be
632
+ * followed: an `https:` address, a path on this site, or a loopback `http:` one (a local
633
+ * development host). Anything else (`javascript:`, `data:`, another `http:`, `//elsewhere`) is
634
+ * not followed.
635
+ */
636
+ export declare function followableUrl(url: string | null | undefined): boolean;
637
+ /** What a paid order's row says about its receipt until the host has a receipt document. */
638
+ export declare const RECEIPT_EMAILED_WORDS = "The payment provider emailed you the receipt.";
639
+ /** Whether the order's row says where its receipt is: a paid order, part or whole. */
640
+ export declare function showsReceiptNote(order: AccountOrder): boolean;
641
+ /** Whether a subscription is still the payer's to cancel, resume or pay (not ended). */
642
+ export declare function isLive(sub: AccountSubscription): boolean;
643
+ /**
644
+ * Whether the Payment method section shows: the customer pays a subscription that has not ended
645
+ * (`subscription.list` lists a customer only the ones they pay). The shells take the host's own
646
+ * answer (`me.portal`'s `paysSubscription`, `portalSections`); a plain page may use this.
647
+ */
648
+ export declare function showsPayment(subscriptions: readonly AccountSubscription[] | undefined): boolean;
649
+ /** Whether the payer may still cancel it (it does not already end), as the host reported it. */
650
+ export declare function canCancel(sub: AccountSubscription): boolean;
651
+ /** Whether the payer may keep it going: cancelled at the period's end, which has not come. */
652
+ export declare function canResume(sub: AccountSubscription): boolean;
653
+ /**
654
+ * What a subscription's state means to its payer, in words, from what the host reports. Display
655
+ * only: whether it gives access is the host's (the seam), never worked out from this.
656
+ */
657
+ export declare function subscriptionStatus(sub: AccountSubscription, locale?: string): string;
658
+ /** One period's price in words (`$29.00 a month`), as the host gave it. */
659
+ export declare function subscriptionPrice(sub: AccountSubscription, locale?: string): string;
660
+ /** What a native shell says where money is managed on the website (ADR 0714). */
661
+ export declare const MANAGE_ON_WEBSITE_WORDS = "Manage on the website";
662
+ /** What to tell a customer whose account call did not go through, in plain words. */
663
+ export declare function accountErrorWords(error: unknown): string;
664
+ /** The details form, in memory until saved. */
665
+ export interface DetailsForm {
666
+ displayName: string;
667
+ givenName: string;
668
+ familyName: string;
669
+ primaryPhone: string;
670
+ }
671
+ /** The longest values the host takes (it checks again). */
672
+ export declare const DETAILS_MAX: {
673
+ displayName: number;
674
+ givenName: number;
675
+ familyName: number;
676
+ primaryPhone: number;
677
+ };
678
+ export declare function detailsForm(me: Pick<AccountMe, keyof DetailsForm>): DetailsForm;
679
+ /** What is wrong before saving, field by field (the host checks again). */
680
+ export declare function detailsProblems(form: DetailsForm): {
681
+ field: keyof DetailsForm;
682
+ message: string;
683
+ }[];
684
+ /** The `me.update` input: only what changed, an emptied field as null. Null when nothing did. */
685
+ export declare function detailsInput(me: Pick<AccountMe, keyof DetailsForm>, form: DetailsForm): AccountDetailsInput | null;
686
+ /** The birthday form: a day and a month as chosen, "" for none. */
687
+ export interface BirthdayForm {
688
+ day: string;
689
+ month: string;
690
+ }
691
+ /** The days a month can have, for a day picker: 1 to 31 until a month is chosen. */
692
+ export declare function birthdayDays(month: string): number[];
693
+ /** The twelve months' names in `locale`, January first, with their numbers. */
694
+ export declare function birthdayMonths(locale?: string): {
695
+ value: string;
696
+ label: string;
697
+ }[];
698
+ export declare function birthdayForm(birthday: AccountBirthday | null): BirthdayForm;
699
+ /** What is wrong before saving (the host checks again): both or neither, a day the month has. */
700
+ export declare function birthdayProblem(form: BirthdayForm): string | null;
701
+ /** The `me.birthday.set` input when the form changed it (none chosen clears it), else null. */
702
+ export declare function birthdayInput(current: AccountBirthday | null, form: BirthdayForm): {
703
+ birthday: AccountBirthday | null;
704
+ } | null;
705
+ /**
706
+ * Orders a page holds. The page's lines are read in one `my.list` whose filter names every order
707
+ * of the page, each a bound variable: kept well under D1's 100 per statement.
708
+ */
709
+ export declare const ORDERS_PAGE = 20;
710
+ /** One page of the customer's orders, newest first, with their lines. */
711
+ export interface OrdersPage {
712
+ orders: AccountOrder[];
713
+ nextCursor: string | null;
714
+ }
715
+ /**
716
+ * The customer's generated client as this entry's own reads take it (`loadOrders`), for code that
717
+ * does not use the hooks: a plain page, a server function. It must hold `my.list`.
718
+ */
719
+ export declare function accountClient(client: ClientHolding & {
720
+ readonly operations: {
721
+ readonly "my.list": unknown;
722
+ };
723
+ }): AccountClient;
724
+ /**
725
+ * One page of the signed-in customer's orders, newest first, each with its lines: their own
726
+ * only (the seam's `my.list` on `order` and `orderLine`; a child's orders are the child's). Two
727
+ * reads for a page, and a few more only for a page of very many lines.
728
+ */
729
+ export declare function loadOrders(api: AccountClient, cursor?: string): Promise<OrdersPage>;
730
+ /** Whether the host refused because the customer must sign in again first (`sign_in_again`). */
731
+ export declare function isSignInAgain(error: unknown): boolean;
732
+ /** What a block says when the host asks for a fresh sign-in before going on. */
733
+ export declare const SIGN_IN_AGAIN_WORDS = "For your safety, sign in again first: we email a code to the address you sign in with. Then you carry on here.";
734
+ /**
735
+ * How a block signs the customer in again in place, as the app's sign-in does it: ask the host
736
+ * for a code to their own sign-in address, then sign in with it (the web template's `/auth/code`
737
+ * and `/auth/sign-in`, the mobile app's session). `confirm` answers falsy for a code that did not
738
+ * work.
739
+ */
740
+ export interface AccountSignIn {
741
+ requestCode(email: string): Promise<boolean>;
742
+ confirm(email: string, code: string): Promise<unknown>;
743
+ }
744
+ /** What a sensitive act came to: done, refused until a fresh sign-in, or failed. */
745
+ export type SensitiveOutcome<T> = {
746
+ kind: "done";
747
+ value: T;
748
+ } | {
749
+ kind: "sign_in_again";
750
+ } | {
751
+ kind: "failed";
752
+ error: unknown;
753
+ };
754
+ /**
755
+ * Runs an act the host keeps to a recent sign-in (changing the sign-in address, deleting the
756
+ * account). A `sign_in_again` refusal is its own outcome, never a failure and never done: the block
757
+ * shows the sign-in step, keeps what the customer was doing, and runs the act again after it.
758
+ */
759
+ export declare function sensitive<T>(act: () => Promise<T>): Promise<SensitiveOutcome<T>>;
760
+ /** The longest address the host takes (it checks again). */
761
+ export declare const EMAIL_MAX = 320;
762
+ /**
763
+ * What is wrong with a new sign-in address before asking (the host checks again), or null. Whether
764
+ * the address can be used is never known here: the host says so only once its code is entered.
765
+ */
766
+ export declare function emailChangeProblem(email: string, current: string): string | null;
767
+ /** A six-digit code, as typed: spaces taken out (the host checks it). */
768
+ export declare function codeInput(typed: string): string;
769
+ /** What to tell a customer whose address change was refused: the host's own words where it gave some. */
770
+ export declare function emailChangeErrorWords(error: unknown): string;
771
+ /** What a customer types to confirm deleting their account. */
772
+ export declare const DELETE_WORD = "DELETE";
773
+ /** Whether the host answered the preview (nothing deleted yet). */
774
+ export declare function isDeletePreview(answer: DeletePreview | DeleteDone | undefined): answer is DeletePreview;
775
+ /**
776
+ * The confirming call's input: only from a preview the host gave (its `expect`), and only once the
777
+ * customer has typed the word. Null otherwise, and the block does not call: nothing is deleted
778
+ * without the customer having been shown, in full, what it will do.
779
+ */
780
+ export declare function deleteConfirmInput(preview: DeletePreview | null | undefined, typed: string): {
781
+ confirm: true;
782
+ expect: string;
783
+ } | null;
784
+ /**
785
+ * Confirms the deletion (`act`: the confirming call) as a sensitive act, and once the host has
786
+ * deleted the account runs `forget` before answering: in the app, ending this device's session
787
+ * and forgetting its stored tokens (`session.signOut`), so a relaunch finds no session even if
788
+ * the person never leaves the screen. A `forget` that fails (offline) is not the deletion's
789
+ * failure: the host has already ended every session.
790
+ */
791
+ export declare function confirmDelete(act: () => Promise<DeletePreview | DeleteDone>, forget?: () => Promise<unknown>): Promise<SensitiveOutcome<DeletePreview | DeleteDone>>;
792
+ /** Whether a confirm was refused because what deleting does changed since the preview. */
793
+ export declare function isPreviewChanged(error: unknown): boolean;
794
+ /** The preview in words, every part of it, as the host answered it. Display only. */
795
+ export declare function deletePreviewWords(preview: DeletePreview, locale?: string): {
796
+ ends: string[];
797
+ cancelled: string[];
798
+ left: string[];
799
+ erase: string;
800
+ };
801
+ /** What a customer is told once the account is deleted. */
802
+ export declare function deletedWords(done: DeleteDone, locale?: string): string;
803
+ /** An attention item in words: what it is, the detail, and what the button says. Display only. */
804
+ export declare function attentionWords(item: AttentionItem, locale?: string): {
805
+ title: string;
806
+ detail: string;
807
+ action: string | null;
808
+ whose: string | null;
809
+ };
810
+ /**
811
+ * Where an attention item is dealt with: a section of My account (for money owed on an order, the
812
+ * order in Orders, `order`: the web pays it there, the app opens the website), a page, or a form
813
+ * to open.
814
+ */
815
+ export type AttentionTarget = {
816
+ kind: "section";
817
+ key: string;
818
+ order?: string;
819
+ } | {
820
+ kind: "page";
821
+ url: string;
822
+ } | {
823
+ kind: "form";
824
+ link: string;
825
+ };
826
+ /**
827
+ * Where to send the customer for an item, among the sections shown (`shown`, the host's sections
828
+ * the app has): agreements for a document, Payment method for a failed card, the order itself in
829
+ * Orders for money owed on it (where the web pays it), the pack's section for its pass or its plan's trial, the provider's page for a payment
830
+ * the bank waits on (from the subscription the host listed), the form by its link. Null where
831
+ * nothing shown deals with it: the item is still listed. A lookup, never a rule.
832
+ */
833
+ export declare function attentionTarget(item: AttentionItem, shown: readonly {
834
+ key: string;
835
+ }[], subscriptions?: readonly Pick<AccountSubscription, "id" | "planObject" | "actionUrl">[]): AttentionTarget | null;
836
+ /** The app's `useQuery` and `useMutation`, as far as these hooks use them. */
837
+ export type AccountUseQuery = UseQuery;
838
+ export type AccountUseMutation = UseMutation;
839
+ /** The operations each hook calls (ADR 0453). */
840
+ export declare const ACCOUNT_HOOKS_CALL: {
841
+ readonly usePortal: readonly ["me.portal"];
842
+ readonly useAttention: readonly ["me.attention"];
843
+ readonly useChangeEmail: readonly ["me.email.change"];
844
+ readonly useConfirmEmail: readonly ["me.email.confirm"];
845
+ readonly useDeleteAccount: readonly ["me.deleteAccount"];
846
+ readonly useMe: readonly ["me.get"];
847
+ readonly useUpdateMe: readonly ["me.update"];
848
+ readonly useBirthday: readonly ["me.birthday.get"];
849
+ readonly useSetBirthday: readonly ["me.birthday.set"];
850
+ readonly useSessions: readonly ["me.sessions.list"];
851
+ readonly useRevokeSession: readonly ["me.sessions.revoke"];
852
+ readonly useFamily: readonly ["me.family"];
853
+ readonly useOrders: readonly ["my.list"];
854
+ readonly useSubscriptions: readonly ["subscription.list"];
855
+ readonly useCancelSubscription: readonly ["subscription.cancel"];
856
+ readonly useResumeSubscription: readonly ["subscription.resume"];
857
+ readonly useBillingPortal: readonly ["subscription.portal"];
858
+ readonly useCheckoutOrder: readonly ["order.checkout"];
859
+ readonly useContactChoices: readonly ["me.contact.choices"];
860
+ readonly useSetContactChoices: readonly ["me.contact.setChoices"];
861
+ };
862
+ /**
863
+ * The app's React functions, as far as these hooks use them. `useQueryClient` (TanStack Query's)
864
+ * lets a deletion forget what the app's cache holds of the account at once (`useDeleteAccount`).
865
+ */
866
+ export interface AccountReact {
867
+ useQuery: AccountUseQuery;
868
+ useMutation: AccountUseMutation;
869
+ useQueryClient?: () => {
870
+ removeQueries(): unknown;
871
+ };
872
+ }
873
+ /**
874
+ * Hooks for a React or React Native app:
875
+ * `const account = createAccountHooks({ useQuery, useMutation, useQueryClient }, api)`, with the
876
+ * customer's generated client. The hooks it cannot back are not there.
877
+ */
878
+ export declare function createAccountHooks<C extends ClientHolding>(react: AccountReact, client: C): import("./hooks.ts").HooksFor<{
879
+ /** Which sections of My account they have, in order, and whether they pay a subscription. */
880
+ usePortal(): {
881
+ data: AccountPortal | undefined;
882
+ isPending: boolean;
883
+ error: unknown;
884
+ refetch?: () => unknown;
885
+ };
886
+ /** What needs their attention, or a child's they act for, soonest first. */
887
+ useAttention(): {
888
+ data: AccountAttention | undefined;
889
+ isPending: boolean;
890
+ error: unknown;
891
+ refetch?: () => unknown;
892
+ };
893
+ /**
894
+ * Ask for a code at a new sign-in address (after a recent sign-in, else `sign_in_again`). The
895
+ * address is not kept in the app's cache once the call is over.
896
+ */
897
+ useChangeEmail(): {
898
+ mutate(input: {
899
+ email: string;
900
+ }): void;
901
+ mutateAsync(input: {
902
+ email: string;
903
+ }): Promise<{
904
+ newEmail: string;
905
+ expiresAt: string;
906
+ }>;
907
+ data: {
908
+ newEmail: string;
909
+ expiresAt: string;
910
+ } | undefined;
911
+ isPending: boolean;
912
+ error: unknown;
913
+ reset?: () => void;
914
+ };
915
+ /** Finish the change with the code from the new address; the code is not kept either. */
916
+ useConfirmEmail(): {
917
+ mutate(input: {
918
+ code: string;
919
+ }): void;
920
+ mutateAsync(input: {
921
+ code: string;
922
+ }): Promise<{
923
+ signInEmail: string;
924
+ sessionsEnded: number;
925
+ }>;
926
+ data: {
927
+ signInEmail: string;
928
+ sessionsEnded: number;
929
+ } | undefined;
930
+ isPending: boolean;
931
+ error: unknown;
932
+ reset?: () => void;
933
+ };
934
+ /**
935
+ * Delete the account: with `{}` the host says what it will do; with `deleteConfirmInput`
936
+ * (the preview's `expect`) it does that. After a recent sign-in, else `sign_in_again`. Once
937
+ * the host has deleted it, every query the app's cache holds is forgotten at once (with the
938
+ * app's `useQueryClient` given): nothing of the account stays in memory until the app leaves.
939
+ */
940
+ useDeleteAccount(): {
941
+ mutate(input: {
942
+ confirm?: boolean;
943
+ expect?: string;
944
+ }): void;
945
+ mutateAsync(input: {
946
+ confirm?: boolean;
947
+ expect?: string;
948
+ }): Promise<DeletePreview | DeleteDone>;
949
+ data: DeletePreview | DeleteDone | undefined;
950
+ isPending: boolean;
951
+ error: unknown;
952
+ reset?: () => void;
953
+ };
954
+ /** The signed-in customer's own Person and sign-in address. */
955
+ useMe(): {
956
+ data: AccountMe | undefined;
957
+ isPending: boolean;
958
+ error: unknown;
959
+ refetch?: () => unknown;
960
+ };
961
+ /** Change their name or phone: pass only what changed (`detailsInput`). */
962
+ useUpdateMe(): {
963
+ mutate(input: AccountDetailsInput): void;
964
+ mutateAsync(input: AccountDetailsInput): Promise<Omit<AccountMe, "signInEmail" | "signInEmailVerified">>;
965
+ data: Omit<AccountMe, "signInEmail" | "signInEmailVerified"> | undefined;
966
+ isPending: boolean;
967
+ error: unknown;
968
+ reset?: () => void;
969
+ };
970
+ /** Their birthday, day and month, or null (stage 53). */
971
+ useBirthday(): {
972
+ data: {
973
+ birthday: AccountBirthday | null;
974
+ } | undefined;
975
+ isPending: boolean;
976
+ error: unknown;
977
+ refetch?: () => unknown;
978
+ };
979
+ /** Give, change or remove their birthday (`birthdayInput`). */
980
+ useSetBirthday(): {
981
+ mutate(input: {
982
+ birthday: AccountBirthday | null;
983
+ }): void;
984
+ mutateAsync(input: {
985
+ birthday: AccountBirthday | null;
986
+ }): Promise<{
987
+ birthday: AccountBirthday | null;
988
+ }>;
989
+ data: {
990
+ birthday: AccountBirthday | null;
991
+ } | undefined;
992
+ isPending: boolean;
993
+ error: unknown;
994
+ reset?: () => void;
995
+ };
996
+ /** The places they are signed in. */
997
+ useSessions(): {
998
+ data: {
999
+ items: AccountSession[];
1000
+ } | undefined;
1001
+ isPending: boolean;
1002
+ error: unknown;
1003
+ refetch?: () => unknown;
1004
+ };
1005
+ /** Sign out one of their sessions, by its id. */
1006
+ useRevokeSession(): {
1007
+ mutate(input: {
1008
+ id: string;
1009
+ }): void;
1010
+ mutateAsync(input: {
1011
+ id: string;
1012
+ }): Promise<{
1013
+ id: string;
1014
+ revoked: true;
1015
+ }>;
1016
+ data: {
1017
+ id: string;
1018
+ revoked: true;
1019
+ } | undefined;
1020
+ isPending: boolean;
1021
+ error: unknown;
1022
+ reset?: () => void;
1023
+ };
1024
+ /** Who they act for and who acts for them. */
1025
+ useFamily(): {
1026
+ data: AccountFamily | undefined;
1027
+ isPending: boolean;
1028
+ error: unknown;
1029
+ refetch?: () => unknown;
1030
+ };
1031
+ /** One page of their orders with lines, newest first: pass a page's `nextCursor` for the next. */
1032
+ useOrders(cursor?: string): {
1033
+ data: OrdersPage | undefined;
1034
+ isPending: boolean;
1035
+ error: unknown;
1036
+ refetch?: () => unknown;
1037
+ };
1038
+ /** The subscriptions they pay, newest first (the host lists a customer only those). */
1039
+ useSubscriptions(): {
1040
+ data: {
1041
+ items: AccountSubscription[];
1042
+ nextCursor: string | null;
1043
+ } | undefined;
1044
+ isPending: boolean;
1045
+ error: unknown;
1046
+ refetch?: () => unknown;
1047
+ };
1048
+ /** End one they pay when its period ends (web only). */
1049
+ useCancelSubscription(): {
1050
+ mutate(input: {
1051
+ id: string;
1052
+ reason?: string;
1053
+ }): void;
1054
+ mutateAsync(input: {
1055
+ id: string;
1056
+ reason?: string;
1057
+ }): Promise<{
1058
+ id: string;
1059
+ requested: true;
1060
+ }>;
1061
+ data: {
1062
+ id: string;
1063
+ requested: true;
1064
+ } | undefined;
1065
+ isPending: boolean;
1066
+ error: unknown;
1067
+ reset?: () => void;
1068
+ };
1069
+ /** Keep going one cancelled at the period's end, before it ends (web only). */
1070
+ useResumeSubscription(): {
1071
+ mutate(input: {
1072
+ id: string;
1073
+ }): void;
1074
+ mutateAsync(input: {
1075
+ id: string;
1076
+ }): Promise<{
1077
+ id: string;
1078
+ requested: true;
1079
+ }>;
1080
+ data: {
1081
+ id: string;
1082
+ requested: true;
1083
+ } | undefined;
1084
+ isPending: boolean;
1085
+ error: unknown;
1086
+ reset?: () => void;
1087
+ };
1088
+ /** The provider's page for their card and past invoices (web only, never in a frame). */
1089
+ useBillingPortal(): {
1090
+ mutate(input: {
1091
+ returnUrl: string;
1092
+ }): void;
1093
+ mutateAsync(input: {
1094
+ returnUrl: string;
1095
+ }): Promise<{
1096
+ url: string;
1097
+ }>;
1098
+ data: {
1099
+ url: string;
1100
+ } | undefined;
1101
+ isPending: boolean;
1102
+ error: unknown;
1103
+ reset?: () => void;
1104
+ };
1105
+ /**
1106
+ * Pay one of their own orders on the provider's page (web only, ADR 0714): the host says what
1107
+ * is charged (the order, its deposit or the rest) and answers the page's address.
1108
+ */
1109
+ useCheckoutOrder(): {
1110
+ mutate(input: {
1111
+ id: string;
1112
+ returnUrl: string;
1113
+ }): void;
1114
+ mutateAsync(input: {
1115
+ id: string;
1116
+ returnUrl: string;
1117
+ }): Promise<{
1118
+ url: string;
1119
+ amount: number;
1120
+ currency: string;
1121
+ kind: "full" | "deposit" | "balance" | "part";
1122
+ expiresAt: string | null;
1123
+ }>;
1124
+ data: {
1125
+ url: string;
1126
+ amount: number;
1127
+ currency: string;
1128
+ kind: "full" | "deposit" | "balance" | "part";
1129
+ expiresAt: string | null;
1130
+ } | undefined;
1131
+ isPending: boolean;
1132
+ error: unknown;
1133
+ reset?: () => void;
1134
+ };
1135
+ /** Their contact preferences, and each child's they act for (stage 30). */
1136
+ useContactChoices(): {
1137
+ data: {
1138
+ people: ContactPerson[];
1139
+ } | undefined;
1140
+ isPending: boolean;
1141
+ error: unknown;
1142
+ refetch?: () => unknown;
1143
+ };
1144
+ /** Change one or more of them (`contactToggle` makes the change for one channel). */
1145
+ useSetContactChoices(): {
1146
+ mutate(input: ContactChoicesInput): void;
1147
+ mutateAsync(input: ContactChoicesInput): Promise<{
1148
+ changed: number;
1149
+ }>;
1150
+ data: {
1151
+ changed: number;
1152
+ } | undefined;
1153
+ isPending: boolean;
1154
+ error: unknown;
1155
+ reset?: () => void;
1156
+ };
1157
+ }, {
1158
+ readonly usePortal: readonly ["me.portal"];
1159
+ readonly useAttention: readonly ["me.attention"];
1160
+ readonly useChangeEmail: readonly ["me.email.change"];
1161
+ readonly useConfirmEmail: readonly ["me.email.confirm"];
1162
+ readonly useDeleteAccount: readonly ["me.deleteAccount"];
1163
+ readonly useMe: readonly ["me.get"];
1164
+ readonly useUpdateMe: readonly ["me.update"];
1165
+ readonly useBirthday: readonly ["me.birthday.get"];
1166
+ readonly useSetBirthday: readonly ["me.birthday.set"];
1167
+ readonly useSessions: readonly ["me.sessions.list"];
1168
+ readonly useRevokeSession: readonly ["me.sessions.revoke"];
1169
+ readonly useFamily: readonly ["me.family"];
1170
+ readonly useOrders: readonly ["my.list"];
1171
+ readonly useSubscriptions: readonly ["subscription.list"];
1172
+ readonly useCancelSubscription: readonly ["subscription.cancel"];
1173
+ readonly useResumeSubscription: readonly ["subscription.resume"];
1174
+ readonly useBillingPortal: readonly ["subscription.portal"];
1175
+ readonly useCheckoutOrder: readonly ["order.checkout"];
1176
+ readonly useContactChoices: readonly ["me.contact.choices"];
1177
+ readonly useSetContactChoices: readonly ["me.contact.setChoices"];
1178
+ }, import("./hooks.ts").OperationsOf<C>>;
1179
+ declare function allAccountHooks(react: AccountReact, api: AccountClient): {
1180
+ /** Which sections of My account they have, in order, and whether they pay a subscription. */
1181
+ usePortal(): {
1182
+ data: AccountPortal | undefined;
1183
+ isPending: boolean;
1184
+ error: unknown;
1185
+ refetch?: () => unknown;
1186
+ };
1187
+ /** What needs their attention, or a child's they act for, soonest first. */
1188
+ useAttention(): {
1189
+ data: AccountAttention | undefined;
1190
+ isPending: boolean;
1191
+ error: unknown;
1192
+ refetch?: () => unknown;
1193
+ };
1194
+ /**
1195
+ * Ask for a code at a new sign-in address (after a recent sign-in, else `sign_in_again`). The
1196
+ * address is not kept in the app's cache once the call is over.
1197
+ */
1198
+ useChangeEmail(): {
1199
+ mutate(input: {
1200
+ email: string;
1201
+ }): void;
1202
+ mutateAsync(input: {
1203
+ email: string;
1204
+ }): Promise<{
1205
+ newEmail: string;
1206
+ expiresAt: string;
1207
+ }>;
1208
+ data: {
1209
+ newEmail: string;
1210
+ expiresAt: string;
1211
+ } | undefined;
1212
+ isPending: boolean;
1213
+ error: unknown;
1214
+ reset?: () => void;
1215
+ };
1216
+ /** Finish the change with the code from the new address; the code is not kept either. */
1217
+ useConfirmEmail(): {
1218
+ mutate(input: {
1219
+ code: string;
1220
+ }): void;
1221
+ mutateAsync(input: {
1222
+ code: string;
1223
+ }): Promise<{
1224
+ signInEmail: string;
1225
+ sessionsEnded: number;
1226
+ }>;
1227
+ data: {
1228
+ signInEmail: string;
1229
+ sessionsEnded: number;
1230
+ } | undefined;
1231
+ isPending: boolean;
1232
+ error: unknown;
1233
+ reset?: () => void;
1234
+ };
1235
+ /**
1236
+ * Delete the account: with `{}` the host says what it will do; with `deleteConfirmInput`
1237
+ * (the preview's `expect`) it does that. After a recent sign-in, else `sign_in_again`. Once
1238
+ * the host has deleted it, every query the app's cache holds is forgotten at once (with the
1239
+ * app's `useQueryClient` given): nothing of the account stays in memory until the app leaves.
1240
+ */
1241
+ useDeleteAccount(): {
1242
+ mutate(input: {
1243
+ confirm?: boolean;
1244
+ expect?: string;
1245
+ }): void;
1246
+ mutateAsync(input: {
1247
+ confirm?: boolean;
1248
+ expect?: string;
1249
+ }): Promise<DeletePreview | DeleteDone>;
1250
+ data: DeletePreview | DeleteDone | undefined;
1251
+ isPending: boolean;
1252
+ error: unknown;
1253
+ reset?: () => void;
1254
+ };
1255
+ /** The signed-in customer's own Person and sign-in address. */
1256
+ useMe(): {
1257
+ data: AccountMe | undefined;
1258
+ isPending: boolean;
1259
+ error: unknown;
1260
+ refetch?: () => unknown;
1261
+ };
1262
+ /** Change their name or phone: pass only what changed (`detailsInput`). */
1263
+ useUpdateMe(): {
1264
+ mutate(input: AccountDetailsInput): void;
1265
+ mutateAsync(input: AccountDetailsInput): Promise<Omit<AccountMe, "signInEmail" | "signInEmailVerified">>;
1266
+ data: Omit<AccountMe, "signInEmail" | "signInEmailVerified"> | undefined;
1267
+ isPending: boolean;
1268
+ error: unknown;
1269
+ reset?: () => void;
1270
+ };
1271
+ /** Their birthday, day and month, or null (stage 53). */
1272
+ useBirthday(): {
1273
+ data: {
1274
+ birthday: AccountBirthday | null;
1275
+ } | undefined;
1276
+ isPending: boolean;
1277
+ error: unknown;
1278
+ refetch?: () => unknown;
1279
+ };
1280
+ /** Give, change or remove their birthday (`birthdayInput`). */
1281
+ useSetBirthday(): {
1282
+ mutate(input: {
1283
+ birthday: AccountBirthday | null;
1284
+ }): void;
1285
+ mutateAsync(input: {
1286
+ birthday: AccountBirthday | null;
1287
+ }): Promise<{
1288
+ birthday: AccountBirthday | null;
1289
+ }>;
1290
+ data: {
1291
+ birthday: AccountBirthday | null;
1292
+ } | undefined;
1293
+ isPending: boolean;
1294
+ error: unknown;
1295
+ reset?: () => void;
1296
+ };
1297
+ /** The places they are signed in. */
1298
+ useSessions(): {
1299
+ data: {
1300
+ items: AccountSession[];
1301
+ } | undefined;
1302
+ isPending: boolean;
1303
+ error: unknown;
1304
+ refetch?: () => unknown;
1305
+ };
1306
+ /** Sign out one of their sessions, by its id. */
1307
+ useRevokeSession(): {
1308
+ mutate(input: {
1309
+ id: string;
1310
+ }): void;
1311
+ mutateAsync(input: {
1312
+ id: string;
1313
+ }): Promise<{
1314
+ id: string;
1315
+ revoked: true;
1316
+ }>;
1317
+ data: {
1318
+ id: string;
1319
+ revoked: true;
1320
+ } | undefined;
1321
+ isPending: boolean;
1322
+ error: unknown;
1323
+ reset?: () => void;
1324
+ };
1325
+ /** Who they act for and who acts for them. */
1326
+ useFamily(): {
1327
+ data: AccountFamily | undefined;
1328
+ isPending: boolean;
1329
+ error: unknown;
1330
+ refetch?: () => unknown;
1331
+ };
1332
+ /** One page of their orders with lines, newest first: pass a page's `nextCursor` for the next. */
1333
+ useOrders(cursor?: string): {
1334
+ data: OrdersPage | undefined;
1335
+ isPending: boolean;
1336
+ error: unknown;
1337
+ refetch?: () => unknown;
1338
+ };
1339
+ /** The subscriptions they pay, newest first (the host lists a customer only those). */
1340
+ useSubscriptions(): {
1341
+ data: {
1342
+ items: AccountSubscription[];
1343
+ nextCursor: string | null;
1344
+ } | undefined;
1345
+ isPending: boolean;
1346
+ error: unknown;
1347
+ refetch?: () => unknown;
1348
+ };
1349
+ /** End one they pay when its period ends (web only). */
1350
+ useCancelSubscription(): {
1351
+ mutate(input: {
1352
+ id: string;
1353
+ reason?: string;
1354
+ }): void;
1355
+ mutateAsync(input: {
1356
+ id: string;
1357
+ reason?: string;
1358
+ }): Promise<{
1359
+ id: string;
1360
+ requested: true;
1361
+ }>;
1362
+ data: {
1363
+ id: string;
1364
+ requested: true;
1365
+ } | undefined;
1366
+ isPending: boolean;
1367
+ error: unknown;
1368
+ reset?: () => void;
1369
+ };
1370
+ /** Keep going one cancelled at the period's end, before it ends (web only). */
1371
+ useResumeSubscription(): {
1372
+ mutate(input: {
1373
+ id: string;
1374
+ }): void;
1375
+ mutateAsync(input: {
1376
+ id: string;
1377
+ }): Promise<{
1378
+ id: string;
1379
+ requested: true;
1380
+ }>;
1381
+ data: {
1382
+ id: string;
1383
+ requested: true;
1384
+ } | undefined;
1385
+ isPending: boolean;
1386
+ error: unknown;
1387
+ reset?: () => void;
1388
+ };
1389
+ /** The provider's page for their card and past invoices (web only, never in a frame). */
1390
+ useBillingPortal(): {
1391
+ mutate(input: {
1392
+ returnUrl: string;
1393
+ }): void;
1394
+ mutateAsync(input: {
1395
+ returnUrl: string;
1396
+ }): Promise<{
1397
+ url: string;
1398
+ }>;
1399
+ data: {
1400
+ url: string;
1401
+ } | undefined;
1402
+ isPending: boolean;
1403
+ error: unknown;
1404
+ reset?: () => void;
1405
+ };
1406
+ /**
1407
+ * Pay one of their own orders on the provider's page (web only, ADR 0714): the host says what
1408
+ * is charged (the order, its deposit or the rest) and answers the page's address.
1409
+ */
1410
+ useCheckoutOrder(): {
1411
+ mutate(input: {
1412
+ id: string;
1413
+ returnUrl: string;
1414
+ }): void;
1415
+ mutateAsync(input: {
1416
+ id: string;
1417
+ returnUrl: string;
1418
+ }): Promise<{
1419
+ url: string;
1420
+ amount: number;
1421
+ currency: string;
1422
+ kind: "full" | "deposit" | "balance" | "part";
1423
+ expiresAt: string | null;
1424
+ }>;
1425
+ data: {
1426
+ url: string;
1427
+ amount: number;
1428
+ currency: string;
1429
+ kind: "full" | "deposit" | "balance" | "part";
1430
+ expiresAt: string | null;
1431
+ } | undefined;
1432
+ isPending: boolean;
1433
+ error: unknown;
1434
+ reset?: () => void;
1435
+ };
1436
+ /** Their contact preferences, and each child's they act for (stage 30). */
1437
+ useContactChoices(): {
1438
+ data: {
1439
+ people: ContactPerson[];
1440
+ } | undefined;
1441
+ isPending: boolean;
1442
+ error: unknown;
1443
+ refetch?: () => unknown;
1444
+ };
1445
+ /** Change one or more of them (`contactToggle` makes the change for one channel). */
1446
+ useSetContactChoices(): {
1447
+ mutate(input: ContactChoicesInput): void;
1448
+ mutateAsync(input: ContactChoicesInput): Promise<{
1449
+ changed: number;
1450
+ }>;
1451
+ data: {
1452
+ changed: number;
1453
+ } | undefined;
1454
+ isPending: boolean;
1455
+ error: unknown;
1456
+ reset?: () => void;
1457
+ };
1458
+ };
1459
+ /** Every hook of this entry. A block takes the ones it calls: `Pick<AccountHooks, "useMe">`. */
1460
+ export type AccountHooks = ReturnType<typeof allAccountHooks>;
1461
+ export {};