@nukleus-sports/core 0.2.1 → 0.3.0
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.cjs +1325 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +510 -1
- package/dist/index.d.ts +510 -1
- package/dist/index.js +1267 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -58,4 +58,513 @@ declare function canEditMarketingDeals(permission: MarketingPermission): boolean
|
|
|
58
58
|
* like today. */
|
|
59
59
|
declare function abbreviatePersonName(name: string | null | undefined): string | null;
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
interface SeasonSummary {
|
|
62
|
+
record: string;
|
|
63
|
+
gamesPlayed: number;
|
|
64
|
+
totalGames: number;
|
|
65
|
+
}
|
|
66
|
+
interface SeasonRecordCompetitor {
|
|
67
|
+
id: string;
|
|
68
|
+
score: {
|
|
69
|
+
value: number;
|
|
70
|
+
};
|
|
71
|
+
winner?: boolean;
|
|
72
|
+
}
|
|
73
|
+
interface SeasonRecordGameDetails {
|
|
74
|
+
competitions?: {
|
|
75
|
+
status?: {
|
|
76
|
+
type?: {
|
|
77
|
+
id?: string;
|
|
78
|
+
};
|
|
79
|
+
period?: number;
|
|
80
|
+
};
|
|
81
|
+
competitors?: SeasonRecordCompetitor[];
|
|
82
|
+
}[];
|
|
83
|
+
}
|
|
84
|
+
interface SeasonRecordGame {
|
|
85
|
+
game_details: SeasonRecordGameDetails | null;
|
|
86
|
+
}
|
|
87
|
+
/** Derives a W-L(-OTL/-T) record from a season's raw ESPN game payloads -- see RECONCILIATION.md. */
|
|
88
|
+
declare function computeSeasonSummary(games: SeasonRecordGame[], espnId: string, leagueId: number): SeasonSummary;
|
|
89
|
+
|
|
90
|
+
type RosterColumnKey = "first_name" | "number" | "position" | "height" | "weight" | "age" | "experience" | "college" | "birthplace" | "hometown";
|
|
91
|
+
interface RosterColumnDef {
|
|
92
|
+
key: RosterColumnKey;
|
|
93
|
+
label: string;
|
|
94
|
+
}
|
|
95
|
+
/** The subset of a player's specific_data (jsonb) the roster table reads. */
|
|
96
|
+
interface RosterPlayerSpecificData {
|
|
97
|
+
height?: string | number | null;
|
|
98
|
+
weight?: string | number | null;
|
|
99
|
+
birth_date?: string | null;
|
|
100
|
+
college_name?: string | null;
|
|
101
|
+
birth_city?: string | null;
|
|
102
|
+
birth_state?: string | null;
|
|
103
|
+
birth_country?: string | null;
|
|
104
|
+
}
|
|
105
|
+
interface RosterPlayerLike {
|
|
106
|
+
first_name: string | null;
|
|
107
|
+
last_name: string | null;
|
|
108
|
+
number: string | number | null;
|
|
109
|
+
position: string | null;
|
|
110
|
+
experience: string | null;
|
|
111
|
+
specific_data: RosterPlayerSpecificData | null;
|
|
112
|
+
}
|
|
113
|
+
/** Per-league roster column set, identical in both apps -- see RECONCILIATION.md. */
|
|
114
|
+
declare function getRosterColumns(leagueId: number): RosterColumnDef[];
|
|
115
|
+
/**
|
|
116
|
+
* Formats one roster cell's display value. `leagueId` is only read for `birthplace`'s
|
|
117
|
+
* league-specific formatting (MLS/MLB rules above).
|
|
118
|
+
*/
|
|
119
|
+
declare function getRosterCellValue(player: RosterPlayerLike, columnKey: RosterColumnKey, leagueId: number): string;
|
|
120
|
+
|
|
121
|
+
/** The venue a team plays in: a stadium, or an arena for indoor leagues. */
|
|
122
|
+
type TeamVenueKind = "stadium" | "arena";
|
|
123
|
+
/** The practice facility a team uses. */
|
|
124
|
+
type TeamFacilityKind = "training_facility" | "coaches_facility";
|
|
125
|
+
type TeamPlaceKind = TeamVenueKind | TeamFacilityKind;
|
|
126
|
+
interface TeamPlace {
|
|
127
|
+
name: string;
|
|
128
|
+
street: string;
|
|
129
|
+
city: string;
|
|
130
|
+
state: string;
|
|
131
|
+
zipcode: string;
|
|
132
|
+
}
|
|
133
|
+
interface TeamPlaceSummary {
|
|
134
|
+
/** "Stadium", "Arena", "Training Facility" or "Coaches Facility" -- picked by the league. */
|
|
135
|
+
label: string;
|
|
136
|
+
/** null when the place has no name saved. */
|
|
137
|
+
name: string | null;
|
|
138
|
+
/** "1 Main St, Seattle, WA, 98134"; empty when no address part is saved. */
|
|
139
|
+
address: string;
|
|
140
|
+
}
|
|
141
|
+
/** Which venue (stadium or arena) a league uses -- the one rule for Team Facts, the Team Info
|
|
142
|
+
* card, and the Team page. */
|
|
143
|
+
declare function getTeamVenueConfig(leagueAbbreviation: string | null | undefined): {
|
|
144
|
+
kind: TeamVenueKind;
|
|
145
|
+
label: "Stadium" | "Arena";
|
|
146
|
+
};
|
|
147
|
+
/** Which practice facility a league uses. */
|
|
148
|
+
declare function getTeamFacilityConfig(leagueAbbreviation: string | null | undefined): {
|
|
149
|
+
kind: TeamFacilityKind;
|
|
150
|
+
label: "Training Facility" | "Coaches Facility";
|
|
151
|
+
};
|
|
152
|
+
/** Reads one place's flat `<kind>_name`/`_street`/`_city`/`_state`/`_zipcode` keys out of `specific_data`. */
|
|
153
|
+
declare function parseTeamPlace(specificData: Record<string, unknown>, kind: TeamPlaceKind): TeamPlace;
|
|
154
|
+
declare function formatTeamPlaceAddress(place: TeamPlace): string;
|
|
155
|
+
/** The league's venue and practice facility -- see RECONCILIATION.md. */
|
|
156
|
+
declare function getTeamPlaceSummaries(specificData: unknown, leagueAbbreviation: string | null | undefined): {
|
|
157
|
+
venue: TeamPlaceSummary;
|
|
158
|
+
facility: TeamPlaceSummary;
|
|
159
|
+
};
|
|
160
|
+
/** "Seattle Seahawks" from the `team` + `nickname` columns; either part may be missing. */
|
|
161
|
+
declare function formatTeamName(team: string | null | undefined, nickname: string | null | undefined): string;
|
|
162
|
+
|
|
163
|
+
interface StaffMember {
|
|
164
|
+
id: number;
|
|
165
|
+
first_name: string;
|
|
166
|
+
last_name: string;
|
|
167
|
+
position: string | null;
|
|
168
|
+
display_order: number;
|
|
169
|
+
}
|
|
170
|
+
interface StaffSort {
|
|
171
|
+
id: string;
|
|
172
|
+
desc: boolean;
|
|
173
|
+
}
|
|
174
|
+
/** Sorts staff by name, position, or (by default) saved display order -- see RECONCILIATION.md. */
|
|
175
|
+
declare function sortTeamStaff<T extends StaffMember>(staff: T[], sorting: StaffSort[]): T[];
|
|
176
|
+
|
|
177
|
+
interface StatColumnDef {
|
|
178
|
+
label: string;
|
|
179
|
+
suffix?: string;
|
|
180
|
+
}
|
|
181
|
+
interface TeamSeasonStatsResult {
|
|
182
|
+
/** Generic 4-value result -- meaning varies by sport. */
|
|
183
|
+
values: [string, string, string, string];
|
|
184
|
+
}
|
|
185
|
+
interface TeamSeasonStatEntry {
|
|
186
|
+
stat_id: number;
|
|
187
|
+
stat_value: string | number | null;
|
|
188
|
+
}
|
|
189
|
+
interface TeamSeasonStatRecord {
|
|
190
|
+
stat_details: {
|
|
191
|
+
stats?: TeamSeasonStatEntry[];
|
|
192
|
+
} | null;
|
|
193
|
+
}
|
|
194
|
+
declare const FOOTBALL_TEAM_STAT_IDS: {
|
|
195
|
+
PASSING_YARDS: number;
|
|
196
|
+
RUSHING_YARDS: number;
|
|
197
|
+
POINTS_FOR: number;
|
|
198
|
+
POINTS_AGAINST: number;
|
|
199
|
+
};
|
|
200
|
+
declare const BASKETBALL_TEAM_STAT_IDS: {
|
|
201
|
+
POINTS_FOR: number;
|
|
202
|
+
REBOUNDS: number;
|
|
203
|
+
ASSISTS: number;
|
|
204
|
+
POINTS_AGAINST: number;
|
|
205
|
+
};
|
|
206
|
+
declare const BASEBALL_TEAM_STAT_IDS: {
|
|
207
|
+
HITS: number;
|
|
208
|
+
AT_BATS: number;
|
|
209
|
+
HOMERUNS: number;
|
|
210
|
+
STRIKEOUTS: number;
|
|
211
|
+
EARNED_RUNS: number;
|
|
212
|
+
INNINGS_PITCHED: number;
|
|
213
|
+
};
|
|
214
|
+
declare const HOCKEY_TEAM_STAT_IDS: {
|
|
215
|
+
GOALS_FOR: number;
|
|
216
|
+
GOALS_AGAINST: number;
|
|
217
|
+
SHOTS: number;
|
|
218
|
+
POWER_PLAY_GOALS: number;
|
|
219
|
+
POWER_PLAY_ATTEMPTS: number;
|
|
220
|
+
};
|
|
221
|
+
/** The ranking config ids behind a team's 4 headline stats, or `null` when that league has none. */
|
|
222
|
+
declare function getTeamRankingConfigIds(sportId: number | null | undefined, leagueId: number | null | undefined): number[] | null;
|
|
223
|
+
/** Whether `getTeamStatColumns`/`computeTeamSeasonStats` has a real implementation for this sport. */
|
|
224
|
+
declare function isSupportedTeamStatsSport(sportId: number): boolean;
|
|
225
|
+
/** Get the 4 stat column definitions for a team based on sport. */
|
|
226
|
+
declare function getTeamStatColumns(sportId: number): StatColumnDef[];
|
|
227
|
+
/** A team's 4 headline season-stat values, or `null` for an empty list/unsupported sport. */
|
|
228
|
+
declare function computeTeamSeasonStats(statsData: TeamSeasonStatRecord[], sportId: number): TeamSeasonStatsResult | null;
|
|
229
|
+
/** One stat's precomputed season totals; which field is set depends on how the stat aggregates. */
|
|
230
|
+
interface TeamSeasonStatTotal {
|
|
231
|
+
sum?: number;
|
|
232
|
+
num?: number;
|
|
233
|
+
avg?: number;
|
|
234
|
+
value?: number;
|
|
235
|
+
}
|
|
236
|
+
interface TeamSeasonSummaryRecord {
|
|
237
|
+
games_played: number | null;
|
|
238
|
+
stat_totals: Record<string, TeamSeasonStatTotal> | null;
|
|
239
|
+
}
|
|
240
|
+
/** The 4 headline values from a precomputed season summary, or `null` for no summary/unsupported sport. */
|
|
241
|
+
declare function computeTeamSeasonStatsFromSummary(summary: TeamSeasonSummaryRecord | null | undefined, sportId: number): TeamSeasonStatsResult | null;
|
|
242
|
+
|
|
243
|
+
interface SeasonSelectorSeason {
|
|
244
|
+
season_year: number;
|
|
245
|
+
season_type: number;
|
|
246
|
+
year_display: string;
|
|
247
|
+
type_name: string;
|
|
248
|
+
}
|
|
249
|
+
interface SeasonSelectorOption {
|
|
250
|
+
value: number;
|
|
251
|
+
label: string;
|
|
252
|
+
}
|
|
253
|
+
/** Prefers Regular Season (type 2) when available, otherwise the newest type. */
|
|
254
|
+
declare function getPreferredSeasonType(types: number[]): number | null;
|
|
255
|
+
/** Distinct years, newest first, each labeled from its first matching season. */
|
|
256
|
+
declare function getSeasonYearOptions(seasons: SeasonSelectorSeason[]): SeasonSelectorOption[];
|
|
257
|
+
/** The season types available for one year, newest type first. */
|
|
258
|
+
declare function getSeasonTypeOptions(seasons: SeasonSelectorSeason[], selectedYear: number | null): SeasonSelectorOption[];
|
|
259
|
+
|
|
260
|
+
interface DatedGame {
|
|
261
|
+
id: number;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Selects up to 3 past + 3 upcoming games (6 total), backfilling from whichever side has fewer than
|
|
265
|
+
* 3 so a short side still leaves 6 shown. `pastGames` must be most-recent-first and `upcomingGames`
|
|
266
|
+
* soonest-first; the result reads chronologically, past to future.
|
|
267
|
+
*/
|
|
268
|
+
declare function selectRecentGames<T extends DatedGame>(upcomingGames: T[], pastGames: T[]): T[];
|
|
269
|
+
|
|
270
|
+
interface StatRanking {
|
|
271
|
+
stat_type_id: number;
|
|
272
|
+
config_id: number;
|
|
273
|
+
rank: number;
|
|
274
|
+
tied: boolean;
|
|
275
|
+
}
|
|
276
|
+
/** Ordinal for a rank (1 -> "1st", 12 -> "12th", 23 -> "23rd"). */
|
|
277
|
+
declare function toOrdinal(rank: number): string;
|
|
278
|
+
/** A ranking's ordinal ("1st", "T-2nd") looked up by `stat_type_id`, or null when unranked. */
|
|
279
|
+
declare function formatStatRank(rankings: StatRanking[], statTypeId: number): string | null;
|
|
280
|
+
/** A ranking's ordinal looked up by `config_id`, or null when unranked. */
|
|
281
|
+
declare function formatStatRankByConfig(rankings: Pick<StatRanking, "config_id" | "rank" | "tied">[], configId: number): string | null;
|
|
282
|
+
/**
|
|
283
|
+
* A stat value at the precision `stat_ranking_configs` declares. Percentages (already normalized by
|
|
284
|
+
* the caller) always show exactly one decimal. `locale` defaults to the runtime's; pass one
|
|
285
|
+
* explicitly where output must be deterministic (tests, SSR).
|
|
286
|
+
*/
|
|
287
|
+
declare function formatStatNumber(value: number, decimals: number | null, isPercent?: boolean, locale?: string | string[]): string;
|
|
288
|
+
/** League-rank pill copy: only the top 10% and top 20% are badged, anything lower returns null. */
|
|
289
|
+
declare function topPercentileLabel(rank: number | null, total: number | null): string | null;
|
|
290
|
+
interface StatRankingFootnoteConfig {
|
|
291
|
+
position_filter?: string[] | null;
|
|
292
|
+
minimum_games?: number | null;
|
|
293
|
+
}
|
|
294
|
+
/** The qualifier footnotes under a leaderboard (position filter, minimum games played). */
|
|
295
|
+
declare function getStatRankingFootnotes(config: StatRankingFootnoteConfig | null | undefined): string[];
|
|
296
|
+
|
|
297
|
+
/** Small guards for reading untyped JSON (e.g. `teams.specific_data`) without casts at every call site. */
|
|
298
|
+
/** True for a plain JSON object -- not null, not an array. */
|
|
299
|
+
declare function isJsonRecord(value: unknown): value is Record<string, unknown>;
|
|
300
|
+
/** The value as a JSON object, or `{}` when it isn't one. */
|
|
301
|
+
declare function toJsonRecord(value: unknown): Record<string, unknown>;
|
|
302
|
+
/** Trimmed text, or null for non-strings and blank strings. */
|
|
303
|
+
declare function toTrimmedText(value: unknown): string | null;
|
|
304
|
+
|
|
305
|
+
interface TeamFacts {
|
|
306
|
+
championships_won: number | null;
|
|
307
|
+
championship_years: number[];
|
|
308
|
+
/** College: national titles below the top level or claimed, e.g. FCS, DII, NAIA. */
|
|
309
|
+
other_national_titles: number | null;
|
|
310
|
+
/** Year with an optional level, e.g. "2005 (FCS)" or "1970". */
|
|
311
|
+
other_title_years: string[];
|
|
312
|
+
championship_appearances: number | null;
|
|
313
|
+
appearance_years: number[];
|
|
314
|
+
conference_titles: number | null;
|
|
315
|
+
/** FCS: the years of each conference title, listed under the count. */
|
|
316
|
+
conference_title_years: number[];
|
|
317
|
+
/** College: conference titles across every conference the school has played in. */
|
|
318
|
+
total_conference_titles: number | null;
|
|
319
|
+
/** College: one entry per conference with its title count, e.g. "SEC (31)". */
|
|
320
|
+
conference_history: string[];
|
|
321
|
+
division_titles: number | null;
|
|
322
|
+
fan_nicknames: string[];
|
|
323
|
+
traditions: string[];
|
|
324
|
+
primary_rival_team_id: number | null;
|
|
325
|
+
owner: string | null;
|
|
326
|
+
stadium_capacity: number | null;
|
|
327
|
+
year_established: number | null;
|
|
328
|
+
/** College: the program's first season of play. */
|
|
329
|
+
first_season: number | null;
|
|
330
|
+
summary: string | null;
|
|
331
|
+
}
|
|
332
|
+
type TeamFactKey = keyof TeamFacts;
|
|
333
|
+
/** True when the team has a `facts` object at all (even if every field is empty). */
|
|
334
|
+
declare function hasTeamFacts(raw: unknown): boolean;
|
|
335
|
+
/** Safely reads a `facts` JSON value; missing/malformed fields fall back to empty values. */
|
|
336
|
+
declare function parseTeamFacts(raw: unknown): TeamFacts;
|
|
337
|
+
interface TeamFacilityImage {
|
|
338
|
+
path: string;
|
|
339
|
+
title: string | null;
|
|
340
|
+
sourceUrl: string | null;
|
|
341
|
+
artist: string | null;
|
|
342
|
+
license: string | null;
|
|
343
|
+
licenseUrl: string | null;
|
|
344
|
+
width: number | null;
|
|
345
|
+
height: number | null;
|
|
346
|
+
updatedAt: string | null;
|
|
347
|
+
}
|
|
348
|
+
interface TeamVenue {
|
|
349
|
+
name: string | null;
|
|
350
|
+
image: TeamFacilityImage | null;
|
|
351
|
+
}
|
|
352
|
+
/** The venue's name and stored photo. `kind` is always "stadium"/"arena" -- Team Facts' own venue config narrows it. */
|
|
353
|
+
declare function parseTeamVenue(specificData: unknown, kind: TeamVenueKind): TeamVenue;
|
|
354
|
+
/** "SounderBruce · CC BY-SA 4.0" style credit, or null when nothing is known. */
|
|
355
|
+
declare function facilityImageCredit(image: TeamFacilityImage): string | null;
|
|
356
|
+
/** Shown wherever a fact hasn't been filled in. */
|
|
357
|
+
declare const EMPTY_FACT_VALUE = "\u2014";
|
|
358
|
+
/** Capacities get thousands separators; years and counts never do ("1976", not "1,976"). */
|
|
359
|
+
declare function formatTeamFactNumber(kind: TeamFactKind, value: number | null): string;
|
|
360
|
+
declare function toRomanNumeral(value: number): string;
|
|
361
|
+
/** "XVII · 1982" for a Super Bowl season year; the bare year for anything before Super Bowl I. */
|
|
362
|
+
declare function formatSuperBowlYear(year: number): string;
|
|
363
|
+
/** Year pills use the league's formatter (NFL "XVII · 1982"); labelled years ("2005 (FCS)") stay as typed. */
|
|
364
|
+
declare function formatYearPills(years: (string | number)[], formatYear: ((year: number) => string) | undefined): (string | number)[];
|
|
365
|
+
/** How a fact is entered and stored. */
|
|
366
|
+
type TeamFactKind = "count" | "years" | "labeled_years" | "list" | "rival" | "text" | "number" | "year" | "longtext";
|
|
367
|
+
declare const TEAM_FACT_KINDS: Record<TeamFactKey, TeamFactKind>;
|
|
368
|
+
/** Year lists shown under their matching count (e.g. win years under "Super Bowls Won"). */
|
|
369
|
+
declare const TEAM_FACT_YEAR_PAIRS: Partial<Record<TeamFactKey, TeamFactKey>>;
|
|
370
|
+
/** How the widget lays out a section's fields: Trophy Case two-up, the profile in one row, the rest stacked. */
|
|
371
|
+
type TeamFactsSectionLayout = "grid" | "row" | "column";
|
|
372
|
+
interface TeamFactsSectionConfig {
|
|
373
|
+
title: string;
|
|
374
|
+
fields: TeamFactKey[];
|
|
375
|
+
layout: TeamFactsSectionLayout;
|
|
376
|
+
/** The venue (stadium/arena) name, photo and photo credit sit at the bottom of this section. */
|
|
377
|
+
showsVenuePhoto?: boolean;
|
|
378
|
+
}
|
|
379
|
+
type TeamFactsVenueConfig = ReturnType<typeof getTeamVenueConfig>;
|
|
380
|
+
type TeamFactsFacilityConfig = ReturnType<typeof getTeamFacilityConfig>;
|
|
381
|
+
interface TeamFactsLeagueConfig {
|
|
382
|
+
labels: Record<TeamFactKey, string>;
|
|
383
|
+
venue: TeamFactsVenueConfig;
|
|
384
|
+
facility: TeamFactsFacilityConfig;
|
|
385
|
+
sections: TeamFactsSectionConfig[];
|
|
386
|
+
/** Formats championship/appearance year pills (e.g. NFL "XVII · 1982"); plain year when absent. */
|
|
387
|
+
formatChampionshipYear?: (year: number) => string;
|
|
388
|
+
/** Another league whose teams can also be picked as the rival (e.g. FBS schools with FCS rivals). */
|
|
389
|
+
rivalPartnerLeague?: string;
|
|
390
|
+
}
|
|
391
|
+
/** The fields the widget renders for a section: year lists are shown under their count, not on their own. */
|
|
392
|
+
declare function teamFactsDisplayFields(section: TeamFactsSectionConfig): TeamFactKey[];
|
|
393
|
+
/** League abbreviations that have their own labels configured. */
|
|
394
|
+
declare const CONFIGURED_TEAM_FACTS_LEAGUES: string[];
|
|
395
|
+
declare function getTeamFactsConfig(leagueAbbreviation: string | null | undefined): TeamFactsLeagueConfig;
|
|
396
|
+
interface TeamFactsRival {
|
|
397
|
+
id: number;
|
|
398
|
+
name: string;
|
|
399
|
+
/** Raw, possibly-relative stored value -- the caller resolves it (e.g. via `EntityAvatar`). */
|
|
400
|
+
teamLogoUrl: string | null;
|
|
401
|
+
}
|
|
402
|
+
type TeamFactsRivalState = {
|
|
403
|
+
status: "none";
|
|
404
|
+
} | {
|
|
405
|
+
status: "loading";
|
|
406
|
+
} | {
|
|
407
|
+
status: "error";
|
|
408
|
+
} | {
|
|
409
|
+
status: "ready";
|
|
410
|
+
rival: TeamFactsRival;
|
|
411
|
+
};
|
|
412
|
+
interface TeamFactsWidgetData {
|
|
413
|
+
teamId: number;
|
|
414
|
+
hasFacts: boolean;
|
|
415
|
+
facts: TeamFacts;
|
|
416
|
+
config: TeamFactsLeagueConfig;
|
|
417
|
+
/** The league's venue (stadium or arena) name and photo. */
|
|
418
|
+
venue: TeamVenue;
|
|
419
|
+
rival: TeamFactsRivalState;
|
|
420
|
+
}
|
|
421
|
+
type TeamFactsWidgetState = {
|
|
422
|
+
status: "loading";
|
|
423
|
+
} | {
|
|
424
|
+
status: "error";
|
|
425
|
+
retry?: () => void;
|
|
426
|
+
devMessage?: string;
|
|
427
|
+
} | {
|
|
428
|
+
status: "ready";
|
|
429
|
+
data: TeamFactsWidgetData;
|
|
430
|
+
};
|
|
431
|
+
/** The minimal team-row fields `toTeamFactsView` reads -- not the full `Team`/`TeamWithDetails` row. */
|
|
432
|
+
interface TeamFactsTeamRow {
|
|
433
|
+
id: number;
|
|
434
|
+
specific_data: unknown;
|
|
435
|
+
league?: {
|
|
436
|
+
abbreviation: string | null;
|
|
437
|
+
} | null;
|
|
438
|
+
}
|
|
439
|
+
/** The minimal rival-row fields `toRivalState` reads. */
|
|
440
|
+
interface TeamFactsRivalTeamRow {
|
|
441
|
+
team: string | null;
|
|
442
|
+
nickname: string | null;
|
|
443
|
+
team_logo_url: string | null;
|
|
444
|
+
}
|
|
445
|
+
type TeamFactsView = Omit<TeamFactsWidgetData, "rival">;
|
|
446
|
+
/** Everything the widget shows that comes from the team's own row. */
|
|
447
|
+
declare function toTeamFactsView(team: TeamFactsTeamRow): TeamFactsView;
|
|
448
|
+
/** A missing rival row (resolved as null) is as unshowable as a failed lookup. */
|
|
449
|
+
declare function toRivalState(rivalId: number | null, rivalTeam: TeamFactsRivalTeamRow | null | undefined, isError: boolean): TeamFactsRivalState;
|
|
450
|
+
|
|
451
|
+
interface RecentGameCompetitor {
|
|
452
|
+
id: string;
|
|
453
|
+
homeAway?: string;
|
|
454
|
+
team?: {
|
|
455
|
+
displayName?: string;
|
|
456
|
+
shortDisplayName?: string;
|
|
457
|
+
name?: string;
|
|
458
|
+
logo?: string;
|
|
459
|
+
};
|
|
460
|
+
score?: {
|
|
461
|
+
value?: number;
|
|
462
|
+
displayValue?: string;
|
|
463
|
+
};
|
|
464
|
+
winner?: boolean;
|
|
465
|
+
}
|
|
466
|
+
interface RecentGameRecord {
|
|
467
|
+
id: number;
|
|
468
|
+
game_date: string;
|
|
469
|
+
home_team_id: number | null;
|
|
470
|
+
away_team_id: number | null;
|
|
471
|
+
/** Nullable in the DB: not every game has an ESPN payload yet. */
|
|
472
|
+
game_details: {
|
|
473
|
+
competitions?: {
|
|
474
|
+
status?: {
|
|
475
|
+
type?: {
|
|
476
|
+
id?: string;
|
|
477
|
+
altDetail?: string;
|
|
478
|
+
};
|
|
479
|
+
};
|
|
480
|
+
/** ESPN payloads can carry holes, so entries may be null. */
|
|
481
|
+
competitors?: (RecentGameCompetitor | null)[];
|
|
482
|
+
}[];
|
|
483
|
+
/** Kickoff time text for a not-yet-started game. */
|
|
484
|
+
time?: string;
|
|
485
|
+
} | null;
|
|
486
|
+
}
|
|
487
|
+
/** The team-row fields opponent resolution reads. */
|
|
488
|
+
interface RecentGameTeamRow {
|
|
489
|
+
id: number;
|
|
490
|
+
team: string | null;
|
|
491
|
+
nickname?: string | null;
|
|
492
|
+
team_logo_url: string | null;
|
|
493
|
+
espn_id?: number | null;
|
|
494
|
+
}
|
|
495
|
+
/** Local midnight, as a timestamp: the boundary between "past" and "today onward". */
|
|
496
|
+
declare function startOfLocalDay(now?: Date): number;
|
|
497
|
+
declare function isGameCompleted(game: RecentGameRecord): boolean;
|
|
498
|
+
declare function isGameBeforeDay(game: RecentGameRecord, dayStart: number): boolean;
|
|
499
|
+
/**
|
|
500
|
+
* `getRecentGames`' "upcoming" bucket is a calendar-day split (today onward), not a completion
|
|
501
|
+
* split: a game already finished earlier today still lands in it. So a truly upcoming fixture is
|
|
502
|
+
* one that is neither completed nor before today.
|
|
503
|
+
*/
|
|
504
|
+
declare function isTrueUpcomingGame(game: RecentGameRecord, todayStart: number): boolean;
|
|
505
|
+
type RecentGameOutcome = "win" | "loss" | "tie" | "none";
|
|
506
|
+
interface RecentGameResult {
|
|
507
|
+
outcome: RecentGameOutcome;
|
|
508
|
+
/** "24-17", or "24-17 OT" when the status carries extra detail; empty for "none". */
|
|
509
|
+
detail: string;
|
|
510
|
+
}
|
|
511
|
+
/** A finished game's result from the viewed team's side, or "none" when it can't be determined. */
|
|
512
|
+
declare function getRecentGameResult(game: RecentGameRecord, teamEspnId: number | null | undefined): RecentGameResult;
|
|
513
|
+
/** The distinct, sorted team ids a set of games names (sorted: RTK Query keys on array args). */
|
|
514
|
+
declare function collectRecentGameTeamIds(games: RecentGameRecord[]): number[];
|
|
515
|
+
/**
|
|
516
|
+
* ESPN competitor ids for games missing a home/away team id. The opponent of a cross-league
|
|
517
|
+
* matchup lives in a different league than the game row, so it's looked up by ESPN id instead.
|
|
518
|
+
*/
|
|
519
|
+
declare function collectRecentGameEspnIds(games: RecentGameRecord[]): number[];
|
|
520
|
+
interface RecentGameLogo {
|
|
521
|
+
url: string;
|
|
522
|
+
/** True for a stored (possibly relative) team logo the caller must resolve; false for an absolute ESPN URL. */
|
|
523
|
+
stored: boolean;
|
|
524
|
+
}
|
|
525
|
+
interface RecentGameOpponent {
|
|
526
|
+
name: string;
|
|
527
|
+
logo: RecentGameLogo | null;
|
|
528
|
+
}
|
|
529
|
+
interface ResolveOpponentArgs {
|
|
530
|
+
game: RecentGameRecord;
|
|
531
|
+
/** The opponent's team id on the game row, when it has one. */
|
|
532
|
+
opponentTeamId: number | null;
|
|
533
|
+
isHome: boolean;
|
|
534
|
+
teamEspnId: number | null | undefined;
|
|
535
|
+
teamsById: ReadonlyMap<number, RecentGameTeamRow>;
|
|
536
|
+
teamsByEspnId: ReadonlyMap<string, RecentGameTeamRow>;
|
|
537
|
+
}
|
|
538
|
+
/**
|
|
539
|
+
* The opponent's name and logo: the team row when the game names one, else the ESPN competitor
|
|
540
|
+
* that isn't the viewed team (preferring the stored team found by ESPN id, so its stored logo is
|
|
541
|
+
* used -- ESPN payloads often omit `team.logo`), else "TBD".
|
|
542
|
+
*/
|
|
543
|
+
declare function resolveRecentGameOpponent({ game, opponentTeamId, isHome, teamEspnId, teamsById, teamsByEspnId, }: ResolveOpponentArgs): RecentGameOpponent;
|
|
544
|
+
interface RecentGameRow {
|
|
545
|
+
id: number;
|
|
546
|
+
gameDate: string;
|
|
547
|
+
isHome: boolean;
|
|
548
|
+
opponent: RecentGameOpponent;
|
|
549
|
+
/** Only for a game that is finished or already past; null for a fixture still to come. */
|
|
550
|
+
result: RecentGameResult | null;
|
|
551
|
+
/** Kickoff time text, only for a fixture still to come. */
|
|
552
|
+
time: string | null;
|
|
553
|
+
/** The first not-yet-played fixture: where the "Upcoming" header goes. */
|
|
554
|
+
isFirstUpcoming: boolean;
|
|
555
|
+
}
|
|
556
|
+
interface BuildRecentGameRowsArgs {
|
|
557
|
+
games: RecentGameRecord[];
|
|
558
|
+
teamId: number | null;
|
|
559
|
+
teamEspnId: number | null | undefined;
|
|
560
|
+
/** Rows for the ids from `collectRecentGameTeamIds`. */
|
|
561
|
+
teams: RecentGameTeamRow[];
|
|
562
|
+
/** Rows for the ids from `collectRecentGameEspnIds`, matched by `espn_id`. */
|
|
563
|
+
espnTeams: RecentGameTeamRow[];
|
|
564
|
+
/** From `startOfLocalDay`; recompute each render so the split follows midnight. */
|
|
565
|
+
todayStart: number;
|
|
566
|
+
}
|
|
567
|
+
/** One render-ready row per game, in the order given. */
|
|
568
|
+
declare function buildRecentGameRows({ games, teamId, teamEspnId, teams, espnTeams, todayStart, }: BuildRecentGameRowsArgs): RecentGameRow[];
|
|
569
|
+
|
|
570
|
+
export { BASEBALL_TEAM_STAT_IDS, BASKETBALL_TEAM_STAT_IDS, type BuildRecentGameRowsArgs, CONFIGURED_TEAM_FACTS_LEAGUES, type DatedGame, type DealStatus, EMPTY_FACT_VALUE, FOOTBALL_TEAM_STAT_IDS, HOCKEY_TEAM_STAT_IDS, type MarketingPermission, type ProjectMemberRole, type RecentGameCompetitor, type RecentGameLogo, type RecentGameOpponent, type RecentGameOutcome, type RecentGameRecord, type RecentGameResult, type RecentGameRow, type RecentGameTeamRow, type ResolveOpponentArgs, type RosterColumnDef, type RosterColumnKey, type RosterPlayerLike, type RosterPlayerSpecificData, type SeasonRecordGame, type SeasonSelectorOption, type SeasonSelectorSeason, type SeasonSummary, type StaffMember, type StaffSort, type StatColumnDef, type StatRanking, type StatRankingFootnoteConfig, TEAM_FACT_KINDS, TEAM_FACT_YEAR_PAIRS, type TeamFacilityImage, type TeamFacilityKind, type TeamFactKey, type TeamFactKind, type TeamFacts, type TeamFactsLeagueConfig, type TeamFactsRival, type TeamFactsRivalState, type TeamFactsRivalTeamRow, type TeamFactsSectionConfig, type TeamFactsSectionLayout, type TeamFactsTeamRow, type TeamFactsWidgetData, type TeamFactsWidgetState, type TeamPlace, type TeamPlaceKind, type TeamPlaceSummary, type TeamSeasonStatEntry, type TeamSeasonStatRecord, type TeamSeasonStatTotal, type TeamSeasonStatsResult, type TeamSeasonSummaryRecord, type TeamVenue, type TeamVenueKind, abbreviatePersonName, buildRecentGameRows, canEditMarketingDeals, canEditProject, canEditTaskStatus, canManageMembers, canViewMarketingDeals, collectRecentGameEspnIds, collectRecentGameTeamIds, computeSeasonSummary, computeTeamSeasonStats, computeTeamSeasonStatsFromSummary, facilityImageCredit, fmt, fmtCurrency, fmtDate, fmtUSD, fmtUSDCompact, fmtUSDWhole, formatDealDate, formatStatNumber, formatStatRank, formatStatRankByConfig, formatSuperBowlYear, formatTeamFactNumber, formatTeamName, formatTeamPlaceAddress, formatYearPills, getDealStatus, getEffectiveMemberRole, getPreferredSeasonType, getRecentGameResult, getRosterCellValue, getRosterColumns, getSeasonTypeOptions, getSeasonYearOptions, getStatRankingFootnotes, getTeamFacilityConfig, getTeamFactsConfig, getTeamPlaceSummaries, getTeamRankingConfigIds, getTeamStatColumns, getTeamVenueConfig, hasTeamFacts, isGameBeforeDay, isGameCompleted, isJsonRecord, isProjectCancelled, isSupportedTeamStatsSport, isTrueUpcomingGame, parseTeamFacts, parseTeamPlace, parseTeamVenue, resolveRecentGameOpponent, selectRecentGames, sortTeamStaff, startOfLocalDay, teamFactsDisplayFields, toJsonRecord, toOrdinal, toRivalState, toRomanNumeral, toTeamFactsView, toTrimmedText, topPercentileLabel };
|