@nukleus-sports/core 0.3.0 → 0.4.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,6 +240,24 @@ 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
+
243
261
  interface SeasonSelectorSeason {
244
262
  season_year: number;
245
263
  season_type: number;
@@ -567,4 +585,4 @@ interface BuildRecentGameRowsArgs {
567
585
  /** One render-ready row per game, in the order given. */
568
586
  declare function buildRecentGameRows({ games, teamId, teamEspnId, teams, espnTeams, todayStart, }: BuildRecentGameRowsArgs): RecentGameRow[];
569
587
 
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 };
588
+ 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;
@@ -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,