@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,193 @@
1
+ // src/contracts/models.ts
2
+ import { ScalarTypeEnum, defineSchemaModel } from "@contractspec/lib.schema";
3
+ var CourseModel = defineSchemaModel({
4
+ name: "Course",
5
+ description: "A learning course",
6
+ fields: {
7
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
8
+ title: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
9
+ slug: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
10
+ description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
11
+ difficulty: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
12
+ status: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
13
+ estimatedDuration: {
14
+ type: ScalarTypeEnum.Int_unsecure(),
15
+ isOptional: true
16
+ },
17
+ thumbnailUrl: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
18
+ createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
19
+ }
20
+ });
21
+ var LearnerModel = defineSchemaModel({
22
+ name: "Learner",
23
+ description: "A learner profile",
24
+ fields: {
25
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
26
+ userId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
27
+ displayName: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
28
+ level: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
29
+ totalXp: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
30
+ currentStreak: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
31
+ longestStreak: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
32
+ createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
33
+ }
34
+ });
35
+ var EnrollmentModel = defineSchemaModel({
36
+ name: "Enrollment",
37
+ description: "A course enrollment",
38
+ fields: {
39
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
40
+ learnerId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
41
+ courseId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
42
+ status: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
43
+ progress: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
44
+ startedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
45
+ completedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true }
46
+ }
47
+ });
48
+ var ProgressModel = defineSchemaModel({
49
+ name: "LessonProgress",
50
+ description: "Lesson progress",
51
+ fields: {
52
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
53
+ learnerId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
54
+ lessonId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
55
+ status: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
56
+ progress: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
57
+ score: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
58
+ timeSpent: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
59
+ completedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true }
60
+ }
61
+ });
62
+ var DeckModel = defineSchemaModel({
63
+ name: "Deck",
64
+ description: "A flashcard deck",
65
+ fields: {
66
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
67
+ title: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
68
+ description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
69
+ cardCount: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
70
+ isPublic: { type: ScalarTypeEnum.Boolean(), isOptional: false },
71
+ createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
72
+ }
73
+ });
74
+ var CardModel = defineSchemaModel({
75
+ name: "Card",
76
+ description: "A flashcard",
77
+ fields: {
78
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
79
+ deckId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
80
+ front: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
81
+ back: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
82
+ hints: { type: ScalarTypeEnum.JSON(), isOptional: true },
83
+ isDue: { type: ScalarTypeEnum.Boolean(), isOptional: false },
84
+ nextReviewAt: { type: ScalarTypeEnum.DateTime(), isOptional: true }
85
+ }
86
+ });
87
+ var AchievementModel = defineSchemaModel({
88
+ name: "Achievement",
89
+ description: "An achievement",
90
+ fields: {
91
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
92
+ key: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
93
+ name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
94
+ description: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
95
+ icon: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
96
+ xpReward: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
97
+ unlockedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true }
98
+ }
99
+ });
100
+ var EnrollInCourseInput = defineSchemaModel({
101
+ name: "EnrollInCourseInput",
102
+ description: "Input for enrolling in a course",
103
+ fields: {
104
+ courseId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false }
105
+ }
106
+ });
107
+ var CompleteLessonInput = defineSchemaModel({
108
+ name: "CompleteLessonInput",
109
+ description: "Input for completing a lesson",
110
+ fields: {
111
+ lessonId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
112
+ score: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
113
+ timeSpent: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false }
114
+ }
115
+ });
116
+ var SubmitCardReviewInput = defineSchemaModel({
117
+ name: "SubmitCardReviewInput",
118
+ description: "Input for submitting a card review",
119
+ fields: {
120
+ cardId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
121
+ rating: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
122
+ responseTimeMs: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true }
123
+ }
124
+ });
125
+ var GetDueCardsInput = defineSchemaModel({
126
+ name: "GetDueCardsInput",
127
+ description: "Input for getting due cards",
128
+ fields: {
129
+ deckId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
130
+ limit: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true }
131
+ }
132
+ });
133
+ var GetDueCardsOutput = defineSchemaModel({
134
+ name: "GetDueCardsOutput",
135
+ description: "Output for getting due cards",
136
+ fields: {
137
+ cards: { type: CardModel, isArray: true, isOptional: false },
138
+ total: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false }
139
+ }
140
+ });
141
+ var GetLearnerDashboardInput = defineSchemaModel({
142
+ name: "GetLearnerDashboardInput",
143
+ description: "Input for getting learner dashboard",
144
+ fields: {
145
+ learnerId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
146
+ }
147
+ });
148
+ var LearnerDashboardModel = defineSchemaModel({
149
+ name: "LearnerDashboard",
150
+ description: "Learner dashboard data",
151
+ fields: {
152
+ learner: { type: LearnerModel, isOptional: false },
153
+ currentStreak: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
154
+ dailyXpGoal: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
155
+ dailyXpProgress: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
156
+ activeEnrollments: {
157
+ type: EnrollmentModel,
158
+ isArray: true,
159
+ isOptional: false
160
+ },
161
+ recentAchievements: {
162
+ type: AchievementModel,
163
+ isArray: true,
164
+ isOptional: false
165
+ },
166
+ dueCardCount: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false }
167
+ }
168
+ });
169
+ var SuccessOutput = defineSchemaModel({
170
+ name: "SuccessOutput",
171
+ description: "Generic success output",
172
+ fields: {
173
+ success: { type: ScalarTypeEnum.Boolean(), isOptional: false },
174
+ xpEarned: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true }
175
+ }
176
+ });
177
+ export {
178
+ SuccessOutput,
179
+ SubmitCardReviewInput,
180
+ ProgressModel,
181
+ LearnerModel,
182
+ LearnerDashboardModel,
183
+ GetLearnerDashboardInput,
184
+ GetDueCardsOutput,
185
+ GetDueCardsInput,
186
+ EnrollmentModel,
187
+ EnrollInCourseInput,
188
+ DeckModel,
189
+ CourseModel,
190
+ CompleteLessonInput,
191
+ CardModel,
192
+ AchievementModel
193
+ };
@@ -0,0 +1,417 @@
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/onboarding.ts
182
+ import { ScalarTypeEnum as ScalarTypeEnum2, defineSchemaModel as defineSchemaModel2 } from "@contractspec/lib.schema";
183
+ import { defineCommand, defineQuery } from "@contractspec/lib.contracts";
184
+ var OnboardingStepConditionModel = defineSchemaModel2({
185
+ name: "OnboardingStepCondition",
186
+ description: "Structured completion condition for onboarding steps.",
187
+ fields: {
188
+ eventName: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
189
+ eventVersion: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
190
+ sourceModule: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
191
+ payloadFilter: { type: ScalarTypeEnum2.JSON(), isOptional: true }
192
+ }
193
+ });
194
+ var OnboardingStepModel = defineSchemaModel2({
195
+ name: "OnboardingStep",
196
+ description: "Declarative onboarding step definition.",
197
+ fields: {
198
+ id: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
199
+ trackId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
200
+ title: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
201
+ description: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
202
+ instructions: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
203
+ helpUrl: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
204
+ order: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: false },
205
+ completionEvent: {
206
+ type: ScalarTypeEnum2.String_unsecure(),
207
+ isOptional: false
208
+ },
209
+ completionCondition: {
210
+ type: OnboardingStepConditionModel,
211
+ isOptional: true
212
+ },
213
+ xpReward: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: true },
214
+ isRequired: { type: ScalarTypeEnum2.Boolean(), isOptional: true },
215
+ canSkip: { type: ScalarTypeEnum2.Boolean(), isOptional: true },
216
+ actionUrl: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
217
+ actionLabel: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
218
+ metadata: { type: ScalarTypeEnum2.JSON(), isOptional: true }
219
+ }
220
+ });
221
+ var OnboardingTrackModel = defineSchemaModel2({
222
+ name: "OnboardingTrack",
223
+ description: "Onboarding track metadata and steps.",
224
+ fields: {
225
+ id: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
226
+ productId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
227
+ name: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
228
+ description: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
229
+ targetUserSegment: {
230
+ type: ScalarTypeEnum2.String_unsecure(),
231
+ isOptional: true
232
+ },
233
+ targetRole: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
234
+ isActive: { type: ScalarTypeEnum2.Boolean(), isOptional: true },
235
+ isRequired: { type: ScalarTypeEnum2.Boolean(), isOptional: true },
236
+ canSkip: { type: ScalarTypeEnum2.Boolean(), isOptional: true },
237
+ totalXp: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: true },
238
+ completionXpBonus: {
239
+ type: ScalarTypeEnum2.Int_unsecure(),
240
+ isOptional: true
241
+ },
242
+ completionBadgeKey: {
243
+ type: ScalarTypeEnum2.String_unsecure(),
244
+ isOptional: true
245
+ },
246
+ streakHoursWindow: {
247
+ type: ScalarTypeEnum2.Int_unsecure(),
248
+ isOptional: true
249
+ },
250
+ streakBonusXp: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: true },
251
+ metadata: { type: ScalarTypeEnum2.JSON(), isOptional: true },
252
+ steps: { type: OnboardingStepModel, isArray: true, isOptional: false }
253
+ }
254
+ });
255
+ var OnboardingStepProgressModel = defineSchemaModel2({
256
+ name: "OnboardingStepProgress",
257
+ description: "Progress for a specific onboarding step.",
258
+ fields: {
259
+ stepId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
260
+ status: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
261
+ xpEarned: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: true },
262
+ triggeringEvent: {
263
+ type: ScalarTypeEnum2.String_unsecure(),
264
+ isOptional: true
265
+ },
266
+ eventPayload: { type: ScalarTypeEnum2.JSON(), isOptional: true },
267
+ completedAt: { type: ScalarTypeEnum2.DateTime(), isOptional: true }
268
+ }
269
+ });
270
+ var OnboardingProgressModel = defineSchemaModel2({
271
+ name: "OnboardingProgress",
272
+ description: "Aggregated progress for an onboarding track.",
273
+ fields: {
274
+ learnerId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
275
+ trackId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
276
+ progress: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: false },
277
+ isCompleted: { type: ScalarTypeEnum2.Boolean(), isOptional: false },
278
+ xpEarned: { type: ScalarTypeEnum2.Int_unsecure(), isOptional: true },
279
+ startedAt: { type: ScalarTypeEnum2.DateTime(), isOptional: true },
280
+ completedAt: { type: ScalarTypeEnum2.DateTime(), isOptional: true },
281
+ lastActivityAt: { type: ScalarTypeEnum2.DateTime(), isOptional: true },
282
+ steps: {
283
+ type: OnboardingStepProgressModel,
284
+ isArray: true,
285
+ isOptional: true
286
+ }
287
+ }
288
+ });
289
+ var ListOnboardingTracksInput = defineSchemaModel2({
290
+ name: "ListOnboardingTracksInput",
291
+ description: "Filters for listing onboarding tracks.",
292
+ fields: {
293
+ learnerId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
294
+ productId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
295
+ trackIds: {
296
+ type: ScalarTypeEnum2.String_unsecure(),
297
+ isArray: true,
298
+ isOptional: true
299
+ },
300
+ includeProgress: {
301
+ type: ScalarTypeEnum2.Boolean(),
302
+ isOptional: true
303
+ }
304
+ }
305
+ });
306
+ var ListOnboardingTracksOutput = defineSchemaModel2({
307
+ name: "ListOnboardingTracksOutput",
308
+ description: "Available onboarding tracks with optional progress.",
309
+ fields: {
310
+ tracks: { type: OnboardingTrackModel, isArray: true, isOptional: false },
311
+ progress: {
312
+ type: OnboardingProgressModel,
313
+ isArray: true,
314
+ isOptional: true
315
+ }
316
+ }
317
+ });
318
+ var GetOnboardingProgressInput = defineSchemaModel2({
319
+ name: "GetOnboardingProgressInput",
320
+ description: "Input for fetching onboarding progress for a track.",
321
+ fields: {
322
+ trackId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
323
+ learnerId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true }
324
+ }
325
+ });
326
+ var RecordOnboardingEventInput = defineSchemaModel2({
327
+ name: "RecordOnboardingEventInput",
328
+ description: "Record a domain event to advance onboarding progress via completion conditions.",
329
+ fields: {
330
+ learnerId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
331
+ trackId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
332
+ eventName: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
333
+ eventVersion: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
334
+ eventPayload: { type: ScalarTypeEnum2.JSON(), isOptional: true },
335
+ occurredAt: { type: ScalarTypeEnum2.DateTime(), isOptional: true }
336
+ }
337
+ });
338
+ var ListOnboardingTracksContract = defineQuery({
339
+ meta: {
340
+ key: "learning.onboarding.listTracks",
341
+ version: "1.0.0",
342
+ stability: "stable",
343
+ owners: [...LEARNING_JOURNEY_OWNERS],
344
+ tags: ["learning", "onboarding", "journey"],
345
+ description: "List onboarding tracks available to a learner or product.",
346
+ goal: "Expose track catalog for UI/API surfaces.",
347
+ context: "Called when showing onboarding/learning journey catalog."
348
+ },
349
+ io: {
350
+ input: ListOnboardingTracksInput,
351
+ output: ListOnboardingTracksOutput
352
+ },
353
+ policy: {
354
+ auth: "user"
355
+ }
356
+ });
357
+ var GetOnboardingProgressContract = defineQuery({
358
+ meta: {
359
+ key: "learning.onboarding.getProgress",
360
+ version: "1.0.0",
361
+ stability: "stable",
362
+ owners: [...LEARNING_JOURNEY_OWNERS],
363
+ tags: ["learning", "onboarding", "journey"],
364
+ description: "Fetch onboarding progress for a specific track.",
365
+ goal: "Display learner progress and remaining steps.",
366
+ context: "Called when rendering a track detail or widget."
367
+ },
368
+ io: {
369
+ input: GetOnboardingProgressInput,
370
+ output: OnboardingProgressModel
371
+ },
372
+ policy: {
373
+ auth: "user"
374
+ }
375
+ });
376
+ var RecordOnboardingEventContract = defineCommand({
377
+ meta: {
378
+ key: "learning.onboarding.recordEvent",
379
+ version: "1.0.0",
380
+ stability: "stable",
381
+ owners: [...LEARNING_JOURNEY_OWNERS],
382
+ tags: ["learning", "onboarding", "events"],
383
+ description: "Record a domain event to evaluate onboarding step completion conditions.",
384
+ goal: "Advance onboarding automatically from product events.",
385
+ context: "Called by event bus handlers when relevant product events fire (e.g., deal.created)."
386
+ },
387
+ io: {
388
+ input: RecordOnboardingEventInput,
389
+ output: SuccessOutput,
390
+ errors: {
391
+ TRACK_NOT_FOUND: {
392
+ description: "Track not found for event routing",
393
+ http: 404,
394
+ gqlCode: "TRACK_NOT_FOUND",
395
+ when: "Track ID or routing context is invalid"
396
+ },
397
+ STEP_NOT_FOUND: {
398
+ description: "Step not found for completion condition",
399
+ http: 404,
400
+ gqlCode: "STEP_NOT_FOUND",
401
+ when: "No step matches the incoming event"
402
+ }
403
+ }
404
+ },
405
+ policy: {
406
+ auth: "user"
407
+ }
408
+ });
409
+ export {
410
+ RecordOnboardingEventContract,
411
+ OnboardingTrackModel,
412
+ OnboardingStepProgressModel,
413
+ OnboardingStepModel,
414
+ OnboardingProgressModel,
415
+ ListOnboardingTracksContract,
416
+ GetOnboardingProgressContract
417
+ };