fitzroy 1.3.1 → 1.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/cli.js CHANGED
@@ -336,6 +336,62 @@ var init_parse_utils = __esm({
336
336
  }
337
337
  });
338
338
 
339
+ // src/lib/venue-mapping.ts
340
+ function normaliseVenueName(raw) {
341
+ const trimmed = raw.trim();
342
+ return VENUE_ALIAS_MAP.get(trimmed.toLowerCase()) ?? trimmed;
343
+ }
344
+ var VENUE_ALIASES, VENUE_ALIAS_MAP;
345
+ var init_venue_mapping = __esm({
346
+ "src/lib/venue-mapping.ts"() {
347
+ "use strict";
348
+ VENUE_ALIASES = [
349
+ ["MCG", "M.C.G.", "Melbourne Cricket Ground"],
350
+ ["SCG", "S.C.G.", "Sydney Cricket Ground"],
351
+ ["Marvel Stadium", "Docklands", "Etihad Stadium", "Telstra Dome", "Colonial Stadium"],
352
+ ["Kardinia Park", "GMHBA Stadium", "Simonds Stadium", "Skilled Stadium"],
353
+ ["Gabba", "The Gabba", "Brisbane Cricket Ground"],
354
+ [
355
+ "Sydney Showground",
356
+ "ENGIE Stadium",
357
+ "GIANTS Stadium",
358
+ "Showground Stadium",
359
+ "Sydney Showground Stadium"
360
+ ],
361
+ ["Accor Stadium", "Stadium Australia", "ANZ Stadium", "Homebush"],
362
+ ["Carrara", "People First Stadium", "Heritage Bank Stadium", "Metricon Stadium"],
363
+ ["Perth Stadium", "Optus Stadium"],
364
+ ["Adelaide Oval"],
365
+ ["Manuka Oval", "Corroboree Group Oval Manuka"],
366
+ ["Blundstone Arena", "Bellerive Oval"],
367
+ ["UTAS Stadium", "York Park", "University of Tasmania Stadium", "Aurora Stadium"],
368
+ ["TIO Stadium", "Marrara Oval"],
369
+ ["Traeger Park", "TIO Traeger Park"],
370
+ ["Mars Stadium", "Eureka Stadium"],
371
+ ["Cazalys Stadium", "Cazaly's Stadium"],
372
+ ["Jiangwan Stadium"],
373
+ ["Riverway Stadium"],
374
+ ["Norwood Oval"],
375
+ ["Subiaco Oval", "Subiaco"],
376
+ ["Football Park", "AAMI Stadium"],
377
+ ["Princes Park", "Ikon Park"],
378
+ ["Blacktown International Sportspark"],
379
+ ["Barossa Park", "Barossa Oval", "Adelaide Hills"],
380
+ ["Ninja Stadium", "Summit Sports Park"]
381
+ ];
382
+ VENUE_ALIAS_MAP = (() => {
383
+ const map = /* @__PURE__ */ new Map();
384
+ for (const [canonical, ...aliases] of VENUE_ALIASES) {
385
+ map.set(canonical.toLowerCase(), canonical);
386
+ for (const alias of aliases) {
387
+ map.set(alias.toLowerCase(), canonical);
388
+ }
389
+ }
390
+ return map;
391
+ })();
392
+ }
393
+ });
394
+
339
395
  // src/transforms/footywire-player-stats.ts
340
396
  import * as cheerio from "cheerio";
341
397
  function cleanPlayerName(raw) {
@@ -628,7 +684,7 @@ function transformMatchItems(items, season, competition, source = "afl-api") {
628
684
  roundNumber: item.round?.roundNumber ?? 0,
629
685
  roundType: inferRoundType(item.round?.name ?? ""),
630
686
  date: new Date(item.match.utcStartTime),
631
- venue: item.venue?.name ?? "",
687
+ venue: item.venue?.name ? normaliseVenueName(item.venue.name) : "",
632
688
  homeTeam: normaliseTeamName(item.match.homeTeam.name),
633
689
  awayTeam: normaliseTeamName(item.match.awayTeam.name),
634
690
  homeGoals: homeScore?.matchScore.goals ?? 0,
@@ -664,6 +720,7 @@ var init_match_results = __esm({
664
720
  "src/transforms/match-results.ts"() {
665
721
  "use strict";
666
722
  init_team_mapping();
723
+ init_venue_mapping();
667
724
  FINALS_PATTERN = /final|elimination|qualifying|preliminary|semi|grand/i;
668
725
  }
669
726
  });
@@ -2235,7 +2292,7 @@ function transformSquiggleGamesToResults(games, season) {
2235
2292
  roundNumber: g.round,
2236
2293
  roundType: inferRoundType(g.roundname),
2237
2294
  date: new Date(g.unixtime * 1e3),
2238
- venue: g.venue,
2295
+ venue: normaliseVenueName(g.venue),
2239
2296
  homeTeam: normaliseTeamName(g.hteam),
2240
2297
  awayTeam: normaliseTeamName(g.ateam),
2241
2298
  homeGoals: g.hgoals ?? 0,
@@ -2298,6 +2355,7 @@ var init_squiggle2 = __esm({
2298
2355
  "src/transforms/squiggle.ts"() {
2299
2356
  "use strict";
2300
2357
  init_team_mapping();
2358
+ init_venue_mapping();
2301
2359
  init_match_results();
2302
2360
  }
2303
2361
  });
@@ -5171,8 +5229,8 @@ resolveAliases();
5171
5229
  var main = defineCommand11({
5172
5230
  meta: {
5173
5231
  name: "fitzroy",
5174
- version: "1.3.1",
5175
- description: "CLI for fetching AFL data \u2014 match results, player stats, fixtures, ladders, and more"
5232
+ version: "1.4.0",
5233
+ description: "TypeScript port of the fitzRoy R package \u2014 fetch AFL data from the command line"
5176
5234
  },
5177
5235
  subCommands: {
5178
5236
  matches: () => Promise.resolve().then(() => (init_matches(), matches_exports)).then((m) => m.matchesCommand),
package/dist/index.d.ts CHANGED
@@ -1759,6 +1759,31 @@ declare const LadderResponseSchema: z2.ZodObject<{
1759
1759
  type LadderEntryRaw = z2.infer<typeof LadderEntryRawSchema>;
1760
1760
  /** Inferred type for the ladder API response. */
1761
1761
  type LadderResponse = z2.infer<typeof LadderResponseSchema>;
1762
+ /**
1763
+ * Venue name normalisation across AFL data sources.
1764
+ *
1765
+ * Maps sponsor names, historical names, and abbreviations to stable canonical
1766
+ * venue names. Lookups are case-insensitive.
1767
+ *
1768
+ * @example
1769
+ * ```ts
1770
+ * normaliseVenueName("GMHBA Stadium"); // "Kardinia Park"
1771
+ * normaliseVenueName("Etihad Stadium"); // "Marvel Stadium"
1772
+ * normaliseVenueName("ENGIE Stadium"); // "Sydney Showground"
1773
+ * normaliseVenueName("People First Stadium"); // "Carrara"
1774
+ * ```
1775
+ */
1776
+ /**
1777
+ * Normalise a venue name to its canonical form.
1778
+ *
1779
+ * Performs a case-insensitive lookup against all known venue names,
1780
+ * sponsor names, and historical names. Returns the input unchanged
1781
+ * if no mapping is found.
1782
+ *
1783
+ * @param raw - The raw venue name string from any data source.
1784
+ * @returns The canonical venue name, or the trimmed input if unknown.
1785
+ */
1786
+ declare function normaliseVenueName(raw: string): string;
1762
1787
  import { z as z3 } from "zod/v4";
1763
1788
  /** Options for constructing an {@link AflApiClient}. */
1764
1789
  interface AflApiClientOptions {
@@ -2179,4 +2204,4 @@ declare function transformSquiggleGamesToFixture(games: readonly SquiggleGame[],
2179
2204
  * Transform Squiggle standings into LadderEntry objects.
2180
2205
  */
2181
2206
  declare function transformSquiggleStandings(standings: readonly SquiggleStanding[]): LadderEntry[];
2182
- export { transformSquiggleStandings, transformSquiggleGamesToResults, transformSquiggleGamesToFixture, transformPlayerStats, transformMatchRoster, transformMatchItems, transformLadderEntries, toAestString, parseFootyWireDate, parseAflTablesDate, parseAflApiDate, ok, normaliseTeamName, inferRoundType, fetchTeams2 as fetchTeams, fetchTeamStats2 as fetchTeamStats, fetchSquad2 as fetchSquad, fetchPlayerStats2 as fetchPlayerStats, fetchPlayerDetails, fetchMatchResults, fetchLineup, fetchLadder2 as fetchLadder, fetchFryziggStats, fetchFixture, fetchCoachesVotes, fetchAwards, err, computeLadder, ValidationError, UnsupportedSourceError, TeamStatsSummaryType, TeamStatsQuery, TeamStatsEntry, TeamScoreSchema, TeamScore, TeamQuery, TeamPlayersSchema, TeamPlayers, TeamListSchema, TeamList, TeamItemSchema, TeamItem, Team, SquiggleStandingsResponseSchema, SquiggleStandingsResponse, SquiggleStandingSchema, SquiggleStanding, SquiggleGamesResponseSchema, SquiggleGamesResponse, SquiggleGameSchema, SquiggleGame, SquiggleClientOptions, SquiggleClient, SquadSchema, SquadQuery, SquadPlayerItemSchema, SquadPlayerItem, SquadPlayerInnerSchema, SquadPlayer, SquadListSchema, SquadList, Squad, SeasonRoundQuery, ScrapeError, ScoreSchema, Score, RoundType, RoundSchema, RoundListSchema, RoundList, Round, RosterPlayerSchema, RosterPlayer, RisingStarNomination, Result, QuarterScore, PlayerStatsQuery, PlayerStatsListSchema, PlayerStatsList, PlayerStatsItemSchema, PlayerStatsItem, PlayerStats, PlayerGameStatsSchema, PlayerGameStats, PlayerDetailsQuery, PlayerDetails, PeriodScoreSchema, PeriodScore, Ok, MatchStatus, MatchRosterSchema, MatchRoster, MatchResult, MatchQuery, MatchItemSchema, MatchItemListSchema, MatchItemList, MatchItem, LineupQuery, LineupPlayer, Lineup, LadderResponseSchema, LadderResponse, LadderQuery, LadderEntryRawSchema, LadderEntryRaw, LadderEntry, Ladder, FootyWireClientOptions, FootyWireClient, Fixture, Err, DataSource, CompseasonSchema, CompseasonListSchema, CompseasonList, Compseason, CompetitionSchema, CompetitionListSchema, CompetitionList, CompetitionCode, Competition, CoachesVoteQuery, CoachesVote, CfsVenueSchema, CfsVenue, CfsScoreSchema, CfsScore, CfsMatchTeamSchema, CfsMatchTeam, CfsMatchSchema, CfsMatch, BrownlowVote, AwardType, AwardQuery, Award, AllAustralianSelection, AflTablesClientOptions, AflTablesClient, AflCoachesClientOptions, AflCoachesClient, AflApiTokenSchema, AflApiToken, AflApiError, AflApiClientOptions, AflApiClient };
2207
+ export { transformSquiggleStandings, transformSquiggleGamesToResults, transformSquiggleGamesToFixture, transformPlayerStats, transformMatchRoster, transformMatchItems, transformLadderEntries, toAestString, parseFootyWireDate, parseAflTablesDate, parseAflApiDate, ok, normaliseVenueName, normaliseTeamName, inferRoundType, fetchTeams2 as fetchTeams, fetchTeamStats2 as fetchTeamStats, fetchSquad2 as fetchSquad, fetchPlayerStats2 as fetchPlayerStats, fetchPlayerDetails, fetchMatchResults, fetchLineup, fetchLadder2 as fetchLadder, fetchFryziggStats, fetchFixture, fetchCoachesVotes, fetchAwards, err, computeLadder, ValidationError, UnsupportedSourceError, TeamStatsSummaryType, TeamStatsQuery, TeamStatsEntry, TeamScoreSchema, TeamScore, TeamQuery, TeamPlayersSchema, TeamPlayers, TeamListSchema, TeamList, TeamItemSchema, TeamItem, Team, SquiggleStandingsResponseSchema, SquiggleStandingsResponse, SquiggleStandingSchema, SquiggleStanding, SquiggleGamesResponseSchema, SquiggleGamesResponse, SquiggleGameSchema, SquiggleGame, SquiggleClientOptions, SquiggleClient, SquadSchema, SquadQuery, SquadPlayerItemSchema, SquadPlayerItem, SquadPlayerInnerSchema, SquadPlayer, SquadListSchema, SquadList, Squad, SeasonRoundQuery, ScrapeError, ScoreSchema, Score, RoundType, RoundSchema, RoundListSchema, RoundList, Round, RosterPlayerSchema, RosterPlayer, RisingStarNomination, Result, QuarterScore, PlayerStatsQuery, PlayerStatsListSchema, PlayerStatsList, PlayerStatsItemSchema, PlayerStatsItem, PlayerStats, PlayerGameStatsSchema, PlayerGameStats, PlayerDetailsQuery, PlayerDetails, PeriodScoreSchema, PeriodScore, Ok, MatchStatus, MatchRosterSchema, MatchRoster, MatchResult, MatchQuery, MatchItemSchema, MatchItemListSchema, MatchItemList, MatchItem, LineupQuery, LineupPlayer, Lineup, LadderResponseSchema, LadderResponse, LadderQuery, LadderEntryRawSchema, LadderEntryRaw, LadderEntry, Ladder, FootyWireClientOptions, FootyWireClient, Fixture, Err, DataSource, CompseasonSchema, CompseasonListSchema, CompseasonList, Compseason, CompetitionSchema, CompetitionListSchema, CompetitionList, CompetitionCode, Competition, CoachesVoteQuery, CoachesVote, CfsVenueSchema, CfsVenue, CfsScoreSchema, CfsScore, CfsMatchTeamSchema, CfsMatchTeam, CfsMatchSchema, CfsMatch, BrownlowVote, AwardType, AwardQuery, Award, AllAustralianSelection, AflTablesClientOptions, AflTablesClient, AflCoachesClientOptions, AflCoachesClient, AflApiTokenSchema, AflApiToken, AflApiError, AflApiClientOptions, AflApiClient };
package/dist/index.js CHANGED
@@ -283,6 +283,56 @@ function parseFloatOr0(text) {
283
283
  return Number.isNaN(n) ? 0 : n;
284
284
  }
285
285
 
286
+ // src/lib/venue-mapping.ts
287
+ var VENUE_ALIASES = [
288
+ ["MCG", "M.C.G.", "Melbourne Cricket Ground"],
289
+ ["SCG", "S.C.G.", "Sydney Cricket Ground"],
290
+ ["Marvel Stadium", "Docklands", "Etihad Stadium", "Telstra Dome", "Colonial Stadium"],
291
+ ["Kardinia Park", "GMHBA Stadium", "Simonds Stadium", "Skilled Stadium"],
292
+ ["Gabba", "The Gabba", "Brisbane Cricket Ground"],
293
+ [
294
+ "Sydney Showground",
295
+ "ENGIE Stadium",
296
+ "GIANTS Stadium",
297
+ "Showground Stadium",
298
+ "Sydney Showground Stadium"
299
+ ],
300
+ ["Accor Stadium", "Stadium Australia", "ANZ Stadium", "Homebush"],
301
+ ["Carrara", "People First Stadium", "Heritage Bank Stadium", "Metricon Stadium"],
302
+ ["Perth Stadium", "Optus Stadium"],
303
+ ["Adelaide Oval"],
304
+ ["Manuka Oval", "Corroboree Group Oval Manuka"],
305
+ ["Blundstone Arena", "Bellerive Oval"],
306
+ ["UTAS Stadium", "York Park", "University of Tasmania Stadium", "Aurora Stadium"],
307
+ ["TIO Stadium", "Marrara Oval"],
308
+ ["Traeger Park", "TIO Traeger Park"],
309
+ ["Mars Stadium", "Eureka Stadium"],
310
+ ["Cazalys Stadium", "Cazaly's Stadium"],
311
+ ["Jiangwan Stadium"],
312
+ ["Riverway Stadium"],
313
+ ["Norwood Oval"],
314
+ ["Subiaco Oval", "Subiaco"],
315
+ ["Football Park", "AAMI Stadium"],
316
+ ["Princes Park", "Ikon Park"],
317
+ ["Blacktown International Sportspark"],
318
+ ["Barossa Park", "Barossa Oval", "Adelaide Hills"],
319
+ ["Ninja Stadium", "Summit Sports Park"]
320
+ ];
321
+ var VENUE_ALIAS_MAP = (() => {
322
+ const map = /* @__PURE__ */ new Map();
323
+ for (const [canonical, ...aliases] of VENUE_ALIASES) {
324
+ map.set(canonical.toLowerCase(), canonical);
325
+ for (const alias of aliases) {
326
+ map.set(alias.toLowerCase(), canonical);
327
+ }
328
+ }
329
+ return map;
330
+ })();
331
+ function normaliseVenueName(raw) {
332
+ const trimmed = raw.trim();
333
+ return VENUE_ALIAS_MAP.get(trimmed.toLowerCase()) ?? trimmed;
334
+ }
335
+
286
336
  // src/transforms/footywire-player-stats.ts
287
337
  var BASIC_COLS = [
288
338
  "Player",
@@ -568,7 +618,7 @@ function transformMatchItems(items, season, competition, source = "afl-api") {
568
618
  roundNumber: item.round?.roundNumber ?? 0,
569
619
  roundType: inferRoundType(item.round?.name ?? ""),
570
620
  date: new Date(item.match.utcStartTime),
571
- venue: item.venue?.name ?? "",
621
+ venue: item.venue?.name ? normaliseVenueName(item.venue.name) : "",
572
622
  homeTeam: normaliseTeamName(item.match.homeTeam.name),
573
623
  awayTeam: normaliseTeamName(item.match.awayTeam.name),
574
624
  homeGoals: homeScore?.matchScore.goals ?? 0,
@@ -2264,7 +2314,7 @@ function transformSquiggleGamesToResults(games, season) {
2264
2314
  roundNumber: g.round,
2265
2315
  roundType: inferRoundType(g.roundname),
2266
2316
  date: new Date(g.unixtime * 1e3),
2267
- venue: g.venue,
2317
+ venue: normaliseVenueName(g.venue),
2268
2318
  homeTeam: normaliseTeamName(g.hteam),
2269
2319
  awayTeam: normaliseTeamName(g.ateam),
2270
2320
  homeGoals: g.hgoals ?? 0,
@@ -3700,6 +3750,7 @@ export {
3700
3750
  fetchTeams,
3701
3751
  inferRoundType,
3702
3752
  normaliseTeamName,
3753
+ normaliseVenueName,
3703
3754
  ok,
3704
3755
  parseAflApiDate,
3705
3756
  parseAflTablesDate,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "fitzroy",
3
- "version": "1.3.1",
4
- "description": "TypeScript library and CLI for AFL data match results, player stats, fixtures, ladders, and more",
3
+ "version": "1.4.0",
4
+ "description": "TypeScript port of the fitzRoy R package — programmatic access to AFL data including match results, player stats, fixtures, ladders, and more",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",