@claudinho/core 0.8.7 → 0.8.8

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
@@ -651,6 +651,26 @@ interface NextFixtureResult {
651
651
  * inventing one — advancement is never read from the static skeleton.
652
652
  */
653
653
  declare function getNextFixtureForTeam(adapter: ProviderAdapter, code: string, now?: Date): Promise<NextFixtureResult>;
654
+ interface KnockoutFixturesResult {
655
+ /** Resolved (both nations known) upcoming knockout fixtures, sorted by kickoff. */
656
+ fixtures: Match[];
657
+ /** True when the overlay fetch failed — caller must NOT cache this as "none". */
658
+ degraded: boolean;
659
+ }
660
+ /**
661
+ * The RESOLVED upcoming knockout fixtures from the live overlay — the data the
662
+ * hot-path statusline can't fetch itself but needs to show a real next-match
663
+ * countdown (e.g. "🇲🇽 vs 🇪🇨 in 2d") instead of a 🏳️ placeholder. The cold-path
664
+ * refresher calls this and caches the result; the statusline reads the cache.
665
+ *
666
+ * Returns only fixtures where BOTH nations are resolved (flag ≠ 🏳️) and kickoff
667
+ * ≥ now, so a slot ESPN hasn't filled yet is simply absent (the statusline then
668
+ * fails closed to "⚽ —", never a placeholder). **Fails closed with
669
+ * `degraded: true` on a provider error** — the caller must keep its prior cached
670
+ * fixtures rather than cache an empty list as a real "no knockouts" (a transient
671
+ * outage must never read as "your team is out").
672
+ */
673
+ declare function getKnockoutFixtures(adapter: ProviderAdapter, now?: Date): Promise<KnockoutFixturesResult>;
654
674
  /**
655
675
  * A single match by id, with live overlay. The provider's scoreboard buckets
656
676
  * days in its own zone (ESPN: US/Eastern), so a fixture's UTC date can differ
@@ -1083,6 +1103,9 @@ declare function parseTeamSlot(team: Team): SlotRef | null;
1083
1103
  */
1084
1104
  declare function buildBracketView(topology: BracketTopology, matches: Match[], tables: GroupStandings[], standingsDegraded: boolean, liveDegraded: boolean, filterStage?: string, lang?: string): BracketView;
1085
1105
 
1106
+ /** True when a team carries a real nation flag (not a bracket placeholder). */
1107
+ declare function isResolvedNation(team: Team): boolean;
1108
+
1086
1109
  /** The bundled knockout bracket topology (generated by gen:schedule). */
1087
1110
  declare function loadBracketTopology(): BracketTopology;
1088
1111
 
@@ -1124,4 +1147,4 @@ declare function formatShareBracket(input: ShareBracketInput, options?: ShareBra
1124
1147
  /** Compact one-line-per-match bracket for narrow share contexts. */
1125
1148
  declare function formatBracketCompactLine(mv: BracketMatchView, opts?: BracketFormatOpts): string;
1126
1149
 
1127
- export { BRACKET_STAGE_ORDER, type BracketFormatOpts, type BracketMatchNode, type BracketMatchView, type BracketResult, type BracketTopology, type BracketView, type BuildSignalInput, DEFAULT_COMPETITION, DEFAULT_FLAVOR, DEFAULT_MAX_AGE_MS, EspnAdapter, type EspnAdapterOptions, FLAVOR_LEVELS, FakeMarketProvider, type FakeMarketProviderOptions, type FavoriteStrength, type FlavorLevel, type FormatOpts, type GroupStandings, LIVE_WINDOW_MS, type Lang, type LedgerRow, type LiveResult, type MapContext, type MarketFavorite, type MarketMapping, type MarketMappingTable, type MarketOutcome, type MarketOutcomeKind, type MarketProvider, type MarketSignal, type MarketSignalOptions, type MarketSignalsResult, type Match, type MatchByIdResult, type MatchEvent, type NextFixtureResult, type Outcome, PolymarketProvider, type PolymarketProviderOptions, type ProviderAdapter, type ProviderCapabilities, type PunditPick, type ResolvedParticipant, SHARE_DISCLAIMER, SHARE_HASHTAG, type ShareBracketInput, type ShareBracketOptions, type ShareSnippetInput, type ShareSnippetOptions, type ShareStyle, type ShareTableInput, type SlotRef, type Stage, type StandingRow, type StandingsResult, type Status, type Team, allFixtures, asFlavorLevel, buildBracketTopology, buildBracketView, buildMarketSignal, byKickoff, competitionBase, computeStandings, countdown, currentOrNextFixtureForTeam, deriveFavorite, favoriteStrength, fixturesByDate, fixturesByGroup, fixturesByTeam, fixturesInLiveWindow, flagEmoji, formatBracketCompactLine, formatBracketList, formatBracketMatchLine, formatBracketTree, formatDate, formatKickoff, formatShareBracket, formatShareSnippet, formatShareTable, formatTime, getBracket, getLiveMatches, getMarketSignal, getMarketSignals, getMatchById, getMatchesForDate, getNextFixtureForTeam, getStandings, groups, hasSaneDistribution, isFinished, isFlavorLevel, isLive, isReliableMarketSignal, isStaleSignal, isValidDate, isValidTimeZone, liveSourceLabel, loadBracketTopology, localDate, makeAdapter, makeMarketProvider, mapEspnEvent, mapsCleanly, marketAttributionText, marketBlock, marketFavoriteText, marketFixtureForTeam, marketLine, marketProbabilityText, marketRelevant, marketSourceLabel, matchFlavor, matchKey, matchLocation, mergeLive, nationToFlag, nationToRegion, nextFixtureForTeam, normalizeLang, normalizeOutcomes, outcomeFromScore, parseStandings, parseTeamSlot, resolveCompetition, resolveMarketSource, resolveTz, sanitizeBundledFixture, scoreline, stageLabel, stageLabelI18n, t };
1150
+ export { BRACKET_STAGE_ORDER, type BracketFormatOpts, type BracketMatchNode, type BracketMatchView, type BracketResult, type BracketTopology, type BracketView, type BuildSignalInput, DEFAULT_COMPETITION, DEFAULT_FLAVOR, DEFAULT_MAX_AGE_MS, EspnAdapter, type EspnAdapterOptions, FLAVOR_LEVELS, FakeMarketProvider, type FakeMarketProviderOptions, type FavoriteStrength, type FlavorLevel, type FormatOpts, type GroupStandings, type KnockoutFixturesResult, LIVE_WINDOW_MS, type Lang, type LedgerRow, type LiveResult, type MapContext, type MarketFavorite, type MarketMapping, type MarketMappingTable, type MarketOutcome, type MarketOutcomeKind, type MarketProvider, type MarketSignal, type MarketSignalOptions, type MarketSignalsResult, type Match, type MatchByIdResult, type MatchEvent, type NextFixtureResult, type Outcome, PolymarketProvider, type PolymarketProviderOptions, type ProviderAdapter, type ProviderCapabilities, type PunditPick, type ResolvedParticipant, SHARE_DISCLAIMER, SHARE_HASHTAG, type ShareBracketInput, type ShareBracketOptions, type ShareSnippetInput, type ShareSnippetOptions, type ShareStyle, type ShareTableInput, type SlotRef, type Stage, type StandingRow, type StandingsResult, type Status, type Team, allFixtures, asFlavorLevel, buildBracketTopology, buildBracketView, buildMarketSignal, byKickoff, competitionBase, computeStandings, countdown, currentOrNextFixtureForTeam, deriveFavorite, favoriteStrength, fixturesByDate, fixturesByGroup, fixturesByTeam, fixturesInLiveWindow, flagEmoji, formatBracketCompactLine, formatBracketList, formatBracketMatchLine, formatBracketTree, formatDate, formatKickoff, formatShareBracket, formatShareSnippet, formatShareTable, formatTime, getBracket, getKnockoutFixtures, getLiveMatches, getMarketSignal, getMarketSignals, getMatchById, getMatchesForDate, getNextFixtureForTeam, getStandings, groups, hasSaneDistribution, isFinished, isFlavorLevel, isLive, isReliableMarketSignal, isResolvedNation, isStaleSignal, isValidDate, isValidTimeZone, liveSourceLabel, loadBracketTopology, localDate, makeAdapter, makeMarketProvider, mapEspnEvent, mapsCleanly, marketAttributionText, marketBlock, marketFavoriteText, marketFixtureForTeam, marketLine, marketProbabilityText, marketRelevant, marketSourceLabel, matchFlavor, matchKey, matchLocation, mergeLive, nationToFlag, nationToRegion, nextFixtureForTeam, normalizeLang, normalizeOutcomes, outcomeFromScore, parseStandings, parseTeamSlot, resolveCompetition, resolveMarketSource, resolveTz, sanitizeBundledFixture, scoreline, stageLabel, stageLabelI18n, t };
package/dist/index.js CHANGED
@@ -4168,6 +4168,20 @@ async function getNextFixtureForTeam(adapter, code, now = /* @__PURE__ */ new Da
4168
4168
  const source = fixture && liveById?.has(fixture.id) ? adapter.name : void 0;
4169
4169
  return { fixture, degraded, source };
4170
4170
  }
4171
+ async function getKnockoutFixtures(adapter, now = /* @__PURE__ */ new Date()) {
4172
+ if (!adapter.fetchWindow) return { fixtures: [], degraded: true };
4173
+ let live;
4174
+ try {
4175
+ live = await adapter.fetchWindow(KNOCKOUT_WINDOW_START, KNOCKOUT_WINDOW_END);
4176
+ } catch {
4177
+ return { fixtures: [], degraded: true };
4178
+ }
4179
+ const nowMs = now.getTime();
4180
+ const fixtures = live.filter(
4181
+ (m) => m.stage !== "GROUP" && m.stage !== "FRIENDLY" && Date.parse(m.kickoff) >= nowMs && isResolvedNation(m.home) && isResolvedNation(m.away)
4182
+ ).sort(byKickoff);
4183
+ return { fixtures, degraded: false };
4184
+ }
4171
4185
  async function getMatchById(adapter, id) {
4172
4186
  const base = allFixtures().find((m) => m.id === id);
4173
4187
  if (!base) return { match: void 0, degraded: false };
@@ -4925,6 +4939,7 @@ export {
4925
4939
  formatShareTable,
4926
4940
  formatTime,
4927
4941
  getBracket,
4942
+ getKnockoutFixtures,
4928
4943
  getLiveMatches,
4929
4944
  getMarketSignal,
4930
4945
  getMarketSignals,
@@ -4938,6 +4953,7 @@ export {
4938
4953
  isFlavorLevel,
4939
4954
  isLive,
4940
4955
  isReliableMarketSignal,
4956
+ isResolvedNation,
4941
4957
  isStaleSignal,
4942
4958
  isValidDate,
4943
4959
  isValidTimeZone,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@claudinho/core",
3
- "version": "0.8.7",
3
+ "version": "0.8.8",
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",