@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.
- package/dist/{SyncStrategy-CCU1H81I.d.cts → SyncStrategy-BXliog1m.d.cts} +14 -1
- package/dist/{SyncStrategy-CCU1H81I.d.ts → SyncStrategy-BXliog1m.d.ts} +14 -1
- package/dist/{contentSource-CrRnbjBx.d.cts → contentSource-D3c1fMAk.d.cts} +11 -0
- package/dist/{contentSource-kD35o65m.d.ts → contentSource-LPf044hY.d.ts} +11 -0
- package/dist/core/index.d.cts +3 -3
- package/dist/core/index.d.ts +3 -3
- package/dist/core/index.js +34 -0
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.mjs +34 -0
- package/dist/core/index.mjs.map +1 -1
- package/dist/{dataLayerProvider-IecbidDO.d.cts → dataLayerProvider-CeLiFbHv.d.cts} +1 -1
- package/dist/{dataLayerProvider-CtzddVdy.d.ts → dataLayerProvider-DaAootVV.d.ts} +1 -1
- package/dist/impl/couch/index.d.cts +4 -3
- package/dist/impl/couch/index.d.ts +4 -3
- package/dist/impl/couch/index.js +50 -0
- package/dist/impl/couch/index.js.map +1 -1
- package/dist/impl/couch/index.mjs +50 -0
- package/dist/impl/couch/index.mjs.map +1 -1
- package/dist/impl/static/index.d.cts +3 -3
- package/dist/impl/static/index.d.ts +3 -3
- package/dist/impl/static/index.js +34 -0
- package/dist/impl/static/index.js.map +1 -1
- package/dist/impl/static/index.mjs +34 -0
- package/dist/impl/static/index.mjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +51 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +51 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/core/interfaces/userDB.ts +10 -0
- package/src/impl/common/BaseUserDB.ts +40 -0
- package/src/impl/common/SyncStrategy.ts +11 -1
- package/src/impl/common/index.ts +1 -0
- package/src/impl/common/types.ts +5 -0
- package/src/impl/couch/CouchDBSyncStrategy.ts +25 -1
- package/src/study/SessionController.ts +6 -2
|
@@ -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-
|
|
1
|
+
import { U as UserDBInterface, a as UserDBReader, C as CourseDBInterface, b as CoursesDBInterface, c as ClassroomDBInterface, A as AdminDBInterface } from './contentSource-D3c1fMAk.cjs';
|
|
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-
|
|
1
|
+
import { U as UserDBInterface, a as UserDBReader, C as CourseDBInterface, b as CoursesDBInterface, c as ClassroomDBInterface, A as AdminDBInterface } from './contentSource-LPf044hY.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Main factory interface for data access
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { T as TagStub, a as Tag, S as SkuilderCourseData, Q as QualifiedCardID } from '../../types-legacy-CrwyZIvI.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-
|
|
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-
|
|
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-D3c1fMAk.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-D3c1fMAk.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
|
-
import { S as SyncStrategy, A as AccountCreationResult, a as AuthenticationResult } from '../../SyncStrategy-
|
|
7
|
+
import { S as SyncStrategy, A as AccountCreationResult, a as AuthenticationResult, b as AdoptSessionResult } from '../../SyncStrategy-BXliog1m.cjs';
|
|
8
8
|
|
|
9
9
|
type NamespacedDatashape = string;
|
|
10
10
|
interface DataShape55 {
|
|
@@ -534,6 +534,7 @@ declare class CouchDBSyncStrategy implements SyncStrategy {
|
|
|
534
534
|
canAuthenticate(): boolean;
|
|
535
535
|
createAccount(username: string, password: string): Promise<AccountCreationResult>;
|
|
536
536
|
authenticate(username: string, password: string): Promise<AuthenticationResult>;
|
|
537
|
+
adoptSession(migrateFromGuest?: string): Promise<AdoptSessionResult>;
|
|
537
538
|
logout(): Promise<AuthenticationResult>;
|
|
538
539
|
getCurrentUsername(): Promise<string>;
|
|
539
540
|
/**
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { T as TagStub, a as Tag, S as SkuilderCourseData, Q as QualifiedCardID } from '../../types-legacy-CrwyZIvI.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-
|
|
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-
|
|
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-LPf044hY.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-LPf044hY.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
|
-
import { S as SyncStrategy, A as AccountCreationResult, a as AuthenticationResult } from '../../SyncStrategy-
|
|
7
|
+
import { S as SyncStrategy, A as AccountCreationResult, a as AuthenticationResult, b as AdoptSessionResult } from '../../SyncStrategy-BXliog1m.js';
|
|
8
8
|
|
|
9
9
|
type NamespacedDatashape = string;
|
|
10
10
|
interface DataShape55 {
|
|
@@ -534,6 +534,7 @@ declare class CouchDBSyncStrategy implements SyncStrategy {
|
|
|
534
534
|
canAuthenticate(): boolean;
|
|
535
535
|
createAccount(username: string, password: string): Promise<AccountCreationResult>;
|
|
536
536
|
authenticate(username: string, password: string): Promise<AuthenticationResult>;
|
|
537
|
+
adoptSession(migrateFromGuest?: string): Promise<AdoptSessionResult>;
|
|
537
538
|
logout(): Promise<AuthenticationResult>;
|
|
538
539
|
getCurrentUsername(): Promise<string>;
|
|
539
540
|
/**
|
package/dist/impl/couch/index.js
CHANGED
|
@@ -9688,6 +9688,40 @@ Currently logged-in as ${this._username}.`
|
|
|
9688
9688
|
}
|
|
9689
9689
|
return loginResult;
|
|
9690
9690
|
}
|
|
9691
|
+
/**
|
|
9692
|
+
* Adopt a remote session that was established outside this client — e.g. a
|
|
9693
|
+
* backend verified a third-party sign-in (Google) and set the session cookie
|
|
9694
|
+
* on its response. Afterwards the user is logged in exactly as after
|
|
9695
|
+
* login(): username switched, guest pointer cleared, init() re-run.
|
|
9696
|
+
*
|
|
9697
|
+
* @param opts.migrateGuestData Carry the current guest account's local data
|
|
9698
|
+
* into the adopted account. Pass true for a freshly created account (as
|
|
9699
|
+
* createAccount() does), false for an existing one (as login() does).
|
|
9700
|
+
*/
|
|
9701
|
+
async adoptSession(opts) {
|
|
9702
|
+
if (!this.syncStrategy.canAuthenticate() || !this.syncStrategy.adoptSession) {
|
|
9703
|
+
throw new Error("Session adoption not supported by current sync strategy");
|
|
9704
|
+
}
|
|
9705
|
+
const guestUsername = this._username.startsWith(GuestUsername) ? this._username : void 0;
|
|
9706
|
+
if (!guestUsername) {
|
|
9707
|
+
throw new Error(`Cannot adopt a session while logged in.
|
|
9708
|
+
Log out of account ${this.getUsername()} first.`);
|
|
9709
|
+
}
|
|
9710
|
+
const result = await this.syncStrategy.adoptSession(
|
|
9711
|
+
opts.migrateGuestData ? guestUsername : void 0
|
|
9712
|
+
);
|
|
9713
|
+
if (result.ok && result.username) {
|
|
9714
|
+
log3(`Adopted session for ${result.username}`);
|
|
9715
|
+
this._username = result.username;
|
|
9716
|
+
try {
|
|
9717
|
+
localStorage.removeItem("sk-guest-uuid");
|
|
9718
|
+
} catch (e) {
|
|
9719
|
+
logger.warn("localStorage not available (Node.js environment):", e);
|
|
9720
|
+
}
|
|
9721
|
+
await this.init();
|
|
9722
|
+
}
|
|
9723
|
+
return result;
|
|
9724
|
+
}
|
|
9691
9725
|
async resetUserData() {
|
|
9692
9726
|
if (this.syncStrategy.canAuthenticate()) {
|
|
9693
9727
|
return {
|
|
@@ -11259,6 +11293,22 @@ var init_CouchDBSyncStrategy = __esm({
|
|
|
11259
11293
|
};
|
|
11260
11294
|
}
|
|
11261
11295
|
}
|
|
11296
|
+
async adoptSession(migrateFromGuest) {
|
|
11297
|
+
let username;
|
|
11298
|
+
try {
|
|
11299
|
+
username = await getLoggedInUsername();
|
|
11300
|
+
} catch {
|
|
11301
|
+
return { ok: false, error: "No session to adopt" };
|
|
11302
|
+
}
|
|
11303
|
+
if (migrateFromGuest?.startsWith(GuestUsername)) {
|
|
11304
|
+
logger.info(`Migrating data from funnel account ${migrateFromGuest} to ${username}`);
|
|
11305
|
+
const migrationResult = await this.migrateFunnelData(migrateFromGuest, username);
|
|
11306
|
+
if (!migrationResult.success) {
|
|
11307
|
+
logger.warn(`Migration failed: ${migrationResult.error}`);
|
|
11308
|
+
}
|
|
11309
|
+
}
|
|
11310
|
+
return { ok: true, username };
|
|
11311
|
+
}
|
|
11262
11312
|
async logout() {
|
|
11263
11313
|
try {
|
|
11264
11314
|
const result = await this.getRemoteCouchRootDB().logOut();
|