@contractspec/example.learning-journey-registry 1.57.0 → 1.59.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 (77) hide show
  1. package/.turbo/turbo-build.log +52 -55
  2. package/.turbo/turbo-prebuild.log +1 -0
  3. package/CHANGELOG.md +45 -0
  4. package/dist/api-types.d.ts +33 -37
  5. package/dist/api-types.d.ts.map +1 -1
  6. package/dist/api-types.js +1 -0
  7. package/dist/api.d.ts +7 -11
  8. package/dist/api.d.ts.map +1 -1
  9. package/dist/api.js +261 -161
  10. package/dist/api.test.d.ts +2 -0
  11. package/dist/api.test.d.ts.map +1 -0
  12. package/dist/browser/api-types.js +0 -0
  13. package/dist/browser/api.js +270 -0
  14. package/dist/browser/docs/index.js +33 -0
  15. package/dist/browser/docs/learning-journey-registry.docblock.js +33 -0
  16. package/dist/browser/example.js +32 -0
  17. package/dist/browser/index.js +540 -0
  18. package/dist/browser/learning-journey-registry.feature.js +45 -0
  19. package/dist/browser/presentations/index.js +67 -0
  20. package/dist/browser/progress-store.js +34 -0
  21. package/dist/browser/tracks.js +52 -0
  22. package/dist/browser/ui/LearningMiniApp.js +133 -0
  23. package/dist/browser/ui/index.js +133 -0
  24. package/dist/docs/index.d.ts +2 -1
  25. package/dist/docs/index.d.ts.map +1 -0
  26. package/dist/docs/index.js +34 -1
  27. package/dist/docs/learning-journey-registry.docblock.d.ts +2 -1
  28. package/dist/docs/learning-journey-registry.docblock.d.ts.map +1 -0
  29. package/dist/docs/learning-journey-registry.docblock.js +18 -22
  30. package/dist/example.d.ts +2 -6
  31. package/dist/example.d.ts.map +1 -1
  32. package/dist/example.js +31 -39
  33. package/dist/index.d.ts +8 -8
  34. package/dist/index.d.ts.map +1 -0
  35. package/dist/index.js +541 -10
  36. package/dist/learning-journey-registry.feature.d.ts +1 -6
  37. package/dist/learning-journey-registry.feature.d.ts.map +1 -1
  38. package/dist/learning-journey-registry.feature.js +44 -73
  39. package/dist/node/api-types.js +0 -0
  40. package/dist/node/api.js +270 -0
  41. package/dist/node/docs/index.js +33 -0
  42. package/dist/node/docs/learning-journey-registry.docblock.js +33 -0
  43. package/dist/node/example.js +32 -0
  44. package/dist/node/index.js +540 -0
  45. package/dist/node/learning-journey-registry.feature.js +45 -0
  46. package/dist/node/presentations/index.js +67 -0
  47. package/dist/node/progress-store.js +34 -0
  48. package/dist/node/tracks.js +52 -0
  49. package/dist/node/ui/LearningMiniApp.js +133 -0
  50. package/dist/node/ui/index.js +133 -0
  51. package/dist/presentations/index.d.ts +4 -9
  52. package/dist/presentations/index.d.ts.map +1 -1
  53. package/dist/presentations/index.js +63 -66
  54. package/dist/progress-store.d.ts +6 -10
  55. package/dist/progress-store.d.ts.map +1 -1
  56. package/dist/progress-store.js +33 -29
  57. package/dist/tracks.d.ts +33 -36
  58. package/dist/tracks.d.ts.map +1 -1
  59. package/dist/tracks.js +44 -39
  60. package/dist/ui/LearningMiniApp.d.ts +8 -16
  61. package/dist/ui/LearningMiniApp.d.ts.map +1 -1
  62. package/dist/ui/LearningMiniApp.js +123 -69
  63. package/dist/ui/index.d.ts +2 -2
  64. package/dist/ui/index.d.ts.map +1 -0
  65. package/dist/ui/index.js +134 -3
  66. package/package.json +143 -48
  67. package/tsdown.config.js +1 -2
  68. package/.turbo/turbo-build$colon$bundle.log +0 -55
  69. package/dist/api.js.map +0 -1
  70. package/dist/docs/learning-journey-registry.docblock.js.map +0 -1
  71. package/dist/example.js.map +0 -1
  72. package/dist/learning-journey-registry.feature.js.map +0 -1
  73. package/dist/presentations/index.js.map +0 -1
  74. package/dist/progress-store.js.map +0 -1
  75. package/dist/tracks.js.map +0 -1
  76. package/dist/ui/LearningMiniApp.js.map +0 -1
  77. package/tsconfig.tsbuildinfo +0 -1
@@ -0,0 +1,540 @@
1
+ // src/tracks.ts
2
+ import { crmLearningTracks } from "@contractspec/example.learning-journey-crm-onboarding/track";
3
+ import { drillTracks } from "@contractspec/example.learning-journey-duo-drills/track";
4
+ import { ambientCoachTracks } from "@contractspec/example.learning-journey-ambient-coach/track";
5
+ import { questTracks } from "@contractspec/example.learning-journey-quest-challenges/track";
6
+ import { platformLearningTracks } from "@contractspec/example.learning-journey-platform-tour/track";
7
+ import { studioLearningTracks } from "@contractspec/example.learning-journey-studio-onboarding/track";
8
+ var mapStep = (step) => ({
9
+ id: step.id,
10
+ title: step.title,
11
+ description: step.description,
12
+ completionEvent: step.completion.eventName,
13
+ completionCondition: step.completion,
14
+ xpReward: step.xpReward,
15
+ isRequired: step.isRequired,
16
+ canSkip: step.canSkip,
17
+ actionUrl: step.actionUrl,
18
+ actionLabel: step.actionLabel,
19
+ availability: step.availability,
20
+ metadata: step.metadata
21
+ });
22
+ var mapTrackSpecToDto = (track) => ({
23
+ id: track.id,
24
+ name: track.name,
25
+ description: track.description,
26
+ productId: track.productId,
27
+ targetUserSegment: track.targetUserSegment,
28
+ targetRole: track.targetRole,
29
+ totalXp: track.totalXp,
30
+ streakRule: track.streakRule,
31
+ completionRewards: track.completionRewards,
32
+ steps: track.steps.map(mapStep),
33
+ metadata: track.metadata
34
+ });
35
+ var learningJourneyTracks = [
36
+ ...studioLearningTracks,
37
+ ...platformLearningTracks,
38
+ ...crmLearningTracks,
39
+ ...drillTracks,
40
+ ...ambientCoachTracks,
41
+ ...questTracks
42
+ ];
43
+ var onboardingTrackCatalog = learningJourneyTracks.map(mapTrackSpecToDto);
44
+ // src/progress-store.ts
45
+ var progressStore = new Map;
46
+ var getTrackResolver = (tracks) => (trackId) => tracks.find((t) => t.id === trackId);
47
+ var getLearnerTracks = (learnerId) => {
48
+ const existing = progressStore.get(learnerId);
49
+ if (existing)
50
+ return existing;
51
+ const map = new Map;
52
+ progressStore.set(learnerId, map);
53
+ return map;
54
+ };
55
+ var initProgress = (learnerId, track) => ({
56
+ learnerId,
57
+ trackId: track.id,
58
+ progress: 0,
59
+ isCompleted: false,
60
+ xpEarned: 0,
61
+ steps: track.steps.map((step) => ({
62
+ id: step.id,
63
+ status: "PENDING",
64
+ xpEarned: 0,
65
+ occurrences: 0,
66
+ masteryCount: 0
67
+ })),
68
+ startedAt: undefined,
69
+ completedAt: undefined,
70
+ lastActivityAt: undefined
71
+ });
72
+
73
+ // src/api.ts
74
+ var getTrack = getTrackResolver(learningJourneyTracks);
75
+ var matchesFilter = (filter, payload) => {
76
+ if (!filter)
77
+ return true;
78
+ if (!payload)
79
+ return false;
80
+ return Object.entries(filter).every(([key, value]) => payload[key] === value);
81
+ };
82
+ var matchesBaseEvent = (condition, event) => {
83
+ if (condition.eventName !== event.name)
84
+ return false;
85
+ if (condition.eventVersion !== undefined && event.version !== undefined) {
86
+ if (condition.eventVersion !== event.version)
87
+ return false;
88
+ }
89
+ if (condition.sourceModule && event.sourceModule && condition.sourceModule !== event.sourceModule) {
90
+ return false;
91
+ }
92
+ return matchesFilter(condition.payloadFilter, event.payload);
93
+ };
94
+ var matchesCondition = (condition, event, step, trackStartedAt) => {
95
+ if (condition.kind === "count") {
96
+ if (!matchesBaseEvent(condition, event))
97
+ return { matched: false };
98
+ const occurrences = (step.occurrences ?? 0) + 1;
99
+ const within = condition.withinHours === undefined || Boolean(trackStartedAt && event.occurredAt && (event.occurredAt.getTime() - trackStartedAt.getTime()) / (1000 * 60 * 60) <= condition.withinHours);
100
+ return { matched: within && occurrences >= condition.atLeast, occurrences };
101
+ }
102
+ if (condition.kind === "time_window") {
103
+ if (!matchesBaseEvent(condition, event))
104
+ return { matched: false };
105
+ if (condition.withinHoursOfStart !== undefined && trackStartedAt && event.occurredAt) {
106
+ const hoursSinceStart = (event.occurredAt.getTime() - trackStartedAt.getTime()) / (1000 * 60 * 60);
107
+ if (hoursSinceStart > condition.withinHoursOfStart) {
108
+ return { matched: false };
109
+ }
110
+ }
111
+ return { matched: true };
112
+ }
113
+ if (condition.kind === "srs_mastery") {
114
+ if (event.name !== condition.eventName)
115
+ return { matched: false };
116
+ const payload = event.payload;
117
+ if (!matchesFilter(condition.payloadFilter, payload)) {
118
+ return { matched: false };
119
+ }
120
+ const skillKey = condition.skillIdField ?? "skillId";
121
+ const masteryKey = condition.masteryField ?? "mastery";
122
+ const skillId = payload?.[skillKey];
123
+ const masteryValue = payload?.[masteryKey];
124
+ if (skillId === undefined || masteryValue === undefined) {
125
+ return { matched: false };
126
+ }
127
+ if (typeof masteryValue !== "number")
128
+ return { matched: false };
129
+ if (masteryValue < condition.minimumMastery)
130
+ return { matched: false };
131
+ const masteryCount = (step.masteryCount ?? 0) + 1;
132
+ const required = condition.requiredCount ?? 1;
133
+ return { matched: masteryCount >= required, masteryCount };
134
+ }
135
+ return { matched: matchesBaseEvent(condition, event) };
136
+ };
137
+ var getAvailability = (availability, startedAt) => {
138
+ if (!availability || !startedAt)
139
+ return {};
140
+ const baseTime = startedAt.getTime();
141
+ let unlockTime = baseTime;
142
+ if (availability.unlockOnDay !== undefined) {
143
+ unlockTime = baseTime + (availability.unlockOnDay - 1) * 24 * 60 * 60 * 1000;
144
+ }
145
+ if (availability.unlockAfterHours !== undefined) {
146
+ unlockTime = baseTime + availability.unlockAfterHours * 60 * 60 * 1000;
147
+ }
148
+ const availableAt = new Date(unlockTime);
149
+ const dueAt = availability.dueWithinHours !== undefined ? new Date(availableAt.getTime() + availability.dueWithinHours * 60 * 60 * 1000) : undefined;
150
+ return { availableAt, dueAt };
151
+ };
152
+ var computeProgressPercent = (steps) => {
153
+ const total = steps.length || 1;
154
+ const done = steps.filter((s) => s.status === "COMPLETED").length;
155
+ return Math.round(done / total * 100);
156
+ };
157
+ var applyTrackCompletionBonuses = (track, progress) => {
158
+ if (progress.isCompleted)
159
+ return progress;
160
+ const completedAt = new Date;
161
+ const startedAt = progress.startedAt ?? completedAt;
162
+ const hoursElapsed = (completedAt.getTime() - startedAt.getTime()) / (1000 * 60 * 60);
163
+ let xpEarned = progress.xpEarned;
164
+ const { completionRewards, streakRule } = track;
165
+ if (completionRewards?.xpBonus) {
166
+ xpEarned += completionRewards.xpBonus;
167
+ }
168
+ if (streakRule?.hoursWindow !== undefined && hoursElapsed <= streakRule.hoursWindow && streakRule.bonusXp) {
169
+ xpEarned += streakRule.bonusXp;
170
+ }
171
+ return {
172
+ ...progress,
173
+ xpEarned,
174
+ isCompleted: true,
175
+ completedAt,
176
+ lastActivityAt: completedAt
177
+ };
178
+ };
179
+ var listTracks = (learnerId) => {
180
+ const progressMap = learnerId ? getLearnerTracks(learnerId) : undefined;
181
+ const progress = learnerId && progressMap ? Array.from(progressMap.values()) : [];
182
+ return {
183
+ tracks: learningJourneyTracks,
184
+ progress
185
+ };
186
+ };
187
+ var getProgress = (trackId, learnerId) => {
188
+ const track = getTrack(trackId);
189
+ if (!track)
190
+ return;
191
+ const map = getLearnerTracks(learnerId);
192
+ const existing = map.get(trackId) ?? initProgress(learnerId, track);
193
+ map.set(trackId, existing);
194
+ return existing;
195
+ };
196
+ var recordEvent = (event) => {
197
+ const targets = event.trackId !== undefined ? learningJourneyTracks.filter((t) => t.id === event.trackId) : learningJourneyTracks;
198
+ const updated = [];
199
+ const eventTime = event.occurredAt ?? new Date;
200
+ for (const track of targets) {
201
+ const map = getLearnerTracks(event.learnerId);
202
+ const current = map.get(track.id) ?? initProgress(event.learnerId, track);
203
+ const startedAt = current.startedAt ?? eventTime;
204
+ let changed = current.startedAt === undefined;
205
+ const steps = current.steps.map((step) => {
206
+ if (step.status === "COMPLETED")
207
+ return step;
208
+ const spec = track.steps.find((s) => s.id === step.id);
209
+ if (!spec)
210
+ return step;
211
+ const { availableAt, dueAt } = getAvailability(spec.availability, startedAt);
212
+ if (availableAt && eventTime < availableAt) {
213
+ return { ...step, availableAt, dueAt };
214
+ }
215
+ if (dueAt && eventTime > dueAt) {
216
+ return { ...step, availableAt, dueAt };
217
+ }
218
+ const result = matchesCondition(spec.completion, event, step, startedAt);
219
+ if (result.matched) {
220
+ changed = true;
221
+ return {
222
+ ...step,
223
+ status: "COMPLETED",
224
+ xpEarned: spec.xpReward ?? 0,
225
+ completedAt: eventTime,
226
+ triggeringEvent: event.name,
227
+ eventPayload: event.payload,
228
+ occurrences: result.occurrences ?? step.occurrences,
229
+ masteryCount: result.masteryCount ?? step.masteryCount,
230
+ availableAt,
231
+ dueAt
232
+ };
233
+ }
234
+ if (result.occurrences !== undefined || result.masteryCount !== undefined) {
235
+ changed = true;
236
+ }
237
+ return {
238
+ ...step,
239
+ occurrences: result.occurrences ?? step.occurrences,
240
+ masteryCount: result.masteryCount ?? step.masteryCount,
241
+ availableAt,
242
+ dueAt
243
+ };
244
+ });
245
+ if (!changed) {
246
+ continue;
247
+ }
248
+ const xpEarned = steps.reduce((sum, s) => sum + s.xpEarned, 0) + (track.totalXp ?? 0);
249
+ let progress = {
250
+ ...current,
251
+ steps,
252
+ xpEarned,
253
+ startedAt,
254
+ lastActivityAt: eventTime,
255
+ progress: computeProgressPercent(steps)
256
+ };
257
+ const allDone = steps.every((s) => s.status === "COMPLETED");
258
+ if (allDone) {
259
+ progress = applyTrackCompletionBonuses(track, progress);
260
+ }
261
+ map.set(track.id, progress);
262
+ updated.push(progress);
263
+ }
264
+ return updated;
265
+ };
266
+
267
+ // src/docs/learning-journey-registry.docblock.ts
268
+ import { registerDocBlocks } from "@contractspec/lib.contracts/docs";
269
+ var registryDocBlocks = [
270
+ {
271
+ id: "docs.learning-journey.registry",
272
+ title: "Learning Journey — Example Track Registry",
273
+ summary: "Aggregates learning journey example tracks (Studio onboarding, Platform tour, CRM first win, Drills, Ambient Coach, Quest challenges).",
274
+ kind: "usage",
275
+ visibility: "public",
276
+ route: "/docs/learning-journey/registry",
277
+ tags: ["learning", "registry", "onboarding"],
278
+ body: `## Tracks
279
+ - \`studio_getting_started\` (Studio onboarding)
280
+ - \`platform_primitives_tour\` (Platform primitives)
281
+ - \`crm_first_win\` (CRM pipeline onboarding)
282
+ - \`drills_language_basics\` (Drills & SRS)
283
+ - \`money_ambient_coach\`, \`coliving_ambient_coach\` (Ambient tips)
284
+ - \`money_reset_7day\` (Quest/challenge)
285
+
286
+ ## Exports
287
+ - \`learningJourneyTracks\` — raw specs
288
+ - \`onboardingTrackCatalog\` — DTOs aligned with onboarding API
289
+ - \`mapTrackSpecToDto\` — helper to map individual tracks
290
+
291
+ ## Wiring
292
+ - Use with onboarding API contracts:
293
+ - \`learning.onboarding.listTracks\`
294
+ - \`learning.onboarding.getProgress\`
295
+ - \`learning.onboarding.recordEvent\`
296
+ - Intended for registry/adapters in Studio UI or services that surface tracks.`
297
+ }
298
+ ];
299
+ registerDocBlocks(registryDocBlocks);
300
+ // src/example.ts
301
+ import { defineExample } from "@contractspec/lib.contracts";
302
+ var example = defineExample({
303
+ meta: {
304
+ key: "learning-journey-registry",
305
+ version: "1.0.0",
306
+ title: "Learning Journey Registry",
307
+ description: "Registry of learning journey tracks + presentations + UI mini-app bindings.",
308
+ kind: "library",
309
+ visibility: "public",
310
+ stability: "experimental",
311
+ owners: ["@platform.core"],
312
+ tags: ["learning", "journey", "registry"]
313
+ },
314
+ docs: {
315
+ rootDocId: "docs.examples.learning-journey-registry"
316
+ },
317
+ entrypoints: {
318
+ packageName: "@contractspec/example.learning-journey-registry",
319
+ docs: "./docs"
320
+ },
321
+ surfaces: {
322
+ templates: true,
323
+ sandbox: { enabled: true, modes: ["markdown", "specs"] },
324
+ studio: { enabled: true, installable: true },
325
+ mcp: { enabled: true }
326
+ }
327
+ });
328
+ var example_default = example;
329
+
330
+ // src/presentations/index.ts
331
+ import {
332
+ definePresentation,
333
+ StabilityEnum
334
+ } from "@contractspec/lib.contracts";
335
+ var baseMeta = {
336
+ domain: "learning-journey",
337
+ title: "Learning Journey",
338
+ owners: ["@learning-team"],
339
+ tags: ["learning", "journey", "onboarding"],
340
+ stability: StabilityEnum.Experimental,
341
+ goal: "Progress through learning tracks",
342
+ context: "Learning journey section"
343
+ };
344
+ var LearningTrackListPresentation = definePresentation({
345
+ meta: {
346
+ key: "learning.journey.track_list",
347
+ version: "1.0.0",
348
+ description: "List of learning journeys available to the learner.",
349
+ ...baseMeta
350
+ },
351
+ source: {
352
+ type: "component",
353
+ framework: "react",
354
+ componentKey: "LearningTrackList"
355
+ },
356
+ targets: ["react", "markdown"]
357
+ });
358
+ var LearningTrackDetailPresentation = definePresentation({
359
+ meta: {
360
+ key: "learning.journey.track_detail",
361
+ version: "1.0.0",
362
+ description: "Track detail with steps and progress state.",
363
+ ...baseMeta
364
+ },
365
+ source: {
366
+ type: "component",
367
+ framework: "react",
368
+ componentKey: "LearningTrackDetail"
369
+ },
370
+ targets: ["react", "markdown", "application/json"]
371
+ });
372
+ var LearningTrackProgressWidgetPresentation = definePresentation({
373
+ meta: {
374
+ key: "learning.journey.progress_widget",
375
+ version: "1.0.0",
376
+ description: "Compact widget showing progress for active track.",
377
+ ...baseMeta
378
+ },
379
+ source: {
380
+ type: "component",
381
+ framework: "react",
382
+ componentKey: "LearningTrackProgressWidget"
383
+ },
384
+ targets: ["react"]
385
+ });
386
+ var learningJourneyPresentations = [
387
+ LearningTrackListPresentation,
388
+ LearningTrackDetailPresentation,
389
+ LearningTrackProgressWidgetPresentation
390
+ ];
391
+
392
+ // src/learning-journey-registry.feature.ts
393
+ import { defineFeature } from "@contractspec/lib.contracts";
394
+ var LearningJourneyRegistryFeature = defineFeature({
395
+ meta: {
396
+ key: "learning-journey-registry",
397
+ version: "1.0.0",
398
+ title: "Learning Journey Registry",
399
+ description: "Shared registry and presentations for learning journey tracks",
400
+ domain: "learning-journey",
401
+ owners: ["@learning-team"],
402
+ tags: ["learning", "journey", "onboarding", "registry"],
403
+ stability: "experimental"
404
+ },
405
+ operations: [],
406
+ events: [],
407
+ presentations: [
408
+ { key: "learning.journey.track_list", version: "1.0.0" },
409
+ { key: "learning.journey.track_detail", version: "1.0.0" },
410
+ { key: "learning.journey.progress_widget", version: "1.0.0" }
411
+ ],
412
+ opToPresentation: [],
413
+ presentationsTargets: [
414
+ {
415
+ key: "learning.journey.track_list",
416
+ version: "1.0.0",
417
+ targets: ["react", "markdown"]
418
+ },
419
+ {
420
+ key: "learning.journey.track_detail",
421
+ version: "1.0.0",
422
+ targets: ["react", "markdown", "application/json"]
423
+ },
424
+ {
425
+ key: "learning.journey.progress_widget",
426
+ version: "1.0.0",
427
+ targets: ["react"]
428
+ }
429
+ ],
430
+ capabilities: {
431
+ requires: [{ key: "identity", version: "1.0.0" }]
432
+ }
433
+ });
434
+
435
+ // src/ui/LearningMiniApp.tsx
436
+ import { useMemo } from "react";
437
+ import { GamifiedMiniApp } from "@contractspec/example.learning-journey-ui-gamified";
438
+ import { OnboardingMiniApp } from "@contractspec/example.learning-journey-ui-onboarding";
439
+ import { CoachingMiniApp } from "@contractspec/example.learning-journey-ui-coaching";
440
+ import { jsxDEV } from "react/jsx-dev-runtime";
441
+ "use client";
442
+ var TEMPLATE_TO_TRACK = {
443
+ "learning-journey-duo-drills": "drills_language_basics",
444
+ "learning-journey-quest-challenges": "money_reset_7day",
445
+ "learning-journey-studio-onboarding": "studio_getting_started",
446
+ "learning-journey-platform-tour": "platform_tour",
447
+ "learning-journey-ambient-coach": "money_ambient_coach",
448
+ "learning-journey-crm-onboarding": "crm_first_win"
449
+ };
450
+ var TEMPLATE_TO_APP_TYPE = {
451
+ "learning-journey-duo-drills": "gamified",
452
+ "learning-journey-quest-challenges": "gamified",
453
+ "learning-journey-studio-onboarding": "onboarding",
454
+ "learning-journey-platform-tour": "onboarding",
455
+ "learning-journey-ambient-coach": "coaching",
456
+ "learning-journey-crm-onboarding": "coaching"
457
+ };
458
+ function LearningMiniApp({
459
+ templateId,
460
+ initialView = "overview",
461
+ onViewChange
462
+ }) {
463
+ const track = useMemo(() => {
464
+ const trackId = TEMPLATE_TO_TRACK[templateId];
465
+ if (!trackId)
466
+ return null;
467
+ return learningJourneyTracks.find((t) => t.id === trackId);
468
+ }, [templateId]);
469
+ const appType = TEMPLATE_TO_APP_TYPE[templateId];
470
+ if (!track) {
471
+ return /* @__PURE__ */ jsxDEV("div", {
472
+ className: "rounded-lg border border-amber-500/50 bg-amber-500/10 p-6 text-center",
473
+ children: /* @__PURE__ */ jsxDEV("p", {
474
+ className: "text-amber-500",
475
+ children: [
476
+ "Unknown learning template: ",
477
+ templateId
478
+ ]
479
+ }, undefined, true, undefined, this)
480
+ }, undefined, false, undefined, this);
481
+ }
482
+ switch (appType) {
483
+ case "gamified":
484
+ return /* @__PURE__ */ jsxDEV(GamifiedMiniApp, {
485
+ track,
486
+ initialView,
487
+ onViewChange
488
+ }, undefined, false, undefined, this);
489
+ case "onboarding":
490
+ return /* @__PURE__ */ jsxDEV(OnboardingMiniApp, {
491
+ track,
492
+ initialView,
493
+ onViewChange
494
+ }, undefined, false, undefined, this);
495
+ case "coaching":
496
+ return /* @__PURE__ */ jsxDEV(CoachingMiniApp, {
497
+ track,
498
+ initialView,
499
+ onViewChange
500
+ }, undefined, false, undefined, this);
501
+ default:
502
+ return /* @__PURE__ */ jsxDEV("div", {
503
+ className: "rounded-lg border border-red-500/50 bg-red-500/10 p-6 text-center",
504
+ children: /* @__PURE__ */ jsxDEV("p", {
505
+ className: "text-red-500",
506
+ children: [
507
+ "Unknown app type for template: ",
508
+ templateId
509
+ ]
510
+ }, undefined, true, undefined, this)
511
+ }, undefined, false, undefined, this);
512
+ }
513
+ }
514
+ function isLearningTemplate(templateId) {
515
+ return templateId in TEMPLATE_TO_TRACK;
516
+ }
517
+ function getLearningTemplateIds() {
518
+ return Object.keys(TEMPLATE_TO_TRACK);
519
+ }
520
+ export {
521
+ studioLearningTracks,
522
+ recordEvent,
523
+ platformLearningTracks,
524
+ onboardingTrackCatalog,
525
+ mapTrackSpecToDto,
526
+ mapStep,
527
+ listTracks,
528
+ learningJourneyTracks,
529
+ learningJourneyPresentations,
530
+ isLearningTemplate,
531
+ getProgress,
532
+ getLearningTemplateIds,
533
+ example_default as example,
534
+ crmLearningTracks,
535
+ LearningTrackProgressWidgetPresentation,
536
+ LearningTrackListPresentation,
537
+ LearningTrackDetailPresentation,
538
+ LearningMiniApp,
539
+ LearningJourneyRegistryFeature
540
+ };
@@ -0,0 +1,45 @@
1
+ // src/learning-journey-registry.feature.ts
2
+ import { defineFeature } from "@contractspec/lib.contracts";
3
+ var LearningJourneyRegistryFeature = defineFeature({
4
+ meta: {
5
+ key: "learning-journey-registry",
6
+ version: "1.0.0",
7
+ title: "Learning Journey Registry",
8
+ description: "Shared registry and presentations for learning journey tracks",
9
+ domain: "learning-journey",
10
+ owners: ["@learning-team"],
11
+ tags: ["learning", "journey", "onboarding", "registry"],
12
+ stability: "experimental"
13
+ },
14
+ operations: [],
15
+ events: [],
16
+ presentations: [
17
+ { key: "learning.journey.track_list", version: "1.0.0" },
18
+ { key: "learning.journey.track_detail", version: "1.0.0" },
19
+ { key: "learning.journey.progress_widget", version: "1.0.0" }
20
+ ],
21
+ opToPresentation: [],
22
+ presentationsTargets: [
23
+ {
24
+ key: "learning.journey.track_list",
25
+ version: "1.0.0",
26
+ targets: ["react", "markdown"]
27
+ },
28
+ {
29
+ key: "learning.journey.track_detail",
30
+ version: "1.0.0",
31
+ targets: ["react", "markdown", "application/json"]
32
+ },
33
+ {
34
+ key: "learning.journey.progress_widget",
35
+ version: "1.0.0",
36
+ targets: ["react"]
37
+ }
38
+ ],
39
+ capabilities: {
40
+ requires: [{ key: "identity", version: "1.0.0" }]
41
+ }
42
+ });
43
+ export {
44
+ LearningJourneyRegistryFeature
45
+ };
@@ -0,0 +1,67 @@
1
+ // src/presentations/index.ts
2
+ import {
3
+ definePresentation,
4
+ StabilityEnum
5
+ } from "@contractspec/lib.contracts";
6
+ var baseMeta = {
7
+ domain: "learning-journey",
8
+ title: "Learning Journey",
9
+ owners: ["@learning-team"],
10
+ tags: ["learning", "journey", "onboarding"],
11
+ stability: StabilityEnum.Experimental,
12
+ goal: "Progress through learning tracks",
13
+ context: "Learning journey section"
14
+ };
15
+ var LearningTrackListPresentation = definePresentation({
16
+ meta: {
17
+ key: "learning.journey.track_list",
18
+ version: "1.0.0",
19
+ description: "List of learning journeys available to the learner.",
20
+ ...baseMeta
21
+ },
22
+ source: {
23
+ type: "component",
24
+ framework: "react",
25
+ componentKey: "LearningTrackList"
26
+ },
27
+ targets: ["react", "markdown"]
28
+ });
29
+ var LearningTrackDetailPresentation = definePresentation({
30
+ meta: {
31
+ key: "learning.journey.track_detail",
32
+ version: "1.0.0",
33
+ description: "Track detail with steps and progress state.",
34
+ ...baseMeta
35
+ },
36
+ source: {
37
+ type: "component",
38
+ framework: "react",
39
+ componentKey: "LearningTrackDetail"
40
+ },
41
+ targets: ["react", "markdown", "application/json"]
42
+ });
43
+ var LearningTrackProgressWidgetPresentation = definePresentation({
44
+ meta: {
45
+ key: "learning.journey.progress_widget",
46
+ version: "1.0.0",
47
+ description: "Compact widget showing progress for active track.",
48
+ ...baseMeta
49
+ },
50
+ source: {
51
+ type: "component",
52
+ framework: "react",
53
+ componentKey: "LearningTrackProgressWidget"
54
+ },
55
+ targets: ["react"]
56
+ });
57
+ var learningJourneyPresentations = [
58
+ LearningTrackListPresentation,
59
+ LearningTrackDetailPresentation,
60
+ LearningTrackProgressWidgetPresentation
61
+ ];
62
+ export {
63
+ learningJourneyPresentations,
64
+ LearningTrackProgressWidgetPresentation,
65
+ LearningTrackListPresentation,
66
+ LearningTrackDetailPresentation
67
+ };
@@ -0,0 +1,34 @@
1
+ // src/progress-store.ts
2
+ var progressStore = new Map;
3
+ var getTrackResolver = (tracks) => (trackId) => tracks.find((t) => t.id === trackId);
4
+ var getLearnerTracks = (learnerId) => {
5
+ const existing = progressStore.get(learnerId);
6
+ if (existing)
7
+ return existing;
8
+ const map = new Map;
9
+ progressStore.set(learnerId, map);
10
+ return map;
11
+ };
12
+ var initProgress = (learnerId, track) => ({
13
+ learnerId,
14
+ trackId: track.id,
15
+ progress: 0,
16
+ isCompleted: false,
17
+ xpEarned: 0,
18
+ steps: track.steps.map((step) => ({
19
+ id: step.id,
20
+ status: "PENDING",
21
+ xpEarned: 0,
22
+ occurrences: 0,
23
+ masteryCount: 0
24
+ })),
25
+ startedAt: undefined,
26
+ completedAt: undefined,
27
+ lastActivityAt: undefined
28
+ });
29
+ export {
30
+ progressStore,
31
+ initProgress,
32
+ getTrackResolver,
33
+ getLearnerTracks
34
+ };