@thedevdavid/sage 0.1.5 → 0.1.7
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/package.json +1 -1
- package/src/subscriptions/index.js +28 -1
package/package.json
CHANGED
|
@@ -24,6 +24,33 @@ export function windowRank(label) {
|
|
|
24
24
|
return 2;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
// The Claude usage API reports its primary buckets twice — as five_hour /
|
|
28
|
+
// seven_day and again in a limits list under raw kinds (session, weekly_all) —
|
|
29
|
+
// and older app versions wrote those aliases into the shared cache. Collapse
|
|
30
|
+
// the aliases so each limit displays once, whatever the source.
|
|
31
|
+
const BUCKET_ALIASES = new Map([
|
|
32
|
+
['session', 'session'],
|
|
33
|
+
['five_hour', 'session'],
|
|
34
|
+
['session (5h)', 'session'],
|
|
35
|
+
['weekly', 'weekly'],
|
|
36
|
+
['weekly_all', 'weekly'],
|
|
37
|
+
['seven_day', 'weekly'],
|
|
38
|
+
['weekly (all models)', 'weekly'],
|
|
39
|
+
]);
|
|
40
|
+
|
|
41
|
+
function bucketKey(label) {
|
|
42
|
+
const l = String(label).toLowerCase();
|
|
43
|
+
return BUCKET_ALIASES.get(l) ?? l;
|
|
44
|
+
}
|
|
45
|
+
|
|
27
46
|
export function sortWindows(windows) {
|
|
28
|
-
|
|
47
|
+
const seen = new Set();
|
|
48
|
+
return [...(windows ?? [])]
|
|
49
|
+
.filter((w) => {
|
|
50
|
+
const key = `${w?.category ?? ''}:${bucketKey(w?.label)}`;
|
|
51
|
+
if (seen.has(key)) return false;
|
|
52
|
+
seen.add(key);
|
|
53
|
+
return true;
|
|
54
|
+
})
|
|
55
|
+
.sort((a, b) => windowRank(a.label) - windowRank(b.label));
|
|
29
56
|
}
|