@happyvertical/smrt-education 0.57.42 → 0.57.44

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.
Files changed (82) hide show
  1. package/AGENTS.md +12 -0
  2. package/README.md +5 -0
  3. package/agents/course-authoring-service.md +179 -0
  4. package/agents/course-generation-review.md +79 -0
  5. package/agents/learner-service.md +33 -0
  6. package/agents/question-records.md +100 -0
  7. package/dist/chunks/{workbook-photo-service-C6mbUUp6.js → workbook-photo-service-BxvZDqjM.js} +1440 -309
  8. package/dist/chunks/workbook-photo-service-BxvZDqjM.js.map +1 -0
  9. package/dist/course-append-only.d.ts +15 -0
  10. package/dist/course-append-only.d.ts.map +1 -0
  11. package/dist/course-authoring-contracts.d.ts +464 -0
  12. package/dist/course-authoring-contracts.d.ts.map +1 -0
  13. package/dist/course-authoring-licence.d.ts +15 -0
  14. package/dist/course-authoring-licence.d.ts.map +1 -0
  15. package/dist/course-authoring-models.d.ts +291 -0
  16. package/dist/course-authoring-models.d.ts.map +1 -0
  17. package/dist/course-authoring-service.d.ts +244 -0
  18. package/dist/course-authoring-service.d.ts.map +1 -0
  19. package/dist/course-delegation.d.ts +26 -0
  20. package/dist/course-delegation.d.ts.map +1 -0
  21. package/dist/course-generation-contracts.d.ts +150 -0
  22. package/dist/course-generation-contracts.d.ts.map +1 -0
  23. package/dist/course-generation-models.d.ts +94 -0
  24. package/dist/course-generation-models.d.ts.map +1 -0
  25. package/dist/course-generation-output.d.ts +31 -0
  26. package/dist/course-generation-output.d.ts.map +1 -0
  27. package/dist/course-generation-proposal-generator.d.ts +94 -0
  28. package/dist/course-generation-proposal-generator.d.ts.map +1 -0
  29. package/dist/course-generation-review-service.d.ts +149 -0
  30. package/dist/course-generation-review-service.d.ts.map +1 -0
  31. package/dist/course-release-scope.d.ts +37 -0
  32. package/dist/course-release-scope.d.ts.map +1 -0
  33. package/dist/course-review-contracts.d.ts +127 -0
  34. package/dist/course-review-contracts.d.ts.map +1 -0
  35. package/dist/course-review-digest.d.ts +4 -0
  36. package/dist/course-review-digest.d.ts.map +1 -0
  37. package/dist/course-review-evaluation.d.ts +63 -0
  38. package/dist/course-review-evaluation.d.ts.map +1 -0
  39. package/dist/course-review-gate.d.ts +15 -0
  40. package/dist/course-review-gate.d.ts.map +1 -0
  41. package/dist/course-review-models.d.ts +96 -0
  42. package/dist/course-review-models.d.ts.map +1 -0
  43. package/dist/group-sharing-contracts.d.ts +5 -0
  44. package/dist/group-sharing-contracts.d.ts.map +1 -1
  45. package/dist/group-sharing-policy.d.ts.map +1 -1
  46. package/dist/group-sharing-reader.d.ts.map +1 -1
  47. package/dist/index.d.ts +27 -0
  48. package/dist/index.d.ts.map +1 -1
  49. package/dist/index.js +5658 -116
  50. package/dist/index.js.map +1 -1
  51. package/dist/ingestion.js +1 -1
  52. package/dist/learner-plan-service.d.ts.map +1 -1
  53. package/dist/learner-service.d.ts +81 -7
  54. package/dist/learner-service.d.ts.map +1 -1
  55. package/dist/learners.d.ts +6 -0
  56. package/dist/learners.d.ts.map +1 -1
  57. package/dist/manifest.json +14304 -2177
  58. package/dist/question-authoring-service.d.ts +125 -0
  59. package/dist/question-authoring-service.d.ts.map +1 -0
  60. package/dist/question-content.d.ts +25 -0
  61. package/dist/question-content.d.ts.map +1 -0
  62. package/dist/question-contracts.d.ts +240 -0
  63. package/dist/question-contracts.d.ts.map +1 -0
  64. package/dist/question-models.d.ts +124 -0
  65. package/dist/question-models.d.ts.map +1 -0
  66. package/dist/question-render.d.ts +20 -0
  67. package/dist/question-render.d.ts.map +1 -0
  68. package/dist/question-response-contracts.d.ts +54 -0
  69. package/dist/question-response-contracts.d.ts.map +1 -0
  70. package/dist/question-response-service.d.ts +63 -0
  71. package/dist/question-response-service.d.ts.map +1 -0
  72. package/dist/question-rubric.d.ts +23 -0
  73. package/dist/question-rubric.d.ts.map +1 -0
  74. package/dist/smrt-knowledge.json +5410 -910
  75. package/dist/submission-service.d.ts.map +1 -1
  76. package/dist/submissions.d.ts +5 -0
  77. package/dist/submissions.d.ts.map +1 -1
  78. package/dist/workbook-contracts.d.ts +6 -0
  79. package/dist/workbook-contracts.d.ts.map +1 -1
  80. package/dist/workbook-models.d.ts.map +1 -1
  81. package/package.json +8 -8
  82. package/dist/chunks/workbook-photo-service-C6mbUUp6.js.map +0 -1
@@ -0,0 +1,291 @@
1
+ import { SmrtCollection, SmrtObject, type SmrtSaveOptions } from '@happyvertical/smrt-core';
2
+ import type { CourseLicenseKind } from './catalog.js';
3
+ /** Immutable snapshot of one authored course draft. The head row selects the draft. */
4
+ export declare class CourseRevision extends SmrtObject {
5
+ tenantId: string;
6
+ courseId: string;
7
+ parentRevisionId: string | null;
8
+ sequence: number;
9
+ authorUserId: string;
10
+ delegatingGuardianUserId: string;
11
+ delegationId: string;
12
+ provenance: string;
13
+ fieldProvenanceJson: string;
14
+ title: string;
15
+ summary: string;
16
+ subject: string;
17
+ theme: string;
18
+ levelMin: number;
19
+ levelMax: number;
20
+ objectivesJson: string;
21
+ sectionsJson: string;
22
+ licenseKind: CourseLicenseKind;
23
+ requestKey: string;
24
+ payloadDigest: string;
25
+ contentDigest: string;
26
+ recordedAt: Date;
27
+ constructor(options?: Record<string, unknown>);
28
+ delete(): Promise<void>;
29
+ save(options?: SmrtSaveOptions): Promise<this>;
30
+ }
31
+ export declare class CourseRevisionCollection extends SmrtCollection<CourseRevision> {
32
+ static readonly _itemClass: typeof CourseRevision;
33
+ }
34
+ /** Immutable lesson snapshot with a stable cross-version `lessonKey`. */
35
+ export declare class LessonRevision extends SmrtObject {
36
+ tenantId: string;
37
+ courseId: string;
38
+ lessonKey: string;
39
+ parentRevisionId: string | null;
40
+ title: string;
41
+ body: string;
42
+ lessonType: string;
43
+ completionRule: string;
44
+ estimatedMinutes: number;
45
+ difficulty: number;
46
+ modality: string;
47
+ externalRef: string;
48
+ externalUrl: string;
49
+ licenseKind: CourseLicenseKind;
50
+ /** The lesson's own licence before materials; sticky across revisions of a lessonKey. */
51
+ ownLicenseKind: string;
52
+ materialsJson: string;
53
+ /** Ordered `LessonQuestionRefInput`s naming immutable question revisions. */
54
+ questionsJson: string;
55
+ /** Flat render parameters that, with the refs, make up the worksheet version id. */
56
+ layoutParamsJson: string;
57
+ provenance: string;
58
+ fieldProvenanceJson: string;
59
+ authorUserId: string;
60
+ delegatingGuardianUserId: string;
61
+ delegationId: string;
62
+ contentDigest: string;
63
+ recordedAt: Date;
64
+ constructor(options?: Record<string, unknown>);
65
+ delete(): Promise<void>;
66
+ save(options?: SmrtSaveOptions): Promise<this>;
67
+ }
68
+ export declare class LessonRevisionCollection extends SmrtCollection<LessonRevision> {
69
+ static readonly _itemClass: typeof LessonRevision;
70
+ }
71
+ /**
72
+ * The only mutable authoring row: the draft head. It moves solely through the
73
+ * service's expected-head compare-and-swap; its identity never changes.
74
+ */
75
+ export declare class CourseDraftHead extends SmrtObject {
76
+ tenantId: string;
77
+ courseId: string;
78
+ headRevisionId: string;
79
+ version: number;
80
+ updatedByUserId: string;
81
+ updatedAt: Date;
82
+ constructor(options?: Record<string, unknown>);
83
+ delete(): Promise<void>;
84
+ save(options?: SmrtSaveOptions): Promise<this>;
85
+ }
86
+ export declare class CourseDraftHeadCollection extends SmrtCollection<CourseDraftHead> {
87
+ static readonly _itemClass: typeof CourseDraftHead;
88
+ }
89
+ /** Append-only release decision bound to one revision and the review that allowed it. */
90
+ export declare class CourseRelease extends SmrtObject {
91
+ tenantId: string;
92
+ courseId: string;
93
+ revisionId: string;
94
+ /** The immutable Course row materialized for this release. */
95
+ releaseCourseId: string;
96
+ releaseNumber: number;
97
+ reviewId: string;
98
+ actorUserId: string;
99
+ delegatingGuardianUserId: string;
100
+ delegationId: string;
101
+ requestKey: string;
102
+ recordedAt: Date;
103
+ constructor(options?: Record<string, unknown>);
104
+ delete(): Promise<void>;
105
+ save(options?: SmrtSaveOptions): Promise<this>;
106
+ }
107
+ export declare class CourseReleaseCollection extends SmrtCollection<CourseRelease> {
108
+ static readonly _itemClass: typeof CourseRelease;
109
+ }
110
+ /** Stable lesson identity for one release's immutable Lesson row. */
111
+ export declare class ReleasedLesson extends SmrtObject {
112
+ tenantId: string;
113
+ courseId: string;
114
+ releaseId: string;
115
+ lessonKey: string;
116
+ lessonRevisionId: string;
117
+ lessonId: string;
118
+ sectionId: string;
119
+ constructor(options?: Record<string, unknown>);
120
+ delete(): Promise<void>;
121
+ save(options?: SmrtSaveOptions): Promise<this>;
122
+ }
123
+ export declare class ReleasedLessonCollection extends SmrtCollection<ReleasedLesson> {
124
+ static readonly _itemClass: typeof ReleasedLesson;
125
+ }
126
+ /** Reversible archive/unarchive decisions; the latest sequence is the state. */
127
+ export declare class CourseArchiveDecision extends SmrtObject {
128
+ tenantId: string;
129
+ courseId: string;
130
+ action: string;
131
+ sequence: number;
132
+ actorUserId: string;
133
+ delegatingGuardianUserId: string;
134
+ delegationId: string;
135
+ requestKey: string;
136
+ recordedAt: Date;
137
+ constructor(options?: Record<string, unknown>);
138
+ delete(): Promise<void>;
139
+ save(options?: SmrtSaveOptions): Promise<this>;
140
+ }
141
+ export declare class CourseArchiveDecisionCollection extends SmrtCollection<CourseArchiveDecision> {
142
+ static readonly _itemClass: typeof CourseArchiveDecision;
143
+ }
144
+ /** Audit record left when an unreferenced draft is discarded. */
145
+ export declare class CourseDiscardTombstone extends SmrtObject {
146
+ tenantId: string;
147
+ courseId: string;
148
+ title: string;
149
+ headRevisionId: string;
150
+ revisionCount: number;
151
+ reason: string;
152
+ actorUserId: string;
153
+ delegatingGuardianUserId: string;
154
+ delegationId: string;
155
+ requestKey: string;
156
+ recordedAt: Date;
157
+ constructor(options?: Record<string, unknown>);
158
+ delete(): Promise<void>;
159
+ save(options?: SmrtSaveOptions): Promise<this>;
160
+ }
161
+ export declare class CourseDiscardTombstoneCollection extends SmrtCollection<CourseDiscardTombstone> {
162
+ static readonly _itemClass: typeof CourseDiscardTombstone;
163
+ }
164
+ /**
165
+ * Append-only record of which release an enrollment follows. Enrollment keeps
166
+ * its immutable course id (the release Course row it was assigned); the latest
167
+ * pin by sequence is the enrollment's current release.
168
+ */
169
+ export declare class EnrollmentReleasePin extends SmrtObject {
170
+ tenantId: string;
171
+ enrollmentId: string;
172
+ learnerId: string;
173
+ /** Authored course identity. */
174
+ courseId: string;
175
+ releaseId: string;
176
+ previousReleaseId: string | null;
177
+ kind: string;
178
+ sequence: number;
179
+ /** Empty for automatic moves, which have no actor. */
180
+ actorUserId: string;
181
+ delegatingGuardianUserId: string;
182
+ delegationId: string;
183
+ /** Automatic moves: the delegation id recorded on the opt-in followed; empty otherwise. */
184
+ optInDelegationId: string;
185
+ /** Host assignment-setting value relied on; automatic moves copy the opt-in's. */
186
+ policyBasis: string;
187
+ /** Scope of the opt-in an automatic move followed ('course' | 'enrollment'); empty otherwise. */
188
+ optInScope: string;
189
+ requestKey: string;
190
+ recordedAt: Date;
191
+ constructor(options?: Record<string, unknown>);
192
+ delete(): Promise<void>;
193
+ save(options?: SmrtSaveOptions): Promise<this>;
194
+ }
195
+ export declare class EnrollmentReleasePinCollection extends SmrtCollection<EnrollmentReleasePin> {
196
+ static readonly _itemClass: typeof EnrollmentReleasePin;
197
+ }
198
+ /** Recorded opt-in/out of auto-upgrade at course or enrollment scope. */
199
+ export declare class CourseUpgradeChoice extends SmrtObject {
200
+ tenantId: string;
201
+ courseId: string;
202
+ /** Empty for a course-level choice. */
203
+ enrollmentId: string;
204
+ enabled: boolean;
205
+ sequence: number;
206
+ actorUserId: string;
207
+ delegatingGuardianUserId: string;
208
+ delegationId: string;
209
+ /** Host assignment-setting value relied on for this choice. */
210
+ policyBasis: string;
211
+ requestKey: string;
212
+ recordedAt: Date;
213
+ constructor(options?: Record<string, unknown>);
214
+ delete(): Promise<void>;
215
+ save(options?: SmrtSaveOptions): Promise<this>;
216
+ }
217
+ export declare class CourseUpgradeChoiceCollection extends SmrtCollection<CourseUpgradeChoice> {
218
+ static readonly _itemClass: typeof CourseUpgradeChoice;
219
+ }
220
+ /**
221
+ * Append-only record of an automatic upgrade that was not performed because the
222
+ * host denied the per-learner assignment decision. The enrollment stays pinned.
223
+ */
224
+ export declare class EnrollmentAutoUpgradeSkip extends SmrtObject {
225
+ tenantId: string;
226
+ enrollmentId: string;
227
+ learnerId: string;
228
+ courseId: string;
229
+ /** The release the enrollment was not moved to. */
230
+ releaseId: string;
231
+ /** 'course' or 'enrollment': the scope of the opt-in that was followed. */
232
+ optInScope: string;
233
+ optInActorUserId: string;
234
+ optInDelegatingGuardianUserId: string;
235
+ optInDelegationId: string;
236
+ policyBasis: string;
237
+ /** The authorizer's bounded reason, else 'not-authorized'. Never a thrown message. */
238
+ reason: string;
239
+ /** The authorizer's short code (`[a-z0-9._-]`, up to 64); empty when none. */
240
+ code: string;
241
+ recordedAt: Date;
242
+ constructor(options?: Record<string, unknown>);
243
+ delete(): Promise<void>;
244
+ save(options?: SmrtSaveOptions): Promise<this>;
245
+ }
246
+ export declare class EnrollmentAutoUpgradeSkipCollection extends SmrtCollection<EnrollmentAutoUpgradeSkip> {
247
+ static readonly _itemClass: typeof EnrollmentAutoUpgradeSkip;
248
+ }
249
+ /**
250
+ * Append-only audit of a delegated-agent assignment: the agent that created the
251
+ * enrollment, the guardian it acted for and the host's delegation id. Written
252
+ * only for delegated enrollments, in the enrollment's own transaction. It is
253
+ * deliberately separate from `Enrollment`, whose released table is not altered.
254
+ */
255
+ export declare class EnrollmentAssignmentRecord extends SmrtObject {
256
+ tenantId: string;
257
+ enrollmentId: string;
258
+ learnerId: string;
259
+ actorUserId: string;
260
+ delegatingGuardianUserId: string;
261
+ delegationId: string;
262
+ recordedAt: Date;
263
+ constructor(options?: Record<string, unknown>);
264
+ delete(): Promise<void>;
265
+ save(options?: SmrtSaveOptions): Promise<this>;
266
+ }
267
+ export declare class EnrollmentAssignmentRecordCollection extends SmrtCollection<EnrollmentAssignmentRecord> {
268
+ static readonly _itemClass: typeof EnrollmentAssignmentRecord;
269
+ }
270
+ /**
271
+ * Append-only audit of a delegated-agent curriculum creation: the agent, the
272
+ * guardian it acted for and the host's delegation id. Written only for delegated
273
+ * `createCurriculum` calls, in the curriculum's own transaction; `Curriculum`
274
+ * itself is not altered.
275
+ */
276
+ export declare class CurriculumCreationRecord extends SmrtObject {
277
+ tenantId: string;
278
+ curriculumId: string;
279
+ learnerId: string;
280
+ actorUserId: string;
281
+ delegatingGuardianUserId: string;
282
+ delegationId: string;
283
+ recordedAt: Date;
284
+ constructor(options?: Record<string, unknown>);
285
+ delete(): Promise<void>;
286
+ save(options?: SmrtSaveOptions): Promise<this>;
287
+ }
288
+ export declare class CurriculumCreationRecordCollection extends SmrtCollection<CurriculumCreationRecord> {
289
+ static readonly _itemClass: typeof CurriculumCreationRecord;
290
+ }
291
+ //# sourceMappingURL=course-authoring-models.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"course-authoring-models.d.ts","sourceRoot":"","sources":["../src/course-authoring-models.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,cAAc,EACd,UAAU,EACV,KAAK,eAAe,EAErB,MAAM,0BAA0B,CAAC;AAElC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AA4DtD,uFAAuF;AACvF,qBAMa,cAAe,SAAQ,UAAU;IAChC,QAAQ,SAAM;IACgB,QAAQ,SAAM;IACN,gBAAgB,EAC9D,MAAM,GACN,IAAI,CAAQ;IAChB,QAAQ,SAAK;IACb,YAAY,SAAM;IAClB,wBAAwB,SAAM;IAC9B,YAAY,SAAM;IAClB,UAAU,SAAc;IACC,mBAAmB,SAAQ;IACpD,KAAK,SAAM;IACc,OAAO,SAAM;IACtC,OAAO,SAAM;IACb,KAAK,SAAM;IACX,QAAQ,SAAK;IACb,QAAQ,SAAK;IACY,cAAc,SAAQ;IACtB,YAAY,SAAQ;IAC7C,WAAW,EAAE,iBAAiB,CAAc;IAC5C,UAAU,SAAM;IAChB,aAAa,SAAM;IACnB,aAAa,SAAM;IACnB,UAAU,OAAc;gBACZ,OAAO,GAAE,MAAM,CAAC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AAW,SAAM;IACjB,wBAAwB,SAAM;IAC9B,YAAY,SAAM;IAClB,UAAU,OAAc;gBACZ,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM;IAIlC,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAGvB,IAAI,CAAC,OAAO,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;CAoB9D;AACD,qBAAa,kCAAmC,SAAQ,cAAc,CAAC,wBAAwB,CAAC;IAC9F,MAAM,CAAC,QAAQ,CAAC,UAAU,kCAA4B;CACvD"}
@@ -0,0 +1,244 @@
1
+ import type { DatabaseInterface } from '@happyvertical/sql';
2
+ import { type AutoUpgradeSkipView, type CourseAuthoringAction, type CourseAuthoringActor, type CourseAuthoringAuthorizer, type CourseAuthoringOperation, type CourseDelegationVerifier, type CourseDraftInput, type CourseHeadView, type CourseLessonRevisionView, type CourseLifecycleState, type CourseMaterialCopyPort, type CoursePage, type CoursePageRequest, type CourseReferenceGuard, type CourseReleaseView, type CourseRevisionView, type CourseStateView, type CourseSummaryView, type CourseUpgradeChoiceView, type EnrollmentPinView, type EnrollmentReleaseView, type ReleaseReviewGate, type SetAutoUpgradeResult } from './course-authoring-contracts.js';
3
+ import { type CourseRevision, type LessonRevision } from './course-authoring-models.js';
4
+ type Row = Record<string, unknown>;
5
+ type Tx = DatabaseInterface;
6
+ /**
7
+ * Normalizes an authorizer answer. Only `allowed === true` allows. Reason and
8
+ * code are host-chosen labels: strip control characters, bound them and drop
9
+ * anything invalid, so a skip row can never carry free-form or unbounded text.
10
+ */
11
+ declare function readDecision(result: unknown): {
12
+ allowed: boolean;
13
+ reason: string;
14
+ code: string;
15
+ /** Raw, unvalidated; only the assign flows read it (see `resolvePolicyBasis`). */
16
+ policyBasis?: unknown;
17
+ };
18
+ export interface CourseAuthoringServiceOptions {
19
+ /** Supplied by the review feature; without it release always fails closed. */
20
+ releaseReviewGate?: ReleaseReviewGate;
21
+ /** Reports review/variant rows that must block discarding a draft. */
22
+ referenceGuard?: CourseReferenceGuard;
23
+ /** Copies uploaded originals to education-owned assets. */
24
+ materialCopy?: CourseMaterialCopyPort;
25
+ /**
26
+ * Required for any delegated (agent) request: without it delegation fields
27
+ * are refused. Runs on the transaction executor before the authorizer.
28
+ */
29
+ verifyDelegation?: CourseDelegationVerifier;
30
+ }
31
+ /**
32
+ * Actor-bound authoring of revisioned courses. All writes are one transaction;
33
+ * every authorizer call receives that transaction's executor.
34
+ */
35
+ export declare class CourseAuthoringService {
36
+ private readonly db;
37
+ private readonly authorizer;
38
+ private readonly options;
39
+ constructor(db: DatabaseInterface, authorizer: CourseAuthoringAuthorizer, options?: CourseAuthoringServiceOptions);
40
+ protected run<T>(operation: (tx: Tx) => Promise<T>): Promise<T>;
41
+ protected authorize(tx: Tx, actor: CourseAuthoringActor, action: CourseAuthoringAction, operation: CourseAuthoringOperation, extra?: {
42
+ courseId?: string;
43
+ enrollmentId?: string;
44
+ learnerId?: string;
45
+ releaseId?: string;
46
+ releaseCourseId?: string;
47
+ }): Promise<ReturnType<typeof readDecision>>;
48
+ /**
49
+ * Fail closed: no port, a denial or a throw all mean the delegation is not
50
+ * verified. The decision carries the verifier's sanitized `{reason, code}` only
51
+ * for an object refusal; a boolean, a throw or a missing port is generic.
52
+ */
53
+ private delegationDecision;
54
+ private delegationVerified;
55
+ protected identityRow(tx: Tx, tenantId: string, courseId: string): Promise<Row>;
56
+ protected state(tx: Tx, tenantId: string, courseId: string): Promise<CourseLifecycleState>;
57
+ private archiveDecisions;
58
+ protected lockHead(tx: Tx, tenantId: string, courseId: string): Promise<void>;
59
+ protected writableDraft(tx: Tx, tenantId: string, courseId: string): Promise<void>;
60
+ /** Creates the stable course identity, its first (empty) revision and draft head. */
61
+ createCourse(request: CourseAuthoringActor & {
62
+ requestKey: string;
63
+ title: string;
64
+ summary?: string;
65
+ subject?: string;
66
+ theme?: string;
67
+ levelMin?: number;
68
+ levelMax?: number;
69
+ objectives?: string[];
70
+ }): Promise<CourseHeadView>;
71
+ protected headView(tx: Tx, tenantId: string, courseId: string): Promise<CourseHeadView>;
72
+ private appendRevision;
73
+ /**
74
+ * Appends a revision and moves the draft head by expected-head compare and
75
+ * swap. A retried request key replays its original result; the same key with a
76
+ * different payload is a typed conflict.
77
+ */
78
+ saveDraft(request: CourseAuthoringActor & {
79
+ courseId: string;
80
+ expectedHeadRevisionId: string;
81
+ requestKey: string;
82
+ draft: CourseDraftInput;
83
+ }): Promise<CourseHeadView & {
84
+ revisionId: string;
85
+ }>;
86
+ /** The save path on a caller-supplied transaction, so composed writes share CAS and authz. */
87
+ protected saveDraftIn(tx: Tx, request: CourseAuthoringActor & {
88
+ courseId: string;
89
+ expectedHeadRevisionId: string;
90
+ requestKey: string;
91
+ draft: CourseDraftInput;
92
+ }): Promise<CourseHeadView & {
93
+ revisionId: string;
94
+ }>;
95
+ /** Extension point run inside the save transaction after the head moved. */
96
+ protected onDraftRevisionAppended(_tx: Tx, _actor: CourseAuthoringActor, _revision: {
97
+ courseId: string;
98
+ revisionId: string;
99
+ }): Promise<void>;
100
+ private revisionLessonIds;
101
+ /**
102
+ * Restricted own licences recorded anywhere in the course history, indexed by
103
+ * lessonKey and by normalized body / title-and-body digest.
104
+ */
105
+ private ownLicenceHistory;
106
+ /** Assets this course already owns through earlier lesson revisions. */
107
+ private knownMaterials;
108
+ private resolveMaterial;
109
+ protected lessonView(row: LessonRevision | Row): CourseLessonRevisionView;
110
+ /** Lesson question refs must name existing immutable revisions of this tenant. */
111
+ private requireQuestionRevisions;
112
+ protected revisionView(tx: Tx, tenantId: string, revision: CourseRevision): Promise<CourseRevisionView>;
113
+ /** Reads a draft revision (the head unless `revisionId` is given), answer keys included. */
114
+ readDraft(request: CourseAuthoringActor & {
115
+ courseId: string;
116
+ revisionId?: string;
117
+ }): Promise<{
118
+ head: CourseHeadView;
119
+ revision: CourseRevisionView;
120
+ }>;
121
+ getCourse(request: CourseAuthoringActor & {
122
+ courseId: string;
123
+ }): Promise<CourseStateView>;
124
+ private courseState;
125
+ /**
126
+ * Authored courses of the tenant, oldest first (created time, then id), with
127
+ * state, draft head, latest release and archive state. Discarded courses are
128
+ * excluded unless `includeDiscarded` is true. Needs `read-draft`.
129
+ */
130
+ listCourses(request: CourseAuthoringActor & CoursePageRequest & {
131
+ includeDiscarded?: boolean;
132
+ }): Promise<CoursePage<CourseSummaryView>>;
133
+ private courseSummary;
134
+ private choiceView;
135
+ /**
136
+ * Recorded auto-upgrade opt-in/out history of a course, in sequence order:
137
+ * every row (course and enrollment level), or with `enrollmentId` that
138
+ * enrollment's own rows plus the choice that currently governs it.
139
+ * Needs `read-draft` (authoring view); a foreign enrollment is a denial.
140
+ */
141
+ listUpgradeChoices(request: CourseAuthoringActor & CoursePageRequest & {
142
+ courseId: string;
143
+ enrollmentId?: string;
144
+ }): Promise<CoursePage<CourseUpgradeChoiceView> & {
145
+ governing: CourseUpgradeChoiceView | null;
146
+ }>;
147
+ /**
148
+ * Automatic upgrades that were not performed, oldest first, for a course
149
+ * and/or an enrollment (at least one is required). Needs `read-draft`.
150
+ */
151
+ listAutoUpgradeSkips(request: CourseAuthoringActor & CoursePageRequest & {
152
+ courseId?: string;
153
+ enrollmentId?: string;
154
+ }): Promise<CoursePage<AutoUpgradeSkipView>>;
155
+ /**
156
+ * Freezes one revision for assignment. Requires a current review of that exact
157
+ * revision from the injected gate; materializes immutable Course, section and
158
+ * Lesson rows for this release only.
159
+ */
160
+ release(request: CourseAuthoringActor & {
161
+ courseId: string;
162
+ revisionId: string;
163
+ requestKey: string;
164
+ }): Promise<CourseReleaseView>;
165
+ private materialize;
166
+ private releaseView;
167
+ /** Reversible; never touches enrollments, progress, submissions, grades or notes. */
168
+ archive(request: CourseAuthoringActor & {
169
+ courseId: string;
170
+ requestKey: string;
171
+ }): Promise<CourseStateView>;
172
+ unarchive(request: CourseAuthoringActor & {
173
+ courseId: string;
174
+ requestKey: string;
175
+ }): Promise<CourseStateView>;
176
+ private setArchived;
177
+ /**
178
+ * Discards a draft nothing references. History stays append-only: a tombstone
179
+ * ends the draft, and erasing its rows belongs to a retention operation.
180
+ */
181
+ discardDraft(request: CourseAuthoringActor & {
182
+ courseId: string;
183
+ requestKey: string;
184
+ reason?: string;
185
+ }): Promise<CourseStateView>;
186
+ private enrollmentRow;
187
+ private pins;
188
+ private releaseRow;
189
+ /** The opt-in/out row that governs an enrollment: its own, else the course's. */
190
+ private governingChoice;
191
+ private autoUpgradeEnabled;
192
+ private pinView;
193
+ private lockEnrollment;
194
+ private appendPin;
195
+ /**
196
+ * Records which release an existing enrollment follows. The enrollment must
197
+ * already have been created on that release's materialized Course row.
198
+ */
199
+ pinEnrollment(request: CourseAuthoringActor & {
200
+ enrollmentId: string;
201
+ releaseId: string;
202
+ requestKey: string;
203
+ /** Optional when the assign authorizer returns the basis. */
204
+ policyBasis?: string;
205
+ }): Promise<EnrollmentPinView>;
206
+ /** Explicit move of a pinned enrollment to a newer release of the same course. */
207
+ upgradeEnrollment(request: CourseAuthoringActor & {
208
+ enrollmentId: string;
209
+ releaseId: string;
210
+ requestKey: string;
211
+ /** Optional when the assign authorizer returns the basis. */
212
+ policyBasis?: string;
213
+ }): Promise<EnrollmentPinView>;
214
+ private movePin;
215
+ /**
216
+ * Records an opt-in or opt-out of auto-upgrade for a course (all its pinned
217
+ * enrollments) or one enrollment. It governs future releases only.
218
+ */
219
+ setAutoUpgrade(request: CourseAuthoringActor & {
220
+ courseId: string;
221
+ enrollmentId?: string;
222
+ enabled: boolean;
223
+ requestKey: string;
224
+ /** Optional when the assign authorizer returns the basis. */
225
+ policyBasis?: string;
226
+ }): Promise<SetAutoUpgradeResult>;
227
+ /**
228
+ * Re-evaluates, per enrollment, the recorded opt-in actor's current authority
229
+ * (and their delegating guardian's) for the `assign` action. Any denial or
230
+ * failure means "do not move"; it never blocks the release itself.
231
+ */
232
+ private authorizeAutoUpgrade;
233
+ /** Moves opted-in enrollments to a new release; each move is recorded. */
234
+ private autoUpgrade;
235
+ /**
236
+ * The enrollment's current release plus the lessons that apply to it. Started
237
+ * lessons stay on the immutable row they were started on after any move.
238
+ */
239
+ getEnrollmentRelease(request: CourseAuthoringActor & {
240
+ enrollmentId: string;
241
+ }): Promise<EnrollmentReleaseView>;
242
+ }
243
+ export {};
244
+ //# sourceMappingURL=course-authoring-service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"course-authoring-service.d.ts","sourceRoot":"","sources":["../src/course-authoring-service.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAW5D,OAAO,EACL,KAAK,mBAAmB,EAIxB,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EAEzB,KAAK,yBAAyB,EAC9B,KAAK,wBAAwB,EAG7B,KAAK,wBAAwB,EAG7B,KAAK,gBAAgB,EACrB,KAAK,cAAc,EAEnB,KAAK,wBAAwB,EAE7B,KAAK,oBAAoB,EAEzB,KAAK,sBAAsB,EAG3B,KAAK,UAAU,EACf,KAAK,iBAAiB,EAGtB,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EAGtB,KAAK,kBAAkB,EAEvB,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,uBAAuB,EAI5B,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,EAE1B,KAAK,iBAAiB,EAGtB,KAAK,oBAAoB,EAC1B,MAAM,iCAAiC,CAAC;AAQzC,OAAO,EAML,KAAK,cAAc,EAOnB,KAAK,cAAc,EAGpB,MAAM,8BAA8B,CAAC;AAuFtC,KAAK,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACnC,KAAK,EAAE,GAAG,iBAAiB,CAAC;AAO5B;;;;GAIG;AACH,iBAAS,YAAY,CAAC,MAAM,EAAE,OAAO,GAAG;IACtC,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,kFAAkF;IAClF,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YAOd,SAAS;IAuCvB;;;OAGG;IACG,aAAa,CACjB,OAAO,EAAE,oBAAoB,GAAG;QAC9B,YAAY,EAAE,MAAM,CAAC;QACrB,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,EAAE,MAAM,CAAC;QACnB,6DAA6D;QAC7D,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,GACA,OAAO,CAAC,iBAAiB,CAAC;IAI7B,kFAAkF;IAC5E,iBAAiB,CACrB,OAAO,EAAE,oBAAoB,GAAG;QAC9B,YAAY,EAAE,MAAM,CAAC;QACrB,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,EAAE,MAAM,CAAC;QACnB,6DAA6D;QAC7D,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,GACA,OAAO,CAAC,iBAAiB,CAAC;YAIf,OAAO;IA6GrB;;;OAGG;IACG,cAAc,CAClB,OAAO,EAAE,oBAAoB,GAAG;QAC9B,QAAQ,EAAE,MAAM,CAAC;QACjB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,OAAO,EAAE,OAAO,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;QACnB,6DAA6D;QAC7D,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,GACA,OAAO,CAAC,oBAAoB,CAAC;IA+EhC;;;;OAIG;YACW,oBAAoB;IA6FlC,0EAA0E;YAC5D,WAAW;IA2EzB;;;OAGG;IACG,oBAAoB,CACxB,OAAO,EAAE,oBAAoB,GAAG;QAAE,YAAY,EAAE,MAAM,CAAA;KAAE,GACvD,OAAO,CAAC,qBAAqB,CAAC;CAoClC"}
@@ -0,0 +1,26 @@
1
+ /** Longest accepted host delegation id and delegating-guardian user id. */
2
+ export declare const MAX_DELEGATION_FIELD_LENGTH = 200;
3
+ /** A validated delegated-agent claim: both members, never one without the other. */
4
+ export interface CourseDelegation {
5
+ delegatingGuardianUserId: string;
6
+ delegationId: string;
7
+ }
8
+ type DelegationClaim = {
9
+ actorUserId?: unknown;
10
+ delegatingGuardianUserId?: unknown;
11
+ delegationId?: unknown;
12
+ };
13
+ /**
14
+ * Reads and validates the delegation members of a trusted actor. The delegation
15
+ * id and delegating guardian are validated as a unit, and the guardian can never
16
+ * be the acting agent. Returns null for an ordinary (non-delegated) actor.
17
+ * Passing validation grants nothing: the host authorizer and the guardian's live
18
+ * membership/relationship still decide.
19
+ */
20
+ export declare function readDelegation(claim: DelegationClaim): CourseDelegation | null;
21
+ /** Delegation members to spread into an actor or authorizer request (empty if none). */
22
+ export declare function delegationActorFields(claim: DelegationClaim): Partial<CourseDelegation>;
23
+ /** Delegation columns for a decision record; empty strings when not delegated. */
24
+ export declare function delegationRecordFields(claim: DelegationClaim): CourseDelegation;
25
+ export {};
26
+ //# sourceMappingURL=course-delegation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"course-delegation.d.ts","sourceRoot":"","sources":["../src/course-delegation.ts"],"names":[],"mappings":"AAKA,2EAA2E;AAC3E,eAAO,MAAM,2BAA2B,MAAM,CAAC;AAE/C,oFAAoF;AACpF,MAAM,WAAW,gBAAgB;IAC/B,wBAAwB,EAAE,MAAM,CAAC;IACjC,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,KAAK,eAAe,GAAG;IACrB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,CAAC;AAmBF;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,eAAe,GACrB,gBAAgB,GAAG,IAAI,CAgBzB;AAED,wFAAwF;AACxF,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,eAAe,GACrB,OAAO,CAAC,gBAAgB,CAAC,CAE3B;AAED,kFAAkF;AAClF,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,eAAe,GACrB,gBAAgB,CAIlB"}