@composable-os/pack-memberships 0.0.0-stage → 0.1.0-beta.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +109 -0
- package/dist/blocks/memberships-mine/mine.d.ts +6 -0
- package/dist/blocks/memberships-mine/mine.js +48 -0
- package/dist/blocks/memberships-native-mine/mine-screen.d.ts +4 -0
- package/dist/blocks/memberships-native-mine/mine-screen.js +12 -0
- package/dist/blocks/memberships-passes/passes.d.ts +10 -0
- package/dist/blocks/memberships-passes/passes.js +43 -0
- package/dist/blocks/memberships-plans/plans.d.ts +15 -0
- package/dist/blocks/memberships-plans/plans.js +106 -0
- package/dist/blocks/memberships-staff-holdings/holdings.d.ts +10 -0
- package/dist/blocks/memberships-staff-holdings/holdings.js +35 -0
- package/dist/client/index.d.ts +808 -0
- package/dist/client/index.js +212 -0
- package/dist/index.d.ts +894 -0
- package/dist/index.js +559 -0
- package/dist/tools.d.ts +134 -0
- package/dist/tools.js +346 -0
- package/package.json +36 -4
- package/README.md +0 -3
|
@@ -0,0 +1,808 @@
|
|
|
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
|
+
}
|
|
33
|
+
/** Why the host gave no free trial (subscription.start's `noTrial`). */
|
|
34
|
+
export type NoTrial = "sign_in" | "used" | "permission" | "held" | "unconfirmed" | "continuation";
|
|
35
|
+
/** What subscription.start answers. */
|
|
36
|
+
export interface StartedSubscription {
|
|
37
|
+
subscriptionId: string;
|
|
38
|
+
url: string;
|
|
39
|
+
amount: number;
|
|
40
|
+
currency: string;
|
|
41
|
+
interval: "week" | "month" | "year";
|
|
42
|
+
trialDays: number | null;
|
|
43
|
+
freeUntil: string | null;
|
|
44
|
+
noTrial: NoTrial | null;
|
|
45
|
+
expiresAt: string | null;
|
|
46
|
+
}
|
|
47
|
+
/** The operations this entry calls, as the generated client types them. */
|
|
48
|
+
export type MembershipsOperations = {
|
|
49
|
+
"x.memberships.plans": {
|
|
50
|
+
kind: "query";
|
|
51
|
+
} & Io<typeof plans>;
|
|
52
|
+
"x.memberships.passTypes": {
|
|
53
|
+
kind: "query";
|
|
54
|
+
} & Io<typeof passTypes>;
|
|
55
|
+
"x.memberships.buy": {
|
|
56
|
+
kind: "mutation";
|
|
57
|
+
} & Io<typeof buy>;
|
|
58
|
+
"x.memberships.mine": {
|
|
59
|
+
kind: "query";
|
|
60
|
+
} & Io<typeof mine>;
|
|
61
|
+
"x.memberships.holdings": {
|
|
62
|
+
kind: "query";
|
|
63
|
+
} & Io<typeof holdings>;
|
|
64
|
+
"x.memberships.givePass": {
|
|
65
|
+
kind: "mutation";
|
|
66
|
+
} & Io<typeof givePass>;
|
|
67
|
+
"x.memberships.voidPass": {
|
|
68
|
+
kind: "mutation";
|
|
69
|
+
} & Io<typeof voidPass>;
|
|
70
|
+
"order.checkout": {
|
|
71
|
+
kind: "mutation";
|
|
72
|
+
input: {
|
|
73
|
+
id: string;
|
|
74
|
+
token?: string;
|
|
75
|
+
returnUrl: string;
|
|
76
|
+
};
|
|
77
|
+
output: {
|
|
78
|
+
url: string;
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
"subscription.start": {
|
|
82
|
+
kind: "mutation";
|
|
83
|
+
input: {
|
|
84
|
+
plan: {
|
|
85
|
+
object: string;
|
|
86
|
+
id: string;
|
|
87
|
+
};
|
|
88
|
+
returnUrl: string;
|
|
89
|
+
email?: string;
|
|
90
|
+
offerId?: string;
|
|
91
|
+
};
|
|
92
|
+
output: StartedSubscription;
|
|
93
|
+
};
|
|
94
|
+
"subscription.list": {
|
|
95
|
+
kind: "query";
|
|
96
|
+
input: {
|
|
97
|
+
filter?: unknown;
|
|
98
|
+
limit?: number;
|
|
99
|
+
};
|
|
100
|
+
output: {
|
|
101
|
+
items: MembershipSubscription[];
|
|
102
|
+
nextCursor: string | null;
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
"subscription.cancel": {
|
|
106
|
+
kind: "mutation";
|
|
107
|
+
input: {
|
|
108
|
+
id: string;
|
|
109
|
+
reason?: string;
|
|
110
|
+
};
|
|
111
|
+
output: {
|
|
112
|
+
id: string;
|
|
113
|
+
requested: true;
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
"subscription.resume": {
|
|
117
|
+
kind: "mutation";
|
|
118
|
+
input: {
|
|
119
|
+
id: string;
|
|
120
|
+
};
|
|
121
|
+
output: {
|
|
122
|
+
id: string;
|
|
123
|
+
requested: true;
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
"subscription.portal": {
|
|
127
|
+
kind: "mutation";
|
|
128
|
+
input: {
|
|
129
|
+
returnUrl: string;
|
|
130
|
+
};
|
|
131
|
+
output: {
|
|
132
|
+
url: string;
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
export type MembershipsClient = PackClient<MembershipsOperations>;
|
|
137
|
+
type Out<N extends keyof MembershipsOperations> = MembershipsOperations[N]["output"];
|
|
138
|
+
/** One membership or pass of the member's, as `mine` gives it. */
|
|
139
|
+
export type Holding = Out<"x.memberships.mine">["holdings"][number];
|
|
140
|
+
/** A plan on sale, as `plans` gives it. */
|
|
141
|
+
export type Plan = Out<"x.memberships.plans">["plans"][number];
|
|
142
|
+
/** A pass type on sale, as `passTypes` gives it. */
|
|
143
|
+
export type PassType = Out<"x.memberships.passTypes">["passTypes"][number];
|
|
144
|
+
/** A price as the host gave it, in its currency (`99.00 AUD`). Display only: never worked out. */
|
|
145
|
+
export declare function formatPrice(price: number | null | undefined, currency: string | null | undefined): string;
|
|
146
|
+
/** A date as a reader sees it (`3 Dec 2026`), from the host's ISO timestamp. Display only. */
|
|
147
|
+
export declare function day(iso: string | null | undefined): string;
|
|
148
|
+
/** What a plan or pass allows, in words: `3 classes a week · Mon, Wed · 09:00 to 16:00`. */
|
|
149
|
+
export declare function allowsWords(item: {
|
|
150
|
+
uses: number | null;
|
|
151
|
+
per?: "total" | "week" | "month" | null;
|
|
152
|
+
weekdays: readonly string[];
|
|
153
|
+
fromMinute: number | null;
|
|
154
|
+
untilMinute: number | null;
|
|
155
|
+
}): string;
|
|
156
|
+
/**
|
|
157
|
+
* What is left of a holding, in words, from the host's count: `2 of 3 left this week`. Display
|
|
158
|
+
* only: whether it can pay for a class is the host's, at booking.
|
|
159
|
+
*/
|
|
160
|
+
export declare function leftWords(h: Holding): string;
|
|
161
|
+
/** What a membership's subscription means to its payer, in words. Display only. */
|
|
162
|
+
export declare function subscriptionStatus(sub: MembershipSubscription): string;
|
|
163
|
+
/** Whether a subscription is still the payer's to cancel, resume or pay (not ended). */
|
|
164
|
+
export declare const isLive: (sub: MembershipSubscription) => boolean;
|
|
165
|
+
/** What a member is told when the host refuses a pass (its `rule` and `reason`). Display only. */
|
|
166
|
+
export declare function refusalWords(details: {
|
|
167
|
+
rule?: unknown;
|
|
168
|
+
reason?: unknown;
|
|
169
|
+
} | 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
|
+
};
|
|
191
|
+
/**
|
|
192
|
+
* The operations each hook calls (ADR 0453). The public's client gets the plans, the pass types,
|
|
193
|
+
* buying and subscribing; a customer's client also what they hold and their subscriptions; the
|
|
194
|
+
* staff client a person's holdings and giving or voiding a pass.
|
|
195
|
+
*/
|
|
196
|
+
export declare const MEMBERSHIPS_HOOKS_CALL: {
|
|
197
|
+
readonly usePlans: readonly ["x.memberships.plans"];
|
|
198
|
+
readonly usePassTypes: readonly ["x.memberships.passTypes"];
|
|
199
|
+
readonly useBuyPass: readonly ["x.memberships.buy", "order.checkout"];
|
|
200
|
+
readonly useMine: readonly ["x.memberships.mine"];
|
|
201
|
+
readonly useHoldings: readonly ["x.memberships.holdings"];
|
|
202
|
+
readonly useGivePass: readonly ["x.memberships.givePass"];
|
|
203
|
+
readonly useVoidPass: readonly ["x.memberships.voidPass"];
|
|
204
|
+
readonly useSubscribe: readonly ["subscription.start"];
|
|
205
|
+
readonly useMySubscriptions: readonly ["subscription.list"];
|
|
206
|
+
readonly useCancelSubscription: readonly ["subscription.cancel"];
|
|
207
|
+
readonly useResumeSubscription: readonly ["subscription.resume"];
|
|
208
|
+
readonly useBillingPortal: readonly ["subscription.portal"];
|
|
209
|
+
};
|
|
210
|
+
/**
|
|
211
|
+
* Hooks for a React or React Native app:
|
|
212
|
+
* `const memberships = createMembershipsHooks({ useQuery, useMutation }, api)`. The hooks a client
|
|
213
|
+
* cannot back are not there, and calling one does not compile.
|
|
214
|
+
*/
|
|
215
|
+
export declare function createMembershipsHooks<C extends ClientHolding>(react: {
|
|
216
|
+
useQuery: UseQuery;
|
|
217
|
+
useMutation: UseMutation;
|
|
218
|
+
}, client: C): import("@composable-os/client").HooksFor<{
|
|
219
|
+
/** The membership plans on sale, with the host's prices and trial days. */
|
|
220
|
+
usePlans(): {
|
|
221
|
+
data: {
|
|
222
|
+
plans: {
|
|
223
|
+
classTypes: string[];
|
|
224
|
+
weekdays: string[];
|
|
225
|
+
fromMinute: number | null;
|
|
226
|
+
untilMinute: number | null;
|
|
227
|
+
id: string;
|
|
228
|
+
title: string | null;
|
|
229
|
+
summary: string | null;
|
|
230
|
+
description: string | null;
|
|
231
|
+
price: number | null;
|
|
232
|
+
uses: number | null;
|
|
233
|
+
per: "week" | "month" | null;
|
|
234
|
+
trialDays: number | null;
|
|
235
|
+
}[];
|
|
236
|
+
currency: string | null;
|
|
237
|
+
} | undefined;
|
|
238
|
+
isPending: boolean;
|
|
239
|
+
error: unknown;
|
|
240
|
+
};
|
|
241
|
+
/** The passes on sale, with the host's prices. */
|
|
242
|
+
usePassTypes(): {
|
|
243
|
+
data: {
|
|
244
|
+
passTypes: {
|
|
245
|
+
classTypes: string[];
|
|
246
|
+
weekdays: string[];
|
|
247
|
+
fromMinute: number | null;
|
|
248
|
+
untilMinute: number | null;
|
|
249
|
+
id: string;
|
|
250
|
+
title: string | null;
|
|
251
|
+
summary: string | null;
|
|
252
|
+
description: string | null;
|
|
253
|
+
price: number | null;
|
|
254
|
+
uses: number | null;
|
|
255
|
+
validDays: number | null;
|
|
256
|
+
onePerPerson: boolean;
|
|
257
|
+
}[];
|
|
258
|
+
currency: string | null;
|
|
259
|
+
} | undefined;
|
|
260
|
+
isPending: boolean;
|
|
261
|
+
error: unknown;
|
|
262
|
+
};
|
|
263
|
+
/** Start an order for a pass; then `checkout` it on the provider's page (web only). */
|
|
264
|
+
useBuyPass(): {
|
|
265
|
+
start: {
|
|
266
|
+
mutate(input: {
|
|
267
|
+
passTypeId: string;
|
|
268
|
+
email?: string | undefined;
|
|
269
|
+
}): void;
|
|
270
|
+
mutateAsync(input: {
|
|
271
|
+
passTypeId: string;
|
|
272
|
+
email?: string | undefined;
|
|
273
|
+
}): Promise<{
|
|
274
|
+
id: string;
|
|
275
|
+
state: string;
|
|
276
|
+
currency: string;
|
|
277
|
+
total: number;
|
|
278
|
+
token: string | null;
|
|
279
|
+
}>;
|
|
280
|
+
data: {
|
|
281
|
+
id: string;
|
|
282
|
+
state: string;
|
|
283
|
+
currency: string;
|
|
284
|
+
total: number;
|
|
285
|
+
token: string | null;
|
|
286
|
+
} | undefined;
|
|
287
|
+
isPending: boolean;
|
|
288
|
+
error: unknown;
|
|
289
|
+
};
|
|
290
|
+
checkout: {
|
|
291
|
+
mutate(input: {
|
|
292
|
+
id: string;
|
|
293
|
+
token?: string;
|
|
294
|
+
returnUrl: string;
|
|
295
|
+
}): void;
|
|
296
|
+
mutateAsync(input: {
|
|
297
|
+
id: string;
|
|
298
|
+
token?: string;
|
|
299
|
+
returnUrl: string;
|
|
300
|
+
}): Promise<{
|
|
301
|
+
url: string;
|
|
302
|
+
}>;
|
|
303
|
+
data: {
|
|
304
|
+
url: string;
|
|
305
|
+
} | undefined;
|
|
306
|
+
isPending: boolean;
|
|
307
|
+
error: unknown;
|
|
308
|
+
};
|
|
309
|
+
};
|
|
310
|
+
/** The signed-in member's memberships and passes, with the host's count of what is left. */
|
|
311
|
+
useMine(): {
|
|
312
|
+
data: {
|
|
313
|
+
holdings: {
|
|
314
|
+
classTypes: string[];
|
|
315
|
+
weekdays: string[];
|
|
316
|
+
fromMinute: number | null;
|
|
317
|
+
untilMinute: number | null;
|
|
318
|
+
id: string;
|
|
319
|
+
kind: "membership" | "pass";
|
|
320
|
+
title: string | null;
|
|
321
|
+
status: string;
|
|
322
|
+
uses: number | null;
|
|
323
|
+
per: "week" | "month" | "total";
|
|
324
|
+
from: string | null;
|
|
325
|
+
until: string | null;
|
|
326
|
+
live: boolean;
|
|
327
|
+
period: {
|
|
328
|
+
key: string;
|
|
329
|
+
startsAt: string;
|
|
330
|
+
endsAt: string;
|
|
331
|
+
used: number;
|
|
332
|
+
left: number | null;
|
|
333
|
+
} | null;
|
|
334
|
+
}[];
|
|
335
|
+
} | undefined;
|
|
336
|
+
isPending: boolean;
|
|
337
|
+
error: unknown;
|
|
338
|
+
};
|
|
339
|
+
/** Staff: one person's memberships and passes. */
|
|
340
|
+
useHoldings(personId: string): {
|
|
341
|
+
data: {
|
|
342
|
+
holdings: {
|
|
343
|
+
classTypes: string[];
|
|
344
|
+
weekdays: string[];
|
|
345
|
+
fromMinute: number | null;
|
|
346
|
+
untilMinute: number | null;
|
|
347
|
+
id: string;
|
|
348
|
+
kind: "membership" | "pass";
|
|
349
|
+
title: string | null;
|
|
350
|
+
status: string;
|
|
351
|
+
uses: number | null;
|
|
352
|
+
per: "week" | "month" | "total";
|
|
353
|
+
from: string | null;
|
|
354
|
+
until: string | null;
|
|
355
|
+
live: boolean;
|
|
356
|
+
period: {
|
|
357
|
+
key: string;
|
|
358
|
+
startsAt: string;
|
|
359
|
+
endsAt: string;
|
|
360
|
+
used: number;
|
|
361
|
+
left: number | null;
|
|
362
|
+
} | null;
|
|
363
|
+
}[];
|
|
364
|
+
} | undefined;
|
|
365
|
+
isPending: boolean;
|
|
366
|
+
error: unknown;
|
|
367
|
+
};
|
|
368
|
+
/** Staff (a person): give a pass by hand, with a reason. */
|
|
369
|
+
useGivePass(): {
|
|
370
|
+
mutate(input: {
|
|
371
|
+
personId: string;
|
|
372
|
+
passTypeId: string;
|
|
373
|
+
reason: string;
|
|
374
|
+
uses?: number | undefined;
|
|
375
|
+
}): void;
|
|
376
|
+
mutateAsync(input: {
|
|
377
|
+
personId: string;
|
|
378
|
+
passTypeId: string;
|
|
379
|
+
reason: string;
|
|
380
|
+
uses?: number | undefined;
|
|
381
|
+
}): Promise<{
|
|
382
|
+
passId: string;
|
|
383
|
+
status: string;
|
|
384
|
+
source: string;
|
|
385
|
+
}>;
|
|
386
|
+
data: {
|
|
387
|
+
passId: string;
|
|
388
|
+
status: string;
|
|
389
|
+
source: string;
|
|
390
|
+
} | undefined;
|
|
391
|
+
isPending: boolean;
|
|
392
|
+
error: unknown;
|
|
393
|
+
};
|
|
394
|
+
/** Staff (a person): void a pass given by hand, with a reason. */
|
|
395
|
+
useVoidPass(): {
|
|
396
|
+
mutate(input: {
|
|
397
|
+
passId: string;
|
|
398
|
+
reason: string;
|
|
399
|
+
}): void;
|
|
400
|
+
mutateAsync(input: {
|
|
401
|
+
passId: string;
|
|
402
|
+
reason: string;
|
|
403
|
+
}): Promise<{
|
|
404
|
+
passId: string;
|
|
405
|
+
status: string;
|
|
406
|
+
source: string;
|
|
407
|
+
}>;
|
|
408
|
+
data: {
|
|
409
|
+
passId: string;
|
|
410
|
+
status: string;
|
|
411
|
+
source: string;
|
|
412
|
+
} | undefined;
|
|
413
|
+
isPending: boolean;
|
|
414
|
+
error: unknown;
|
|
415
|
+
};
|
|
416
|
+
/** Start a membership: the host opens the provider's page (web only); the trial is the host's. */
|
|
417
|
+
useSubscribe(): {
|
|
418
|
+
mutate(input: {
|
|
419
|
+
plan: {
|
|
420
|
+
object: string;
|
|
421
|
+
id: string;
|
|
422
|
+
};
|
|
423
|
+
returnUrl: string;
|
|
424
|
+
email?: string;
|
|
425
|
+
offerId?: string;
|
|
426
|
+
}): void;
|
|
427
|
+
mutateAsync(input: {
|
|
428
|
+
plan: {
|
|
429
|
+
object: string;
|
|
430
|
+
id: string;
|
|
431
|
+
};
|
|
432
|
+
returnUrl: string;
|
|
433
|
+
email?: string;
|
|
434
|
+
offerId?: string;
|
|
435
|
+
}): Promise<StartedSubscription>;
|
|
436
|
+
data: StartedSubscription | undefined;
|
|
437
|
+
isPending: boolean;
|
|
438
|
+
error: unknown;
|
|
439
|
+
};
|
|
440
|
+
/** The signed-in payer's own membership subscriptions, newest first. */
|
|
441
|
+
useMySubscriptions(): {
|
|
442
|
+
data: {
|
|
443
|
+
items: MembershipSubscription[];
|
|
444
|
+
nextCursor: string | null;
|
|
445
|
+
} | undefined;
|
|
446
|
+
isPending: boolean;
|
|
447
|
+
error: unknown;
|
|
448
|
+
};
|
|
449
|
+
/** End their own membership when its period ends (web only). */
|
|
450
|
+
useCancelSubscription(): {
|
|
451
|
+
mutate(input: {
|
|
452
|
+
id: string;
|
|
453
|
+
reason?: string;
|
|
454
|
+
}): void;
|
|
455
|
+
mutateAsync(input: {
|
|
456
|
+
id: string;
|
|
457
|
+
reason?: string;
|
|
458
|
+
}): Promise<{
|
|
459
|
+
id: string;
|
|
460
|
+
requested: true;
|
|
461
|
+
}>;
|
|
462
|
+
data: {
|
|
463
|
+
id: string;
|
|
464
|
+
requested: true;
|
|
465
|
+
} | undefined;
|
|
466
|
+
isPending: boolean;
|
|
467
|
+
error: unknown;
|
|
468
|
+
};
|
|
469
|
+
/** Undo that, before the period ends (web only). */
|
|
470
|
+
useResumeSubscription(): {
|
|
471
|
+
mutate(input: {
|
|
472
|
+
id: string;
|
|
473
|
+
}): void;
|
|
474
|
+
mutateAsync(input: {
|
|
475
|
+
id: string;
|
|
476
|
+
}): Promise<{
|
|
477
|
+
id: string;
|
|
478
|
+
requested: true;
|
|
479
|
+
}>;
|
|
480
|
+
data: {
|
|
481
|
+
id: string;
|
|
482
|
+
requested: true;
|
|
483
|
+
} | undefined;
|
|
484
|
+
isPending: boolean;
|
|
485
|
+
error: unknown;
|
|
486
|
+
};
|
|
487
|
+
/** The provider's portal for their card and past invoices (web only, never in a frame). */
|
|
488
|
+
useBillingPortal(): {
|
|
489
|
+
mutate(input: {
|
|
490
|
+
returnUrl: string;
|
|
491
|
+
}): void;
|
|
492
|
+
mutateAsync(input: {
|
|
493
|
+
returnUrl: string;
|
|
494
|
+
}): Promise<{
|
|
495
|
+
url: string;
|
|
496
|
+
}>;
|
|
497
|
+
data: {
|
|
498
|
+
url: string;
|
|
499
|
+
} | undefined;
|
|
500
|
+
isPending: boolean;
|
|
501
|
+
error: unknown;
|
|
502
|
+
};
|
|
503
|
+
}, {
|
|
504
|
+
readonly usePlans: readonly ["x.memberships.plans"];
|
|
505
|
+
readonly usePassTypes: readonly ["x.memberships.passTypes"];
|
|
506
|
+
readonly useBuyPass: readonly ["x.memberships.buy", "order.checkout"];
|
|
507
|
+
readonly useMine: readonly ["x.memberships.mine"];
|
|
508
|
+
readonly useHoldings: readonly ["x.memberships.holdings"];
|
|
509
|
+
readonly useGivePass: readonly ["x.memberships.givePass"];
|
|
510
|
+
readonly useVoidPass: readonly ["x.memberships.voidPass"];
|
|
511
|
+
readonly useSubscribe: readonly ["subscription.start"];
|
|
512
|
+
readonly useMySubscriptions: readonly ["subscription.list"];
|
|
513
|
+
readonly useCancelSubscription: readonly ["subscription.cancel"];
|
|
514
|
+
readonly useResumeSubscription: readonly ["subscription.resume"];
|
|
515
|
+
readonly useBillingPortal: readonly ["subscription.portal"];
|
|
516
|
+
}, import("@composable-os/client").OperationsOf<C>>;
|
|
517
|
+
declare function allMembershipsHooks(react: {
|
|
518
|
+
useQuery: UseQuery;
|
|
519
|
+
useMutation: UseMutation;
|
|
520
|
+
}, api: MembershipsClient): {
|
|
521
|
+
/** The membership plans on sale, with the host's prices and trial days. */
|
|
522
|
+
usePlans(): {
|
|
523
|
+
data: {
|
|
524
|
+
plans: {
|
|
525
|
+
classTypes: string[];
|
|
526
|
+
weekdays: string[];
|
|
527
|
+
fromMinute: number | null;
|
|
528
|
+
untilMinute: number | null;
|
|
529
|
+
id: string;
|
|
530
|
+
title: string | null;
|
|
531
|
+
summary: string | null;
|
|
532
|
+
description: string | null;
|
|
533
|
+
price: number | null;
|
|
534
|
+
uses: number | null;
|
|
535
|
+
per: "week" | "month" | null;
|
|
536
|
+
trialDays: number | null;
|
|
537
|
+
}[];
|
|
538
|
+
currency: string | null;
|
|
539
|
+
} | undefined;
|
|
540
|
+
isPending: boolean;
|
|
541
|
+
error: unknown;
|
|
542
|
+
};
|
|
543
|
+
/** The passes on sale, with the host's prices. */
|
|
544
|
+
usePassTypes(): {
|
|
545
|
+
data: {
|
|
546
|
+
passTypes: {
|
|
547
|
+
classTypes: string[];
|
|
548
|
+
weekdays: string[];
|
|
549
|
+
fromMinute: number | null;
|
|
550
|
+
untilMinute: number | null;
|
|
551
|
+
id: string;
|
|
552
|
+
title: string | null;
|
|
553
|
+
summary: string | null;
|
|
554
|
+
description: string | null;
|
|
555
|
+
price: number | null;
|
|
556
|
+
uses: number | null;
|
|
557
|
+
validDays: number | null;
|
|
558
|
+
onePerPerson: boolean;
|
|
559
|
+
}[];
|
|
560
|
+
currency: string | null;
|
|
561
|
+
} | undefined;
|
|
562
|
+
isPending: boolean;
|
|
563
|
+
error: unknown;
|
|
564
|
+
};
|
|
565
|
+
/** Start an order for a pass; then `checkout` it on the provider's page (web only). */
|
|
566
|
+
useBuyPass(): {
|
|
567
|
+
start: {
|
|
568
|
+
mutate(input: {
|
|
569
|
+
passTypeId: string;
|
|
570
|
+
email?: string | undefined;
|
|
571
|
+
}): void;
|
|
572
|
+
mutateAsync(input: {
|
|
573
|
+
passTypeId: string;
|
|
574
|
+
email?: string | undefined;
|
|
575
|
+
}): Promise<{
|
|
576
|
+
id: string;
|
|
577
|
+
state: string;
|
|
578
|
+
currency: string;
|
|
579
|
+
total: number;
|
|
580
|
+
token: string | null;
|
|
581
|
+
}>;
|
|
582
|
+
data: {
|
|
583
|
+
id: string;
|
|
584
|
+
state: string;
|
|
585
|
+
currency: string;
|
|
586
|
+
total: number;
|
|
587
|
+
token: string | null;
|
|
588
|
+
} | undefined;
|
|
589
|
+
isPending: boolean;
|
|
590
|
+
error: unknown;
|
|
591
|
+
};
|
|
592
|
+
checkout: {
|
|
593
|
+
mutate(input: {
|
|
594
|
+
id: string;
|
|
595
|
+
token?: string;
|
|
596
|
+
returnUrl: string;
|
|
597
|
+
}): void;
|
|
598
|
+
mutateAsync(input: {
|
|
599
|
+
id: string;
|
|
600
|
+
token?: string;
|
|
601
|
+
returnUrl: string;
|
|
602
|
+
}): Promise<{
|
|
603
|
+
url: string;
|
|
604
|
+
}>;
|
|
605
|
+
data: {
|
|
606
|
+
url: string;
|
|
607
|
+
} | undefined;
|
|
608
|
+
isPending: boolean;
|
|
609
|
+
error: unknown;
|
|
610
|
+
};
|
|
611
|
+
};
|
|
612
|
+
/** The signed-in member's memberships and passes, with the host's count of what is left. */
|
|
613
|
+
useMine(): {
|
|
614
|
+
data: {
|
|
615
|
+
holdings: {
|
|
616
|
+
classTypes: string[];
|
|
617
|
+
weekdays: string[];
|
|
618
|
+
fromMinute: number | null;
|
|
619
|
+
untilMinute: number | null;
|
|
620
|
+
id: string;
|
|
621
|
+
kind: "membership" | "pass";
|
|
622
|
+
title: string | null;
|
|
623
|
+
status: string;
|
|
624
|
+
uses: number | null;
|
|
625
|
+
per: "week" | "month" | "total";
|
|
626
|
+
from: string | null;
|
|
627
|
+
until: string | null;
|
|
628
|
+
live: boolean;
|
|
629
|
+
period: {
|
|
630
|
+
key: string;
|
|
631
|
+
startsAt: string;
|
|
632
|
+
endsAt: string;
|
|
633
|
+
used: number;
|
|
634
|
+
left: number | null;
|
|
635
|
+
} | null;
|
|
636
|
+
}[];
|
|
637
|
+
} | undefined;
|
|
638
|
+
isPending: boolean;
|
|
639
|
+
error: unknown;
|
|
640
|
+
};
|
|
641
|
+
/** Staff: one person's memberships and passes. */
|
|
642
|
+
useHoldings(personId: string): {
|
|
643
|
+
data: {
|
|
644
|
+
holdings: {
|
|
645
|
+
classTypes: string[];
|
|
646
|
+
weekdays: string[];
|
|
647
|
+
fromMinute: number | null;
|
|
648
|
+
untilMinute: number | null;
|
|
649
|
+
id: string;
|
|
650
|
+
kind: "membership" | "pass";
|
|
651
|
+
title: string | null;
|
|
652
|
+
status: string;
|
|
653
|
+
uses: number | null;
|
|
654
|
+
per: "week" | "month" | "total";
|
|
655
|
+
from: string | null;
|
|
656
|
+
until: string | null;
|
|
657
|
+
live: boolean;
|
|
658
|
+
period: {
|
|
659
|
+
key: string;
|
|
660
|
+
startsAt: string;
|
|
661
|
+
endsAt: string;
|
|
662
|
+
used: number;
|
|
663
|
+
left: number | null;
|
|
664
|
+
} | null;
|
|
665
|
+
}[];
|
|
666
|
+
} | undefined;
|
|
667
|
+
isPending: boolean;
|
|
668
|
+
error: unknown;
|
|
669
|
+
};
|
|
670
|
+
/** Staff (a person): give a pass by hand, with a reason. */
|
|
671
|
+
useGivePass(): {
|
|
672
|
+
mutate(input: {
|
|
673
|
+
personId: string;
|
|
674
|
+
passTypeId: string;
|
|
675
|
+
reason: string;
|
|
676
|
+
uses?: number | undefined;
|
|
677
|
+
}): void;
|
|
678
|
+
mutateAsync(input: {
|
|
679
|
+
personId: string;
|
|
680
|
+
passTypeId: string;
|
|
681
|
+
reason: string;
|
|
682
|
+
uses?: number | undefined;
|
|
683
|
+
}): Promise<{
|
|
684
|
+
passId: string;
|
|
685
|
+
status: string;
|
|
686
|
+
source: string;
|
|
687
|
+
}>;
|
|
688
|
+
data: {
|
|
689
|
+
passId: string;
|
|
690
|
+
status: string;
|
|
691
|
+
source: string;
|
|
692
|
+
} | undefined;
|
|
693
|
+
isPending: boolean;
|
|
694
|
+
error: unknown;
|
|
695
|
+
};
|
|
696
|
+
/** Staff (a person): void a pass given by hand, with a reason. */
|
|
697
|
+
useVoidPass(): {
|
|
698
|
+
mutate(input: {
|
|
699
|
+
passId: string;
|
|
700
|
+
reason: string;
|
|
701
|
+
}): void;
|
|
702
|
+
mutateAsync(input: {
|
|
703
|
+
passId: string;
|
|
704
|
+
reason: string;
|
|
705
|
+
}): Promise<{
|
|
706
|
+
passId: string;
|
|
707
|
+
status: string;
|
|
708
|
+
source: string;
|
|
709
|
+
}>;
|
|
710
|
+
data: {
|
|
711
|
+
passId: string;
|
|
712
|
+
status: string;
|
|
713
|
+
source: string;
|
|
714
|
+
} | undefined;
|
|
715
|
+
isPending: boolean;
|
|
716
|
+
error: unknown;
|
|
717
|
+
};
|
|
718
|
+
/** Start a membership: the host opens the provider's page (web only); the trial is the host's. */
|
|
719
|
+
useSubscribe(): {
|
|
720
|
+
mutate(input: {
|
|
721
|
+
plan: {
|
|
722
|
+
object: string;
|
|
723
|
+
id: string;
|
|
724
|
+
};
|
|
725
|
+
returnUrl: string;
|
|
726
|
+
email?: string;
|
|
727
|
+
offerId?: string;
|
|
728
|
+
}): void;
|
|
729
|
+
mutateAsync(input: {
|
|
730
|
+
plan: {
|
|
731
|
+
object: string;
|
|
732
|
+
id: string;
|
|
733
|
+
};
|
|
734
|
+
returnUrl: string;
|
|
735
|
+
email?: string;
|
|
736
|
+
offerId?: string;
|
|
737
|
+
}): Promise<StartedSubscription>;
|
|
738
|
+
data: StartedSubscription | undefined;
|
|
739
|
+
isPending: boolean;
|
|
740
|
+
error: unknown;
|
|
741
|
+
};
|
|
742
|
+
/** The signed-in payer's own membership subscriptions, newest first. */
|
|
743
|
+
useMySubscriptions(): {
|
|
744
|
+
data: {
|
|
745
|
+
items: MembershipSubscription[];
|
|
746
|
+
nextCursor: string | null;
|
|
747
|
+
} | undefined;
|
|
748
|
+
isPending: boolean;
|
|
749
|
+
error: unknown;
|
|
750
|
+
};
|
|
751
|
+
/** End their own membership when its period ends (web only). */
|
|
752
|
+
useCancelSubscription(): {
|
|
753
|
+
mutate(input: {
|
|
754
|
+
id: string;
|
|
755
|
+
reason?: string;
|
|
756
|
+
}): void;
|
|
757
|
+
mutateAsync(input: {
|
|
758
|
+
id: string;
|
|
759
|
+
reason?: string;
|
|
760
|
+
}): Promise<{
|
|
761
|
+
id: string;
|
|
762
|
+
requested: true;
|
|
763
|
+
}>;
|
|
764
|
+
data: {
|
|
765
|
+
id: string;
|
|
766
|
+
requested: true;
|
|
767
|
+
} | undefined;
|
|
768
|
+
isPending: boolean;
|
|
769
|
+
error: unknown;
|
|
770
|
+
};
|
|
771
|
+
/** Undo that, before the period ends (web only). */
|
|
772
|
+
useResumeSubscription(): {
|
|
773
|
+
mutate(input: {
|
|
774
|
+
id: string;
|
|
775
|
+
}): void;
|
|
776
|
+
mutateAsync(input: {
|
|
777
|
+
id: string;
|
|
778
|
+
}): Promise<{
|
|
779
|
+
id: string;
|
|
780
|
+
requested: true;
|
|
781
|
+
}>;
|
|
782
|
+
data: {
|
|
783
|
+
id: string;
|
|
784
|
+
requested: true;
|
|
785
|
+
} | undefined;
|
|
786
|
+
isPending: boolean;
|
|
787
|
+
error: unknown;
|
|
788
|
+
};
|
|
789
|
+
/** The provider's portal for their card and past invoices (web only, never in a frame). */
|
|
790
|
+
useBillingPortal(): {
|
|
791
|
+
mutate(input: {
|
|
792
|
+
returnUrl: string;
|
|
793
|
+
}): void;
|
|
794
|
+
mutateAsync(input: {
|
|
795
|
+
returnUrl: string;
|
|
796
|
+
}): Promise<{
|
|
797
|
+
url: string;
|
|
798
|
+
}>;
|
|
799
|
+
data: {
|
|
800
|
+
url: string;
|
|
801
|
+
} | undefined;
|
|
802
|
+
isPending: boolean;
|
|
803
|
+
error: unknown;
|
|
804
|
+
};
|
|
805
|
+
};
|
|
806
|
+
/** Every hook of this entry. A block takes the ones it calls: `Pick<MembershipsHooks, "useMine">`. */
|
|
807
|
+
export type MembershipsHooks = ReturnType<typeof allMembershipsHooks>;
|
|
808
|
+
export {};
|