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