@vue-skuilder/db 0.3.1 → 0.3.2
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/{contentSource-2zVmcjKA.d.ts → contentSource-CSI0pJ2D.d.ts} +10 -0
- package/dist/core/index.cjs +62 -14
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.ts +3 -3
- package/dist/core/interfaces/contentSource.mjs.map +1 -1
- package/dist/core/navigators/Pipeline.mjs +7 -1
- package/dist/core/navigators/Pipeline.mjs.map +1 -1
- package/dist/core/navigators/filters/eloDistance.mjs +17 -2
- package/dist/core/navigators/filters/eloDistance.mjs.map +1 -1
- package/dist/core/navigators/generators/prescribed.mjs +20 -10
- package/dist/core/navigators/generators/prescribed.mjs.map +1 -1
- package/dist/core/navigators/index.mjs +2 -0
- package/dist/core/navigators/index.mjs.map +1 -1
- package/dist/core/versionStamps.mjs +1 -1
- package/dist/{dataLayerProvider-rGyLQ93v.d.ts → dataLayerProvider-D5n1gGc_.d.ts} +1 -1
- package/dist/diagnostics/index.d.ts +2 -2
- package/dist/impl/couch/courseDB.mjs +5 -0
- package/dist/impl/couch/courseDB.mjs.map +1 -1
- package/dist/impl/couch/index.cjs +37 -2
- package/dist/impl/couch/index.cjs.map +1 -1
- package/dist/impl/couch/index.d.ts +4 -2
- package/dist/impl/static/courseDB.mjs +5 -0
- package/dist/impl/static/courseDB.mjs.map +1 -1
- package/dist/impl/static/index.cjs +37 -2
- package/dist/impl/static/index.cjs.map +1 -1
- package/dist/impl/static/index.d.ts +4 -2
- package/dist/index.cjs +73 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/study/SessionController.mjs +1 -0
- package/dist/study/SessionController.mjs.map +1 -1
- package/package.json +3 -3
- package/src/core/interfaces/contentSource.ts +7 -0
- package/src/core/navigators/Pipeline.ts +7 -0
- package/src/core/navigators/filters/eloDistance.ts +31 -2
- package/src/core/navigators/generators/prescribed.ts +56 -11
- package/src/core/navigators/generators/types.ts +3 -0
- package/src/core/navigators/index.ts +5 -0
- package/src/impl/couch/courseDB.ts +13 -0
- package/src/impl/static/courseDB.ts +13 -0
- package/src/study/SessionController.ts +3 -0
- package/tests/core/navigators/eloDistanceFilter.test.ts +15 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { C as ClassroomDBInterface, A as AdminDBInterface } from '../../classroomDB-DLTtLZct.js';
|
|
2
|
-
import { U as UserDBInterface, C as CourseDBInterface, a as CoursesDBInterface, b as CourseInfo, S as StudySessionItem, D as DataLayerResult, c as ContentNavigationStrategyData, d as ContentNavigator, R as ReplanHints, G as GeneratorResult } from '../../contentSource-
|
|
3
|
-
import { D as DataLayerProvider } from '../../dataLayerProvider-
|
|
2
|
+
import { U as UserDBInterface, C as CourseDBInterface, a as CoursesDBInterface, b as CourseInfo, S as StudySessionItem, D as DataLayerResult, c as ContentNavigationStrategyData, d as ContentNavigator, R as ReplanHints, G as GeneratorResult } from '../../contentSource-CSI0pJ2D.js';
|
|
3
|
+
import { D as DataLayerProvider } from '../../dataLayerProvider-D5n1gGc_.js';
|
|
4
4
|
import { S as StaticCourseManifest } from '../../types-DF0JuPbs.js';
|
|
5
5
|
import { CourseConfig, CourseElo, DataShape } from '@vue-skuilder/common';
|
|
6
6
|
import { S as SkuilderCourseData, Q as QualifiedCardID, T as TagStub, a as Tag } from '../../types-legacy-DdVjg81H.js';
|
|
@@ -176,6 +176,8 @@ declare class StaticCourseDB implements CourseDBInterface {
|
|
|
176
176
|
createNavigator(user: UserDBInterface): Promise<ContentNavigator>;
|
|
177
177
|
private _pendingHints;
|
|
178
178
|
setEphemeralHints(hints: ReplanHints): void;
|
|
179
|
+
private _sessionId;
|
|
180
|
+
setSessionId(sessionId: string): void;
|
|
179
181
|
/** Forward a presentation to the navigator (a new card restarts its intake clock). */
|
|
180
182
|
notePresented(card: {
|
|
181
183
|
cardId: string;
|
package/dist/index.cjs
CHANGED
|
@@ -1621,9 +1621,12 @@ var init_prescribed = __esm({
|
|
|
1621
1621
|
const allRelevantIds = dedupe([...allTargetIds, ...allSupportIds]);
|
|
1622
1622
|
const tagsByCard = allRelevantIds.length > 0 ? await this.course.getAppliedTagsBatch(allRelevantIds) : /* @__PURE__ */ new Map();
|
|
1623
1623
|
const cardsByTag = await this.loadCardsByTag();
|
|
1624
|
+
const sessionId = context?.sessionId;
|
|
1625
|
+
const newSession = sessionId === void 0 || sessionId !== progress.lastSessionId;
|
|
1624
1626
|
const nextState = {
|
|
1625
1627
|
updatedAt: isoNow(),
|
|
1626
|
-
groups: {}
|
|
1628
|
+
groups: {},
|
|
1629
|
+
...sessionId || progress.lastSessionId ? { lastSessionId: sessionId ?? progress.lastSessionId } : {}
|
|
1627
1630
|
};
|
|
1628
1631
|
const emitted = [];
|
|
1629
1632
|
const emittedIds = /* @__PURE__ */ new Set();
|
|
@@ -1663,7 +1666,11 @@ var init_prescribed = __esm({
|
|
|
1663
1666
|
);
|
|
1664
1667
|
}
|
|
1665
1668
|
}
|
|
1666
|
-
nextState.groups[group.id] = this.buildNextGroupState(
|
|
1669
|
+
nextState.groups[group.id] = this.buildNextGroupState(
|
|
1670
|
+
runtime,
|
|
1671
|
+
progress.groups[group.id],
|
|
1672
|
+
newSession
|
|
1673
|
+
);
|
|
1667
1674
|
const directCards = this.buildDirectTargetCards(
|
|
1668
1675
|
runtime,
|
|
1669
1676
|
courseId,
|
|
@@ -1735,12 +1742,8 @@ var init_prescribed = __esm({
|
|
|
1735
1742
|
for (const group of this.config.groups) {
|
|
1736
1743
|
const groupState = nextState.groups[group.id];
|
|
1737
1744
|
const surfaced = surfacedByGroup.get(group.id);
|
|
1738
|
-
if (surfaced &&
|
|
1739
|
-
groupState.
|
|
1740
|
-
groupState.sessionsSinceSurfaced = 0;
|
|
1741
|
-
if (surfaced.supportIds.length > 0) {
|
|
1742
|
-
groupState.lastSupportAt = isoNow();
|
|
1743
|
-
}
|
|
1745
|
+
if (surfaced && surfaced.supportIds.length > 0) {
|
|
1746
|
+
groupState.lastSupportAt = isoNow();
|
|
1744
1747
|
}
|
|
1745
1748
|
}
|
|
1746
1749
|
await this.putStrategyState(nextState).catch((e) => {
|
|
@@ -2006,14 +2009,24 @@ var init_prescribed = __esm({
|
|
|
2006
2009
|
debugVersion: PRESCRIBED_DEBUG_VERSION
|
|
2007
2010
|
};
|
|
2008
2011
|
}
|
|
2009
|
-
|
|
2012
|
+
/**
|
|
2013
|
+
* The group's state after this run. The staleness clock resets only when a
|
|
2014
|
+
* target has reached the learner since the last run: it is newly in
|
|
2015
|
+
* `encounteredTargets`, which reads card history and scheduled reviews, so
|
|
2016
|
+
* the card was shown and answered. Emitting a target does not count; it may
|
|
2017
|
+
* lose to the rest of the heap. (Before 2026-11, emission reset the clock,
|
|
2018
|
+
* and a group that emitted every run never escalated.) The clock advances
|
|
2019
|
+
* once per study session, not per run.
|
|
2020
|
+
*/
|
|
2021
|
+
buildNextGroupState(runtime, prior, newSession) {
|
|
2010
2022
|
const carriedSessions = prior?.sessionsSinceSurfaced ?? 0;
|
|
2011
|
-
const
|
|
2023
|
+
const previouslyEncountered = new Set(prior?.encounteredCardIds ?? []);
|
|
2024
|
+
const surfacedThisRun = prior !== void 0 && [...runtime.encounteredTargets].some((id) => !previouslyEncountered.has(id));
|
|
2012
2025
|
return {
|
|
2013
2026
|
encounteredCardIds: [...runtime.encounteredTargets].sort(),
|
|
2014
2027
|
pendingTargetIds: [...runtime.pendingTargets].sort(),
|
|
2015
|
-
lastSurfacedAt: prior?.lastSurfacedAt ?? null,
|
|
2016
|
-
sessionsSinceSurfaced: surfacedThisRun ? 0 : carriedSessions + 1,
|
|
2028
|
+
lastSurfacedAt: surfacedThisRun ? isoNow() : prior?.lastSurfacedAt ?? null,
|
|
2029
|
+
sessionsSinceSurfaced: surfacedThisRun ? 0 : carriedSessions + (newSession ? 1 : 0),
|
|
2017
2030
|
lastSupportAt: prior?.lastSupportAt ?? null,
|
|
2018
2031
|
blockedTargetIds: [...runtime.blockedTargets].sort(),
|
|
2019
2032
|
lastResolvedSupportTags: [...runtime.supportTags].sort()
|
|
@@ -3140,6 +3153,9 @@ __export(eloDistance_exports, {
|
|
|
3140
3153
|
mountMultiDimEloToggle: () => mountMultiDimEloToggle,
|
|
3141
3154
|
tagAwareGap: () => tagAwareGap
|
|
3142
3155
|
});
|
|
3156
|
+
function isIntroCard(card) {
|
|
3157
|
+
return (card.tags ?? []).some((t) => (0, import_common5.tagRole)(t) === "intro");
|
|
3158
|
+
}
|
|
3143
3159
|
function computeMultiplier(distance, halfLife, minMultiplier, maxMultiplier) {
|
|
3144
3160
|
const normalizedDistance = distance / halfLife;
|
|
3145
3161
|
const decay = Math.exp(-(normalizedDistance * normalizedDistance));
|
|
@@ -3207,7 +3223,7 @@ async function applyEloDistance(cards, context, config, source) {
|
|
|
3207
3223
|
const { course, userElo, userCourseElo } = context;
|
|
3208
3224
|
const { halfLife, minMultiplier, maxMultiplier } = config;
|
|
3209
3225
|
const tagAware = (config.tagAware || multiDimElo) && userCourseElo !== void 0;
|
|
3210
|
-
const missing = cards.filter((c) => tagAware || c.cardElo === void 0).map((c) => c.cardId);
|
|
3226
|
+
const missing = cards.filter((c) => !isIntroCard(c) && (tagAware || c.cardElo === void 0)).map((c) => c.cardId);
|
|
3211
3227
|
const fetched = /* @__PURE__ */ new Map();
|
|
3212
3228
|
if (missing.length > 0) {
|
|
3213
3229
|
const elos = await course.getCardEloData(missing);
|
|
@@ -3216,6 +3232,22 @@ async function applyEloDistance(cards, context, config, source) {
|
|
|
3216
3232
|
});
|
|
3217
3233
|
}
|
|
3218
3234
|
return cards.map((card) => {
|
|
3235
|
+
if (isIntroCard(card)) {
|
|
3236
|
+
return {
|
|
3237
|
+
...card,
|
|
3238
|
+
provenance: [
|
|
3239
|
+
...card.provenance,
|
|
3240
|
+
{
|
|
3241
|
+
strategy: "eloDistance",
|
|
3242
|
+
strategyName: source.name,
|
|
3243
|
+
strategyId: source.strategyId,
|
|
3244
|
+
action: "passed",
|
|
3245
|
+
score: card.score,
|
|
3246
|
+
reason: "intro card: ELO is a placeholder, distance not applied \u2192 1.00x"
|
|
3247
|
+
}
|
|
3248
|
+
]
|
|
3249
|
+
};
|
|
3250
|
+
}
|
|
3219
3251
|
const full = fetched.get(card.cardId);
|
|
3220
3252
|
const cardElo = full?.global?.score ?? card.cardElo ?? DEFAULT_CARD_ELO;
|
|
3221
3253
|
let distance = Math.abs(cardElo - userElo);
|
|
@@ -3588,6 +3620,9 @@ var init_navigators = __esm({
|
|
|
3588
3620
|
*/
|
|
3589
3621
|
setEphemeralHints(_hints) {
|
|
3590
3622
|
}
|
|
3623
|
+
/** See StudyContentSource.setSessionId. No-op for non-Pipeline navigators. */
|
|
3624
|
+
setSessionId(_sessionId) {
|
|
3625
|
+
}
|
|
3591
3626
|
};
|
|
3592
3627
|
}
|
|
3593
3628
|
});
|
|
@@ -3624,7 +3659,7 @@ var FRAMEWORK_VERSION, hostAppVersion, DEFAULT_STRATEGY_HASH;
|
|
|
3624
3659
|
var init_versionStamps = __esm({
|
|
3625
3660
|
"src/core/versionStamps.ts"() {
|
|
3626
3661
|
"use strict";
|
|
3627
|
-
FRAMEWORK_VERSION = true ? "0.3.
|
|
3662
|
+
FRAMEWORK_VERSION = true ? "0.3.2" : "dev";
|
|
3628
3663
|
DEFAULT_STRATEGY_HASH = "default";
|
|
3629
3664
|
}
|
|
3630
3665
|
});
|
|
@@ -7069,6 +7104,7 @@ var init_Pipeline = __esm({
|
|
|
7069
7104
|
* getWeightedCards() call, then cleared.
|
|
7070
7105
|
*/
|
|
7071
7106
|
_ephemeralHints = null;
|
|
7107
|
+
_sessionId;
|
|
7072
7108
|
/**
|
|
7073
7109
|
* The intake valve's clock (see regulators.ts), loaded from strategy state on
|
|
7074
7110
|
* first use and kept in memory. Writes are chained so a presentation and a
|
|
@@ -7104,6 +7140,10 @@ var init_Pipeline = __esm({
|
|
|
7104
7140
|
*
|
|
7105
7141
|
* Overrides ContentNavigator.setEphemeralHints() no-op.
|
|
7106
7142
|
*/
|
|
7143
|
+
/** See StudyContentSource.setSessionId. Carried into every run's context. */
|
|
7144
|
+
setSessionId(sessionId) {
|
|
7145
|
+
this._sessionId = sessionId;
|
|
7146
|
+
}
|
|
7107
7147
|
setEphemeralHints(hints) {
|
|
7108
7148
|
this._ephemeralHints = hints;
|
|
7109
7149
|
logger.info(`[Pipeline] Ephemeral hints set: ${JSON.stringify(hints)}`);
|
|
@@ -7551,7 +7591,8 @@ var init_Pipeline = __esm({
|
|
|
7551
7591
|
course: this.course,
|
|
7552
7592
|
userElo,
|
|
7553
7593
|
...userCourseElo ? { userCourseElo } : {},
|
|
7554
|
-
orchestration
|
|
7594
|
+
orchestration,
|
|
7595
|
+
...this._sessionId ? { sessionId: this._sessionId } : {}
|
|
7555
7596
|
};
|
|
7556
7597
|
}
|
|
7557
7598
|
/**
|
|
@@ -9100,6 +9141,9 @@ var init_SessionController = __esm({
|
|
|
9100
9141
|
)
|
|
9101
9142
|
};
|
|
9102
9143
|
this.sources = sources;
|
|
9144
|
+
for (const source of sources) {
|
|
9145
|
+
source.setSessionId?.(this.sessionId);
|
|
9146
|
+
}
|
|
9103
9147
|
this.startTime = /* @__PURE__ */ new Date();
|
|
9104
9148
|
this._secondsRemaining = time;
|
|
9105
9149
|
this.endTime = new Date(this.startTime.valueOf() + 1e3 * this._secondsRemaining);
|
|
@@ -13354,6 +13398,10 @@ ${e.stack}` : JSON.stringify(e);
|
|
|
13354
13398
|
setEphemeralHints(hints) {
|
|
13355
13399
|
this._pendingHints = hints;
|
|
13356
13400
|
}
|
|
13401
|
+
_sessionId = null;
|
|
13402
|
+
setSessionId(sessionId) {
|
|
13403
|
+
this._sessionId = sessionId;
|
|
13404
|
+
}
|
|
13357
13405
|
/**
|
|
13358
13406
|
* Forward a presentation to the navigator (a new card restarts its intake
|
|
13359
13407
|
* clock). Builds the navigator if the cached one has expired.
|
|
@@ -13370,6 +13418,9 @@ ${e.stack}` : JSON.stringify(e);
|
|
|
13370
13418
|
navigator2.setEphemeralHints(this._pendingHints);
|
|
13371
13419
|
this._pendingHints = null;
|
|
13372
13420
|
}
|
|
13421
|
+
if (this._sessionId) {
|
|
13422
|
+
navigator2.setSessionId(this._sessionId);
|
|
13423
|
+
}
|
|
13373
13424
|
const result = await navigator2.getWeightedCards(limit);
|
|
13374
13425
|
return result;
|
|
13375
13426
|
} catch (e) {
|
|
@@ -15591,6 +15642,10 @@ var init_courseDB2 = __esm({
|
|
|
15591
15642
|
setEphemeralHints(hints) {
|
|
15592
15643
|
this._pendingHints = hints;
|
|
15593
15644
|
}
|
|
15645
|
+
_sessionId = null;
|
|
15646
|
+
setSessionId(sessionId) {
|
|
15647
|
+
this._sessionId = sessionId;
|
|
15648
|
+
}
|
|
15594
15649
|
/** Forward a presentation to the navigator (a new card restarts its intake clock). */
|
|
15595
15650
|
notePresented(card) {
|
|
15596
15651
|
if (card.status !== "new") return;
|
|
@@ -15603,6 +15658,9 @@ var init_courseDB2 = __esm({
|
|
|
15603
15658
|
navigator2.setEphemeralHints(this._pendingHints);
|
|
15604
15659
|
this._pendingHints = null;
|
|
15605
15660
|
}
|
|
15661
|
+
if (this._sessionId) {
|
|
15662
|
+
navigator2.setSessionId(this._sessionId);
|
|
15663
|
+
}
|
|
15606
15664
|
return navigator2.getWeightedCards(limit);
|
|
15607
15665
|
} catch (e) {
|
|
15608
15666
|
logger.error(`[static/courseDB] Error getting weighted cards: ${e}`);
|