@tansy/lms 0.0.0-stage → 0.1.0

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/schema.d.ts ADDED
@@ -0,0 +1,706 @@
1
+ import type { PluginRole } from "tansy/plugin";
2
+ /** The collections the LMS creates on first install. Owners can change all of it afterwards. */
3
+ export declare const COLLECTIONS: readonly ["lms-courses", "lms-sections", "lms-lessons", "lms-quizzes", "lms-enrollments", "lms-progress", "lms-attempts", "lms-certificates", "lms-my-courses", "lms-certificate", "lms-outline"];
4
+ /** Blocks a course description allows when it's created. */
5
+ export declare const DESCRIPTION_BLOCKS: string[];
6
+ /** Blocks a lesson allows when it's created. Owners can add their own. */
7
+ export declare const LESSON_BLOCKS: string[];
8
+ /** Where a course's own content lives. An instructor writes these for their own courses only. */
9
+ export declare const AUTHORED: readonly ["lms-courses", "lms-sections", "lms-lessons", "lms-quizzes"];
10
+ /** Who teaches and who runs the school. Created once, then owners change them under Roles like any other. */
11
+ export declare function lmsRoles(): PluginRole[];
12
+ /** The name shown on a course. Filled from the instructor's account, and only managers can change it. */
13
+ /** Sold through the Payments plugin. Added after the first release, so migration 003 adds it to existing sites. */
14
+ export declare const PAID_ACCESS: {
15
+ label: string;
16
+ value: string;
17
+ };
18
+ /** Enrolled through a plan from the Payments plugin, and lapsed when the plan no longer covers the course. Added by migration 006. */
19
+ export declare const PLAN_SOURCE: {
20
+ label: string;
21
+ value: string;
22
+ };
23
+ export declare const LAPSED_STATE: {
24
+ label: string;
25
+ value: string;
26
+ };
27
+ export declare const BYLINE_FIELD: {
28
+ name: string;
29
+ type: string;
30
+ config: {
31
+ maxLength: number;
32
+ label: string;
33
+ };
34
+ };
35
+ /**
36
+ * The gate. A course id in the hidden lms_courses user field means an active enrollment,
37
+ * and only the plugin writes that field. Rules read user values on every request, so
38
+ * revoking an enrollment ends access on the next one, through every way of reading records.
39
+ */
40
+ export declare const ENROLLED = "@request.auth.lms_courses ?= course";
41
+ /** The user field the gate reads. */
42
+ export declare const COURSES_FIELD = "lms_courses";
43
+ /**
44
+ * Only what a course page may show anyone about its lessons. Drafts stay out, and the
45
+ * lessons themselves stay gated. Quoted names, so it runs the same on SQLite and Postgres.
46
+ */
47
+ export declare const OUTLINE_QUERY = "SELECT \"id\", \"title\", \"course\", \"section\", \"position\", \"preview\", \"durationMinutes\" FROM \"rec_lms_lessons\" WHERE \"status\" = 'published'";
48
+ /** A field the plugin's code reads or writes, by collection: the contract Extensions checks. */
49
+ export declare const CONTRACT: {
50
+ "lms-courses": {
51
+ slug: string;
52
+ title: string;
53
+ summary: string;
54
+ byline: string;
55
+ access: string;
56
+ };
57
+ "lms-sections": {
58
+ course: string;
59
+ title: string;
60
+ position: string;
61
+ };
62
+ "lms-lessons": {
63
+ slug: string;
64
+ title: string;
65
+ course: string;
66
+ section: string;
67
+ position: string;
68
+ preview: string;
69
+ content: string;
70
+ };
71
+ "lms-quizzes": {
72
+ lesson: string;
73
+ course: string;
74
+ title: string;
75
+ questions: string;
76
+ passingScore: string;
77
+ maxAttempts: string;
78
+ };
79
+ "lms-enrollments": {
80
+ course: string;
81
+ student: string;
82
+ state: string;
83
+ source: string;
84
+ enrolledAt: string;
85
+ completedAt: string;
86
+ };
87
+ "lms-progress": {
88
+ key: string;
89
+ student: string;
90
+ course: string;
91
+ lesson: string;
92
+ completedAt: string;
93
+ };
94
+ "lms-attempts": {
95
+ quiz: string;
96
+ student: string;
97
+ answers: string;
98
+ score: string;
99
+ passed: string;
100
+ submittedAt: string;
101
+ };
102
+ "lms-certificates": {
103
+ code: string;
104
+ student: string;
105
+ course: string;
106
+ studentName: string;
107
+ issuedAt: string;
108
+ };
109
+ };
110
+ export declare function lmsSchema(basePath: string): {
111
+ version: number;
112
+ collections: ({
113
+ slug: string;
114
+ name: string;
115
+ description: string;
116
+ urlPattern: string;
117
+ rules: {
118
+ createRule: null;
119
+ updateRule: null;
120
+ deleteRule: null;
121
+ listRule: string;
122
+ viewRule: string;
123
+ };
124
+ fields: ({
125
+ name: string;
126
+ type: string;
127
+ config: {
128
+ maxLength: number;
129
+ label: string;
130
+ };
131
+ } | {
132
+ name: string;
133
+ type: string;
134
+ config: {
135
+ unique: boolean;
136
+ maxLength: number;
137
+ pattern: string;
138
+ patternError: string;
139
+ };
140
+ } | {
141
+ name: string;
142
+ type: string;
143
+ config: {
144
+ required: boolean;
145
+ maxLength: number;
146
+ searchable: boolean;
147
+ multiline?: undefined;
148
+ allowedBlocks?: undefined;
149
+ options?: undefined;
150
+ defaultValue?: undefined;
151
+ format?: undefined;
152
+ min?: undefined;
153
+ };
154
+ } | {
155
+ name: string;
156
+ type: string;
157
+ config: {
158
+ multiline: boolean;
159
+ maxLength: number;
160
+ searchable: boolean;
161
+ required?: undefined;
162
+ allowedBlocks?: undefined;
163
+ options?: undefined;
164
+ defaultValue?: undefined;
165
+ format?: undefined;
166
+ min?: undefined;
167
+ };
168
+ } | {
169
+ name: string;
170
+ type: string;
171
+ config: {
172
+ required?: undefined;
173
+ maxLength?: undefined;
174
+ searchable?: undefined;
175
+ multiline?: undefined;
176
+ allowedBlocks?: undefined;
177
+ options?: undefined;
178
+ defaultValue?: undefined;
179
+ format?: undefined;
180
+ min?: undefined;
181
+ };
182
+ } | {
183
+ name: string;
184
+ type: string;
185
+ config: {
186
+ allowedBlocks: string[];
187
+ required?: undefined;
188
+ maxLength?: undefined;
189
+ searchable?: undefined;
190
+ multiline?: undefined;
191
+ options?: undefined;
192
+ defaultValue?: undefined;
193
+ format?: undefined;
194
+ min?: undefined;
195
+ };
196
+ } | {
197
+ name: string;
198
+ type: string;
199
+ config: {
200
+ options: {
201
+ label: string;
202
+ value: string;
203
+ }[];
204
+ required?: undefined;
205
+ maxLength?: undefined;
206
+ searchable?: undefined;
207
+ multiline?: undefined;
208
+ allowedBlocks?: undefined;
209
+ defaultValue?: undefined;
210
+ format?: undefined;
211
+ min?: undefined;
212
+ };
213
+ } | {
214
+ name: string;
215
+ type: string;
216
+ config: {
217
+ options: {
218
+ label: string;
219
+ value: string;
220
+ }[];
221
+ defaultValue: string;
222
+ required?: undefined;
223
+ maxLength?: undefined;
224
+ searchable?: undefined;
225
+ multiline?: undefined;
226
+ allowedBlocks?: undefined;
227
+ format?: undefined;
228
+ min?: undefined;
229
+ };
230
+ } | {
231
+ name: string;
232
+ type: string;
233
+ config: {
234
+ format: string;
235
+ min: number;
236
+ required?: undefined;
237
+ maxLength?: undefined;
238
+ searchable?: undefined;
239
+ multiline?: undefined;
240
+ allowedBlocks?: undefined;
241
+ options?: undefined;
242
+ defaultValue?: undefined;
243
+ };
244
+ })[];
245
+ type?: undefined;
246
+ viewQuery?: undefined;
247
+ } | {
248
+ slug: string;
249
+ name: string;
250
+ description: string;
251
+ urlPattern: string;
252
+ rules: {
253
+ createRule: null;
254
+ updateRule: null;
255
+ deleteRule: null;
256
+ listRule: string;
257
+ viewRule: string;
258
+ };
259
+ fields: ({
260
+ name: string;
261
+ type: string;
262
+ config: {
263
+ unique: boolean;
264
+ maxLength: number;
265
+ pattern: string;
266
+ patternError: string;
267
+ };
268
+ } | {
269
+ name: string;
270
+ type: string;
271
+ config: {
272
+ format: string;
273
+ min: number;
274
+ description: string;
275
+ };
276
+ } | {
277
+ name: string;
278
+ type: string;
279
+ config: {
280
+ required: boolean;
281
+ maxLength: number;
282
+ collection?: undefined;
283
+ displayField?: undefined;
284
+ description?: undefined;
285
+ allowedBlocks?: undefined;
286
+ format?: undefined;
287
+ min?: undefined;
288
+ };
289
+ } | {
290
+ name: string;
291
+ type: string;
292
+ config: {
293
+ collection: string;
294
+ displayField: string;
295
+ required: boolean;
296
+ maxLength?: undefined;
297
+ description?: undefined;
298
+ allowedBlocks?: undefined;
299
+ format?: undefined;
300
+ min?: undefined;
301
+ };
302
+ } | {
303
+ name: string;
304
+ type: string;
305
+ config: {
306
+ collection: string;
307
+ displayField: string;
308
+ required?: undefined;
309
+ maxLength?: undefined;
310
+ description?: undefined;
311
+ allowedBlocks?: undefined;
312
+ format?: undefined;
313
+ min?: undefined;
314
+ };
315
+ } | {
316
+ name: string;
317
+ type: string;
318
+ config: {
319
+ description: string;
320
+ required?: undefined;
321
+ maxLength?: undefined;
322
+ collection?: undefined;
323
+ displayField?: undefined;
324
+ allowedBlocks?: undefined;
325
+ format?: undefined;
326
+ min?: undefined;
327
+ };
328
+ } | {
329
+ name: string;
330
+ type: string;
331
+ config: {
332
+ allowedBlocks: string[];
333
+ required?: undefined;
334
+ maxLength?: undefined;
335
+ collection?: undefined;
336
+ displayField?: undefined;
337
+ description?: undefined;
338
+ format?: undefined;
339
+ min?: undefined;
340
+ };
341
+ } | {
342
+ name: string;
343
+ type: string;
344
+ config: {
345
+ format: string;
346
+ min: number;
347
+ required?: undefined;
348
+ maxLength?: undefined;
349
+ collection?: undefined;
350
+ displayField?: undefined;
351
+ description?: undefined;
352
+ allowedBlocks?: undefined;
353
+ };
354
+ })[];
355
+ type?: undefined;
356
+ viewQuery?: undefined;
357
+ } | {
358
+ slug: string;
359
+ name: string;
360
+ description: string;
361
+ urlPattern: null;
362
+ rules: {
363
+ createRule: null;
364
+ updateRule: null;
365
+ deleteRule: null;
366
+ listRule: string;
367
+ viewRule: string;
368
+ };
369
+ fields: ({
370
+ name: string;
371
+ type: string;
372
+ config: {
373
+ required: boolean;
374
+ maxLength: number;
375
+ collection?: undefined;
376
+ displayField?: undefined;
377
+ description?: undefined;
378
+ allowedBlocks?: undefined;
379
+ hidden?: undefined;
380
+ format?: undefined;
381
+ min?: undefined;
382
+ max?: undefined;
383
+ };
384
+ } | {
385
+ name: string;
386
+ type: string;
387
+ config: {
388
+ collection: string;
389
+ displayField: string;
390
+ required: boolean;
391
+ maxLength?: undefined;
392
+ description?: undefined;
393
+ allowedBlocks?: undefined;
394
+ hidden?: undefined;
395
+ format?: undefined;
396
+ min?: undefined;
397
+ max?: undefined;
398
+ };
399
+ } | {
400
+ name: string;
401
+ type: string;
402
+ config: {
403
+ collection: string;
404
+ displayField: string;
405
+ description: string;
406
+ required?: undefined;
407
+ maxLength?: undefined;
408
+ allowedBlocks?: undefined;
409
+ hidden?: undefined;
410
+ format?: undefined;
411
+ min?: undefined;
412
+ max?: undefined;
413
+ };
414
+ } | {
415
+ name: string;
416
+ type: string;
417
+ config: {
418
+ allowedBlocks: string[];
419
+ hidden: boolean;
420
+ required?: undefined;
421
+ maxLength?: undefined;
422
+ collection?: undefined;
423
+ displayField?: undefined;
424
+ description?: undefined;
425
+ format?: undefined;
426
+ min?: undefined;
427
+ max?: undefined;
428
+ };
429
+ } | {
430
+ name: string;
431
+ type: string;
432
+ config: {
433
+ format: string;
434
+ min: number;
435
+ max: number;
436
+ description: string;
437
+ required?: undefined;
438
+ maxLength?: undefined;
439
+ collection?: undefined;
440
+ displayField?: undefined;
441
+ allowedBlocks?: undefined;
442
+ hidden?: undefined;
443
+ };
444
+ } | {
445
+ name: string;
446
+ type: string;
447
+ config: {
448
+ format: string;
449
+ min: number;
450
+ description: string;
451
+ required?: undefined;
452
+ maxLength?: undefined;
453
+ collection?: undefined;
454
+ displayField?: undefined;
455
+ allowedBlocks?: undefined;
456
+ hidden?: undefined;
457
+ max?: undefined;
458
+ };
459
+ })[];
460
+ type?: undefined;
461
+ viewQuery?: undefined;
462
+ } | {
463
+ slug: string;
464
+ name: string;
465
+ description: string;
466
+ urlPattern: null;
467
+ rules: {
468
+ createRule: null;
469
+ updateRule: null;
470
+ deleteRule: null;
471
+ listRule: string;
472
+ viewRule: string;
473
+ };
474
+ fields: ({
475
+ name: string;
476
+ type: string;
477
+ config: {
478
+ required: boolean;
479
+ maxLength: number;
480
+ label: string;
481
+ };
482
+ } | {
483
+ name: string;
484
+ type: string;
485
+ config: {
486
+ collection: string;
487
+ displayField: string;
488
+ required: boolean;
489
+ options?: undefined;
490
+ defaultValue?: undefined;
491
+ };
492
+ } | {
493
+ name: string;
494
+ type: string;
495
+ config: {
496
+ options: {
497
+ label: string;
498
+ value: string;
499
+ }[];
500
+ defaultValue: string;
501
+ collection?: undefined;
502
+ displayField?: undefined;
503
+ required?: undefined;
504
+ };
505
+ } | {
506
+ name: string;
507
+ type: string;
508
+ config: {
509
+ collection?: undefined;
510
+ displayField?: undefined;
511
+ required?: undefined;
512
+ options?: undefined;
513
+ defaultValue?: undefined;
514
+ };
515
+ })[];
516
+ type?: undefined;
517
+ viewQuery?: undefined;
518
+ } | {
519
+ slug: string;
520
+ name: string;
521
+ description: string;
522
+ urlPattern: null;
523
+ rules: {
524
+ createRule: null;
525
+ updateRule: null;
526
+ deleteRule: null;
527
+ listRule: string;
528
+ viewRule: string;
529
+ };
530
+ fields: ({
531
+ name: string;
532
+ type: string;
533
+ config: {
534
+ required: boolean;
535
+ maxLength: number;
536
+ label: string;
537
+ };
538
+ } | {
539
+ name: string;
540
+ type: string;
541
+ config: {
542
+ collection: string;
543
+ displayField: string;
544
+ required: boolean;
545
+ min?: undefined;
546
+ max?: undefined;
547
+ };
548
+ } | {
549
+ name: string;
550
+ type: string;
551
+ config: {
552
+ collection?: undefined;
553
+ displayField?: undefined;
554
+ required?: undefined;
555
+ min?: undefined;
556
+ max?: undefined;
557
+ };
558
+ } | {
559
+ name: string;
560
+ type: string;
561
+ config: {
562
+ min: number;
563
+ max: number;
564
+ collection?: undefined;
565
+ displayField?: undefined;
566
+ required?: undefined;
567
+ };
568
+ })[];
569
+ type?: undefined;
570
+ viewQuery?: undefined;
571
+ } | {
572
+ slug: string;
573
+ name: string;
574
+ description: string;
575
+ urlPattern: null;
576
+ rules: {
577
+ createRule: null;
578
+ updateRule: null;
579
+ deleteRule: null;
580
+ listRule: string;
581
+ viewRule: string;
582
+ };
583
+ fields: ({
584
+ name: string;
585
+ type: string;
586
+ config: {
587
+ required: boolean;
588
+ maxLength: number;
589
+ label: string;
590
+ };
591
+ } | {
592
+ name: string;
593
+ type: string;
594
+ config: {
595
+ required: boolean;
596
+ unique: boolean;
597
+ maxLength: number;
598
+ collection?: undefined;
599
+ displayField?: undefined;
600
+ };
601
+ } | {
602
+ name: string;
603
+ type: string;
604
+ config: {
605
+ collection: string;
606
+ displayField: string;
607
+ required: boolean;
608
+ unique?: undefined;
609
+ maxLength?: undefined;
610
+ };
611
+ } | {
612
+ name: string;
613
+ type: string;
614
+ config: {
615
+ maxLength: number;
616
+ required?: undefined;
617
+ unique?: undefined;
618
+ collection?: undefined;
619
+ displayField?: undefined;
620
+ };
621
+ } | {
622
+ name: string;
623
+ type: string;
624
+ config: {
625
+ required?: undefined;
626
+ unique?: undefined;
627
+ maxLength?: undefined;
628
+ collection?: undefined;
629
+ displayField?: undefined;
630
+ };
631
+ })[];
632
+ type?: undefined;
633
+ viewQuery?: undefined;
634
+ } | {
635
+ slug: string;
636
+ name: string;
637
+ description: string;
638
+ type: string;
639
+ urlPattern: string;
640
+ rules: {
641
+ createRule: null;
642
+ updateRule: null;
643
+ deleteRule: null;
644
+ listRule: string;
645
+ viewRule: string;
646
+ };
647
+ fields: ({
648
+ name: string;
649
+ type: string;
650
+ config: {
651
+ required: boolean;
652
+ maxLength: number;
653
+ };
654
+ } | {
655
+ name: string;
656
+ type: string;
657
+ config: {
658
+ required?: undefined;
659
+ maxLength?: undefined;
660
+ };
661
+ })[];
662
+ viewQuery?: undefined;
663
+ } | {
664
+ slug: string;
665
+ name: string;
666
+ description: string;
667
+ type: string;
668
+ viewQuery: string;
669
+ urlPattern: null;
670
+ rules: {
671
+ createRule: null;
672
+ updateRule: null;
673
+ deleteRule: null;
674
+ listRule: string;
675
+ viewRule: string;
676
+ };
677
+ fields: never[];
678
+ })[];
679
+ blocks: {
680
+ name: string;
681
+ label: string;
682
+ labels: {
683
+ ar: string;
684
+ };
685
+ icon: null;
686
+ fields: {
687
+ name: string;
688
+ type: string;
689
+ config: {
690
+ collection: string;
691
+ displayField: string;
692
+ required: boolean;
693
+ };
694
+ }[];
695
+ }[];
696
+ userFields: {
697
+ name: string;
698
+ type: string;
699
+ config: {
700
+ hidden: boolean;
701
+ label: string;
702
+ description: string;
703
+ };
704
+ selfEditable: boolean;
705
+ }[];
706
+ };