@vue-skuilder/db 0.2.25 → 0.2.27
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 +55 -13
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.mjs +55 -13
- 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 +71 -13
- package/dist/impl/couch/index.js.map +1 -1
- package/dist/impl/couch/index.mjs +71 -13
- 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 +55 -13
- package/dist/impl/static/index.js.map +1 -1
- package/dist/impl/static/index.mjs +55 -13
- 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 +72 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +72 -14
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/core/interfaces/userDB.ts +10 -0
- package/src/core/navigators/generators/prescribed.ts +43 -14
- 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
- package/tests/core/navigators/prescribedIntroExposure.test.ts +29 -0
|
@@ -1942,7 +1942,8 @@ var init_generators = __esm({
|
|
|
1942
1942
|
// src/core/navigators/generators/prescribed.ts
|
|
1943
1943
|
var prescribed_exports = {};
|
|
1944
1944
|
__export(prescribed_exports, {
|
|
1945
|
-
default: () => PrescribedCardsGenerator
|
|
1945
|
+
default: () => PrescribedCardsGenerator,
|
|
1946
|
+
unmetIntroExposeTags: () => unmetIntroExposeTags
|
|
1946
1947
|
});
|
|
1947
1948
|
function dedupe(arr) {
|
|
1948
1949
|
return [...new Set(arr)];
|
|
@@ -1982,6 +1983,19 @@ function formatAge(ms) {
|
|
|
1982
1983
|
if (hours < 24) return `${hours}h`;
|
|
1983
1984
|
return `${Math.round(hours / 24)}d`;
|
|
1984
1985
|
}
|
|
1986
|
+
function unmetIntroExposeTags(tags, userTagElo, minCount) {
|
|
1987
|
+
if (minCount <= 0) return [];
|
|
1988
|
+
const exposeTags = new Set(tags.filter((tag) => tag.startsWith("gpc:expose:")));
|
|
1989
|
+
for (const tag of tags) {
|
|
1990
|
+
if (!tag.startsWith("gpc:intro:")) continue;
|
|
1991
|
+
const suffix = tag.slice("gpc:intro:".length);
|
|
1992
|
+
if (suffix) exposeTags.add(`gpc:expose:${suffix}`);
|
|
1993
|
+
}
|
|
1994
|
+
return [...exposeTags].filter((tag) => {
|
|
1995
|
+
const tagElo = userTagElo[tag];
|
|
1996
|
+
return !tagElo || tagElo.count < minCount;
|
|
1997
|
+
});
|
|
1998
|
+
}
|
|
1985
1999
|
function pickTopByScore(cards, limit) {
|
|
1986
2000
|
return [...cards].sort((a, b) => b.score - a.score || a.cardId.localeCompare(b.cardId)).slice(0, limit);
|
|
1987
2001
|
}
|
|
@@ -2280,6 +2294,7 @@ var init_prescribed = __esm({
|
|
|
2280
2294
|
freshnessWindowSessions: typeof raw.freshnessWindowSessions === "number" ? raw.freshnessWindowSessions : DEFAULT_FRESHNESS_WINDOW,
|
|
2281
2295
|
maxDirectTargetsPerRun: typeof raw.maxDirectTargetsPerRun === "number" ? raw.maxDirectTargetsPerRun : DEFAULT_MAX_DIRECT_PER_RUN,
|
|
2282
2296
|
maxSupportCardsPerRun: typeof raw.maxSupportCardsPerRun === "number" ? raw.maxSupportCardsPerRun : DEFAULT_MAX_SUPPORT_PER_RUN,
|
|
2297
|
+
introExposeMinCount: typeof raw.introExposeMinCount === "number" ? raw.introExposeMinCount : DEFAULT_MIN_COUNT,
|
|
2283
2298
|
hierarchyWalk: {
|
|
2284
2299
|
enabled: raw.hierarchyWalk?.enabled !== false,
|
|
2285
2300
|
maxDepth: typeof raw.hierarchyWalk?.maxDepth === "number" ? raw.hierarchyWalk.maxDepth : DEFAULT_HIERARCHY_DEPTH
|
|
@@ -2355,18 +2370,11 @@ var init_prescribed = __esm({
|
|
|
2355
2370
|
group.hierarchyWalk?.enabled !== false,
|
|
2356
2371
|
group.hierarchyWalk?.maxDepth ?? DEFAULT_HIERARCHY_DEPTH
|
|
2357
2372
|
);
|
|
2358
|
-
const
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
exposeTags.add(`gpc:expose:${suffix}`);
|
|
2364
|
-
}
|
|
2365
|
-
}
|
|
2366
|
-
const unmetExposeTags = [...exposeTags].filter((tag) => {
|
|
2367
|
-
const tagElo = userTagElo[tag];
|
|
2368
|
-
return !tagElo || tagElo.count < DEFAULT_MIN_COUNT;
|
|
2369
|
-
});
|
|
2373
|
+
const unmetExposeTags = unmetIntroExposeTags(
|
|
2374
|
+
tags,
|
|
2375
|
+
userTagElo,
|
|
2376
|
+
group.introExposeMinCount ?? DEFAULT_MIN_COUNT
|
|
2377
|
+
);
|
|
2370
2378
|
if (unmetExposeTags.length > 0) {
|
|
2371
2379
|
unmetExposeTags.forEach((tag) => supportTags.add(tag));
|
|
2372
2380
|
}
|
|
@@ -9673,6 +9681,40 @@ Currently logged-in as ${this._username}.`
|
|
|
9673
9681
|
}
|
|
9674
9682
|
return loginResult;
|
|
9675
9683
|
}
|
|
9684
|
+
/**
|
|
9685
|
+
* Adopt a remote session that was established outside this client — e.g. a
|
|
9686
|
+
* backend verified a third-party sign-in (Google) and set the session cookie
|
|
9687
|
+
* on its response. Afterwards the user is logged in exactly as after
|
|
9688
|
+
* login(): username switched, guest pointer cleared, init() re-run.
|
|
9689
|
+
*
|
|
9690
|
+
* @param opts.migrateGuestData Carry the current guest account's local data
|
|
9691
|
+
* into the adopted account. Pass true for a freshly created account (as
|
|
9692
|
+
* createAccount() does), false for an existing one (as login() does).
|
|
9693
|
+
*/
|
|
9694
|
+
async adoptSession(opts) {
|
|
9695
|
+
if (!this.syncStrategy.canAuthenticate() || !this.syncStrategy.adoptSession) {
|
|
9696
|
+
throw new Error("Session adoption not supported by current sync strategy");
|
|
9697
|
+
}
|
|
9698
|
+
const guestUsername = this._username.startsWith(GuestUsername) ? this._username : void 0;
|
|
9699
|
+
if (!guestUsername) {
|
|
9700
|
+
throw new Error(`Cannot adopt a session while logged in.
|
|
9701
|
+
Log out of account ${this.getUsername()} first.`);
|
|
9702
|
+
}
|
|
9703
|
+
const result = await this.syncStrategy.adoptSession(
|
|
9704
|
+
opts.migrateGuestData ? guestUsername : void 0
|
|
9705
|
+
);
|
|
9706
|
+
if (result.ok && result.username) {
|
|
9707
|
+
log3(`Adopted session for ${result.username}`);
|
|
9708
|
+
this._username = result.username;
|
|
9709
|
+
try {
|
|
9710
|
+
localStorage.removeItem("sk-guest-uuid");
|
|
9711
|
+
} catch (e) {
|
|
9712
|
+
logger.warn("localStorage not available (Node.js environment):", e);
|
|
9713
|
+
}
|
|
9714
|
+
await this.init();
|
|
9715
|
+
}
|
|
9716
|
+
return result;
|
|
9717
|
+
}
|
|
9676
9718
|
async resetUserData() {
|
|
9677
9719
|
if (this.syncStrategy.canAuthenticate()) {
|
|
9678
9720
|
return {
|
|
@@ -11243,6 +11285,22 @@ var init_CouchDBSyncStrategy = __esm({
|
|
|
11243
11285
|
};
|
|
11244
11286
|
}
|
|
11245
11287
|
}
|
|
11288
|
+
async adoptSession(migrateFromGuest) {
|
|
11289
|
+
let username;
|
|
11290
|
+
try {
|
|
11291
|
+
username = await getLoggedInUsername();
|
|
11292
|
+
} catch {
|
|
11293
|
+
return { ok: false, error: "No session to adopt" };
|
|
11294
|
+
}
|
|
11295
|
+
if (migrateFromGuest?.startsWith(GuestUsername)) {
|
|
11296
|
+
logger.info(`Migrating data from funnel account ${migrateFromGuest} to ${username}`);
|
|
11297
|
+
const migrationResult = await this.migrateFunnelData(migrateFromGuest, username);
|
|
11298
|
+
if (!migrationResult.success) {
|
|
11299
|
+
logger.warn(`Migration failed: ${migrationResult.error}`);
|
|
11300
|
+
}
|
|
11301
|
+
}
|
|
11302
|
+
return { ok: true, username };
|
|
11303
|
+
}
|
|
11246
11304
|
async logout() {
|
|
11247
11305
|
try {
|
|
11248
11306
|
const result = await this.getRemoteCouchRootDB().logOut();
|