@contractspec/module.learning-journey 3.7.16 → 3.7.17

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 (94) hide show
  1. package/dist/browser/contracts/index.js +1 -578
  2. package/dist/browser/contracts/models.js +1 -193
  3. package/dist/browser/contracts/onboarding.js +1 -417
  4. package/dist/browser/contracts/operations.js +1 -326
  5. package/dist/browser/contracts/shared.js +1 -5
  6. package/dist/browser/docs/index.js +7 -51
  7. package/dist/browser/docs/learning-journey.docblock.js +7 -51
  8. package/dist/browser/engines/index.js +1 -675
  9. package/dist/browser/engines/srs.js +1 -198
  10. package/dist/browser/engines/streak.js +1 -159
  11. package/dist/browser/engines/xp.js +1 -320
  12. package/dist/browser/entities/ai.js +1 -343
  13. package/dist/browser/entities/course.js +1 -276
  14. package/dist/browser/entities/flashcard.js +1 -222
  15. package/dist/browser/entities/gamification.js +1 -340
  16. package/dist/browser/entities/index.js +1 -2140
  17. package/dist/browser/entities/learner.js +1 -333
  18. package/dist/browser/entities/onboarding.js +1 -301
  19. package/dist/browser/entities/quiz.js +1 -304
  20. package/dist/browser/events.js +1 -423
  21. package/dist/browser/i18n/catalogs/en.js +1 -43
  22. package/dist/browser/i18n/catalogs/es.js +1 -43
  23. package/dist/browser/i18n/catalogs/fr.js +1 -43
  24. package/dist/browser/i18n/catalogs/index.js +1 -127
  25. package/dist/browser/i18n/index.js +1 -169
  26. package/dist/browser/i18n/keys.js +1 -16
  27. package/dist/browser/i18n/locale.js +1 -13
  28. package/dist/browser/i18n/messages.js +1 -139
  29. package/dist/browser/index.js +7 -3914
  30. package/dist/browser/learning-journey.capability.js +1 -43
  31. package/dist/browser/learning-journey.feature.js +1 -56
  32. package/dist/contracts/index.js +1 -578
  33. package/dist/contracts/models.js +1 -193
  34. package/dist/contracts/onboarding.js +1 -417
  35. package/dist/contracts/operations.js +1 -326
  36. package/dist/contracts/shared.js +1 -5
  37. package/dist/docs/index.js +7 -51
  38. package/dist/docs/learning-journey.docblock.js +7 -51
  39. package/dist/engines/index.js +1 -675
  40. package/dist/engines/srs.js +1 -198
  41. package/dist/engines/streak.js +1 -159
  42. package/dist/engines/xp.js +1 -320
  43. package/dist/entities/ai.js +1 -343
  44. package/dist/entities/course.js +1 -276
  45. package/dist/entities/flashcard.js +1 -222
  46. package/dist/entities/gamification.js +1 -340
  47. package/dist/entities/index.js +1 -2140
  48. package/dist/entities/learner.js +1 -333
  49. package/dist/entities/onboarding.js +1 -301
  50. package/dist/entities/quiz.js +1 -304
  51. package/dist/events.js +1 -423
  52. package/dist/i18n/catalogs/en.js +1 -43
  53. package/dist/i18n/catalogs/es.js +1 -43
  54. package/dist/i18n/catalogs/fr.js +1 -43
  55. package/dist/i18n/catalogs/index.js +1 -127
  56. package/dist/i18n/index.js +1 -169
  57. package/dist/i18n/keys.js +1 -16
  58. package/dist/i18n/locale.js +1 -13
  59. package/dist/i18n/messages.js +1 -139
  60. package/dist/index.js +7 -3914
  61. package/dist/learning-journey.capability.js +1 -43
  62. package/dist/learning-journey.feature.js +1 -56
  63. package/dist/node/contracts/index.js +1 -578
  64. package/dist/node/contracts/models.js +1 -193
  65. package/dist/node/contracts/onboarding.js +1 -417
  66. package/dist/node/contracts/operations.js +1 -326
  67. package/dist/node/contracts/shared.js +1 -5
  68. package/dist/node/docs/index.js +7 -51
  69. package/dist/node/docs/learning-journey.docblock.js +7 -51
  70. package/dist/node/engines/index.js +1 -675
  71. package/dist/node/engines/srs.js +1 -198
  72. package/dist/node/engines/streak.js +1 -159
  73. package/dist/node/engines/xp.js +1 -320
  74. package/dist/node/entities/ai.js +1 -343
  75. package/dist/node/entities/course.js +1 -276
  76. package/dist/node/entities/flashcard.js +1 -222
  77. package/dist/node/entities/gamification.js +1 -340
  78. package/dist/node/entities/index.js +1 -2140
  79. package/dist/node/entities/learner.js +1 -333
  80. package/dist/node/entities/onboarding.js +1 -301
  81. package/dist/node/entities/quiz.js +1 -304
  82. package/dist/node/events.js +1 -423
  83. package/dist/node/i18n/catalogs/en.js +1 -43
  84. package/dist/node/i18n/catalogs/es.js +1 -43
  85. package/dist/node/i18n/catalogs/fr.js +1 -43
  86. package/dist/node/i18n/catalogs/index.js +1 -127
  87. package/dist/node/i18n/index.js +1 -169
  88. package/dist/node/i18n/keys.js +1 -16
  89. package/dist/node/i18n/locale.js +1 -13
  90. package/dist/node/i18n/messages.js +1 -139
  91. package/dist/node/index.js +7 -3914
  92. package/dist/node/learning-journey.capability.js +1 -43
  93. package/dist/node/learning-journey.feature.js +1 -56
  94. package/package.json +5 -5
@@ -1,579 +1,2 @@
1
1
  // @bun
2
- // src/contracts/models.ts
3
- import { defineSchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
4
- var CourseModel = defineSchemaModel({
5
- name: "Course",
6
- description: "A learning course",
7
- fields: {
8
- id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
9
- title: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
10
- slug: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
11
- description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
12
- difficulty: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
13
- status: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
14
- estimatedDuration: {
15
- type: ScalarTypeEnum.Int_unsecure(),
16
- isOptional: true
17
- },
18
- thumbnailUrl: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
19
- createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
20
- }
21
- });
22
- var LearnerModel = defineSchemaModel({
23
- name: "Learner",
24
- description: "A learner profile",
25
- fields: {
26
- id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
27
- userId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
28
- displayName: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
29
- level: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
30
- totalXp: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
31
- currentStreak: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
32
- longestStreak: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
33
- createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
34
- }
35
- });
36
- var EnrollmentModel = defineSchemaModel({
37
- name: "Enrollment",
38
- description: "A course enrollment",
39
- fields: {
40
- id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
41
- learnerId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
42
- courseId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
43
- status: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
44
- progress: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
45
- startedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
46
- completedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true }
47
- }
48
- });
49
- var ProgressModel = defineSchemaModel({
50
- name: "LessonProgress",
51
- description: "Lesson progress",
52
- fields: {
53
- id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
54
- learnerId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
55
- lessonId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
56
- status: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
57
- progress: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
58
- score: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
59
- timeSpent: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
60
- completedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true }
61
- }
62
- });
63
- var DeckModel = defineSchemaModel({
64
- name: "Deck",
65
- description: "A flashcard deck",
66
- fields: {
67
- id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
68
- title: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
69
- description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
70
- cardCount: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
71
- isPublic: { type: ScalarTypeEnum.Boolean(), isOptional: false },
72
- createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
73
- }
74
- });
75
- var CardModel = defineSchemaModel({
76
- name: "Card",
77
- description: "A flashcard",
78
- fields: {
79
- id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
80
- deckId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
81
- front: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
82
- back: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
83
- hints: { type: ScalarTypeEnum.JSON(), isOptional: true },
84
- isDue: { type: ScalarTypeEnum.Boolean(), isOptional: false },
85
- nextReviewAt: { type: ScalarTypeEnum.DateTime(), isOptional: true }
86
- }
87
- });
88
- var AchievementModel = defineSchemaModel({
89
- name: "Achievement",
90
- description: "An achievement",
91
- fields: {
92
- id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
93
- key: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
94
- name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
95
- description: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
96
- icon: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
97
- xpReward: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
98
- unlockedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true }
99
- }
100
- });
101
- var EnrollInCourseInput = defineSchemaModel({
102
- name: "EnrollInCourseInput",
103
- description: "Input for enrolling in a course",
104
- fields: {
105
- courseId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false }
106
- }
107
- });
108
- var CompleteLessonInput = defineSchemaModel({
109
- name: "CompleteLessonInput",
110
- description: "Input for completing a lesson",
111
- fields: {
112
- lessonId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
113
- score: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
114
- timeSpent: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false }
115
- }
116
- });
117
- var SubmitCardReviewInput = defineSchemaModel({
118
- name: "SubmitCardReviewInput",
119
- description: "Input for submitting a card review",
120
- fields: {
121
- cardId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
122
- rating: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
123
- responseTimeMs: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true }
124
- }
125
- });
126
- var GetDueCardsInput = defineSchemaModel({
127
- name: "GetDueCardsInput",
128
- description: "Input for getting due cards",
129
- fields: {
130
- deckId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
131
- limit: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true }
132
- }
133
- });
134
- var GetDueCardsOutput = defineSchemaModel({
135
- name: "GetDueCardsOutput",
136
- description: "Output for getting due cards",
137
- fields: {
138
- cards: { type: CardModel, isArray: true, isOptional: false },
139
- total: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false }
140
- }
141
- });
142
- var GetLearnerDashboardInput = defineSchemaModel({
143
- name: "GetLearnerDashboardInput",
144
- description: "Input for getting learner dashboard",
145
- fields: {
146
- learnerId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
147
- }
148
- });
149
- var LearnerDashboardModel = defineSchemaModel({
150
- name: "LearnerDashboard",
151
- description: "Learner dashboard data",
152
- fields: {
153
- learner: { type: LearnerModel, isOptional: false },
154
- currentStreak: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
155
- dailyXpGoal: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
156
- dailyXpProgress: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
157
- activeEnrollments: {
158
- type: EnrollmentModel,
159
- isArray: true,
160
- isOptional: false
161
- },
162
- recentAchievements: {
163
- type: AchievementModel,
164
- isArray: true,
165
- isOptional: false
166
- },
167
- dueCardCount: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false }
168
- }
169
- });
170
- var SuccessOutput = defineSchemaModel({
171
- name: "SuccessOutput",
172
- description: "Generic success output",
173
- fields: {
174
- success: { type: ScalarTypeEnum.Boolean(), isOptional: false },
175
- xpEarned: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true }
176
- }
177
- });
178
-
179
- // src/contracts/shared.ts
180
- var LEARNING_JOURNEY_OWNERS = ["modules.learning-journey"];
181
-
182
- // src/contracts/onboarding.ts
183
- import { defineCommand, defineQuery } from "@contractspec/lib.contracts-spec";
184
- import { defineSchemaModel as defineSchemaModel2, ScalarTypeEnum as ScalarTypeEnum2 } from "@contractspec/lib.schema";
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
-
411
- // src/contracts/operations.ts
412
- import { defineCommand as defineCommand2, defineQuery as defineQuery2 } from "@contractspec/lib.contracts-spec";
413
- var EnrollInCourseContract = defineCommand2({
414
- meta: {
415
- key: "learning.enroll",
416
- version: "1.0.0",
417
- stability: "stable",
418
- owners: [...LEARNING_JOURNEY_OWNERS],
419
- tags: ["learning", "enrollment"],
420
- description: "Enroll in a course.",
421
- goal: "Start learning a new course.",
422
- context: "Called when a learner wants to start a course."
423
- },
424
- io: {
425
- input: EnrollInCourseInput,
426
- output: EnrollmentModel,
427
- errors: {
428
- COURSE_NOT_FOUND: {
429
- description: "Course does not exist",
430
- http: 404,
431
- gqlCode: "COURSE_NOT_FOUND",
432
- when: "Course ID is invalid"
433
- },
434
- ALREADY_ENROLLED: {
435
- description: "Already enrolled in course",
436
- http: 409,
437
- gqlCode: "ALREADY_ENROLLED",
438
- when: "Learner is already enrolled"
439
- }
440
- }
441
- },
442
- policy: {
443
- auth: "user"
444
- }
445
- });
446
- var CompleteLessonContract = defineCommand2({
447
- meta: {
448
- key: "learning.completeLesson",
449
- version: "1.0.0",
450
- stability: "stable",
451
- owners: [...LEARNING_JOURNEY_OWNERS],
452
- tags: ["learning", "progress"],
453
- description: "Mark a lesson as completed.",
454
- goal: "Record lesson completion and earn XP.",
455
- context: "Called when a learner finishes a lesson."
456
- },
457
- io: {
458
- input: CompleteLessonInput,
459
- output: SuccessOutput,
460
- errors: {
461
- LESSON_NOT_FOUND: {
462
- description: "Lesson does not exist",
463
- http: 404,
464
- gqlCode: "LESSON_NOT_FOUND",
465
- when: "Lesson ID is invalid"
466
- },
467
- NOT_ENROLLED: {
468
- description: "Not enrolled in course",
469
- http: 403,
470
- gqlCode: "NOT_ENROLLED",
471
- when: "Learner is not enrolled in the course"
472
- }
473
- }
474
- },
475
- policy: {
476
- auth: "user"
477
- }
478
- });
479
- var SubmitCardReviewContract = defineCommand2({
480
- meta: {
481
- key: "learning.submitCardReview",
482
- version: "1.0.0",
483
- stability: "stable",
484
- owners: [...LEARNING_JOURNEY_OWNERS],
485
- tags: ["learning", "flashcards"],
486
- description: "Submit a flashcard review.",
487
- goal: "Record review and update SRS schedule.",
488
- context: "Called when reviewing flashcards."
489
- },
490
- io: {
491
- input: SubmitCardReviewInput,
492
- output: SuccessOutput,
493
- errors: {
494
- CARD_NOT_FOUND: {
495
- description: "Card does not exist",
496
- http: 404,
497
- gqlCode: "CARD_NOT_FOUND",
498
- when: "Card ID is invalid"
499
- },
500
- INVALID_RATING: {
501
- description: "Invalid rating",
502
- http: 400,
503
- gqlCode: "INVALID_RATING",
504
- when: "Rating must be AGAIN, HARD, GOOD, or EASY"
505
- }
506
- }
507
- },
508
- policy: {
509
- auth: "user"
510
- }
511
- });
512
- var GetDueCardsContract = defineQuery2({
513
- meta: {
514
- key: "learning.getDueCards",
515
- version: "1.0.0",
516
- stability: "stable",
517
- owners: [...LEARNING_JOURNEY_OWNERS],
518
- tags: ["learning", "flashcards"],
519
- description: "Get flashcards due for review.",
520
- goal: "Get the next batch of cards to review.",
521
- context: "Called when starting a review session."
522
- },
523
- io: {
524
- input: GetDueCardsInput,
525
- output: GetDueCardsOutput
526
- },
527
- policy: {
528
- auth: "user"
529
- }
530
- });
531
- var GetLearnerDashboardContract = defineQuery2({
532
- meta: {
533
- key: "learning.getDashboard",
534
- version: "1.0.0",
535
- stability: "stable",
536
- owners: [...LEARNING_JOURNEY_OWNERS],
537
- tags: ["learning", "dashboard"],
538
- description: "Get learner dashboard data.",
539
- goal: "Display learner progress and stats.",
540
- context: "Called when viewing the learning dashboard."
541
- },
542
- io: {
543
- input: GetLearnerDashboardInput,
544
- output: LearnerDashboardModel
545
- },
546
- policy: {
547
- auth: "user"
548
- }
549
- });
550
- export {
551
- SuccessOutput,
552
- SubmitCardReviewInput,
553
- SubmitCardReviewContract,
554
- RecordOnboardingEventContract,
555
- ProgressModel,
556
- OnboardingTrackModel,
557
- OnboardingStepProgressModel,
558
- OnboardingStepModel,
559
- OnboardingProgressModel,
560
- ListOnboardingTracksContract,
561
- LearnerModel,
562
- LearnerDashboardModel,
563
- LEARNING_JOURNEY_OWNERS,
564
- GetOnboardingProgressContract,
565
- GetLearnerDashboardInput,
566
- GetLearnerDashboardContract,
567
- GetDueCardsOutput,
568
- GetDueCardsInput,
569
- GetDueCardsContract,
570
- EnrollmentModel,
571
- EnrollInCourseInput,
572
- EnrollInCourseContract,
573
- DeckModel,
574
- CourseModel,
575
- CompleteLessonInput,
576
- CompleteLessonContract,
577
- CardModel,
578
- AchievementModel
579
- };
2
+ import{defineSchemaModel as s,ScalarTypeEnum as e}from"@contractspec/lib.schema";var z=s({name:"Course",description:"A learning course",fields:{id:{type:e.String_unsecure(),isOptional:!1},title:{type:e.String_unsecure(),isOptional:!1},slug:{type:e.String_unsecure(),isOptional:!1},description:{type:e.String_unsecure(),isOptional:!0},difficulty:{type:e.String_unsecure(),isOptional:!1},status:{type:e.String_unsecure(),isOptional:!1},estimatedDuration:{type:e.Int_unsecure(),isOptional:!0},thumbnailUrl:{type:e.String_unsecure(),isOptional:!0},createdAt:{type:e.DateTime(),isOptional:!1}}}),x=s({name:"Learner",description:"A learner profile",fields:{id:{type:e.String_unsecure(),isOptional:!1},userId:{type:e.String_unsecure(),isOptional:!1},displayName:{type:e.String_unsecure(),isOptional:!0},level:{type:e.Int_unsecure(),isOptional:!1},totalXp:{type:e.Int_unsecure(),isOptional:!1},currentStreak:{type:e.Int_unsecure(),isOptional:!1},longestStreak:{type:e.Int_unsecure(),isOptional:!1},createdAt:{type:e.DateTime(),isOptional:!1}}}),o=s({name:"Enrollment",description:"A course enrollment",fields:{id:{type:e.String_unsecure(),isOptional:!1},learnerId:{type:e.String_unsecure(),isOptional:!1},courseId:{type:e.String_unsecure(),isOptional:!1},status:{type:e.String_unsecure(),isOptional:!1},progress:{type:e.Int_unsecure(),isOptional:!1},startedAt:{type:e.DateTime(),isOptional:!0},completedAt:{type:e.DateTime(),isOptional:!0}}}),F=s({name:"LessonProgress",description:"Lesson progress",fields:{id:{type:e.String_unsecure(),isOptional:!1},learnerId:{type:e.String_unsecure(),isOptional:!1},lessonId:{type:e.String_unsecure(),isOptional:!1},status:{type:e.String_unsecure(),isOptional:!1},progress:{type:e.Int_unsecure(),isOptional:!1},score:{type:e.Int_unsecure(),isOptional:!0},timeSpent:{type:e.Int_unsecure(),isOptional:!1},completedAt:{type:e.DateTime(),isOptional:!0}}}),H=s({name:"Deck",description:"A flashcard deck",fields:{id:{type:e.String_unsecure(),isOptional:!1},title:{type:e.String_unsecure(),isOptional:!1},description:{type:e.String_unsecure(),isOptional:!0},cardCount:{type:e.Int_unsecure(),isOptional:!1},isPublic:{type:e.Boolean(),isOptional:!1},createdAt:{type:e.DateTime(),isOptional:!1}}}),y=s({name:"Card",description:"A flashcard",fields:{id:{type:e.String_unsecure(),isOptional:!1},deckId:{type:e.String_unsecure(),isOptional:!1},front:{type:e.String_unsecure(),isOptional:!1},back:{type:e.String_unsecure(),isOptional:!1},hints:{type:e.JSON(),isOptional:!0},isDue:{type:e.Boolean(),isOptional:!1},nextReviewAt:{type:e.DateTime(),isOptional:!0}}}),D=s({name:"Achievement",description:"An achievement",fields:{id:{type:e.String_unsecure(),isOptional:!1},key:{type:e.String_unsecure(),isOptional:!1},name:{type:e.String_unsecure(),isOptional:!1},description:{type:e.String_unsecure(),isOptional:!1},icon:{type:e.String_unsecure(),isOptional:!0},xpReward:{type:e.Int_unsecure(),isOptional:!1},unlockedAt:{type:e.DateTime(),isOptional:!0}}}),l=s({name:"EnrollInCourseInput",description:"Input for enrolling in a course",fields:{courseId:{type:e.String_unsecure(),isOptional:!1}}}),u=s({name:"CompleteLessonInput",description:"Input for completing a lesson",fields:{lessonId:{type:e.String_unsecure(),isOptional:!1},score:{type:e.Int_unsecure(),isOptional:!0},timeSpent:{type:e.Int_unsecure(),isOptional:!1}}}),a=s({name:"SubmitCardReviewInput",description:"Input for submitting a card review",fields:{cardId:{type:e.String_unsecure(),isOptional:!1},rating:{type:e.String_unsecure(),isOptional:!1},responseTimeMs:{type:e.Int_unsecure(),isOptional:!0}}}),f=s({name:"GetDueCardsInput",description:"Input for getting due cards",fields:{deckId:{type:e.String_unsecure(),isOptional:!0},limit:{type:e.Int_unsecure(),isOptional:!0}}}),O=s({name:"GetDueCardsOutput",description:"Output for getting due cards",fields:{cards:{type:y,isArray:!0,isOptional:!1},total:{type:e.Int_unsecure(),isOptional:!1}}}),d=s({name:"GetLearnerDashboardInput",description:"Input for getting learner dashboard",fields:{learnerId:{type:e.String_unsecure(),isOptional:!0}}}),c=s({name:"LearnerDashboard",description:"Learner dashboard data",fields:{learner:{type:x,isOptional:!1},currentStreak:{type:e.Int_unsecure(),isOptional:!1},dailyXpGoal:{type:e.Int_unsecure(),isOptional:!1},dailyXpProgress:{type:e.Int_unsecure(),isOptional:!1},activeEnrollments:{type:o,isArray:!0,isOptional:!1},recentAchievements:{type:D,isArray:!0,isOptional:!1},dueCardCount:{type:e.Int_unsecure(),isOptional:!1}}}),r=s({name:"SuccessOutput",description:"Generic success output",fields:{success:{type:e.Boolean(),isOptional:!1},xpEarned:{type:e.Int_unsecure(),isOptional:!0}}});var i=["modules.learning-journey"];import{defineCommand as A,defineQuery as _}from"@contractspec/lib.contracts-spec";import{defineSchemaModel as n,ScalarTypeEnum as t}from"@contractspec/lib.schema";var k=n({name:"OnboardingStepCondition",description:"Structured completion condition for onboarding steps.",fields:{eventName:{type:t.String_unsecure(),isOptional:!1},eventVersion:{type:t.String_unsecure(),isOptional:!0},sourceModule:{type:t.String_unsecure(),isOptional:!0},payloadFilter:{type:t.JSON(),isOptional:!0}}}),v=n({name:"OnboardingStep",description:"Declarative onboarding step definition.",fields:{id:{type:t.String_unsecure(),isOptional:!1},trackId:{type:t.String_unsecure(),isOptional:!1},title:{type:t.String_unsecure(),isOptional:!1},description:{type:t.String_unsecure(),isOptional:!0},instructions:{type:t.String_unsecure(),isOptional:!0},helpUrl:{type:t.String_unsecure(),isOptional:!0},order:{type:t.Int_unsecure(),isOptional:!1},completionEvent:{type:t.String_unsecure(),isOptional:!1},completionCondition:{type:k,isOptional:!0},xpReward:{type:t.Int_unsecure(),isOptional:!0},isRequired:{type:t.Boolean(),isOptional:!0},canSkip:{type:t.Boolean(),isOptional:!0},actionUrl:{type:t.String_unsecure(),isOptional:!0},actionLabel:{type:t.String_unsecure(),isOptional:!0},metadata:{type:t.JSON(),isOptional:!0}}}),C=n({name:"OnboardingTrack",description:"Onboarding track metadata and steps.",fields:{id:{type:t.String_unsecure(),isOptional:!1},productId:{type:t.String_unsecure(),isOptional:!0},name:{type:t.String_unsecure(),isOptional:!1},description:{type:t.String_unsecure(),isOptional:!0},targetUserSegment:{type:t.String_unsecure(),isOptional:!0},targetRole:{type:t.String_unsecure(),isOptional:!0},isActive:{type:t.Boolean(),isOptional:!0},isRequired:{type:t.Boolean(),isOptional:!0},canSkip:{type:t.Boolean(),isOptional:!0},totalXp:{type:t.Int_unsecure(),isOptional:!0},completionXpBonus:{type:t.Int_unsecure(),isOptional:!0},completionBadgeKey:{type:t.String_unsecure(),isOptional:!0},streakHoursWindow:{type:t.Int_unsecure(),isOptional:!0},streakBonusXp:{type:t.Int_unsecure(),isOptional:!0},metadata:{type:t.JSON(),isOptional:!0},steps:{type:v,isArray:!0,isOptional:!1}}}),w=n({name:"OnboardingStepProgress",description:"Progress for a specific onboarding step.",fields:{stepId:{type:t.String_unsecure(),isOptional:!1},status:{type:t.String_unsecure(),isOptional:!1},xpEarned:{type:t.Int_unsecure(),isOptional:!0},triggeringEvent:{type:t.String_unsecure(),isOptional:!0},eventPayload:{type:t.JSON(),isOptional:!0},completedAt:{type:t.DateTime(),isOptional:!0}}}),g=n({name:"OnboardingProgress",description:"Aggregated progress for an onboarding track.",fields:{learnerId:{type:t.String_unsecure(),isOptional:!0},trackId:{type:t.String_unsecure(),isOptional:!1},progress:{type:t.Int_unsecure(),isOptional:!1},isCompleted:{type:t.Boolean(),isOptional:!1},xpEarned:{type:t.Int_unsecure(),isOptional:!0},startedAt:{type:t.DateTime(),isOptional:!0},completedAt:{type:t.DateTime(),isOptional:!0},lastActivityAt:{type:t.DateTime(),isOptional:!0},steps:{type:w,isArray:!0,isOptional:!0}}}),B=n({name:"ListOnboardingTracksInput",description:"Filters for listing onboarding tracks.",fields:{learnerId:{type:t.String_unsecure(),isOptional:!0},productId:{type:t.String_unsecure(),isOptional:!0},trackIds:{type:t.String_unsecure(),isArray:!0,isOptional:!0},includeProgress:{type:t.Boolean(),isOptional:!0}}}),X=n({name:"ListOnboardingTracksOutput",description:"Available onboarding tracks with optional progress.",fields:{tracks:{type:C,isArray:!0,isOptional:!1},progress:{type:g,isArray:!0,isOptional:!0}}}),h=n({name:"GetOnboardingProgressInput",description:"Input for fetching onboarding progress for a track.",fields:{trackId:{type:t.String_unsecure(),isOptional:!1},learnerId:{type:t.String_unsecure(),isOptional:!0}}}),j=n({name:"RecordOnboardingEventInput",description:"Record a domain event to advance onboarding progress via completion conditions.",fields:{learnerId:{type:t.String_unsecure(),isOptional:!1},trackId:{type:t.String_unsecure(),isOptional:!0},eventName:{type:t.String_unsecure(),isOptional:!1},eventVersion:{type:t.String_unsecure(),isOptional:!0},eventPayload:{type:t.JSON(),isOptional:!0},occurredAt:{type:t.DateTime(),isOptional:!0}}}),G=_({meta:{key:"learning.onboarding.listTracks",version:"1.0.0",stability:"stable",owners:[...i],tags:["learning","onboarding","journey"],description:"List onboarding tracks available to a learner or product.",goal:"Expose track catalog for UI/API surfaces.",context:"Called when showing onboarding/learning journey catalog."},io:{input:B,output:X},policy:{auth:"user"}}),b=_({meta:{key:"learning.onboarding.getProgress",version:"1.0.0",stability:"stable",owners:[...i],tags:["learning","onboarding","journey"],description:"Fetch onboarding progress for a specific track.",goal:"Display learner progress and remaining steps.",context:"Called when rendering a track detail or widget."},io:{input:h,output:g},policy:{auth:"user"}}),Q=A({meta:{key:"learning.onboarding.recordEvent",version:"1.0.0",stability:"stable",owners:[...i],tags:["learning","onboarding","events"],description:"Record a domain event to evaluate onboarding step completion conditions.",goal:"Advance onboarding automatically from product events.",context:"Called by event bus handlers when relevant product events fire (e.g., deal.created)."},io:{input:j,output:r,errors:{TRACK_NOT_FOUND:{description:"Track not found for event routing",http:404,gqlCode:"TRACK_NOT_FOUND",when:"Track ID or routing context is invalid"},STEP_NOT_FOUND:{description:"Step not found for completion condition",http:404,gqlCode:"STEP_NOT_FOUND",when:"No step matches the incoming event"}}},policy:{auth:"user"}});import{defineCommand as p,defineQuery as I}from"@contractspec/lib.contracts-spec";var Y=p({meta:{key:"learning.enroll",version:"1.0.0",stability:"stable",owners:[...i],tags:["learning","enrollment"],description:"Enroll in a course.",goal:"Start learning a new course.",context:"Called when a learner wants to start a course."},io:{input:l,output:o,errors:{COURSE_NOT_FOUND:{description:"Course does not exist",http:404,gqlCode:"COURSE_NOT_FOUND",when:"Course ID is invalid"},ALREADY_ENROLLED:{description:"Already enrolled in course",http:409,gqlCode:"ALREADY_ENROLLED",when:"Learner is already enrolled"}}},policy:{auth:"user"}}),R=p({meta:{key:"learning.completeLesson",version:"1.0.0",stability:"stable",owners:[...i],tags:["learning","progress"],description:"Mark a lesson as completed.",goal:"Record lesson completion and earn XP.",context:"Called when a learner finishes a lesson."},io:{input:u,output:r,errors:{LESSON_NOT_FOUND:{description:"Lesson does not exist",http:404,gqlCode:"LESSON_NOT_FOUND",when:"Lesson ID is invalid"},NOT_ENROLLED:{description:"Not enrolled in course",http:403,gqlCode:"NOT_ENROLLED",when:"Learner is not enrolled in the course"}}},policy:{auth:"user"}}),m=p({meta:{key:"learning.submitCardReview",version:"1.0.0",stability:"stable",owners:[...i],tags:["learning","flashcards"],description:"Submit a flashcard review.",goal:"Record review and update SRS schedule.",context:"Called when reviewing flashcards."},io:{input:a,output:r,errors:{CARD_NOT_FOUND:{description:"Card does not exist",http:404,gqlCode:"CARD_NOT_FOUND",when:"Card ID is invalid"},INVALID_RATING:{description:"Invalid rating",http:400,gqlCode:"INVALID_RATING",when:"Rating must be AGAIN, HARD, GOOD, or EASY"}}},policy:{auth:"user"}}),N=I({meta:{key:"learning.getDueCards",version:"1.0.0",stability:"stable",owners:[...i],tags:["learning","flashcards"],description:"Get flashcards due for review.",goal:"Get the next batch of cards to review.",context:"Called when starting a review session."},io:{input:f,output:O},policy:{auth:"user"}}),S=I({meta:{key:"learning.getDashboard",version:"1.0.0",stability:"stable",owners:[...i],tags:["learning","dashboard"],description:"Get learner dashboard data.",goal:"Display learner progress and stats.",context:"Called when viewing the learning dashboard."},io:{input:d,output:c},policy:{auth:"user"}});export{r as SuccessOutput,a as SubmitCardReviewInput,m as SubmitCardReviewContract,Q as RecordOnboardingEventContract,F as ProgressModel,C as OnboardingTrackModel,w as OnboardingStepProgressModel,v as OnboardingStepModel,g as OnboardingProgressModel,G as ListOnboardingTracksContract,x as LearnerModel,c as LearnerDashboardModel,i as LEARNING_JOURNEY_OWNERS,b as GetOnboardingProgressContract,d as GetLearnerDashboardInput,S as GetLearnerDashboardContract,O as GetDueCardsOutput,f as GetDueCardsInput,N as GetDueCardsContract,o as EnrollmentModel,l as EnrollInCourseInput,Y as EnrollInCourseContract,H as DeckModel,z as CourseModel,u as CompleteLessonInput,R as CompleteLessonContract,y as CardModel,D as AchievementModel};