@claudinho/core 0.5.0 → 0.5.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/index.d.ts +28 -2
- package/dist/index.js +16 -3
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -424,6 +424,12 @@ declare class EspnAdapter implements ProviderAdapter {
|
|
|
424
424
|
constructor(opts?: EspnAdapterOptions);
|
|
425
425
|
fetchByDate(dateISO: string): Promise<Match[]>;
|
|
426
426
|
fetchWindow(startDate: string, endDate: string): Promise<Match[]>;
|
|
427
|
+
/**
|
|
428
|
+
* In-play matches from ESPN's DEFAULT scoreboard bucket only (no `dates`). This
|
|
429
|
+
* single bucket misses a late kickoff ESPN files under an adjacent day, so it
|
|
430
|
+
* is a fallback for window-less callers — the domain `getLiveMatches` wraps a
|
|
431
|
+
* ±1-day window around this to catch boundary-crossing matches. Prefer it.
|
|
432
|
+
*/
|
|
427
433
|
fetchLive(): Promise<Match[]>;
|
|
428
434
|
/** Standings endpoint URL (lives under apis/v2, not site/v2; derived from base). */
|
|
429
435
|
private standingsUrl;
|
|
@@ -525,8 +531,20 @@ declare function marketFixtureForTeam(adapter: ProviderAdapter, code: string, no
|
|
|
525
531
|
* provider error.
|
|
526
532
|
*/
|
|
527
533
|
declare function getMatchById(adapter: ProviderAdapter, id: string): Promise<MatchByIdResult>;
|
|
528
|
-
/**
|
|
529
|
-
|
|
534
|
+
/**
|
|
535
|
+
* Currently-live matches; empty + degraded on error.
|
|
536
|
+
*
|
|
537
|
+
* The provider buckets its scoreboard by its own day (ESPN: US/Eastern), so a
|
|
538
|
+
* late kickoff that crossed the day boundary lands in an ADJACENT bucket — a
|
|
539
|
+
* 04:00Z match still live at 76' while the provider's default "today" bucket
|
|
540
|
+
* already shows the prior, all-FT day. A bare `adapter.fetchLive()` reads only
|
|
541
|
+
* that single default bucket, so it silently MISSES such a match and `live` /
|
|
542
|
+
* the statusline / the hook show "nothing live" mid-match. Fetch the ±1-day UTC
|
|
543
|
+
* window around `now` instead — the same trick {@link getMatchesForDate} and
|
|
544
|
+
* {@link getMatchById} use — and filter to in-play, so no live match can hide in
|
|
545
|
+
* an adjacent bucket. Adapters without a window fetch fall back to `fetchLive()`.
|
|
546
|
+
*/
|
|
547
|
+
declare function getLiveMatches(adapter: ProviderAdapter, now?: Date): Promise<LiveResult>;
|
|
530
548
|
|
|
531
549
|
/**
|
|
532
550
|
* Prediction-market "signal" model — a *sidecar* to Match, deliberately never
|
|
@@ -866,6 +884,14 @@ interface ShareSnippetInput {
|
|
|
866
884
|
emptyNote?: string;
|
|
867
885
|
/** Exact run cue to advertise, e.g. "npx @claudinho/cli next MEX". */
|
|
868
886
|
installLine?: string;
|
|
887
|
+
/**
|
|
888
|
+
* True when the live fetch failed and these are static fixtures (no live
|
|
889
|
+
* scores). A pasted card must say so — otherwise a "no matches" / scheduled
|
|
890
|
+
* card reads as authoritative when the feed is actually down. When set with
|
|
891
|
+
* matches present, a not-live notice is appended; for the empty case the
|
|
892
|
+
* caller picks a feed-down `emptyNote`.
|
|
893
|
+
*/
|
|
894
|
+
degraded?: boolean;
|
|
869
895
|
/** Timezone for kickoff date/time (date/time only — copy stays English). */
|
|
870
896
|
tz?: string;
|
|
871
897
|
/** Locale for kickoff date/time. */
|
package/dist/index.js
CHANGED
|
@@ -2839,9 +2839,15 @@ var EspnAdapter = class {
|
|
|
2839
2839
|
async fetchWindow(startDate, endDate) {
|
|
2840
2840
|
return this.fetchScoreboard(`${toEspnDate(startDate)}-${toEspnDate(endDate)}`);
|
|
2841
2841
|
}
|
|
2842
|
+
/**
|
|
2843
|
+
* In-play matches from ESPN's DEFAULT scoreboard bucket only (no `dates`). This
|
|
2844
|
+
* single bucket misses a late kickoff ESPN files under an adjacent day, so it
|
|
2845
|
+
* is a fallback for window-less callers — the domain `getLiveMatches` wraps a
|
|
2846
|
+
* ±1-day window around this to catch boundary-crossing matches. Prefer it.
|
|
2847
|
+
*/
|
|
2842
2848
|
async fetchLive() {
|
|
2843
2849
|
const today = await this.fetchScoreboard();
|
|
2844
|
-
return today.filter((m) => m.status
|
|
2850
|
+
return today.filter((m) => isLive(m.status));
|
|
2845
2851
|
}
|
|
2846
2852
|
/** Standings endpoint URL (lives under apis/v2, not site/v2; derived from base). */
|
|
2847
2853
|
standingsUrl() {
|
|
@@ -2986,9 +2992,13 @@ async function getMatchById(adapter, id) {
|
|
|
2986
2992
|
return { match: base, degraded: true };
|
|
2987
2993
|
}
|
|
2988
2994
|
}
|
|
2989
|
-
async function getLiveMatches(adapter) {
|
|
2995
|
+
async function getLiveMatches(adapter, now = /* @__PURE__ */ new Date()) {
|
|
2990
2996
|
try {
|
|
2991
|
-
|
|
2997
|
+
const day = now.toISOString().slice(0, 10);
|
|
2998
|
+
const matches = adapter.fetchWindow ? (await adapter.fetchWindow(shiftUtcDate(day, -1), shiftUtcDate(day, 1))).filter(
|
|
2999
|
+
(m) => isLive(m.status)
|
|
3000
|
+
) : await adapter.fetchLive();
|
|
3001
|
+
return { matches, degraded: false, source: adapter.name };
|
|
2992
3002
|
} catch {
|
|
2993
3003
|
return { matches: [], degraded: true };
|
|
2994
3004
|
}
|
|
@@ -3508,6 +3518,9 @@ function formatShareSnippet(input, options = {}) {
|
|
|
3508
3518
|
blocks.push(card.join("\n"));
|
|
3509
3519
|
}
|
|
3510
3520
|
}
|
|
3521
|
+
if (input.degraded && input.matches.length > 0) {
|
|
3522
|
+
blocks.push("(Live data unavailable \u2014 showing the bundled schedule, not live scores.)");
|
|
3523
|
+
}
|
|
3511
3524
|
blocks.push(
|
|
3512
3525
|
shareFooter({
|
|
3513
3526
|
source: input.source,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@claudinho/core",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"description": "Domain model, provider adapters (ESPN), standings, bundled schedule, and the read-only Polymarket market-signal sidecar powering Claudinho. Not affiliated with FIFA or Anthropic.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|