@composable-os/pack-courses 0.0.0-stage → 0.1.0-beta.10
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/automations.d.ts +12 -0
- package/dist/automations.js +84 -0
- package/dist/blocks/courses-builder/course-builder.d.ts +5 -0
- package/dist/blocks/courses-builder/course-builder.js +69 -0
- package/dist/blocks/courses-catalogue/catalogue.d.ts +6 -0
- package/dist/blocks/courses-catalogue/catalogue.js +21 -0
- package/dist/blocks/courses-course/course-page.d.ts +10 -0
- package/dist/blocks/courses-course/course-page.js +51 -0
- package/dist/blocks/courses-my-courses/my-courses.d.ts +5 -0
- package/dist/blocks/courses-my-courses/my-courses.js +20 -0
- package/dist/blocks/courses-native-catalogue/catalogue-screen.d.ts +6 -0
- package/dist/blocks/courses-native-catalogue/catalogue-screen.js +15 -0
- package/dist/blocks/courses-native-course/course-screen.d.ts +7 -0
- package/dist/blocks/courses-native-course/course-screen.js +18 -0
- package/dist/blocks/courses-native-my-courses/my-courses-screen.d.ts +5 -0
- package/dist/blocks/courses-native-my-courses/my-courses-screen.js +9 -0
- package/dist/blocks/courses-native-player/lesson-screen.d.ts +19 -0
- package/dist/blocks/courses-native-player/lesson-screen.js +11 -0
- package/dist/blocks/courses-native-subscription/subscription-screen.d.ts +4 -0
- package/dist/blocks/courses-native-subscription/subscription-screen.js +17 -0
- package/dist/blocks/courses-player/player.d.ts +12 -0
- package/dist/blocks/courses-player/player.js +51 -0
- package/dist/blocks/courses-subscribe/subscribe.d.ts +28 -0
- package/dist/blocks/courses-subscribe/subscribe.js +146 -0
- package/dist/blocks/courses-subscription/my-subscription.d.ts +6 -0
- package/dist/blocks/courses-subscription/my-subscription.js +50 -0
- package/dist/client/index.d.ts +1319 -0
- package/dist/client/index.js +414 -0
- package/dist/dashboards.d.ts +5 -0
- package/dist/dashboards.js +119 -0
- package/dist/index.d.ts +809 -0
- package/dist/index.js +427 -0
- package/dist/outline.d.ts +85 -0
- package/dist/outline.js +188 -0
- package/dist/tools.d.ts +255 -0
- package/dist/tools.js +826 -0
- package/package.json +36 -4
- package/README.md +0 -3
|
@@ -0,0 +1,1319 @@
|
|
|
1
|
+
import { type ClientHolding, type PackClient } from "@composable-os/client";
|
|
2
|
+
import type { z } from "@composable-os/sdk";
|
|
3
|
+
import { type Lesson, type LessonKind, type Outline, type Section } from "../outline.ts";
|
|
4
|
+
import type { buy, catalogue, course, endEnrolment, enrol, lesson, myCourses, plans, progress, startSession, stats } from "../tools.ts";
|
|
5
|
+
export { completion, findLesson, lessonsOf, nextLesson, watchedToEnd } from "../outline.ts";
|
|
6
|
+
export type { Lesson, LessonKind, Outline, Section };
|
|
7
|
+
type Io<T extends {
|
|
8
|
+
input: z.ZodType;
|
|
9
|
+
output: z.ZodType;
|
|
10
|
+
}> = {
|
|
11
|
+
input: z.input<T["input"]>;
|
|
12
|
+
output: z.output<T["output"]>;
|
|
13
|
+
};
|
|
14
|
+
export declare const COURSE = "courses.course";
|
|
15
|
+
/** What media.play answers (ADR 0476). */
|
|
16
|
+
export interface Playback {
|
|
17
|
+
id: string;
|
|
18
|
+
token: string;
|
|
19
|
+
expiresAt: string;
|
|
20
|
+
hls: string;
|
|
21
|
+
dash: string;
|
|
22
|
+
iframe: string;
|
|
23
|
+
poster: string;
|
|
24
|
+
duration: number | null;
|
|
25
|
+
captions: {
|
|
26
|
+
language: string;
|
|
27
|
+
label: string;
|
|
28
|
+
}[];
|
|
29
|
+
}
|
|
30
|
+
export declare const PLAN = "courses.plan";
|
|
31
|
+
/** A subscription as its payer reads it (`subscription.list`, stage 32a). */
|
|
32
|
+
export interface CourseSubscription {
|
|
33
|
+
id: string;
|
|
34
|
+
state: "incomplete" | "expired" | "trialing" | "active" | "past_due" | "unpaid" | "paused" | "ended";
|
|
35
|
+
planObject: string;
|
|
36
|
+
planId: string;
|
|
37
|
+
planTitle: string;
|
|
38
|
+
/** One period's price, in the currency's minor unit, tax included. */
|
|
39
|
+
amount: number;
|
|
40
|
+
currency: string;
|
|
41
|
+
interval: "week" | "month" | "year";
|
|
42
|
+
trialEnd: string | null;
|
|
43
|
+
currentPeriodEnd: string | null;
|
|
44
|
+
cancelAtPeriodEnd: boolean;
|
|
45
|
+
cancelAt: string | null;
|
|
46
|
+
endedAt: string | null;
|
|
47
|
+
/** The provider's page to confirm a renewal on (3D Secure), while one waits. */
|
|
48
|
+
actionUrl: string | null;
|
|
49
|
+
createdAt: string;
|
|
50
|
+
}
|
|
51
|
+
/** Why the host gave no free trial on a plan that has one (subscription.start's `noTrial`). */
|
|
52
|
+
export type NoTrial = "sign_in" | "used" | "permission" | "held" | "unconfirmed" | "continuation";
|
|
53
|
+
/** What a member is told about a trial the host did not give. Display only. */
|
|
54
|
+
export declare function noTrialWords(reason: NoTrial): string;
|
|
55
|
+
/**
|
|
56
|
+
* A continuation offer (stage 32a, ADR 0491): a subscriber moving from another platform continues
|
|
57
|
+
* here, free until the date they had paid up to, then charged. Only its own person, signed in as
|
|
58
|
+
* its address, reads or takes it (`subscription.offer.mine`, `subscription.start { offerId }`).
|
|
59
|
+
*/
|
|
60
|
+
export interface ContinuationOffer {
|
|
61
|
+
id: string;
|
|
62
|
+
planObject: string;
|
|
63
|
+
planId: string;
|
|
64
|
+
/** Free until this moment, then charged. */
|
|
65
|
+
freeUntil: string;
|
|
66
|
+
/** Under 48 hours left: taking it now is charged at once. */
|
|
67
|
+
chargedNow: boolean;
|
|
68
|
+
/** Its plan is no longer on sale and there is no single other: the member asks the company. */
|
|
69
|
+
askUs: boolean;
|
|
70
|
+
}
|
|
71
|
+
/** The member's offer for `planId`, if they have one. */
|
|
72
|
+
export declare function offerFor(offers: readonly ContinuationOffer[] | undefined, planId: string): ContinuationOffer | undefined;
|
|
73
|
+
/** What a member is told about their offer, in words. Display only. */
|
|
74
|
+
export declare function offerWords(offer: ContinuationOffer): string;
|
|
75
|
+
/** What subscription.start answers. */
|
|
76
|
+
export interface StartedSubscription {
|
|
77
|
+
subscriptionId: string;
|
|
78
|
+
url: string;
|
|
79
|
+
amount: number;
|
|
80
|
+
currency: string;
|
|
81
|
+
interval: "week" | "month" | "year";
|
|
82
|
+
trialDays: number | null;
|
|
83
|
+
/** Free until this moment (a continuation offer taken), then charged. */
|
|
84
|
+
freeUntil: string | null;
|
|
85
|
+
noTrial: NoTrial | null;
|
|
86
|
+
expiresAt: string | null;
|
|
87
|
+
}
|
|
88
|
+
/** The operations this entry calls, as the generated client types them. */
|
|
89
|
+
export type CoursesOperations = {
|
|
90
|
+
"x.courses.plans": {
|
|
91
|
+
kind: "query";
|
|
92
|
+
} & Io<typeof plans>;
|
|
93
|
+
"subscription.start": {
|
|
94
|
+
kind: "mutation";
|
|
95
|
+
input: {
|
|
96
|
+
plan: {
|
|
97
|
+
object: string;
|
|
98
|
+
id: string;
|
|
99
|
+
};
|
|
100
|
+
returnUrl: string;
|
|
101
|
+
email?: string;
|
|
102
|
+
offerId?: string;
|
|
103
|
+
};
|
|
104
|
+
output: StartedSubscription;
|
|
105
|
+
};
|
|
106
|
+
"subscription.offer.mine": {
|
|
107
|
+
kind: "query";
|
|
108
|
+
input: Record<string, unknown>;
|
|
109
|
+
output: {
|
|
110
|
+
offers: ContinuationOffer[];
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
"subscription.list": {
|
|
114
|
+
kind: "query";
|
|
115
|
+
input: {
|
|
116
|
+
filter?: unknown;
|
|
117
|
+
limit?: number;
|
|
118
|
+
};
|
|
119
|
+
output: {
|
|
120
|
+
items: CourseSubscription[];
|
|
121
|
+
nextCursor: string | null;
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
"subscription.cancel": {
|
|
125
|
+
kind: "mutation";
|
|
126
|
+
input: {
|
|
127
|
+
id: string;
|
|
128
|
+
reason?: string;
|
|
129
|
+
};
|
|
130
|
+
output: {
|
|
131
|
+
id: string;
|
|
132
|
+
requested: true;
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
"subscription.resume": {
|
|
136
|
+
kind: "mutation";
|
|
137
|
+
input: {
|
|
138
|
+
id: string;
|
|
139
|
+
};
|
|
140
|
+
output: {
|
|
141
|
+
id: string;
|
|
142
|
+
requested: true;
|
|
143
|
+
};
|
|
144
|
+
};
|
|
145
|
+
"subscription.portal": {
|
|
146
|
+
kind: "mutation";
|
|
147
|
+
input: {
|
|
148
|
+
returnUrl: string;
|
|
149
|
+
};
|
|
150
|
+
output: {
|
|
151
|
+
url: string;
|
|
152
|
+
};
|
|
153
|
+
};
|
|
154
|
+
"x.courses.catalogue": {
|
|
155
|
+
kind: "query";
|
|
156
|
+
} & Io<typeof catalogue>;
|
|
157
|
+
"x.courses.course": {
|
|
158
|
+
kind: "query";
|
|
159
|
+
} & Io<typeof course>;
|
|
160
|
+
"x.courses.lesson": {
|
|
161
|
+
kind: "query";
|
|
162
|
+
} & Io<typeof lesson>;
|
|
163
|
+
"x.courses.myCourses": {
|
|
164
|
+
kind: "query";
|
|
165
|
+
} & Io<typeof myCourses>;
|
|
166
|
+
"x.courses.startSession": {
|
|
167
|
+
kind: "query";
|
|
168
|
+
} & Io<typeof startSession>;
|
|
169
|
+
"x.courses.progress": {
|
|
170
|
+
kind: "mutation";
|
|
171
|
+
} & Io<typeof progress>;
|
|
172
|
+
"x.courses.buy": {
|
|
173
|
+
kind: "mutation";
|
|
174
|
+
} & Io<typeof buy>;
|
|
175
|
+
"x.courses.enrol": {
|
|
176
|
+
kind: "mutation";
|
|
177
|
+
} & Io<typeof enrol>;
|
|
178
|
+
"x.courses.endEnrolment": {
|
|
179
|
+
kind: "mutation";
|
|
180
|
+
} & Io<typeof endEnrolment>;
|
|
181
|
+
"x.courses.stats": {
|
|
182
|
+
kind: "query";
|
|
183
|
+
} & Io<typeof stats>;
|
|
184
|
+
"media.play": {
|
|
185
|
+
kind: "query";
|
|
186
|
+
input: {
|
|
187
|
+
id: string;
|
|
188
|
+
record?: {
|
|
189
|
+
object: string;
|
|
190
|
+
id: string;
|
|
191
|
+
};
|
|
192
|
+
field?: string;
|
|
193
|
+
purpose?: "stream";
|
|
194
|
+
seconds?: number;
|
|
195
|
+
};
|
|
196
|
+
output: Playback;
|
|
197
|
+
};
|
|
198
|
+
"order.checkout": {
|
|
199
|
+
kind: "mutation";
|
|
200
|
+
input: {
|
|
201
|
+
id: string;
|
|
202
|
+
token?: string;
|
|
203
|
+
returnUrl: string;
|
|
204
|
+
};
|
|
205
|
+
output: {
|
|
206
|
+
url: string;
|
|
207
|
+
};
|
|
208
|
+
};
|
|
209
|
+
"record.update": {
|
|
210
|
+
kind: "mutation";
|
|
211
|
+
input: {
|
|
212
|
+
object: string;
|
|
213
|
+
id: string;
|
|
214
|
+
values: Record<string, unknown>;
|
|
215
|
+
};
|
|
216
|
+
output: {
|
|
217
|
+
id: string;
|
|
218
|
+
values: Record<string, unknown>;
|
|
219
|
+
};
|
|
220
|
+
};
|
|
221
|
+
"record.get": {
|
|
222
|
+
kind: "query";
|
|
223
|
+
input: {
|
|
224
|
+
object: string;
|
|
225
|
+
id: string;
|
|
226
|
+
};
|
|
227
|
+
output: {
|
|
228
|
+
id: string;
|
|
229
|
+
values: Record<string, unknown>;
|
|
230
|
+
};
|
|
231
|
+
};
|
|
232
|
+
"record.publish": {
|
|
233
|
+
kind: "mutation";
|
|
234
|
+
input: {
|
|
235
|
+
object: string;
|
|
236
|
+
id: string;
|
|
237
|
+
note?: string;
|
|
238
|
+
};
|
|
239
|
+
output: {
|
|
240
|
+
version: number;
|
|
241
|
+
publishedAt: string;
|
|
242
|
+
};
|
|
243
|
+
};
|
|
244
|
+
"media.list": {
|
|
245
|
+
kind: "query";
|
|
246
|
+
input: {
|
|
247
|
+
filter?: unknown;
|
|
248
|
+
limit?: number;
|
|
249
|
+
};
|
|
250
|
+
output: {
|
|
251
|
+
items: {
|
|
252
|
+
id: string;
|
|
253
|
+
values: Record<string, unknown>;
|
|
254
|
+
}[];
|
|
255
|
+
nextCursor: string | null;
|
|
256
|
+
};
|
|
257
|
+
};
|
|
258
|
+
"record.list": {
|
|
259
|
+
kind: "query";
|
|
260
|
+
input: {
|
|
261
|
+
object: string;
|
|
262
|
+
filter?: unknown;
|
|
263
|
+
limit?: number;
|
|
264
|
+
};
|
|
265
|
+
output: {
|
|
266
|
+
items: {
|
|
267
|
+
id: string;
|
|
268
|
+
title?: string | null;
|
|
269
|
+
values: Record<string, unknown>;
|
|
270
|
+
}[];
|
|
271
|
+
};
|
|
272
|
+
};
|
|
273
|
+
};
|
|
274
|
+
type In<N extends keyof CoursesOperations> = CoursesOperations[N]["input"];
|
|
275
|
+
export type CoursesClient = PackClient<CoursesOperations>;
|
|
276
|
+
/** A token is asked for again this long before it expires. */
|
|
277
|
+
export declare const PLAYBACK_REFRESH_BEFORE_MS: number;
|
|
278
|
+
/**
|
|
279
|
+
* How long to wait before asking for a new token: until `PLAYBACK_REFRESH_BEFORE_MS` before it
|
|
280
|
+
* expires, never less than 10 seconds (a token about to expire is asked for again at once after).
|
|
281
|
+
*/
|
|
282
|
+
export declare function refreshInMs(expiresAt: string, now?: number): number;
|
|
283
|
+
/** A price as the host gave it, in its currency (`99.00 AUD`). Display only: never worked out. */
|
|
284
|
+
export declare function formatPrice(price: number | null | undefined, currency: string | null | undefined): string;
|
|
285
|
+
/**
|
|
286
|
+
* An amount the host gave in the currency's minor unit (a subscription's price per period), in
|
|
287
|
+
* that currency: `29.00 AUD`. Display only: the minor unit's digits are the currency's own.
|
|
288
|
+
*/
|
|
289
|
+
export declare function formatMinor(minor: number, currency: string): string;
|
|
290
|
+
/** A date as a reader sees it (`3 Dec 2026`), from the host's ISO timestamp. Display only. */
|
|
291
|
+
export declare function day(iso: string | null | undefined): string;
|
|
292
|
+
/**
|
|
293
|
+
* What a subscription's state means to its member, in words, from what the host reports. Display
|
|
294
|
+
* only: whether it gives access is the host's (the seam), never worked out from this.
|
|
295
|
+
*/
|
|
296
|
+
export declare function subscriptionStatus(sub: CourseSubscription): string;
|
|
297
|
+
/** Whether a subscription is still the member's to cancel, resume or pay (not ended). */
|
|
298
|
+
export declare const isLive: (sub: CourseSubscription) => boolean;
|
|
299
|
+
/** A lesson's length as a reader sees it: `12 min`. Display only. */
|
|
300
|
+
export declare function minutes(duration: number | null | undefined): string;
|
|
301
|
+
/** Where a phone asks the host for a picture (the course cover): as the Content pack's. */
|
|
302
|
+
export declare function hostMediaUrl(hostUrl: string): (id: string, width: number) => string;
|
|
303
|
+
/** A picture on the site's own media route (`/api/media/<id>?w=`), for the web blocks. */
|
|
304
|
+
export declare function mediaPath(id: string, width?: number, base?: string): string;
|
|
305
|
+
/** A key from a title, unused in `taken`: `wrist-prep`, `wrist-prep-2`. */
|
|
306
|
+
export declare function newKey(title: string, taken: ReadonlySet<string>): string;
|
|
307
|
+
/**
|
|
308
|
+
* Pure edits of an outline: each returns a new outline and never changes a lesson's key once it
|
|
309
|
+
* has one (progress is kept by it). The builder block saves the result with `record.update`.
|
|
310
|
+
*/
|
|
311
|
+
export declare const outlineEdits: {
|
|
312
|
+
addSection(outline: Outline, title: string): Outline;
|
|
313
|
+
renameSection(outline: Outline, key: string, title: string): Outline;
|
|
314
|
+
removeSection(outline: Outline, key: string): Outline;
|
|
315
|
+
addLesson(outline: Outline, section: string, kind: LessonKind, title: string): Outline;
|
|
316
|
+
/** Changes a lesson's fields; its key and kind stay. */
|
|
317
|
+
updateLesson(outline: Outline, key: string, patch: Record<string, unknown>): Outline;
|
|
318
|
+
removeLesson(outline: Outline, key: string): Outline;
|
|
319
|
+
/** Moves a lesson to `index` of `section` (by drag or by keyboard). */
|
|
320
|
+
moveLesson(outline: Outline, key: string, section: string, index: number): Outline;
|
|
321
|
+
};
|
|
322
|
+
/** The app's `useQuery`, as far as these hooks use it. */
|
|
323
|
+
export type UseQuery = <T>(options: {
|
|
324
|
+
queryKey: readonly unknown[];
|
|
325
|
+
queryFn: () => Promise<T>;
|
|
326
|
+
enabled?: boolean;
|
|
327
|
+
refetchInterval?: number | false | ((query: {
|
|
328
|
+
state: {
|
|
329
|
+
data: T | undefined;
|
|
330
|
+
};
|
|
331
|
+
}) => number | false);
|
|
332
|
+
}) => {
|
|
333
|
+
data: T | undefined;
|
|
334
|
+
isPending: boolean;
|
|
335
|
+
error: unknown;
|
|
336
|
+
};
|
|
337
|
+
/** What a query hook returns, as `UseQuery` gives it. */
|
|
338
|
+
export interface QueryResult<T> {
|
|
339
|
+
data: T | undefined;
|
|
340
|
+
isPending: boolean;
|
|
341
|
+
error: unknown;
|
|
342
|
+
}
|
|
343
|
+
type Out<N extends keyof CoursesOperations> = CoursesOperations[N]["output"];
|
|
344
|
+
/** The app's `useMutation`, as far as these hooks use it. */
|
|
345
|
+
export type UseMutation = <I, O>(options: {
|
|
346
|
+
mutationKey: readonly unknown[];
|
|
347
|
+
mutationFn: (input: I) => Promise<O>;
|
|
348
|
+
}) => {
|
|
349
|
+
mutate(input: I): void;
|
|
350
|
+
mutateAsync(input: I): Promise<O>;
|
|
351
|
+
data: O | undefined;
|
|
352
|
+
isPending: boolean;
|
|
353
|
+
error: unknown;
|
|
354
|
+
};
|
|
355
|
+
/**
|
|
356
|
+
* The operations each hook calls (ADR 0453). The public's client gets the catalogue, the course
|
|
357
|
+
* page and buying; a customer's client also their lessons, playback, progress and courses; the
|
|
358
|
+
* staff client the course builder's and the enrolment hooks too.
|
|
359
|
+
*/
|
|
360
|
+
export declare const COURSES_HOOKS_CALL: {
|
|
361
|
+
readonly useCatalogue: readonly ["x.courses.catalogue"];
|
|
362
|
+
readonly useCourse: readonly ["x.courses.course"];
|
|
363
|
+
readonly useBuy: readonly ["x.courses.buy", "order.checkout"];
|
|
364
|
+
readonly useLesson: readonly ["x.courses.lesson"];
|
|
365
|
+
readonly usePlayback: readonly ["media.play"];
|
|
366
|
+
readonly useProgress: readonly ["x.courses.progress"];
|
|
367
|
+
readonly useMyCourses: readonly ["x.courses.myCourses"];
|
|
368
|
+
readonly useStartSession: readonly ["x.courses.startSession"];
|
|
369
|
+
readonly useEnrol: readonly ["x.courses.enrol"];
|
|
370
|
+
readonly useEndEnrolment: readonly ["x.courses.endEnrolment"];
|
|
371
|
+
readonly useStats: readonly ["x.courses.stats"];
|
|
372
|
+
readonly usePlans: readonly ["x.courses.plans"];
|
|
373
|
+
readonly useSubscribe: readonly ["subscription.start"];
|
|
374
|
+
readonly useMySubscriptions: readonly ["subscription.list"];
|
|
375
|
+
readonly useMyOffers: readonly ["subscription.offer.mine"];
|
|
376
|
+
readonly useCancelSubscription: readonly ["subscription.cancel"];
|
|
377
|
+
readonly useResumeSubscription: readonly ["subscription.resume"];
|
|
378
|
+
readonly useBillingPortal: readonly ["subscription.portal"];
|
|
379
|
+
readonly useWorkingCopy: readonly ["record.get"];
|
|
380
|
+
readonly useSaveOutline: readonly ["record.update"];
|
|
381
|
+
readonly usePublishCourse: readonly ["record.publish"];
|
|
382
|
+
readonly useLibraryVideos: readonly ["media.list"];
|
|
383
|
+
readonly usePublishedPrograms: readonly ["record.list"];
|
|
384
|
+
};
|
|
385
|
+
/**
|
|
386
|
+
* Hooks for a React or React Native app:
|
|
387
|
+
* `const courses = createCoursesHooks({ useQuery, useMutation }, api)`. The hooks a client cannot
|
|
388
|
+
* back are not there, and calling one does not compile.
|
|
389
|
+
*/
|
|
390
|
+
export declare function createCoursesHooks<C extends ClientHolding>(react: {
|
|
391
|
+
useQuery: UseQuery;
|
|
392
|
+
useMutation: UseMutation;
|
|
393
|
+
}, client: C): import("@composable-os/client").HooksFor<{
|
|
394
|
+
/** The catalogue: published courses, bundles and themes, with the host's prices. */
|
|
395
|
+
useCatalogue(input?: In<"x.courses.catalogue">): {
|
|
396
|
+
data: {
|
|
397
|
+
themes: {
|
|
398
|
+
id: string;
|
|
399
|
+
name: string | null;
|
|
400
|
+
slug: string | null;
|
|
401
|
+
summary: string | null;
|
|
402
|
+
picture: {
|
|
403
|
+
[x: string]: unknown;
|
|
404
|
+
media: string;
|
|
405
|
+
alt?: string | undefined;
|
|
406
|
+
} | null;
|
|
407
|
+
}[];
|
|
408
|
+
courses: {
|
|
409
|
+
id: string;
|
|
410
|
+
title: string | null;
|
|
411
|
+
slug: string | null;
|
|
412
|
+
theme: string | null;
|
|
413
|
+
level: number | null;
|
|
414
|
+
summary: string | null;
|
|
415
|
+
cover: {
|
|
416
|
+
[x: string]: unknown;
|
|
417
|
+
media: string;
|
|
418
|
+
alt?: string | undefined;
|
|
419
|
+
} | null;
|
|
420
|
+
trailer: {
|
|
421
|
+
media: string;
|
|
422
|
+
poster?: string | undefined;
|
|
423
|
+
} | null;
|
|
424
|
+
price: number | null;
|
|
425
|
+
lessons: number;
|
|
426
|
+
}[];
|
|
427
|
+
bundles: {
|
|
428
|
+
id: string;
|
|
429
|
+
title: string | null;
|
|
430
|
+
slug: string | null;
|
|
431
|
+
summary: string | null;
|
|
432
|
+
cover: {
|
|
433
|
+
[x: string]: unknown;
|
|
434
|
+
media: string;
|
|
435
|
+
alt?: string | undefined;
|
|
436
|
+
} | null;
|
|
437
|
+
courses: string[];
|
|
438
|
+
price: number | null;
|
|
439
|
+
}[];
|
|
440
|
+
currency: string | null;
|
|
441
|
+
} | undefined;
|
|
442
|
+
isPending: boolean;
|
|
443
|
+
error: unknown;
|
|
444
|
+
};
|
|
445
|
+
/** One published course by its address, with whether the caller holds it. */
|
|
446
|
+
useCourse(slug: string | null): QueryResult<Out<"x.courses.course">>;
|
|
447
|
+
/** Start an order for a course or a bundle; then `checkout` it (web only). */
|
|
448
|
+
useBuy(): {
|
|
449
|
+
start: {
|
|
450
|
+
mutate(input: {
|
|
451
|
+
courseId?: string | undefined;
|
|
452
|
+
bundleId?: string | undefined;
|
|
453
|
+
email?: string | undefined;
|
|
454
|
+
}): void;
|
|
455
|
+
mutateAsync(input: {
|
|
456
|
+
courseId?: string | undefined;
|
|
457
|
+
bundleId?: string | undefined;
|
|
458
|
+
email?: string | undefined;
|
|
459
|
+
}): Promise<{
|
|
460
|
+
id: string;
|
|
461
|
+
state: string;
|
|
462
|
+
currency: string;
|
|
463
|
+
total: number;
|
|
464
|
+
token: string | null;
|
|
465
|
+
}>;
|
|
466
|
+
data: {
|
|
467
|
+
id: string;
|
|
468
|
+
state: string;
|
|
469
|
+
currency: string;
|
|
470
|
+
total: number;
|
|
471
|
+
token: string | null;
|
|
472
|
+
} | undefined;
|
|
473
|
+
isPending: boolean;
|
|
474
|
+
error: unknown;
|
|
475
|
+
};
|
|
476
|
+
checkout: {
|
|
477
|
+
mutate(input: {
|
|
478
|
+
id: string;
|
|
479
|
+
token?: string;
|
|
480
|
+
returnUrl: string;
|
|
481
|
+
}): void;
|
|
482
|
+
mutateAsync(input: {
|
|
483
|
+
id: string;
|
|
484
|
+
token?: string;
|
|
485
|
+
returnUrl: string;
|
|
486
|
+
}): Promise<{
|
|
487
|
+
url: string;
|
|
488
|
+
}>;
|
|
489
|
+
data: {
|
|
490
|
+
url: string;
|
|
491
|
+
} | undefined;
|
|
492
|
+
isPending: boolean;
|
|
493
|
+
error: unknown;
|
|
494
|
+
};
|
|
495
|
+
};
|
|
496
|
+
/** One lesson for a holder (or a free preview). */
|
|
497
|
+
useLesson(courseId: string | null, lessonKey: string | null): QueryResult<Out<"x.courses.lesson">>;
|
|
498
|
+
/**
|
|
499
|
+
* A token to play a lesson's video (or a trailer), from the host's `media.play`; asked for
|
|
500
|
+
* again `PLAYBACK_REFRESH_BEFORE_MS` before it expires, so a long video keeps playing.
|
|
501
|
+
*/
|
|
502
|
+
usePlayback(video: {
|
|
503
|
+
media: string;
|
|
504
|
+
record?: {
|
|
505
|
+
object: string;
|
|
506
|
+
id: string;
|
|
507
|
+
};
|
|
508
|
+
field?: string;
|
|
509
|
+
} | null): QueryResult<Playback>;
|
|
510
|
+
/** Mark a lesson started or done, and keep where its video was left. */
|
|
511
|
+
useProgress(): {
|
|
512
|
+
mutate(input: {
|
|
513
|
+
courseId: string;
|
|
514
|
+
lessonKey: string;
|
|
515
|
+
state?: "done" | "started" | undefined;
|
|
516
|
+
position?: number | undefined;
|
|
517
|
+
duration?: number | undefined;
|
|
518
|
+
}): void;
|
|
519
|
+
mutateAsync(input: {
|
|
520
|
+
courseId: string;
|
|
521
|
+
lessonKey: string;
|
|
522
|
+
state?: "done" | "started" | undefined;
|
|
523
|
+
position?: number | undefined;
|
|
524
|
+
duration?: number | undefined;
|
|
525
|
+
}): Promise<{
|
|
526
|
+
lessonKey: string;
|
|
527
|
+
state: "done" | "started";
|
|
528
|
+
position: number | null;
|
|
529
|
+
done: number;
|
|
530
|
+
counted: number;
|
|
531
|
+
complete: boolean;
|
|
532
|
+
}>;
|
|
533
|
+
data: {
|
|
534
|
+
lessonKey: string;
|
|
535
|
+
state: "done" | "started";
|
|
536
|
+
position: number | null;
|
|
537
|
+
done: number;
|
|
538
|
+
counted: number;
|
|
539
|
+
complete: boolean;
|
|
540
|
+
} | undefined;
|
|
541
|
+
isPending: boolean;
|
|
542
|
+
error: unknown;
|
|
543
|
+
};
|
|
544
|
+
/** What the caller holds, with progress. */
|
|
545
|
+
useMyCourses(): {
|
|
546
|
+
data: {
|
|
547
|
+
courses: {
|
|
548
|
+
id: string;
|
|
549
|
+
title: string | null;
|
|
550
|
+
slug: string | null;
|
|
551
|
+
theme: string | null;
|
|
552
|
+
level: number | null;
|
|
553
|
+
summary: string | null;
|
|
554
|
+
cover: {
|
|
555
|
+
[x: string]: unknown;
|
|
556
|
+
media: string;
|
|
557
|
+
alt?: string | undefined;
|
|
558
|
+
} | null;
|
|
559
|
+
trailer: {
|
|
560
|
+
media: string;
|
|
561
|
+
poster?: string | undefined;
|
|
562
|
+
} | null;
|
|
563
|
+
price: number | null;
|
|
564
|
+
lessons: number;
|
|
565
|
+
why: "bought" | "bundle" | "given" | "imported" | "subscription";
|
|
566
|
+
done: number;
|
|
567
|
+
counted: number;
|
|
568
|
+
complete: boolean;
|
|
569
|
+
continueWith: string | null;
|
|
570
|
+
}[];
|
|
571
|
+
} | undefined;
|
|
572
|
+
isPending: boolean;
|
|
573
|
+
error: unknown;
|
|
574
|
+
};
|
|
575
|
+
/** A session lesson's own Programs session, once it is assigned. */
|
|
576
|
+
useStartSession(courseId: string | null, lessonKey: string | null): QueryResult<Out<"x.courses.startSession">>;
|
|
577
|
+
/** Staff: give a person access, with a reason. */
|
|
578
|
+
useEnrol(): {
|
|
579
|
+
mutate(input: {
|
|
580
|
+
personId: string;
|
|
581
|
+
reason: string;
|
|
582
|
+
courseId?: string | undefined;
|
|
583
|
+
bundleId?: string | undefined;
|
|
584
|
+
until?: string | undefined;
|
|
585
|
+
}): void;
|
|
586
|
+
mutateAsync(input: {
|
|
587
|
+
personId: string;
|
|
588
|
+
reason: string;
|
|
589
|
+
courseId?: string | undefined;
|
|
590
|
+
bundleId?: string | undefined;
|
|
591
|
+
until?: string | undefined;
|
|
592
|
+
}): Promise<{
|
|
593
|
+
enrolmentId: string;
|
|
594
|
+
status: string;
|
|
595
|
+
source: string;
|
|
596
|
+
}>;
|
|
597
|
+
data: {
|
|
598
|
+
enrolmentId: string;
|
|
599
|
+
status: string;
|
|
600
|
+
source: string;
|
|
601
|
+
} | undefined;
|
|
602
|
+
isPending: boolean;
|
|
603
|
+
error: unknown;
|
|
604
|
+
};
|
|
605
|
+
/** Staff: end an enrolment staff gave or one imported. */
|
|
606
|
+
useEndEnrolment(): {
|
|
607
|
+
mutate(input: {
|
|
608
|
+
enrolmentId: string;
|
|
609
|
+
reason: string;
|
|
610
|
+
}): void;
|
|
611
|
+
mutateAsync(input: {
|
|
612
|
+
enrolmentId: string;
|
|
613
|
+
reason: string;
|
|
614
|
+
}): Promise<{
|
|
615
|
+
enrolmentId: string;
|
|
616
|
+
status: string;
|
|
617
|
+
source: string;
|
|
618
|
+
}>;
|
|
619
|
+
data: {
|
|
620
|
+
enrolmentId: string;
|
|
621
|
+
status: string;
|
|
622
|
+
source: string;
|
|
623
|
+
} | undefined;
|
|
624
|
+
isPending: boolean;
|
|
625
|
+
error: unknown;
|
|
626
|
+
};
|
|
627
|
+
/** Staff: enrolments and lessons done. */
|
|
628
|
+
useStats(courseId?: string): {
|
|
629
|
+
data: {
|
|
630
|
+
courses: {
|
|
631
|
+
courseId: string;
|
|
632
|
+
title: string | null;
|
|
633
|
+
active: number;
|
|
634
|
+
ended: number;
|
|
635
|
+
void: number;
|
|
636
|
+
lessonsDone: number;
|
|
637
|
+
}[];
|
|
638
|
+
byWeek: {
|
|
639
|
+
week: string;
|
|
640
|
+
done: number;
|
|
641
|
+
}[];
|
|
642
|
+
} | undefined;
|
|
643
|
+
isPending: boolean;
|
|
644
|
+
error: unknown;
|
|
645
|
+
};
|
|
646
|
+
/** The course plans on offer, with the host's prices and trial days. */
|
|
647
|
+
usePlans(): {
|
|
648
|
+
data: {
|
|
649
|
+
plans: {
|
|
650
|
+
id: string;
|
|
651
|
+
title: string | null;
|
|
652
|
+
description: string | null;
|
|
653
|
+
price: number | null;
|
|
654
|
+
trialDays: number | null;
|
|
655
|
+
}[];
|
|
656
|
+
currency: string | null;
|
|
657
|
+
} | undefined;
|
|
658
|
+
isPending: boolean;
|
|
659
|
+
error: unknown;
|
|
660
|
+
};
|
|
661
|
+
/**
|
|
662
|
+
* Start a course subscription: the host opens the provider's page (web only). Whether the
|
|
663
|
+
* trial is given is the host's (`noTrial` says why not).
|
|
664
|
+
*/
|
|
665
|
+
useSubscribe(): {
|
|
666
|
+
mutate(input: {
|
|
667
|
+
plan: {
|
|
668
|
+
object: string;
|
|
669
|
+
id: string;
|
|
670
|
+
};
|
|
671
|
+
returnUrl: string;
|
|
672
|
+
email?: string;
|
|
673
|
+
offerId?: string;
|
|
674
|
+
}): void;
|
|
675
|
+
mutateAsync(input: {
|
|
676
|
+
plan: {
|
|
677
|
+
object: string;
|
|
678
|
+
id: string;
|
|
679
|
+
};
|
|
680
|
+
returnUrl: string;
|
|
681
|
+
email?: string;
|
|
682
|
+
offerId?: string;
|
|
683
|
+
}): Promise<StartedSubscription>;
|
|
684
|
+
data: StartedSubscription | undefined;
|
|
685
|
+
isPending: boolean;
|
|
686
|
+
error: unknown;
|
|
687
|
+
};
|
|
688
|
+
/** The signed-in customer's own course subscriptions, newest first. */
|
|
689
|
+
useMySubscriptions(): {
|
|
690
|
+
data: {
|
|
691
|
+
items: CourseSubscription[];
|
|
692
|
+
nextCursor: string | null;
|
|
693
|
+
} | undefined;
|
|
694
|
+
isPending: boolean;
|
|
695
|
+
error: unknown;
|
|
696
|
+
};
|
|
697
|
+
/**
|
|
698
|
+
* The signed-in customer's own continuation offers (moving from another platform): free until
|
|
699
|
+
* their paid-up date. Read only; taking one is `useSubscribe` with `offerId` (web only).
|
|
700
|
+
*/
|
|
701
|
+
useMyOffers(options?: {
|
|
702
|
+
enabled?: boolean;
|
|
703
|
+
}): {
|
|
704
|
+
data: {
|
|
705
|
+
offers: ContinuationOffer[];
|
|
706
|
+
} | undefined;
|
|
707
|
+
isPending: boolean;
|
|
708
|
+
error: unknown;
|
|
709
|
+
};
|
|
710
|
+
/** End their own subscription when its period ends (web only). */
|
|
711
|
+
useCancelSubscription(): {
|
|
712
|
+
mutate(input: {
|
|
713
|
+
id: string;
|
|
714
|
+
reason?: string;
|
|
715
|
+
}): void;
|
|
716
|
+
mutateAsync(input: {
|
|
717
|
+
id: string;
|
|
718
|
+
reason?: string;
|
|
719
|
+
}): Promise<{
|
|
720
|
+
id: string;
|
|
721
|
+
requested: true;
|
|
722
|
+
}>;
|
|
723
|
+
data: {
|
|
724
|
+
id: string;
|
|
725
|
+
requested: true;
|
|
726
|
+
} | undefined;
|
|
727
|
+
isPending: boolean;
|
|
728
|
+
error: unknown;
|
|
729
|
+
};
|
|
730
|
+
/** Undo that, before the period ends (web only). */
|
|
731
|
+
useResumeSubscription(): {
|
|
732
|
+
mutate(input: {
|
|
733
|
+
id: string;
|
|
734
|
+
}): void;
|
|
735
|
+
mutateAsync(input: {
|
|
736
|
+
id: string;
|
|
737
|
+
}): Promise<{
|
|
738
|
+
id: string;
|
|
739
|
+
requested: true;
|
|
740
|
+
}>;
|
|
741
|
+
data: {
|
|
742
|
+
id: string;
|
|
743
|
+
requested: true;
|
|
744
|
+
} | undefined;
|
|
745
|
+
isPending: boolean;
|
|
746
|
+
error: unknown;
|
|
747
|
+
};
|
|
748
|
+
/** The provider's portal for their card and past invoices (web only, never in a frame). */
|
|
749
|
+
useBillingPortal(): {
|
|
750
|
+
mutate(input: {
|
|
751
|
+
returnUrl: string;
|
|
752
|
+
}): void;
|
|
753
|
+
mutateAsync(input: {
|
|
754
|
+
returnUrl: string;
|
|
755
|
+
}): Promise<{
|
|
756
|
+
url: string;
|
|
757
|
+
}>;
|
|
758
|
+
data: {
|
|
759
|
+
url: string;
|
|
760
|
+
} | undefined;
|
|
761
|
+
isPending: boolean;
|
|
762
|
+
error: unknown;
|
|
763
|
+
};
|
|
764
|
+
/** Staff: a course's working copy, as the builder edits it. */
|
|
765
|
+
useWorkingCopy(courseId: string): {
|
|
766
|
+
data: {
|
|
767
|
+
id: string;
|
|
768
|
+
values: Record<string, unknown>;
|
|
769
|
+
} | undefined;
|
|
770
|
+
isPending: boolean;
|
|
771
|
+
error: unknown;
|
|
772
|
+
};
|
|
773
|
+
/** Staff: save the course's working copy (its outline). */
|
|
774
|
+
useSaveOutline(): {
|
|
775
|
+
mutate(input: {
|
|
776
|
+
object: string;
|
|
777
|
+
id: string;
|
|
778
|
+
values: Record<string, unknown>;
|
|
779
|
+
}): void;
|
|
780
|
+
mutateAsync(input: {
|
|
781
|
+
object: string;
|
|
782
|
+
id: string;
|
|
783
|
+
values: Record<string, unknown>;
|
|
784
|
+
}): Promise<{
|
|
785
|
+
id: string;
|
|
786
|
+
values: Record<string, unknown>;
|
|
787
|
+
}>;
|
|
788
|
+
data: {
|
|
789
|
+
id: string;
|
|
790
|
+
values: Record<string, unknown>;
|
|
791
|
+
} | undefined;
|
|
792
|
+
isPending: boolean;
|
|
793
|
+
error: unknown;
|
|
794
|
+
};
|
|
795
|
+
/** Staff: publish the course (a person; an assistant's request waits for one). */
|
|
796
|
+
usePublishCourse(): {
|
|
797
|
+
mutate(input: {
|
|
798
|
+
object: string;
|
|
799
|
+
id: string;
|
|
800
|
+
note?: string;
|
|
801
|
+
}): void;
|
|
802
|
+
mutateAsync(input: {
|
|
803
|
+
object: string;
|
|
804
|
+
id: string;
|
|
805
|
+
note?: string;
|
|
806
|
+
}): Promise<{
|
|
807
|
+
version: number;
|
|
808
|
+
publishedAt: string;
|
|
809
|
+
}>;
|
|
810
|
+
data: {
|
|
811
|
+
version: number;
|
|
812
|
+
publishedAt: string;
|
|
813
|
+
} | undefined;
|
|
814
|
+
isPending: boolean;
|
|
815
|
+
error: unknown;
|
|
816
|
+
};
|
|
817
|
+
/** Staff: the library's ready videos, to pick a lesson's video. */
|
|
818
|
+
useLibraryVideos(): {
|
|
819
|
+
data: {
|
|
820
|
+
items: {
|
|
821
|
+
id: string;
|
|
822
|
+
values: Record<string, unknown>;
|
|
823
|
+
}[];
|
|
824
|
+
nextCursor: string | null;
|
|
825
|
+
} | undefined;
|
|
826
|
+
isPending: boolean;
|
|
827
|
+
error: unknown;
|
|
828
|
+
};
|
|
829
|
+
/** Staff: the published Programs programs, to pick a session lesson's program. */
|
|
830
|
+
usePublishedPrograms(): {
|
|
831
|
+
data: {
|
|
832
|
+
items: {
|
|
833
|
+
id: string;
|
|
834
|
+
title?: string | null;
|
|
835
|
+
values: Record<string, unknown>;
|
|
836
|
+
}[];
|
|
837
|
+
} | undefined;
|
|
838
|
+
isPending: boolean;
|
|
839
|
+
error: unknown;
|
|
840
|
+
};
|
|
841
|
+
}, {
|
|
842
|
+
readonly useCatalogue: readonly ["x.courses.catalogue"];
|
|
843
|
+
readonly useCourse: readonly ["x.courses.course"];
|
|
844
|
+
readonly useBuy: readonly ["x.courses.buy", "order.checkout"];
|
|
845
|
+
readonly useLesson: readonly ["x.courses.lesson"];
|
|
846
|
+
readonly usePlayback: readonly ["media.play"];
|
|
847
|
+
readonly useProgress: readonly ["x.courses.progress"];
|
|
848
|
+
readonly useMyCourses: readonly ["x.courses.myCourses"];
|
|
849
|
+
readonly useStartSession: readonly ["x.courses.startSession"];
|
|
850
|
+
readonly useEnrol: readonly ["x.courses.enrol"];
|
|
851
|
+
readonly useEndEnrolment: readonly ["x.courses.endEnrolment"];
|
|
852
|
+
readonly useStats: readonly ["x.courses.stats"];
|
|
853
|
+
readonly usePlans: readonly ["x.courses.plans"];
|
|
854
|
+
readonly useSubscribe: readonly ["subscription.start"];
|
|
855
|
+
readonly useMySubscriptions: readonly ["subscription.list"];
|
|
856
|
+
readonly useMyOffers: readonly ["subscription.offer.mine"];
|
|
857
|
+
readonly useCancelSubscription: readonly ["subscription.cancel"];
|
|
858
|
+
readonly useResumeSubscription: readonly ["subscription.resume"];
|
|
859
|
+
readonly useBillingPortal: readonly ["subscription.portal"];
|
|
860
|
+
readonly useWorkingCopy: readonly ["record.get"];
|
|
861
|
+
readonly useSaveOutline: readonly ["record.update"];
|
|
862
|
+
readonly usePublishCourse: readonly ["record.publish"];
|
|
863
|
+
readonly useLibraryVideos: readonly ["media.list"];
|
|
864
|
+
readonly usePublishedPrograms: readonly ["record.list"];
|
|
865
|
+
}, import("@composable-os/client").OperationsOf<C>>;
|
|
866
|
+
declare function allCoursesHooks(react: {
|
|
867
|
+
useQuery: UseQuery;
|
|
868
|
+
useMutation: UseMutation;
|
|
869
|
+
}, api: CoursesClient): {
|
|
870
|
+
/** The catalogue: published courses, bundles and themes, with the host's prices. */
|
|
871
|
+
useCatalogue(input?: In<"x.courses.catalogue">): {
|
|
872
|
+
data: {
|
|
873
|
+
themes: {
|
|
874
|
+
id: string;
|
|
875
|
+
name: string | null;
|
|
876
|
+
slug: string | null;
|
|
877
|
+
summary: string | null;
|
|
878
|
+
picture: {
|
|
879
|
+
[x: string]: unknown;
|
|
880
|
+
media: string;
|
|
881
|
+
alt?: string | undefined;
|
|
882
|
+
} | null;
|
|
883
|
+
}[];
|
|
884
|
+
courses: {
|
|
885
|
+
id: string;
|
|
886
|
+
title: string | null;
|
|
887
|
+
slug: string | null;
|
|
888
|
+
theme: string | null;
|
|
889
|
+
level: number | null;
|
|
890
|
+
summary: string | null;
|
|
891
|
+
cover: {
|
|
892
|
+
[x: string]: unknown;
|
|
893
|
+
media: string;
|
|
894
|
+
alt?: string | undefined;
|
|
895
|
+
} | null;
|
|
896
|
+
trailer: {
|
|
897
|
+
media: string;
|
|
898
|
+
poster?: string | undefined;
|
|
899
|
+
} | null;
|
|
900
|
+
price: number | null;
|
|
901
|
+
lessons: number;
|
|
902
|
+
}[];
|
|
903
|
+
bundles: {
|
|
904
|
+
id: string;
|
|
905
|
+
title: string | null;
|
|
906
|
+
slug: string | null;
|
|
907
|
+
summary: string | null;
|
|
908
|
+
cover: {
|
|
909
|
+
[x: string]: unknown;
|
|
910
|
+
media: string;
|
|
911
|
+
alt?: string | undefined;
|
|
912
|
+
} | null;
|
|
913
|
+
courses: string[];
|
|
914
|
+
price: number | null;
|
|
915
|
+
}[];
|
|
916
|
+
currency: string | null;
|
|
917
|
+
} | undefined;
|
|
918
|
+
isPending: boolean;
|
|
919
|
+
error: unknown;
|
|
920
|
+
};
|
|
921
|
+
/** One published course by its address, with whether the caller holds it. */
|
|
922
|
+
useCourse(slug: string | null): QueryResult<Out<"x.courses.course">>;
|
|
923
|
+
/** Start an order for a course or a bundle; then `checkout` it (web only). */
|
|
924
|
+
useBuy(): {
|
|
925
|
+
start: {
|
|
926
|
+
mutate(input: {
|
|
927
|
+
courseId?: string | undefined;
|
|
928
|
+
bundleId?: string | undefined;
|
|
929
|
+
email?: string | undefined;
|
|
930
|
+
}): void;
|
|
931
|
+
mutateAsync(input: {
|
|
932
|
+
courseId?: string | undefined;
|
|
933
|
+
bundleId?: string | undefined;
|
|
934
|
+
email?: string | undefined;
|
|
935
|
+
}): Promise<{
|
|
936
|
+
id: string;
|
|
937
|
+
state: string;
|
|
938
|
+
currency: string;
|
|
939
|
+
total: number;
|
|
940
|
+
token: string | null;
|
|
941
|
+
}>;
|
|
942
|
+
data: {
|
|
943
|
+
id: string;
|
|
944
|
+
state: string;
|
|
945
|
+
currency: string;
|
|
946
|
+
total: number;
|
|
947
|
+
token: string | null;
|
|
948
|
+
} | undefined;
|
|
949
|
+
isPending: boolean;
|
|
950
|
+
error: unknown;
|
|
951
|
+
};
|
|
952
|
+
checkout: {
|
|
953
|
+
mutate(input: {
|
|
954
|
+
id: string;
|
|
955
|
+
token?: string;
|
|
956
|
+
returnUrl: string;
|
|
957
|
+
}): void;
|
|
958
|
+
mutateAsync(input: {
|
|
959
|
+
id: string;
|
|
960
|
+
token?: string;
|
|
961
|
+
returnUrl: string;
|
|
962
|
+
}): Promise<{
|
|
963
|
+
url: string;
|
|
964
|
+
}>;
|
|
965
|
+
data: {
|
|
966
|
+
url: string;
|
|
967
|
+
} | undefined;
|
|
968
|
+
isPending: boolean;
|
|
969
|
+
error: unknown;
|
|
970
|
+
};
|
|
971
|
+
};
|
|
972
|
+
/** One lesson for a holder (or a free preview). */
|
|
973
|
+
useLesson(courseId: string | null, lessonKey: string | null): QueryResult<Out<"x.courses.lesson">>;
|
|
974
|
+
/**
|
|
975
|
+
* A token to play a lesson's video (or a trailer), from the host's `media.play`; asked for
|
|
976
|
+
* again `PLAYBACK_REFRESH_BEFORE_MS` before it expires, so a long video keeps playing.
|
|
977
|
+
*/
|
|
978
|
+
usePlayback(video: {
|
|
979
|
+
media: string;
|
|
980
|
+
record?: {
|
|
981
|
+
object: string;
|
|
982
|
+
id: string;
|
|
983
|
+
};
|
|
984
|
+
field?: string;
|
|
985
|
+
} | null): QueryResult<Playback>;
|
|
986
|
+
/** Mark a lesson started or done, and keep where its video was left. */
|
|
987
|
+
useProgress(): {
|
|
988
|
+
mutate(input: {
|
|
989
|
+
courseId: string;
|
|
990
|
+
lessonKey: string;
|
|
991
|
+
state?: "done" | "started" | undefined;
|
|
992
|
+
position?: number | undefined;
|
|
993
|
+
duration?: number | undefined;
|
|
994
|
+
}): void;
|
|
995
|
+
mutateAsync(input: {
|
|
996
|
+
courseId: string;
|
|
997
|
+
lessonKey: string;
|
|
998
|
+
state?: "done" | "started" | undefined;
|
|
999
|
+
position?: number | undefined;
|
|
1000
|
+
duration?: number | undefined;
|
|
1001
|
+
}): Promise<{
|
|
1002
|
+
lessonKey: string;
|
|
1003
|
+
state: "done" | "started";
|
|
1004
|
+
position: number | null;
|
|
1005
|
+
done: number;
|
|
1006
|
+
counted: number;
|
|
1007
|
+
complete: boolean;
|
|
1008
|
+
}>;
|
|
1009
|
+
data: {
|
|
1010
|
+
lessonKey: string;
|
|
1011
|
+
state: "done" | "started";
|
|
1012
|
+
position: number | null;
|
|
1013
|
+
done: number;
|
|
1014
|
+
counted: number;
|
|
1015
|
+
complete: boolean;
|
|
1016
|
+
} | undefined;
|
|
1017
|
+
isPending: boolean;
|
|
1018
|
+
error: unknown;
|
|
1019
|
+
};
|
|
1020
|
+
/** What the caller holds, with progress. */
|
|
1021
|
+
useMyCourses(): {
|
|
1022
|
+
data: {
|
|
1023
|
+
courses: {
|
|
1024
|
+
id: string;
|
|
1025
|
+
title: string | null;
|
|
1026
|
+
slug: string | null;
|
|
1027
|
+
theme: string | null;
|
|
1028
|
+
level: number | null;
|
|
1029
|
+
summary: string | null;
|
|
1030
|
+
cover: {
|
|
1031
|
+
[x: string]: unknown;
|
|
1032
|
+
media: string;
|
|
1033
|
+
alt?: string | undefined;
|
|
1034
|
+
} | null;
|
|
1035
|
+
trailer: {
|
|
1036
|
+
media: string;
|
|
1037
|
+
poster?: string | undefined;
|
|
1038
|
+
} | null;
|
|
1039
|
+
price: number | null;
|
|
1040
|
+
lessons: number;
|
|
1041
|
+
why: "bought" | "bundle" | "given" | "imported" | "subscription";
|
|
1042
|
+
done: number;
|
|
1043
|
+
counted: number;
|
|
1044
|
+
complete: boolean;
|
|
1045
|
+
continueWith: string | null;
|
|
1046
|
+
}[];
|
|
1047
|
+
} | undefined;
|
|
1048
|
+
isPending: boolean;
|
|
1049
|
+
error: unknown;
|
|
1050
|
+
};
|
|
1051
|
+
/** A session lesson's own Programs session, once it is assigned. */
|
|
1052
|
+
useStartSession(courseId: string | null, lessonKey: string | null): QueryResult<Out<"x.courses.startSession">>;
|
|
1053
|
+
/** Staff: give a person access, with a reason. */
|
|
1054
|
+
useEnrol(): {
|
|
1055
|
+
mutate(input: {
|
|
1056
|
+
personId: string;
|
|
1057
|
+
reason: string;
|
|
1058
|
+
courseId?: string | undefined;
|
|
1059
|
+
bundleId?: string | undefined;
|
|
1060
|
+
until?: string | undefined;
|
|
1061
|
+
}): void;
|
|
1062
|
+
mutateAsync(input: {
|
|
1063
|
+
personId: string;
|
|
1064
|
+
reason: string;
|
|
1065
|
+
courseId?: string | undefined;
|
|
1066
|
+
bundleId?: string | undefined;
|
|
1067
|
+
until?: string | undefined;
|
|
1068
|
+
}): Promise<{
|
|
1069
|
+
enrolmentId: string;
|
|
1070
|
+
status: string;
|
|
1071
|
+
source: string;
|
|
1072
|
+
}>;
|
|
1073
|
+
data: {
|
|
1074
|
+
enrolmentId: string;
|
|
1075
|
+
status: string;
|
|
1076
|
+
source: string;
|
|
1077
|
+
} | undefined;
|
|
1078
|
+
isPending: boolean;
|
|
1079
|
+
error: unknown;
|
|
1080
|
+
};
|
|
1081
|
+
/** Staff: end an enrolment staff gave or one imported. */
|
|
1082
|
+
useEndEnrolment(): {
|
|
1083
|
+
mutate(input: {
|
|
1084
|
+
enrolmentId: string;
|
|
1085
|
+
reason: string;
|
|
1086
|
+
}): void;
|
|
1087
|
+
mutateAsync(input: {
|
|
1088
|
+
enrolmentId: string;
|
|
1089
|
+
reason: string;
|
|
1090
|
+
}): Promise<{
|
|
1091
|
+
enrolmentId: string;
|
|
1092
|
+
status: string;
|
|
1093
|
+
source: string;
|
|
1094
|
+
}>;
|
|
1095
|
+
data: {
|
|
1096
|
+
enrolmentId: string;
|
|
1097
|
+
status: string;
|
|
1098
|
+
source: string;
|
|
1099
|
+
} | undefined;
|
|
1100
|
+
isPending: boolean;
|
|
1101
|
+
error: unknown;
|
|
1102
|
+
};
|
|
1103
|
+
/** Staff: enrolments and lessons done. */
|
|
1104
|
+
useStats(courseId?: string): {
|
|
1105
|
+
data: {
|
|
1106
|
+
courses: {
|
|
1107
|
+
courseId: string;
|
|
1108
|
+
title: string | null;
|
|
1109
|
+
active: number;
|
|
1110
|
+
ended: number;
|
|
1111
|
+
void: number;
|
|
1112
|
+
lessonsDone: number;
|
|
1113
|
+
}[];
|
|
1114
|
+
byWeek: {
|
|
1115
|
+
week: string;
|
|
1116
|
+
done: number;
|
|
1117
|
+
}[];
|
|
1118
|
+
} | undefined;
|
|
1119
|
+
isPending: boolean;
|
|
1120
|
+
error: unknown;
|
|
1121
|
+
};
|
|
1122
|
+
/** The course plans on offer, with the host's prices and trial days. */
|
|
1123
|
+
usePlans(): {
|
|
1124
|
+
data: {
|
|
1125
|
+
plans: {
|
|
1126
|
+
id: string;
|
|
1127
|
+
title: string | null;
|
|
1128
|
+
description: string | null;
|
|
1129
|
+
price: number | null;
|
|
1130
|
+
trialDays: number | null;
|
|
1131
|
+
}[];
|
|
1132
|
+
currency: string | null;
|
|
1133
|
+
} | undefined;
|
|
1134
|
+
isPending: boolean;
|
|
1135
|
+
error: unknown;
|
|
1136
|
+
};
|
|
1137
|
+
/**
|
|
1138
|
+
* Start a course subscription: the host opens the provider's page (web only). Whether the
|
|
1139
|
+
* trial is given is the host's (`noTrial` says why not).
|
|
1140
|
+
*/
|
|
1141
|
+
useSubscribe(): {
|
|
1142
|
+
mutate(input: {
|
|
1143
|
+
plan: {
|
|
1144
|
+
object: string;
|
|
1145
|
+
id: string;
|
|
1146
|
+
};
|
|
1147
|
+
returnUrl: string;
|
|
1148
|
+
email?: string;
|
|
1149
|
+
offerId?: string;
|
|
1150
|
+
}): void;
|
|
1151
|
+
mutateAsync(input: {
|
|
1152
|
+
plan: {
|
|
1153
|
+
object: string;
|
|
1154
|
+
id: string;
|
|
1155
|
+
};
|
|
1156
|
+
returnUrl: string;
|
|
1157
|
+
email?: string;
|
|
1158
|
+
offerId?: string;
|
|
1159
|
+
}): Promise<StartedSubscription>;
|
|
1160
|
+
data: StartedSubscription | undefined;
|
|
1161
|
+
isPending: boolean;
|
|
1162
|
+
error: unknown;
|
|
1163
|
+
};
|
|
1164
|
+
/** The signed-in customer's own course subscriptions, newest first. */
|
|
1165
|
+
useMySubscriptions(): {
|
|
1166
|
+
data: {
|
|
1167
|
+
items: CourseSubscription[];
|
|
1168
|
+
nextCursor: string | null;
|
|
1169
|
+
} | undefined;
|
|
1170
|
+
isPending: boolean;
|
|
1171
|
+
error: unknown;
|
|
1172
|
+
};
|
|
1173
|
+
/**
|
|
1174
|
+
* The signed-in customer's own continuation offers (moving from another platform): free until
|
|
1175
|
+
* their paid-up date. Read only; taking one is `useSubscribe` with `offerId` (web only).
|
|
1176
|
+
*/
|
|
1177
|
+
useMyOffers(options?: {
|
|
1178
|
+
enabled?: boolean;
|
|
1179
|
+
}): {
|
|
1180
|
+
data: {
|
|
1181
|
+
offers: ContinuationOffer[];
|
|
1182
|
+
} | undefined;
|
|
1183
|
+
isPending: boolean;
|
|
1184
|
+
error: unknown;
|
|
1185
|
+
};
|
|
1186
|
+
/** End their own subscription when its period ends (web only). */
|
|
1187
|
+
useCancelSubscription(): {
|
|
1188
|
+
mutate(input: {
|
|
1189
|
+
id: string;
|
|
1190
|
+
reason?: string;
|
|
1191
|
+
}): void;
|
|
1192
|
+
mutateAsync(input: {
|
|
1193
|
+
id: string;
|
|
1194
|
+
reason?: string;
|
|
1195
|
+
}): Promise<{
|
|
1196
|
+
id: string;
|
|
1197
|
+
requested: true;
|
|
1198
|
+
}>;
|
|
1199
|
+
data: {
|
|
1200
|
+
id: string;
|
|
1201
|
+
requested: true;
|
|
1202
|
+
} | undefined;
|
|
1203
|
+
isPending: boolean;
|
|
1204
|
+
error: unknown;
|
|
1205
|
+
};
|
|
1206
|
+
/** Undo that, before the period ends (web only). */
|
|
1207
|
+
useResumeSubscription(): {
|
|
1208
|
+
mutate(input: {
|
|
1209
|
+
id: string;
|
|
1210
|
+
}): void;
|
|
1211
|
+
mutateAsync(input: {
|
|
1212
|
+
id: string;
|
|
1213
|
+
}): Promise<{
|
|
1214
|
+
id: string;
|
|
1215
|
+
requested: true;
|
|
1216
|
+
}>;
|
|
1217
|
+
data: {
|
|
1218
|
+
id: string;
|
|
1219
|
+
requested: true;
|
|
1220
|
+
} | undefined;
|
|
1221
|
+
isPending: boolean;
|
|
1222
|
+
error: unknown;
|
|
1223
|
+
};
|
|
1224
|
+
/** The provider's portal for their card and past invoices (web only, never in a frame). */
|
|
1225
|
+
useBillingPortal(): {
|
|
1226
|
+
mutate(input: {
|
|
1227
|
+
returnUrl: string;
|
|
1228
|
+
}): void;
|
|
1229
|
+
mutateAsync(input: {
|
|
1230
|
+
returnUrl: string;
|
|
1231
|
+
}): Promise<{
|
|
1232
|
+
url: string;
|
|
1233
|
+
}>;
|
|
1234
|
+
data: {
|
|
1235
|
+
url: string;
|
|
1236
|
+
} | undefined;
|
|
1237
|
+
isPending: boolean;
|
|
1238
|
+
error: unknown;
|
|
1239
|
+
};
|
|
1240
|
+
/** Staff: a course's working copy, as the builder edits it. */
|
|
1241
|
+
useWorkingCopy(courseId: string): {
|
|
1242
|
+
data: {
|
|
1243
|
+
id: string;
|
|
1244
|
+
values: Record<string, unknown>;
|
|
1245
|
+
} | undefined;
|
|
1246
|
+
isPending: boolean;
|
|
1247
|
+
error: unknown;
|
|
1248
|
+
};
|
|
1249
|
+
/** Staff: save the course's working copy (its outline). */
|
|
1250
|
+
useSaveOutline(): {
|
|
1251
|
+
mutate(input: {
|
|
1252
|
+
object: string;
|
|
1253
|
+
id: string;
|
|
1254
|
+
values: Record<string, unknown>;
|
|
1255
|
+
}): void;
|
|
1256
|
+
mutateAsync(input: {
|
|
1257
|
+
object: string;
|
|
1258
|
+
id: string;
|
|
1259
|
+
values: Record<string, unknown>;
|
|
1260
|
+
}): Promise<{
|
|
1261
|
+
id: string;
|
|
1262
|
+
values: Record<string, unknown>;
|
|
1263
|
+
}>;
|
|
1264
|
+
data: {
|
|
1265
|
+
id: string;
|
|
1266
|
+
values: Record<string, unknown>;
|
|
1267
|
+
} | undefined;
|
|
1268
|
+
isPending: boolean;
|
|
1269
|
+
error: unknown;
|
|
1270
|
+
};
|
|
1271
|
+
/** Staff: publish the course (a person; an assistant's request waits for one). */
|
|
1272
|
+
usePublishCourse(): {
|
|
1273
|
+
mutate(input: {
|
|
1274
|
+
object: string;
|
|
1275
|
+
id: string;
|
|
1276
|
+
note?: string;
|
|
1277
|
+
}): void;
|
|
1278
|
+
mutateAsync(input: {
|
|
1279
|
+
object: string;
|
|
1280
|
+
id: string;
|
|
1281
|
+
note?: string;
|
|
1282
|
+
}): Promise<{
|
|
1283
|
+
version: number;
|
|
1284
|
+
publishedAt: string;
|
|
1285
|
+
}>;
|
|
1286
|
+
data: {
|
|
1287
|
+
version: number;
|
|
1288
|
+
publishedAt: string;
|
|
1289
|
+
} | undefined;
|
|
1290
|
+
isPending: boolean;
|
|
1291
|
+
error: unknown;
|
|
1292
|
+
};
|
|
1293
|
+
/** Staff: the library's ready videos, to pick a lesson's video. */
|
|
1294
|
+
useLibraryVideos(): {
|
|
1295
|
+
data: {
|
|
1296
|
+
items: {
|
|
1297
|
+
id: string;
|
|
1298
|
+
values: Record<string, unknown>;
|
|
1299
|
+
}[];
|
|
1300
|
+
nextCursor: string | null;
|
|
1301
|
+
} | undefined;
|
|
1302
|
+
isPending: boolean;
|
|
1303
|
+
error: unknown;
|
|
1304
|
+
};
|
|
1305
|
+
/** Staff: the published Programs programs, to pick a session lesson's program. */
|
|
1306
|
+
usePublishedPrograms(): {
|
|
1307
|
+
data: {
|
|
1308
|
+
items: {
|
|
1309
|
+
id: string;
|
|
1310
|
+
title?: string | null;
|
|
1311
|
+
values: Record<string, unknown>;
|
|
1312
|
+
}[];
|
|
1313
|
+
} | undefined;
|
|
1314
|
+
isPending: boolean;
|
|
1315
|
+
error: unknown;
|
|
1316
|
+
};
|
|
1317
|
+
};
|
|
1318
|
+
/** Every hook of this entry. A block takes the ones it calls: `Pick<CoursesHooks, "useLesson">`. */
|
|
1319
|
+
export type CoursesHooks = ReturnType<typeof allCoursesHooks>;
|