@contractspec/module.learning-journey 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.
- package/dist/browser/contracts/index.js +578 -0
- package/dist/browser/contracts/models.js +193 -0
- package/dist/browser/contracts/onboarding.js +417 -0
- package/dist/browser/contracts/operations.js +326 -0
- package/dist/browser/contracts/shared.js +5 -0
- package/dist/browser/docs/index.js +124 -0
- package/dist/browser/docs/learning-journey.docblock.js +124 -0
- package/dist/browser/engines/index.js +526 -0
- package/dist/browser/engines/srs.js +198 -0
- package/dist/browser/engines/streak.js +159 -0
- package/dist/browser/engines/xp.js +171 -0
- package/dist/browser/entities/ai.js +343 -0
- package/dist/browser/entities/course.js +276 -0
- package/dist/browser/entities/flashcard.js +222 -0
- package/dist/browser/entities/gamification.js +340 -0
- package/dist/browser/entities/index.js +2136 -0
- package/dist/browser/entities/learner.js +329 -0
- package/dist/browser/entities/onboarding.js +301 -0
- package/dist/browser/entities/quiz.js +304 -0
- package/dist/browser/events.js +423 -0
- package/dist/browser/index.js +3833 -0
- package/dist/browser/learning-journey.capability.js +40 -0
- package/dist/browser/learning-journey.feature.js +56 -0
- package/dist/browser/track-spec.js +0 -0
- package/dist/contracts/index.d.ts +5 -5
- package/dist/contracts/index.d.ts.map +1 -0
- package/dist/contracts/index.js +578 -5
- package/dist/contracts/models.d.ts +426 -431
- package/dist/contracts/models.d.ts.map +1 -1
- package/dist/contracts/models.js +178 -372
- package/dist/contracts/onboarding.d.ts +621 -627
- package/dist/contracts/onboarding.d.ts.map +1 -1
- package/dist/contracts/onboarding.js +404 -388
- package/dist/contracts/operations.d.ts +243 -249
- package/dist/contracts/operations.d.ts.map +1 -1
- package/dist/contracts/operations.js +324 -148
- package/dist/contracts/shared.d.ts +1 -4
- package/dist/contracts/shared.d.ts.map +1 -1
- package/dist/contracts/shared.js +6 -6
- package/dist/docs/index.d.ts +2 -1
- package/dist/docs/index.d.ts.map +1 -0
- package/dist/docs/index.js +125 -1
- package/dist/docs/learning-journey.docblock.d.ts +2 -1
- package/dist/docs/learning-journey.docblock.d.ts.map +1 -0
- package/dist/docs/learning-journey.docblock.js +47 -58
- package/dist/engines/index.d.ts +4 -4
- package/dist/engines/index.d.ts.map +1 -0
- package/dist/engines/index.js +526 -4
- package/dist/engines/srs.d.ts +89 -92
- package/dist/engines/srs.d.ts.map +1 -1
- package/dist/engines/srs.js +197 -217
- package/dist/engines/streak.d.ts +84 -87
- package/dist/engines/streak.d.ts.map +1 -1
- package/dist/engines/streak.js +158 -192
- package/dist/engines/xp.d.ts +80 -83
- package/dist/engines/xp.d.ts.map +1 -1
- package/dist/engines/xp.js +170 -211
- package/dist/entities/ai.d.ts +199 -204
- package/dist/entities/ai.d.ts.map +1 -1
- package/dist/entities/ai.js +336 -368
- package/dist/entities/course.d.ts +149 -154
- package/dist/entities/course.d.ts.map +1 -1
- package/dist/entities/course.js +267 -306
- package/dist/entities/flashcard.d.ts +144 -149
- package/dist/entities/flashcard.d.ts.map +1 -1
- package/dist/entities/flashcard.js +217 -243
- package/dist/entities/gamification.d.ts +197 -202
- package/dist/entities/gamification.d.ts.map +1 -1
- package/dist/entities/gamification.js +331 -382
- package/dist/entities/index.d.ts +613 -618
- package/dist/entities/index.d.ts.map +1 -1
- package/dist/entities/index.js +2135 -43
- package/dist/entities/learner.d.ts +191 -196
- package/dist/entities/learner.d.ts.map +1 -1
- package/dist/entities/learner.js +322 -357
- package/dist/entities/onboarding.d.ts +164 -169
- package/dist/entities/onboarding.d.ts.map +1 -1
- package/dist/entities/onboarding.js +296 -301
- package/dist/entities/quiz.d.ts +184 -189
- package/dist/entities/quiz.d.ts.map +1 -1
- package/dist/entities/quiz.js +296 -361
- package/dist/events.d.ts +608 -614
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js +421 -687
- package/dist/index.d.ts +8 -20
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3834 -22
- package/dist/learning-journey.capability.d.ts +3 -8
- package/dist/learning-journey.capability.d.ts.map +1 -1
- package/dist/learning-journey.capability.js +41 -46
- package/dist/learning-journey.feature.d.ts +1 -6
- package/dist/learning-journey.feature.d.ts.map +1 -1
- package/dist/learning-journey.feature.js +55 -155
- package/dist/node/contracts/index.js +578 -0
- package/dist/node/contracts/models.js +193 -0
- package/dist/node/contracts/onboarding.js +417 -0
- package/dist/node/contracts/operations.js +326 -0
- package/dist/node/contracts/shared.js +5 -0
- package/dist/node/docs/index.js +124 -0
- package/dist/node/docs/learning-journey.docblock.js +124 -0
- package/dist/node/engines/index.js +526 -0
- package/dist/node/engines/srs.js +198 -0
- package/dist/node/engines/streak.js +159 -0
- package/dist/node/engines/xp.js +171 -0
- package/dist/node/entities/ai.js +343 -0
- package/dist/node/entities/course.js +276 -0
- package/dist/node/entities/flashcard.js +222 -0
- package/dist/node/entities/gamification.js +340 -0
- package/dist/node/entities/index.js +2136 -0
- package/dist/node/entities/learner.js +329 -0
- package/dist/node/entities/onboarding.js +301 -0
- package/dist/node/entities/quiz.js +304 -0
- package/dist/node/events.js +423 -0
- package/dist/node/index.js +3833 -0
- package/dist/node/learning-journey.capability.js +40 -0
- package/dist/node/learning-journey.feature.js +56 -0
- package/dist/node/track-spec.js +0 -0
- package/dist/track-spec.d.ts +115 -118
- package/dist/track-spec.d.ts.map +1 -1
- package/dist/track-spec.js +1 -0
- package/package.json +237 -60
- package/dist/contracts/models.js.map +0 -1
- package/dist/contracts/onboarding.js.map +0 -1
- package/dist/contracts/operations.js.map +0 -1
- package/dist/contracts/shared.js.map +0 -1
- package/dist/docs/learning-journey.docblock.js.map +0 -1
- package/dist/engines/srs.js.map +0 -1
- package/dist/engines/streak.js.map +0 -1
- package/dist/engines/xp.js.map +0 -1
- package/dist/entities/ai.js.map +0 -1
- package/dist/entities/course.js.map +0 -1
- package/dist/entities/flashcard.js.map +0 -1
- package/dist/entities/gamification.js.map +0 -1
- package/dist/entities/index.js.map +0 -1
- package/dist/entities/learner.js.map +0 -1
- package/dist/entities/onboarding.js.map +0 -1
- package/dist/entities/quiz.js.map +0 -1
- package/dist/events.js.map +0 -1
- package/dist/learning-journey.capability.js.map +0 -1
- package/dist/learning-journey.feature.js.map +0 -1
|
@@ -1,392 +1,341 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
// @bun
|
|
2
|
+
// src/entities/gamification.ts
|
|
3
|
+
import {
|
|
4
|
+
defineEntity,
|
|
5
|
+
defineEntityEnum,
|
|
6
|
+
field,
|
|
7
|
+
index
|
|
8
|
+
} from "@contractspec/lib.schema";
|
|
9
|
+
var AchievementTypeEnum = defineEntityEnum({
|
|
10
|
+
name: "AchievementType",
|
|
11
|
+
values: [
|
|
12
|
+
"MILESTONE",
|
|
13
|
+
"STREAK",
|
|
14
|
+
"SKILL",
|
|
15
|
+
"SOCIAL",
|
|
16
|
+
"SPECIAL",
|
|
17
|
+
"SEASONAL"
|
|
18
|
+
],
|
|
19
|
+
schema: "lssm_learning",
|
|
20
|
+
description: "Type of achievement."
|
|
19
21
|
});
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
values: [
|
|
26
|
-
"DAILY",
|
|
27
|
-
"WEEKLY",
|
|
28
|
-
"MONTHLY",
|
|
29
|
-
"ALL_TIME"
|
|
30
|
-
],
|
|
31
|
-
schema: "lssm_learning",
|
|
32
|
-
description: "Leaderboard time period."
|
|
22
|
+
var LeaderboardPeriodEnum = defineEntityEnum({
|
|
23
|
+
name: "LeaderboardPeriod",
|
|
24
|
+
values: ["DAILY", "WEEKLY", "MONTHLY", "ALL_TIME"],
|
|
25
|
+
schema: "lssm_learning",
|
|
26
|
+
description: "Leaderboard time period."
|
|
33
27
|
});
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
isOptional: true,
|
|
93
|
-
description: "Organization scope"
|
|
94
|
-
}),
|
|
95
|
-
metadata: field.json({
|
|
96
|
-
isOptional: true,
|
|
97
|
-
description: "Additional metadata"
|
|
98
|
-
}),
|
|
99
|
-
createdAt: field.createdAt(),
|
|
100
|
-
updatedAt: field.updatedAt(),
|
|
101
|
-
learnerAchievements: field.hasMany("LearnerAchievement")
|
|
102
|
-
},
|
|
103
|
-
indexes: [
|
|
104
|
-
index.on(["type"]),
|
|
105
|
-
index.on(["category"]),
|
|
106
|
-
index.on(["isActive"]),
|
|
107
|
-
index.on(["orgId"])
|
|
108
|
-
],
|
|
109
|
-
enums: [AchievementTypeEnum]
|
|
28
|
+
var AchievementEntity = defineEntity({
|
|
29
|
+
name: "Achievement",
|
|
30
|
+
description: "An achievement that can be unlocked.",
|
|
31
|
+
schema: "lssm_learning",
|
|
32
|
+
map: "achievement",
|
|
33
|
+
fields: {
|
|
34
|
+
id: field.id({ description: "Unique achievement identifier" }),
|
|
35
|
+
key: field.string({ isUnique: true, description: "Achievement key" }),
|
|
36
|
+
name: field.string({ description: "Achievement name" }),
|
|
37
|
+
description: field.string({ description: "Achievement description" }),
|
|
38
|
+
icon: field.string({ isOptional: true, description: "Icon name or URL" }),
|
|
39
|
+
color: field.string({ isOptional: true, description: "Display color" }),
|
|
40
|
+
badgeUrl: field.string({
|
|
41
|
+
isOptional: true,
|
|
42
|
+
description: "Badge image URL"
|
|
43
|
+
}),
|
|
44
|
+
type: field.enum("AchievementType", {
|
|
45
|
+
default: "MILESTONE",
|
|
46
|
+
description: "Achievement type"
|
|
47
|
+
}),
|
|
48
|
+
category: field.string({
|
|
49
|
+
isOptional: true,
|
|
50
|
+
description: "Achievement category"
|
|
51
|
+
}),
|
|
52
|
+
rarity: field.string({
|
|
53
|
+
default: '"common"',
|
|
54
|
+
description: "Rarity: common, rare, epic, legendary"
|
|
55
|
+
}),
|
|
56
|
+
xpReward: field.int({ default: 50, description: "XP awarded" }),
|
|
57
|
+
condition: field.json({ description: "Unlock condition" }),
|
|
58
|
+
order: field.int({ default: 0, description: "Display order" }),
|
|
59
|
+
isHidden: field.boolean({
|
|
60
|
+
default: false,
|
|
61
|
+
description: "Hide until unlocked"
|
|
62
|
+
}),
|
|
63
|
+
isActive: field.boolean({
|
|
64
|
+
default: true,
|
|
65
|
+
description: "Whether achievement is active"
|
|
66
|
+
}),
|
|
67
|
+
orgId: field.string({
|
|
68
|
+
isOptional: true,
|
|
69
|
+
description: "Organization scope"
|
|
70
|
+
}),
|
|
71
|
+
metadata: field.json({
|
|
72
|
+
isOptional: true,
|
|
73
|
+
description: "Additional metadata"
|
|
74
|
+
}),
|
|
75
|
+
createdAt: field.createdAt(),
|
|
76
|
+
updatedAt: field.updatedAt(),
|
|
77
|
+
learnerAchievements: field.hasMany("LearnerAchievement")
|
|
78
|
+
},
|
|
79
|
+
indexes: [
|
|
80
|
+
index.on(["type"]),
|
|
81
|
+
index.on(["category"]),
|
|
82
|
+
index.on(["isActive"]),
|
|
83
|
+
index.on(["orgId"])
|
|
84
|
+
],
|
|
85
|
+
enums: [AchievementTypeEnum]
|
|
110
86
|
});
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
index.on(["learnerId", "unlockedAt"]),
|
|
147
|
-
index.on(["achievementId"])
|
|
148
|
-
]
|
|
87
|
+
var LearnerAchievementEntity = defineEntity({
|
|
88
|
+
name: "LearnerAchievement",
|
|
89
|
+
description: "An achievement unlocked by a learner.",
|
|
90
|
+
schema: "lssm_learning",
|
|
91
|
+
map: "learner_achievement",
|
|
92
|
+
fields: {
|
|
93
|
+
id: field.id({ description: "Unique record identifier" }),
|
|
94
|
+
learnerId: field.foreignKey({ description: "Learner" }),
|
|
95
|
+
achievementId: field.foreignKey({ description: "Achievement" }),
|
|
96
|
+
xpEarned: field.int({ default: 0, description: "XP earned" }),
|
|
97
|
+
progress: field.int({ default: 100, description: "Progress percentage" }),
|
|
98
|
+
currentValue: field.int({
|
|
99
|
+
isOptional: true,
|
|
100
|
+
description: "Current value towards goal"
|
|
101
|
+
}),
|
|
102
|
+
targetValue: field.int({
|
|
103
|
+
isOptional: true,
|
|
104
|
+
description: "Target value for completion"
|
|
105
|
+
}),
|
|
106
|
+
unlockedAt: field.dateTime({ description: "When unlocked" }),
|
|
107
|
+
createdAt: field.createdAt(),
|
|
108
|
+
learner: field.belongsTo("Learner", ["learnerId"], ["id"], {
|
|
109
|
+
onDelete: "Cascade"
|
|
110
|
+
}),
|
|
111
|
+
achievement: field.belongsTo("Achievement", ["achievementId"], ["id"], {
|
|
112
|
+
onDelete: "Cascade"
|
|
113
|
+
})
|
|
114
|
+
},
|
|
115
|
+
indexes: [
|
|
116
|
+
index.unique(["learnerId", "achievementId"], {
|
|
117
|
+
name: "learner_achievement_unique"
|
|
118
|
+
}),
|
|
119
|
+
index.on(["learnerId", "unlockedAt"]),
|
|
120
|
+
index.on(["achievementId"])
|
|
121
|
+
]
|
|
149
122
|
});
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
]
|
|
123
|
+
var StreakEntity = defineEntity({
|
|
124
|
+
name: "Streak",
|
|
125
|
+
description: "Tracks daily learning streaks.",
|
|
126
|
+
schema: "lssm_learning",
|
|
127
|
+
map: "streak",
|
|
128
|
+
fields: {
|
|
129
|
+
id: field.id({ description: "Unique streak identifier" }),
|
|
130
|
+
learnerId: field.foreignKey({ description: "Learner" }),
|
|
131
|
+
currentStreak: field.int({
|
|
132
|
+
default: 0,
|
|
133
|
+
description: "Current streak days"
|
|
134
|
+
}),
|
|
135
|
+
longestStreak: field.int({
|
|
136
|
+
default: 0,
|
|
137
|
+
description: "Longest streak ever"
|
|
138
|
+
}),
|
|
139
|
+
lastActivityAt: field.dateTime({
|
|
140
|
+
isOptional: true,
|
|
141
|
+
description: "Last learning activity"
|
|
142
|
+
}),
|
|
143
|
+
lastActivityDate: field.string({
|
|
144
|
+
isOptional: true,
|
|
145
|
+
description: "Last activity date (YYYY-MM-DD)"
|
|
146
|
+
}),
|
|
147
|
+
freezesRemaining: field.int({
|
|
148
|
+
default: 0,
|
|
149
|
+
description: "Streak freezes available"
|
|
150
|
+
}),
|
|
151
|
+
freezeUsedAt: field.dateTime({
|
|
152
|
+
isOptional: true,
|
|
153
|
+
description: "When last freeze was used"
|
|
154
|
+
}),
|
|
155
|
+
streakHistory: field.json({
|
|
156
|
+
isOptional: true,
|
|
157
|
+
description: "Historical streak data"
|
|
158
|
+
}),
|
|
159
|
+
createdAt: field.createdAt(),
|
|
160
|
+
updatedAt: field.updatedAt(),
|
|
161
|
+
learner: field.belongsTo("Learner", ["learnerId"], ["id"], {
|
|
162
|
+
onDelete: "Cascade"
|
|
163
|
+
})
|
|
164
|
+
},
|
|
165
|
+
indexes: [
|
|
166
|
+
index.unique(["learnerId"], { name: "streak_learner_unique" }),
|
|
167
|
+
index.on(["currentStreak"]),
|
|
168
|
+
index.on(["longestStreak"])
|
|
169
|
+
]
|
|
198
170
|
});
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
indexes: [index.unique(["learnerId", "date"], { name: "daily_goal_unique" }), index.on(["date", "isCompleted"])]
|
|
171
|
+
var DailyGoalEntity = defineEntity({
|
|
172
|
+
name: "DailyGoal",
|
|
173
|
+
description: "Daily XP goal tracking.",
|
|
174
|
+
schema: "lssm_learning",
|
|
175
|
+
map: "daily_goal",
|
|
176
|
+
fields: {
|
|
177
|
+
id: field.id({ description: "Unique goal identifier" }),
|
|
178
|
+
learnerId: field.foreignKey({ description: "Learner" }),
|
|
179
|
+
date: field.string({ description: "Date (YYYY-MM-DD)" }),
|
|
180
|
+
targetXp: field.int({ description: "Target XP for the day" }),
|
|
181
|
+
currentXp: field.int({ default: 0, description: "XP earned today" }),
|
|
182
|
+
isCompleted: field.boolean({
|
|
183
|
+
default: false,
|
|
184
|
+
description: "Whether goal was met"
|
|
185
|
+
}),
|
|
186
|
+
completedAt: field.dateTime({
|
|
187
|
+
isOptional: true,
|
|
188
|
+
description: "When goal was completed"
|
|
189
|
+
}),
|
|
190
|
+
xpBreakdown: field.json({
|
|
191
|
+
isOptional: true,
|
|
192
|
+
description: "XP sources breakdown"
|
|
193
|
+
}),
|
|
194
|
+
createdAt: field.createdAt(),
|
|
195
|
+
updatedAt: field.updatedAt(),
|
|
196
|
+
learner: field.belongsTo("Learner", ["learnerId"], ["id"], {
|
|
197
|
+
onDelete: "Cascade"
|
|
198
|
+
})
|
|
199
|
+
},
|
|
200
|
+
indexes: [
|
|
201
|
+
index.unique(["learnerId", "date"], { name: "daily_goal_unique" }),
|
|
202
|
+
index.on(["date", "isCompleted"])
|
|
203
|
+
]
|
|
233
204
|
});
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
isOptional: true,
|
|
273
|
-
description: "League tier"
|
|
274
|
-
}),
|
|
275
|
-
orgId: field.string({
|
|
276
|
-
isOptional: true,
|
|
277
|
-
description: "Organization scope"
|
|
278
|
-
}),
|
|
279
|
-
createdAt: field.createdAt(),
|
|
280
|
-
updatedAt: field.updatedAt(),
|
|
281
|
-
learner: field.belongsTo("Learner", ["learnerId"], ["id"], { onDelete: "Cascade" })
|
|
282
|
-
},
|
|
283
|
-
indexes: [
|
|
284
|
-
index.unique([
|
|
285
|
-
"learnerId",
|
|
286
|
-
"periodType",
|
|
287
|
-
"periodKey"
|
|
288
|
-
], { name: "leaderboard_entry_unique" }),
|
|
289
|
-
index.on([
|
|
290
|
-
"periodType",
|
|
291
|
-
"periodKey",
|
|
292
|
-
"xp"
|
|
293
|
-
]),
|
|
294
|
-
index.on([
|
|
295
|
-
"orgId",
|
|
296
|
-
"periodType",
|
|
297
|
-
"periodKey",
|
|
298
|
-
"xp"
|
|
299
|
-
])
|
|
300
|
-
],
|
|
301
|
-
enums: [LeaderboardPeriodEnum]
|
|
205
|
+
var LeaderboardEntryEntity = defineEntity({
|
|
206
|
+
name: "LeaderboardEntry",
|
|
207
|
+
description: "Leaderboard entry for a learner.",
|
|
208
|
+
schema: "lssm_learning",
|
|
209
|
+
map: "leaderboard_entry",
|
|
210
|
+
fields: {
|
|
211
|
+
id: field.id({ description: "Unique entry identifier" }),
|
|
212
|
+
learnerId: field.foreignKey({ description: "Learner" }),
|
|
213
|
+
periodType: field.enum("LeaderboardPeriod", { description: "Period type" }),
|
|
214
|
+
periodKey: field.string({ description: "Period key (e.g., 2024-W01)" }),
|
|
215
|
+
xp: field.int({ default: 0, description: "XP earned in period" }),
|
|
216
|
+
rank: field.int({ isOptional: true, description: "Rank in leaderboard" }),
|
|
217
|
+
lessonsCompleted: field.int({
|
|
218
|
+
default: 0,
|
|
219
|
+
description: "Lessons completed"
|
|
220
|
+
}),
|
|
221
|
+
quizzesPassed: field.int({ default: 0, description: "Quizzes passed" }),
|
|
222
|
+
cardsReviewed: field.int({ default: 0, description: "Cards reviewed" }),
|
|
223
|
+
streakDays: field.int({ default: 0, description: "Streak days in period" }),
|
|
224
|
+
league: field.string({ isOptional: true, description: "League tier" }),
|
|
225
|
+
orgId: field.string({
|
|
226
|
+
isOptional: true,
|
|
227
|
+
description: "Organization scope"
|
|
228
|
+
}),
|
|
229
|
+
createdAt: field.createdAt(),
|
|
230
|
+
updatedAt: field.updatedAt(),
|
|
231
|
+
learner: field.belongsTo("Learner", ["learnerId"], ["id"], {
|
|
232
|
+
onDelete: "Cascade"
|
|
233
|
+
})
|
|
234
|
+
},
|
|
235
|
+
indexes: [
|
|
236
|
+
index.unique(["learnerId", "periodType", "periodKey"], {
|
|
237
|
+
name: "leaderboard_entry_unique"
|
|
238
|
+
}),
|
|
239
|
+
index.on(["periodType", "periodKey", "xp"]),
|
|
240
|
+
index.on(["orgId", "periodType", "periodKey", "xp"])
|
|
241
|
+
],
|
|
242
|
+
enums: [LeaderboardPeriodEnum]
|
|
302
243
|
});
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
updatedAt: field.updatedAt(),
|
|
340
|
-
learner: field.belongsTo("Learner", ["learnerId"], ["id"], { onDelete: "Cascade" })
|
|
341
|
-
},
|
|
342
|
-
indexes: [index.unique(["learnerId"], { name: "heart_learner_unique" }), index.on(["nextRefillAt"])]
|
|
244
|
+
var HeartEntity = defineEntity({
|
|
245
|
+
name: "Heart",
|
|
246
|
+
description: "Lives/hearts system for quiz attempts.",
|
|
247
|
+
schema: "lssm_learning",
|
|
248
|
+
map: "heart",
|
|
249
|
+
fields: {
|
|
250
|
+
id: field.id({ description: "Unique heart record identifier" }),
|
|
251
|
+
learnerId: field.foreignKey({ description: "Learner" }),
|
|
252
|
+
current: field.int({ default: 5, description: "Current hearts" }),
|
|
253
|
+
max: field.int({ default: 5, description: "Maximum hearts" }),
|
|
254
|
+
lastRefillAt: field.dateTime({
|
|
255
|
+
isOptional: true,
|
|
256
|
+
description: "Last refill time"
|
|
257
|
+
}),
|
|
258
|
+
nextRefillAt: field.dateTime({
|
|
259
|
+
isOptional: true,
|
|
260
|
+
description: "Next refill time"
|
|
261
|
+
}),
|
|
262
|
+
refillIntervalMinutes: field.int({
|
|
263
|
+
default: 240,
|
|
264
|
+
description: "Minutes between refills"
|
|
265
|
+
}),
|
|
266
|
+
infiniteUntil: field.dateTime({
|
|
267
|
+
isOptional: true,
|
|
268
|
+
description: "Infinite hearts until"
|
|
269
|
+
}),
|
|
270
|
+
createdAt: field.createdAt(),
|
|
271
|
+
updatedAt: field.updatedAt(),
|
|
272
|
+
learner: field.belongsTo("Learner", ["learnerId"], ["id"], {
|
|
273
|
+
onDelete: "Cascade"
|
|
274
|
+
})
|
|
275
|
+
},
|
|
276
|
+
indexes: [
|
|
277
|
+
index.unique(["learnerId"], { name: "heart_learner_unique" }),
|
|
278
|
+
index.on(["nextRefillAt"])
|
|
279
|
+
]
|
|
343
280
|
});
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
281
|
+
var XPTransactionEntity = defineEntity({
|
|
282
|
+
name: "XPTransaction",
|
|
283
|
+
description: "Record of XP earned or spent.",
|
|
284
|
+
schema: "lssm_learning",
|
|
285
|
+
map: "xp_transaction",
|
|
286
|
+
fields: {
|
|
287
|
+
id: field.id({ description: "Unique transaction identifier" }),
|
|
288
|
+
learnerId: field.foreignKey({ description: "Learner" }),
|
|
289
|
+
amount: field.int({
|
|
290
|
+
description: "XP amount (positive = earned, negative = spent)"
|
|
291
|
+
}),
|
|
292
|
+
type: field.string({
|
|
293
|
+
description: "Transaction type (lesson, quiz, streak, achievement, etc.)"
|
|
294
|
+
}),
|
|
295
|
+
sourceType: field.string({
|
|
296
|
+
isOptional: true,
|
|
297
|
+
description: "Source entity type"
|
|
298
|
+
}),
|
|
299
|
+
sourceId: field.string({
|
|
300
|
+
isOptional: true,
|
|
301
|
+
description: "Source entity ID"
|
|
302
|
+
}),
|
|
303
|
+
description: field.string({
|
|
304
|
+
isOptional: true,
|
|
305
|
+
description: "Human-readable description"
|
|
306
|
+
}),
|
|
307
|
+
balanceAfter: field.int({ description: "Total XP after transaction" }),
|
|
308
|
+
createdAt: field.createdAt(),
|
|
309
|
+
learner: field.belongsTo("Learner", ["learnerId"], ["id"], {
|
|
310
|
+
onDelete: "Cascade"
|
|
311
|
+
})
|
|
312
|
+
},
|
|
313
|
+
indexes: [
|
|
314
|
+
index.on(["learnerId", "createdAt"]),
|
|
315
|
+
index.on(["type"]),
|
|
316
|
+
index.on(["sourceType", "sourceId"])
|
|
317
|
+
]
|
|
378
318
|
});
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
319
|
+
var gamificationEntities = [
|
|
320
|
+
AchievementEntity,
|
|
321
|
+
LearnerAchievementEntity,
|
|
322
|
+
StreakEntity,
|
|
323
|
+
DailyGoalEntity,
|
|
324
|
+
LeaderboardEntryEntity,
|
|
325
|
+
HeartEntity,
|
|
326
|
+
XPTransactionEntity
|
|
387
327
|
];
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
328
|
+
var gamificationEnums = [AchievementTypeEnum, LeaderboardPeriodEnum];
|
|
329
|
+
export {
|
|
330
|
+
gamificationEnums,
|
|
331
|
+
gamificationEntities,
|
|
332
|
+
XPTransactionEntity,
|
|
333
|
+
StreakEntity,
|
|
334
|
+
LearnerAchievementEntity,
|
|
335
|
+
LeaderboardPeriodEnum,
|
|
336
|
+
LeaderboardEntryEntity,
|
|
337
|
+
HeartEntity,
|
|
338
|
+
DailyGoalEntity,
|
|
339
|
+
AchievementTypeEnum,
|
|
340
|
+
AchievementEntity
|
|
341
|
+
};
|