@vue-skuilder/db 0.2.26 → 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/core/index.js +21 -13
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.mjs +21 -13
- package/dist/core/index.mjs.map +1 -1
- package/dist/impl/couch/index.js +21 -13
- package/dist/impl/couch/index.js.map +1 -1
- package/dist/impl/couch/index.mjs +21 -13
- package/dist/impl/couch/index.mjs.map +1 -1
- package/dist/impl/static/index.js +21 -13
- package/dist/impl/static/index.js.map +1 -1
- package/dist/impl/static/index.mjs +21 -13
- package/dist/impl/static/index.mjs.map +1 -1
- package/dist/index.js +21 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +21 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/core/navigators/generators/prescribed.ts +43 -14
- package/tests/core/navigators/prescribedIntroExposure.test.ts +29 -0
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.2.
|
|
7
|
+
"version": "0.2.27",
|
|
8
8
|
"description": "Database layer for vue-skuilder",
|
|
9
9
|
"main": "dist/index.js",
|
|
10
10
|
"module": "dist/index.mjs",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"@nilock2/pouchdb-authentication": "^1.0.2",
|
|
51
|
-
"@vue-skuilder/common": "0.2.
|
|
51
|
+
"@vue-skuilder/common": "0.2.27",
|
|
52
52
|
"cross-fetch": "^4.1.0",
|
|
53
53
|
"moment": "^2.29.4",
|
|
54
54
|
"pouchdb": "^9.0.0",
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"vite": "^8.0.0",
|
|
64
64
|
"vitest": "^4.1.0"
|
|
65
65
|
},
|
|
66
|
-
"stableVersion": "0.2.
|
|
66
|
+
"stableVersion": "0.2.27"
|
|
67
67
|
}
|
|
@@ -48,6 +48,16 @@ interface PrescribedGroupConfig {
|
|
|
48
48
|
maxDirectTargetsPerRun?: number;
|
|
49
49
|
maxSupportCardsPerRun?: number;
|
|
50
50
|
hierarchyWalk?: HierarchyWalkConfig;
|
|
51
|
+
/**
|
|
52
|
+
* Exposure an intro target needs before it may surface. Each target is held
|
|
53
|
+
* back — and cards bearing its missing exposure tags are emitted as support —
|
|
54
|
+
* until every exposure tag it implies (its own `gpc:expose:*` tags, plus
|
|
55
|
+
* `gpc:expose:X` for each `gpc:intro:X`) reaches this count. Default 3: a
|
|
56
|
+
* letter is met incidentally inside other words before it is introduced.
|
|
57
|
+
* Set 0 for targets that must be introduced *before* any exposure — e.g.
|
|
58
|
+
* irregular words, which only ever appear in their own cards.
|
|
59
|
+
*/
|
|
60
|
+
introExposeMinCount?: number;
|
|
51
61
|
retireOnEncounter?: boolean;
|
|
52
62
|
/**
|
|
53
63
|
* Tag patterns identifying *practice* skills to drill once unlocked. For each
|
|
@@ -222,6 +232,32 @@ function formatAge(ms: number): string {
|
|
|
222
232
|
return `${Math.round(hours / 24)}d`;
|
|
223
233
|
}
|
|
224
234
|
|
|
235
|
+
/**
|
|
236
|
+
* The exposure tags an intro target still lacks before it may surface: its own
|
|
237
|
+
* `gpc:expose:*` tags plus `gpc:expose:X` for each `gpc:intro:X`, each needing
|
|
238
|
+
* `minCount` attempts. A `minCount` of 0 requires nothing — not even an entry
|
|
239
|
+
* in `userTagElo`.
|
|
240
|
+
*/
|
|
241
|
+
export function unmetIntroExposeTags(
|
|
242
|
+
tags: string[],
|
|
243
|
+
userTagElo: Record<string, { count: number }>,
|
|
244
|
+
minCount: number
|
|
245
|
+
): string[] {
|
|
246
|
+
if (minCount <= 0) return [];
|
|
247
|
+
|
|
248
|
+
const exposeTags = new Set(tags.filter((tag) => tag.startsWith('gpc:expose:')));
|
|
249
|
+
for (const tag of tags) {
|
|
250
|
+
if (!tag.startsWith('gpc:intro:')) continue;
|
|
251
|
+
const suffix = tag.slice('gpc:intro:'.length);
|
|
252
|
+
if (suffix) exposeTags.add(`gpc:expose:${suffix}`);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
return [...exposeTags].filter((tag) => {
|
|
256
|
+
const tagElo = userTagElo[tag];
|
|
257
|
+
return !tagElo || tagElo.count < minCount;
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
|
|
225
261
|
function pickTopByScore(cards: WeightedCard[], limit: number): WeightedCard[] {
|
|
226
262
|
return [...cards]
|
|
227
263
|
.sort((a, b) => b.score - a.score || a.cardId.localeCompare(b.cardId))
|
|
@@ -609,6 +645,8 @@ export default class PrescribedCardsGenerator extends ContentNavigator implement
|
|
|
609
645
|
typeof raw.maxDirectTargetsPerRun === 'number' ? raw.maxDirectTargetsPerRun : DEFAULT_MAX_DIRECT_PER_RUN,
|
|
610
646
|
maxSupportCardsPerRun:
|
|
611
647
|
typeof raw.maxSupportCardsPerRun === 'number' ? raw.maxSupportCardsPerRun : DEFAULT_MAX_SUPPORT_PER_RUN,
|
|
648
|
+
introExposeMinCount:
|
|
649
|
+
typeof raw.introExposeMinCount === 'number' ? raw.introExposeMinCount : DEFAULT_MIN_COUNT,
|
|
612
650
|
hierarchyWalk: {
|
|
613
651
|
enabled: raw.hierarchyWalk?.enabled !== false,
|
|
614
652
|
maxDepth:
|
|
@@ -715,20 +753,11 @@ export default class PrescribedCardsGenerator extends ContentNavigator implement
|
|
|
715
753
|
group.hierarchyWalk?.maxDepth ?? DEFAULT_HIERARCHY_DEPTH
|
|
716
754
|
);
|
|
717
755
|
|
|
718
|
-
const
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
if (suffix) {
|
|
724
|
-
exposeTags.add(`gpc:expose:${suffix}`);
|
|
725
|
-
}
|
|
726
|
-
}
|
|
727
|
-
|
|
728
|
-
const unmetExposeTags = [...exposeTags].filter((tag) => {
|
|
729
|
-
const tagElo = userTagElo[tag];
|
|
730
|
-
return !tagElo || tagElo.count < DEFAULT_MIN_COUNT;
|
|
731
|
-
});
|
|
756
|
+
const unmetExposeTags = unmetIntroExposeTags(
|
|
757
|
+
tags,
|
|
758
|
+
userTagElo,
|
|
759
|
+
group.introExposeMinCount ?? DEFAULT_MIN_COUNT
|
|
760
|
+
);
|
|
732
761
|
|
|
733
762
|
if (unmetExposeTags.length > 0) {
|
|
734
763
|
unmetExposeTags.forEach((tag) => supportTags.add(tag));
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { unmetIntroExposeTags } from '../../../src/core/navigators/generators/prescribed';
|
|
3
|
+
|
|
4
|
+
describe('unmetIntroExposeTags', () => {
|
|
5
|
+
it('implies gpc:expose:X from gpc:intro:X and requires minCount of it', () => {
|
|
6
|
+
const tags = ['gpc:intro:v-V', 'concept:match:simple'];
|
|
7
|
+
expect(unmetIntroExposeTags(tags, {}, 3)).toEqual(['gpc:expose:v-V']);
|
|
8
|
+
expect(unmetIntroExposeTags(tags, { 'gpc:expose:v-V': { count: 2 } }, 3)).toEqual([
|
|
9
|
+
'gpc:expose:v-V',
|
|
10
|
+
]);
|
|
11
|
+
expect(unmetIntroExposeTags(tags, { 'gpc:expose:v-V': { count: 3 } }, 3)).toEqual([]);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it("counts the card's own gpc:expose:* tags once alongside the implied one", () => {
|
|
15
|
+
const tags = ['gpc:intro:v-V', 'gpc:expose:v-V', 'gpc:expose:a-AE'];
|
|
16
|
+
expect(unmetIntroExposeTags(tags, { 'gpc:expose:a-AE': { count: 5 } }, 3)).toEqual([
|
|
17
|
+
'gpc:expose:v-V',
|
|
18
|
+
]);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('minCount 0 requires nothing, even with no exposure entry at all', () => {
|
|
22
|
+
const tags = ['gpc:intro:WORD-was', 'concept:match:whole_word'];
|
|
23
|
+
expect(unmetIntroExposeTags(tags, {}, 0)).toEqual([]);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('non-intro targets with no expose tags need nothing', () => {
|
|
27
|
+
expect(unmetIntroExposeTags(['gpc:exercise:t-T'], {}, 3)).toEqual([]);
|
|
28
|
+
});
|
|
29
|
+
});
|