@howaboua/opencode-usage-plugin 0.1.4-dev.1 → 0.1.4-dev.2
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/usage/fetch.d.ts.map +1 -1
- package/dist/usage/fetch.js +4 -3
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../src/usage/fetch.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAQ7C,wBAAsB,mBAAmB,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../src/usage/fetch.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAQ7C,wBAAsB,mBAAmB,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CA2CnF;AAWD,wBAAgB,qBAAqB,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAEzE;AA6BD,wBAAsB,SAAS,gDAG9B"}
|
package/dist/usage/fetch.js
CHANGED
|
@@ -18,14 +18,14 @@ export async function fetchUsageSnapshots(filter) {
|
|
|
18
18
|
};
|
|
19
19
|
const { auths, codexDiagnostics } = await loadMergedAuths();
|
|
20
20
|
const entries = resolveProviderAuths(auths, null);
|
|
21
|
-
const
|
|
21
|
+
const snapshotsMap = new Map();
|
|
22
22
|
const fetched = new Set();
|
|
23
23
|
const fetches = entries
|
|
24
24
|
.filter(e => (!target || e.providerID === target) && isEnabled(e.providerID))
|
|
25
25
|
.map(async (e) => {
|
|
26
26
|
const snap = await providers[e.providerID]?.fetchUsage?.(e.auth).catch(() => null);
|
|
27
27
|
if (snap) {
|
|
28
|
-
|
|
28
|
+
snapshotsMap.set(e.providerID, snap);
|
|
29
29
|
fetched.add(e.providerID);
|
|
30
30
|
}
|
|
31
31
|
});
|
|
@@ -36,7 +36,7 @@ export async function fetchUsageSnapshots(filter) {
|
|
|
36
36
|
if (provider?.fetchUsage) {
|
|
37
37
|
fetches.push(provider.fetchUsage(undefined).then(s => {
|
|
38
38
|
if (s) {
|
|
39
|
-
|
|
39
|
+
snapshotsMap.set(id, s);
|
|
40
40
|
fetched.add(id);
|
|
41
41
|
}
|
|
42
42
|
}).catch(() => { }));
|
|
@@ -44,6 +44,7 @@ export async function fetchUsageSnapshots(filter) {
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
await Promise.race([Promise.all(fetches), new Promise(r => setTimeout(r, 5000))]);
|
|
47
|
+
const snapshots = Array.from(snapshotsMap.values());
|
|
47
48
|
return appendMissingStates(snapshots, fetched, isEnabled, target, codexDiagnostics);
|
|
48
49
|
}
|
|
49
50
|
function resolveFilter(f) {
|
package/package.json
CHANGED