@claudinho/core 0.8.5 → 0.8.7
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 +26 -1
- package/dist/index.js +32 -5
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -626,6 +626,31 @@ interface MatchByIdResult {
|
|
|
626
626
|
* nothing rather than something wrong).
|
|
627
627
|
*/
|
|
628
628
|
declare function marketFixtureForTeam(adapter: ProviderAdapter, code: string, now?: Date): Promise<MatchByIdResult>;
|
|
629
|
+
interface NextFixtureResult {
|
|
630
|
+
fixture?: Match;
|
|
631
|
+
/** True when the live overlay fetch failed and only the static skeleton was used. */
|
|
632
|
+
degraded: boolean;
|
|
633
|
+
/** The provider that served the live overlay (absent when degraded). */
|
|
634
|
+
source?: string;
|
|
635
|
+
}
|
|
636
|
+
/**
|
|
637
|
+
* A team's next UPCOMING fixture, LIVE-RESOLVED across the knockout phase.
|
|
638
|
+
*
|
|
639
|
+
* The bundled schedule's knockout slots are resultless placeholders (home/away
|
|
640
|
+
* are slot refs like "Group A winner", never a nation — see
|
|
641
|
+
* {@link sanitizeBundledFixture}), so a purely static lookup goes blind the
|
|
642
|
+
* moment a team's last GROUP game passes: `next MEX` answers "no upcoming
|
|
643
|
+
* fixture" even after ESPN has confirmed Mexico's Round-of-32 tie. Overlay the
|
|
644
|
+
* live knockout window (the SAME single fetch {@link getBracket} uses) so the
|
|
645
|
+
* merged set carries the resolved nations, then pick the team's next fixture
|
|
646
|
+
* with kickoff ≥ now. (Strictly upcoming — the in-play match is `getLiveMatches`'
|
|
647
|
+
* job, preserving the pre-overlay `next` semantics.)
|
|
648
|
+
*
|
|
649
|
+
* Fails closed: on any provider error it falls back to the static result
|
|
650
|
+
* (`degraded: true`), so a feed outage degrades to "no fixture" rather than
|
|
651
|
+
* inventing one — advancement is never read from the static skeleton.
|
|
652
|
+
*/
|
|
653
|
+
declare function getNextFixtureForTeam(adapter: ProviderAdapter, code: string, now?: Date): Promise<NextFixtureResult>;
|
|
629
654
|
/**
|
|
630
655
|
* A single match by id, with live overlay. The provider's scoreboard buckets
|
|
631
656
|
* days in its own zone (ESPN: US/Eastern), so a fixture's UTC date can differ
|
|
@@ -1099,4 +1124,4 @@ declare function formatShareBracket(input: ShareBracketInput, options?: ShareBra
|
|
|
1099
1124
|
/** Compact one-line-per-match bracket for narrow share contexts. */
|
|
1100
1125
|
declare function formatBracketCompactLine(mv: BracketMatchView, opts?: BracketFormatOpts): string;
|
|
1101
1126
|
|
|
1102
|
-
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 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, 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 };
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -295,8 +295,8 @@ var ES = {
|
|
|
295
295
|
"bracket.invalidStage": "La fase debe ser una de: R32, R16, QF, SF, 3P, F",
|
|
296
296
|
"bracket.unknownStage": 'Fase desconocida "{stage}". Usa R32, R16, QF, SF, 3P o F.',
|
|
297
297
|
"bracket.slot.groupWinner": "Ganador del grupo {group}",
|
|
298
|
-
"bracket.slot.groupSecond": "2
|
|
299
|
-
"bracket.slot.third": "3
|
|
298
|
+
"bracket.slot.groupSecond": "2\xBA del grupo {group}",
|
|
299
|
+
"bracket.slot.third": "3\xBA ({groups})",
|
|
300
300
|
"bracket.slot.winner": "Ganador {stage} {n}",
|
|
301
301
|
"bracket.slot.loser": "Perdedor {stage} {n}",
|
|
302
302
|
"bracket.slot.tbd": "Por definir",
|
|
@@ -3400,17 +3400,24 @@ function participant(team, status) {
|
|
|
3400
3400
|
function tbd(label) {
|
|
3401
3401
|
return { label, flag: "\u{1F3F3}\uFE0F", status: "tbd" };
|
|
3402
3402
|
}
|
|
3403
|
+
function confirmedLiveParticipant(team) {
|
|
3404
|
+
if (!team || team.flag === "\u{1F3F3}\uFE0F") return void 0;
|
|
3405
|
+
return participant(team, "confirmed");
|
|
3406
|
+
}
|
|
3403
3407
|
function winnerLabel(ctx, stage, index) {
|
|
3404
3408
|
return t(ctx.lang, "bracket.slot.winner", {
|
|
3405
3409
|
stage: stageLabelI18n(ctx.lang, stage),
|
|
3406
3410
|
n: String(index)
|
|
3407
3411
|
});
|
|
3408
3412
|
}
|
|
3409
|
-
function resolveSlot(ref, ctx) {
|
|
3413
|
+
function resolveSlot(ref, ctx, liveTeam) {
|
|
3414
|
+
const liveParticipant = confirmedLiveParticipant(liveTeam);
|
|
3410
3415
|
switch (ref.kind) {
|
|
3411
3416
|
case "seed":
|
|
3417
|
+
if (liveParticipant) return liveParticipant;
|
|
3412
3418
|
return tbd(ref.label);
|
|
3413
3419
|
case "group": {
|
|
3420
|
+
if (liveParticipant) return liveParticipant;
|
|
3414
3421
|
if (!ctx.standingsDegraded && hasGroupStarted(ref.group, ctx.tables)) {
|
|
3415
3422
|
const team = teamFromStandings(ref.group, ref.position, ctx.tables);
|
|
3416
3423
|
if (team) {
|
|
@@ -3422,6 +3429,7 @@ function resolveSlot(ref, ctx) {
|
|
|
3422
3429
|
return tbd(label);
|
|
3423
3430
|
}
|
|
3424
3431
|
case "third":
|
|
3432
|
+
if (liveParticipant) return liveParticipant;
|
|
3425
3433
|
return tbd(t(ctx.lang, "bracket.slot.third", { groups: ref.groups.join("/") }));
|
|
3426
3434
|
case "winner": {
|
|
3427
3435
|
const node = ctx.nodesByKey.get(matchKey(ref.stage, ref.index));
|
|
@@ -3430,6 +3438,7 @@ function resolveSlot(ref, ctx) {
|
|
|
3430
3438
|
const winner = resolveWinner(match);
|
|
3431
3439
|
if (winner) return participant(winner, "confirmed");
|
|
3432
3440
|
}
|
|
3441
|
+
if (liveParticipant) return liveParticipant;
|
|
3433
3442
|
return tbd(winnerLabel(ctx, ref.stage, ref.index));
|
|
3434
3443
|
}
|
|
3435
3444
|
case "loser": {
|
|
@@ -3439,6 +3448,7 @@ function resolveSlot(ref, ctx) {
|
|
|
3439
3448
|
const loser = resolveLoser(match);
|
|
3440
3449
|
if (loser) return participant(loser, "confirmed");
|
|
3441
3450
|
}
|
|
3451
|
+
if (liveParticipant) return liveParticipant;
|
|
3442
3452
|
return tbd(
|
|
3443
3453
|
t(ctx.lang, "bracket.slot.loser", {
|
|
3444
3454
|
stage: stageLabelI18n(ctx.lang, ref.stage),
|
|
@@ -3476,8 +3486,8 @@ function buildBracketView(topology, matches, tables, standingsDegraded, liveDegr
|
|
|
3476
3486
|
stage: node.stage,
|
|
3477
3487
|
index: node.index,
|
|
3478
3488
|
kickoff: match.kickoff,
|
|
3479
|
-
home: resolveSlot(node.home, ctx),
|
|
3480
|
-
away: resolveSlot(node.away, ctx),
|
|
3489
|
+
home: resolveSlot(node.home, ctx, match.home),
|
|
3490
|
+
away: resolveSlot(node.away, ctx, match.away),
|
|
3481
3491
|
match
|
|
3482
3492
|
};
|
|
3483
3493
|
});
|
|
@@ -4142,6 +4152,22 @@ async function marketFixtureForTeam(adapter, code, now = /* @__PURE__ */ new Dat
|
|
|
4142
4152
|
const next = nextFixtureForTeam(code, { from: now });
|
|
4143
4153
|
return { match: next, degraded: false };
|
|
4144
4154
|
}
|
|
4155
|
+
async function getNextFixtureForTeam(adapter, code, now = /* @__PURE__ */ new Date()) {
|
|
4156
|
+
const base = allFixtures();
|
|
4157
|
+
let matches = base;
|
|
4158
|
+
let degraded = true;
|
|
4159
|
+
let liveById;
|
|
4160
|
+
try {
|
|
4161
|
+
const live = adapter.fetchWindow ? await adapter.fetchWindow(KNOCKOUT_WINDOW_START, KNOCKOUT_WINDOW_END) : [];
|
|
4162
|
+
matches = mergeLive(base, live);
|
|
4163
|
+
degraded = false;
|
|
4164
|
+
liveById = new Set(live.map((m) => m.id));
|
|
4165
|
+
} catch {
|
|
4166
|
+
}
|
|
4167
|
+
const fixture = nextFixtureForTeam(code, { from: now, fixtures: matches });
|
|
4168
|
+
const source = fixture && liveById?.has(fixture.id) ? adapter.name : void 0;
|
|
4169
|
+
return { fixture, degraded, source };
|
|
4170
|
+
}
|
|
4145
4171
|
async function getMatchById(adapter, id) {
|
|
4146
4172
|
const base = allFixtures().find((m) => m.id === id);
|
|
4147
4173
|
if (!base) return { match: void 0, degraded: false };
|
|
@@ -4904,6 +4930,7 @@ export {
|
|
|
4904
4930
|
getMarketSignals,
|
|
4905
4931
|
getMatchById,
|
|
4906
4932
|
getMatchesForDate,
|
|
4933
|
+
getNextFixtureForTeam,
|
|
4907
4934
|
getStandings,
|
|
4908
4935
|
groups,
|
|
4909
4936
|
hasSaneDistribution,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@claudinho/core",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.7",
|
|
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",
|