@nukleus-sports/core 0.3.0 → 0.5.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.d.ts CHANGED
@@ -240,9 +240,31 @@ interface TeamSeasonSummaryRecord {
240
240
  /** The 4 headline values from a precomputed season summary, or `null` for no summary/unsupported sport. */
241
241
  declare function computeTeamSeasonStatsFromSummary(summary: TeamSeasonSummaryRecord | null | undefined, sportId: number): TeamSeasonStatsResult | null;
242
242
 
243
+ interface TeamStatTypeLike {
244
+ id: number;
245
+ sport_id: number;
246
+ type_source_name: string;
247
+ }
248
+ /**
249
+ * Drops any stat type that isn't this sport's own (defends against a caller passing an unfiltered,
250
+ * multi-sport list) and this sport's hidden ids, keeping every remaining category.
251
+ */
252
+ declare function getVisibleTeamStatTypes<T extends TeamStatTypeLike>(statTypes: T[], sportId: number): T[];
253
+ /**
254
+ * The already-visible stat types for one category (offense/defense/batting/pitching/...), in this
255
+ * sport's configured display order -- anything not in that order sorts last, by id.
256
+ */
257
+ declare function getOrderedTeamStatTypesForCategory<T extends TeamStatTypeLike>(statTypes: T[], sportId: number, category: string): T[];
258
+ /** Whether this sport's stats split into categories (e.g. offense/defense) worth a picker. */
259
+ declare function showsTeamStatCategoryPicker(sportId: number): boolean;
260
+
261
+ /**
262
+ * Both real apps' `LeagueSeason` row (`year`/`type`), not the Stats tab's `StatSeason` row
263
+ * (`season_year`/`season_type`) -- see RECONCILIATION.md for why.
264
+ */
243
265
  interface SeasonSelectorSeason {
244
- season_year: number;
245
- season_type: number;
266
+ year: number;
267
+ type: number;
246
268
  year_display: string;
247
269
  type_name: string;
248
270
  }
@@ -254,7 +276,7 @@ interface SeasonSelectorOption {
254
276
  declare function getPreferredSeasonType(types: number[]): number | null;
255
277
  /** Distinct years, newest first, each labeled from its first matching season. */
256
278
  declare function getSeasonYearOptions(seasons: SeasonSelectorSeason[]): SeasonSelectorOption[];
257
- /** The season types available for one year, newest type first. */
279
+ /** The season types available for one year, in both real apps' own ascending (not newest-first) order. */
258
280
  declare function getSeasonTypeOptions(seasons: SeasonSelectorSeason[], selectedYear: number | null): SeasonSelectorOption[];
259
281
 
260
282
  interface DatedGame {
@@ -567,4 +589,4 @@ interface BuildRecentGameRowsArgs {
567
589
  /** One render-ready row per game, in the order given. */
568
590
  declare function buildRecentGameRows({ games, teamId, teamEspnId, teams, espnTeams, todayStart, }: BuildRecentGameRowsArgs): RecentGameRow[];
569
591
 
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 };
592
+ 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 TeamStatTypeLike, 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, getOrderedTeamStatTypesForCategory, getPreferredSeasonType, getRecentGameResult, getRosterCellValue, getRosterColumns, getSeasonTypeOptions, getSeasonYearOptions, getStatRankingFootnotes, getTeamFacilityConfig, getTeamFactsConfig, getTeamPlaceSummaries, getTeamRankingConfigIds, getTeamStatColumns, getTeamVenueConfig, getVisibleTeamStatTypes, hasTeamFacts, isGameBeforeDay, isGameCompleted, isJsonRecord, isProjectCancelled, isSupportedTeamStatsSport, isTrueUpcomingGame, parseTeamFacts, parseTeamPlace, parseTeamVenue, resolveRecentGameOpponent, selectRecentGames, showsTeamStatCategoryPicker, sortTeamStaff, startOfLocalDay, teamFactsDisplayFields, toJsonRecord, toOrdinal, toRivalState, toRomanNumeral, toTeamFactsView, toTrimmedText, topPercentileLabel };
package/dist/index.js CHANGED
@@ -595,6 +595,55 @@ function computeTeamSeasonStatsFromSummary(summary, sportId) {
595
595
  return null;
596
596
  }
597
597
 
598
+ // src/teamStatsTable.ts
599
+ var HIDDEN_TEAM_STAT_TYPES_CONFIG = {
600
+ // Football (sport_id = 1)
601
+ 1: [250, 253, 254, 263, 264, 271, 272, 268, 257, 267],
602
+ // Basketball (sport_id = 2)
603
+ 2: [293, 295, 297, 300, 281, 283],
604
+ // Baseball (sport_id = 3)
605
+ 3: [307, 311, 312, 319, 320, 321],
606
+ // Hockey (sport_id = 5)
607
+ 5: [338, 340, 346]
608
+ };
609
+ var TEAM_STAT_DISPLAY_ORDER_CONFIG = {
610
+ // Football (sport_id = 1)
611
+ 1: {
612
+ offense: [251, 255, 261, 244, 246, 248, 266, 268, 257, 259, 265, 270],
613
+ defense: [252, 256, 262, 245, 247, 249, 267, 269, 258, 260]
614
+ },
615
+ // Hockey (sport_id = 5)
616
+ 5: {
617
+ offense: [332, 334, 336, 328, 326, 330, 342, 344]
618
+ },
619
+ // Baseball (sport_id = 3)
620
+ 3: {
621
+ batting: [303, 308, 304, 309, 306, 302, 310, 305, 313],
622
+ pitching: [325, 323, 316, 324, 317, 322, 318, 315, 314]
623
+ }
624
+ };
625
+ var SPORTS_WITHOUT_STAT_CATEGORIES = [2, 5];
626
+ function getVisibleTeamStatTypes(statTypes, sportId) {
627
+ const hidden = new Set(HIDDEN_TEAM_STAT_TYPES_CONFIG[sportId] ?? []);
628
+ return statTypes.filter((statType) => statType.sport_id === sportId && !hidden.has(statType.id));
629
+ }
630
+ function getOrderedTeamStatTypesForCategory(statTypes, sportId, category) {
631
+ const filtered = statTypes.filter((statType) => statType.type_source_name === category);
632
+ const order = TEAM_STAT_DISPLAY_ORDER_CONFIG[sportId]?.[category];
633
+ if (!order) return filtered;
634
+ return [...filtered].sort((a, b) => {
635
+ const indexA = order.indexOf(a.id);
636
+ const indexB = order.indexOf(b.id);
637
+ if (indexA !== -1 && indexB !== -1) return indexA - indexB;
638
+ if (indexA !== -1) return -1;
639
+ if (indexB !== -1) return 1;
640
+ return a.id - b.id;
641
+ });
642
+ }
643
+ function showsTeamStatCategoryPicker(sportId) {
644
+ return !SPORTS_WITHOUT_STAT_CATEGORIES.includes(sportId);
645
+ }
646
+
598
647
  // src/teamSeasonSelector.ts
599
648
  function getPreferredSeasonType(types) {
600
649
  if (types.length === 0) return null;
@@ -602,15 +651,15 @@ function getPreferredSeasonType(types) {
602
651
  return Math.max(...types);
603
652
  }
604
653
  function getSeasonYearOptions(seasons) {
605
- const years = [...new Set(seasons.map((s) => s.season_year))].sort((a, b) => b - a);
654
+ const years = [...new Set(seasons.map((s) => s.year))].sort((a, b) => b - a);
606
655
  return years.map((year) => ({
607
656
  value: year,
608
- label: seasons.find((s) => s.season_year === year)?.year_display ?? String(year)
657
+ label: seasons.find((s) => s.year === year)?.year_display ?? String(year)
609
658
  }));
610
659
  }
611
660
  function getSeasonTypeOptions(seasons, selectedYear) {
612
661
  if (selectedYear === null) return [];
613
- return seasons.filter((s) => s.season_year === selectedYear).sort((a, b) => b.season_type - a.season_type).map((s) => ({ value: s.season_type, label: s.type_name }));
662
+ return seasons.filter((s) => s.year === selectedYear).sort((a, b) => a.type - b.type).map((s) => ({ value: s.type, label: s.type_name }));
614
663
  }
615
664
 
616
665
  // src/recentGamesSelection.ts
@@ -1346,6 +1395,7 @@ export {
1346
1395
  formatYearPills,
1347
1396
  getDealStatus,
1348
1397
  getEffectiveMemberRole,
1398
+ getOrderedTeamStatTypesForCategory,
1349
1399
  getPreferredSeasonType,
1350
1400
  getRecentGameResult,
1351
1401
  getRosterCellValue,
@@ -1359,6 +1409,7 @@ export {
1359
1409
  getTeamRankingConfigIds,
1360
1410
  getTeamStatColumns,
1361
1411
  getTeamVenueConfig,
1412
+ getVisibleTeamStatTypes,
1362
1413
  hasTeamFacts,
1363
1414
  isGameBeforeDay,
1364
1415
  isGameCompleted,
@@ -1371,6 +1422,7 @@ export {
1371
1422
  parseTeamVenue,
1372
1423
  resolveRecentGameOpponent,
1373
1424
  selectRecentGames,
1425
+ showsTeamStatCategoryPicker,
1374
1426
  sortTeamStaff,
1375
1427
  startOfLocalDay,
1376
1428
  teamFactsDisplayFields,