@contractspec/module.learning-journey 1.57.0 → 1.58.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.
Files changed (140) hide show
  1. package/dist/browser/contracts/index.js +578 -0
  2. package/dist/browser/contracts/models.js +193 -0
  3. package/dist/browser/contracts/onboarding.js +417 -0
  4. package/dist/browser/contracts/operations.js +326 -0
  5. package/dist/browser/contracts/shared.js +5 -0
  6. package/dist/browser/docs/index.js +124 -0
  7. package/dist/browser/docs/learning-journey.docblock.js +124 -0
  8. package/dist/browser/engines/index.js +526 -0
  9. package/dist/browser/engines/srs.js +198 -0
  10. package/dist/browser/engines/streak.js +159 -0
  11. package/dist/browser/engines/xp.js +171 -0
  12. package/dist/browser/entities/ai.js +343 -0
  13. package/dist/browser/entities/course.js +276 -0
  14. package/dist/browser/entities/flashcard.js +222 -0
  15. package/dist/browser/entities/gamification.js +340 -0
  16. package/dist/browser/entities/index.js +2136 -0
  17. package/dist/browser/entities/learner.js +329 -0
  18. package/dist/browser/entities/onboarding.js +301 -0
  19. package/dist/browser/entities/quiz.js +304 -0
  20. package/dist/browser/events.js +423 -0
  21. package/dist/browser/index.js +3833 -0
  22. package/dist/browser/learning-journey.capability.js +40 -0
  23. package/dist/browser/learning-journey.feature.js +56 -0
  24. package/dist/browser/track-spec.js +0 -0
  25. package/dist/contracts/index.d.ts +5 -5
  26. package/dist/contracts/index.d.ts.map +1 -0
  27. package/dist/contracts/index.js +578 -5
  28. package/dist/contracts/models.d.ts +426 -431
  29. package/dist/contracts/models.d.ts.map +1 -1
  30. package/dist/contracts/models.js +178 -372
  31. package/dist/contracts/onboarding.d.ts +621 -627
  32. package/dist/contracts/onboarding.d.ts.map +1 -1
  33. package/dist/contracts/onboarding.js +404 -388
  34. package/dist/contracts/operations.d.ts +243 -249
  35. package/dist/contracts/operations.d.ts.map +1 -1
  36. package/dist/contracts/operations.js +324 -148
  37. package/dist/contracts/shared.d.ts +1 -4
  38. package/dist/contracts/shared.d.ts.map +1 -1
  39. package/dist/contracts/shared.js +6 -6
  40. package/dist/docs/index.d.ts +2 -1
  41. package/dist/docs/index.d.ts.map +1 -0
  42. package/dist/docs/index.js +125 -1
  43. package/dist/docs/learning-journey.docblock.d.ts +2 -1
  44. package/dist/docs/learning-journey.docblock.d.ts.map +1 -0
  45. package/dist/docs/learning-journey.docblock.js +47 -58
  46. package/dist/engines/index.d.ts +4 -4
  47. package/dist/engines/index.d.ts.map +1 -0
  48. package/dist/engines/index.js +526 -4
  49. package/dist/engines/srs.d.ts +89 -92
  50. package/dist/engines/srs.d.ts.map +1 -1
  51. package/dist/engines/srs.js +197 -217
  52. package/dist/engines/streak.d.ts +84 -87
  53. package/dist/engines/streak.d.ts.map +1 -1
  54. package/dist/engines/streak.js +158 -192
  55. package/dist/engines/xp.d.ts +80 -83
  56. package/dist/engines/xp.d.ts.map +1 -1
  57. package/dist/engines/xp.js +170 -211
  58. package/dist/entities/ai.d.ts +199 -204
  59. package/dist/entities/ai.d.ts.map +1 -1
  60. package/dist/entities/ai.js +336 -368
  61. package/dist/entities/course.d.ts +149 -154
  62. package/dist/entities/course.d.ts.map +1 -1
  63. package/dist/entities/course.js +267 -306
  64. package/dist/entities/flashcard.d.ts +144 -149
  65. package/dist/entities/flashcard.d.ts.map +1 -1
  66. package/dist/entities/flashcard.js +217 -243
  67. package/dist/entities/gamification.d.ts +197 -202
  68. package/dist/entities/gamification.d.ts.map +1 -1
  69. package/dist/entities/gamification.js +331 -382
  70. package/dist/entities/index.d.ts +613 -618
  71. package/dist/entities/index.d.ts.map +1 -1
  72. package/dist/entities/index.js +2135 -43
  73. package/dist/entities/learner.d.ts +191 -196
  74. package/dist/entities/learner.d.ts.map +1 -1
  75. package/dist/entities/learner.js +322 -357
  76. package/dist/entities/onboarding.d.ts +164 -169
  77. package/dist/entities/onboarding.d.ts.map +1 -1
  78. package/dist/entities/onboarding.js +296 -301
  79. package/dist/entities/quiz.d.ts +184 -189
  80. package/dist/entities/quiz.d.ts.map +1 -1
  81. package/dist/entities/quiz.js +296 -361
  82. package/dist/events.d.ts +608 -614
  83. package/dist/events.d.ts.map +1 -1
  84. package/dist/events.js +421 -687
  85. package/dist/index.d.ts +8 -20
  86. package/dist/index.d.ts.map +1 -0
  87. package/dist/index.js +3834 -22
  88. package/dist/learning-journey.capability.d.ts +3 -8
  89. package/dist/learning-journey.capability.d.ts.map +1 -1
  90. package/dist/learning-journey.capability.js +41 -46
  91. package/dist/learning-journey.feature.d.ts +1 -6
  92. package/dist/learning-journey.feature.d.ts.map +1 -1
  93. package/dist/learning-journey.feature.js +55 -155
  94. package/dist/node/contracts/index.js +578 -0
  95. package/dist/node/contracts/models.js +193 -0
  96. package/dist/node/contracts/onboarding.js +417 -0
  97. package/dist/node/contracts/operations.js +326 -0
  98. package/dist/node/contracts/shared.js +5 -0
  99. package/dist/node/docs/index.js +124 -0
  100. package/dist/node/docs/learning-journey.docblock.js +124 -0
  101. package/dist/node/engines/index.js +526 -0
  102. package/dist/node/engines/srs.js +198 -0
  103. package/dist/node/engines/streak.js +159 -0
  104. package/dist/node/engines/xp.js +171 -0
  105. package/dist/node/entities/ai.js +343 -0
  106. package/dist/node/entities/course.js +276 -0
  107. package/dist/node/entities/flashcard.js +222 -0
  108. package/dist/node/entities/gamification.js +340 -0
  109. package/dist/node/entities/index.js +2136 -0
  110. package/dist/node/entities/learner.js +329 -0
  111. package/dist/node/entities/onboarding.js +301 -0
  112. package/dist/node/entities/quiz.js +304 -0
  113. package/dist/node/events.js +423 -0
  114. package/dist/node/index.js +3833 -0
  115. package/dist/node/learning-journey.capability.js +40 -0
  116. package/dist/node/learning-journey.feature.js +56 -0
  117. package/dist/node/track-spec.js +0 -0
  118. package/dist/track-spec.d.ts +115 -118
  119. package/dist/track-spec.d.ts.map +1 -1
  120. package/dist/track-spec.js +1 -0
  121. package/package.json +237 -60
  122. package/dist/contracts/models.js.map +0 -1
  123. package/dist/contracts/onboarding.js.map +0 -1
  124. package/dist/contracts/operations.js.map +0 -1
  125. package/dist/contracts/shared.js.map +0 -1
  126. package/dist/docs/learning-journey.docblock.js.map +0 -1
  127. package/dist/engines/srs.js.map +0 -1
  128. package/dist/engines/streak.js.map +0 -1
  129. package/dist/engines/xp.js.map +0 -1
  130. package/dist/entities/ai.js.map +0 -1
  131. package/dist/entities/course.js.map +0 -1
  132. package/dist/entities/flashcard.js.map +0 -1
  133. package/dist/entities/gamification.js.map +0 -1
  134. package/dist/entities/index.js.map +0 -1
  135. package/dist/entities/learner.js.map +0 -1
  136. package/dist/entities/onboarding.js.map +0 -1
  137. package/dist/entities/quiz.js.map +0 -1
  138. package/dist/events.js.map +0 -1
  139. package/dist/learning-journey.capability.js.map +0 -1
  140. package/dist/learning-journey.feature.js.map +0 -1
@@ -0,0 +1,3833 @@
1
+ // src/contracts/shared.ts
2
+ var LEARNING_JOURNEY_OWNERS = ["modules.learning-journey"];
3
+
4
+ // src/contracts/models.ts
5
+ import { ScalarTypeEnum, defineSchemaModel } from "@contractspec/lib.schema";
6
+ var CourseModel = defineSchemaModel({
7
+ name: "Course",
8
+ description: "A learning course",
9
+ fields: {
10
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
11
+ title: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
12
+ slug: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
13
+ description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
14
+ difficulty: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
15
+ status: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
16
+ estimatedDuration: {
17
+ type: ScalarTypeEnum.Int_unsecure(),
18
+ isOptional: true
19
+ },
20
+ thumbnailUrl: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
21
+ createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
22
+ }
23
+ });
24
+ var LearnerModel = defineSchemaModel({
25
+ name: "Learner",
26
+ description: "A learner profile",
27
+ fields: {
28
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
29
+ userId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
30
+ displayName: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
31
+ level: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
32
+ totalXp: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
33
+ currentStreak: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
34
+ longestStreak: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
35
+ createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
36
+ }
37
+ });
38
+ var EnrollmentModel = defineSchemaModel({
39
+ name: "Enrollment",
40
+ description: "A course enrollment",
41
+ fields: {
42
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
43
+ learnerId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
44
+ courseId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
45
+ status: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
46
+ progress: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
47
+ startedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
48
+ completedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true }
49
+ }
50
+ });
51
+ var ProgressModel = defineSchemaModel({
52
+ name: "LessonProgress",
53
+ description: "Lesson progress",
54
+ fields: {
55
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
56
+ learnerId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
57
+ lessonId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
58
+ status: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
59
+ progress: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
60
+ score: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
61
+ timeSpent: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
62
+ completedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true }
63
+ }
64
+ });
65
+ var DeckModel = defineSchemaModel({
66
+ name: "Deck",
67
+ description: "A flashcard deck",
68
+ fields: {
69
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
70
+ title: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
71
+ description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
72
+ cardCount: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
73
+ isPublic: { type: ScalarTypeEnum.Boolean(), isOptional: false },
74
+ createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
75
+ }
76
+ });
77
+ var CardModel = defineSchemaModel({
78
+ name: "Card",
79
+ description: "A flashcard",
80
+ fields: {
81
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
82
+ deckId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
83
+ front: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
84
+ back: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
85
+ hints: { type: ScalarTypeEnum.JSON(), isOptional: true },
86
+ isDue: { type: ScalarTypeEnum.Boolean(), isOptional: false },
87
+ nextReviewAt: { type: ScalarTypeEnum.DateTime(), isOptional: true }
88
+ }
89
+ });
90
+ var AchievementModel = defineSchemaModel({
91
+ name: "Achievement",
92
+ description: "An achievement",
93
+ fields: {
94
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
95
+ key: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
96
+ name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
97
+ description: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
98
+ icon: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
99
+ xpReward: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
100
+ unlockedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true }
101
+ }
102
+ });
103
+ var EnrollInCourseInput = defineSchemaModel({
104
+ name: "EnrollInCourseInput",
105
+ description: "Input for enrolling in a course",
106
+ fields: {
107
+ courseId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false }
108
+ }
109
+ });
110
+ var CompleteLessonInput = defineSchemaModel({
111
+ name: "CompleteLessonInput",
112
+ description: "Input for completing a lesson",
113
+ fields: {
114
+ lessonId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
115
+ score: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
116
+ timeSpent: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false }
117
+ }
118
+ });
119
+ var SubmitCardReviewInput = defineSchemaModel({
120
+ name: "SubmitCardReviewInput",
121
+ description: "Input for submitting a card review",
122
+ fields: {
123
+ cardId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
124
+ rating: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
125
+ responseTimeMs: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true }
126
+ }
127
+ });
128
+ var GetDueCardsInput = defineSchemaModel({
129
+ name: "GetDueCardsInput",
130
+ description: "Input for getting due cards",
131
+ fields: {
132
+ deckId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
133
+ limit: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true }
134
+ }
135
+ });
136
+ var GetDueCardsOutput = defineSchemaModel({
137
+ name: "GetDueCardsOutput",
138
+ description: "Output for getting due cards",
139
+ fields: {
140
+ cards: { type: CardModel, isArray: true, isOptional: false },
141
+ total: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false }
142
+ }
143
+ });
144
+ var GetLearnerDashboardInput = defineSchemaModel({
145
+ name: "GetLearnerDashboardInput",
146
+ description: "Input for getting learner dashboard",
147
+ fields: {
148
+ learnerId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
149
+ }
150
+ });
151
+ var LearnerDashboardModel = defineSchemaModel({
152
+ name: "LearnerDashboard",
153
+ description: "Learner dashboard data",
154
+ fields: {
155
+ learner: { type: LearnerModel, isOptional: false },
156
+ currentStreak: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
157
+ dailyXpGoal: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
158
+ dailyXpProgress: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
159
+ activeEnrollments: {
160
+ type: EnrollmentModel,
161
+ isArray: true,
162
+ isOptional: false
163
+ },
164
+ recentAchievements: {
165
+ type: AchievementModel,
166
+ isArray: true,
167
+ isOptional: false
168
+ },
169
+ dueCardCount: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false }
170
+ }
171
+ });
172
+ var SuccessOutput = defineSchemaModel({
173
+ name: "SuccessOutput",
174
+ description: "Generic success output",
175
+ fields: {
176
+ success: { type: ScalarTypeEnum.Boolean(), isOptional: false },
177
+ xpEarned: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true }
178
+ }
179
+ });
180
+
181
+ // src/contracts/operations.ts
182
+ import { defineCommand, defineQuery } from "@contractspec/lib.contracts";
183
+ var EnrollInCourseContract = defineCommand({
184
+ meta: {
185
+ key: "learning.enroll",
186
+ version: "1.0.0",
187
+ stability: "stable",
188
+ owners: [...LEARNING_JOURNEY_OWNERS],
189
+ tags: ["learning", "enrollment"],
190
+ description: "Enroll in a course.",
191
+ goal: "Start learning a new course.",
192
+ context: "Called when a learner wants to start a course."
193
+ },
194
+ io: {
195
+ input: EnrollInCourseInput,
196
+ output: EnrollmentModel,
197
+ errors: {
198
+ COURSE_NOT_FOUND: {
199
+ description: "Course does not exist",
200
+ http: 404,
201
+ gqlCode: "COURSE_NOT_FOUND",
202
+ when: "Course ID is invalid"
203
+ },
204
+ ALREADY_ENROLLED: {
205
+ description: "Already enrolled in course",
206
+ http: 409,
207
+ gqlCode: "ALREADY_ENROLLED",
208
+ when: "Learner is already enrolled"
209
+ }
210
+ }
211
+ },
212
+ policy: {
213
+ auth: "user"
214
+ }
215
+ });
216
+ var CompleteLessonContract = defineCommand({
217
+ meta: {
218
+ key: "learning.completeLesson",
219
+ version: "1.0.0",
220
+ stability: "stable",
221
+ owners: [...LEARNING_JOURNEY_OWNERS],
222
+ tags: ["learning", "progress"],
223
+ description: "Mark a lesson as completed.",
224
+ goal: "Record lesson completion and earn XP.",
225
+ context: "Called when a learner finishes a lesson."
226
+ },
227
+ io: {
228
+ input: CompleteLessonInput,
229
+ output: SuccessOutput,
230
+ errors: {
231
+ LESSON_NOT_FOUND: {
232
+ description: "Lesson does not exist",
233
+ http: 404,
234
+ gqlCode: "LESSON_NOT_FOUND",
235
+ when: "Lesson ID is invalid"
236
+ },
237
+ NOT_ENROLLED: {
238
+ description: "Not enrolled in course",
239
+ http: 403,
240
+ gqlCode: "NOT_ENROLLED",
241
+ when: "Learner is not enrolled in the course"
242
+ }
243
+ }
244
+ },
245
+ policy: {
246
+ auth: "user"
247
+ }
248
+ });
249
+ var SubmitCardReviewContract = defineCommand({
250
+ meta: {
251
+ key: "learning.submitCardReview",
252
+ version: "1.0.0",
253
+ stability: "stable",
254
+ owners: [...LEARNING_JOURNEY_OWNERS],
255
+ tags: ["learning", "flashcards"],
256
+ description: "Submit a flashcard review.",
257
+ goal: "Record review and update SRS schedule.",
258
+ context: "Called when reviewing flashcards."
259
+ },
260
+ io: {
261
+ input: SubmitCardReviewInput,
262
+ output: SuccessOutput,
263
+ errors: {
264
+ CARD_NOT_FOUND: {
265
+ description: "Card does not exist",
266
+ http: 404,
267
+ gqlCode: "CARD_NOT_FOUND",
268
+ when: "Card ID is invalid"
269
+ },
270
+ INVALID_RATING: {
271
+ description: "Invalid rating",
272
+ http: 400,
273
+ gqlCode: "INVALID_RATING",
274
+ when: "Rating must be AGAIN, HARD, GOOD, or EASY"
275
+ }
276
+ }
277
+ },
278
+ policy: {
279
+ auth: "user"
280
+ }
281
+ });
282
+ var GetDueCardsContract = defineQuery({
283
+ meta: {
284
+ key: "learning.getDueCards",
285
+ version: "1.0.0",
286
+ stability: "stable",
287
+ owners: [...LEARNING_JOURNEY_OWNERS],
288
+ tags: ["learning", "flashcards"],
289
+ description: "Get flashcards due for review.",
290
+ goal: "Get the next batch of cards to review.",
291
+ context: "Called when starting a review session."
292
+ },
293
+ io: {
294
+ input: GetDueCardsInput,
295
+ output: GetDueCardsOutput
296
+ },
297
+ policy: {
298
+ auth: "user"
299
+ }
300
+ });
301
+ var GetLearnerDashboardContract = defineQuery({
302
+ meta: {
303
+ key: "learning.getDashboard",
304
+ version: "1.0.0",
305
+ stability: "stable",
306
+ owners: [...LEARNING_JOURNEY_OWNERS],
307
+ tags: ["learning", "dashboard"],
308
+ description: "Get learner dashboard data.",
309
+ goal: "Display learner progress and stats.",
310
+ context: "Called when viewing the learning dashboard."
311
+ },
312
+ io: {
313
+ input: GetLearnerDashboardInput,
314
+ output: LearnerDashboardModel
315
+ },
316
+ policy: {
317
+ auth: "user"
318
+ }
319
+ });
320
+
321
+ // src/contracts/onboarding.ts
322
+ import { ScalarTypeEnum as ScalarTypeEnum2, defineSchemaModel as defineSchemaModel2 } from "@contractspec/lib.schema";
323
+ import { defineCommand as defineCommand2, defineQuery as defineQuery2 } from "@contractspec/lib.contracts";
324
+ var OnboardingStepConditionModel = defineSchemaModel2({
325
+ name: "OnboardingStepCondition",
326
+ description: "Structured completion condition for onboarding steps.",
327
+ fields: {
328
+ eventName: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
329
+ eventVersion: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
330
+ sourceModule: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
331
+ payloadFilter: { type: ScalarTypeEnum2.JSON(), isOptional: true }
332
+ }
333
+ });
334
+ var OnboardingStepModel = defineSchemaModel2({
335
+ name: "OnboardingStep",
336
+ description: "Declarative onboarding step definition.",
337
+ fields: {
338
+ id: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
339
+ trackId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
340
+ title: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
341
+ description: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
342
+ instructions: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
343
+ helpUrl: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
344
+ order: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: false },
345
+ completionEvent: {
346
+ type: ScalarTypeEnum2.String_unsecure(),
347
+ isOptional: false
348
+ },
349
+ completionCondition: {
350
+ type: OnboardingStepConditionModel,
351
+ isOptional: true
352
+ },
353
+ xpReward: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: true },
354
+ isRequired: { type: ScalarTypeEnum2.Boolean(), isOptional: true },
355
+ canSkip: { type: ScalarTypeEnum2.Boolean(), isOptional: true },
356
+ actionUrl: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
357
+ actionLabel: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
358
+ metadata: { type: ScalarTypeEnum2.JSON(), isOptional: true }
359
+ }
360
+ });
361
+ var OnboardingTrackModel = defineSchemaModel2({
362
+ name: "OnboardingTrack",
363
+ description: "Onboarding track metadata and steps.",
364
+ fields: {
365
+ id: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
366
+ productId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
367
+ name: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
368
+ description: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
369
+ targetUserSegment: {
370
+ type: ScalarTypeEnum2.String_unsecure(),
371
+ isOptional: true
372
+ },
373
+ targetRole: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
374
+ isActive: { type: ScalarTypeEnum2.Boolean(), isOptional: true },
375
+ isRequired: { type: ScalarTypeEnum2.Boolean(), isOptional: true },
376
+ canSkip: { type: ScalarTypeEnum2.Boolean(), isOptional: true },
377
+ totalXp: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: true },
378
+ completionXpBonus: {
379
+ type: ScalarTypeEnum2.Int_unsecure(),
380
+ isOptional: true
381
+ },
382
+ completionBadgeKey: {
383
+ type: ScalarTypeEnum2.String_unsecure(),
384
+ isOptional: true
385
+ },
386
+ streakHoursWindow: {
387
+ type: ScalarTypeEnum2.Int_unsecure(),
388
+ isOptional: true
389
+ },
390
+ streakBonusXp: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: true },
391
+ metadata: { type: ScalarTypeEnum2.JSON(), isOptional: true },
392
+ steps: { type: OnboardingStepModel, isArray: true, isOptional: false }
393
+ }
394
+ });
395
+ var OnboardingStepProgressModel = defineSchemaModel2({
396
+ name: "OnboardingStepProgress",
397
+ description: "Progress for a specific onboarding step.",
398
+ fields: {
399
+ stepId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
400
+ status: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
401
+ xpEarned: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: true },
402
+ triggeringEvent: {
403
+ type: ScalarTypeEnum2.String_unsecure(),
404
+ isOptional: true
405
+ },
406
+ eventPayload: { type: ScalarTypeEnum2.JSON(), isOptional: true },
407
+ completedAt: { type: ScalarTypeEnum2.DateTime(), isOptional: true }
408
+ }
409
+ });
410
+ var OnboardingProgressModel = defineSchemaModel2({
411
+ name: "OnboardingProgress",
412
+ description: "Aggregated progress for an onboarding track.",
413
+ fields: {
414
+ learnerId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
415
+ trackId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
416
+ progress: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: false },
417
+ isCompleted: { type: ScalarTypeEnum2.Boolean(), isOptional: false },
418
+ xpEarned: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: true },
419
+ startedAt: { type: ScalarTypeEnum2.DateTime(), isOptional: true },
420
+ completedAt: { type: ScalarTypeEnum2.DateTime(), isOptional: true },
421
+ lastActivityAt: { type: ScalarTypeEnum2.DateTime(), isOptional: true },
422
+ steps: {
423
+ type: OnboardingStepProgressModel,
424
+ isArray: true,
425
+ isOptional: true
426
+ }
427
+ }
428
+ });
429
+ var ListOnboardingTracksInput = defineSchemaModel2({
430
+ name: "ListOnboardingTracksInput",
431
+ description: "Filters for listing onboarding tracks.",
432
+ fields: {
433
+ learnerId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
434
+ productId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
435
+ trackIds: {
436
+ type: ScalarTypeEnum2.String_unsecure(),
437
+ isArray: true,
438
+ isOptional: true
439
+ },
440
+ includeProgress: {
441
+ type: ScalarTypeEnum2.Boolean(),
442
+ isOptional: true
443
+ }
444
+ }
445
+ });
446
+ var ListOnboardingTracksOutput = defineSchemaModel2({
447
+ name: "ListOnboardingTracksOutput",
448
+ description: "Available onboarding tracks with optional progress.",
449
+ fields: {
450
+ tracks: { type: OnboardingTrackModel, isArray: true, isOptional: false },
451
+ progress: {
452
+ type: OnboardingProgressModel,
453
+ isArray: true,
454
+ isOptional: true
455
+ }
456
+ }
457
+ });
458
+ var GetOnboardingProgressInput = defineSchemaModel2({
459
+ name: "GetOnboardingProgressInput",
460
+ description: "Input for fetching onboarding progress for a track.",
461
+ fields: {
462
+ trackId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
463
+ learnerId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true }
464
+ }
465
+ });
466
+ var RecordOnboardingEventInput = defineSchemaModel2({
467
+ name: "RecordOnboardingEventInput",
468
+ description: "Record a domain event to advance onboarding progress via completion conditions.",
469
+ fields: {
470
+ learnerId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
471
+ trackId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
472
+ eventName: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
473
+ eventVersion: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
474
+ eventPayload: { type: ScalarTypeEnum2.JSON(), isOptional: true },
475
+ occurredAt: { type: ScalarTypeEnum2.DateTime(), isOptional: true }
476
+ }
477
+ });
478
+ var ListOnboardingTracksContract = defineQuery2({
479
+ meta: {
480
+ key: "learning.onboarding.listTracks",
481
+ version: "1.0.0",
482
+ stability: "stable",
483
+ owners: [...LEARNING_JOURNEY_OWNERS],
484
+ tags: ["learning", "onboarding", "journey"],
485
+ description: "List onboarding tracks available to a learner or product.",
486
+ goal: "Expose track catalog for UI/API surfaces.",
487
+ context: "Called when showing onboarding/learning journey catalog."
488
+ },
489
+ io: {
490
+ input: ListOnboardingTracksInput,
491
+ output: ListOnboardingTracksOutput
492
+ },
493
+ policy: {
494
+ auth: "user"
495
+ }
496
+ });
497
+ var GetOnboardingProgressContract = defineQuery2({
498
+ meta: {
499
+ key: "learning.onboarding.getProgress",
500
+ version: "1.0.0",
501
+ stability: "stable",
502
+ owners: [...LEARNING_JOURNEY_OWNERS],
503
+ tags: ["learning", "onboarding", "journey"],
504
+ description: "Fetch onboarding progress for a specific track.",
505
+ goal: "Display learner progress and remaining steps.",
506
+ context: "Called when rendering a track detail or widget."
507
+ },
508
+ io: {
509
+ input: GetOnboardingProgressInput,
510
+ output: OnboardingProgressModel
511
+ },
512
+ policy: {
513
+ auth: "user"
514
+ }
515
+ });
516
+ var RecordOnboardingEventContract = defineCommand2({
517
+ meta: {
518
+ key: "learning.onboarding.recordEvent",
519
+ version: "1.0.0",
520
+ stability: "stable",
521
+ owners: [...LEARNING_JOURNEY_OWNERS],
522
+ tags: ["learning", "onboarding", "events"],
523
+ description: "Record a domain event to evaluate onboarding step completion conditions.",
524
+ goal: "Advance onboarding automatically from product events.",
525
+ context: "Called by event bus handlers when relevant product events fire (e.g., deal.created)."
526
+ },
527
+ io: {
528
+ input: RecordOnboardingEventInput,
529
+ output: SuccessOutput,
530
+ errors: {
531
+ TRACK_NOT_FOUND: {
532
+ description: "Track not found for event routing",
533
+ http: 404,
534
+ gqlCode: "TRACK_NOT_FOUND",
535
+ when: "Track ID or routing context is invalid"
536
+ },
537
+ STEP_NOT_FOUND: {
538
+ description: "Step not found for completion condition",
539
+ http: 404,
540
+ gqlCode: "STEP_NOT_FOUND",
541
+ when: "No step matches the incoming event"
542
+ }
543
+ }
544
+ },
545
+ policy: {
546
+ auth: "user"
547
+ }
548
+ });
549
+ // src/docs/learning-journey.docblock.ts
550
+ import { registerDocBlocks } from "@contractspec/lib.contracts/docs";
551
+ var learningJourneyDocBlocks = [
552
+ {
553
+ id: "docs.learning-journey.engine",
554
+ title: "Learning Journey Engine",
555
+ summary: "Tracks learners, tracks/modules/steps, progress, quizzes, streaks, XP, and AI coaching hooks for product-integrated onboarding.",
556
+ kind: "reference",
557
+ visibility: "public",
558
+ route: "/docs/learning-journey/engine",
559
+ tags: ["learning", "onboarding", "journey", "education"],
560
+ body: `## Capabilities
561
+
562
+ - **Entities**: Learner, Track, Module, Step, Progress, Quiz, Flashcard, AI Coach, Gamification (XP, streaks, badges).
563
+ - **Contracts**: enroll/resume/advance steps, complete quizzes, record streaks, assign XP, fetch progress dashboards, onboarding list/progress/recordEvent.
564
+ - **Engines**: spaced-repetition (SRS), streak calculator, XP progression.
565
+ - **Events**: learner.enrolled, step.completed, quiz.scored, streak.reset, xp.awarded, onboarding.started/completed/step_completed.
566
+
567
+ ## Completion conditions
568
+ - Event-based: name/version/source + payload filter
569
+ - Count-based: require N events (optional time window)
570
+ - Time-bounded: must complete within a window; steps can unlock by day/hour
571
+ - SRS mastery: complete when cards/skills hit mastery thresholds (with required counts)
572
+
573
+ ## Usage
574
+
575
+ 1) Compose schema
576
+ - Include \`learningJourneySchemaContribution\` (entities export) in composition.
577
+
578
+ 2) Register contracts/events
579
+ - Import from \`@contractspec/module.learning-journey\` into your spec registry.
580
+
581
+ 3) Bind to product actions
582
+ - Tie \`Step\` completion conditions to domain events (e.g., deal.created, agent.run.completed, drill.session.completed).
583
+ - Trigger notifications via Notification Center and audits on completion.
584
+
585
+ 4) Gamification
586
+ - Use \`XP\` and \`Streak\` engines to update learner stats; emit analytics for UI.
587
+
588
+ ## Example
589
+
590
+ ${"```"}ts
591
+ import { learningJourneyEntities } from '@contractspec/module.learning-journey';
592
+ import { StreakEngine } from '@contractspec/module.learning-journey/engines';
593
+
594
+ const streak = new StreakEngine({ graceDays: 1 });
595
+ const updated = streak.compute({ lastActiveAt: new Date(), today: new Date() });
596
+ ${"```"},
597
+
598
+ ## Guardrails
599
+
600
+ - Keep steps bound to real product events, not just button clicks.
601
+ - Avoid storing PII in content; keep org/user scoping for multi-tenant isolation.
602
+ - Emit analytics and audit logs for completions; respect \`prefers-reduced-motion\` in UIs consuming these specs.
603
+ - Track completion bonuses: \`completionXpBonus\`, \`completionBadgeKey\`, optional \`streakHoursWindow\` + \`streakBonusXp\`.
604
+ `
605
+ },
606
+ {
607
+ id: "docs.learning-journey.goal",
608
+ title: "Learning Journey — Goal",
609
+ summary: "Why the learning journey engine exists and the outcomes it targets.",
610
+ kind: "goal",
611
+ visibility: "public",
612
+ route: "/docs/learning-journey/goal",
613
+ tags: ["learning", "goal"],
614
+ body: `## Why it matters
615
+ - Provides a regenerable onboarding/education engine tied to product signals.
616
+ - Keeps tracks, steps, quizzes, and gamification consistent across surfaces.
617
+
618
+ ## Business/Product goal
619
+ - Drive activation and retention with measurable progress, SRS, and streaks.
620
+ - Allow product teams to adjust journeys safely via specs.
621
+
622
+ ## Success criteria
623
+ - Journey changes regenerate UI/API/events without drift.
624
+ - Analytics/audit hooks exist for completions and streaks.`
625
+ },
626
+ {
627
+ id: "docs.learning-journey.usage",
628
+ title: "Learning Journey — Usage",
629
+ summary: "How to compose, bind, and regenerate journeys safely.",
630
+ kind: "usage",
631
+ visibility: "public",
632
+ route: "/docs/learning-journey/usage",
633
+ tags: ["learning", "usage"],
634
+ body: `## Setup
635
+ 1) Include \`learningJourneyEntities\` in schema composition.
636
+ 2) Register contracts/events from \`@contractspec/module.learning-journey\`.
637
+ 3) Bind steps to real product events (e.g., deal.created, run.completed).
638
+
639
+ ## Extend & regenerate
640
+ 1) Update track/module/step definitions or quiz schemas in spec.
641
+ 2) Regenerate to sync UI/API/events; mark PII paths where needed.
642
+ 3) Use Feature Flags to trial new tracks or streak rules.
643
+
644
+ ## Guardrails
645
+ - Avoid hardcoded progression; keep engines declarative.
646
+ - Emit analytics/audit for completions; respect user locale/accessibility in presentations.
647
+ - Keep content free of PII; scope learners by org/tenant.`
648
+ },
649
+ {
650
+ id: "docs.learning-journey.constraints",
651
+ title: "Learning Journey — Constraints & Safety",
652
+ summary: "Internal guardrails for progression, telemetry, and regeneration semantics.",
653
+ kind: "reference",
654
+ visibility: "internal",
655
+ route: "/docs/learning-journey/constraints",
656
+ tags: ["learning", "constraints", "internal"],
657
+ body: `## Constraints
658
+ - Progression (tracks/modules/steps) and engines (SRS, streaks, XP) must stay declarative in spec.
659
+ - Events to emit: learner.enrolled, step.completed, quiz.scored, streak.reset, xp.awarded.
660
+ - Regeneration should not change scoring/streak rules without explicit spec change.
661
+
662
+ ## PII & Telemetry
663
+ - Mark PII (learner identifiers) and redact in presentations; keep telemetry aggregated when possible.
664
+ - Respect accessibility (prefers-reduced-motion) in UIs consuming these specs.
665
+
666
+ ## Verification
667
+ - Add fixtures for streak/XP rule changes and quiz scoring.
668
+ - Ensure Notifications/Audit wiring persists for completions; analytics emitted for progress.
669
+ - Use Feature Flags to trial new tracks or reward rules; default safe/off.`
670
+ }
671
+ ];
672
+ registerDocBlocks(learningJourneyDocBlocks);
673
+ // src/engines/srs.ts
674
+ var DEFAULT_SRS_CONFIG = {
675
+ learningSteps: [1, 10],
676
+ graduatingInterval: 1,
677
+ easyInterval: 4,
678
+ relearningSteps: [10],
679
+ minEaseFactor: 1.3,
680
+ maxInterval: 365,
681
+ intervalModifier: 1,
682
+ newIntervalModifier: 0.5,
683
+ hardIntervalModifier: 1.2,
684
+ easyBonus: 1.3
685
+ };
686
+
687
+ class SRSEngine {
688
+ config;
689
+ constructor(config = {}) {
690
+ this.config = { ...DEFAULT_SRS_CONFIG, ...config };
691
+ }
692
+ calculateNextReview(state, rating, now = new Date) {
693
+ if (!state.isGraduated && !state.isRelearning) {
694
+ return this.handleLearningCard(state, rating, now);
695
+ }
696
+ if (state.isRelearning) {
697
+ return this.handleRelearningCard(state, rating, now);
698
+ }
699
+ return this.handleReviewCard(state, rating, now);
700
+ }
701
+ getInitialState() {
702
+ return {
703
+ interval: 0,
704
+ easeFactor: 2.5,
705
+ repetitions: 0,
706
+ learningStep: 0,
707
+ isGraduated: false,
708
+ isRelearning: false,
709
+ lapses: 0
710
+ };
711
+ }
712
+ isDue(nextReviewAt, now = new Date) {
713
+ return nextReviewAt <= now;
714
+ }
715
+ getOverdueDays(nextReviewAt, now = new Date) {
716
+ const diff = now.getTime() - nextReviewAt.getTime();
717
+ return Math.floor(diff / (1000 * 60 * 60 * 24));
718
+ }
719
+ handleLearningCard(state, rating, now) {
720
+ const steps = this.config.learningSteps;
721
+ let newStep = state.learningStep;
722
+ let isGraduated = false;
723
+ let interval = 0;
724
+ let nextReviewAt;
725
+ switch (rating) {
726
+ case "AGAIN":
727
+ newStep = 0;
728
+ interval = steps[0] ?? 1;
729
+ nextReviewAt = this.addMinutes(now, interval);
730
+ break;
731
+ case "HARD":
732
+ interval = steps[newStep] ?? steps[0] ?? 1;
733
+ nextReviewAt = this.addMinutes(now, interval);
734
+ break;
735
+ case "GOOD":
736
+ newStep++;
737
+ if (newStep >= steps.length) {
738
+ isGraduated = true;
739
+ interval = this.config.graduatingInterval;
740
+ nextReviewAt = this.addDays(now, interval);
741
+ } else {
742
+ interval = steps[newStep] ?? 10;
743
+ nextReviewAt = this.addMinutes(now, interval);
744
+ }
745
+ break;
746
+ case "EASY":
747
+ isGraduated = true;
748
+ interval = this.config.easyInterval;
749
+ nextReviewAt = this.addDays(now, interval);
750
+ break;
751
+ }
752
+ return {
753
+ interval: isGraduated ? interval : 0,
754
+ easeFactor: state.easeFactor,
755
+ repetitions: isGraduated ? 1 : 0,
756
+ nextReviewAt,
757
+ learningStep: newStep,
758
+ isGraduated,
759
+ isRelearning: false,
760
+ lapses: state.lapses
761
+ };
762
+ }
763
+ handleRelearningCard(state, rating, now) {
764
+ const steps = this.config.relearningSteps;
765
+ let newStep = state.learningStep;
766
+ let isRelearning = true;
767
+ let interval = 0;
768
+ let nextReviewAt;
769
+ switch (rating) {
770
+ case "AGAIN":
771
+ newStep = 0;
772
+ interval = steps[0] ?? 10;
773
+ nextReviewAt = this.addMinutes(now, interval);
774
+ break;
775
+ case "HARD":
776
+ interval = steps[newStep] ?? steps[0] ?? 10;
777
+ nextReviewAt = this.addMinutes(now, interval);
778
+ break;
779
+ case "GOOD":
780
+ newStep++;
781
+ if (newStep >= steps.length) {
782
+ isRelearning = false;
783
+ interval = Math.max(1, Math.floor(state.interval * this.config.newIntervalModifier));
784
+ nextReviewAt = this.addDays(now, interval);
785
+ } else {
786
+ interval = steps[newStep] ?? 10;
787
+ nextReviewAt = this.addMinutes(now, interval);
788
+ }
789
+ break;
790
+ case "EASY":
791
+ isRelearning = false;
792
+ interval = Math.max(1, Math.floor(state.interval * this.config.newIntervalModifier * 1.5));
793
+ nextReviewAt = this.addDays(now, interval);
794
+ break;
795
+ }
796
+ return {
797
+ interval: isRelearning ? state.interval : interval,
798
+ easeFactor: state.easeFactor,
799
+ repetitions: isRelearning ? state.repetitions : state.repetitions + 1,
800
+ nextReviewAt,
801
+ learningStep: newStep,
802
+ isGraduated: true,
803
+ isRelearning,
804
+ lapses: state.lapses
805
+ };
806
+ }
807
+ handleReviewCard(state, rating, now) {
808
+ let newInterval;
809
+ let newEaseFactor = state.easeFactor;
810
+ let repetitions = state.repetitions;
811
+ let isRelearning = false;
812
+ let learningStep = 0;
813
+ let lapses = state.lapses;
814
+ switch (rating) {
815
+ case "AGAIN":
816
+ lapses++;
817
+ isRelearning = true;
818
+ learningStep = 0;
819
+ newEaseFactor = Math.max(this.config.minEaseFactor, newEaseFactor - 0.2);
820
+ newInterval = state.interval;
821
+ return {
822
+ interval: newInterval,
823
+ easeFactor: newEaseFactor,
824
+ repetitions,
825
+ nextReviewAt: this.addMinutes(now, this.config.relearningSteps[0] ?? 10),
826
+ learningStep,
827
+ isGraduated: true,
828
+ isRelearning: true,
829
+ lapses
830
+ };
831
+ case "HARD":
832
+ newEaseFactor = Math.max(this.config.minEaseFactor, newEaseFactor - 0.15);
833
+ newInterval = Math.max(state.interval + 1, state.interval * this.config.hardIntervalModifier);
834
+ break;
835
+ case "GOOD":
836
+ newInterval = state.interval * newEaseFactor * this.config.intervalModifier;
837
+ repetitions++;
838
+ break;
839
+ case "EASY":
840
+ newEaseFactor = newEaseFactor + 0.15;
841
+ newInterval = state.interval * newEaseFactor * this.config.easyBonus * this.config.intervalModifier;
842
+ repetitions++;
843
+ break;
844
+ }
845
+ newInterval = Math.min(Math.round(newInterval), this.config.maxInterval);
846
+ newInterval = Math.max(1, newInterval);
847
+ return {
848
+ interval: newInterval,
849
+ easeFactor: newEaseFactor,
850
+ repetitions,
851
+ nextReviewAt: this.addDays(now, newInterval),
852
+ learningStep,
853
+ isGraduated: true,
854
+ isRelearning,
855
+ lapses
856
+ };
857
+ }
858
+ addMinutes(date, minutes) {
859
+ return new Date(date.getTime() + minutes * 60 * 1000);
860
+ }
861
+ addDays(date, days) {
862
+ return new Date(date.getTime() + days * 24 * 60 * 60 * 1000);
863
+ }
864
+ }
865
+ var srsEngine = new SRSEngine;
866
+
867
+ // src/engines/xp.ts
868
+ var DEFAULT_XP_CONFIG = {
869
+ baseValues: {
870
+ lesson_complete: 10,
871
+ quiz_pass: 20,
872
+ quiz_perfect: 50,
873
+ flashcard_review: 1,
874
+ course_complete: 200,
875
+ module_complete: 50,
876
+ streak_bonus: 5,
877
+ achievement_unlock: 0,
878
+ daily_goal_complete: 15,
879
+ first_lesson: 25,
880
+ onboarding_step: 5,
881
+ onboarding_complete: 50
882
+ },
883
+ scoreThresholds: [
884
+ { min: 90, multiplier: 1.5 },
885
+ { min: 80, multiplier: 1.25 },
886
+ { min: 70, multiplier: 1 },
887
+ { min: 60, multiplier: 0.75 },
888
+ { min: 0, multiplier: 0.5 }
889
+ ],
890
+ streakTiers: [
891
+ { days: 365, bonus: 50 },
892
+ { days: 180, bonus: 30 },
893
+ { days: 90, bonus: 20 },
894
+ { days: 30, bonus: 15 },
895
+ { days: 14, bonus: 10 },
896
+ { days: 7, bonus: 5 },
897
+ { days: 3, bonus: 2 },
898
+ { days: 1, bonus: 0 }
899
+ ],
900
+ perfectScoreMultiplier: 1.5,
901
+ firstAttemptBonus: 10,
902
+ retryPenalty: 0.5,
903
+ speedBonusMultiplier: 1.2,
904
+ speedBonusThreshold: 0.8
905
+ };
906
+
907
+ class XPEngine {
908
+ config;
909
+ constructor(config = {}) {
910
+ this.config = {
911
+ ...DEFAULT_XP_CONFIG,
912
+ ...config,
913
+ baseValues: { ...DEFAULT_XP_CONFIG.baseValues, ...config.baseValues },
914
+ scoreThresholds: config.scoreThresholds || DEFAULT_XP_CONFIG.scoreThresholds,
915
+ streakTiers: config.streakTiers || DEFAULT_XP_CONFIG.streakTiers
916
+ };
917
+ }
918
+ calculate(input) {
919
+ const breakdown = [];
920
+ const baseXp = input.baseXp ?? this.config.baseValues[input.activity];
921
+ let totalXp = baseXp;
922
+ breakdown.push({
923
+ source: "base",
924
+ amount: baseXp
925
+ });
926
+ if (input.score !== undefined) {
927
+ const scoreMultiplier = this.getScoreMultiplier(input.score);
928
+ if (scoreMultiplier !== 1) {
929
+ const scoreBonus = Math.round(baseXp * (scoreMultiplier - 1));
930
+ totalXp += scoreBonus;
931
+ breakdown.push({
932
+ source: "score_bonus",
933
+ amount: scoreBonus,
934
+ multiplier: scoreMultiplier
935
+ });
936
+ }
937
+ if (input.score === 100) {
938
+ const perfectBonus = Math.round(baseXp * (this.config.perfectScoreMultiplier - 1));
939
+ totalXp += perfectBonus;
940
+ breakdown.push({
941
+ source: "perfect_score",
942
+ amount: perfectBonus,
943
+ multiplier: this.config.perfectScoreMultiplier
944
+ });
945
+ }
946
+ }
947
+ if (input.attemptNumber === 1 && !input.isRetry) {
948
+ totalXp += this.config.firstAttemptBonus;
949
+ breakdown.push({
950
+ source: "first_attempt",
951
+ amount: this.config.firstAttemptBonus
952
+ });
953
+ }
954
+ if (input.isRetry) {
955
+ const penalty = Math.round(totalXp * (1 - this.config.retryPenalty));
956
+ totalXp -= penalty;
957
+ breakdown.push({
958
+ source: "retry_penalty",
959
+ amount: -penalty,
960
+ multiplier: this.config.retryPenalty
961
+ });
962
+ }
963
+ if (input.currentStreak && input.currentStreak > 0) {
964
+ const streakBonus = this.getStreakBonus(input.currentStreak);
965
+ if (streakBonus > 0) {
966
+ totalXp += streakBonus;
967
+ breakdown.push({
968
+ source: "streak_bonus",
969
+ amount: streakBonus
970
+ });
971
+ }
972
+ }
973
+ if (baseXp > 0) {
974
+ totalXp = Math.max(1, totalXp);
975
+ }
976
+ return {
977
+ totalXp: Math.round(totalXp),
978
+ baseXp,
979
+ breakdown
980
+ };
981
+ }
982
+ calculateStreakBonus(currentStreak) {
983
+ const bonus = this.getStreakBonus(currentStreak);
984
+ return {
985
+ totalXp: bonus,
986
+ baseXp: bonus,
987
+ breakdown: [
988
+ {
989
+ source: "streak_bonus",
990
+ amount: bonus
991
+ }
992
+ ]
993
+ };
994
+ }
995
+ getXpForLevel(level) {
996
+ if (level <= 1)
997
+ return 0;
998
+ return Math.round(100 * Math.pow(level - 1, 1.5));
999
+ }
1000
+ getLevelFromXp(totalXp) {
1001
+ let level = 1;
1002
+ let xpRequired = this.getXpForLevel(level + 1);
1003
+ while (totalXp >= xpRequired && level < 1000) {
1004
+ level++;
1005
+ xpRequired = this.getXpForLevel(level + 1);
1006
+ }
1007
+ const xpForCurrentLevel = this.getXpForLevel(level);
1008
+ const xpForNextLevel = this.getXpForLevel(level + 1);
1009
+ return {
1010
+ level,
1011
+ xpInLevel: totalXp - xpForCurrentLevel,
1012
+ xpForNextLevel: xpForNextLevel - xpForCurrentLevel
1013
+ };
1014
+ }
1015
+ getScoreMultiplier(score) {
1016
+ for (const threshold of this.config.scoreThresholds) {
1017
+ if (score >= threshold.min) {
1018
+ return threshold.multiplier;
1019
+ }
1020
+ }
1021
+ return 1;
1022
+ }
1023
+ getStreakBonus(streak) {
1024
+ for (const tier of this.config.streakTiers) {
1025
+ if (streak >= tier.days) {
1026
+ return tier.bonus;
1027
+ }
1028
+ }
1029
+ return 0;
1030
+ }
1031
+ }
1032
+ var xpEngine = new XPEngine;
1033
+
1034
+ // src/engines/streak.ts
1035
+ var DEFAULT_STREAK_CONFIG = {
1036
+ timezone: "UTC",
1037
+ freezesPerMonth: 2,
1038
+ maxFreezes: 5,
1039
+ gracePeriodHours: 4
1040
+ };
1041
+
1042
+ class StreakEngine {
1043
+ config;
1044
+ constructor(config = {}) {
1045
+ this.config = { ...DEFAULT_STREAK_CONFIG, ...config };
1046
+ }
1047
+ update(state, now = new Date) {
1048
+ const todayDate = this.getDateString(now);
1049
+ const result = {
1050
+ state: { ...state },
1051
+ streakMaintained: false,
1052
+ streakLost: false,
1053
+ freezeUsed: false,
1054
+ newStreak: false,
1055
+ daysMissed: 0
1056
+ };
1057
+ if (!state.lastActivityDate) {
1058
+ result.state.currentStreak = 1;
1059
+ result.state.longestStreak = Math.max(1, state.longestStreak);
1060
+ result.state.lastActivityAt = now;
1061
+ result.state.lastActivityDate = todayDate;
1062
+ result.newStreak = true;
1063
+ result.streakMaintained = true;
1064
+ return result;
1065
+ }
1066
+ if (state.lastActivityDate === todayDate) {
1067
+ result.state.lastActivityAt = now;
1068
+ result.streakMaintained = true;
1069
+ return result;
1070
+ }
1071
+ const daysSinceActivity = this.getDaysBetween(state.lastActivityDate, todayDate);
1072
+ if (daysSinceActivity === 1) {
1073
+ result.state.currentStreak = state.currentStreak + 1;
1074
+ result.state.longestStreak = Math.max(result.state.currentStreak, state.longestStreak);
1075
+ result.state.lastActivityAt = now;
1076
+ result.state.lastActivityDate = todayDate;
1077
+ result.streakMaintained = true;
1078
+ return result;
1079
+ }
1080
+ result.daysMissed = daysSinceActivity - 1;
1081
+ const freezesNeeded = result.daysMissed;
1082
+ if (freezesNeeded <= state.freezesRemaining) {
1083
+ result.state.freezesRemaining = state.freezesRemaining - freezesNeeded;
1084
+ result.state.freezeUsedAt = now;
1085
+ result.state.currentStreak = state.currentStreak + 1;
1086
+ result.state.longestStreak = Math.max(result.state.currentStreak, state.longestStreak);
1087
+ result.state.lastActivityAt = now;
1088
+ result.state.lastActivityDate = todayDate;
1089
+ result.freezeUsed = true;
1090
+ result.streakMaintained = true;
1091
+ return result;
1092
+ }
1093
+ result.streakLost = true;
1094
+ result.state.currentStreak = 1;
1095
+ result.state.lastActivityAt = now;
1096
+ result.state.lastActivityDate = todayDate;
1097
+ result.newStreak = true;
1098
+ return result;
1099
+ }
1100
+ checkStatus(state, now = new Date) {
1101
+ if (!state.lastActivityDate) {
1102
+ return {
1103
+ isActive: false,
1104
+ willExpireAt: null,
1105
+ canUseFreeze: false,
1106
+ daysUntilExpiry: 0
1107
+ };
1108
+ }
1109
+ const todayDate = this.getDateString(now);
1110
+ const daysSinceActivity = this.getDaysBetween(state.lastActivityDate, todayDate);
1111
+ if (daysSinceActivity === 0) {
1112
+ const tomorrow = this.addDays(now, 1);
1113
+ tomorrow.setHours(23, 59, 59, 999);
1114
+ return {
1115
+ isActive: true,
1116
+ willExpireAt: tomorrow,
1117
+ canUseFreeze: state.freezesRemaining > 0,
1118
+ daysUntilExpiry: 1
1119
+ };
1120
+ }
1121
+ if (daysSinceActivity === 1) {
1122
+ const endOfDay = new Date(now);
1123
+ endOfDay.setHours(23 + this.config.gracePeriodHours, 59, 59, 999);
1124
+ return {
1125
+ isActive: true,
1126
+ willExpireAt: endOfDay,
1127
+ canUseFreeze: state.freezesRemaining > 0,
1128
+ daysUntilExpiry: 0
1129
+ };
1130
+ }
1131
+ const missedDays = daysSinceActivity - 1;
1132
+ return {
1133
+ isActive: missedDays <= state.freezesRemaining,
1134
+ willExpireAt: null,
1135
+ canUseFreeze: missedDays <= state.freezesRemaining,
1136
+ daysUntilExpiry: -missedDays
1137
+ };
1138
+ }
1139
+ useFreeze(state, now = new Date) {
1140
+ if (state.freezesRemaining <= 0) {
1141
+ return null;
1142
+ }
1143
+ return {
1144
+ ...state,
1145
+ freezesRemaining: state.freezesRemaining - 1,
1146
+ freezeUsedAt: now
1147
+ };
1148
+ }
1149
+ awardMonthlyFreezes(state) {
1150
+ return {
1151
+ ...state,
1152
+ freezesRemaining: Math.min(state.freezesRemaining + this.config.freezesPerMonth, this.config.maxFreezes)
1153
+ };
1154
+ }
1155
+ getInitialState() {
1156
+ return {
1157
+ currentStreak: 0,
1158
+ longestStreak: 0,
1159
+ lastActivityAt: null,
1160
+ lastActivityDate: null,
1161
+ freezesRemaining: this.config.freezesPerMonth,
1162
+ freezeUsedAt: null
1163
+ };
1164
+ }
1165
+ getMilestones(currentStreak) {
1166
+ const milestones = [3, 7, 14, 30, 60, 90, 180, 365, 500, 1000];
1167
+ const achieved = milestones.filter((m) => currentStreak >= m);
1168
+ const next = milestones.find((m) => currentStreak < m) ?? null;
1169
+ return { achieved, next };
1170
+ }
1171
+ getDateString(date) {
1172
+ const year = date.getFullYear();
1173
+ const month = String(date.getMonth() + 1).padStart(2, "0");
1174
+ const day = String(date.getDate()).padStart(2, "0");
1175
+ return `${year}-${month}-${day}`;
1176
+ }
1177
+ getDaysBetween(dateStr1, dateStr2) {
1178
+ const date1 = new Date(dateStr1);
1179
+ const date2 = new Date(dateStr2);
1180
+ const diffTime = date2.getTime() - date1.getTime();
1181
+ return Math.floor(diffTime / (1000 * 60 * 60 * 24));
1182
+ }
1183
+ addDays(date, days) {
1184
+ return new Date(date.getTime() + days * 24 * 60 * 60 * 1000);
1185
+ }
1186
+ }
1187
+ var streakEngine = new StreakEngine;
1188
+ // src/entities/ai.ts
1189
+ import {
1190
+ defineEntity,
1191
+ defineEntityEnum,
1192
+ field,
1193
+ index
1194
+ } from "@contractspec/lib.schema";
1195
+ var LearningStyleEnum = defineEntityEnum({
1196
+ name: "LearningStyle",
1197
+ values: ["VISUAL", "AUDITORY", "READING", "KINESTHETIC", "MIXED"],
1198
+ schema: "lssm_learning",
1199
+ description: "Preferred learning style."
1200
+ });
1201
+ var RecommendationTypeEnum = defineEntityEnum({
1202
+ name: "RecommendationType",
1203
+ values: [
1204
+ "COURSE",
1205
+ "LESSON",
1206
+ "REVIEW",
1207
+ "PRACTICE",
1208
+ "ASSESSMENT",
1209
+ "DECK"
1210
+ ],
1211
+ schema: "lssm_learning",
1212
+ description: "Type of learning recommendation."
1213
+ });
1214
+ var LearnerProfileEntity = defineEntity({
1215
+ name: "LearnerProfile",
1216
+ description: "AI personalization profile for a learner.",
1217
+ schema: "lssm_learning",
1218
+ map: "learner_profile",
1219
+ fields: {
1220
+ id: field.id({ description: "Unique profile identifier" }),
1221
+ learnerId: field.foreignKey({ description: "Learner" }),
1222
+ learningStyle: field.enum("LearningStyle", {
1223
+ default: "MIXED",
1224
+ description: "Preferred learning style"
1225
+ }),
1226
+ preferredDifficulty: field.string({
1227
+ default: '"adaptive"',
1228
+ description: "Difficulty preference"
1229
+ }),
1230
+ preferredSessionLength: field.int({
1231
+ default: 30,
1232
+ description: "Preferred session length in minutes"
1233
+ }),
1234
+ interests: field.json({ isOptional: true, description: "Topic interests" }),
1235
+ goals: field.json({ isOptional: true, description: "Learning goals" }),
1236
+ pacePreference: field.string({
1237
+ default: '"normal"',
1238
+ description: "Learning pace: slow, normal, fast"
1239
+ }),
1240
+ bestTimeOfDay: field.string({
1241
+ isOptional: true,
1242
+ description: "Best time for learning"
1243
+ }),
1244
+ averageSessionLength: field.int({
1245
+ isOptional: true,
1246
+ description: "Average session length"
1247
+ }),
1248
+ daysActivePerWeek: field.int({
1249
+ isOptional: true,
1250
+ description: "Days active per week"
1251
+ }),
1252
+ avgQuizScore: field.int({
1253
+ isOptional: true,
1254
+ description: "Average quiz score"
1255
+ }),
1256
+ avgLessonCompletionTime: field.int({
1257
+ isOptional: true,
1258
+ description: "Avg lesson completion time"
1259
+ }),
1260
+ strengths: field.json({
1261
+ isOptional: true,
1262
+ description: "Identified strengths"
1263
+ }),
1264
+ weaknesses: field.json({
1265
+ isOptional: true,
1266
+ description: "Areas for improvement"
1267
+ }),
1268
+ lastAnalyzedAt: field.dateTime({
1269
+ isOptional: true,
1270
+ description: "Last AI analysis"
1271
+ }),
1272
+ metadata: field.json({
1273
+ isOptional: true,
1274
+ description: "Additional metadata"
1275
+ }),
1276
+ createdAt: field.createdAt(),
1277
+ updatedAt: field.updatedAt(),
1278
+ learner: field.belongsTo("Learner", ["learnerId"], ["id"], {
1279
+ onDelete: "Cascade"
1280
+ })
1281
+ },
1282
+ indexes: [
1283
+ index.unique(["learnerId"], { name: "learner_profile_unique" }),
1284
+ index.on(["learningStyle"])
1285
+ ],
1286
+ enums: [LearningStyleEnum]
1287
+ });
1288
+ var SkillMapEntity = defineEntity({
1289
+ name: "SkillMap",
1290
+ description: "Maps learner proficiency across skills.",
1291
+ schema: "lssm_learning",
1292
+ map: "skill_map",
1293
+ fields: {
1294
+ id: field.id({ description: "Unique skill map identifier" }),
1295
+ learnerId: field.foreignKey({ description: "Learner" }),
1296
+ skillId: field.string({ description: "Skill identifier" }),
1297
+ skillName: field.string({ description: "Skill name" }),
1298
+ skillCategory: field.string({
1299
+ isOptional: true,
1300
+ description: "Skill category"
1301
+ }),
1302
+ level: field.int({ default: 0, description: "Proficiency level (0-100)" }),
1303
+ confidence: field.decimal({
1304
+ default: 0.5,
1305
+ description: "Confidence in assessment"
1306
+ }),
1307
+ lessonsCompleted: field.int({
1308
+ default: 0,
1309
+ description: "Related lessons completed"
1310
+ }),
1311
+ quizzesCompleted: field.int({
1312
+ default: 0,
1313
+ description: "Related quizzes completed"
1314
+ }),
1315
+ practiceTime: field.int({
1316
+ default: 0,
1317
+ description: "Practice time in minutes"
1318
+ }),
1319
+ lastPracticedAt: field.dateTime({
1320
+ isOptional: true,
1321
+ description: "Last practice time"
1322
+ }),
1323
+ learningVelocity: field.decimal({
1324
+ isOptional: true,
1325
+ description: "Learning speed for this skill"
1326
+ }),
1327
+ predictedTimeToMastery: field.int({
1328
+ isOptional: true,
1329
+ description: "Predicted time to mastery (minutes)"
1330
+ }),
1331
+ createdAt: field.createdAt(),
1332
+ updatedAt: field.updatedAt(),
1333
+ learner: field.belongsTo("Learner", ["learnerId"], ["id"], {
1334
+ onDelete: "Cascade"
1335
+ })
1336
+ },
1337
+ indexes: [
1338
+ index.unique(["learnerId", "skillId"], { name: "skill_map_unique" }),
1339
+ index.on(["skillId", "level"]),
1340
+ index.on(["learnerId", "level"])
1341
+ ]
1342
+ });
1343
+ var LearningPathEntity = defineEntity({
1344
+ name: "LearningPath",
1345
+ description: "AI-generated personalized learning path.",
1346
+ schema: "lssm_learning",
1347
+ map: "learning_path",
1348
+ fields: {
1349
+ id: field.id({ description: "Unique path identifier" }),
1350
+ learnerId: field.foreignKey({ description: "Learner" }),
1351
+ name: field.string({ description: "Path name" }),
1352
+ description: field.string({
1353
+ isOptional: true,
1354
+ description: "Path description"
1355
+ }),
1356
+ goal: field.string({ isOptional: true, description: "Path goal" }),
1357
+ steps: field.json({ description: "Ordered list of learning steps" }),
1358
+ currentStepIndex: field.int({
1359
+ default: 0,
1360
+ description: "Current step index"
1361
+ }),
1362
+ progress: field.int({ default: 0, description: "Completion percentage" }),
1363
+ completedSteps: field.int({ default: 0, description: "Steps completed" }),
1364
+ totalSteps: field.int({ default: 0, description: "Total steps" }),
1365
+ generatedAt: field.dateTime({ description: "When path was generated" }),
1366
+ adaptedFrom: field.string({
1367
+ isOptional: true,
1368
+ description: "Original path ID if adapted"
1369
+ }),
1370
+ generationParams: field.json({
1371
+ isOptional: true,
1372
+ description: "AI generation parameters"
1373
+ }),
1374
+ adaptationHistory: field.json({
1375
+ isOptional: true,
1376
+ description: "Path adaptation history"
1377
+ }),
1378
+ isActive: field.boolean({
1379
+ default: true,
1380
+ description: "Whether path is active"
1381
+ }),
1382
+ isCompleted: field.boolean({
1383
+ default: false,
1384
+ description: "Whether path is completed"
1385
+ }),
1386
+ startedAt: field.dateTime({
1387
+ isOptional: true,
1388
+ description: "When started"
1389
+ }),
1390
+ completedAt: field.dateTime({
1391
+ isOptional: true,
1392
+ description: "When completed"
1393
+ }),
1394
+ estimatedCompletionDate: field.dateTime({
1395
+ isOptional: true,
1396
+ description: "Estimated completion"
1397
+ }),
1398
+ createdAt: field.createdAt(),
1399
+ updatedAt: field.updatedAt(),
1400
+ learner: field.belongsTo("Learner", ["learnerId"], ["id"], {
1401
+ onDelete: "Cascade"
1402
+ })
1403
+ },
1404
+ indexes: [index.on(["learnerId", "isActive"]), index.on(["generatedAt"])]
1405
+ });
1406
+ var RecommendationEntity = defineEntity({
1407
+ name: "Recommendation",
1408
+ description: "AI-powered learning recommendation.",
1409
+ schema: "lssm_learning",
1410
+ map: "recommendation",
1411
+ fields: {
1412
+ id: field.id({ description: "Unique recommendation identifier" }),
1413
+ learnerId: field.foreignKey({ description: "Learner" }),
1414
+ type: field.enum("RecommendationType", {
1415
+ description: "Recommendation type"
1416
+ }),
1417
+ itemId: field.string({ description: "Recommended item ID" }),
1418
+ itemType: field.string({
1419
+ description: "Item type (course, lesson, deck, etc.)"
1420
+ }),
1421
+ score: field.decimal({ description: "Recommendation score (0-1)" }),
1422
+ confidence: field.decimal({ description: "Confidence in recommendation" }),
1423
+ reason: field.string({ description: "Human-readable reason" }),
1424
+ factors: field.json({
1425
+ isOptional: true,
1426
+ description: "Factors that contributed to recommendation"
1427
+ }),
1428
+ status: field.string({
1429
+ default: '"pending"',
1430
+ description: "Status: pending, viewed, accepted, dismissed"
1431
+ }),
1432
+ viewedAt: field.dateTime({ isOptional: true, description: "When viewed" }),
1433
+ acceptedAt: field.dateTime({
1434
+ isOptional: true,
1435
+ description: "When accepted"
1436
+ }),
1437
+ dismissedAt: field.dateTime({
1438
+ isOptional: true,
1439
+ description: "When dismissed"
1440
+ }),
1441
+ feedback: field.string({ isOptional: true, description: "User feedback" }),
1442
+ feedbackRating: field.int({
1443
+ isOptional: true,
1444
+ description: "Feedback rating (1-5)"
1445
+ }),
1446
+ expiresAt: field.dateTime({
1447
+ isOptional: true,
1448
+ description: "When recommendation expires"
1449
+ }),
1450
+ createdAt: field.createdAt(),
1451
+ updatedAt: field.updatedAt(),
1452
+ learner: field.belongsTo("Learner", ["learnerId"], ["id"], {
1453
+ onDelete: "Cascade"
1454
+ })
1455
+ },
1456
+ indexes: [
1457
+ index.on(["learnerId", "status", "score"]),
1458
+ index.on(["type", "status"]),
1459
+ index.on(["expiresAt"])
1460
+ ],
1461
+ enums: [RecommendationTypeEnum]
1462
+ });
1463
+ var LearningGapEntity = defineEntity({
1464
+ name: "LearningGap",
1465
+ description: "Identified learning gap.",
1466
+ schema: "lssm_learning",
1467
+ map: "learning_gap",
1468
+ fields: {
1469
+ id: field.id({ description: "Unique gap identifier" }),
1470
+ learnerId: field.foreignKey({ description: "Learner" }),
1471
+ skillId: field.string({ description: "Skill with gap" }),
1472
+ skillName: field.string({ description: "Skill name" }),
1473
+ severity: field.string({
1474
+ default: '"moderate"',
1475
+ description: "Gap severity: minor, moderate, major"
1476
+ }),
1477
+ confidence: field.decimal({ description: "Confidence in gap detection" }),
1478
+ evidence: field.json({ isOptional: true, description: "Evidence for gap" }),
1479
+ relatedQuestions: field.json({
1480
+ isOptional: true,
1481
+ description: "Questions that revealed gap"
1482
+ }),
1483
+ suggestedRemediation: field.json({
1484
+ isOptional: true,
1485
+ description: "Suggested remediation"
1486
+ }),
1487
+ remediationProgress: field.int({
1488
+ default: 0,
1489
+ description: "Remediation progress"
1490
+ }),
1491
+ status: field.string({
1492
+ default: '"open"',
1493
+ description: "Status: open, in_progress, resolved"
1494
+ }),
1495
+ resolvedAt: field.dateTime({
1496
+ isOptional: true,
1497
+ description: "When resolved"
1498
+ }),
1499
+ detectedAt: field.dateTime({ description: "When gap was detected" }),
1500
+ createdAt: field.createdAt(),
1501
+ updatedAt: field.updatedAt(),
1502
+ learner: field.belongsTo("Learner", ["learnerId"], ["id"], {
1503
+ onDelete: "Cascade"
1504
+ })
1505
+ },
1506
+ indexes: [
1507
+ index.on(["learnerId", "status"]),
1508
+ index.on(["skillId", "status"]),
1509
+ index.on(["severity", "status"])
1510
+ ]
1511
+ });
1512
+ var aiEntities = [
1513
+ LearnerProfileEntity,
1514
+ SkillMapEntity,
1515
+ LearningPathEntity,
1516
+ RecommendationEntity,
1517
+ LearningGapEntity
1518
+ ];
1519
+ var aiEnums = [LearningStyleEnum, RecommendationTypeEnum];
1520
+
1521
+ // src/entities/course.ts
1522
+ import {
1523
+ defineEntity as defineEntity2,
1524
+ defineEntityEnum as defineEntityEnum2,
1525
+ field as field2,
1526
+ index as index2
1527
+ } from "@contractspec/lib.schema";
1528
+ var CourseDifficultyEnum = defineEntityEnum2({
1529
+ name: "CourseDifficulty",
1530
+ values: ["BEGINNER", "INTERMEDIATE", "ADVANCED", "EXPERT"],
1531
+ schema: "lssm_learning",
1532
+ description: "Difficulty level of a course."
1533
+ });
1534
+ var CourseStatusEnum = defineEntityEnum2({
1535
+ name: "CourseStatus",
1536
+ values: ["DRAFT", "PUBLISHED", "ARCHIVED"],
1537
+ schema: "lssm_learning",
1538
+ description: "Publication status of a course."
1539
+ });
1540
+ var LessonTypeEnum = defineEntityEnum2({
1541
+ name: "LessonType",
1542
+ values: [
1543
+ "CONTENT",
1544
+ "VIDEO",
1545
+ "INTERACTIVE",
1546
+ "QUIZ",
1547
+ "PRACTICE",
1548
+ "PROJECT"
1549
+ ],
1550
+ schema: "lssm_learning",
1551
+ description: "Type of lesson content."
1552
+ });
1553
+ var ContentTypeEnum = defineEntityEnum2({
1554
+ name: "ContentType",
1555
+ values: ["MARKDOWN", "VIDEO", "AUDIO", "EMBED", "SCORM", "CUSTOM"],
1556
+ schema: "lssm_learning",
1557
+ description: "Type of lesson content format."
1558
+ });
1559
+ var CourseEntity = defineEntity2({
1560
+ name: "Course",
1561
+ description: "A structured learning course.",
1562
+ schema: "lssm_learning",
1563
+ map: "course",
1564
+ fields: {
1565
+ id: field2.id({ description: "Unique course identifier" }),
1566
+ title: field2.string({ description: "Course title" }),
1567
+ slug: field2.string({ isUnique: true, description: "URL-friendly slug" }),
1568
+ description: field2.string({
1569
+ isOptional: true,
1570
+ description: "Course description"
1571
+ }),
1572
+ summary: field2.string({ isOptional: true, description: "Short summary" }),
1573
+ difficulty: field2.enum("CourseDifficulty", {
1574
+ default: "BEGINNER",
1575
+ description: "Difficulty level"
1576
+ }),
1577
+ category: field2.string({
1578
+ isOptional: true,
1579
+ description: "Course category"
1580
+ }),
1581
+ tags: field2.json({ isOptional: true, description: "Tags for discovery" }),
1582
+ prerequisites: field2.json({
1583
+ isOptional: true,
1584
+ description: "Required course IDs"
1585
+ }),
1586
+ requiredSkills: field2.json({
1587
+ isOptional: true,
1588
+ description: "Required skill levels"
1589
+ }),
1590
+ estimatedDuration: field2.int({
1591
+ isOptional: true,
1592
+ description: "Estimated duration in minutes"
1593
+ }),
1594
+ thumbnailUrl: field2.string({
1595
+ isOptional: true,
1596
+ description: "Thumbnail image URL"
1597
+ }),
1598
+ coverImageUrl: field2.string({
1599
+ isOptional: true,
1600
+ description: "Cover image URL"
1601
+ }),
1602
+ promoVideoUrl: field2.string({
1603
+ isOptional: true,
1604
+ description: "Promo video URL"
1605
+ }),
1606
+ status: field2.enum("CourseStatus", {
1607
+ default: "DRAFT",
1608
+ description: "Publication status"
1609
+ }),
1610
+ publishedAt: field2.dateTime({
1611
+ isOptional: true,
1612
+ description: "When published"
1613
+ }),
1614
+ authorId: field2.string({ description: "Author user ID" }),
1615
+ orgId: field2.string({
1616
+ isOptional: true,
1617
+ description: "Organization scope"
1618
+ }),
1619
+ isPublic: field2.boolean({
1620
+ default: false,
1621
+ description: "Whether course is publicly accessible"
1622
+ }),
1623
+ isFeatured: field2.boolean({
1624
+ default: false,
1625
+ description: "Whether course is featured"
1626
+ }),
1627
+ certificateEnabled: field2.boolean({
1628
+ default: false,
1629
+ description: "Award certificate on completion"
1630
+ }),
1631
+ metadata: field2.json({
1632
+ isOptional: true,
1633
+ description: "Additional metadata"
1634
+ }),
1635
+ createdAt: field2.createdAt(),
1636
+ updatedAt: field2.updatedAt(),
1637
+ modules: field2.hasMany("CourseModule"),
1638
+ enrollments: field2.hasMany("Enrollment")
1639
+ },
1640
+ indexes: [
1641
+ index2.on(["orgId", "status"]),
1642
+ index2.on(["category"]),
1643
+ index2.on(["difficulty"]),
1644
+ index2.on(["authorId"])
1645
+ ],
1646
+ enums: [CourseDifficultyEnum, CourseStatusEnum]
1647
+ });
1648
+ var CourseModuleEntity = defineEntity2({
1649
+ name: "CourseModule",
1650
+ description: "A module (section) within a course.",
1651
+ schema: "lssm_learning",
1652
+ map: "course_module",
1653
+ fields: {
1654
+ id: field2.id({ description: "Unique module identifier" }),
1655
+ courseId: field2.foreignKey({ description: "Parent course" }),
1656
+ title: field2.string({ description: "Module title" }),
1657
+ description: field2.string({
1658
+ isOptional: true,
1659
+ description: "Module description"
1660
+ }),
1661
+ order: field2.int({ default: 0, description: "Display order" }),
1662
+ unlockCondition: field2.json({
1663
+ isOptional: true,
1664
+ description: "Conditions to unlock module"
1665
+ }),
1666
+ prerequisiteModuleIds: field2.json({
1667
+ isOptional: true,
1668
+ description: "Required modules to complete first"
1669
+ }),
1670
+ estimatedDuration: field2.int({
1671
+ isOptional: true,
1672
+ description: "Estimated duration in minutes"
1673
+ }),
1674
+ createdAt: field2.createdAt(),
1675
+ updatedAt: field2.updatedAt(),
1676
+ course: field2.belongsTo("Course", ["courseId"], ["id"], {
1677
+ onDelete: "Cascade"
1678
+ }),
1679
+ lessons: field2.hasMany("Lesson"),
1680
+ completions: field2.hasMany("ModuleCompletion")
1681
+ },
1682
+ indexes: [index2.on(["courseId", "order"])]
1683
+ });
1684
+ var LessonEntity = defineEntity2({
1685
+ name: "Lesson",
1686
+ description: "An individual lesson within a module.",
1687
+ schema: "lssm_learning",
1688
+ map: "lesson",
1689
+ fields: {
1690
+ id: field2.id({ description: "Unique lesson identifier" }),
1691
+ moduleId: field2.foreignKey({ description: "Parent module" }),
1692
+ title: field2.string({ description: "Lesson title" }),
1693
+ description: field2.string({
1694
+ isOptional: true,
1695
+ description: "Lesson description"
1696
+ }),
1697
+ type: field2.enum("LessonType", {
1698
+ default: "CONTENT",
1699
+ description: "Lesson type"
1700
+ }),
1701
+ order: field2.int({ default: 0, description: "Display order" }),
1702
+ estimatedDuration: field2.int({
1703
+ isOptional: true,
1704
+ description: "Estimated duration in minutes"
1705
+ }),
1706
+ xpReward: field2.int({
1707
+ default: 10,
1708
+ description: "XP awarded on completion"
1709
+ }),
1710
+ isFree: field2.boolean({
1711
+ default: false,
1712
+ description: "Whether lesson is free preview"
1713
+ }),
1714
+ isRequired: field2.boolean({
1715
+ default: true,
1716
+ description: "Whether lesson is required for completion"
1717
+ }),
1718
+ metadata: field2.json({
1719
+ isOptional: true,
1720
+ description: "Additional metadata"
1721
+ }),
1722
+ createdAt: field2.createdAt(),
1723
+ updatedAt: field2.updatedAt(),
1724
+ module: field2.belongsTo("CourseModule", ["moduleId"], ["id"], {
1725
+ onDelete: "Cascade"
1726
+ }),
1727
+ contents: field2.hasMany("LessonContent"),
1728
+ progress: field2.hasMany("LessonProgress"),
1729
+ quizzes: field2.hasMany("Quiz")
1730
+ },
1731
+ indexes: [index2.on(["moduleId", "order"]), index2.on(["type"])],
1732
+ enums: [LessonTypeEnum]
1733
+ });
1734
+ var LessonContentEntity = defineEntity2({
1735
+ name: "LessonContent",
1736
+ description: "Content block within a lesson.",
1737
+ schema: "lssm_learning",
1738
+ map: "lesson_content",
1739
+ fields: {
1740
+ id: field2.id({ description: "Unique content identifier" }),
1741
+ lessonId: field2.foreignKey({ description: "Parent lesson" }),
1742
+ contentType: field2.enum("ContentType", { description: "Content format" }),
1743
+ content: field2.string({
1744
+ isOptional: true,
1745
+ description: "Text content (markdown, etc.)"
1746
+ }),
1747
+ mediaUrl: field2.string({
1748
+ isOptional: true,
1749
+ description: "Media URL for video/audio"
1750
+ }),
1751
+ embedData: field2.json({
1752
+ isOptional: true,
1753
+ description: "Embed data for external content"
1754
+ }),
1755
+ order: field2.int({ default: 0, description: "Display order" }),
1756
+ duration: field2.int({
1757
+ isOptional: true,
1758
+ description: "Content duration in seconds"
1759
+ }),
1760
+ metadata: field2.json({
1761
+ isOptional: true,
1762
+ description: "Additional metadata"
1763
+ }),
1764
+ createdAt: field2.createdAt(),
1765
+ updatedAt: field2.updatedAt(),
1766
+ lesson: field2.belongsTo("Lesson", ["lessonId"], ["id"], {
1767
+ onDelete: "Cascade"
1768
+ })
1769
+ },
1770
+ indexes: [index2.on(["lessonId", "order"])],
1771
+ enums: [ContentTypeEnum]
1772
+ });
1773
+ var courseEntities = [
1774
+ CourseEntity,
1775
+ CourseModuleEntity,
1776
+ LessonEntity,
1777
+ LessonContentEntity
1778
+ ];
1779
+ var courseEnums = [
1780
+ CourseDifficultyEnum,
1781
+ CourseStatusEnum,
1782
+ LessonTypeEnum,
1783
+ ContentTypeEnum
1784
+ ];
1785
+
1786
+ // src/entities/flashcard.ts
1787
+ import {
1788
+ defineEntity as defineEntity3,
1789
+ defineEntityEnum as defineEntityEnum3,
1790
+ field as field3,
1791
+ index as index3
1792
+ } from "@contractspec/lib.schema";
1793
+ var CardRatingEnum = defineEntityEnum3({
1794
+ name: "CardRating",
1795
+ values: ["AGAIN", "HARD", "GOOD", "EASY"],
1796
+ schema: "lssm_learning",
1797
+ description: "Rating for a flashcard review."
1798
+ });
1799
+ var DeckEntity = defineEntity3({
1800
+ name: "Deck",
1801
+ description: "A collection of flashcards.",
1802
+ schema: "lssm_learning",
1803
+ map: "deck",
1804
+ fields: {
1805
+ id: field3.id({ description: "Unique deck identifier" }),
1806
+ ownerId: field3.foreignKey({ description: "Deck owner (learner)" }),
1807
+ title: field3.string({ description: "Deck title" }),
1808
+ description: field3.string({
1809
+ isOptional: true,
1810
+ description: "Deck description"
1811
+ }),
1812
+ category: field3.string({ isOptional: true, description: "Deck category" }),
1813
+ tags: field3.json({ isOptional: true, description: "Tags for discovery" }),
1814
+ isPublic: field3.boolean({
1815
+ default: false,
1816
+ description: "Whether deck is publicly visible"
1817
+ }),
1818
+ cardCount: field3.int({ default: 0, description: "Number of cards" }),
1819
+ coverImageUrl: field3.string({
1820
+ isOptional: true,
1821
+ description: "Cover image URL"
1822
+ }),
1823
+ orgId: field3.string({
1824
+ isOptional: true,
1825
+ description: "Organization scope"
1826
+ }),
1827
+ newCardsPerDay: field3.int({
1828
+ default: 20,
1829
+ description: "New cards to introduce per day"
1830
+ }),
1831
+ reviewsPerDay: field3.int({
1832
+ default: 100,
1833
+ description: "Maximum reviews per day"
1834
+ }),
1835
+ metadata: field3.json({
1836
+ isOptional: true,
1837
+ description: "Additional metadata"
1838
+ }),
1839
+ createdAt: field3.createdAt(),
1840
+ updatedAt: field3.updatedAt(),
1841
+ owner: field3.belongsTo("Learner", ["ownerId"], ["id"], {
1842
+ onDelete: "Cascade"
1843
+ }),
1844
+ cards: field3.hasMany("Card")
1845
+ },
1846
+ indexes: [
1847
+ index3.on(["ownerId"]),
1848
+ index3.on(["isPublic", "category"]),
1849
+ index3.on(["orgId"])
1850
+ ]
1851
+ });
1852
+ var CardEntity = defineEntity3({
1853
+ name: "Card",
1854
+ description: "An individual flashcard.",
1855
+ schema: "lssm_learning",
1856
+ map: "card",
1857
+ fields: {
1858
+ id: field3.id({ description: "Unique card identifier" }),
1859
+ deckId: field3.foreignKey({ description: "Parent deck" }),
1860
+ front: field3.string({ description: "Front of card (question)" }),
1861
+ back: field3.string({ description: "Back of card (answer)" }),
1862
+ hints: field3.json({ isOptional: true, description: "Hints for the card" }),
1863
+ explanation: field3.string({
1864
+ isOptional: true,
1865
+ description: "Detailed explanation"
1866
+ }),
1867
+ frontMediaUrl: field3.string({
1868
+ isOptional: true,
1869
+ description: "Media for front"
1870
+ }),
1871
+ backMediaUrl: field3.string({
1872
+ isOptional: true,
1873
+ description: "Media for back"
1874
+ }),
1875
+ audioUrl: field3.string({
1876
+ isOptional: true,
1877
+ description: "Audio pronunciation"
1878
+ }),
1879
+ tags: field3.json({ isOptional: true, description: "Card tags" }),
1880
+ difficulty: field3.int({ default: 0, description: "Card difficulty (0-5)" }),
1881
+ order: field3.int({ default: 0, description: "Card order in deck" }),
1882
+ isSuspended: field3.boolean({
1883
+ default: false,
1884
+ description: "Whether card is suspended"
1885
+ }),
1886
+ metadata: field3.json({
1887
+ isOptional: true,
1888
+ description: "Additional metadata"
1889
+ }),
1890
+ createdAt: field3.createdAt(),
1891
+ updatedAt: field3.updatedAt(),
1892
+ deck: field3.belongsTo("Deck", ["deckId"], ["id"], { onDelete: "Cascade" }),
1893
+ reviews: field3.hasMany("CardReview"),
1894
+ schedules: field3.hasMany("CardSchedule")
1895
+ },
1896
+ indexes: [index3.on(["deckId", "order"]), index3.on(["isSuspended"])]
1897
+ });
1898
+ var CardReviewEntity = defineEntity3({
1899
+ name: "CardReview",
1900
+ description: "A single review of a flashcard.",
1901
+ schema: "lssm_learning",
1902
+ map: "card_review",
1903
+ fields: {
1904
+ id: field3.id({ description: "Unique review identifier" }),
1905
+ learnerId: field3.foreignKey({ description: "Reviewer" }),
1906
+ cardId: field3.foreignKey({ description: "Reviewed card" }),
1907
+ rating: field3.enum("CardRating", { description: "Review rating" }),
1908
+ responseTimeMs: field3.int({
1909
+ isOptional: true,
1910
+ description: "Time to respond in ms"
1911
+ }),
1912
+ intervalBefore: field3.int({ description: "Interval before review (days)" }),
1913
+ easeFactorBefore: field3.decimal({
1914
+ description: "Ease factor before review"
1915
+ }),
1916
+ intervalAfter: field3.int({ description: "Interval after review (days)" }),
1917
+ easeFactorAfter: field3.decimal({ description: "Ease factor after review" }),
1918
+ reviewType: field3.string({
1919
+ default: '"review"',
1920
+ description: "Type: new, learning, review, relearning"
1921
+ }),
1922
+ reviewedAt: field3.dateTime({ description: "When reviewed" }),
1923
+ createdAt: field3.createdAt(),
1924
+ learner: field3.belongsTo("Learner", ["learnerId"], ["id"], {
1925
+ onDelete: "Cascade"
1926
+ }),
1927
+ card: field3.belongsTo("Card", ["cardId"], ["id"], { onDelete: "Cascade" })
1928
+ },
1929
+ indexes: [
1930
+ index3.on(["learnerId", "reviewedAt"]),
1931
+ index3.on(["cardId", "reviewedAt"]),
1932
+ index3.on(["rating"])
1933
+ ],
1934
+ enums: [CardRatingEnum]
1935
+ });
1936
+ var CardScheduleEntity = defineEntity3({
1937
+ name: "CardSchedule",
1938
+ description: "SRS schedule for a learner/card pair.",
1939
+ schema: "lssm_learning",
1940
+ map: "card_schedule",
1941
+ fields: {
1942
+ id: field3.id({ description: "Unique schedule identifier" }),
1943
+ learnerId: field3.foreignKey({ description: "Learner" }),
1944
+ cardId: field3.foreignKey({ description: "Card" }),
1945
+ interval: field3.int({
1946
+ default: 0,
1947
+ description: "Current interval in days"
1948
+ }),
1949
+ easeFactor: field3.decimal({
1950
+ default: 2.5,
1951
+ description: "Ease factor (SM-2)"
1952
+ }),
1953
+ repetitions: field3.int({
1954
+ default: 0,
1955
+ description: "Number of successful repetitions"
1956
+ }),
1957
+ nextReviewAt: field3.dateTime({ description: "When next review is due" }),
1958
+ lastReviewAt: field3.dateTime({
1959
+ isOptional: true,
1960
+ description: "When last reviewed"
1961
+ }),
1962
+ learningStep: field3.int({
1963
+ default: 0,
1964
+ description: "Current learning step"
1965
+ }),
1966
+ isGraduated: field3.boolean({
1967
+ default: false,
1968
+ description: "Whether card has graduated"
1969
+ }),
1970
+ isRelearning: field3.boolean({
1971
+ default: false,
1972
+ description: "Whether card is being relearned"
1973
+ }),
1974
+ lapses: field3.int({
1975
+ default: 0,
1976
+ description: "Number of times card was forgotten"
1977
+ }),
1978
+ reviewCount: field3.int({ default: 0, description: "Total review count" }),
1979
+ createdAt: field3.createdAt(),
1980
+ updatedAt: field3.updatedAt(),
1981
+ learner: field3.belongsTo("Learner", ["learnerId"], ["id"], {
1982
+ onDelete: "Cascade"
1983
+ }),
1984
+ card: field3.belongsTo("Card", ["cardId"], ["id"], { onDelete: "Cascade" })
1985
+ },
1986
+ indexes: [
1987
+ index3.unique(["learnerId", "cardId"], { name: "card_schedule_unique" }),
1988
+ index3.on(["learnerId", "nextReviewAt"]),
1989
+ index3.on(["nextReviewAt"])
1990
+ ]
1991
+ });
1992
+ var flashcardEntities = [
1993
+ DeckEntity,
1994
+ CardEntity,
1995
+ CardReviewEntity,
1996
+ CardScheduleEntity
1997
+ ];
1998
+ var flashcardEnums = [CardRatingEnum];
1999
+
2000
+ // src/entities/gamification.ts
2001
+ import {
2002
+ defineEntity as defineEntity4,
2003
+ defineEntityEnum as defineEntityEnum4,
2004
+ field as field4,
2005
+ index as index4
2006
+ } from "@contractspec/lib.schema";
2007
+ var AchievementTypeEnum = defineEntityEnum4({
2008
+ name: "AchievementType",
2009
+ values: [
2010
+ "MILESTONE",
2011
+ "STREAK",
2012
+ "SKILL",
2013
+ "SOCIAL",
2014
+ "SPECIAL",
2015
+ "SEASONAL"
2016
+ ],
2017
+ schema: "lssm_learning",
2018
+ description: "Type of achievement."
2019
+ });
2020
+ var LeaderboardPeriodEnum = defineEntityEnum4({
2021
+ name: "LeaderboardPeriod",
2022
+ values: ["DAILY", "WEEKLY", "MONTHLY", "ALL_TIME"],
2023
+ schema: "lssm_learning",
2024
+ description: "Leaderboard time period."
2025
+ });
2026
+ var AchievementEntity = defineEntity4({
2027
+ name: "Achievement",
2028
+ description: "An achievement that can be unlocked.",
2029
+ schema: "lssm_learning",
2030
+ map: "achievement",
2031
+ fields: {
2032
+ id: field4.id({ description: "Unique achievement identifier" }),
2033
+ key: field4.string({ isUnique: true, description: "Achievement key" }),
2034
+ name: field4.string({ description: "Achievement name" }),
2035
+ description: field4.string({ description: "Achievement description" }),
2036
+ icon: field4.string({ isOptional: true, description: "Icon name or URL" }),
2037
+ color: field4.string({ isOptional: true, description: "Display color" }),
2038
+ badgeUrl: field4.string({
2039
+ isOptional: true,
2040
+ description: "Badge image URL"
2041
+ }),
2042
+ type: field4.enum("AchievementType", {
2043
+ default: "MILESTONE",
2044
+ description: "Achievement type"
2045
+ }),
2046
+ category: field4.string({
2047
+ isOptional: true,
2048
+ description: "Achievement category"
2049
+ }),
2050
+ rarity: field4.string({
2051
+ default: '"common"',
2052
+ description: "Rarity: common, rare, epic, legendary"
2053
+ }),
2054
+ xpReward: field4.int({ default: 50, description: "XP awarded" }),
2055
+ condition: field4.json({ description: "Unlock condition" }),
2056
+ order: field4.int({ default: 0, description: "Display order" }),
2057
+ isHidden: field4.boolean({
2058
+ default: false,
2059
+ description: "Hide until unlocked"
2060
+ }),
2061
+ isActive: field4.boolean({
2062
+ default: true,
2063
+ description: "Whether achievement is active"
2064
+ }),
2065
+ orgId: field4.string({
2066
+ isOptional: true,
2067
+ description: "Organization scope"
2068
+ }),
2069
+ metadata: field4.json({
2070
+ isOptional: true,
2071
+ description: "Additional metadata"
2072
+ }),
2073
+ createdAt: field4.createdAt(),
2074
+ updatedAt: field4.updatedAt(),
2075
+ learnerAchievements: field4.hasMany("LearnerAchievement")
2076
+ },
2077
+ indexes: [
2078
+ index4.on(["type"]),
2079
+ index4.on(["category"]),
2080
+ index4.on(["isActive"]),
2081
+ index4.on(["orgId"])
2082
+ ],
2083
+ enums: [AchievementTypeEnum]
2084
+ });
2085
+ var LearnerAchievementEntity = defineEntity4({
2086
+ name: "LearnerAchievement",
2087
+ description: "An achievement unlocked by a learner.",
2088
+ schema: "lssm_learning",
2089
+ map: "learner_achievement",
2090
+ fields: {
2091
+ id: field4.id({ description: "Unique record identifier" }),
2092
+ learnerId: field4.foreignKey({ description: "Learner" }),
2093
+ achievementId: field4.foreignKey({ description: "Achievement" }),
2094
+ xpEarned: field4.int({ default: 0, description: "XP earned" }),
2095
+ progress: field4.int({ default: 100, description: "Progress percentage" }),
2096
+ currentValue: field4.int({
2097
+ isOptional: true,
2098
+ description: "Current value towards goal"
2099
+ }),
2100
+ targetValue: field4.int({
2101
+ isOptional: true,
2102
+ description: "Target value for completion"
2103
+ }),
2104
+ unlockedAt: field4.dateTime({ description: "When unlocked" }),
2105
+ createdAt: field4.createdAt(),
2106
+ learner: field4.belongsTo("Learner", ["learnerId"], ["id"], {
2107
+ onDelete: "Cascade"
2108
+ }),
2109
+ achievement: field4.belongsTo("Achievement", ["achievementId"], ["id"], {
2110
+ onDelete: "Cascade"
2111
+ })
2112
+ },
2113
+ indexes: [
2114
+ index4.unique(["learnerId", "achievementId"], {
2115
+ name: "learner_achievement_unique"
2116
+ }),
2117
+ index4.on(["learnerId", "unlockedAt"]),
2118
+ index4.on(["achievementId"])
2119
+ ]
2120
+ });
2121
+ var StreakEntity = defineEntity4({
2122
+ name: "Streak",
2123
+ description: "Tracks daily learning streaks.",
2124
+ schema: "lssm_learning",
2125
+ map: "streak",
2126
+ fields: {
2127
+ id: field4.id({ description: "Unique streak identifier" }),
2128
+ learnerId: field4.foreignKey({ description: "Learner" }),
2129
+ currentStreak: field4.int({
2130
+ default: 0,
2131
+ description: "Current streak days"
2132
+ }),
2133
+ longestStreak: field4.int({
2134
+ default: 0,
2135
+ description: "Longest streak ever"
2136
+ }),
2137
+ lastActivityAt: field4.dateTime({
2138
+ isOptional: true,
2139
+ description: "Last learning activity"
2140
+ }),
2141
+ lastActivityDate: field4.string({
2142
+ isOptional: true,
2143
+ description: "Last activity date (YYYY-MM-DD)"
2144
+ }),
2145
+ freezesRemaining: field4.int({
2146
+ default: 0,
2147
+ description: "Streak freezes available"
2148
+ }),
2149
+ freezeUsedAt: field4.dateTime({
2150
+ isOptional: true,
2151
+ description: "When last freeze was used"
2152
+ }),
2153
+ streakHistory: field4.json({
2154
+ isOptional: true,
2155
+ description: "Historical streak data"
2156
+ }),
2157
+ createdAt: field4.createdAt(),
2158
+ updatedAt: field4.updatedAt(),
2159
+ learner: field4.belongsTo("Learner", ["learnerId"], ["id"], {
2160
+ onDelete: "Cascade"
2161
+ })
2162
+ },
2163
+ indexes: [
2164
+ index4.unique(["learnerId"], { name: "streak_learner_unique" }),
2165
+ index4.on(["currentStreak"]),
2166
+ index4.on(["longestStreak"])
2167
+ ]
2168
+ });
2169
+ var DailyGoalEntity = defineEntity4({
2170
+ name: "DailyGoal",
2171
+ description: "Daily XP goal tracking.",
2172
+ schema: "lssm_learning",
2173
+ map: "daily_goal",
2174
+ fields: {
2175
+ id: field4.id({ description: "Unique goal identifier" }),
2176
+ learnerId: field4.foreignKey({ description: "Learner" }),
2177
+ date: field4.string({ description: "Date (YYYY-MM-DD)" }),
2178
+ targetXp: field4.int({ description: "Target XP for the day" }),
2179
+ currentXp: field4.int({ default: 0, description: "XP earned today" }),
2180
+ isCompleted: field4.boolean({
2181
+ default: false,
2182
+ description: "Whether goal was met"
2183
+ }),
2184
+ completedAt: field4.dateTime({
2185
+ isOptional: true,
2186
+ description: "When goal was completed"
2187
+ }),
2188
+ xpBreakdown: field4.json({
2189
+ isOptional: true,
2190
+ description: "XP sources breakdown"
2191
+ }),
2192
+ createdAt: field4.createdAt(),
2193
+ updatedAt: field4.updatedAt(),
2194
+ learner: field4.belongsTo("Learner", ["learnerId"], ["id"], {
2195
+ onDelete: "Cascade"
2196
+ })
2197
+ },
2198
+ indexes: [
2199
+ index4.unique(["learnerId", "date"], { name: "daily_goal_unique" }),
2200
+ index4.on(["date", "isCompleted"])
2201
+ ]
2202
+ });
2203
+ var LeaderboardEntryEntity = defineEntity4({
2204
+ name: "LeaderboardEntry",
2205
+ description: "Leaderboard entry for a learner.",
2206
+ schema: "lssm_learning",
2207
+ map: "leaderboard_entry",
2208
+ fields: {
2209
+ id: field4.id({ description: "Unique entry identifier" }),
2210
+ learnerId: field4.foreignKey({ description: "Learner" }),
2211
+ periodType: field4.enum("LeaderboardPeriod", { description: "Period type" }),
2212
+ periodKey: field4.string({ description: "Period key (e.g., 2024-W01)" }),
2213
+ xp: field4.int({ default: 0, description: "XP earned in period" }),
2214
+ rank: field4.int({ isOptional: true, description: "Rank in leaderboard" }),
2215
+ lessonsCompleted: field4.int({
2216
+ default: 0,
2217
+ description: "Lessons completed"
2218
+ }),
2219
+ quizzesPassed: field4.int({ default: 0, description: "Quizzes passed" }),
2220
+ cardsReviewed: field4.int({ default: 0, description: "Cards reviewed" }),
2221
+ streakDays: field4.int({ default: 0, description: "Streak days in period" }),
2222
+ league: field4.string({ isOptional: true, description: "League tier" }),
2223
+ orgId: field4.string({
2224
+ isOptional: true,
2225
+ description: "Organization scope"
2226
+ }),
2227
+ createdAt: field4.createdAt(),
2228
+ updatedAt: field4.updatedAt(),
2229
+ learner: field4.belongsTo("Learner", ["learnerId"], ["id"], {
2230
+ onDelete: "Cascade"
2231
+ })
2232
+ },
2233
+ indexes: [
2234
+ index4.unique(["learnerId", "periodType", "periodKey"], {
2235
+ name: "leaderboard_entry_unique"
2236
+ }),
2237
+ index4.on(["periodType", "periodKey", "xp"]),
2238
+ index4.on(["orgId", "periodType", "periodKey", "xp"])
2239
+ ],
2240
+ enums: [LeaderboardPeriodEnum]
2241
+ });
2242
+ var HeartEntity = defineEntity4({
2243
+ name: "Heart",
2244
+ description: "Lives/hearts system for quiz attempts.",
2245
+ schema: "lssm_learning",
2246
+ map: "heart",
2247
+ fields: {
2248
+ id: field4.id({ description: "Unique heart record identifier" }),
2249
+ learnerId: field4.foreignKey({ description: "Learner" }),
2250
+ current: field4.int({ default: 5, description: "Current hearts" }),
2251
+ max: field4.int({ default: 5, description: "Maximum hearts" }),
2252
+ lastRefillAt: field4.dateTime({
2253
+ isOptional: true,
2254
+ description: "Last refill time"
2255
+ }),
2256
+ nextRefillAt: field4.dateTime({
2257
+ isOptional: true,
2258
+ description: "Next refill time"
2259
+ }),
2260
+ refillIntervalMinutes: field4.int({
2261
+ default: 240,
2262
+ description: "Minutes between refills"
2263
+ }),
2264
+ infiniteUntil: field4.dateTime({
2265
+ isOptional: true,
2266
+ description: "Infinite hearts until"
2267
+ }),
2268
+ createdAt: field4.createdAt(),
2269
+ updatedAt: field4.updatedAt(),
2270
+ learner: field4.belongsTo("Learner", ["learnerId"], ["id"], {
2271
+ onDelete: "Cascade"
2272
+ })
2273
+ },
2274
+ indexes: [
2275
+ index4.unique(["learnerId"], { name: "heart_learner_unique" }),
2276
+ index4.on(["nextRefillAt"])
2277
+ ]
2278
+ });
2279
+ var XPTransactionEntity = defineEntity4({
2280
+ name: "XPTransaction",
2281
+ description: "Record of XP earned or spent.",
2282
+ schema: "lssm_learning",
2283
+ map: "xp_transaction",
2284
+ fields: {
2285
+ id: field4.id({ description: "Unique transaction identifier" }),
2286
+ learnerId: field4.foreignKey({ description: "Learner" }),
2287
+ amount: field4.int({
2288
+ description: "XP amount (positive = earned, negative = spent)"
2289
+ }),
2290
+ type: field4.string({
2291
+ description: "Transaction type (lesson, quiz, streak, achievement, etc.)"
2292
+ }),
2293
+ sourceType: field4.string({
2294
+ isOptional: true,
2295
+ description: "Source entity type"
2296
+ }),
2297
+ sourceId: field4.string({
2298
+ isOptional: true,
2299
+ description: "Source entity ID"
2300
+ }),
2301
+ description: field4.string({
2302
+ isOptional: true,
2303
+ description: "Human-readable description"
2304
+ }),
2305
+ balanceAfter: field4.int({ description: "Total XP after transaction" }),
2306
+ createdAt: field4.createdAt(),
2307
+ learner: field4.belongsTo("Learner", ["learnerId"], ["id"], {
2308
+ onDelete: "Cascade"
2309
+ })
2310
+ },
2311
+ indexes: [
2312
+ index4.on(["learnerId", "createdAt"]),
2313
+ index4.on(["type"]),
2314
+ index4.on(["sourceType", "sourceId"])
2315
+ ]
2316
+ });
2317
+ var gamificationEntities = [
2318
+ AchievementEntity,
2319
+ LearnerAchievementEntity,
2320
+ StreakEntity,
2321
+ DailyGoalEntity,
2322
+ LeaderboardEntryEntity,
2323
+ HeartEntity,
2324
+ XPTransactionEntity
2325
+ ];
2326
+ var gamificationEnums = [AchievementTypeEnum, LeaderboardPeriodEnum];
2327
+
2328
+ // src/entities/learner.ts
2329
+ import {
2330
+ defineEntity as defineEntity5,
2331
+ defineEntityEnum as defineEntityEnum5,
2332
+ field as field5,
2333
+ index as index5
2334
+ } from "@contractspec/lib.schema";
2335
+ var EnrollmentStatusEnum = defineEntityEnum5({
2336
+ name: "EnrollmentStatus",
2337
+ values: [
2338
+ "ENROLLED",
2339
+ "IN_PROGRESS",
2340
+ "COMPLETED",
2341
+ "DROPPED",
2342
+ "EXPIRED"
2343
+ ],
2344
+ schema: "lssm_learning",
2345
+ description: "Status of a course enrollment."
2346
+ });
2347
+ var ProgressStatusEnum = defineEntityEnum5({
2348
+ name: "ProgressStatus",
2349
+ values: ["NOT_STARTED", "IN_PROGRESS", "COMPLETED", "SKIPPED"],
2350
+ schema: "lssm_learning",
2351
+ description: "Status of lesson progress."
2352
+ });
2353
+ var LearnerEntity = defineEntity5({
2354
+ name: "Learner",
2355
+ description: "A learner profile.",
2356
+ schema: "lssm_learning",
2357
+ map: "learner",
2358
+ fields: {
2359
+ id: field5.id({ description: "Unique learner identifier" }),
2360
+ userId: field5.string({ isUnique: true, description: "Associated user ID" }),
2361
+ displayName: field5.string({
2362
+ isOptional: true,
2363
+ description: "Display name"
2364
+ }),
2365
+ avatarUrl: field5.string({ isOptional: true, description: "Avatar URL" }),
2366
+ bio: field5.string({ isOptional: true, description: "Short bio" }),
2367
+ level: field5.int({ default: 1, description: "Current level" }),
2368
+ totalXp: field5.int({ default: 0, description: "Total XP earned" }),
2369
+ currentStreak: field5.int({
2370
+ default: 0,
2371
+ description: "Current streak days"
2372
+ }),
2373
+ longestStreak: field5.int({
2374
+ default: 0,
2375
+ description: "Longest streak ever"
2376
+ }),
2377
+ lastActivityAt: field5.dateTime({
2378
+ isOptional: true,
2379
+ description: "Last learning activity"
2380
+ }),
2381
+ timezone: field5.string({
2382
+ default: '"UTC"',
2383
+ description: "Learner timezone"
2384
+ }),
2385
+ dailyGoalXp: field5.int({ default: 50, description: "Daily XP goal" }),
2386
+ reminderEnabled: field5.boolean({
2387
+ default: true,
2388
+ description: "Enable reminders"
2389
+ }),
2390
+ reminderTime: field5.string({
2391
+ isOptional: true,
2392
+ description: "Preferred reminder time"
2393
+ }),
2394
+ orgId: field5.string({
2395
+ isOptional: true,
2396
+ description: "Organization scope"
2397
+ }),
2398
+ metadata: field5.json({
2399
+ isOptional: true,
2400
+ description: "Additional metadata"
2401
+ }),
2402
+ createdAt: field5.createdAt(),
2403
+ updatedAt: field5.updatedAt(),
2404
+ enrollments: field5.hasMany("Enrollment"),
2405
+ lessonProgress: field5.hasMany("LessonProgress"),
2406
+ achievements: field5.hasMany("LearnerAchievement"),
2407
+ decks: field5.hasMany("Deck"),
2408
+ profile: field5.hasOne("LearnerProfile")
2409
+ },
2410
+ indexes: [
2411
+ index5.on(["orgId"]),
2412
+ index5.on(["totalXp"]),
2413
+ index5.on(["level"]),
2414
+ index5.on(["currentStreak"])
2415
+ ]
2416
+ });
2417
+ var EnrollmentEntity = defineEntity5({
2418
+ name: "Enrollment",
2419
+ description: "A learner enrollment in a course.",
2420
+ schema: "lssm_learning",
2421
+ map: "enrollment",
2422
+ fields: {
2423
+ id: field5.id({ description: "Unique enrollment identifier" }),
2424
+ learnerId: field5.foreignKey({ description: "Enrolled learner" }),
2425
+ courseId: field5.foreignKey({ description: "Enrolled course" }),
2426
+ status: field5.enum("EnrollmentStatus", {
2427
+ default: "ENROLLED",
2428
+ description: "Enrollment status"
2429
+ }),
2430
+ progress: field5.int({
2431
+ default: 0,
2432
+ description: "Completion percentage (0-100)"
2433
+ }),
2434
+ completedLessons: field5.int({
2435
+ default: 0,
2436
+ description: "Number of completed lessons"
2437
+ }),
2438
+ totalLessons: field5.int({
2439
+ default: 0,
2440
+ description: "Total lessons in course"
2441
+ }),
2442
+ xpEarned: field5.int({
2443
+ default: 0,
2444
+ description: "XP earned in this course"
2445
+ }),
2446
+ startedAt: field5.dateTime({
2447
+ isOptional: true,
2448
+ description: "When learner started"
2449
+ }),
2450
+ completedAt: field5.dateTime({
2451
+ isOptional: true,
2452
+ description: "When learner completed"
2453
+ }),
2454
+ lastAccessedAt: field5.dateTime({
2455
+ isOptional: true,
2456
+ description: "Last access time"
2457
+ }),
2458
+ certificateId: field5.string({
2459
+ isOptional: true,
2460
+ description: "Issued certificate ID"
2461
+ }),
2462
+ metadata: field5.json({
2463
+ isOptional: true,
2464
+ description: "Additional metadata"
2465
+ }),
2466
+ createdAt: field5.createdAt(),
2467
+ updatedAt: field5.updatedAt(),
2468
+ learner: field5.belongsTo("Learner", ["learnerId"], ["id"], {
2469
+ onDelete: "Cascade"
2470
+ }),
2471
+ course: field5.belongsTo("Course", ["courseId"], ["id"], {
2472
+ onDelete: "Cascade"
2473
+ })
2474
+ },
2475
+ indexes: [
2476
+ index5.unique(["learnerId", "courseId"], { name: "enrollment_unique" }),
2477
+ index5.on(["learnerId", "status"]),
2478
+ index5.on(["courseId", "status"])
2479
+ ],
2480
+ enums: [EnrollmentStatusEnum]
2481
+ });
2482
+ var LessonProgressEntity = defineEntity5({
2483
+ name: "LessonProgress",
2484
+ description: "Progress tracking for a lesson.",
2485
+ schema: "lssm_learning",
2486
+ map: "lesson_progress",
2487
+ fields: {
2488
+ id: field5.id({ description: "Unique progress identifier" }),
2489
+ learnerId: field5.foreignKey({ description: "Learner" }),
2490
+ lessonId: field5.foreignKey({ description: "Lesson" }),
2491
+ status: field5.enum("ProgressStatus", {
2492
+ default: "NOT_STARTED",
2493
+ description: "Progress status"
2494
+ }),
2495
+ progress: field5.int({
2496
+ default: 0,
2497
+ description: "Completion percentage (0-100)"
2498
+ }),
2499
+ score: field5.int({
2500
+ isOptional: true,
2501
+ description: "Score achieved (for quizzes)"
2502
+ }),
2503
+ attempts: field5.int({ default: 0, description: "Number of attempts" }),
2504
+ bestScore: field5.int({
2505
+ isOptional: true,
2506
+ description: "Best score across attempts"
2507
+ }),
2508
+ timeSpent: field5.int({ default: 0, description: "Time spent in seconds" }),
2509
+ xpEarned: field5.int({
2510
+ default: 0,
2511
+ description: "XP earned from this lesson"
2512
+ }),
2513
+ startedAt: field5.dateTime({
2514
+ isOptional: true,
2515
+ description: "When started"
2516
+ }),
2517
+ completedAt: field5.dateTime({
2518
+ isOptional: true,
2519
+ description: "When completed"
2520
+ }),
2521
+ lastAccessedAt: field5.dateTime({
2522
+ isOptional: true,
2523
+ description: "Last access time"
2524
+ }),
2525
+ bookmarks: field5.json({
2526
+ isOptional: true,
2527
+ description: "Content bookmarks"
2528
+ }),
2529
+ notes: field5.string({ isOptional: true, description: "Learner notes" }),
2530
+ createdAt: field5.createdAt(),
2531
+ updatedAt: field5.updatedAt(),
2532
+ learner: field5.belongsTo("Learner", ["learnerId"], ["id"], {
2533
+ onDelete: "Cascade"
2534
+ }),
2535
+ lesson: field5.belongsTo("Lesson", ["lessonId"], ["id"], {
2536
+ onDelete: "Cascade"
2537
+ })
2538
+ },
2539
+ indexes: [
2540
+ index5.unique(["learnerId", "lessonId"], { name: "lesson_progress_unique" }),
2541
+ index5.on(["learnerId", "status"]),
2542
+ index5.on(["lessonId"])
2543
+ ],
2544
+ enums: [ProgressStatusEnum]
2545
+ });
2546
+ var ModuleCompletionEntity = defineEntity5({
2547
+ name: "ModuleCompletion",
2548
+ description: "Module completion record.",
2549
+ schema: "lssm_learning",
2550
+ map: "module_completion",
2551
+ fields: {
2552
+ id: field5.id({ description: "Unique completion identifier" }),
2553
+ learnerId: field5.foreignKey({ description: "Learner" }),
2554
+ moduleId: field5.foreignKey({ description: "Module" }),
2555
+ score: field5.int({ isOptional: true, description: "Average score" }),
2556
+ xpEarned: field5.int({ default: 0, description: "XP earned" }),
2557
+ timeSpent: field5.int({ default: 0, description: "Time spent in seconds" }),
2558
+ completedAt: field5.dateTime({ description: "When completed" }),
2559
+ createdAt: field5.createdAt(),
2560
+ learner: field5.belongsTo("Learner", ["learnerId"], ["id"], {
2561
+ onDelete: "Cascade"
2562
+ }),
2563
+ module: field5.belongsTo("CourseModule", ["moduleId"], ["id"], {
2564
+ onDelete: "Cascade"
2565
+ })
2566
+ },
2567
+ indexes: [
2568
+ index5.unique(["learnerId", "moduleId"], {
2569
+ name: "module_completion_unique"
2570
+ }),
2571
+ index5.on(["learnerId", "completedAt"])
2572
+ ]
2573
+ });
2574
+ var CertificateEntity = defineEntity5({
2575
+ name: "Certificate",
2576
+ description: "Course completion certificate.",
2577
+ schema: "lssm_learning",
2578
+ map: "certificate",
2579
+ fields: {
2580
+ id: field5.id({ description: "Unique certificate identifier" }),
2581
+ learnerId: field5.foreignKey({ description: "Certificate holder" }),
2582
+ courseId: field5.foreignKey({ description: "Completed course" }),
2583
+ enrollmentId: field5.foreignKey({ description: "Associated enrollment" }),
2584
+ certificateNumber: field5.string({
2585
+ isUnique: true,
2586
+ description: "Unique certificate number"
2587
+ }),
2588
+ title: field5.string({ description: "Certificate title" }),
2589
+ description: field5.string({
2590
+ isOptional: true,
2591
+ description: "Certificate description"
2592
+ }),
2593
+ score: field5.int({ isOptional: true, description: "Final score" }),
2594
+ grade: field5.string({ isOptional: true, description: "Grade awarded" }),
2595
+ issuedAt: field5.dateTime({ description: "When issued" }),
2596
+ validUntil: field5.dateTime({
2597
+ isOptional: true,
2598
+ description: "Expiration date"
2599
+ }),
2600
+ verificationUrl: field5.string({
2601
+ isOptional: true,
2602
+ description: "Verification URL"
2603
+ }),
2604
+ credentialHash: field5.string({
2605
+ isOptional: true,
2606
+ description: "Credential hash for verification"
2607
+ }),
2608
+ isRevoked: field5.boolean({
2609
+ default: false,
2610
+ description: "Whether certificate is revoked"
2611
+ }),
2612
+ revokedAt: field5.dateTime({
2613
+ isOptional: true,
2614
+ description: "When revoked"
2615
+ }),
2616
+ revokedReason: field5.string({
2617
+ isOptional: true,
2618
+ description: "Revocation reason"
2619
+ }),
2620
+ metadata: field5.json({
2621
+ isOptional: true,
2622
+ description: "Additional metadata"
2623
+ }),
2624
+ createdAt: field5.createdAt(),
2625
+ learner: field5.belongsTo("Learner", ["learnerId"], ["id"], {
2626
+ onDelete: "Cascade"
2627
+ }),
2628
+ course: field5.belongsTo("Course", ["courseId"], ["id"], {
2629
+ onDelete: "Cascade"
2630
+ })
2631
+ },
2632
+ indexes: [
2633
+ index5.on(["learnerId"]),
2634
+ index5.on(["courseId"]),
2635
+ index5.on(["issuedAt"])
2636
+ ]
2637
+ });
2638
+ var learnerEntities = [
2639
+ LearnerEntity,
2640
+ EnrollmentEntity,
2641
+ LessonProgressEntity,
2642
+ ModuleCompletionEntity,
2643
+ CertificateEntity
2644
+ ];
2645
+ var learnerEnums = [EnrollmentStatusEnum, ProgressStatusEnum];
2646
+
2647
+ // src/entities/onboarding.ts
2648
+ import {
2649
+ defineEntity as defineEntity6,
2650
+ defineEntityEnum as defineEntityEnum6,
2651
+ field as field6,
2652
+ index as index6
2653
+ } from "@contractspec/lib.schema";
2654
+ var OnboardingStepStatusEnum = defineEntityEnum6({
2655
+ name: "OnboardingStepStatus",
2656
+ values: ["PENDING", "IN_PROGRESS", "COMPLETED", "SKIPPED"],
2657
+ schema: "lssm_learning",
2658
+ description: "Status of an onboarding step."
2659
+ });
2660
+ var OnboardingTrackEntity = defineEntity6({
2661
+ name: "OnboardingTrack",
2662
+ description: "An onboarding track for a product.",
2663
+ schema: "lssm_learning",
2664
+ map: "onboarding_track",
2665
+ fields: {
2666
+ id: field6.id({ description: "Unique track identifier" }),
2667
+ productId: field6.string({ description: "Product this track is for" }),
2668
+ name: field6.string({ description: "Track name" }),
2669
+ description: field6.string({
2670
+ isOptional: true,
2671
+ description: "Track description"
2672
+ }),
2673
+ targetUserSegment: field6.string({
2674
+ isOptional: true,
2675
+ description: "Target user segment"
2676
+ }),
2677
+ targetRole: field6.string({
2678
+ isOptional: true,
2679
+ description: "Target user role"
2680
+ }),
2681
+ welcomeTitle: field6.string({
2682
+ isOptional: true,
2683
+ description: "Welcome message title"
2684
+ }),
2685
+ welcomeMessage: field6.string({
2686
+ isOptional: true,
2687
+ description: "Welcome message"
2688
+ }),
2689
+ completionTitle: field6.string({
2690
+ isOptional: true,
2691
+ description: "Completion message title"
2692
+ }),
2693
+ completionMessage: field6.string({
2694
+ isOptional: true,
2695
+ description: "Completion message"
2696
+ }),
2697
+ isActive: field6.boolean({
2698
+ default: true,
2699
+ description: "Whether track is active"
2700
+ }),
2701
+ isRequired: field6.boolean({
2702
+ default: false,
2703
+ description: "Whether track is required"
2704
+ }),
2705
+ canSkip: field6.boolean({
2706
+ default: true,
2707
+ description: "Whether steps can be skipped"
2708
+ }),
2709
+ totalXp: field6.int({
2710
+ default: 100,
2711
+ description: "Total XP for completing track"
2712
+ }),
2713
+ completionXpBonus: field6.int({
2714
+ isOptional: true,
2715
+ description: "Bonus XP for completing track"
2716
+ }),
2717
+ completionBadgeKey: field6.string({
2718
+ isOptional: true,
2719
+ description: "Badge awarded on completion"
2720
+ }),
2721
+ streakHoursWindow: field6.int({
2722
+ isOptional: true,
2723
+ description: "Hours window to finish for streak bonus"
2724
+ }),
2725
+ streakBonusXp: field6.int({
2726
+ isOptional: true,
2727
+ description: "Bonus XP if completed within streak window"
2728
+ }),
2729
+ orgId: field6.string({
2730
+ isOptional: true,
2731
+ description: "Organization scope"
2732
+ }),
2733
+ metadata: field6.json({
2734
+ isOptional: true,
2735
+ description: "Additional metadata"
2736
+ }),
2737
+ createdAt: field6.createdAt(),
2738
+ updatedAt: field6.updatedAt(),
2739
+ steps: field6.hasMany("OnboardingStep"),
2740
+ progress: field6.hasMany("OnboardingProgress")
2741
+ },
2742
+ indexes: [
2743
+ index6.on(["productId", "isActive"]),
2744
+ index6.on(["orgId"]),
2745
+ index6.unique(["productId", "targetUserSegment", "targetRole"], {
2746
+ name: "onboarding_track_target"
2747
+ })
2748
+ ]
2749
+ });
2750
+ var OnboardingStepEntity = defineEntity6({
2751
+ name: "OnboardingStep",
2752
+ description: "A step in an onboarding track.",
2753
+ schema: "lssm_learning",
2754
+ map: "onboarding_step",
2755
+ fields: {
2756
+ id: field6.id({ description: "Unique step identifier" }),
2757
+ trackId: field6.foreignKey({ description: "Parent track" }),
2758
+ title: field6.string({ description: "Step title" }),
2759
+ description: field6.string({
2760
+ isOptional: true,
2761
+ description: "Step description"
2762
+ }),
2763
+ instructions: field6.string({
2764
+ isOptional: true,
2765
+ description: "How to complete the step"
2766
+ }),
2767
+ helpUrl: field6.string({
2768
+ isOptional: true,
2769
+ description: "Link to help documentation"
2770
+ }),
2771
+ order: field6.int({ default: 0, description: "Display order" }),
2772
+ triggerEvent: field6.string({
2773
+ isOptional: true,
2774
+ description: "Event that triggers step start"
2775
+ }),
2776
+ completionEvent: field6.string({
2777
+ description: "Event that completes the step"
2778
+ }),
2779
+ completionEventVersion: field6.int({
2780
+ isOptional: true,
2781
+ description: "Version of the completion event"
2782
+ }),
2783
+ completionSourceModule: field6.string({
2784
+ isOptional: true,
2785
+ description: "Module emitting the completion event"
2786
+ }),
2787
+ completionEventFilter: field6.json({
2788
+ isOptional: true,
2789
+ description: "Filter for completion event"
2790
+ }),
2791
+ actionUrl: field6.string({
2792
+ isOptional: true,
2793
+ description: "URL to navigate to complete"
2794
+ }),
2795
+ actionLabel: field6.string({
2796
+ isOptional: true,
2797
+ description: "Action button label"
2798
+ }),
2799
+ highlightSelector: field6.string({
2800
+ isOptional: true,
2801
+ description: "CSS selector to highlight"
2802
+ }),
2803
+ tooltipPosition: field6.string({
2804
+ isOptional: true,
2805
+ description: "Tooltip position"
2806
+ }),
2807
+ xpReward: field6.int({ default: 10, description: "XP for completing step" }),
2808
+ isRequired: field6.boolean({
2809
+ default: true,
2810
+ description: "Whether step is required"
2811
+ }),
2812
+ canSkip: field6.boolean({
2813
+ default: true,
2814
+ description: "Whether step can be skipped"
2815
+ }),
2816
+ metadata: field6.json({
2817
+ isOptional: true,
2818
+ description: "Additional metadata"
2819
+ }),
2820
+ createdAt: field6.createdAt(),
2821
+ updatedAt: field6.updatedAt(),
2822
+ track: field6.belongsTo("OnboardingTrack", ["trackId"], ["id"], {
2823
+ onDelete: "Cascade"
2824
+ })
2825
+ },
2826
+ indexes: [index6.on(["trackId", "order"]), index6.on(["completionEvent"])]
2827
+ });
2828
+ var OnboardingProgressEntity = defineEntity6({
2829
+ name: "OnboardingProgress",
2830
+ description: "Tracks user progress through an onboarding track.",
2831
+ schema: "lssm_learning",
2832
+ map: "onboarding_progress",
2833
+ fields: {
2834
+ id: field6.id({ description: "Unique progress identifier" }),
2835
+ learnerId: field6.foreignKey({ description: "Learner" }),
2836
+ trackId: field6.foreignKey({ description: "Onboarding track" }),
2837
+ currentStepId: field6.string({
2838
+ isOptional: true,
2839
+ description: "Current step ID"
2840
+ }),
2841
+ completedSteps: field6.json({
2842
+ default: "[]",
2843
+ description: "Array of completed step IDs"
2844
+ }),
2845
+ skippedSteps: field6.json({
2846
+ default: "[]",
2847
+ description: "Array of skipped step IDs"
2848
+ }),
2849
+ progress: field6.int({
2850
+ default: 0,
2851
+ description: "Completion percentage (0-100)"
2852
+ }),
2853
+ isCompleted: field6.boolean({
2854
+ default: false,
2855
+ description: "Whether track is completed"
2856
+ }),
2857
+ xpEarned: field6.int({ default: 0, description: "XP earned from track" }),
2858
+ startedAt: field6.dateTime({ description: "When user started" }),
2859
+ completedAt: field6.dateTime({
2860
+ isOptional: true,
2861
+ description: "When user completed"
2862
+ }),
2863
+ lastActivityAt: field6.dateTime({
2864
+ isOptional: true,
2865
+ description: "Last activity"
2866
+ }),
2867
+ isDismissed: field6.boolean({
2868
+ default: false,
2869
+ description: "Whether user dismissed onboarding"
2870
+ }),
2871
+ dismissedAt: field6.dateTime({
2872
+ isOptional: true,
2873
+ description: "When dismissed"
2874
+ }),
2875
+ metadata: field6.json({
2876
+ isOptional: true,
2877
+ description: "Additional metadata"
2878
+ }),
2879
+ createdAt: field6.createdAt(),
2880
+ updatedAt: field6.updatedAt(),
2881
+ learner: field6.belongsTo("Learner", ["learnerId"], ["id"], {
2882
+ onDelete: "Cascade"
2883
+ }),
2884
+ track: field6.belongsTo("OnboardingTrack", ["trackId"], ["id"], {
2885
+ onDelete: "Cascade"
2886
+ })
2887
+ },
2888
+ indexes: [
2889
+ index6.unique(["learnerId", "trackId"], {
2890
+ name: "onboarding_progress_unique"
2891
+ }),
2892
+ index6.on(["learnerId", "isCompleted"]),
2893
+ index6.on(["trackId"])
2894
+ ],
2895
+ enums: [OnboardingStepStatusEnum]
2896
+ });
2897
+ var OnboardingStepCompletionEntity = defineEntity6({
2898
+ name: "OnboardingStepCompletion",
2899
+ description: "Individual step completion record.",
2900
+ schema: "lssm_learning",
2901
+ map: "onboarding_step_completion",
2902
+ fields: {
2903
+ id: field6.id({ description: "Unique completion identifier" }),
2904
+ progressId: field6.foreignKey({ description: "Parent progress record" }),
2905
+ stepId: field6.foreignKey({ description: "Completed step" }),
2906
+ status: field6.enum("OnboardingStepStatus", {
2907
+ description: "Completion status"
2908
+ }),
2909
+ xpEarned: field6.int({ default: 0, description: "XP earned" }),
2910
+ triggeringEvent: field6.string({
2911
+ isOptional: true,
2912
+ description: "Event that triggered completion"
2913
+ }),
2914
+ eventPayload: field6.json({
2915
+ isOptional: true,
2916
+ description: "Event payload"
2917
+ }),
2918
+ completedAt: field6.dateTime({ description: "When completed" }),
2919
+ createdAt: field6.createdAt(),
2920
+ progress: field6.belongsTo("OnboardingProgress", ["progressId"], ["id"], {
2921
+ onDelete: "Cascade"
2922
+ }),
2923
+ step: field6.belongsTo("OnboardingStep", ["stepId"], ["id"], {
2924
+ onDelete: "Cascade"
2925
+ })
2926
+ },
2927
+ indexes: [
2928
+ index6.unique(["progressId", "stepId"], { name: "step_completion_unique" }),
2929
+ index6.on(["completedAt"])
2930
+ ]
2931
+ });
2932
+ var onboardingEntities = [
2933
+ OnboardingTrackEntity,
2934
+ OnboardingStepEntity,
2935
+ OnboardingProgressEntity,
2936
+ OnboardingStepCompletionEntity
2937
+ ];
2938
+ var onboardingEnums = [OnboardingStepStatusEnum];
2939
+
2940
+ // src/entities/quiz.ts
2941
+ import {
2942
+ defineEntity as defineEntity7,
2943
+ defineEntityEnum as defineEntityEnum7,
2944
+ field as field7,
2945
+ index as index7
2946
+ } from "@contractspec/lib.schema";
2947
+ var QuestionTypeEnum = defineEntityEnum7({
2948
+ name: "QuestionType",
2949
+ values: [
2950
+ "MULTIPLE_CHOICE",
2951
+ "TRUE_FALSE",
2952
+ "FILL_BLANK",
2953
+ "MATCHING",
2954
+ "SHORT_ANSWER",
2955
+ "CODE"
2956
+ ],
2957
+ schema: "lssm_learning",
2958
+ description: "Type of quiz question."
2959
+ });
2960
+ var QuizStatusEnum = defineEntityEnum7({
2961
+ name: "QuizStatus",
2962
+ values: ["DRAFT", "PUBLISHED", "ARCHIVED"],
2963
+ schema: "lssm_learning",
2964
+ description: "Publication status of a quiz."
2965
+ });
2966
+ var AttemptStatusEnum = defineEntityEnum7({
2967
+ name: "AttemptStatus",
2968
+ values: ["IN_PROGRESS", "COMPLETED", "TIMED_OUT", "ABANDONED"],
2969
+ schema: "lssm_learning",
2970
+ description: "Status of a quiz attempt."
2971
+ });
2972
+ var QuizEntity = defineEntity7({
2973
+ name: "Quiz",
2974
+ description: "A quiz assessment.",
2975
+ schema: "lssm_learning",
2976
+ map: "quiz",
2977
+ fields: {
2978
+ id: field7.id({ description: "Unique quiz identifier" }),
2979
+ lessonId: field7.foreignKey({
2980
+ isOptional: true,
2981
+ description: "Associated lesson"
2982
+ }),
2983
+ title: field7.string({ description: "Quiz title" }),
2984
+ description: field7.string({
2985
+ isOptional: true,
2986
+ description: "Quiz description"
2987
+ }),
2988
+ instructions: field7.string({
2989
+ isOptional: true,
2990
+ description: "Quiz instructions"
2991
+ }),
2992
+ passingScore: field7.int({
2993
+ default: 70,
2994
+ description: "Passing score percentage"
2995
+ }),
2996
+ timeLimit: field7.int({
2997
+ isOptional: true,
2998
+ description: "Time limit in seconds"
2999
+ }),
3000
+ maxAttempts: field7.int({
3001
+ isOptional: true,
3002
+ description: "Maximum attempts allowed"
3003
+ }),
3004
+ shuffleQuestions: field7.boolean({
3005
+ default: false,
3006
+ description: "Shuffle question order"
3007
+ }),
3008
+ shuffleOptions: field7.boolean({
3009
+ default: false,
3010
+ description: "Shuffle answer options"
3011
+ }),
3012
+ showCorrectAnswers: field7.boolean({
3013
+ default: true,
3014
+ description: "Show correct answers after"
3015
+ }),
3016
+ showExplanations: field7.boolean({
3017
+ default: true,
3018
+ description: "Show explanations after"
3019
+ }),
3020
+ status: field7.enum("QuizStatus", {
3021
+ default: "DRAFT",
3022
+ description: "Publication status"
3023
+ }),
3024
+ totalPoints: field7.int({
3025
+ default: 0,
3026
+ description: "Total points available"
3027
+ }),
3028
+ xpReward: field7.int({ default: 20, description: "XP for passing" }),
3029
+ orgId: field7.string({
3030
+ isOptional: true,
3031
+ description: "Organization scope"
3032
+ }),
3033
+ metadata: field7.json({
3034
+ isOptional: true,
3035
+ description: "Additional metadata"
3036
+ }),
3037
+ createdAt: field7.createdAt(),
3038
+ updatedAt: field7.updatedAt(),
3039
+ lesson: field7.belongsTo("Lesson", ["lessonId"], ["id"], {
3040
+ onDelete: "Cascade"
3041
+ }),
3042
+ questions: field7.hasMany("Question"),
3043
+ attempts: field7.hasMany("QuizAttempt")
3044
+ },
3045
+ indexes: [index7.on(["lessonId"]), index7.on(["status"]), index7.on(["orgId"])],
3046
+ enums: [QuizStatusEnum]
3047
+ });
3048
+ var QuestionEntity = defineEntity7({
3049
+ name: "Question",
3050
+ description: "A quiz question.",
3051
+ schema: "lssm_learning",
3052
+ map: "question",
3053
+ fields: {
3054
+ id: field7.id({ description: "Unique question identifier" }),
3055
+ quizId: field7.foreignKey({ description: "Parent quiz" }),
3056
+ type: field7.enum("QuestionType", { description: "Question type" }),
3057
+ content: field7.string({ description: "Question text" }),
3058
+ mediaUrl: field7.string({ isOptional: true, description: "Question media" }),
3059
+ points: field7.int({ default: 1, description: "Points for correct answer" }),
3060
+ codeLanguage: field7.string({
3061
+ isOptional: true,
3062
+ description: "Programming language"
3063
+ }),
3064
+ codeTemplate: field7.string({
3065
+ isOptional: true,
3066
+ description: "Starter code template"
3067
+ }),
3068
+ testCases: field7.json({
3069
+ isOptional: true,
3070
+ description: "Test cases for code validation"
3071
+ }),
3072
+ explanation: field7.string({
3073
+ isOptional: true,
3074
+ description: "Explanation of correct answer"
3075
+ }),
3076
+ hint: field7.string({
3077
+ isOptional: true,
3078
+ description: "Hint for the question"
3079
+ }),
3080
+ order: field7.int({ default: 0, description: "Display order" }),
3081
+ skillId: field7.string({
3082
+ isOptional: true,
3083
+ description: "Associated skill"
3084
+ }),
3085
+ metadata: field7.json({
3086
+ isOptional: true,
3087
+ description: "Additional metadata"
3088
+ }),
3089
+ createdAt: field7.createdAt(),
3090
+ updatedAt: field7.updatedAt(),
3091
+ quiz: field7.belongsTo("Quiz", ["quizId"], ["id"], { onDelete: "Cascade" }),
3092
+ options: field7.hasMany("QuestionOption")
3093
+ },
3094
+ indexes: [
3095
+ index7.on(["quizId", "order"]),
3096
+ index7.on(["type"]),
3097
+ index7.on(["skillId"])
3098
+ ],
3099
+ enums: [QuestionTypeEnum]
3100
+ });
3101
+ var QuestionOptionEntity = defineEntity7({
3102
+ name: "QuestionOption",
3103
+ description: "An answer option for a question.",
3104
+ schema: "lssm_learning",
3105
+ map: "question_option",
3106
+ fields: {
3107
+ id: field7.id({ description: "Unique option identifier" }),
3108
+ questionId: field7.foreignKey({ description: "Parent question" }),
3109
+ content: field7.string({ description: "Option text" }),
3110
+ matchContent: field7.string({
3111
+ isOptional: true,
3112
+ description: "Match pair content"
3113
+ }),
3114
+ isCorrect: field7.boolean({
3115
+ default: false,
3116
+ description: "Whether option is correct"
3117
+ }),
3118
+ feedback: field7.string({
3119
+ isOptional: true,
3120
+ description: "Feedback when selected"
3121
+ }),
3122
+ order: field7.int({ default: 0, description: "Display order" }),
3123
+ metadata: field7.json({
3124
+ isOptional: true,
3125
+ description: "Additional metadata"
3126
+ }),
3127
+ createdAt: field7.createdAt(),
3128
+ updatedAt: field7.updatedAt(),
3129
+ question: field7.belongsTo("Question", ["questionId"], ["id"], {
3130
+ onDelete: "Cascade"
3131
+ })
3132
+ },
3133
+ indexes: [index7.on(["questionId", "order"])]
3134
+ });
3135
+ var QuizAttemptEntity = defineEntity7({
3136
+ name: "QuizAttempt",
3137
+ description: "A learner quiz attempt.",
3138
+ schema: "lssm_learning",
3139
+ map: "quiz_attempt",
3140
+ fields: {
3141
+ id: field7.id({ description: "Unique attempt identifier" }),
3142
+ learnerId: field7.foreignKey({ description: "Learner" }),
3143
+ quizId: field7.foreignKey({ description: "Quiz" }),
3144
+ status: field7.enum("AttemptStatus", {
3145
+ default: "IN_PROGRESS",
3146
+ description: "Attempt status"
3147
+ }),
3148
+ score: field7.int({ isOptional: true, description: "Score achieved" }),
3149
+ percentageScore: field7.int({
3150
+ isOptional: true,
3151
+ description: "Percentage score"
3152
+ }),
3153
+ passed: field7.boolean({ isOptional: true, description: "Whether passed" }),
3154
+ totalQuestions: field7.int({ default: 0, description: "Total questions" }),
3155
+ answeredQuestions: field7.int({
3156
+ default: 0,
3157
+ description: "Questions answered"
3158
+ }),
3159
+ correctAnswers: field7.int({ default: 0, description: "Correct answers" }),
3160
+ answers: field7.json({ isOptional: true, description: "Submitted answers" }),
3161
+ xpEarned: field7.int({ default: 0, description: "XP earned" }),
3162
+ timeSpent: field7.int({ default: 0, description: "Time spent in seconds" }),
3163
+ startedAt: field7.dateTime({ description: "When started" }),
3164
+ completedAt: field7.dateTime({
3165
+ isOptional: true,
3166
+ description: "When completed"
3167
+ }),
3168
+ attemptNumber: field7.int({
3169
+ default: 1,
3170
+ description: "Which attempt this is"
3171
+ }),
3172
+ metadata: field7.json({
3173
+ isOptional: true,
3174
+ description: "Additional metadata"
3175
+ }),
3176
+ createdAt: field7.createdAt(),
3177
+ updatedAt: field7.updatedAt(),
3178
+ learner: field7.belongsTo("Learner", ["learnerId"], ["id"], {
3179
+ onDelete: "Cascade"
3180
+ }),
3181
+ quiz: field7.belongsTo("Quiz", ["quizId"], ["id"], { onDelete: "Cascade" })
3182
+ },
3183
+ indexes: [
3184
+ index7.on(["learnerId", "quizId"]),
3185
+ index7.on(["learnerId", "status"]),
3186
+ index7.on(["quizId", "status"])
3187
+ ],
3188
+ enums: [AttemptStatusEnum]
3189
+ });
3190
+ var SkillAssessmentEntity = defineEntity7({
3191
+ name: "SkillAssessment",
3192
+ description: "Assessment of a skill based on quiz performance.",
3193
+ schema: "lssm_learning",
3194
+ map: "skill_assessment",
3195
+ fields: {
3196
+ id: field7.id({ description: "Unique assessment identifier" }),
3197
+ learnerId: field7.foreignKey({ description: "Learner" }),
3198
+ skillId: field7.string({ description: "Skill identifier" }),
3199
+ skillName: field7.string({ description: "Skill name" }),
3200
+ level: field7.int({ default: 1, description: "Proficiency level (1-5)" }),
3201
+ score: field7.int({ default: 0, description: "Assessment score (0-100)" }),
3202
+ confidence: field7.decimal({
3203
+ default: 0.5,
3204
+ description: "Confidence in assessment"
3205
+ }),
3206
+ questionsAnswered: field7.int({
3207
+ default: 0,
3208
+ description: "Total questions answered"
3209
+ }),
3210
+ questionsCorrect: field7.int({ default: 0, description: "Total correct" }),
3211
+ assessedAt: field7.dateTime({ description: "Last assessment time" }),
3212
+ createdAt: field7.createdAt(),
3213
+ updatedAt: field7.updatedAt(),
3214
+ learner: field7.belongsTo("Learner", ["learnerId"], ["id"], {
3215
+ onDelete: "Cascade"
3216
+ })
3217
+ },
3218
+ indexes: [
3219
+ index7.unique(["learnerId", "skillId"], { name: "skill_assessment_unique" }),
3220
+ index7.on(["learnerId", "level"]),
3221
+ index7.on(["skillId"])
3222
+ ]
3223
+ });
3224
+ var quizEntities = [
3225
+ QuizEntity,
3226
+ QuestionEntity,
3227
+ QuestionOptionEntity,
3228
+ QuizAttemptEntity,
3229
+ SkillAssessmentEntity
3230
+ ];
3231
+ var quizEnums = [QuestionTypeEnum, QuizStatusEnum, AttemptStatusEnum];
3232
+ // src/entities/index.ts
3233
+ var learningJourneyEntities = [
3234
+ ...courseEntities,
3235
+ ...learnerEntities,
3236
+ ...onboardingEntities,
3237
+ ...flashcardEntities,
3238
+ ...quizEntities,
3239
+ ...gamificationEntities,
3240
+ ...aiEntities
3241
+ ];
3242
+ var learningJourneyEnums = [
3243
+ ...courseEnums,
3244
+ ...learnerEnums,
3245
+ ...onboardingEnums,
3246
+ ...flashcardEnums,
3247
+ ...quizEnums,
3248
+ ...gamificationEnums,
3249
+ ...aiEnums
3250
+ ];
3251
+ var learningJourneySchemaContribution = {
3252
+ moduleId: "@contractspec/module.learning-journey",
3253
+ entities: learningJourneyEntities,
3254
+ enums: learningJourneyEnums
3255
+ };
3256
+
3257
+ // src/events.ts
3258
+ import { ScalarTypeEnum as ScalarTypeEnum3, defineSchemaModel as defineSchemaModel3 } from "@contractspec/lib.schema";
3259
+ import { defineEvent } from "@contractspec/lib.contracts";
3260
+ var CoursePublishedPayload = defineSchemaModel3({
3261
+ name: "CoursePublishedEventPayload",
3262
+ description: "Payload when a course is published",
3263
+ fields: {
3264
+ courseId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
3265
+ title: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
3266
+ authorId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
3267
+ publishedAt: { type: ScalarTypeEnum3.DateTime(), isOptional: false }
3268
+ }
3269
+ });
3270
+ var CoursePublishedEvent = defineEvent({
3271
+ meta: {
3272
+ key: "course.published",
3273
+ version: "1.0.0",
3274
+ description: "A course has been published.",
3275
+ stability: "stable",
3276
+ owners: [...LEARNING_JOURNEY_OWNERS],
3277
+ tags: ["learning", "course"]
3278
+ },
3279
+ payload: CoursePublishedPayload
3280
+ });
3281
+ var EnrollmentCreatedPayload = defineSchemaModel3({
3282
+ name: "EnrollmentCreatedEventPayload",
3283
+ description: "Payload when a learner enrolls in a course",
3284
+ fields: {
3285
+ enrollmentId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
3286
+ learnerId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
3287
+ courseId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
3288
+ enrolledAt: { type: ScalarTypeEnum3.DateTime(), isOptional: false }
3289
+ }
3290
+ });
3291
+ var EnrollmentCreatedEvent = defineEvent({
3292
+ meta: {
3293
+ key: "enrollment.created",
3294
+ version: "1.0.0",
3295
+ description: "A learner has enrolled in a course.",
3296
+ stability: "stable",
3297
+ owners: [...LEARNING_JOURNEY_OWNERS],
3298
+ tags: ["learning", "enrollment"]
3299
+ },
3300
+ payload: EnrollmentCreatedPayload
3301
+ });
3302
+ var LessonCompletedPayload = defineSchemaModel3({
3303
+ name: "LessonCompletedEventPayload",
3304
+ description: "Payload when a lesson is completed",
3305
+ fields: {
3306
+ learnerId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
3307
+ lessonId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
3308
+ courseId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
3309
+ score: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: true },
3310
+ xpEarned: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: false },
3311
+ timeSpent: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: false },
3312
+ completedAt: { type: ScalarTypeEnum3.DateTime(), isOptional: false }
3313
+ }
3314
+ });
3315
+ var LessonCompletedEvent = defineEvent({
3316
+ meta: {
3317
+ key: "lesson.completed",
3318
+ version: "1.0.0",
3319
+ description: "A learner has completed a lesson.",
3320
+ stability: "stable",
3321
+ owners: [...LEARNING_JOURNEY_OWNERS],
3322
+ tags: ["learning", "progress", "lesson"]
3323
+ },
3324
+ payload: LessonCompletedPayload
3325
+ });
3326
+ var CourseCompletedPayload = defineSchemaModel3({
3327
+ name: "CourseCompletedEventPayload",
3328
+ description: "Payload when a course is completed",
3329
+ fields: {
3330
+ learnerId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
3331
+ courseId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
3332
+ enrollmentId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
3333
+ score: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: true },
3334
+ xpEarned: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: false },
3335
+ certificateId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: true },
3336
+ completedAt: { type: ScalarTypeEnum3.DateTime(), isOptional: false }
3337
+ }
3338
+ });
3339
+ var CourseCompletedEvent = defineEvent({
3340
+ meta: {
3341
+ key: "course.completed",
3342
+ version: "1.0.0",
3343
+ description: "A learner has completed a course.",
3344
+ stability: "stable",
3345
+ owners: [...LEARNING_JOURNEY_OWNERS],
3346
+ tags: ["learning", "progress", "course"]
3347
+ },
3348
+ payload: CourseCompletedPayload
3349
+ });
3350
+ var OnboardingStartedPayload = defineSchemaModel3({
3351
+ name: "OnboardingStartedEventPayload",
3352
+ description: "Payload when onboarding starts",
3353
+ fields: {
3354
+ learnerId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
3355
+ trackId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
3356
+ productId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
3357
+ startedAt: { type: ScalarTypeEnum3.DateTime(), isOptional: false }
3358
+ }
3359
+ });
3360
+ var OnboardingStartedEvent = defineEvent({
3361
+ meta: {
3362
+ key: "onboarding.started",
3363
+ version: "1.0.0",
3364
+ description: "A learner has started onboarding.",
3365
+ stability: "stable",
3366
+ owners: [...LEARNING_JOURNEY_OWNERS],
3367
+ tags: ["learning", "onboarding"]
3368
+ },
3369
+ payload: OnboardingStartedPayload
3370
+ });
3371
+ var OnboardingStepCompletedPayload = defineSchemaModel3({
3372
+ name: "OnboardingStepCompletedEventPayload",
3373
+ description: "Payload when an onboarding step is completed",
3374
+ fields: {
3375
+ learnerId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
3376
+ trackId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
3377
+ stepId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
3378
+ triggeringEvent: {
3379
+ type: ScalarTypeEnum3.String_unsecure(),
3380
+ isOptional: true
3381
+ },
3382
+ xpEarned: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: false },
3383
+ completedAt: { type: ScalarTypeEnum3.DateTime(), isOptional: false }
3384
+ }
3385
+ });
3386
+ var OnboardingStepCompletedEvent = defineEvent({
3387
+ meta: {
3388
+ key: "onboarding.step_completed",
3389
+ version: "1.0.0",
3390
+ description: "An onboarding step has been completed.",
3391
+ stability: "stable",
3392
+ owners: [...LEARNING_JOURNEY_OWNERS],
3393
+ tags: ["learning", "onboarding"]
3394
+ },
3395
+ payload: OnboardingStepCompletedPayload
3396
+ });
3397
+ var OnboardingCompletedPayload = defineSchemaModel3({
3398
+ name: "OnboardingCompletedEventPayload",
3399
+ description: "Payload when onboarding is completed",
3400
+ fields: {
3401
+ learnerId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
3402
+ trackId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
3403
+ productId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
3404
+ xpEarned: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: false },
3405
+ completedAt: { type: ScalarTypeEnum3.DateTime(), isOptional: false }
3406
+ }
3407
+ });
3408
+ var OnboardingCompletedEvent = defineEvent({
3409
+ meta: {
3410
+ key: "onboarding.completed",
3411
+ version: "1.0.0",
3412
+ description: "A learner has completed onboarding.",
3413
+ stability: "stable",
3414
+ owners: [...LEARNING_JOURNEY_OWNERS],
3415
+ tags: ["learning", "onboarding"]
3416
+ },
3417
+ payload: OnboardingCompletedPayload
3418
+ });
3419
+ var CardReviewedPayload = defineSchemaModel3({
3420
+ name: "CardReviewedEventPayload",
3421
+ description: "Payload when a flashcard is reviewed",
3422
+ fields: {
3423
+ learnerId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
3424
+ cardId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
3425
+ deckId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
3426
+ rating: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
3427
+ responseTimeMs: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: true },
3428
+ reviewedAt: { type: ScalarTypeEnum3.DateTime(), isOptional: false }
3429
+ }
3430
+ });
3431
+ var CardReviewedEvent = defineEvent({
3432
+ meta: {
3433
+ key: "flashcard.reviewed",
3434
+ version: "1.0.0",
3435
+ description: "A flashcard has been reviewed.",
3436
+ stability: "stable",
3437
+ owners: [...LEARNING_JOURNEY_OWNERS],
3438
+ tags: ["learning", "flashcards"]
3439
+ },
3440
+ payload: CardReviewedPayload
3441
+ });
3442
+ var QuizStartedPayload = defineSchemaModel3({
3443
+ name: "QuizStartedEventPayload",
3444
+ description: "Payload when a quiz is started",
3445
+ fields: {
3446
+ learnerId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
3447
+ quizId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
3448
+ attemptId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
3449
+ attemptNumber: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: false },
3450
+ startedAt: { type: ScalarTypeEnum3.DateTime(), isOptional: false }
3451
+ }
3452
+ });
3453
+ var QuizStartedEvent = defineEvent({
3454
+ meta: {
3455
+ key: "quiz.started",
3456
+ version: "1.0.0",
3457
+ description: "A quiz attempt has started.",
3458
+ stability: "stable",
3459
+ owners: [...LEARNING_JOURNEY_OWNERS],
3460
+ tags: ["learning", "quiz"]
3461
+ },
3462
+ payload: QuizStartedPayload
3463
+ });
3464
+ var QuizCompletedPayload = defineSchemaModel3({
3465
+ name: "QuizCompletedEventPayload",
3466
+ description: "Payload when a quiz is completed",
3467
+ fields: {
3468
+ learnerId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
3469
+ quizId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
3470
+ attemptId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
3471
+ score: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: false },
3472
+ percentageScore: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: false },
3473
+ passed: { type: ScalarTypeEnum3.Boolean(), isOptional: false },
3474
+ xpEarned: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: false },
3475
+ timeSpent: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: false },
3476
+ completedAt: { type: ScalarTypeEnum3.DateTime(), isOptional: false }
3477
+ }
3478
+ });
3479
+ var QuizCompletedEvent = defineEvent({
3480
+ meta: {
3481
+ key: "quiz.completed",
3482
+ version: "1.0.0",
3483
+ description: "A quiz attempt has been completed.",
3484
+ stability: "stable",
3485
+ owners: [...LEARNING_JOURNEY_OWNERS],
3486
+ tags: ["learning", "quiz"]
3487
+ },
3488
+ payload: QuizCompletedPayload
3489
+ });
3490
+ var XpEarnedPayload = defineSchemaModel3({
3491
+ name: "XpEarnedEventPayload",
3492
+ description: "Payload when XP is earned",
3493
+ fields: {
3494
+ learnerId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
3495
+ amount: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: false },
3496
+ source: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
3497
+ sourceId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: true },
3498
+ totalXp: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: false },
3499
+ earnedAt: { type: ScalarTypeEnum3.DateTime(), isOptional: false }
3500
+ }
3501
+ });
3502
+ var XpEarnedEvent = defineEvent({
3503
+ meta: {
3504
+ key: "xp.earned",
3505
+ version: "1.0.0",
3506
+ description: "XP has been earned.",
3507
+ stability: "stable",
3508
+ owners: [...LEARNING_JOURNEY_OWNERS],
3509
+ tags: ["learning", "gamification", "xp"]
3510
+ },
3511
+ payload: XpEarnedPayload
3512
+ });
3513
+ var LevelUpPayload = defineSchemaModel3({
3514
+ name: "LevelUpEventPayload",
3515
+ description: "Payload when a learner levels up",
3516
+ fields: {
3517
+ learnerId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
3518
+ previousLevel: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: false },
3519
+ newLevel: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: false },
3520
+ totalXp: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: false },
3521
+ leveledUpAt: { type: ScalarTypeEnum3.DateTime(), isOptional: false }
3522
+ }
3523
+ });
3524
+ var LevelUpEvent = defineEvent({
3525
+ meta: {
3526
+ key: "level.up",
3527
+ version: "1.0.0",
3528
+ description: "A learner has leveled up.",
3529
+ stability: "stable",
3530
+ owners: [...LEARNING_JOURNEY_OWNERS],
3531
+ tags: ["learning", "gamification", "level"]
3532
+ },
3533
+ payload: LevelUpPayload
3534
+ });
3535
+ var StreakUpdatedPayload = defineSchemaModel3({
3536
+ name: "StreakUpdatedEventPayload",
3537
+ description: "Payload when a streak is updated",
3538
+ fields: {
3539
+ learnerId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
3540
+ previousStreak: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: false },
3541
+ currentStreak: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: false },
3542
+ longestStreak: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: false },
3543
+ freezeUsed: { type: ScalarTypeEnum3.Boolean(), isOptional: false },
3544
+ updatedAt: { type: ScalarTypeEnum3.DateTime(), isOptional: false }
3545
+ }
3546
+ });
3547
+ var StreakUpdatedEvent = defineEvent({
3548
+ meta: {
3549
+ key: "streak.updated",
3550
+ version: "1.0.0",
3551
+ description: "A streak has been updated.",
3552
+ stability: "stable",
3553
+ owners: [...LEARNING_JOURNEY_OWNERS],
3554
+ tags: ["learning", "gamification", "streak"]
3555
+ },
3556
+ payload: StreakUpdatedPayload
3557
+ });
3558
+ var AchievementUnlockedPayload = defineSchemaModel3({
3559
+ name: "AchievementUnlockedEventPayload",
3560
+ description: "Payload when an achievement is unlocked",
3561
+ fields: {
3562
+ learnerId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
3563
+ achievementId: {
3564
+ type: ScalarTypeEnum3.String_unsecure(),
3565
+ isOptional: false
3566
+ },
3567
+ achievementKey: {
3568
+ type: ScalarTypeEnum3.String_unsecure(),
3569
+ isOptional: false
3570
+ },
3571
+ achievementName: {
3572
+ type: ScalarTypeEnum3.String_unsecure(),
3573
+ isOptional: false
3574
+ },
3575
+ xpEarned: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: false },
3576
+ unlockedAt: { type: ScalarTypeEnum3.DateTime(), isOptional: false }
3577
+ }
3578
+ });
3579
+ var AchievementUnlockedEvent = defineEvent({
3580
+ meta: {
3581
+ key: "achievement.unlocked",
3582
+ version: "1.0.0",
3583
+ description: "An achievement has been unlocked.",
3584
+ stability: "stable",
3585
+ owners: [...LEARNING_JOURNEY_OWNERS],
3586
+ tags: ["learning", "gamification", "achievement"]
3587
+ },
3588
+ payload: AchievementUnlockedPayload
3589
+ });
3590
+ var DailyGoalCompletedPayload = defineSchemaModel3({
3591
+ name: "DailyGoalCompletedEventPayload",
3592
+ description: "Payload when a daily goal is completed",
3593
+ fields: {
3594
+ learnerId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
3595
+ date: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
3596
+ targetXp: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: false },
3597
+ actualXp: { type: ScalarTypeEnum3.Int_unsecure(), isOptional: false },
3598
+ completedAt: { type: ScalarTypeEnum3.DateTime(), isOptional: false }
3599
+ }
3600
+ });
3601
+ var DailyGoalCompletedEvent = defineEvent({
3602
+ meta: {
3603
+ key: "daily_goal.completed",
3604
+ version: "1.0.0",
3605
+ description: "A daily goal has been completed.",
3606
+ stability: "stable",
3607
+ owners: [...LEARNING_JOURNEY_OWNERS],
3608
+ tags: ["learning", "gamification", "goal"]
3609
+ },
3610
+ payload: DailyGoalCompletedPayload
3611
+ });
3612
+ var CertificateIssuedPayload = defineSchemaModel3({
3613
+ name: "CertificateIssuedEventPayload",
3614
+ description: "Payload when a certificate is issued",
3615
+ fields: {
3616
+ certificateId: {
3617
+ type: ScalarTypeEnum3.String_unsecure(),
3618
+ isOptional: false
3619
+ },
3620
+ learnerId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
3621
+ courseId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
3622
+ certificateNumber: {
3623
+ type: ScalarTypeEnum3.String_unsecure(),
3624
+ isOptional: false
3625
+ },
3626
+ issuedAt: { type: ScalarTypeEnum3.DateTime(), isOptional: false }
3627
+ }
3628
+ });
3629
+ var CertificateIssuedEvent = defineEvent({
3630
+ meta: {
3631
+ key: "certificate.issued",
3632
+ version: "1.0.0",
3633
+ description: "A certificate has been issued.",
3634
+ stability: "stable",
3635
+ owners: [...LEARNING_JOURNEY_OWNERS],
3636
+ tags: ["learning", "certificate"]
3637
+ },
3638
+ payload: CertificateIssuedPayload
3639
+ });
3640
+ var LearningJourneyEvents = {
3641
+ CoursePublishedEvent,
3642
+ EnrollmentCreatedEvent,
3643
+ LessonCompletedEvent,
3644
+ CourseCompletedEvent,
3645
+ OnboardingStartedEvent,
3646
+ OnboardingStepCompletedEvent,
3647
+ OnboardingCompletedEvent,
3648
+ CardReviewedEvent,
3649
+ QuizStartedEvent,
3650
+ QuizCompletedEvent,
3651
+ XpEarnedEvent,
3652
+ LevelUpEvent,
3653
+ StreakUpdatedEvent,
3654
+ AchievementUnlockedEvent,
3655
+ DailyGoalCompletedEvent,
3656
+ CertificateIssuedEvent
3657
+ };
3658
+ // src/learning-journey.feature.ts
3659
+ import { defineFeature } from "@contractspec/lib.contracts";
3660
+ var LearningJourneyFeature = defineFeature({
3661
+ meta: {
3662
+ key: "learning-journey",
3663
+ version: "1.0.0",
3664
+ title: "Learning Journey",
3665
+ description: "Learning platform with courses, onboarding, flashcards, and gamification",
3666
+ domain: "learning",
3667
+ owners: ["@platform.learning-journey"],
3668
+ tags: ["learning", "onboarding", "courses", "flashcards", "gamification"],
3669
+ stability: "stable"
3670
+ },
3671
+ operations: [
3672
+ { key: "learning.onboarding.recordEvent", version: "1.0.0" },
3673
+ { key: "learning.onboarding.listTracks", version: "1.0.0" },
3674
+ { key: "learning.onboarding.getProgress", version: "1.0.0" },
3675
+ { key: "learning.enroll", version: "1.0.0" },
3676
+ { key: "learning.completeLesson", version: "1.0.0" },
3677
+ { key: "learning.submitCardReview", version: "1.0.0" },
3678
+ { key: "learning.getDueCards", version: "1.0.0" },
3679
+ { key: "learning.getDashboard", version: "1.0.0" }
3680
+ ],
3681
+ events: [
3682
+ { key: "course.published", version: "1.0.0" },
3683
+ { key: "course.completed", version: "1.0.0" },
3684
+ { key: "enrollment.created", version: "1.0.0" },
3685
+ { key: "lesson.completed", version: "1.0.0" },
3686
+ { key: "onboarding.started", version: "1.0.0" },
3687
+ { key: "onboarding.step_completed", version: "1.0.0" },
3688
+ { key: "onboarding.completed", version: "1.0.0" },
3689
+ { key: "flashcard.reviewed", version: "1.0.0" },
3690
+ { key: "quiz.started", version: "1.0.0" },
3691
+ { key: "quiz.completed", version: "1.0.0" },
3692
+ { key: "xp.earned", version: "1.0.0" },
3693
+ { key: "level.up", version: "1.0.0" },
3694
+ { key: "streak.updated", version: "1.0.0" },
3695
+ { key: "achievement.unlocked", version: "1.0.0" },
3696
+ { key: "daily_goal.completed", version: "1.0.0" },
3697
+ { key: "certificate.issued", version: "1.0.0" }
3698
+ ],
3699
+ presentations: [],
3700
+ opToPresentation: [],
3701
+ presentationsTargets: [],
3702
+ capabilities: {
3703
+ provides: [
3704
+ { key: "learning-journey", version: "1.0.0" },
3705
+ { key: "onboarding", version: "1.0.0" },
3706
+ { key: "gamification", version: "1.0.0" }
3707
+ ],
3708
+ requires: [{ key: "identity", version: "1.0.0" }]
3709
+ }
3710
+ });
3711
+ export {
3712
+ xpEngine,
3713
+ streakEngine,
3714
+ srsEngine,
3715
+ quizEnums,
3716
+ quizEntities,
3717
+ onboardingEnums,
3718
+ onboardingEntities,
3719
+ learningJourneySchemaContribution,
3720
+ learningJourneyEnums,
3721
+ learningJourneyEntities,
3722
+ learnerEnums,
3723
+ learnerEntities,
3724
+ gamificationEnums,
3725
+ gamificationEntities,
3726
+ flashcardEnums,
3727
+ flashcardEntities,
3728
+ courseEnums,
3729
+ courseEntities,
3730
+ aiEnums,
3731
+ aiEntities,
3732
+ XpEarnedEvent,
3733
+ XPTransactionEntity,
3734
+ XPEngine,
3735
+ SuccessOutput,
3736
+ SubmitCardReviewInput,
3737
+ SubmitCardReviewContract,
3738
+ StreakUpdatedEvent,
3739
+ StreakEntity,
3740
+ StreakEngine,
3741
+ SkillMapEntity,
3742
+ SkillAssessmentEntity,
3743
+ SRSEngine,
3744
+ RecordOnboardingEventContract,
3745
+ RecommendationTypeEnum,
3746
+ RecommendationEntity,
3747
+ QuizStatusEnum,
3748
+ QuizStartedEvent,
3749
+ QuizEntity,
3750
+ QuizCompletedEvent,
3751
+ QuizAttemptEntity,
3752
+ QuestionTypeEnum,
3753
+ QuestionOptionEntity,
3754
+ QuestionEntity,
3755
+ ProgressStatusEnum,
3756
+ ProgressModel,
3757
+ OnboardingTrackModel,
3758
+ OnboardingTrackEntity,
3759
+ OnboardingStepStatusEnum,
3760
+ OnboardingStepProgressModel,
3761
+ OnboardingStepModel,
3762
+ OnboardingStepEntity,
3763
+ OnboardingStepCompletionEntity,
3764
+ OnboardingStepCompletedEvent,
3765
+ OnboardingStartedEvent,
3766
+ OnboardingProgressModel,
3767
+ OnboardingProgressEntity,
3768
+ OnboardingCompletedEvent,
3769
+ ModuleCompletionEntity,
3770
+ ListOnboardingTracksContract,
3771
+ LevelUpEvent,
3772
+ LessonTypeEnum,
3773
+ LessonProgressEntity,
3774
+ LessonEntity,
3775
+ LessonContentEntity,
3776
+ LessonCompletedEvent,
3777
+ LearningStyleEnum,
3778
+ LearningPathEntity,
3779
+ LearningJourneyFeature,
3780
+ LearningJourneyEvents,
3781
+ LearningGapEntity,
3782
+ LearnerProfileEntity,
3783
+ LearnerModel,
3784
+ LearnerEntity,
3785
+ LearnerDashboardModel,
3786
+ LearnerAchievementEntity,
3787
+ LeaderboardPeriodEnum,
3788
+ LeaderboardEntryEntity,
3789
+ LEARNING_JOURNEY_OWNERS,
3790
+ HeartEntity,
3791
+ GetOnboardingProgressContract,
3792
+ GetLearnerDashboardInput,
3793
+ GetLearnerDashboardContract,
3794
+ GetDueCardsOutput,
3795
+ GetDueCardsInput,
3796
+ GetDueCardsContract,
3797
+ EnrollmentStatusEnum,
3798
+ EnrollmentModel,
3799
+ EnrollmentEntity,
3800
+ EnrollmentCreatedEvent,
3801
+ EnrollInCourseInput,
3802
+ EnrollInCourseContract,
3803
+ DeckModel,
3804
+ DeckEntity,
3805
+ DailyGoalEntity,
3806
+ DailyGoalCompletedEvent,
3807
+ DEFAULT_XP_CONFIG,
3808
+ DEFAULT_STREAK_CONFIG,
3809
+ DEFAULT_SRS_CONFIG,
3810
+ CourseStatusEnum,
3811
+ CoursePublishedEvent,
3812
+ CourseModuleEntity,
3813
+ CourseModel,
3814
+ CourseEntity,
3815
+ CourseDifficultyEnum,
3816
+ CourseCompletedEvent,
3817
+ ContentTypeEnum,
3818
+ CompleteLessonInput,
3819
+ CompleteLessonContract,
3820
+ CertificateIssuedEvent,
3821
+ CertificateEntity,
3822
+ CardScheduleEntity,
3823
+ CardReviewedEvent,
3824
+ CardReviewEntity,
3825
+ CardRatingEnum,
3826
+ CardModel,
3827
+ CardEntity,
3828
+ AttemptStatusEnum,
3829
+ AchievementUnlockedEvent,
3830
+ AchievementTypeEnum,
3831
+ AchievementModel,
3832
+ AchievementEntity
3833
+ };