@vue-skuilder/db 0.2.21 → 0.2.23

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 (48) hide show
  1. package/dist/{contentSource-BMxsujRu.d.cts → contentSource-BvOpKUeU.d.ts} +442 -79
  2. package/dist/{contentSource-Bazgkf4C.d.ts → contentSource-DT9NaX69.d.cts} +442 -79
  3. package/dist/core/index.d.cts +84 -342
  4. package/dist/core/index.d.ts +84 -342
  5. package/dist/core/index.js +79 -4
  6. package/dist/core/index.js.map +1 -1
  7. package/dist/core/index.mjs +74 -4
  8. package/dist/core/index.mjs.map +1 -1
  9. package/dist/{dataLayerProvider-Bt-D6xas.d.ts → dataLayerProvider-CY2B2lyW.d.ts} +1 -1
  10. package/dist/{dataLayerProvider-DifVCcIS.d.cts → dataLayerProvider-wY6s_4x9.d.cts} +1 -1
  11. package/dist/impl/couch/index.d.cts +3 -3
  12. package/dist/impl/couch/index.d.ts +3 -3
  13. package/dist/impl/couch/index.js +63 -4
  14. package/dist/impl/couch/index.js.map +1 -1
  15. package/dist/impl/couch/index.mjs +63 -4
  16. package/dist/impl/couch/index.mjs.map +1 -1
  17. package/dist/impl/static/index.d.cts +4 -4
  18. package/dist/impl/static/index.d.ts +4 -4
  19. package/dist/impl/static/index.js +63 -4
  20. package/dist/impl/static/index.js.map +1 -1
  21. package/dist/impl/static/index.mjs +63 -4
  22. package/dist/impl/static/index.mjs.map +1 -1
  23. package/dist/{index-BLLT5BYE.d.ts → index-BkBJlGDX.d.ts} +1 -1
  24. package/dist/{index-k9NFHpS1.d.cts → index-D7WdMDAs.d.cts} +1 -1
  25. package/dist/index.d.cts +51 -14
  26. package/dist/index.d.ts +51 -14
  27. package/dist/index.js +240 -12
  28. package/dist/index.js.map +1 -1
  29. package/dist/index.mjs +235 -12
  30. package/dist/index.mjs.map +1 -1
  31. package/dist/{types-BFUa1pa3.d.cts → types-DjiFOZxJ.d.cts} +1 -1
  32. package/dist/{types-legacy-4tlwHnXo.d.cts → types-legacy-CrwyZIvI.d.cts} +10 -2
  33. package/dist/{types-legacy-4tlwHnXo.d.ts → types-legacy-CrwyZIvI.d.ts} +10 -2
  34. package/dist/{types-CHgpWQAY.d.ts → types-uJ2Xn3_X.d.ts} +1 -1
  35. package/dist/util/packer/index.d.cts +3 -3
  36. package/dist/util/packer/index.d.ts +3 -3
  37. package/package.json +3 -3
  38. package/src/core/index.ts +1 -0
  39. package/src/core/interfaces/userDB.ts +7 -0
  40. package/src/core/navigators/PipelineDebugger.ts +41 -1
  41. package/src/core/navigators/index.ts +3 -0
  42. package/src/core/types/studySession.ts +125 -0
  43. package/src/core/types/types-legacy.ts +8 -0
  44. package/src/impl/common/BaseUserDB.ts +36 -0
  45. package/src/study/SessionController.ts +188 -2
  46. package/src/study/SessionDebugger.ts +4 -3
  47. package/src/study/SessionOverlay.ts +1 -0
  48. package/src/study/services/ResponseProcessor.ts +32 -4
@@ -264,6 +264,7 @@ var init_types_legacy = __esm({
264
264
  DocType2["STRATEGY_STATE"] = "STRATEGY_STATE";
265
265
  DocType2["USER_OUTCOME"] = "USER_OUTCOME";
266
266
  DocType2["STRATEGY_LEARNING_STATE"] = "STRATEGY_LEARNING_STATE";
267
+ DocType2["STUDY_SESSION"] = "STUDY_SESSION";
267
268
  return DocType2;
268
269
  })(DocType || {});
269
270
  DocTypePrefixes = {
@@ -280,7 +281,8 @@ var init_types_legacy = __esm({
280
281
  ["NAVIGATION_STRATEGY" /* NAVIGATION_STRATEGY */]: "NAVIGATION_STRATEGY",
281
282
  ["STRATEGY_STATE" /* STRATEGY_STATE */]: "STRATEGY_STATE",
282
283
  ["USER_OUTCOME" /* USER_OUTCOME */]: "USER_OUTCOME",
283
- ["STRATEGY_LEARNING_STATE" /* STRATEGY_LEARNING_STATE */]: "STRATEGY_LEARNING_STATE"
284
+ ["STRATEGY_LEARNING_STATE" /* STRATEGY_LEARNING_STATE */]: "STRATEGY_LEARNING_STATE",
285
+ ["STUDY_SESSION" /* STUDY_SESSION */]: "SESSION"
284
286
  };
285
287
  }
286
288
  });
@@ -716,10 +718,13 @@ __export(PipelineDebugger_exports, {
716
718
  buildRunReport: () => buildRunReport,
717
719
  captureRun: () => captureRun,
718
720
  clearRunHistory: () => clearRunHistory,
721
+ drainCapturedRuns: () => drainCapturedRuns,
719
722
  getActivePipeline: () => getActivePipeline,
723
+ getRunsForSession: () => getRunsForSession,
720
724
  mountPipelineDebugger: () => mountPipelineDebugger,
721
725
  pipelineDebugAPI: () => pipelineDebugAPI,
722
- registerPipelineForDebug: () => registerPipelineForDebug
726
+ registerPipelineForDebug: () => registerPipelineForDebug,
727
+ setDebugSessionId: () => setDebugSessionId
723
728
  });
724
729
  function registerPipelineForDebug(pipeline) {
725
730
  _activePipeline = pipeline;
@@ -727,8 +732,20 @@ function registerPipelineForDebug(pipeline) {
727
732
  function getActivePipeline() {
728
733
  return _activePipeline;
729
734
  }
735
+ function setDebugSessionId(sessionId) {
736
+ _currentSessionId = sessionId;
737
+ }
738
+ function drainCapturedRuns() {
739
+ const drained = _pendingRuns;
740
+ _pendingRuns = [];
741
+ return drained;
742
+ }
743
+ function getRunsForSession(sessionId) {
744
+ return runHistory.filter((r) => r.sessionId === sessionId).reverse();
745
+ }
730
746
  function clearRunHistory() {
731
747
  runHistory.length = 0;
748
+ _pendingRuns = [];
732
749
  }
733
750
  function getOrigin(card) {
734
751
  const firstEntry = card.provenance[0];
@@ -743,12 +760,15 @@ function captureRun(report) {
743
760
  const fullReport = {
744
761
  ...report,
745
762
  runId: `run-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
763
+ sessionId: _currentSessionId,
746
764
  timestamp: /* @__PURE__ */ new Date()
747
765
  };
748
766
  runHistory.unshift(fullReport);
749
767
  if (runHistory.length > MAX_RUNS) {
750
768
  runHistory.pop();
751
769
  }
770
+ _pendingRuns.push(fullReport);
771
+ return fullReport;
752
772
  }
753
773
  function parseCardElo(provenance) {
754
774
  const eloEntry = provenance.find((p) => p.strategy === "elo");
@@ -1076,7 +1096,7 @@ function mountPipelineDebugger() {
1076
1096
  win.skuilder = win.skuilder || {};
1077
1097
  win.skuilder.pipeline = pipelineDebugAPI;
1078
1098
  }
1079
- var _activePipeline, MAX_RUNS, runHistory, DISCARDED_KEEP_TOP, _uiContainer, _selectedRunIndex, _cardSearchQuery, pipelineDebugAPI;
1099
+ var _activePipeline, MAX_RUNS, runHistory, _currentSessionId, _pendingRuns, DISCARDED_KEEP_TOP, _uiContainer, _selectedRunIndex, _cardSearchQuery, pipelineDebugAPI;
1080
1100
  var init_PipelineDebugger = __esm({
1081
1101
  "src/core/navigators/PipelineDebugger.ts"() {
1082
1102
  "use strict";
@@ -1085,6 +1105,7 @@ var init_PipelineDebugger = __esm({
1085
1105
  _activePipeline = null;
1086
1106
  MAX_RUNS = 10;
1087
1107
  runHistory = [];
1108
+ _pendingRuns = [];
1088
1109
  DISCARDED_KEEP_TOP = 25;
1089
1110
  _uiContainer = null;
1090
1111
  _selectedRunIndex = null;
@@ -5062,11 +5083,13 @@ __export(navigators_exports, {
5062
5083
  clearSrsBacklogDebug: () => clearSrsBacklogDebug,
5063
5084
  clearStrategyPressureDebug: () => clearStrategyPressureDebug,
5064
5085
  diversityRerank: () => diversityRerank,
5086
+ drainCapturedRuns: () => drainCapturedRuns,
5065
5087
  getActivePipeline: () => getActivePipeline,
5066
5088
  getCardOrigin: () => getCardOrigin,
5067
5089
  getRegisteredNavigator: () => getRegisteredNavigator,
5068
5090
  getRegisteredNavigatorNames: () => getRegisteredNavigatorNames,
5069
5091
  getRegisteredNavigatorRole: () => getRegisteredNavigatorRole,
5092
+ getRunsForSession: () => getRunsForSession,
5070
5093
  getSrsBacklogDebug: () => getSrsBacklogDebug,
5071
5094
  getStrategyPressureDebug: () => getStrategyPressureDebug,
5072
5095
  hasRegisteredNavigator: () => hasRegisteredNavigator,
@@ -5075,7 +5098,8 @@ __export(navigators_exports, {
5075
5098
  isGenerator: () => isGenerator,
5076
5099
  mountPipelineDebugger: () => mountPipelineDebugger,
5077
5100
  pipelineDebugAPI: () => pipelineDebugAPI,
5078
- registerNavigator: () => registerNavigator
5101
+ registerNavigator: () => registerNavigator,
5102
+ setDebugSessionId: () => setDebugSessionId
5079
5103
  });
5080
5104
  function registerNavigator(implementingClass, constructor, role) {
5081
5105
  navigatorRegistry.set(implementingClass, { constructor, role });
@@ -6730,6 +6754,14 @@ var init_userOutcome = __esm({
6730
6754
  }
6731
6755
  });
6732
6756
 
6757
+ // src/core/types/studySession.ts
6758
+ var init_studySession = __esm({
6759
+ "src/core/types/studySession.ts"() {
6760
+ "use strict";
6761
+ init_types_legacy();
6762
+ }
6763
+ });
6764
+
6733
6765
  // src/core/types/hydration.ts
6734
6766
  var HYDRATION_MARKER_ID;
6735
6767
  var init_hydration = __esm({
@@ -7234,6 +7266,7 @@ var init_core = __esm({
7234
7266
  init_user();
7235
7267
  init_strategyState();
7236
7268
  init_userOutcome();
7269
+ init_studySession();
7237
7270
  init_hydration();
7238
7271
  init_Loggable();
7239
7272
  init_util();
@@ -8502,6 +8535,32 @@ Currently logged-in as ${this._username}.`
8502
8535
  };
8503
8536
  await this.localDB.put(doc);
8504
8537
  }
8538
+ /**
8539
+ * Open and close write the same `_id`, so the 409 path is the expected
8540
+ * route for the second write, not an error case.
8541
+ */
8542
+ async putStudySession(doc) {
8543
+ try {
8544
+ await this.localDB.put(doc);
8545
+ } catch (err) {
8546
+ if (err.status === 409) {
8547
+ const existing = await this.localDB.get(doc._id);
8548
+ await this.localDB.put({ ...doc, _rev: existing._rev });
8549
+ } else {
8550
+ throw err;
8551
+ }
8552
+ }
8553
+ }
8554
+ async getStudySessions(courseId) {
8555
+ const prefix = courseId ? `${DocTypePrefixes["STUDY_SESSION" /* STUDY_SESSION */]}::${courseId}::` : `${DocTypePrefixes["STUDY_SESSION" /* STUDY_SESSION */]}::`;
8556
+ const keys = getStartAndEndKeys2(prefix);
8557
+ const res = await this.localDB.allDocs({
8558
+ startkey: keys.startkey,
8559
+ endkey: keys.endkey,
8560
+ include_docs: true
8561
+ });
8562
+ return res.rows.map((r) => r.doc).filter((d) => !!d).sort((a, b) => b.startTime.localeCompare(a.startTime));
8563
+ }
8505
8564
  async putUserOutcome(record) {
8506
8565
  try {
8507
8566
  await this.localDB.put(record);