fifa-wc26 0.2.1 → 0.2.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/cli.js +9 -6
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1000,18 +1000,19 @@ async function buildRegistry(opts) {
|
|
|
1000
1000
|
}
|
|
1001
1001
|
return new ProviderRegistry(providers);
|
|
1002
1002
|
}
|
|
1003
|
-
async function runCached(key, ttlSec, fetcher, opts) {
|
|
1003
|
+
async function runCached(key, ttlSec, fetcher, opts, cacheOpts = {}) {
|
|
1004
|
+
const validate = cacheOpts.validate ?? (() => true);
|
|
1004
1005
|
if (!opts.noCache) {
|
|
1005
1006
|
const hit = await env.cache.read(key, { allowStale: false });
|
|
1006
|
-
if (hit) return { data: hit.data, stale: false };
|
|
1007
|
+
if (hit && validate(hit.data)) return { data: hit.data, stale: false };
|
|
1007
1008
|
}
|
|
1008
1009
|
try {
|
|
1009
1010
|
const { data, provider } = await fetcher();
|
|
1010
|
-
await env.cache.write(key, data, ttlSec, provider);
|
|
1011
|
+
if (validate(data)) await env.cache.write(key, data, ttlSec, provider);
|
|
1011
1012
|
return { data, stale: false };
|
|
1012
1013
|
} catch (e) {
|
|
1013
1014
|
const stale = await env.cache.read(key, { allowStale: true });
|
|
1014
|
-
if (stale) {
|
|
1015
|
+
if (stale && validate(stale.data)) {
|
|
1015
1016
|
const reason = e instanceof WC26Error ? e.code.toLowerCase() : "unreachable";
|
|
1016
1017
|
return { data: stale.data, stale: true, reason };
|
|
1017
1018
|
}
|
|
@@ -1176,7 +1177,8 @@ function fixturesCmd(p) {
|
|
|
1176
1177
|
});
|
|
1177
1178
|
return { data: data2, provider };
|
|
1178
1179
|
},
|
|
1179
|
-
g
|
|
1180
|
+
g,
|
|
1181
|
+
{ validate: (d) => g.team || g.from || g.to || g.stage ? d.length > 0 : d.length >= 50 }
|
|
1180
1182
|
);
|
|
1181
1183
|
const filtered = data.filter(
|
|
1182
1184
|
(f) => (!q.stage || f.stage === q.stage) && (!q.teamCode || f.home.code === q.teamCode || f.away.code === q.teamCode)
|
|
@@ -1214,7 +1216,8 @@ function nextCmd(p) {
|
|
|
1214
1216
|
});
|
|
1215
1217
|
return { data: data2, provider };
|
|
1216
1218
|
},
|
|
1217
|
-
g
|
|
1219
|
+
g,
|
|
1220
|
+
{ validate: (d) => g.team ? d.length > 0 : d.length >= 50 }
|
|
1218
1221
|
);
|
|
1219
1222
|
const now = Date.now();
|
|
1220
1223
|
const out = data.filter((f) => f.status === "scheduled" && new Date(f.utcKickoff).getTime() > now).sort((a, b) => a.utcKickoff.localeCompare(b.utcKickoff)).slice(0, n);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fifa-wc26",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "FIFA World Cup 2026 CLI: fixtures, live scores, group standings, ASCII bracket, team lookup. Keyless providers, smart cache, terminal-friendly output.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|