@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
@@ -1,4 +1,4 @@
1
- import { U as UserDBInterface, a as UserDBReader, C as CourseDBInterface, b as CoursesDBInterface, c as ClassroomDBInterface, A as AdminDBInterface } from './contentSource-BDRX_YYJ.js';
1
+ import { U as UserDBInterface, a as UserDBReader, C as CourseDBInterface, b as CoursesDBInterface, c as ClassroomDBInterface, A as AdminDBInterface } from './contentSource-B1pqryv6.js';
2
2
 
3
3
  /**
4
4
  * Main factory interface for data access
@@ -1,4 +1,4 @@
1
- import { U as UserDBInterface, a as UserDBReader, C as CourseDBInterface, b as CoursesDBInterface, c as ClassroomDBInterface, A as AdminDBInterface } from './contentSource-D-LQYFyx.cjs';
1
+ import { U as UserDBInterface, a as UserDBReader, C as CourseDBInterface, b as CoursesDBInterface, c as ClassroomDBInterface, A as AdminDBInterface } from './contentSource-CpTxVrFx.cjs';
2
2
 
3
3
  /**
4
4
  * Main factory interface for data access
@@ -1,7 +1,7 @@
1
- import { T as TagStub, a as Tag, S as SkuilderCourseData, Q as QualifiedCardID } from '../../types-legacy-4tlwHnXo.cjs';
1
+ import { T as TagStub, a as Tag, S as SkuilderCourseData, Q as QualifiedCardID } from '../../types-legacy-BytY5eAR.cjs';
2
2
  import { Moment } from 'moment';
3
- import { A as AdminDBInterface, g as AssignedContent, h as StudyContentSource, i as StudentClassroomDBInterface, U as UserDBInterface, G as GeneratorResult, T as TeacherClassroomDBInterface, b as CoursesDBInterface, C as CourseDBInterface, d as CourseInfo, D as DataLayerResult, e as ContentNavigationStrategyData, f as ContentNavigator, R as ReplanHints, S as StudySessionItem, j as ScheduledCard } from '../../contentSource-D-LQYFyx.cjs';
4
- export { q as ContentSourceID, k as StudySessionFailedItem, l as StudySessionFailedNewItem, m as StudySessionFailedReviewItem, n as StudySessionNewItem, o as StudySessionReviewItem, r as getStudySource, p as isReview } from '../../contentSource-D-LQYFyx.cjs';
3
+ import { A as AdminDBInterface, g as AssignedContent, h as StudyContentSource, i as StudentClassroomDBInterface, U as UserDBInterface, G as GeneratorResult, T as TeacherClassroomDBInterface, b as CoursesDBInterface, C as CourseDBInterface, d as CourseInfo, D as DataLayerResult, e as ContentNavigationStrategyData, f as ContentNavigator, R as ReplanHints, S as StudySessionItem, j as ScheduledCard } from '../../contentSource-CpTxVrFx.cjs';
4
+ export { q as ContentSourceID, k as StudySessionFailedItem, l as StudySessionFailedNewItem, m as StudySessionFailedReviewItem, n as StudySessionNewItem, o as StudySessionReviewItem, r as getStudySource, p as isReview } from '../../contentSource-CpTxVrFx.cjs';
5
5
  import * as _vue_skuilder_common from '@vue-skuilder/common';
6
6
  import { ClassroomConfig, DataShape, CourseElo, CourseConfig as CourseConfig$1 } from '@vue-skuilder/common';
7
7
  import { S as SyncStrategy, A as AccountCreationResult, a as AuthenticationResult } from '../../SyncStrategy-CCU1H81I.cjs';
@@ -1,7 +1,7 @@
1
- import { T as TagStub, a as Tag, S as SkuilderCourseData, Q as QualifiedCardID } from '../../types-legacy-4tlwHnXo.js';
1
+ import { T as TagStub, a as Tag, S as SkuilderCourseData, Q as QualifiedCardID } from '../../types-legacy-BytY5eAR.js';
2
2
  import { Moment } from 'moment';
3
- import { A as AdminDBInterface, g as AssignedContent, h as StudyContentSource, i as StudentClassroomDBInterface, U as UserDBInterface, G as GeneratorResult, T as TeacherClassroomDBInterface, b as CoursesDBInterface, C as CourseDBInterface, d as CourseInfo, D as DataLayerResult, e as ContentNavigationStrategyData, f as ContentNavigator, R as ReplanHints, S as StudySessionItem, j as ScheduledCard } from '../../contentSource-BDRX_YYJ.js';
4
- export { q as ContentSourceID, k as StudySessionFailedItem, l as StudySessionFailedNewItem, m as StudySessionFailedReviewItem, n as StudySessionNewItem, o as StudySessionReviewItem, r as getStudySource, p as isReview } from '../../contentSource-BDRX_YYJ.js';
3
+ import { A as AdminDBInterface, g as AssignedContent, h as StudyContentSource, i as StudentClassroomDBInterface, U as UserDBInterface, G as GeneratorResult, T as TeacherClassroomDBInterface, b as CoursesDBInterface, C as CourseDBInterface, d as CourseInfo, D as DataLayerResult, e as ContentNavigationStrategyData, f as ContentNavigator, R as ReplanHints, S as StudySessionItem, j as ScheduledCard } from '../../contentSource-B1pqryv6.js';
4
+ export { q as ContentSourceID, k as StudySessionFailedItem, l as StudySessionFailedNewItem, m as StudySessionFailedReviewItem, n as StudySessionNewItem, o as StudySessionReviewItem, r as getStudySource, p as isReview } from '../../contentSource-B1pqryv6.js';
5
5
  import * as _vue_skuilder_common from '@vue-skuilder/common';
6
6
  import { ClassroomConfig, DataShape, CourseElo, CourseConfig as CourseConfig$1 } from '@vue-skuilder/common';
7
7
  import { S as SyncStrategy, A as AccountCreationResult, a as AuthenticationResult } from '../../SyncStrategy-CCU1H81I.js';
@@ -286,6 +286,7 @@ var init_types_legacy = __esm({
286
286
  DocType2["STRATEGY_STATE"] = "STRATEGY_STATE";
287
287
  DocType2["USER_OUTCOME"] = "USER_OUTCOME";
288
288
  DocType2["STRATEGY_LEARNING_STATE"] = "STRATEGY_LEARNING_STATE";
289
+ DocType2["STUDY_SESSION"] = "STUDY_SESSION";
289
290
  return DocType2;
290
291
  })(DocType || {});
291
292
  DocTypePrefixes = {
@@ -302,7 +303,8 @@ var init_types_legacy = __esm({
302
303
  ["NAVIGATION_STRATEGY" /* NAVIGATION_STRATEGY */]: "NAVIGATION_STRATEGY",
303
304
  ["STRATEGY_STATE" /* STRATEGY_STATE */]: "STRATEGY_STATE",
304
305
  ["USER_OUTCOME" /* USER_OUTCOME */]: "USER_OUTCOME",
305
- ["STRATEGY_LEARNING_STATE" /* STRATEGY_LEARNING_STATE */]: "STRATEGY_LEARNING_STATE"
306
+ ["STRATEGY_LEARNING_STATE" /* STRATEGY_LEARNING_STATE */]: "STRATEGY_LEARNING_STATE",
307
+ ["STUDY_SESSION" /* STUDY_SESSION */]: "SESSION"
306
308
  };
307
309
  }
308
310
  });
@@ -738,10 +740,13 @@ __export(PipelineDebugger_exports, {
738
740
  buildRunReport: () => buildRunReport,
739
741
  captureRun: () => captureRun,
740
742
  clearRunHistory: () => clearRunHistory,
743
+ drainCapturedRuns: () => drainCapturedRuns,
741
744
  getActivePipeline: () => getActivePipeline,
745
+ getRunsForSession: () => getRunsForSession,
742
746
  mountPipelineDebugger: () => mountPipelineDebugger,
743
747
  pipelineDebugAPI: () => pipelineDebugAPI,
744
- registerPipelineForDebug: () => registerPipelineForDebug
748
+ registerPipelineForDebug: () => registerPipelineForDebug,
749
+ setDebugSessionId: () => setDebugSessionId
745
750
  });
746
751
  function registerPipelineForDebug(pipeline) {
747
752
  _activePipeline = pipeline;
@@ -749,8 +754,20 @@ function registerPipelineForDebug(pipeline) {
749
754
  function getActivePipeline() {
750
755
  return _activePipeline;
751
756
  }
757
+ function setDebugSessionId(sessionId) {
758
+ _currentSessionId = sessionId;
759
+ }
760
+ function drainCapturedRuns() {
761
+ const drained = _pendingRuns;
762
+ _pendingRuns = [];
763
+ return drained;
764
+ }
765
+ function getRunsForSession(sessionId) {
766
+ return runHistory.filter((r) => r.sessionId === sessionId).reverse();
767
+ }
752
768
  function clearRunHistory() {
753
769
  runHistory.length = 0;
770
+ _pendingRuns = [];
754
771
  }
755
772
  function getOrigin(card) {
756
773
  const firstEntry = card.provenance[0];
@@ -765,12 +782,15 @@ function captureRun(report) {
765
782
  const fullReport = {
766
783
  ...report,
767
784
  runId: `run-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
785
+ sessionId: _currentSessionId,
768
786
  timestamp: /* @__PURE__ */ new Date()
769
787
  };
770
788
  runHistory.unshift(fullReport);
771
789
  if (runHistory.length > MAX_RUNS) {
772
790
  runHistory.pop();
773
791
  }
792
+ _pendingRuns.push(fullReport);
793
+ return fullReport;
774
794
  }
775
795
  function parseCardElo(provenance) {
776
796
  const eloEntry = provenance.find((p) => p.strategy === "elo");
@@ -1098,7 +1118,7 @@ function mountPipelineDebugger() {
1098
1118
  win.skuilder = win.skuilder || {};
1099
1119
  win.skuilder.pipeline = pipelineDebugAPI;
1100
1120
  }
1101
- var _activePipeline, MAX_RUNS, runHistory, DISCARDED_KEEP_TOP, _uiContainer, _selectedRunIndex, _cardSearchQuery, pipelineDebugAPI;
1121
+ var _activePipeline, MAX_RUNS, runHistory, _currentSessionId, _pendingRuns, DISCARDED_KEEP_TOP, _uiContainer, _selectedRunIndex, _cardSearchQuery, pipelineDebugAPI;
1102
1122
  var init_PipelineDebugger = __esm({
1103
1123
  "src/core/navigators/PipelineDebugger.ts"() {
1104
1124
  "use strict";
@@ -1107,6 +1127,7 @@ var init_PipelineDebugger = __esm({
1107
1127
  _activePipeline = null;
1108
1128
  MAX_RUNS = 10;
1109
1129
  runHistory = [];
1130
+ _pendingRuns = [];
1110
1131
  DISCARDED_KEEP_TOP = 25;
1111
1132
  _uiContainer = null;
1112
1133
  _selectedRunIndex = null;
@@ -5084,11 +5105,13 @@ __export(navigators_exports, {
5084
5105
  clearSrsBacklogDebug: () => clearSrsBacklogDebug,
5085
5106
  clearStrategyPressureDebug: () => clearStrategyPressureDebug,
5086
5107
  diversityRerank: () => diversityRerank,
5108
+ drainCapturedRuns: () => drainCapturedRuns,
5087
5109
  getActivePipeline: () => getActivePipeline,
5088
5110
  getCardOrigin: () => getCardOrigin,
5089
5111
  getRegisteredNavigator: () => getRegisteredNavigator,
5090
5112
  getRegisteredNavigatorNames: () => getRegisteredNavigatorNames,
5091
5113
  getRegisteredNavigatorRole: () => getRegisteredNavigatorRole,
5114
+ getRunsForSession: () => getRunsForSession,
5092
5115
  getSrsBacklogDebug: () => getSrsBacklogDebug,
5093
5116
  getStrategyPressureDebug: () => getStrategyPressureDebug,
5094
5117
  hasRegisteredNavigator: () => hasRegisteredNavigator,
@@ -5097,7 +5120,8 @@ __export(navigators_exports, {
5097
5120
  isGenerator: () => isGenerator,
5098
5121
  mountPipelineDebugger: () => mountPipelineDebugger,
5099
5122
  pipelineDebugAPI: () => pipelineDebugAPI,
5100
- registerNavigator: () => registerNavigator
5123
+ registerNavigator: () => registerNavigator,
5124
+ setDebugSessionId: () => setDebugSessionId
5101
5125
  });
5102
5126
  function registerNavigator(implementingClass, constructor, role) {
5103
5127
  navigatorRegistry.set(implementingClass, { constructor, role });
@@ -6748,6 +6772,14 @@ var init_userOutcome = __esm({
6748
6772
  }
6749
6773
  });
6750
6774
 
6775
+ // src/core/types/studySession.ts
6776
+ var init_studySession = __esm({
6777
+ "src/core/types/studySession.ts"() {
6778
+ "use strict";
6779
+ init_types_legacy();
6780
+ }
6781
+ });
6782
+
6751
6783
  // src/core/types/hydration.ts
6752
6784
  var HYDRATION_MARKER_ID;
6753
6785
  var init_hydration = __esm({
@@ -7254,6 +7286,7 @@ var init_core = __esm({
7254
7286
  init_user();
7255
7287
  init_strategyState();
7256
7288
  init_userOutcome();
7289
+ init_studySession();
7257
7290
  init_hydration();
7258
7291
  init_Loggable();
7259
7292
  init_util();
@@ -8522,6 +8555,32 @@ Currently logged-in as ${this._username}.`
8522
8555
  };
8523
8556
  await this.localDB.put(doc);
8524
8557
  }
8558
+ /**
8559
+ * Open and close write the same `_id`, so the 409 path is the expected
8560
+ * route for the second write, not an error case.
8561
+ */
8562
+ async putStudySession(doc) {
8563
+ try {
8564
+ await this.localDB.put(doc);
8565
+ } catch (err) {
8566
+ if (err.status === 409) {
8567
+ const existing = await this.localDB.get(doc._id);
8568
+ await this.localDB.put({ ...doc, _rev: existing._rev });
8569
+ } else {
8570
+ throw err;
8571
+ }
8572
+ }
8573
+ }
8574
+ async getStudySessions(courseId) {
8575
+ const prefix = courseId ? `${DocTypePrefixes["STUDY_SESSION" /* STUDY_SESSION */]}::${courseId}::` : `${DocTypePrefixes["STUDY_SESSION" /* STUDY_SESSION */]}::`;
8576
+ const keys = getStartAndEndKeys2(prefix);
8577
+ const res = await this.localDB.allDocs({
8578
+ startkey: keys.startkey,
8579
+ endkey: keys.endkey,
8580
+ include_docs: true
8581
+ });
8582
+ return res.rows.map((r) => r.doc).filter((d) => !!d).sort((a, b) => b.startTime.localeCompare(a.startTime));
8583
+ }
8525
8584
  async putUserOutcome(record) {
8526
8585
  try {
8527
8586
  await this.localDB.put(record);