nhl-api-ts 0.2.0 → 0.2.1

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.
@@ -12,7 +12,7 @@ import { teams as fetchTeams, teamRoster } from '#src/api/teams.mjs';
12
12
  * @param params.apiSleepRate Seconds to sleep between team requests. Defaults to 1.
13
13
  * @example await client.helpers.gameIdsBySeason({ season: '20232024', gameTypes: [2] })
14
14
  */
15
- export const gameIdsBySeason = async (ctx, { season, gameTypes, apiSleepRate = 1, }) => {
15
+ export async function gameIdsBySeason(ctx, { season, gameTypes, apiSleepRate = 1, }) {
16
16
  const teams = await fetchTeams(ctx);
17
17
  const gameIds = [];
18
18
  for (const team of teams) {
@@ -33,7 +33,7 @@ export const gameIdsBySeason = async (ctx, { season, gameTypes, apiSleepRate = 1
33
33
  }
34
34
  }
35
35
  return gameIds;
36
- };
36
+ }
37
37
  /**
38
38
  * Gets every rostered player across all NHL teams for a given season. Each
39
39
  * player gets a `team` abbreviation and flattened `firstName` / `lastName`.
@@ -42,7 +42,7 @@ export const gameIdsBySeason = async (ctx, { season, gameTypes, apiSleepRate = 1
42
42
  * @param params.apiSleepRate Seconds to sleep between team requests. Defaults to 0.5.
43
43
  * @example await client.helpers.allPlayers({ season: '20232024' })
44
44
  */
45
- export const allPlayers = async (ctx, { season, apiSleepRate = 0.5 }) => {
45
+ export async function allPlayers(ctx, { season, apiSleepRate = 0.5 }) {
46
46
  const teams = await fetchTeams(ctx);
47
47
  console.error('Fetching all player base stats. This may take a while...');
48
48
  const outData = [];
@@ -63,7 +63,7 @@ export const allPlayers = async (ctx, { season, apiSleepRate = 0.5 }) => {
63
63
  }
64
64
  }
65
65
  return outData;
66
- };
66
+ }
67
67
  /**
68
68
  * Gets summary statistics for every skater in a given season, merged with
69
69
  * the roster info from `allPlayers` (stat fields win on key collisions).
@@ -73,7 +73,7 @@ export const allPlayers = async (ctx, { season, apiSleepRate = 0.5 }) => {
73
73
  * @param params.apiSleepRate Seconds to sleep between team requests. Defaults to 1.
74
74
  * @example await client.helpers.allPlayersSummaryStatistics({ season: '20232024' })
75
75
  */
76
- export const allPlayersSummaryStatistics = async (ctx, { season, apiSleepRate = 1 }) => {
76
+ export async function allPlayersSummaryStatistics(ctx, { season, apiSleepRate = 1 }) {
77
77
  console.error('WARNING: This method will take a while to run. In the event of rate limiting, you may need to increase the api_sleep_rate.');
78
78
  const players = await allPlayers(ctx, { season, apiSleepRate });
79
79
  const teams = await fetchTeams(ctx);
@@ -98,7 +98,7 @@ export const allPlayersSummaryStatistics = async (ctx, { season, apiSleepRate =
98
98
  : undefined;
99
99
  return player ? { ...player, ...statEntry } : statEntry;
100
100
  });
101
- };
101
+ }
102
102
  export const helpersApi = {
103
103
  gameIdsBySeason,
104
104
  allPlayers,
@@ -5,32 +5,32 @@ import type { Country, DraftYear, GlossaryEntry, SeasonRules, StatsConfig } from
5
5
  *
6
6
  * @example https://api.nhle.com/stats/rest/en/glossary?sort=fullName
7
7
  */
8
- export declare const glossary: (ctx: Context) => Promise<GlossaryEntry[]>;
8
+ export declare function glossary(ctx: Context): Promise<GlossaryEntry[]>;
9
9
  /**
10
10
  * Gets the stats API configuration, including available report types and
11
11
  * filters.
12
12
  *
13
13
  * @example https://api.nhle.com/stats/rest/en/config
14
14
  */
15
- export declare const config: (ctx: Context) => Promise<StatsConfig>;
15
+ export declare function config(ctx: Context): Promise<StatsConfig>;
16
16
  /**
17
17
  * Gets the list of countries recognized by the NHL.
18
18
  *
19
19
  * @example https://api.nhle.com/stats/rest/en/country
20
20
  */
21
- export declare const countries: (ctx: Context) => Promise<Country[]>;
21
+ export declare function countries(ctx: Context): Promise<Country[]>;
22
22
  /**
23
23
  * Gets rules and metadata for every NHL season on record.
24
24
  *
25
25
  * @example https://api.nhle.com/stats/rest/en/season
26
26
  */
27
- export declare const seasonSpecificRulesAndInfo: (ctx: Context) => Promise<SeasonRules[]>;
27
+ export declare function seasonSpecificRulesAndInfo(ctx: Context): Promise<SeasonRules[]>;
28
28
  /**
29
29
  * Gets the number of rounds for each NHL draft year.
30
30
  *
31
31
  * @example https://api.nhle.com/stats/rest/en/draft
32
32
  */
33
- export declare const draftYearAndRounds: (ctx: Context) => Promise<DraftYear[]>;
33
+ export declare function draftYearAndRounds(ctx: Context): Promise<DraftYear[]>;
34
34
  export declare const miscApi: {
35
35
  readonly glossary: typeof glossary;
36
36
  readonly config: typeof config;
package/dist/api/misc.mjs CHANGED
@@ -8,32 +8,42 @@ async function getData(ctx, resource) {
8
8
  *
9
9
  * @example https://api.nhle.com/stats/rest/en/glossary?sort=fullName
10
10
  */
11
- export const glossary = async (ctx) => getData(ctx, 'stats/rest/en/glossary?sort=fullName');
11
+ export async function glossary(ctx) {
12
+ return getData(ctx, 'stats/rest/en/glossary?sort=fullName');
13
+ }
12
14
  /**
13
15
  * Gets the stats API configuration, including available report types and
14
16
  * filters.
15
17
  *
16
18
  * @example https://api.nhle.com/stats/rest/en/config
17
19
  */
18
- export const config = async (ctx) => (await ctx.get(Endpoint.API_CORE, 'stats/rest/en/config')).json();
20
+ export async function config(ctx) {
21
+ return (await ctx.get(Endpoint.API_CORE, 'stats/rest/en/config')).json();
22
+ }
19
23
  /**
20
24
  * Gets the list of countries recognized by the NHL.
21
25
  *
22
26
  * @example https://api.nhle.com/stats/rest/en/country
23
27
  */
24
- export const countries = async (ctx) => getData(ctx, 'stats/rest/en/country');
28
+ export async function countries(ctx) {
29
+ return getData(ctx, 'stats/rest/en/country');
30
+ }
25
31
  /**
26
32
  * Gets rules and metadata for every NHL season on record.
27
33
  *
28
34
  * @example https://api.nhle.com/stats/rest/en/season
29
35
  */
30
- export const seasonSpecificRulesAndInfo = async (ctx) => getData(ctx, 'stats/rest/en/season');
36
+ export async function seasonSpecificRulesAndInfo(ctx) {
37
+ return getData(ctx, 'stats/rest/en/season');
38
+ }
31
39
  /**
32
40
  * Gets the number of rounds for each NHL draft year.
33
41
  *
34
42
  * @example https://api.nhle.com/stats/rest/en/draft
35
43
  */
36
- export const draftYearAndRounds = async (ctx) => getData(ctx, 'stats/rest/en/draft');
44
+ export async function draftYearAndRounds(ctx) {
45
+ return getData(ctx, 'stats/rest/en/draft');
46
+ }
37
47
  export const miscApi = {
38
48
  glossary,
39
49
  config,
@@ -7,9 +7,9 @@ import type { Id } from '#src/utils.mjs';
7
7
  * @param params.teamAbbr Team abbreviation, e.g. BUF, TOR
8
8
  * @example https://api-web.nhle.com/v1/prospects/BUF
9
9
  */
10
- export declare const prospectsByTeam: (ctx: Context, { teamAbbr }: {
10
+ export declare function prospectsByTeam(ctx: Context, { teamAbbr }: {
11
11
  teamAbbr: string;
12
- }) => Promise<Prospects>;
12
+ }): Promise<Prospects>;
13
13
  /**
14
14
  * Gets the roster for a given team and season, grouped by position
15
15
  * (forwards, defensemen, goalies). Same data as `teams.teamRoster`.
@@ -18,10 +18,10 @@ export declare const prospectsByTeam: (ctx: Context, { teamAbbr }: {
18
18
  * @param params.season Season in YYYYYYYY format, e.g. 20232024
19
19
  * @example https://api-web.nhle.com/v1/roster/BUF/20232024
20
20
  */
21
- export declare const playersByTeam: (ctx: Context, { teamAbbr, season }: {
21
+ export declare function playersByTeam(ctx: Context, { teamAbbr, season }: {
22
22
  teamAbbr: string;
23
23
  season: Id;
24
- }) => Promise<Roster>;
24
+ }): Promise<Roster>;
25
25
  export declare const playersApi: {
26
26
  readonly prospectsByTeam: typeof prospectsByTeam;
27
27
  readonly playersByTeam: typeof playersByTeam;
@@ -5,7 +5,9 @@ import { Endpoint } from '#src/http-client.mjs';
5
5
  * @param params.teamAbbr Team abbreviation, e.g. BUF, TOR
6
6
  * @example https://api-web.nhle.com/v1/prospects/BUF
7
7
  */
8
- export const prospectsByTeam = async (ctx, { teamAbbr }) => (await ctx.get(Endpoint.API_WEB_V1, `prospects/${teamAbbr}`)).json();
8
+ export async function prospectsByTeam(ctx, { teamAbbr }) {
9
+ return (await ctx.get(Endpoint.API_WEB_V1, `prospects/${teamAbbr}`)).json();
10
+ }
9
11
  /**
10
12
  * Gets the roster for a given team and season, grouped by position
11
13
  * (forwards, defensemen, goalies). Same data as `teams.teamRoster`.
@@ -14,5 +16,7 @@ export const prospectsByTeam = async (ctx, { teamAbbr }) => (await ctx.get(Endpo
14
16
  * @param params.season Season in YYYYYYYY format, e.g. 20232024
15
17
  * @example https://api-web.nhle.com/v1/roster/BUF/20232024
16
18
  */
17
- export const playersByTeam = async (ctx, { teamAbbr, season }) => (await ctx.get(Endpoint.API_WEB_V1, `roster/${teamAbbr}/${season}`)).json();
19
+ export async function playersByTeam(ctx, { teamAbbr, season }) {
20
+ return (await ctx.get(Endpoint.API_WEB_V1, `roster/${teamAbbr}/${season}`)).json();
21
+ }
18
22
  export const playersApi = { prospectsByTeam, playersByTeam };
@@ -21,18 +21,18 @@ export interface DailySchedule {
21
21
  * @throws RangeError If the date is not a valid YYYY-MM-DD date
22
22
  * @example await client.schedule.dailySchedule({ date: '2024-10-09' })
23
23
  */
24
- export declare const dailySchedule: (ctx: Context, { date }?: {
24
+ export declare function dailySchedule(ctx: Context, { date }?: {
25
25
  date?: string;
26
- }) => Promise<DailySchedule>;
26
+ }): Promise<DailySchedule>;
27
27
  /**
28
28
  * Gets NHL schedule for a week starting from the specified date.
29
29
  *
30
30
  * @param params.date Date in YYYY-MM-DD format. Defaults to "now".
31
31
  * @example https://api-web.nhle.com/v1/schedule/2024-10-09
32
32
  */
33
- export declare const weeklySchedule: (ctx: Context, { date }?: {
33
+ export declare function weeklySchedule(ctx: Context, { date }?: {
34
34
  date?: string;
35
- }) => Promise<WeeklySchedule>;
35
+ }): Promise<WeeklySchedule>;
36
36
  /**
37
37
  * Gets monthly schedule for a specified team.
38
38
  *
@@ -40,10 +40,10 @@ export declare const weeklySchedule: (ctx: Context, { date }?: {
40
40
  * @param params.month Month in YYYY-MM format. Defaults to "now".
41
41
  * @example https://api-web.nhle.com/v1/club-schedule/BUF/month/2023-11
42
42
  */
43
- export declare const teamMonthlySchedule: (ctx: Context, { teamAbbr, month }: {
43
+ export declare function teamMonthlySchedule(ctx: Context, { teamAbbr, month }: {
44
44
  teamAbbr: string;
45
45
  month?: string;
46
- }) => Promise<ClubScheduleGame[]>;
46
+ }): Promise<ClubScheduleGame[]>;
47
47
  /**
48
48
  * Gets weekly schedule for a specified team.
49
49
  *
@@ -51,10 +51,10 @@ export declare const teamMonthlySchedule: (ctx: Context, { teamAbbr, month }: {
51
51
  * @param params.date Date in YYYY-MM-DD format. Defaults to "now".
52
52
  * @example https://api-web.nhle.com/v1/club-schedule/BUF/week/2024-02-10
53
53
  */
54
- export declare const teamWeeklySchedule: (ctx: Context, { teamAbbr, date }: {
54
+ export declare function teamWeeklySchedule(ctx: Context, { teamAbbr, date }: {
55
55
  teamAbbr: string;
56
56
  date?: string;
57
- }) => Promise<ClubScheduleGame[]>;
57
+ }): Promise<ClubScheduleGame[]>;
58
58
  /**
59
59
  * Gets the full season schedule for a specified team.
60
60
  *
@@ -62,28 +62,28 @@ export declare const teamWeeklySchedule: (ctx: Context, { teamAbbr, date }: {
62
62
  * @param params.season Season in YYYYYYYY format, e.g. 20232024
63
63
  * @example https://api-web.nhle.com/v1/club-schedule-season/BUF/20232024
64
64
  */
65
- export declare const teamSeasonSchedule: (ctx: Context, { teamAbbr, season }: {
65
+ export declare function teamSeasonSchedule(ctx: Context, { teamAbbr, season }: {
66
66
  teamAbbr: string;
67
67
  season: Id;
68
- }) => Promise<TeamSeasonSchedule>;
68
+ }): Promise<TeamSeasonSchedule>;
69
69
  /**
70
70
  * Gets the schedule in calendar format for a specified date.
71
71
  *
72
72
  * @param params.date Date in YYYY-MM-DD format
73
73
  * @example https://api-web.nhle.com/v1/schedule-calendar/2023-11-08
74
74
  */
75
- export declare const calendarSchedule: (ctx: Context, { date }: {
75
+ export declare function calendarSchedule(ctx: Context, { date }: {
76
76
  date: string;
77
- }) => Promise<CalendarSchedule>;
77
+ }): Promise<CalendarSchedule>;
78
78
  /**
79
79
  * Gets all playoff series information up to the current round.
80
80
  *
81
81
  * @param params.season Season in YYYYYYYY format, e.g. 20232024
82
82
  * @example https://api-web.nhle.com/v1/playoff-series/carousel/20232024
83
83
  */
84
- export declare const playoffCarousel: (ctx: Context, { season }: {
84
+ export declare function playoffCarousel(ctx: Context, { season }: {
85
85
  season: Id;
86
- }) => Promise<PlayoffCarousel>;
86
+ }): Promise<PlayoffCarousel>;
87
87
  /**
88
88
  * Returns the schedule and results for a specified playoff series matchup.
89
89
  *
@@ -91,19 +91,19 @@ export declare const playoffCarousel: (ctx: Context, { season }: {
91
91
  * @param params.series Series letter, e.g. "a" (first round) through "o" (final)
92
92
  * @example https://api-web.nhle.com/v1/schedule/playoff-series/20232024/a
93
93
  */
94
- export declare const playoffSeriesSchedule: (ctx: Context, { season, series }: {
94
+ export declare function playoffSeriesSchedule(ctx: Context, { season, series }: {
95
95
  season: Id;
96
96
  series: string;
97
- }) => Promise<PlayoffSeriesSchedule>;
97
+ }): Promise<PlayoffSeriesSchedule>;
98
98
  /**
99
99
  * Returns the full playoff bracket for a given year.
100
100
  *
101
101
  * @param params.year Year the playoffs took place, e.g. 2024
102
102
  * @example https://api-web.nhle.com/v1/playoff-bracket/2024
103
103
  */
104
- export declare const playoffBracket: (ctx: Context, { year }: {
104
+ export declare function playoffBracket(ctx: Context, { year }: {
105
105
  year: Id;
106
- }) => Promise<PlayoffBracket>;
106
+ }): Promise<PlayoffBracket>;
107
107
  export declare const scheduleApi: {
108
108
  readonly dailySchedule: typeof dailySchedule;
109
109
  readonly weeklySchedule: typeof weeklySchedule;
@@ -1,5 +1,7 @@
1
1
  import { Endpoint } from '#src/http-client.mjs';
2
- const pad = (value, width = 2) => String(value).padStart(width, '0');
2
+ function pad(value, width = 2) {
3
+ return String(value).padStart(width, '0');
4
+ }
3
5
  /** Today's date (local time) as YYYY-MM-DD. */
4
6
  function today() {
5
7
  const now = new Date();
@@ -29,7 +31,7 @@ export function normalizeDate(date) {
29
31
  * @throws RangeError If the date is not a valid YYYY-MM-DD date
30
32
  * @example await client.schedule.dailySchedule({ date: '2024-10-09' })
31
33
  */
32
- export const dailySchedule = async (ctx, { date } = {}) => {
34
+ export async function dailySchedule(ctx, { date } = {}) {
33
35
  const resolvedDate = date ? normalizeDate(date) : today();
34
36
  const scheduleData = await (await ctx.get(Endpoint.API_WEB_V1, `schedule/${resolvedDate}`)).json();
35
37
  const responsePayload = {
@@ -46,17 +48,17 @@ export const dailySchedule = async (ctx, { date } = {}) => {
46
48
  responsePayload.numberOfGames = games.length;
47
49
  }
48
50
  return responsePayload;
49
- };
51
+ }
50
52
  /**
51
53
  * Gets NHL schedule for a week starting from the specified date.
52
54
  *
53
55
  * @param params.date Date in YYYY-MM-DD format. Defaults to "now".
54
56
  * @example https://api-web.nhle.com/v1/schedule/2024-10-09
55
57
  */
56
- export const weeklySchedule = async (ctx, { date } = {}) => {
58
+ export async function weeklySchedule(ctx, { date } = {}) {
57
59
  const res = date ? date : 'now';
58
60
  return (await ctx.get(Endpoint.API_WEB_V1, `schedule/${res}`)).json();
59
- };
61
+ }
60
62
  /**
61
63
  * Gets monthly schedule for a specified team.
62
64
  *
@@ -64,11 +66,11 @@ export const weeklySchedule = async (ctx, { date } = {}) => {
64
66
  * @param params.month Month in YYYY-MM format. Defaults to "now".
65
67
  * @example https://api-web.nhle.com/v1/club-schedule/BUF/month/2023-11
66
68
  */
67
- export const teamMonthlySchedule = async (ctx, { teamAbbr, month }) => {
69
+ export async function teamMonthlySchedule(ctx, { teamAbbr, month }) {
68
70
  const resource = `club-schedule/${teamAbbr}/month/${month ? month : 'now'}`;
69
71
  const response = await (await ctx.get(Endpoint.API_WEB_V1, resource)).json();
70
72
  return response.games ?? [];
71
- };
73
+ }
72
74
  /**
73
75
  * Gets weekly schedule for a specified team.
74
76
  *
@@ -76,11 +78,11 @@ export const teamMonthlySchedule = async (ctx, { teamAbbr, month }) => {
76
78
  * @param params.date Date in YYYY-MM-DD format. Defaults to "now".
77
79
  * @example https://api-web.nhle.com/v1/club-schedule/BUF/week/2024-02-10
78
80
  */
79
- export const teamWeeklySchedule = async (ctx, { teamAbbr, date }) => {
81
+ export async function teamWeeklySchedule(ctx, { teamAbbr, date }) {
80
82
  const resource = `club-schedule/${teamAbbr}/week/${date ? date : 'now'}`;
81
83
  const response = await (await ctx.get(Endpoint.API_WEB_V1, resource)).json();
82
84
  return response.games ?? [];
83
- };
85
+ }
84
86
  /**
85
87
  * Gets the full season schedule for a specified team.
86
88
  *
@@ -88,21 +90,27 @@ export const teamWeeklySchedule = async (ctx, { teamAbbr, date }) => {
88
90
  * @param params.season Season in YYYYYYYY format, e.g. 20232024
89
91
  * @example https://api-web.nhle.com/v1/club-schedule-season/BUF/20232024
90
92
  */
91
- export const teamSeasonSchedule = async (ctx, { teamAbbr, season }) => (await ctx.get(Endpoint.API_WEB_V1, `club-schedule-season/${teamAbbr}/${season}`)).json();
93
+ export async function teamSeasonSchedule(ctx, { teamAbbr, season }) {
94
+ return (await ctx.get(Endpoint.API_WEB_V1, `club-schedule-season/${teamAbbr}/${season}`)).json();
95
+ }
92
96
  /**
93
97
  * Gets the schedule in calendar format for a specified date.
94
98
  *
95
99
  * @param params.date Date in YYYY-MM-DD format
96
100
  * @example https://api-web.nhle.com/v1/schedule-calendar/2023-11-08
97
101
  */
98
- export const calendarSchedule = async (ctx, { date }) => (await ctx.get(Endpoint.API_WEB_V1, `schedule-calendar/${date}`)).json();
102
+ export async function calendarSchedule(ctx, { date }) {
103
+ return (await ctx.get(Endpoint.API_WEB_V1, `schedule-calendar/${date}`)).json();
104
+ }
99
105
  /**
100
106
  * Gets all playoff series information up to the current round.
101
107
  *
102
108
  * @param params.season Season in YYYYYYYY format, e.g. 20232024
103
109
  * @example https://api-web.nhle.com/v1/playoff-series/carousel/20232024
104
110
  */
105
- export const playoffCarousel = async (ctx, { season }) => (await ctx.get(Endpoint.API_WEB_V1, `playoff-series/carousel/${season}`)).json();
111
+ export async function playoffCarousel(ctx, { season }) {
112
+ return (await ctx.get(Endpoint.API_WEB_V1, `playoff-series/carousel/${season}`)).json();
113
+ }
106
114
  /**
107
115
  * Returns the schedule and results for a specified playoff series matchup.
108
116
  *
@@ -110,14 +118,18 @@ export const playoffCarousel = async (ctx, { season }) => (await ctx.get(Endpoin
110
118
  * @param params.series Series letter, e.g. "a" (first round) through "o" (final)
111
119
  * @example https://api-web.nhle.com/v1/schedule/playoff-series/20232024/a
112
120
  */
113
- export const playoffSeriesSchedule = async (ctx, { season, series }) => (await ctx.get(Endpoint.API_WEB_V1, `schedule/playoff-series/${season}/${series}`)).json();
121
+ export async function playoffSeriesSchedule(ctx, { season, series }) {
122
+ return (await ctx.get(Endpoint.API_WEB_V1, `schedule/playoff-series/${season}/${series}`)).json();
123
+ }
114
124
  /**
115
125
  * Returns the full playoff bracket for a given year.
116
126
  *
117
127
  * @param params.year Year the playoffs took place, e.g. 2024
118
128
  * @example https://api-web.nhle.com/v1/playoff-bracket/2024
119
129
  */
120
- export const playoffBracket = async (ctx, { year }) => (await ctx.get(Endpoint.API_WEB_V1, `playoff-bracket/${year}`)).json();
130
+ export async function playoffBracket(ctx, { year }) {
131
+ return (await ctx.get(Endpoint.API_WEB_V1, `playoff-bracket/${year}`)).json();
132
+ }
121
133
  export const scheduleApi = {
122
134
  dailySchedule,
123
135
  weeklySchedule,
@@ -12,17 +12,17 @@ import type { Id } from '#src/utils.mjs';
12
12
  * @throws RangeError If the season id is not found in the standings manifest
13
13
  * @example await client.standings.leagueStandings({ season: '20222023' })
14
14
  */
15
- export declare const leagueStandings: (ctx: Context, { date, season }?: {
15
+ export declare function leagueStandings(ctx: Context, { date, season }?: {
16
16
  date?: string;
17
17
  season?: Id;
18
- }) => Promise<LeagueStandings>;
18
+ }): Promise<LeagueStandings>;
19
19
  /**
20
20
  * Gets metadata for every historical NHL season: start/end dates and which
21
21
  * standings rules (conferences, divisions, wildcard, ties...) were in use.
22
22
  *
23
23
  * @example https://api-web.nhle.com/v1/standings-season
24
24
  */
25
- export declare const seasonStandingManifest: (ctx: Context) => Promise<StandingsSeason[]>;
25
+ export declare function seasonStandingManifest(ctx: Context): Promise<StandingsSeason[]>;
26
26
  export declare const standingsApi: {
27
27
  readonly leagueStandings: typeof leagueStandings;
28
28
  readonly seasonStandingManifest: typeof seasonStandingManifest;
@@ -10,7 +10,7 @@ import { Endpoint } from '#src/http-client.mjs';
10
10
  * @throws RangeError If the season id is not found in the standings manifest
11
11
  * @example await client.standings.leagueStandings({ season: '20222023' })
12
12
  */
13
- export const leagueStandings = async (ctx, { date, season } = {}) => {
13
+ export async function leagueStandings(ctx, { date, season } = {}) {
14
14
  if (season) {
15
15
  const seasons = await seasonStandingManifest(ctx);
16
16
  const seasonData = seasons.find((seasonEntry) => seasonEntry.id === Number(season));
@@ -21,17 +21,17 @@ export const leagueStandings = async (ctx, { date, season } = {}) => {
21
21
  }
22
22
  const res = date ? date : 'now';
23
23
  return (await ctx.get(Endpoint.API_WEB_V1, `standings/${res}`)).json();
24
- };
24
+ }
25
25
  /**
26
26
  * Gets metadata for every historical NHL season: start/end dates and which
27
27
  * standings rules (conferences, divisions, wildcard, ties...) were in use.
28
28
  *
29
29
  * @example https://api-web.nhle.com/v1/standings-season
30
30
  */
31
- export const seasonStandingManifest = async (ctx) => {
31
+ export async function seasonStandingManifest(ctx) {
32
32
  const response = await (await ctx.get(Endpoint.API_WEB_V1, 'standings-season')).json();
33
33
  return response.seasons ?? [];
34
- };
34
+ }
35
35
  export const standingsApi = {
36
36
  leagueStandings,
37
37
  seasonStandingManifest,
@@ -81,18 +81,18 @@ export interface GoalieStatsSummaryParams<Report extends keyof GoalieReportRows
81
81
  * @param params.teamAbbr Team abbreviation, e.g. BUF, TOR
82
82
  * @example https://api-web.nhle.com/v1/club-stats-season/TOR
83
83
  */
84
- export declare const gametypesPerSeasonDirectoryByTeam: (ctx: Context, { teamAbbr }: {
84
+ export declare function gametypesPerSeasonDirectoryByTeam(ctx: Context, { teamAbbr }: {
85
85
  teamAbbr: string;
86
- }) => Promise<ClubStatsSeason[]>;
86
+ }): Promise<ClubStatsSeason[]>;
87
87
  /**
88
88
  * Gets a player's career statistics and biographical information.
89
89
  *
90
90
  * @param params.playerId NHL player id, e.g. 8481528
91
91
  * @example https://api-web.nhle.com/v1/player/8481528/landing
92
92
  */
93
- export declare const playerCareerStats: (ctx: Context, { playerId }: {
93
+ export declare function playerCareerStats(ctx: Context, { playerId }: {
94
94
  playerId: Id;
95
- }) => Promise<PlayerLanding>;
95
+ }): Promise<PlayerLanding>;
96
96
  /**
97
97
  * Gets a player's game log for a specific season and game type.
98
98
  *
@@ -101,24 +101,24 @@ export declare const playerCareerStats: (ctx: Context, { playerId }: {
101
101
  * @param params.gameType 1=Preseason, 2=Regular season, 3=Playoffs
102
102
  * @example https://api-web.nhle.com/v1/player/8481528/game-log/20232024/2
103
103
  */
104
- export declare const playerGameLog: (ctx: Context, { playerId, seasonId, gameType, }: {
104
+ export declare function playerGameLog(ctx: Context, { playerId, seasonId, gameType, }: {
105
105
  playerId: Id;
106
106
  seasonId: Id;
107
107
  gameType: number;
108
- }) => Promise<GameLogEntry[]>;
108
+ }): Promise<GameLogEntry[]>;
109
109
  /**
110
110
  * Retrieves team summary statistics across one or more seasons.
111
111
  *
112
112
  * @example await client.stats.teamSummary({ startSeason: '20232024', endSeason: '20232024' })
113
113
  */
114
- export declare const teamSummary: (ctx: Context, { startSeason, endSeason, gameTypeId, isGame, isAggregate, sortExpr, start, limit, factCayenneExp, defaultCayenneExp, }: TeamSummaryParams) => Promise<TeamSummaryRow[]>;
114
+ export declare function teamSummary(ctx: Context, { startSeason, endSeason, gameTypeId, isGame, isAggregate, sortExpr, start, limit, factCayenneExp, defaultCayenneExp, }: TeamSummaryParams): Promise<TeamSummaryRow[]>;
115
115
  /**
116
116
  * Gets simplified skater statistics summary for specified seasons and
117
117
  * franchises.
118
118
  *
119
119
  * @example await client.stats.skaterStatsSummary({ startSeason: '20232024', endSeason: '20232024', franchiseId: 10 })
120
120
  */
121
- export declare const skaterStatsSummary: (ctx: Context, { startSeason, endSeason, franchiseId, gameTypeId, aggregate, sortExpr, start, limit, factCayenneExp, defaultCayenneExp, }: SkaterStatsSummaryParams) => Promise<SkaterReportRows['summary'][]>;
121
+ export declare function skaterStatsSummary(ctx: Context, { startSeason, endSeason, franchiseId, gameTypeId, aggregate, sortExpr, start, limit, factCayenneExp, defaultCayenneExp, }: SkaterStatsSummaryParams): Promise<SkaterReportRows['summary'][]>;
122
122
  /**
123
123
  * Retrieves skater statistics using a query context and specified report
124
124
  * type. Returns the full response (`{ data, total }`).
@@ -134,14 +134,14 @@ export declare const skaterStatsSummary: (ctx: Context, { startSeason, endSeason
134
134
  * ]);
135
135
  * await client.stats.skaterStatsWithQueryContext({ queryContext: context, reportType: 'summary' });
136
136
  */
137
- export declare const skaterStatsWithQueryContext: <Report extends keyof SkaterReportRows>(ctx: Context, { queryContext, reportType, sortExpr, aggregate, start, limit, }: SkaterStatsWithQueryContextParams<Report>) => Promise<StatsApiPage<SkaterReportRows[Report]>>;
137
+ export declare function skaterStatsWithQueryContext<Report extends keyof SkaterReportRows>(ctx: Context, { queryContext, reportType, sortExpr, aggregate, start, limit, }: SkaterStatsWithQueryContextParams<Report>): Promise<StatsApiPage<SkaterReportRows[Report]>>;
138
138
  /**
139
139
  * Retrieves goalie statistics with various filtering and aggregation
140
140
  * options.
141
141
  *
142
142
  * @example await client.stats.goalieStatsSummary({ startSeason: '20232024', statsType: 'advanced' })
143
143
  */
144
- export declare const goalieStatsSummary: <Report extends keyof GoalieReportRows = 'summary'>(ctx: Context, { startSeason, endSeason, statsType, gameTypeId, franchiseId, aggregate, sortExpr, start, limit, factCayenneExp, defaultCayenneExp, }: GoalieStatsSummaryParams<Report>) => Promise<GoalieReportRows[Report][]>;
144
+ export declare function goalieStatsSummary<Report extends keyof GoalieReportRows = 'summary'>(ctx: Context, { startSeason, endSeason, statsType, gameTypeId, franchiseId, aggregate, sortExpr, start, limit, factCayenneExp, defaultCayenneExp, }: GoalieStatsSummaryParams<Report>): Promise<GoalieReportRows[Report][]>;
145
145
  export declare const statsApi: {
146
146
  readonly gametypesPerSeasonDirectoryByTeam: typeof gametypesPerSeasonDirectoryByTeam;
147
147
  readonly playerCareerStats: typeof playerCareerStats;
@@ -13,14 +13,18 @@ const REPORTS_WITHOUT_GAMES_PLAYED = [
13
13
  * @param params.teamAbbr Team abbreviation, e.g. BUF, TOR
14
14
  * @example https://api-web.nhle.com/v1/club-stats-season/TOR
15
15
  */
16
- export const gametypesPerSeasonDirectoryByTeam = async (ctx, { teamAbbr }) => (await ctx.get(Endpoint.API_WEB_V1, `club-stats-season/${teamAbbr}`)).json();
16
+ export async function gametypesPerSeasonDirectoryByTeam(ctx, { teamAbbr }) {
17
+ return (await ctx.get(Endpoint.API_WEB_V1, `club-stats-season/${teamAbbr}`)).json();
18
+ }
17
19
  /**
18
20
  * Gets a player's career statistics and biographical information.
19
21
  *
20
22
  * @param params.playerId NHL player id, e.g. 8481528
21
23
  * @example https://api-web.nhle.com/v1/player/8481528/landing
22
24
  */
23
- export const playerCareerStats = async (ctx, { playerId }) => (await ctx.get(Endpoint.API_WEB_V1, `player/${playerId}/landing`)).json();
25
+ export async function playerCareerStats(ctx, { playerId }) {
26
+ return (await ctx.get(Endpoint.API_WEB_V1, `player/${playerId}/landing`)).json();
27
+ }
24
28
  /**
25
29
  * Gets a player's game log for a specific season and game type.
26
30
  *
@@ -29,16 +33,16 @@ export const playerCareerStats = async (ctx, { playerId }) => (await ctx.get(End
29
33
  * @param params.gameType 1=Preseason, 2=Regular season, 3=Playoffs
30
34
  * @example https://api-web.nhle.com/v1/player/8481528/game-log/20232024/2
31
35
  */
32
- export const playerGameLog = async (ctx, { playerId, seasonId, gameType, }) => {
36
+ export async function playerGameLog(ctx, { playerId, seasonId, gameType, }) {
33
37
  const data = await (await ctx.get(Endpoint.API_WEB_V1, `player/${playerId}/game-log/${seasonId}/${gameType}`)).json();
34
38
  return data.gameLog ?? [];
35
- };
39
+ }
36
40
  /**
37
41
  * Retrieves team summary statistics across one or more seasons.
38
42
  *
39
43
  * @example await client.stats.teamSummary({ startSeason: '20232024', endSeason: '20232024' })
40
44
  */
41
- export const teamSummary = async (ctx, { startSeason, endSeason, gameTypeId = 2, isGame = false, isAggregate = false, sortExpr, start = 0, limit = 50, factCayenneExp = 'gamesPlayed>1', defaultCayenneExp, }) => {
45
+ export async function teamSummary(ctx, { startSeason, endSeason, gameTypeId = 2, isGame = false, isAggregate = false, sortExpr, start = 0, limit = 50, factCayenneExp = 'gamesPlayed>1', defaultCayenneExp, }) {
42
46
  const effectiveSortExpr = sortExpr && sortExpr.length > 0
43
47
  ? sortExpr
44
48
  : [
@@ -63,14 +67,14 @@ export const teamSummary = async (ctx, { startSeason, endSeason, gameTypeId = 2,
63
67
  };
64
68
  const response = await (await ctx.get(Endpoint.API_STATS, 'en/team/summary', qParams)).json();
65
69
  return response.data;
66
- };
70
+ }
67
71
  /**
68
72
  * Gets simplified skater statistics summary for specified seasons and
69
73
  * franchises.
70
74
  *
71
75
  * @example await client.stats.skaterStatsSummary({ startSeason: '20232024', endSeason: '20232024', franchiseId: 10 })
72
76
  */
73
- export const skaterStatsSummary = async (ctx, { startSeason, endSeason, franchiseId, gameTypeId = 2, aggregate = false, sortExpr, start = 0, limit = 25, factCayenneExp = 'gamesPlayed>=1', defaultCayenneExp, }) => {
77
+ export async function skaterStatsSummary(ctx, { startSeason, endSeason, franchiseId, gameTypeId = 2, aggregate = false, sortExpr, start = 0, limit = 25, factCayenneExp = 'gamesPlayed>=1', defaultCayenneExp, }) {
74
78
  const effectiveSortExpr = sortExpr && sortExpr.length > 0
75
79
  ? sortExpr
76
80
  : [
@@ -94,7 +98,7 @@ export const skaterStatsSummary = async (ctx, { startSeason, endSeason, franchis
94
98
  };
95
99
  const response = await (await ctx.get(Endpoint.API_STATS, 'en/skater/summary', qParams)).json();
96
100
  return response.data;
97
- };
101
+ }
98
102
  /**
99
103
  * Retrieves skater statistics using a query context and specified report
100
104
  * type. Returns the full response (`{ data, total }`).
@@ -110,7 +114,7 @@ export const skaterStatsSummary = async (ctx, { startSeason, endSeason, franchis
110
114
  * ]);
111
115
  * await client.stats.skaterStatsWithQueryContext({ queryContext: context, reportType: 'summary' });
112
116
  */
113
- export const skaterStatsWithQueryContext = async (ctx, { queryContext, reportType, sortExpr, aggregate = false, start = 0, limit = 25, }) => {
117
+ export async function skaterStatsWithQueryContext(ctx, { queryContext, reportType, sortExpr, aggregate = false, start = 0, limit = 25, }) {
114
118
  const effectiveSortExpr = sortExpr && sortExpr.length > 0
115
119
  ? sortExpr
116
120
  : defaultSortForReport(reportType);
@@ -127,14 +131,14 @@ export const skaterStatsWithQueryContext = async (ctx, { queryContext, reportTyp
127
131
  cayenneExp: queryContext.query,
128
132
  };
129
133
  return (await ctx.get(Endpoint.API_STATS, `en/skater/${reportType}`, qParams)).json();
130
- };
134
+ }
131
135
  /**
132
136
  * Retrieves goalie statistics with various filtering and aggregation
133
137
  * options.
134
138
  *
135
139
  * @example await client.stats.goalieStatsSummary({ startSeason: '20232024', statsType: 'advanced' })
136
140
  */
137
- export const goalieStatsSummary = async (ctx, { startSeason, endSeason, statsType, gameTypeId = 2, franchiseId, aggregate = false, sortExpr, start = 0, limit = 25, factCayenneExp, defaultCayenneExp, }) => {
141
+ export async function goalieStatsSummary(ctx, { startSeason, endSeason, statsType, gameTypeId = 2, franchiseId, aggregate = false, sortExpr, start = 0, limit = 25, factCayenneExp, defaultCayenneExp, }) {
138
142
  const report = statsType ?? 'summary';
139
143
  const effectiveEndSeason = endSeason === undefined || endSeason === null ? startSeason : endSeason;
140
144
  const effectiveSortExpr = sortExpr && sortExpr.length > 0 ? sortExpr : goalieStatsSorts(report);
@@ -154,7 +158,7 @@ export const goalieStatsSummary = async (ctx, { startSeason, endSeason, statsTyp
154
158
  };
155
159
  const response = await (await ctx.get(Endpoint.API_STATS, `en/goalie/${report}`, qParams)).json();
156
160
  return response.data ?? [];
157
- };
161
+ }
158
162
  export const statsApi = {
159
163
  gametypesPerSeasonDirectoryByTeam,
160
164
  playerCareerStats,