@vue-skuilder/db 0.2.20 → 0.2.22

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 (49) hide show
  1. package/dist/{contentSource-BDRX_YYJ.d.ts → contentSource-B1pqryv6.d.ts} +87 -2
  2. package/dist/{contentSource-D-LQYFyx.d.cts → contentSource-CpTxVrFx.d.cts} +87 -2
  3. package/dist/core/index.d.cts +16 -6
  4. package/dist/core/index.d.ts +16 -6
  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-Dpshuql4.d.ts → dataLayerProvider-BZqH27f4.d.ts} +1 -1
  10. package/dist/{dataLayerProvider-Dd2UcCif.d.cts → dataLayerProvider-D4c7iUc_.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-k9NFHpS1.d.cts → index-DGApnUZ-.d.cts} +1 -1
  24. package/dist/{index-BLLT5BYE.d.ts → index-rmNIwnkV.d.ts} +1 -1
  25. package/dist/index.d.cts +51 -14
  26. package/dist/index.d.ts +51 -14
  27. package/dist/index.js +231 -12
  28. package/dist/index.js.map +1 -1
  29. package/dist/index.mjs +226 -12
  30. package/dist/index.mjs.map +1 -1
  31. package/dist/{types-CHgpWQAY.d.ts → types-B-Y3aoi5.d.ts} +1 -1
  32. package/dist/{types-legacy-4tlwHnXo.d.cts → types-legacy-BytY5eAR.d.cts} +9 -1
  33. package/dist/{types-legacy-4tlwHnXo.d.ts → types-legacy-BytY5eAR.d.ts} +9 -1
  34. package/dist/{types-BFUa1pa3.d.cts → types-r6fyuWP2.d.cts} +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 +100 -0
  43. package/src/core/types/types-legacy.ts +8 -0
  44. package/src/core/types/user.ts +6 -1
  45. package/src/impl/common/BaseUserDB.ts +36 -0
  46. package/src/study/SessionController.ts +179 -2
  47. package/src/study/SessionDebugger.ts +4 -3
  48. package/src/study/SessionOverlay.ts +1 -0
  49. package/src/study/services/ResponseProcessor.ts +32 -4
@@ -100,6 +100,7 @@ var init_types_legacy = __esm({
100
100
  DocType3["STRATEGY_STATE"] = "STRATEGY_STATE";
101
101
  DocType3["USER_OUTCOME"] = "USER_OUTCOME";
102
102
  DocType3["STRATEGY_LEARNING_STATE"] = "STRATEGY_LEARNING_STATE";
103
+ DocType3["STUDY_SESSION"] = "STUDY_SESSION";
103
104
  return DocType3;
104
105
  })(DocType || {});
105
106
  DocTypePrefixes = {
@@ -116,7 +117,8 @@ var init_types_legacy = __esm({
116
117
  ["NAVIGATION_STRATEGY" /* NAVIGATION_STRATEGY */]: "NAVIGATION_STRATEGY",
117
118
  ["STRATEGY_STATE" /* STRATEGY_STATE */]: "STRATEGY_STATE",
118
119
  ["USER_OUTCOME" /* USER_OUTCOME */]: "USER_OUTCOME",
119
- ["STRATEGY_LEARNING_STATE" /* STRATEGY_LEARNING_STATE */]: "STRATEGY_LEARNING_STATE"
120
+ ["STRATEGY_LEARNING_STATE" /* STRATEGY_LEARNING_STATE */]: "STRATEGY_LEARNING_STATE",
121
+ ["STUDY_SESSION" /* STUDY_SESSION */]: "SESSION"
120
122
  };
121
123
  }
122
124
  });
@@ -596,10 +598,13 @@ __export(PipelineDebugger_exports, {
596
598
  buildRunReport: () => buildRunReport,
597
599
  captureRun: () => captureRun,
598
600
  clearRunHistory: () => clearRunHistory,
601
+ drainCapturedRuns: () => drainCapturedRuns,
599
602
  getActivePipeline: () => getActivePipeline,
603
+ getRunsForSession: () => getRunsForSession,
600
604
  mountPipelineDebugger: () => mountPipelineDebugger,
601
605
  pipelineDebugAPI: () => pipelineDebugAPI,
602
- registerPipelineForDebug: () => registerPipelineForDebug
606
+ registerPipelineForDebug: () => registerPipelineForDebug,
607
+ setDebugSessionId: () => setDebugSessionId
603
608
  });
604
609
  function registerPipelineForDebug(pipeline) {
605
610
  _activePipeline = pipeline;
@@ -607,8 +612,20 @@ function registerPipelineForDebug(pipeline) {
607
612
  function getActivePipeline() {
608
613
  return _activePipeline;
609
614
  }
615
+ function setDebugSessionId(sessionId) {
616
+ _currentSessionId = sessionId;
617
+ }
618
+ function drainCapturedRuns() {
619
+ const drained = _pendingRuns;
620
+ _pendingRuns = [];
621
+ return drained;
622
+ }
623
+ function getRunsForSession(sessionId) {
624
+ return runHistory.filter((r) => r.sessionId === sessionId).reverse();
625
+ }
610
626
  function clearRunHistory() {
611
627
  runHistory.length = 0;
628
+ _pendingRuns = [];
612
629
  }
613
630
  function getOrigin(card) {
614
631
  const firstEntry = card.provenance[0];
@@ -623,12 +640,15 @@ function captureRun(report) {
623
640
  const fullReport = {
624
641
  ...report,
625
642
  runId: `run-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
643
+ sessionId: _currentSessionId,
626
644
  timestamp: /* @__PURE__ */ new Date()
627
645
  };
628
646
  runHistory.unshift(fullReport);
629
647
  if (runHistory.length > MAX_RUNS) {
630
648
  runHistory.pop();
631
649
  }
650
+ _pendingRuns.push(fullReport);
651
+ return fullReport;
632
652
  }
633
653
  function parseCardElo(provenance) {
634
654
  const eloEntry = provenance.find((p) => p.strategy === "elo");
@@ -956,7 +976,7 @@ function mountPipelineDebugger() {
956
976
  win.skuilder = win.skuilder || {};
957
977
  win.skuilder.pipeline = pipelineDebugAPI;
958
978
  }
959
- var _activePipeline, MAX_RUNS, runHistory, DISCARDED_KEEP_TOP, _uiContainer, _selectedRunIndex, _cardSearchQuery, pipelineDebugAPI;
979
+ var _activePipeline, MAX_RUNS, runHistory, _currentSessionId, _pendingRuns, DISCARDED_KEEP_TOP, _uiContainer, _selectedRunIndex, _cardSearchQuery, pipelineDebugAPI;
960
980
  var init_PipelineDebugger = __esm({
961
981
  "src/core/navigators/PipelineDebugger.ts"() {
962
982
  "use strict";
@@ -965,6 +985,7 @@ var init_PipelineDebugger = __esm({
965
985
  _activePipeline = null;
966
986
  MAX_RUNS = 10;
967
987
  runHistory = [];
988
+ _pendingRuns = [];
968
989
  DISCARDED_KEEP_TOP = 25;
969
990
  _uiContainer = null;
970
991
  _selectedRunIndex = null;
@@ -4942,11 +4963,13 @@ __export(navigators_exports, {
4942
4963
  clearSrsBacklogDebug: () => clearSrsBacklogDebug,
4943
4964
  clearStrategyPressureDebug: () => clearStrategyPressureDebug,
4944
4965
  diversityRerank: () => diversityRerank,
4966
+ drainCapturedRuns: () => drainCapturedRuns,
4945
4967
  getActivePipeline: () => getActivePipeline,
4946
4968
  getCardOrigin: () => getCardOrigin,
4947
4969
  getRegisteredNavigator: () => getRegisteredNavigator,
4948
4970
  getRegisteredNavigatorNames: () => getRegisteredNavigatorNames,
4949
4971
  getRegisteredNavigatorRole: () => getRegisteredNavigatorRole,
4972
+ getRunsForSession: () => getRunsForSession,
4950
4973
  getSrsBacklogDebug: () => getSrsBacklogDebug,
4951
4974
  getStrategyPressureDebug: () => getStrategyPressureDebug,
4952
4975
  hasRegisteredNavigator: () => hasRegisteredNavigator,
@@ -4955,7 +4978,8 @@ __export(navigators_exports, {
4955
4978
  isGenerator: () => isGenerator,
4956
4979
  mountPipelineDebugger: () => mountPipelineDebugger,
4957
4980
  pipelineDebugAPI: () => pipelineDebugAPI,
4958
- registerNavigator: () => registerNavigator
4981
+ registerNavigator: () => registerNavigator,
4982
+ setDebugSessionId: () => setDebugSessionId
4959
4983
  });
4960
4984
  function registerNavigator(implementingClass, constructor, role) {
4961
4985
  navigatorRegistry.set(implementingClass, { constructor, role });
@@ -6562,6 +6586,32 @@ Currently logged-in as ${this._username}.`
6562
6586
  };
6563
6587
  await this.localDB.put(doc);
6564
6588
  }
6589
+ /**
6590
+ * Open and close write the same `_id`, so the 409 path is the expected
6591
+ * route for the second write, not an error case.
6592
+ */
6593
+ async putStudySession(doc) {
6594
+ try {
6595
+ await this.localDB.put(doc);
6596
+ } catch (err) {
6597
+ if (err.status === 409) {
6598
+ const existing = await this.localDB.get(doc._id);
6599
+ await this.localDB.put({ ...doc, _rev: existing._rev });
6600
+ } else {
6601
+ throw err;
6602
+ }
6603
+ }
6604
+ }
6605
+ async getStudySessions(courseId) {
6606
+ const prefix = courseId ? `${DocTypePrefixes["STUDY_SESSION" /* STUDY_SESSION */]}::${courseId}::` : `${DocTypePrefixes["STUDY_SESSION" /* STUDY_SESSION */]}::`;
6607
+ const keys = getStartAndEndKeys(prefix);
6608
+ const res = await this.localDB.allDocs({
6609
+ startkey: keys.startkey,
6610
+ endkey: keys.endkey,
6611
+ include_docs: true
6612
+ });
6613
+ return res.rows.map((r) => r.doc).filter((d) => !!d).sort((a, b) => b.startTime.localeCompare(a.startTime));
6614
+ }
6565
6615
  async putUserOutcome(record) {
6566
6616
  try {
6567
6617
  await this.localDB.put(record);
@@ -6707,6 +6757,14 @@ var init_userOutcome = __esm({
6707
6757
  }
6708
6758
  });
6709
6759
 
6760
+ // src/core/types/studySession.ts
6761
+ var init_studySession = __esm({
6762
+ "src/core/types/studySession.ts"() {
6763
+ "use strict";
6764
+ init_types_legacy();
6765
+ }
6766
+ });
6767
+
6710
6768
  // src/core/types/hydration.ts
6711
6769
  var HYDRATION_MARKER_ID;
6712
6770
  var init_hydration = __esm({
@@ -7084,6 +7142,7 @@ var init_core = __esm({
7084
7142
  init_user();
7085
7143
  init_strategyState();
7086
7144
  init_userOutcome();
7145
+ init_studySession();
7087
7146
  init_hydration();
7088
7147
  init_Loggable();
7089
7148
  init_util();