@vue-skuilder/db 0.2.25 → 0.2.26

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 (38) hide show
  1. package/dist/{SyncStrategy-CCU1H81I.d.cts → SyncStrategy-BXliog1m.d.cts} +14 -1
  2. package/dist/{SyncStrategy-CCU1H81I.d.ts → SyncStrategy-BXliog1m.d.ts} +14 -1
  3. package/dist/{contentSource-CrRnbjBx.d.cts → contentSource-D3c1fMAk.d.cts} +11 -0
  4. package/dist/{contentSource-kD35o65m.d.ts → contentSource-LPf044hY.d.ts} +11 -0
  5. package/dist/core/index.d.cts +3 -3
  6. package/dist/core/index.d.ts +3 -3
  7. package/dist/core/index.js +34 -0
  8. package/dist/core/index.js.map +1 -1
  9. package/dist/core/index.mjs +34 -0
  10. package/dist/core/index.mjs.map +1 -1
  11. package/dist/{dataLayerProvider-IecbidDO.d.cts → dataLayerProvider-CeLiFbHv.d.cts} +1 -1
  12. package/dist/{dataLayerProvider-CtzddVdy.d.ts → dataLayerProvider-DaAootVV.d.ts} +1 -1
  13. package/dist/impl/couch/index.d.cts +4 -3
  14. package/dist/impl/couch/index.d.ts +4 -3
  15. package/dist/impl/couch/index.js +50 -0
  16. package/dist/impl/couch/index.js.map +1 -1
  17. package/dist/impl/couch/index.mjs +50 -0
  18. package/dist/impl/couch/index.mjs.map +1 -1
  19. package/dist/impl/static/index.d.cts +3 -3
  20. package/dist/impl/static/index.d.ts +3 -3
  21. package/dist/impl/static/index.js +34 -0
  22. package/dist/impl/static/index.js.map +1 -1
  23. package/dist/impl/static/index.mjs +34 -0
  24. package/dist/impl/static/index.mjs.map +1 -1
  25. package/dist/index.d.cts +3 -3
  26. package/dist/index.d.ts +3 -3
  27. package/dist/index.js +51 -1
  28. package/dist/index.js.map +1 -1
  29. package/dist/index.mjs +51 -1
  30. package/dist/index.mjs.map +1 -1
  31. package/package.json +3 -3
  32. package/src/core/interfaces/userDB.ts +10 -0
  33. package/src/impl/common/BaseUserDB.ts +40 -0
  34. package/src/impl/common/SyncStrategy.ts +11 -1
  35. package/src/impl/common/index.ts +1 -0
  36. package/src/impl/common/types.ts +5 -0
  37. package/src/impl/couch/CouchDBSyncStrategy.ts +25 -1
  38. package/src/study/SessionController.ts +6 -2
package/dist/index.d.cts CHANGED
@@ -1,6 +1,6 @@
1
- import { U as UserDBInterface, s as CourseRegistrationDoc, t as SessionEloEvent, S as StudySessionItem, W as WeightedCard, R as ReplanHints, h as StudyContentSource, u as SessionStateSnapshotProvider, G as GeneratorResult, C as CourseDBInterface } from './contentSource-CrRnbjBx.cjs';
2
- export { M as ActivityRecord, A as AdminDBInterface, x as AssignedCard, g as AssignedContent, w as AssignedCourse, v as AssignedTag, af as CardGenerator, ah as CardGeneratorFactory, c as ClassroomDBInterface, I as ClassroomRegistration, H as ClassroomRegistrationDesignation, J as ClassroomRegistrationDoc, e as ContentNavigationStrategyData, f as ContentNavigator, q as ContentSourceID, d as CourseInfo, N as CourseRegistration, b as CoursesDBInterface, ay as DocumentUpdater, aq as FilterImpact, ag as GeneratorContext, ap as GeneratorSummary, $ as HYDRATION_MARKER_ID, a0 as HydrationMarker, as as LearnableWeight, a1 as NavigatorConstructor, ab as NavigatorRole, ac as NavigatorRoles, aa as Navigators, at as OrchestrationContext, ar as PipelineForecaster, ao as PipelineRunReport, j as ScheduledCard, V as SessionStateSnapshot, K as SessionTrackingData, a8 as StrategyContribution, i as StudentClassroomDBInterface, P as StudySessionDoc, k as StudySessionFailedItem, l as StudySessionFailedNewItem, m as StudySessionFailedReviewItem, n as StudySessionNewItem, o as StudySessionReviewItem, Q as StudySessionRunSummary, T as TeacherClassroomDBInterface, L as UserConfig, E as UserCourseSetting, B as UserCourseSettings, z as UserDBAuthenticator, a as UserDBReader, y as UserDBWriter, Z as UserHydrationState, _ as UserHydrationStatus, O as UserOutcomeRecord, F as UsrCrsDataInterface, au as computeDeviation, aw as computeEffectiveWeight, av as computeSpread, ax as createOrchestrationContext, an as drainCapturedRuns, ak as getActivePipeline, a9 as getCardOrigin, aB as getLapses, a3 as getRegisteredNavigator, a6 as getRegisteredNavigatorNames, a5 as getRegisteredNavigatorRole, am as getRunsForSession, aA as getStreak, r as getStudySource, a4 as hasRegisteredNavigator, a7 as initializeNavigatorRegistry, ae as isFilter, ad as isGenerator, p as isReview, X as makeStudySessionId, aj as mountPipelineDebugger, az as newInterval, Y as newSessionId, ai as pipelineDebugAPI, a2 as registerNavigator, al as setDebugSessionId } from './contentSource-CrRnbjBx.cjs';
3
- import { D as DataLayerProvider } from './dataLayerProvider-IecbidDO.cjs';
1
+ import { U as UserDBInterface, s as CourseRegistrationDoc, t as SessionEloEvent, S as StudySessionItem, W as WeightedCard, R as ReplanHints, h as StudyContentSource, u as SessionStateSnapshotProvider, G as GeneratorResult, C as CourseDBInterface } from './contentSource-D3c1fMAk.cjs';
2
+ export { M as ActivityRecord, A as AdminDBInterface, x as AssignedCard, g as AssignedContent, w as AssignedCourse, v as AssignedTag, af as CardGenerator, ah as CardGeneratorFactory, c as ClassroomDBInterface, I as ClassroomRegistration, H as ClassroomRegistrationDesignation, J as ClassroomRegistrationDoc, e as ContentNavigationStrategyData, f as ContentNavigator, q as ContentSourceID, d as CourseInfo, N as CourseRegistration, b as CoursesDBInterface, ay as DocumentUpdater, aq as FilterImpact, ag as GeneratorContext, ap as GeneratorSummary, $ as HYDRATION_MARKER_ID, a0 as HydrationMarker, as as LearnableWeight, a1 as NavigatorConstructor, ab as NavigatorRole, ac as NavigatorRoles, aa as Navigators, at as OrchestrationContext, ar as PipelineForecaster, ao as PipelineRunReport, j as ScheduledCard, V as SessionStateSnapshot, K as SessionTrackingData, a8 as StrategyContribution, i as StudentClassroomDBInterface, P as StudySessionDoc, k as StudySessionFailedItem, l as StudySessionFailedNewItem, m as StudySessionFailedReviewItem, n as StudySessionNewItem, o as StudySessionReviewItem, Q as StudySessionRunSummary, T as TeacherClassroomDBInterface, L as UserConfig, E as UserCourseSetting, B as UserCourseSettings, z as UserDBAuthenticator, a as UserDBReader, y as UserDBWriter, Z as UserHydrationState, _ as UserHydrationStatus, O as UserOutcomeRecord, F as UsrCrsDataInterface, au as computeDeviation, aw as computeEffectiveWeight, av as computeSpread, ax as createOrchestrationContext, an as drainCapturedRuns, ak as getActivePipeline, a9 as getCardOrigin, aB as getLapses, a3 as getRegisteredNavigator, a6 as getRegisteredNavigatorNames, a5 as getRegisteredNavigatorRole, am as getRunsForSession, aA as getStreak, r as getStudySource, a4 as hasRegisteredNavigator, a7 as initializeNavigatorRegistry, ae as isFilter, ad as isGenerator, p as isReview, X as makeStudySessionId, aj as mountPipelineDebugger, az as newInterval, Y as newSessionId, ai as pipelineDebugAPI, a2 as registerNavigator, al as setDebugSessionId } from './contentSource-D3c1fMAk.cjs';
3
+ import { D as DataLayerProvider } from './dataLayerProvider-CeLiFbHv.cjs';
4
4
  import { C as CardHistory, b as CardRecord, c as QuestionRecord } from './types-legacy-CrwyZIvI.cjs';
5
5
  export { d as CardData, e as CourseListData, g as DataShapeData, f as DisplayableData, D as DocType, i as DocTypePrefixes, F as Field, G as GuestUsername, Q as QualifiedCardID, h as QuestionData, S as SkuilderCourseData, a as Tag, T as TagStub, l as log } from './types-legacy-CrwyZIvI.cjs';
6
6
  import { SrsBacklogDebug, StrategyPressureDebug, Loggable } from './core/index.cjs';
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { U as UserDBInterface, s as CourseRegistrationDoc, t as SessionEloEvent, S as StudySessionItem, W as WeightedCard, R as ReplanHints, h as StudyContentSource, u as SessionStateSnapshotProvider, G as GeneratorResult, C as CourseDBInterface } from './contentSource-kD35o65m.js';
2
- export { M as ActivityRecord, A as AdminDBInterface, x as AssignedCard, g as AssignedContent, w as AssignedCourse, v as AssignedTag, af as CardGenerator, ah as CardGeneratorFactory, c as ClassroomDBInterface, I as ClassroomRegistration, H as ClassroomRegistrationDesignation, J as ClassroomRegistrationDoc, e as ContentNavigationStrategyData, f as ContentNavigator, q as ContentSourceID, d as CourseInfo, N as CourseRegistration, b as CoursesDBInterface, ay as DocumentUpdater, aq as FilterImpact, ag as GeneratorContext, ap as GeneratorSummary, $ as HYDRATION_MARKER_ID, a0 as HydrationMarker, as as LearnableWeight, a1 as NavigatorConstructor, ab as NavigatorRole, ac as NavigatorRoles, aa as Navigators, at as OrchestrationContext, ar as PipelineForecaster, ao as PipelineRunReport, j as ScheduledCard, V as SessionStateSnapshot, K as SessionTrackingData, a8 as StrategyContribution, i as StudentClassroomDBInterface, P as StudySessionDoc, k as StudySessionFailedItem, l as StudySessionFailedNewItem, m as StudySessionFailedReviewItem, n as StudySessionNewItem, o as StudySessionReviewItem, Q as StudySessionRunSummary, T as TeacherClassroomDBInterface, L as UserConfig, E as UserCourseSetting, B as UserCourseSettings, z as UserDBAuthenticator, a as UserDBReader, y as UserDBWriter, Z as UserHydrationState, _ as UserHydrationStatus, O as UserOutcomeRecord, F as UsrCrsDataInterface, au as computeDeviation, aw as computeEffectiveWeight, av as computeSpread, ax as createOrchestrationContext, an as drainCapturedRuns, ak as getActivePipeline, a9 as getCardOrigin, aB as getLapses, a3 as getRegisteredNavigator, a6 as getRegisteredNavigatorNames, a5 as getRegisteredNavigatorRole, am as getRunsForSession, aA as getStreak, r as getStudySource, a4 as hasRegisteredNavigator, a7 as initializeNavigatorRegistry, ae as isFilter, ad as isGenerator, p as isReview, X as makeStudySessionId, aj as mountPipelineDebugger, az as newInterval, Y as newSessionId, ai as pipelineDebugAPI, a2 as registerNavigator, al as setDebugSessionId } from './contentSource-kD35o65m.js';
3
- import { D as DataLayerProvider } from './dataLayerProvider-CtzddVdy.js';
1
+ import { U as UserDBInterface, s as CourseRegistrationDoc, t as SessionEloEvent, S as StudySessionItem, W as WeightedCard, R as ReplanHints, h as StudyContentSource, u as SessionStateSnapshotProvider, G as GeneratorResult, C as CourseDBInterface } from './contentSource-LPf044hY.js';
2
+ export { M as ActivityRecord, A as AdminDBInterface, x as AssignedCard, g as AssignedContent, w as AssignedCourse, v as AssignedTag, af as CardGenerator, ah as CardGeneratorFactory, c as ClassroomDBInterface, I as ClassroomRegistration, H as ClassroomRegistrationDesignation, J as ClassroomRegistrationDoc, e as ContentNavigationStrategyData, f as ContentNavigator, q as ContentSourceID, d as CourseInfo, N as CourseRegistration, b as CoursesDBInterface, ay as DocumentUpdater, aq as FilterImpact, ag as GeneratorContext, ap as GeneratorSummary, $ as HYDRATION_MARKER_ID, a0 as HydrationMarker, as as LearnableWeight, a1 as NavigatorConstructor, ab as NavigatorRole, ac as NavigatorRoles, aa as Navigators, at as OrchestrationContext, ar as PipelineForecaster, ao as PipelineRunReport, j as ScheduledCard, V as SessionStateSnapshot, K as SessionTrackingData, a8 as StrategyContribution, i as StudentClassroomDBInterface, P as StudySessionDoc, k as StudySessionFailedItem, l as StudySessionFailedNewItem, m as StudySessionFailedReviewItem, n as StudySessionNewItem, o as StudySessionReviewItem, Q as StudySessionRunSummary, T as TeacherClassroomDBInterface, L as UserConfig, E as UserCourseSetting, B as UserCourseSettings, z as UserDBAuthenticator, a as UserDBReader, y as UserDBWriter, Z as UserHydrationState, _ as UserHydrationStatus, O as UserOutcomeRecord, F as UsrCrsDataInterface, au as computeDeviation, aw as computeEffectiveWeight, av as computeSpread, ax as createOrchestrationContext, an as drainCapturedRuns, ak as getActivePipeline, a9 as getCardOrigin, aB as getLapses, a3 as getRegisteredNavigator, a6 as getRegisteredNavigatorNames, a5 as getRegisteredNavigatorRole, am as getRunsForSession, aA as getStreak, r as getStudySource, a4 as hasRegisteredNavigator, a7 as initializeNavigatorRegistry, ae as isFilter, ad as isGenerator, p as isReview, X as makeStudySessionId, aj as mountPipelineDebugger, az as newInterval, Y as newSessionId, ai as pipelineDebugAPI, a2 as registerNavigator, al as setDebugSessionId } from './contentSource-LPf044hY.js';
3
+ import { D as DataLayerProvider } from './dataLayerProvider-DaAootVV.js';
4
4
  import { C as CardHistory, b as CardRecord, c as QuestionRecord } from './types-legacy-CrwyZIvI.js';
5
5
  export { d as CardData, e as CourseListData, g as DataShapeData, f as DisplayableData, D as DocType, i as DocTypePrefixes, F as Field, G as GuestUsername, Q as QualifiedCardID, h as QuestionData, S as SkuilderCourseData, a as Tag, T as TagStub, l as log } from './types-legacy-CrwyZIvI.js';
6
6
  import { SrsBacklogDebug, StrategyPressureDebug, Loggable } from './core/index.js';
package/dist/index.js CHANGED
@@ -7368,6 +7368,22 @@ var init_CouchDBSyncStrategy = __esm({
7368
7368
  };
7369
7369
  }
7370
7370
  }
7371
+ async adoptSession(migrateFromGuest) {
7372
+ let username;
7373
+ try {
7374
+ username = await getLoggedInUsername();
7375
+ } catch {
7376
+ return { ok: false, error: "No session to adopt" };
7377
+ }
7378
+ if (migrateFromGuest?.startsWith(GuestUsername)) {
7379
+ logger.info(`Migrating data from funnel account ${migrateFromGuest} to ${username}`);
7380
+ const migrationResult = await this.migrateFunnelData(migrateFromGuest, username);
7381
+ if (!migrationResult.success) {
7382
+ logger.warn(`Migration failed: ${migrationResult.error}`);
7383
+ }
7384
+ }
7385
+ return { ok: true, username };
7386
+ }
7371
7387
  async logout() {
7372
7388
  try {
7373
7389
  const result = await this.getRemoteCouchRootDB().logOut();
@@ -11958,7 +11974,7 @@ var init_SessionController = __esm({
11958
11974
  });
11959
11975
  } catch (error) {
11960
11976
  this.error(`Failed to get content from source ${i}:`, error);
11961
- if (this.sources.length === 1) {
11977
+ if (this.sources.length === 1 && !replan) {
11962
11978
  throw new Error(`Cannot start session: failed to load content from source ${i}`);
11963
11979
  }
11964
11980
  }
@@ -13094,6 +13110,40 @@ Currently logged-in as ${this._username}.`
13094
13110
  }
13095
13111
  return loginResult;
13096
13112
  }
13113
+ /**
13114
+ * Adopt a remote session that was established outside this client — e.g. a
13115
+ * backend verified a third-party sign-in (Google) and set the session cookie
13116
+ * on its response. Afterwards the user is logged in exactly as after
13117
+ * login(): username switched, guest pointer cleared, init() re-run.
13118
+ *
13119
+ * @param opts.migrateGuestData Carry the current guest account's local data
13120
+ * into the adopted account. Pass true for a freshly created account (as
13121
+ * createAccount() does), false for an existing one (as login() does).
13122
+ */
13123
+ async adoptSession(opts) {
13124
+ if (!this.syncStrategy.canAuthenticate() || !this.syncStrategy.adoptSession) {
13125
+ throw new Error("Session adoption not supported by current sync strategy");
13126
+ }
13127
+ const guestUsername = this._username.startsWith(GuestUsername) ? this._username : void 0;
13128
+ if (!guestUsername) {
13129
+ throw new Error(`Cannot adopt a session while logged in.
13130
+ Log out of account ${this.getUsername()} first.`);
13131
+ }
13132
+ const result = await this.syncStrategy.adoptSession(
13133
+ opts.migrateGuestData ? guestUsername : void 0
13134
+ );
13135
+ if (result.ok && result.username) {
13136
+ log4(`Adopted session for ${result.username}`);
13137
+ this._username = result.username;
13138
+ try {
13139
+ localStorage.removeItem("sk-guest-uuid");
13140
+ } catch (e) {
13141
+ logger.warn("localStorage not available (Node.js environment):", e);
13142
+ }
13143
+ await this.init();
13144
+ }
13145
+ return result;
13146
+ }
13097
13147
  async resetUserData() {
13098
13148
  if (this.syncStrategy.canAuthenticate()) {
13099
13149
  return {