nhl-api-ts 0.2.0 → 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.
Files changed (51) hide show
  1. package/README.md +81 -9
  2. package/dist/api/draft.d.mts +61 -0
  3. package/dist/api/draft.mjs +68 -0
  4. package/dist/api/edge.d.mts +221 -24
  5. package/dist/api/edge.mjs +276 -27
  6. package/dist/api/game-center.d.mts +63 -15
  7. package/dist/api/game-center.mjs +67 -8
  8. package/dist/api/helpers.d.mts +6 -6
  9. package/dist/api/helpers.mjs +6 -6
  10. package/dist/api/misc.d.mts +120 -6
  11. package/dist/api/misc.mjs +162 -7
  12. package/dist/api/players.d.mts +59 -7
  13. package/dist/api/players.mjs +85 -4
  14. package/dist/api/query/cayenne.d.mts +4 -0
  15. package/dist/api/query/cayenne.mjs +13 -0
  16. package/dist/api/query/sorting/sorting-options.d.mts +8 -0
  17. package/dist/api/query/sorting/sorting-options.mjs +30 -0
  18. package/dist/api/schedule.d.mts +36 -23
  19. package/dist/api/schedule.mjs +40 -16
  20. package/dist/api/standings.d.mts +3 -3
  21. package/dist/api/standings.mjs +4 -4
  22. package/dist/api/stats.d.mts +105 -16
  23. package/dist/api/stats.mjs +145 -41
  24. package/dist/api/teams.d.mts +48 -8
  25. package/dist/api/teams.mjs +59 -7
  26. package/dist/cli/colors.d.mts +2 -2
  27. package/dist/cli/colors.mjs +6 -2
  28. package/dist/cli/commands.mjs +521 -46
  29. package/dist/cli/run.mjs +7 -5
  30. package/dist/http-client.d.mts +2 -1
  31. package/dist/http-client.mjs +10 -3
  32. package/dist/index.d.mts +8 -2
  33. package/dist/index.mjs +3 -0
  34. package/dist/nhl-client.d.mts +70 -15
  35. package/dist/nhl-client.mjs +40 -17
  36. package/dist/types/common.d.mts +0 -1
  37. package/dist/types/draft.d.mts +97 -0
  38. package/dist/types/draft.mjs +1 -0
  39. package/dist/types/edge.d.mts +301 -5
  40. package/dist/types/game-center.d.mts +277 -119
  41. package/dist/types/index.d.mts +1 -0
  42. package/dist/types/misc.d.mts +101 -0
  43. package/dist/types/misc.mjs +0 -1
  44. package/dist/types/players.d.mts +23 -2
  45. package/dist/types/schedule.d.mts +50 -62
  46. package/dist/types/standings.d.mts +1 -2
  47. package/dist/types/stats.d.mts +313 -111
  48. package/dist/types/teams.d.mts +29 -1
  49. package/dist/utils.d.mts +1 -1
  50. package/dist/utils.mjs +3 -1
  51. package/package.json +7 -28
@@ -1,3 +1,5 @@
1
+ import { andClauses, cayenneString } from '#src/api/query/cayenne.mjs';
2
+ import { filter, toQuery, } from '#src/api/query/filters.mjs';
1
3
  import { Endpoint } from '#src/http-client.mjs';
2
4
  /**
3
5
  * Gets prospects for a specific team, grouped by position.
@@ -5,14 +7,93 @@ import { Endpoint } from '#src/http-client.mjs';
5
7
  * @param params.teamAbbr Team abbreviation, e.g. BUF, TOR
6
8
  * @example https://api-web.nhle.com/v1/prospects/BUF
7
9
  */
8
- export const prospectsByTeam = async (ctx, { teamAbbr }) => (await ctx.get(Endpoint.API_WEB_V1, `prospects/${teamAbbr}`)).json();
10
+ export async function prospectsByTeam(ctx, { teamAbbr }) {
11
+ return (await ctx.get(Endpoint.API_WEB_V1, `prospects/${teamAbbr}`)).json();
12
+ }
9
13
  /**
10
14
  * Gets the roster for a given team and season, grouped by position
11
15
  * (forwards, defensemen, goalies). Same data as `teams.teamRoster`.
12
16
  *
13
17
  * @param params.teamAbbr Team abbreviation, e.g. BUF, TOR
14
- * @param params.season Season in YYYYYYYY format, e.g. 20232024
18
+ * @param params.season Season in YYYYYYYY format, e.g. 20232024. Defaults to
19
+ * the current season (`current`; this endpoint has no `now` alias).
15
20
  * @example https://api-web.nhle.com/v1/roster/BUF/20232024
16
21
  */
17
- export const playersByTeam = async (ctx, { teamAbbr, season }) => (await ctx.get(Endpoint.API_WEB_V1, `roster/${teamAbbr}/${season}`)).json();
18
- export const playersApi = { prospectsByTeam, playersByTeam };
22
+ export async function playersByTeam(ctx, { teamAbbr, season }) {
23
+ return (await ctx.get(Endpoint.API_WEB_V1, `roster/${teamAbbr}/${season ?? 'current'}`)).json();
24
+ }
25
+ /**
26
+ * Gets the players featured in the nhl.com player spotlight.
27
+ *
28
+ * @example https://api-web.nhle.com/v1/player-spotlight
29
+ */
30
+ export async function playerSpotlight(ctx) {
31
+ return (await ctx.get(Endpoint.API_WEB_V1, 'player-spotlight')).json();
32
+ }
33
+ function playerSearchClauses({ name, teamId, position, cayenneExp, }) {
34
+ const clauses = [];
35
+ if (name?.trim()) {
36
+ clauses.push(`fullName likeIgnoreCase ${cayenneString(`%${name.trim()}%`)}`);
37
+ }
38
+ if (teamId !== undefined && teamId !== null) {
39
+ clauses.push(`currentTeamId=${teamId}`);
40
+ }
41
+ if (position !== undefined) {
42
+ clauses.push(position === 'G'
43
+ ? "positionCode='G'"
44
+ : toQuery(filter.position(position)));
45
+ }
46
+ if (cayenneExp?.trim()) {
47
+ clauses.push(cayenneExp);
48
+ }
49
+ return clauses;
50
+ }
51
+ /**
52
+ * Searches every player on record, past and present. Returns the full page
53
+ * (`{ data, total }`): the API sends **at most 5 rows** per request, whatever
54
+ * the limit, so page with `start` until you have `total` rows.
55
+ *
56
+ * @param params.name Case-insensitive part of the full name, e.g. "matth"
57
+ * @param params.teamId NHL team id of the current team, e.g. 10
58
+ * @param params.position C, L, R, D, G, or F for every forward
59
+ * @param params.cayenneExp Extra filter expression, e.g. "sweaterNumber=34"
60
+ * @param params.sort Field to sort by, e.g. "lastName"
61
+ * @param params.dir ASC or DESC
62
+ * @param params.start Pagination offset
63
+ * @param params.include Only return these fields, e.g. ['id', 'fullName']
64
+ * @param params.exclude Leave out these fields
65
+ * @throws RangeError When no filter is given (the API would return no rows)
66
+ * @example await client.players.playerSearch({ name: 'matthews', position: 'C' })
67
+ */
68
+ export async function playerSearch(ctx, params) {
69
+ const { sort, dir, start, include, exclude } = params;
70
+ const clauses = playerSearchClauses(params);
71
+ if (clauses.length === 0) {
72
+ throw new RangeError('Missing filter. Pass name, teamId, position or cayenneExp.');
73
+ }
74
+ const query = {
75
+ cayenneExp: andClauses(clauses),
76
+ };
77
+ if (sort !== undefined) {
78
+ query.sort = sort;
79
+ }
80
+ if (dir !== undefined) {
81
+ query.dir = dir;
82
+ }
83
+ if (start !== undefined) {
84
+ query.start = start;
85
+ }
86
+ if (include && include.length > 0) {
87
+ query.include = include;
88
+ }
89
+ if (exclude && exclude.length > 0) {
90
+ query.exclude = exclude;
91
+ }
92
+ return (await ctx.get(Endpoint.API_STATS, 'en/players', query)).json();
93
+ }
94
+ export const playersApi = {
95
+ prospectsByTeam,
96
+ playersByTeam,
97
+ playerSpotlight,
98
+ playerSearch,
99
+ };
@@ -0,0 +1,4 @@
1
+ /** Quotes a value as a cayenne string literal, backslash-escaping `\` and `'`. */
2
+ export declare function cayenneString(value: string): string;
3
+ /** Joins clauses with `and`, parenthesizing each when there is more than one. */
4
+ export declare function andClauses(clauses: readonly string[]): string;
@@ -0,0 +1,13 @@
1
+ // Internal helpers for SDK methods that build their own `cayenneExp`. Not
2
+ // exported from the package: `buildQuery` / `filter` cover the report filters.
3
+ /** Quotes a value as a cayenne string literal, backslash-escaping `\` and `'`. */
4
+ export function cayenneString(value) {
5
+ return `'${value.replace(/[\\']/g, (char) => `\\${char}`)}'`;
6
+ }
7
+ /** Joins clauses with `and`, parenthesizing each when there is more than one. */
8
+ export function andClauses(clauses) {
9
+ if (clauses.length === 1) {
10
+ return clauses[0];
11
+ }
12
+ return clauses.map((clause) => `(${clause})`).join(' and ');
13
+ }
@@ -133,4 +133,12 @@ export declare const SKATER_REPORT_TYPES: string[];
133
133
  * summary sort for unknown report types.
134
134
  */
135
135
  export declare function defaultSortForReport(report: string): SortExpr[];
136
+ /**
137
+ * Default sort criteria for a team summary. Falls back to points and wins.
138
+ */
139
+ export declare function defaultSortForTeamSummary(expr: SortExpr[] | undefined, isAggregate: boolean): SortExpr[];
140
+ /**
141
+ * Default sort criteria for a skater stats summary. Falls back to points
142
+ */
143
+ export declare function defaultSortForSkaterStatsSummary(expr: SortExpr[] | undefined): SortExpr[];
136
144
  export {};
@@ -92,3 +92,33 @@ export function defaultSortForReport(report) {
92
92
  ? sortingLookup[report]
93
93
  : undefined) ?? skaterSummaryDefaultSorting);
94
94
  }
95
+ /**
96
+ * Default sort criteria for a team summary. Falls back to points and wins.
97
+ */
98
+ export function defaultSortForTeamSummary(expr, isAggregate) {
99
+ if (expr && expr.length > 0) {
100
+ return expr;
101
+ }
102
+ return [
103
+ { property: 'points', direction: 'DESC' },
104
+ { property: 'wins', direction: 'DESC' },
105
+ // aggregated rows span seasons, so they have no teamId
106
+ {
107
+ property: isAggregate ? 'franchiseId' : 'teamId',
108
+ direction: 'ASC',
109
+ },
110
+ ];
111
+ }
112
+ /**
113
+ * Default sort criteria for a skater stats summary. Falls back to points
114
+ */
115
+ export function defaultSortForSkaterStatsSummary(expr) {
116
+ if (expr && expr.length > 0) {
117
+ return expr;
118
+ }
119
+ return [
120
+ { property: 'points', direction: 'DESC' },
121
+ { property: 'gamesPlayed', direction: 'ASC' },
122
+ { property: 'playerId', direction: 'ASC' },
123
+ ];
124
+ }
@@ -1,5 +1,5 @@
1
1
  import type { Context } from '#src/context.mjs';
2
- import type { CalendarSchedule, ClubScheduleGame, OddsPartner, PlayoffBracket, PlayoffCarousel, PlayoffSeriesSchedule, ScheduleGame, TeamSeasonSchedule, WeeklySchedule } from '#src/types/index.mjs';
2
+ import type { CalendarSchedule, ClubScheduleGame, OddsPartner, PlayoffBracket, PlayoffCarousel, PlayoffSeriesMeta, PlayoffSeriesSchedule, ScheduleGame, TeamSeasonSchedule, WeeklySchedule } from '#src/types/index.mjs';
3
3
  import type { Id } from '#src/utils.mjs';
4
4
  /**
5
5
  * Parses and normalizes a YYYY-MM-DD date: single-digit months/days are
@@ -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,39 +51,39 @@ 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
  *
61
61
  * @param params.teamAbbr Team abbreviation, e.g. BUF, TOR
62
- * @param params.season Season in YYYYYYYY format, e.g. 20232024
62
+ * @param params.season Season in YYYYYYYY format, e.g. 20232024. Defaults to "now".
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
- season: Id;
68
- }) => Promise<TeamSeasonSchedule>;
67
+ season?: Id;
68
+ }): Promise<TeamSeasonSchedule>;
69
69
  /**
70
70
  * Gets the schedule in calendar format for a specified date.
71
71
  *
72
- * @param params.date Date in YYYY-MM-DD format
72
+ * @param params.date Date in YYYY-MM-DD format. Defaults to "now".
73
73
  * @example https://api-web.nhle.com/v1/schedule-calendar/2023-11-08
74
74
  */
75
- export declare const calendarSchedule: (ctx: Context, { date }: {
76
- date: string;
77
- }) => Promise<CalendarSchedule>;
75
+ export declare function calendarSchedule(ctx: Context, { date }?: {
76
+ date?: string;
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,31 @@ 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
+ /**
99
+ * Returns the metadata nhl.com uses to render a playoff series page: the
100
+ * round title and the two seeded teams.
101
+ *
102
+ * @param params.year Year the playoffs took place, e.g. 2024
103
+ * @param params.series Series letter, e.g. "a" (first round) through "o" (final). Case-insensitive.
104
+ * @example https://api-web.nhle.com/v1/meta/playoff-series/2024/a
105
+ */
106
+ export declare function playoffSeriesMeta(ctx: Context, { year, series }: {
107
+ year: Id;
108
+ series: string;
109
+ }): Promise<PlayoffSeriesMeta>;
98
110
  /**
99
111
  * Returns the full playoff bracket for a given year.
100
112
  *
101
113
  * @param params.year Year the playoffs took place, e.g. 2024
102
114
  * @example https://api-web.nhle.com/v1/playoff-bracket/2024
103
115
  */
104
- export declare const playoffBracket: (ctx: Context, { year }: {
116
+ export declare function playoffBracket(ctx: Context, { year }: {
105
117
  year: Id;
106
- }) => Promise<PlayoffBracket>;
118
+ }): Promise<PlayoffBracket>;
107
119
  export declare const scheduleApi: {
108
120
  readonly dailySchedule: typeof dailySchedule;
109
121
  readonly weeklySchedule: typeof weeklySchedule;
@@ -113,5 +125,6 @@ export declare const scheduleApi: {
113
125
  readonly calendarSchedule: typeof calendarSchedule;
114
126
  readonly playoffCarousel: typeof playoffCarousel;
115
127
  readonly playoffSeriesSchedule: typeof playoffSeriesSchedule;
128
+ readonly playoffSeriesMeta: typeof playoffSeriesMeta;
116
129
  readonly playoffBracket: typeof playoffBracket;
117
130
  };
@@ -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,33 +78,39 @@ 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
  *
87
89
  * @param params.teamAbbr Team abbreviation, e.g. BUF, TOR
88
- * @param params.season Season in YYYYYYYY format, e.g. 20232024
90
+ * @param params.season Season in YYYYYYYY format, e.g. 20232024. Defaults to "now".
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 ?? 'now'}`)).json();
95
+ }
92
96
  /**
93
97
  * Gets the schedule in calendar format for a specified date.
94
98
  *
95
- * @param params.date Date in YYYY-MM-DD format
99
+ * @param params.date Date in YYYY-MM-DD format. Defaults to "now".
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 ?? 'now'}`)).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,29 @@ 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
+ }
124
+ /**
125
+ * Returns the metadata nhl.com uses to render a playoff series page: the
126
+ * round title and the two seeded teams.
127
+ *
128
+ * @param params.year Year the playoffs took place, e.g. 2024
129
+ * @param params.series Series letter, e.g. "a" (first round) through "o" (final). Case-insensitive.
130
+ * @example https://api-web.nhle.com/v1/meta/playoff-series/2024/a
131
+ */
132
+ export async function playoffSeriesMeta(ctx, { year, series }) {
133
+ return (await ctx.get(Endpoint.API_WEB_V1, `meta/playoff-series/${year}/${series}`)).json();
134
+ }
114
135
  /**
115
136
  * Returns the full playoff bracket for a given year.
116
137
  *
117
138
  * @param params.year Year the playoffs took place, e.g. 2024
118
139
  * @example https://api-web.nhle.com/v1/playoff-bracket/2024
119
140
  */
120
- export const playoffBracket = async (ctx, { year }) => (await ctx.get(Endpoint.API_WEB_V1, `playoff-bracket/${year}`)).json();
141
+ export async function playoffBracket(ctx, { year }) {
142
+ return (await ctx.get(Endpoint.API_WEB_V1, `playoff-bracket/${year}`)).json();
143
+ }
121
144
  export const scheduleApi = {
122
145
  dailySchedule,
123
146
  weeklySchedule,
@@ -127,5 +150,6 @@ export const scheduleApi = {
127
150
  calendarSchedule,
128
151
  playoffCarousel,
129
152
  playoffSeriesSchedule,
153
+ playoffSeriesMeta,
130
154
  playoffBracket,
131
155
  };
@@ -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,