@vue-skuilder/db 0.2.31 → 0.2.33
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-Doh1aVBJ.d.cts → contentSource-CTQ4kWhR.d.cts} +22 -0
- package/dist/{contentSource-DMduBjDC.d.ts → contentSource-JmWYu8IK.d.ts} +22 -0
- package/dist/core/index.d.cts +3 -3
- package/dist/core/index.d.ts +3 -3
- package/dist/core/index.js +50 -3
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.mjs +50 -3
- package/dist/core/index.mjs.map +1 -1
- package/dist/{dataLayerProvider-BW1CBAbb.d.cts → dataLayerProvider-DfI_KYAe.d.cts} +1 -1
- package/dist/{dataLayerProvider-Cxfe4nSK.d.ts → dataLayerProvider-rlLE2Mf-.d.ts} +1 -1
- package/dist/diagnostics/index.d.cts +2 -2
- package/dist/diagnostics/index.d.ts +2 -2
- package/dist/diagnostics/index.js +12 -0
- package/dist/diagnostics/index.js.map +1 -1
- package/dist/diagnostics/index.mjs +12 -0
- package/dist/diagnostics/index.mjs.map +1 -1
- package/dist/impl/couch/index.d.cts +17 -2
- package/dist/impl/couch/index.d.ts +17 -2
- package/dist/impl/couch/index.js +50 -3
- package/dist/impl/couch/index.js.map +1 -1
- package/dist/impl/couch/index.mjs +50 -3
- package/dist/impl/couch/index.mjs.map +1 -1
- package/dist/impl/static/index.d.cts +2 -2
- package/dist/impl/static/index.d.ts +2 -2
- package/dist/impl/static/index.js +50 -3
- package/dist/impl/static/index.js.map +1 -1
- package/dist/impl/static/index.mjs +50 -3
- package/dist/impl/static/index.mjs.map +1 -1
- package/dist/index.d.cts +14 -3
- package/dist/index.d.ts +14 -3
- package/dist/index.js +101 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +101 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/core/navigators/Pipeline.ts +13 -2
- package/src/core/navigators/PipelineAssembler.ts +2 -0
- package/src/core/navigators/PipelineDebugger.ts +12 -0
- package/src/core/navigators/defaults.ts +4 -1
- package/src/core/types/studySession.ts +11 -1
- package/src/core/versionStamps.ts +66 -0
- package/src/diagnostics/text.ts +13 -0
- package/src/factory.ts +6 -0
- package/src/study/SessionController.ts +3 -0
- package/src/study/services/EloService.ts +49 -4
- package/tsup.config.ts +5 -0
package/dist/index.mjs
CHANGED
|
@@ -4770,6 +4770,11 @@ var init_Pipeline = __esm({
|
|
|
4770
4770
|
* This eliminates a remote getCourseConfig() round trip per pipeline run.
|
|
4771
4771
|
*/
|
|
4772
4772
|
_cachedOrchestration = null;
|
|
4773
|
+
/**
|
|
4774
|
+
* Hash of the strategy docs this pipeline was assembled from (see
|
|
4775
|
+
* versionStamps.ts), set by whoever builds it. Stamped on every run.
|
|
4776
|
+
*/
|
|
4777
|
+
strategyHash;
|
|
4773
4778
|
/**
|
|
4774
4779
|
* Persistent tag cache. Maps cardId → tag names.
|
|
4775
4780
|
*
|
|
@@ -4963,7 +4968,8 @@ var init_Pipeline = __esm({
|
|
|
4963
4968
|
logResultCards(result);
|
|
4964
4969
|
logCardProvenance(result, 3);
|
|
4965
4970
|
try {
|
|
4966
|
-
const
|
|
4971
|
+
const courseConfig = await this.course?.getCourseConfig().catch(() => void 0);
|
|
4972
|
+
const courseName = courseConfig?.name;
|
|
4967
4973
|
const report = buildRunReport(
|
|
4968
4974
|
this.course?.getCourseID() || "unknown",
|
|
4969
4975
|
courseName,
|
|
@@ -4978,7 +4984,11 @@ var init_Pipeline = __esm({
|
|
|
4978
4984
|
scoredCards,
|
|
4979
4985
|
regulators
|
|
4980
4986
|
);
|
|
4981
|
-
|
|
4987
|
+
const versions = {
|
|
4988
|
+
...this.strategyHash ? { strategies: this.strategyHash } : {},
|
|
4989
|
+
...courseConfig?.contentVersion ? { content: courseConfig.contentVersion } : {}
|
|
4990
|
+
};
|
|
4991
|
+
captureRun({ ...report, ...Object.keys(versions).length ? { versions } : {} });
|
|
4982
4992
|
} catch (e) {
|
|
4983
4993
|
logger.debug(`[Pipeline] Failed to capture debug run: ${e}`);
|
|
4984
4994
|
}
|
|
@@ -5475,6 +5485,43 @@ var init_Pipeline = __esm({
|
|
|
5475
5485
|
}
|
|
5476
5486
|
});
|
|
5477
5487
|
|
|
5488
|
+
// src/core/versionStamps.ts
|
|
5489
|
+
function setAppVersion(version) {
|
|
5490
|
+
hostAppVersion = version;
|
|
5491
|
+
}
|
|
5492
|
+
function sessionVersions() {
|
|
5493
|
+
return { framework: FRAMEWORK_VERSION, ...hostAppVersion ? { app: hostAppVersion } : {} };
|
|
5494
|
+
}
|
|
5495
|
+
function stableStringify(value) {
|
|
5496
|
+
if (Array.isArray(value)) return `[${value.map(stableStringify).join(",")}]`;
|
|
5497
|
+
if (value && typeof value === "object") {
|
|
5498
|
+
const entries = Object.entries(value).filter(([, v]) => v !== void 0).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
|
|
5499
|
+
return `{${entries.map(([k, v]) => `${JSON.stringify(k)}:${stableStringify(v)}`).join(",")}}`;
|
|
5500
|
+
}
|
|
5501
|
+
return JSON.stringify(value);
|
|
5502
|
+
}
|
|
5503
|
+
function strategyHash(strategies) {
|
|
5504
|
+
if (strategies.length === 0) return DEFAULT_STRATEGY_HASH;
|
|
5505
|
+
const text = strategies.map((s) => {
|
|
5506
|
+
const { _rev: _ignored, ...rest } = s;
|
|
5507
|
+
return stableStringify(rest);
|
|
5508
|
+
}).sort().join("\n");
|
|
5509
|
+
let h = 2166136261;
|
|
5510
|
+
for (let i = 0; i < text.length; i++) {
|
|
5511
|
+
h ^= text.charCodeAt(i);
|
|
5512
|
+
h = Math.imul(h, 16777619);
|
|
5513
|
+
}
|
|
5514
|
+
return (h >>> 0).toString(16).padStart(8, "0");
|
|
5515
|
+
}
|
|
5516
|
+
var FRAMEWORK_VERSION, hostAppVersion, DEFAULT_STRATEGY_HASH;
|
|
5517
|
+
var init_versionStamps = __esm({
|
|
5518
|
+
"src/core/versionStamps.ts"() {
|
|
5519
|
+
"use strict";
|
|
5520
|
+
FRAMEWORK_VERSION = true ? "0.2.33" : "dev";
|
|
5521
|
+
DEFAULT_STRATEGY_HASH = "default";
|
|
5522
|
+
}
|
|
5523
|
+
});
|
|
5524
|
+
|
|
5478
5525
|
// src/core/navigators/defaults.ts
|
|
5479
5526
|
var defaults_exports = {};
|
|
5480
5527
|
__export(defaults_exports, {
|
|
@@ -5527,7 +5574,9 @@ function createDefaultPipeline(user, course) {
|
|
|
5527
5574
|
course,
|
|
5528
5575
|
createDefaultEloDistanceStrategy(courseId)
|
|
5529
5576
|
);
|
|
5530
|
-
|
|
5577
|
+
const pipeline = new Pipeline(compositeGenerator, [eloDistanceFilter], user, course);
|
|
5578
|
+
pipeline.strategyHash = DEFAULT_STRATEGY_HASH;
|
|
5579
|
+
return pipeline;
|
|
5531
5580
|
}
|
|
5532
5581
|
var init_defaults = __esm({
|
|
5533
5582
|
"src/core/navigators/defaults.ts"() {
|
|
@@ -5539,6 +5588,7 @@ var init_defaults = __esm({
|
|
|
5539
5588
|
init_srs();
|
|
5540
5589
|
init_eloDistance();
|
|
5541
5590
|
init_types_legacy();
|
|
5591
|
+
init_versionStamps();
|
|
5542
5592
|
}
|
|
5543
5593
|
});
|
|
5544
5594
|
|
|
@@ -5682,6 +5732,7 @@ var init_PipelineAssembler = __esm({
|
|
|
5682
5732
|
init_logger();
|
|
5683
5733
|
init_CompositeGenerator();
|
|
5684
5734
|
init_pipelinePlan();
|
|
5735
|
+
init_versionStamps();
|
|
5685
5736
|
PipelineAssembler = class {
|
|
5686
5737
|
/**
|
|
5687
5738
|
* Assembles a navigation pipeline from strategy documents.
|
|
@@ -5763,6 +5814,7 @@ var init_PipelineAssembler = __esm({
|
|
|
5763
5814
|
}
|
|
5764
5815
|
}
|
|
5765
5816
|
const pipeline = new Pipeline(generator, filters, user, course);
|
|
5817
|
+
pipeline.strategyHash = strategyHash(strategies);
|
|
5766
5818
|
logger.debug(
|
|
5767
5819
|
`[PipelineAssembler] Assembled pipeline with ${generatorStrategies.length} generator(s) and ${filters.length} filter(s)`
|
|
5768
5820
|
);
|
|
@@ -8222,10 +8274,30 @@ var init_EloService = __esm({
|
|
|
8222
8274
|
EloService = class {
|
|
8223
8275
|
dataLayer;
|
|
8224
8276
|
user;
|
|
8277
|
+
/** Per course ID: its compiled `CourseConfig.qaUsernamePattern`, or null. */
|
|
8278
|
+
qaPatterns = /* @__PURE__ */ new Map();
|
|
8225
8279
|
constructor(dataLayer, user) {
|
|
8226
8280
|
this.dataLayer = dataLayer;
|
|
8227
8281
|
this.user = user;
|
|
8228
8282
|
}
|
|
8283
|
+
/**
|
|
8284
|
+
* Whether the current user is one of the course's QA accounts
|
|
8285
|
+
* (`CourseConfig.qaUsernamePattern`), whose responses must not move card
|
|
8286
|
+
* ELO. The pattern is read once per course. If the config is unreadable or
|
|
8287
|
+
* the pattern doesn't compile, nobody is a QA account.
|
|
8288
|
+
*/
|
|
8289
|
+
async isQaUser(courseDB) {
|
|
8290
|
+
const courseId = courseDB.getCourseID();
|
|
8291
|
+
let pattern = this.qaPatterns.get(courseId);
|
|
8292
|
+
if (!pattern) {
|
|
8293
|
+
pattern = courseDB.getCourseConfig().then((cfg) => cfg.qaUsernamePattern ? new RegExp(cfg.qaUsernamePattern, "i") : null).catch((e) => {
|
|
8294
|
+
logger.warn(`[EloService] No QA username pattern for ${courseId}: ${e}`);
|
|
8295
|
+
return null;
|
|
8296
|
+
});
|
|
8297
|
+
this.qaPatterns.set(courseId, pattern);
|
|
8298
|
+
}
|
|
8299
|
+
return (await pattern)?.test(this.user.getUsername()) ?? false;
|
|
8300
|
+
}
|
|
8229
8301
|
/**
|
|
8230
8302
|
* Updates both user and card ELO ratings based on user performance.
|
|
8231
8303
|
* @param userScore Score between 0-1 representing user performance
|
|
@@ -8252,6 +8324,7 @@ var init_EloService = __esm({
|
|
|
8252
8324
|
const userElo = toCourseElo7(courseReg.elo);
|
|
8253
8325
|
const cardElo = (await courseDB.getCardEloData([currentCard.card.card_id]))[0];
|
|
8254
8326
|
if (cardElo && userElo) {
|
|
8327
|
+
const writeCard = !await this.isQaUser(courseDB);
|
|
8255
8328
|
const beforeUserGlobal = userElo.global.score;
|
|
8256
8329
|
const beforeCardGlobal = cardElo.global.score;
|
|
8257
8330
|
const cardTagKeys = Object.keys(cardElo.tags);
|
|
@@ -8275,12 +8348,18 @@ var init_EloService = __esm({
|
|
|
8275
8348
|
at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
8276
8349
|
userScore,
|
|
8277
8350
|
global: { before: beforeUserGlobal, after: eloUpdate.userElo.global.score },
|
|
8278
|
-
card: {
|
|
8351
|
+
card: {
|
|
8352
|
+
before: beforeCardGlobal,
|
|
8353
|
+
after: writeCard ? eloUpdate.cardElo.global.score : beforeCardGlobal
|
|
8354
|
+
},
|
|
8279
8355
|
...cardTagKeys.length ? { tags } : {}
|
|
8280
8356
|
};
|
|
8357
|
+
if (!writeCard) {
|
|
8358
|
+
logger.info(`[EloService] QA account: card ELO for ${card_id} not written`);
|
|
8359
|
+
}
|
|
8281
8360
|
const results = await Promise.allSettled([
|
|
8282
8361
|
this.user.updateUserElo(course_id, eloUpdate.userElo),
|
|
8283
|
-
courseDB.updateCardElo(card_id, eloUpdate.cardElo)
|
|
8362
|
+
writeCard ? courseDB.updateCardElo(card_id, eloUpdate.cardElo) : Promise.resolve(null)
|
|
8284
8363
|
]);
|
|
8285
8364
|
const userEloStatus = results[0].status === "fulfilled";
|
|
8286
8365
|
const cardEloStatus = results[1].status === "fulfilled";
|
|
@@ -8347,6 +8426,7 @@ var init_EloService = __esm({
|
|
|
8347
8426
|
}
|
|
8348
8427
|
}
|
|
8349
8428
|
if (cardElo && userElo) {
|
|
8429
|
+
const writeCard = !await this.isQaUser(courseDB);
|
|
8350
8430
|
const beforeUserGlobal = userElo.global.score;
|
|
8351
8431
|
const beforeCardGlobal = cardElo.global.score;
|
|
8352
8432
|
const touchedTags = Object.keys(enriched).filter((key) => key !== "_global");
|
|
@@ -8378,12 +8458,18 @@ var init_EloService = __esm({
|
|
|
8378
8458
|
at,
|
|
8379
8459
|
userScore: globalScore,
|
|
8380
8460
|
global: { before: beforeUserGlobal, after: eloUpdate.userElo.global.score },
|
|
8381
|
-
card: {
|
|
8461
|
+
card: {
|
|
8462
|
+
before: beforeCardGlobal,
|
|
8463
|
+
after: writeCard ? eloUpdate.cardElo.global.score : beforeCardGlobal
|
|
8464
|
+
},
|
|
8382
8465
|
...touchedTags.length ? { tags } : {}
|
|
8383
8466
|
};
|
|
8467
|
+
if (!writeCard) {
|
|
8468
|
+
logger.info(`[EloService] QA account: card ELO for ${card_id} not written`);
|
|
8469
|
+
}
|
|
8384
8470
|
const results = await Promise.allSettled([
|
|
8385
8471
|
this.user.updateUserElo(course_id, eloUpdate.userElo),
|
|
8386
|
-
courseDB.updateCardElo(card_id, eloUpdate.cardElo)
|
|
8472
|
+
writeCard ? courseDB.updateCardElo(card_id, eloUpdate.cardElo) : Promise.resolve(null)
|
|
8387
8473
|
]);
|
|
8388
8474
|
const userEloStatus = results[0].status === "fulfilled";
|
|
8389
8475
|
const cardEloStatus = results[1].status === "fulfilled";
|
|
@@ -11699,6 +11785,7 @@ var init_SessionController = __esm({
|
|
|
11699
11785
|
init_util2();
|
|
11700
11786
|
init_navigators();
|
|
11701
11787
|
init_Pipeline();
|
|
11788
|
+
init_versionStamps();
|
|
11702
11789
|
init_SourceMixer();
|
|
11703
11790
|
init_MixerDebugger();
|
|
11704
11791
|
init_SessionDebugger();
|
|
@@ -11997,7 +12084,8 @@ var init_SessionController = __esm({
|
|
|
11997
12084
|
...run.discardedTail ? { discardedTail: run.discardedTail } : {},
|
|
11998
12085
|
cards: persistedRunCards(run),
|
|
11999
12086
|
...run.unselectedNew ? { unselectedNew: persistedUnselectedNew(run.unselectedNew) } : {},
|
|
12000
|
-
...run.regulators ? { regulators: run.regulators.map(persistedReading) } : {}
|
|
12087
|
+
...run.regulators ? { regulators: run.regulators.map(persistedReading) } : {},
|
|
12088
|
+
...run.versions ? { versions: run.versions } : {}
|
|
12001
12089
|
});
|
|
12002
12090
|
}
|
|
12003
12091
|
}
|
|
@@ -12034,6 +12122,7 @@ var init_SessionController = __esm({
|
|
|
12034
12122
|
sourceCount: this.sources.length,
|
|
12035
12123
|
initHints: this._sessionHints
|
|
12036
12124
|
},
|
|
12125
|
+
versions: sessionVersions(),
|
|
12037
12126
|
initialQueues: { supplyQ: this.supplyQ.length, failedQ: this.failedQ.length },
|
|
12038
12127
|
runs: [...this._runLog],
|
|
12039
12128
|
stateAtStart: await this._captureState("start")
|
|
@@ -15740,6 +15829,9 @@ async function initializeDataLayer(config) {
|
|
|
15740
15829
|
if (config.options.localStoragePrefix) {
|
|
15741
15830
|
ENV.LOCAL_STORAGE_PREFIX = config.options.localStoragePrefix;
|
|
15742
15831
|
}
|
|
15832
|
+
if (config.options.appVersion) {
|
|
15833
|
+
setAppVersion(config.options.appVersion);
|
|
15834
|
+
}
|
|
15743
15835
|
if (config.type === "couch") {
|
|
15744
15836
|
if (!config.options.COUCHDB_SERVER_URL || !config.options.COUCHDB_SERVER_PROTOCOL) {
|
|
15745
15837
|
throw new Error("Missing CouchDB server URL or protocol");
|
|
@@ -15796,6 +15888,7 @@ var init_factory = __esm({
|
|
|
15796
15888
|
init_common();
|
|
15797
15889
|
init_logger();
|
|
15798
15890
|
init_navigators();
|
|
15891
|
+
init_versionStamps();
|
|
15799
15892
|
NOT_SET = "NOT_SET";
|
|
15800
15893
|
ENV = {
|
|
15801
15894
|
COUCHDB_SERVER_PROTOCOL: NOT_SET,
|