@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
package/dist/core/index.mjs
CHANGED
|
@@ -1867,7 +1867,8 @@ var init_generators = __esm({
|
|
|
1867
1867
|
// src/core/navigators/generators/prescribed.ts
|
|
1868
1868
|
var prescribed_exports = {};
|
|
1869
1869
|
__export(prescribed_exports, {
|
|
1870
|
-
default: () => PrescribedCardsGenerator
|
|
1870
|
+
default: () => PrescribedCardsGenerator,
|
|
1871
|
+
unmetIntroExposeTags: () => unmetIntroExposeTags
|
|
1871
1872
|
});
|
|
1872
1873
|
function dedupe(arr) {
|
|
1873
1874
|
return [...new Set(arr)];
|
|
@@ -1907,6 +1908,19 @@ function formatAge(ms) {
|
|
|
1907
1908
|
if (hours < 24) return `${hours}h`;
|
|
1908
1909
|
return `${Math.round(hours / 24)}d`;
|
|
1909
1910
|
}
|
|
1911
|
+
function unmetIntroExposeTags(tags, userTagElo, minCount) {
|
|
1912
|
+
if (minCount <= 0) return [];
|
|
1913
|
+
const exposeTags = new Set(tags.filter((tag) => tag.startsWith("gpc:expose:")));
|
|
1914
|
+
for (const tag of tags) {
|
|
1915
|
+
if (!tag.startsWith("gpc:intro:")) continue;
|
|
1916
|
+
const suffix = tag.slice("gpc:intro:".length);
|
|
1917
|
+
if (suffix) exposeTags.add(`gpc:expose:${suffix}`);
|
|
1918
|
+
}
|
|
1919
|
+
return [...exposeTags].filter((tag) => {
|
|
1920
|
+
const tagElo = userTagElo[tag];
|
|
1921
|
+
return !tagElo || tagElo.count < minCount;
|
|
1922
|
+
});
|
|
1923
|
+
}
|
|
1910
1924
|
function pickTopByScore(cards, limit) {
|
|
1911
1925
|
return [...cards].sort((a, b) => b.score - a.score || a.cardId.localeCompare(b.cardId)).slice(0, limit);
|
|
1912
1926
|
}
|
|
@@ -2205,6 +2219,7 @@ var init_prescribed = __esm({
|
|
|
2205
2219
|
freshnessWindowSessions: typeof raw.freshnessWindowSessions === "number" ? raw.freshnessWindowSessions : DEFAULT_FRESHNESS_WINDOW,
|
|
2206
2220
|
maxDirectTargetsPerRun: typeof raw.maxDirectTargetsPerRun === "number" ? raw.maxDirectTargetsPerRun : DEFAULT_MAX_DIRECT_PER_RUN,
|
|
2207
2221
|
maxSupportCardsPerRun: typeof raw.maxSupportCardsPerRun === "number" ? raw.maxSupportCardsPerRun : DEFAULT_MAX_SUPPORT_PER_RUN,
|
|
2222
|
+
introExposeMinCount: typeof raw.introExposeMinCount === "number" ? raw.introExposeMinCount : DEFAULT_MIN_COUNT,
|
|
2208
2223
|
hierarchyWalk: {
|
|
2209
2224
|
enabled: raw.hierarchyWalk?.enabled !== false,
|
|
2210
2225
|
maxDepth: typeof raw.hierarchyWalk?.maxDepth === "number" ? raw.hierarchyWalk.maxDepth : DEFAULT_HIERARCHY_DEPTH
|
|
@@ -2280,18 +2295,11 @@ var init_prescribed = __esm({
|
|
|
2280
2295
|
group.hierarchyWalk?.enabled !== false,
|
|
2281
2296
|
group.hierarchyWalk?.maxDepth ?? DEFAULT_HIERARCHY_DEPTH
|
|
2282
2297
|
);
|
|
2283
|
-
const
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
exposeTags.add(`gpc:expose:${suffix}`);
|
|
2289
|
-
}
|
|
2290
|
-
}
|
|
2291
|
-
const unmetExposeTags = [...exposeTags].filter((tag) => {
|
|
2292
|
-
const tagElo = userTagElo[tag];
|
|
2293
|
-
return !tagElo || tagElo.count < DEFAULT_MIN_COUNT;
|
|
2294
|
-
});
|
|
2298
|
+
const unmetExposeTags = unmetIntroExposeTags(
|
|
2299
|
+
tags,
|
|
2300
|
+
userTagElo,
|
|
2301
|
+
group.introExposeMinCount ?? DEFAULT_MIN_COUNT
|
|
2302
|
+
);
|
|
2295
2303
|
if (unmetExposeTags.length > 0) {
|
|
2296
2304
|
unmetExposeTags.forEach((tag) => supportTags.add(tag));
|
|
2297
2305
|
}
|
|
@@ -9200,6 +9208,40 @@ Currently logged-in as ${this._username}.`
|
|
|
9200
9208
|
}
|
|
9201
9209
|
return loginResult;
|
|
9202
9210
|
}
|
|
9211
|
+
/**
|
|
9212
|
+
* Adopt a remote session that was established outside this client — e.g. a
|
|
9213
|
+
* backend verified a third-party sign-in (Google) and set the session cookie
|
|
9214
|
+
* on its response. Afterwards the user is logged in exactly as after
|
|
9215
|
+
* login(): username switched, guest pointer cleared, init() re-run.
|
|
9216
|
+
*
|
|
9217
|
+
* @param opts.migrateGuestData Carry the current guest account's local data
|
|
9218
|
+
* into the adopted account. Pass true for a freshly created account (as
|
|
9219
|
+
* createAccount() does), false for an existing one (as login() does).
|
|
9220
|
+
*/
|
|
9221
|
+
async adoptSession(opts) {
|
|
9222
|
+
if (!this.syncStrategy.canAuthenticate() || !this.syncStrategy.adoptSession) {
|
|
9223
|
+
throw new Error("Session adoption not supported by current sync strategy");
|
|
9224
|
+
}
|
|
9225
|
+
const guestUsername = this._username.startsWith(GuestUsername) ? this._username : void 0;
|
|
9226
|
+
if (!guestUsername) {
|
|
9227
|
+
throw new Error(`Cannot adopt a session while logged in.
|
|
9228
|
+
Log out of account ${this.getUsername()} first.`);
|
|
9229
|
+
}
|
|
9230
|
+
const result = await this.syncStrategy.adoptSession(
|
|
9231
|
+
opts.migrateGuestData ? guestUsername : void 0
|
|
9232
|
+
);
|
|
9233
|
+
if (result.ok && result.username) {
|
|
9234
|
+
log3(`Adopted session for ${result.username}`);
|
|
9235
|
+
this._username = result.username;
|
|
9236
|
+
try {
|
|
9237
|
+
localStorage.removeItem("sk-guest-uuid");
|
|
9238
|
+
} catch (e) {
|
|
9239
|
+
logger.warn("localStorage not available (Node.js environment):", e);
|
|
9240
|
+
}
|
|
9241
|
+
await this.init();
|
|
9242
|
+
}
|
|
9243
|
+
return result;
|
|
9244
|
+
}
|
|
9203
9245
|
async resetUserData() {
|
|
9204
9246
|
if (this.syncStrategy.canAuthenticate()) {
|
|
9205
9247
|
return {
|