@claudinho/core 0.8.15 → 0.8.17
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.js +63 -25
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3422,7 +3422,7 @@ function winnerLabel(ctx, stage, index) {
|
|
|
3422
3422
|
n: String(index)
|
|
3423
3423
|
});
|
|
3424
3424
|
}
|
|
3425
|
-
function resolveSlot(ref, ctx, liveTeam) {
|
|
3425
|
+
function resolveSlot(ref, ctx, liveTeam, fixtureInMergedSet = false) {
|
|
3426
3426
|
const liveParticipant = confirmedLiveParticipant(liveTeam);
|
|
3427
3427
|
switch (ref.kind) {
|
|
3428
3428
|
case "seed":
|
|
@@ -3444,23 +3444,27 @@ function resolveSlot(ref, ctx, liveTeam) {
|
|
|
3444
3444
|
if (liveParticipant) return liveParticipant;
|
|
3445
3445
|
return tbd(t(ctx.lang, "bracket.slot.third", { groups: ref.groups.join("/") }));
|
|
3446
3446
|
case "winner": {
|
|
3447
|
-
const node = ctx.nodesByKey.get(matchKey(ref.stage, ref.index));
|
|
3448
|
-
const match = node ? ctx.matchesById.get(node.matchId) : void 0;
|
|
3449
|
-
if (match) {
|
|
3450
|
-
const winner = resolveWinner(match);
|
|
3451
|
-
if (winner) return participant(winner, "confirmed");
|
|
3452
|
-
}
|
|
3453
3447
|
if (liveParticipant) return liveParticipant;
|
|
3448
|
+
if (!fixtureInMergedSet) {
|
|
3449
|
+
const node = ctx.nodesByKey.get(matchKey(ref.stage, ref.index));
|
|
3450
|
+
const match = node ? ctx.matchesById.get(node.matchId) : void 0;
|
|
3451
|
+
if (match) {
|
|
3452
|
+
const winner = resolveWinner(match);
|
|
3453
|
+
if (winner) return participant(winner, "confirmed");
|
|
3454
|
+
}
|
|
3455
|
+
}
|
|
3454
3456
|
return tbd(winnerLabel(ctx, ref.stage, ref.index));
|
|
3455
3457
|
}
|
|
3456
3458
|
case "loser": {
|
|
3457
|
-
const node = ctx.nodesByKey.get(matchKey(ref.stage, ref.index));
|
|
3458
|
-
const match = node ? ctx.matchesById.get(node.matchId) : void 0;
|
|
3459
|
-
if (match) {
|
|
3460
|
-
const loser = resolveLoser(match);
|
|
3461
|
-
if (loser) return participant(loser, "confirmed");
|
|
3462
|
-
}
|
|
3463
3459
|
if (liveParticipant) return liveParticipant;
|
|
3460
|
+
if (!fixtureInMergedSet) {
|
|
3461
|
+
const node = ctx.nodesByKey.get(matchKey(ref.stage, ref.index));
|
|
3462
|
+
const match = node ? ctx.matchesById.get(node.matchId) : void 0;
|
|
3463
|
+
if (match) {
|
|
3464
|
+
const loser = resolveLoser(match);
|
|
3465
|
+
if (loser) return participant(loser, "confirmed");
|
|
3466
|
+
}
|
|
3467
|
+
}
|
|
3464
3468
|
return tbd(
|
|
3465
3469
|
t(ctx.lang, "bracket.slot.loser", {
|
|
3466
3470
|
stage: stageLabelI18n(ctx.lang, ref.stage),
|
|
@@ -3483,6 +3487,7 @@ function buildBracketView(topology, matches, tables, standingsDegraded, liveDegr
|
|
|
3483
3487
|
if (want && stage !== want) continue;
|
|
3484
3488
|
const nodes = topology.matches.filter((n) => n.stage === stage);
|
|
3485
3489
|
const matchViews = nodes.map((node) => {
|
|
3490
|
+
const fixtureInMergedSet = matchesById.has(node.matchId);
|
|
3486
3491
|
const match = matchesById.get(node.matchId) ?? {
|
|
3487
3492
|
id: node.matchId,
|
|
3488
3493
|
stage: node.stage,
|
|
@@ -3498,8 +3503,8 @@ function buildBracketView(topology, matches, tables, standingsDegraded, liveDegr
|
|
|
3498
3503
|
stage: node.stage,
|
|
3499
3504
|
index: node.index,
|
|
3500
3505
|
kickoff: match.kickoff,
|
|
3501
|
-
home: resolveSlot(node.home, ctx, match.home),
|
|
3502
|
-
away: resolveSlot(node.away, ctx, match.away),
|
|
3506
|
+
home: resolveSlot(node.home, ctx, match.home, fixtureInMergedSet),
|
|
3507
|
+
away: resolveSlot(node.away, ctx, match.away, fixtureInMergedSet),
|
|
3503
3508
|
match
|
|
3504
3509
|
};
|
|
3505
3510
|
});
|
|
@@ -4460,7 +4465,8 @@ var PolymarketProvider = class {
|
|
|
4460
4465
|
opts;
|
|
4461
4466
|
name = "polymarket";
|
|
4462
4467
|
async findSignal(match, options) {
|
|
4463
|
-
|
|
4468
|
+
const deadline = options?.deadlineMs != null ? Date.now() + options.deadlineMs : Number.POSITIVE_INFINITY;
|
|
4469
|
+
return (await this.resolveOne(match, options, deadline)).signal;
|
|
4464
4470
|
}
|
|
4465
4471
|
async findSignals(matches, options) {
|
|
4466
4472
|
const signals = /* @__PURE__ */ new Map();
|
|
@@ -4468,7 +4474,7 @@ var PolymarketProvider = class {
|
|
|
4468
4474
|
const deadline = options?.deadlineMs != null ? Date.now() + options.deadlineMs : Number.POSITIVE_INFINITY;
|
|
4469
4475
|
for (const m of matches) {
|
|
4470
4476
|
if (Date.now() >= deadline) break;
|
|
4471
|
-
const r = await this.resolveOne(m, options);
|
|
4477
|
+
const r = await this.resolveOne(m, options, deadline);
|
|
4472
4478
|
if (r.checked) checked.add(m.id);
|
|
4473
4479
|
if (r.signal) signals.set(m.id, r.signal);
|
|
4474
4480
|
}
|
|
@@ -4480,13 +4486,16 @@ var PolymarketProvider = class {
|
|
|
4480
4486
|
* provider/network error — so transient failures are retried, not
|
|
4481
4487
|
* negative-cached.
|
|
4482
4488
|
*/
|
|
4483
|
-
async resolveOne(match, options) {
|
|
4489
|
+
async resolveOne(match, options, deadline = Number.POSITIVE_INFINITY) {
|
|
4484
4490
|
const entry = (this.opts.mapping ?? BUNDLED_MAPPING)[match.id];
|
|
4485
4491
|
const slugs = entry?.eventSlug ? [entry.eventSlug] : deriveEventSlugs(match);
|
|
4486
4492
|
if (slugs.length === 0) return { checked: true };
|
|
4493
|
+
const configured = options?.timeoutMs ?? this.opts.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
4487
4494
|
try {
|
|
4488
4495
|
for (const slug of slugs) {
|
|
4489
|
-
const
|
|
4496
|
+
const remaining = deadline - Date.now();
|
|
4497
|
+
if (remaining <= 0) return { checked: false };
|
|
4498
|
+
const event = await this.fetchEvent(slug, Math.min(configured, remaining));
|
|
4490
4499
|
const signal = event ? this.toSignal(match, slug, event, options) : void 0;
|
|
4491
4500
|
if (signal) return { signal, checked: true };
|
|
4492
4501
|
}
|
|
@@ -4566,6 +4575,27 @@ var PolymarketProvider = class {
|
|
|
4566
4575
|
return signal.ambiguous ? void 0 : signal;
|
|
4567
4576
|
}
|
|
4568
4577
|
};
|
|
4578
|
+
var POLYMARKET_TOKEN = {
|
|
4579
|
+
SUI: "che",
|
|
4580
|
+
// Switzerland
|
|
4581
|
+
NED: "nld",
|
|
4582
|
+
// Netherlands
|
|
4583
|
+
URU: "ury",
|
|
4584
|
+
// Uruguay
|
|
4585
|
+
POR: "prt",
|
|
4586
|
+
// Portugal
|
|
4587
|
+
CRO: "hrv",
|
|
4588
|
+
// Croatia
|
|
4589
|
+
COD: "cdr",
|
|
4590
|
+
// DR Congo
|
|
4591
|
+
CPV: "cvi"
|
|
4592
|
+
// Cabo Verde
|
|
4593
|
+
};
|
|
4594
|
+
function pmTokens(code) {
|
|
4595
|
+
const c = code.toLowerCase();
|
|
4596
|
+
const alias = POLYMARKET_TOKEN[code.toUpperCase()];
|
|
4597
|
+
return alias && alias !== c ? [alias, c] : [c];
|
|
4598
|
+
}
|
|
4569
4599
|
function deriveEventSlugs(match) {
|
|
4570
4600
|
const home = match.home.code.toLowerCase();
|
|
4571
4601
|
const away = match.away.code.toLowerCase();
|
|
@@ -4573,10 +4603,18 @@ function deriveEventSlugs(match) {
|
|
|
4573
4603
|
if (!/^[a-z]{3}$/.test(home) || !/^[a-z]{3}$/.test(away)) return [];
|
|
4574
4604
|
const utcDate = match.kickoff.slice(0, 10);
|
|
4575
4605
|
if (!/^\d{4}-\d{2}-\d{2}$/.test(utcDate)) return [];
|
|
4576
|
-
|
|
4577
|
-
|
|
4578
|
-
|
|
4579
|
-
];
|
|
4606
|
+
const dates = [utcDate, shiftUtcDate(utcDate, -1)];
|
|
4607
|
+
const homeToks = pmTokens(match.home.code);
|
|
4608
|
+
const awayToks = pmTokens(match.away.code);
|
|
4609
|
+
const slugs = [];
|
|
4610
|
+
for (const d of dates) {
|
|
4611
|
+
for (const h of homeToks) {
|
|
4612
|
+
for (const a of awayToks) {
|
|
4613
|
+
slugs.push(`fifwc-${h}-${a}-${d}`);
|
|
4614
|
+
}
|
|
4615
|
+
}
|
|
4616
|
+
}
|
|
4617
|
+
return [...new Set(slugs)];
|
|
4580
4618
|
}
|
|
4581
4619
|
function slugToken(m) {
|
|
4582
4620
|
return (m.slug ?? "").toLowerCase().split("-").pop() ?? "";
|
|
@@ -4585,10 +4623,10 @@ function isDrawMarket(m) {
|
|
|
4585
4623
|
return slugToken(m) === "draw" || (m.groupItemTitle ?? "").trim().toLowerCase().startsWith("draw");
|
|
4586
4624
|
}
|
|
4587
4625
|
function pickMarket(markets, teamCode, teamName) {
|
|
4588
|
-
const
|
|
4626
|
+
const tokens = pmTokens(teamCode);
|
|
4589
4627
|
const name = teamName.trim().toLowerCase();
|
|
4590
4628
|
const teamMarkets = markets.filter((m) => !isDrawMarket(m));
|
|
4591
|
-
const bySlug = teamMarkets.find((m) => slugToken(m)
|
|
4629
|
+
const bySlug = teamMarkets.find((m) => tokens.includes(slugToken(m)));
|
|
4592
4630
|
if (bySlug) return bySlug;
|
|
4593
4631
|
return teamMarkets.find((m) => (m.groupItemTitle ?? "").trim().toLowerCase() === name);
|
|
4594
4632
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@claudinho/core",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.17",
|
|
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",
|