@claudinho/core 0.5.1 → 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 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
- /** Currently-live matches; empty + degraded on error. */
529
- declare function getLiveMatches(adapter: ProviderAdapter): Promise<LiveResult>;
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
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 === "LIVE" || m.status === "HT");
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
- return { matches: await adapter.fetchLive(), degraded: false, source: adapter.name };
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@claudinho/core",
3
- "version": "0.5.1",
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",