@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
|
@@ -1675,7 +1675,8 @@ var init_generators = __esm({
|
|
|
1675
1675
|
// src/core/navigators/generators/prescribed.ts
|
|
1676
1676
|
var prescribed_exports = {};
|
|
1677
1677
|
__export(prescribed_exports, {
|
|
1678
|
-
default: () => PrescribedCardsGenerator
|
|
1678
|
+
default: () => PrescribedCardsGenerator,
|
|
1679
|
+
unmetIntroExposeTags: () => unmetIntroExposeTags
|
|
1679
1680
|
});
|
|
1680
1681
|
function dedupe(arr) {
|
|
1681
1682
|
return [...new Set(arr)];
|
|
@@ -1715,6 +1716,19 @@ function formatAge(ms) {
|
|
|
1715
1716
|
if (hours < 24) return `${hours}h`;
|
|
1716
1717
|
return `${Math.round(hours / 24)}d`;
|
|
1717
1718
|
}
|
|
1719
|
+
function unmetIntroExposeTags(tags, userTagElo, minCount) {
|
|
1720
|
+
if (minCount <= 0) return [];
|
|
1721
|
+
const exposeTags = new Set(tags.filter((tag) => tag.startsWith("gpc:expose:")));
|
|
1722
|
+
for (const tag of tags) {
|
|
1723
|
+
if (!tag.startsWith("gpc:intro:")) continue;
|
|
1724
|
+
const suffix = tag.slice("gpc:intro:".length);
|
|
1725
|
+
if (suffix) exposeTags.add(`gpc:expose:${suffix}`);
|
|
1726
|
+
}
|
|
1727
|
+
return [...exposeTags].filter((tag) => {
|
|
1728
|
+
const tagElo = userTagElo[tag];
|
|
1729
|
+
return !tagElo || tagElo.count < minCount;
|
|
1730
|
+
});
|
|
1731
|
+
}
|
|
1718
1732
|
function pickTopByScore(cards, limit) {
|
|
1719
1733
|
return [...cards].sort((a, b) => b.score - a.score || a.cardId.localeCompare(b.cardId)).slice(0, limit);
|
|
1720
1734
|
}
|
|
@@ -2013,6 +2027,7 @@ var init_prescribed = __esm({
|
|
|
2013
2027
|
freshnessWindowSessions: typeof raw.freshnessWindowSessions === "number" ? raw.freshnessWindowSessions : DEFAULT_FRESHNESS_WINDOW,
|
|
2014
2028
|
maxDirectTargetsPerRun: typeof raw.maxDirectTargetsPerRun === "number" ? raw.maxDirectTargetsPerRun : DEFAULT_MAX_DIRECT_PER_RUN,
|
|
2015
2029
|
maxSupportCardsPerRun: typeof raw.maxSupportCardsPerRun === "number" ? raw.maxSupportCardsPerRun : DEFAULT_MAX_SUPPORT_PER_RUN,
|
|
2030
|
+
introExposeMinCount: typeof raw.introExposeMinCount === "number" ? raw.introExposeMinCount : DEFAULT_MIN_COUNT,
|
|
2016
2031
|
hierarchyWalk: {
|
|
2017
2032
|
enabled: raw.hierarchyWalk?.enabled !== false,
|
|
2018
2033
|
maxDepth: typeof raw.hierarchyWalk?.maxDepth === "number" ? raw.hierarchyWalk.maxDepth : DEFAULT_HIERARCHY_DEPTH
|
|
@@ -2088,18 +2103,11 @@ var init_prescribed = __esm({
|
|
|
2088
2103
|
group.hierarchyWalk?.enabled !== false,
|
|
2089
2104
|
group.hierarchyWalk?.maxDepth ?? DEFAULT_HIERARCHY_DEPTH
|
|
2090
2105
|
);
|
|
2091
|
-
const
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
exposeTags.add(`gpc:expose:${suffix}`);
|
|
2097
|
-
}
|
|
2098
|
-
}
|
|
2099
|
-
const unmetExposeTags = [...exposeTags].filter((tag) => {
|
|
2100
|
-
const tagElo = userTagElo[tag];
|
|
2101
|
-
return !tagElo || tagElo.count < DEFAULT_MIN_COUNT;
|
|
2102
|
-
});
|
|
2106
|
+
const unmetExposeTags = unmetIntroExposeTags(
|
|
2107
|
+
tags,
|
|
2108
|
+
userTagElo,
|
|
2109
|
+
group.introExposeMinCount ?? DEFAULT_MIN_COUNT
|
|
2110
|
+
);
|
|
2103
2111
|
if (unmetExposeTags.length > 0) {
|
|
2104
2112
|
unmetExposeTags.forEach((tag) => supportTags.add(tag));
|
|
2105
2113
|
}
|
|
@@ -7742,6 +7750,40 @@ Currently logged-in as ${this._username}.`
|
|
|
7742
7750
|
}
|
|
7743
7751
|
return loginResult;
|
|
7744
7752
|
}
|
|
7753
|
+
/**
|
|
7754
|
+
* Adopt a remote session that was established outside this client — e.g. a
|
|
7755
|
+
* backend verified a third-party sign-in (Google) and set the session cookie
|
|
7756
|
+
* on its response. Afterwards the user is logged in exactly as after
|
|
7757
|
+
* login(): username switched, guest pointer cleared, init() re-run.
|
|
7758
|
+
*
|
|
7759
|
+
* @param opts.migrateGuestData Carry the current guest account's local data
|
|
7760
|
+
* into the adopted account. Pass true for a freshly created account (as
|
|
7761
|
+
* createAccount() does), false for an existing one (as login() does).
|
|
7762
|
+
*/
|
|
7763
|
+
async adoptSession(opts) {
|
|
7764
|
+
if (!this.syncStrategy.canAuthenticate() || !this.syncStrategy.adoptSession) {
|
|
7765
|
+
throw new Error("Session adoption not supported by current sync strategy");
|
|
7766
|
+
}
|
|
7767
|
+
const guestUsername = this._username.startsWith(GuestUsername) ? this._username : void 0;
|
|
7768
|
+
if (!guestUsername) {
|
|
7769
|
+
throw new Error(`Cannot adopt a session while logged in.
|
|
7770
|
+
Log out of account ${this.getUsername()} first.`);
|
|
7771
|
+
}
|
|
7772
|
+
const result = await this.syncStrategy.adoptSession(
|
|
7773
|
+
opts.migrateGuestData ? guestUsername : void 0
|
|
7774
|
+
);
|
|
7775
|
+
if (result.ok && result.username) {
|
|
7776
|
+
log3(`Adopted session for ${result.username}`);
|
|
7777
|
+
this._username = result.username;
|
|
7778
|
+
try {
|
|
7779
|
+
localStorage.removeItem("sk-guest-uuid");
|
|
7780
|
+
} catch (e) {
|
|
7781
|
+
logger.warn("localStorage not available (Node.js environment):", e);
|
|
7782
|
+
}
|
|
7783
|
+
await this.init();
|
|
7784
|
+
}
|
|
7785
|
+
return result;
|
|
7786
|
+
}
|
|
7745
7787
|
async resetUserData() {
|
|
7746
7788
|
if (this.syncStrategy.canAuthenticate()) {
|
|
7747
7789
|
return {
|