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,4 +1,5 @@
1
1
  export type * from '#src/types/common.mjs';
2
+ export type * from '#src/types/draft.mjs';
2
3
  export type * from '#src/types/edge.mjs';
3
4
  export type * from '#src/types/game-center.mjs';
4
5
  export type * from '#src/types/helpers.mjs';
@@ -1,3 +1,11 @@
1
+ import type { GameType, LocalizedString, OddsPartner, OpenUnion } from '#src/types/common.mjs';
2
+ import type { MetaTeam } from '#src/types/game-center.mjs';
3
+ export interface ComponentSeason {
4
+ id: string;
5
+ component: string;
6
+ gameTypeId: GameType;
7
+ seasonId: number;
8
+ }
1
9
  export interface Country {
2
10
  id: string;
3
11
  country3Code: string;
@@ -16,6 +24,9 @@ export interface DraftYear {
16
24
  draftYear: number;
17
25
  rounds: number;
18
26
  }
27
+ export interface GeoLocation {
28
+ country: string;
29
+ }
19
30
  export interface GlossaryEntry {
20
31
  id: number;
21
32
  abbreviation: string;
@@ -25,6 +36,62 @@ export interface GlossaryEntry {
25
36
  languageCode: string;
26
37
  lastUpdated: string;
27
38
  }
39
+ export interface Meta {
40
+ players: MetaPlayer[];
41
+ teams: MetaTeam[];
42
+ /** Empty in every observed response */
43
+ seasonStates: unknown[];
44
+ }
45
+ export interface MetaPlayer {
46
+ playerId: number;
47
+ playerSlug: string;
48
+ actionShot: string;
49
+ name: LocalizedString;
50
+ currentTeams: MetaPlayerTeam[];
51
+ isGoalie: boolean;
52
+ }
53
+ export interface MetaPlayerTeam {
54
+ teamId: number;
55
+ abbrev: string;
56
+ force: boolean;
57
+ }
58
+ export interface PartnerGameOdd {
59
+ description: OpenUnion<'MONEY_LINE_2_WAY' | 'MONEY_LINE_3_WAY' | 'OVER_UNDER' | 'PUCK_LINE'>;
60
+ value: number;
61
+ /** The line, e.g. "-1.5" or "O5.5"; "Draw" for the 3-way draw price; "" otherwise */
62
+ qualifier: string;
63
+ }
64
+ export interface PartnerGameOdds {
65
+ currentOddsDate: string;
66
+ lastUpdatedUTC: string;
67
+ bettingPartner: OddsPartner;
68
+ games: PartnerGameOddsGame[];
69
+ }
70
+ export interface PartnerGameOddsGame {
71
+ gameId: number;
72
+ gameType: GameType;
73
+ startTimeUTC: string;
74
+ homeTeam: PartnerGameOddsTeam;
75
+ awayTeam: PartnerGameOddsTeam;
76
+ }
77
+ export interface PartnerGameOddsTeam {
78
+ id: number;
79
+ name: LocalizedString;
80
+ abbrev: string;
81
+ logo: string;
82
+ odds: PartnerGameOdd[];
83
+ }
84
+ export interface PostalLookupTeam {
85
+ stateProvince: string;
86
+ teamName: LocalizedString;
87
+ postalCode: string;
88
+ country: string;
89
+ city: string;
90
+ /** Absent for Canadian postal codes */
91
+ networkType?: string;
92
+ /** Absent for Canadian postal codes */
93
+ county?: string;
94
+ }
28
95
  export interface ReportColumns {
29
96
  displayItems: string[];
30
97
  resultFilters: string[];
@@ -66,3 +133,37 @@ export interface StatsConfig {
66
133
  aggregatedColumns: string[];
67
134
  individualColumns: string[];
68
135
  }
136
+ /** One game of the stats API (`en/game`). */
137
+ export interface StatsGame {
138
+ id: number;
139
+ easternStartTime: string;
140
+ gameDate: string;
141
+ gameNumber: number;
142
+ gameScheduleStateId: number;
143
+ gameStateId: number;
144
+ gameType: GameType;
145
+ homeScore: number;
146
+ homeTeamId: number;
147
+ period: number;
148
+ season: number;
149
+ visitingScore: number;
150
+ visitingTeamId: number;
151
+ }
152
+ export interface TvSchedule {
153
+ date: string;
154
+ startDate: string;
155
+ endDate: string;
156
+ broadcasts: TvScheduleBroadcast[];
157
+ }
158
+ export interface TvScheduleBroadcast {
159
+ startTime: string;
160
+ endTime: string;
161
+ durationSeconds: number;
162
+ title: string;
163
+ description: string;
164
+ houseNumber: string;
165
+ broadcastType: OpenUnion<'HD'>;
166
+ /** "LIVE" for live games, "" otherwise */
167
+ broadcastStatus: OpenUnion<'LIVE' | ''>;
168
+ broadcastImageUrl: string;
169
+ }
@@ -1,2 +1 @@
1
- // Response types derived from live NHL API probing. See CONTRIBUTING.md.
2
1
  export {};
@@ -1,5 +1,17 @@
1
1
  import type { LocalizedString, PositionCode, ShootsCatches } from '#src/types/common.mjs';
2
2
  import type { RosterPlayer } from '#src/types/teams.mjs';
3
+ export interface PlayerSpotlight {
4
+ playerId: number;
5
+ name: LocalizedString;
6
+ playerSlug: string;
7
+ position: PositionCode;
8
+ sweaterNumber: number;
9
+ teamId: number;
10
+ headshot: string;
11
+ teamTriCode: string;
12
+ teamLogo: string;
13
+ sortId: number;
14
+ }
3
15
  export interface Prospects {
4
16
  forwards: ProspectsForward[];
5
17
  defensemen: RosterPlayer[];
@@ -19,7 +31,7 @@ export interface ProspectsForward {
19
31
  birthDate: string;
20
32
  birthCity: LocalizedString;
21
33
  birthCountry: string;
22
- /** Absent when team=TOR. Low sample count */
34
+ /** Only for players born in the USA or Canada */
23
35
  birthStateProvince?: LocalizedString;
24
36
  sweaterNumber?: number;
25
37
  }
@@ -28,7 +40,6 @@ export interface ProspectsGoalie {
28
40
  headshot: string;
29
41
  firstName: LocalizedString;
30
42
  lastName: LocalizedString;
31
- /** Low sample count */
32
43
  sweaterNumber?: number;
33
44
  positionCode: PositionCode;
34
45
  shootsCatches: ShootsCatches;
@@ -40,3 +51,13 @@ export interface ProspectsGoalie {
40
51
  birthCity: LocalizedString;
41
52
  birthCountry: string;
42
53
  }
54
+ /** One row of the stats API player search (`en/players`). */
55
+ export interface StatsPlayer {
56
+ id: number;
57
+ currentTeamId: number | null;
58
+ firstName: string;
59
+ fullName: string;
60
+ lastName: string;
61
+ positionCode: PositionCode;
62
+ sweaterNumber: number | null;
63
+ }
@@ -35,24 +35,24 @@ export interface ClubScheduleGame {
35
35
  awayTeam: ClubScheduleGameAwayTeam;
36
36
  homeTeam: ScheduleHomeTeam;
37
37
  periodDescriptor: PeriodDescriptor;
38
- /** Absent when team=BUF,week=now; team=TOR,week=now; team=UTA,week=now */
38
+ /** Absent before the game is played */
39
39
  gameOutcome?: GameOutcome;
40
- /** Absent when team=BUF,week=now; team=TOR,week=now; team=UTA,week=now */
40
+ /** Absent before the game is played */
41
41
  winningGoalie?: WinningGoalie;
42
- /** Absent when team=BUF,week=now; team=TOR,week=now; team=UTA,week=now */
42
+ /** Absent before the game is played */
43
43
  winningGoalScorer?: WinningGoalie;
44
- /** Absent when team=BUF,week=now; team=TOR,week=now; team=UTA,week=now */
44
+ /** Absent before the game is played */
45
45
  threeMinRecap?: string;
46
- /** Absent when team=BUF,week=now; team=TOR,week=now; team=UTA,week=now */
46
+ /** Absent before the game is played */
47
47
  condensedGame?: string;
48
48
  gameCenterLink: string;
49
- /** Absent when team=BUF,week=2024-02-10; team=BUF,week=now; team=TOR,week=now; team=UTA,week=now */
49
+ /** Absent before the game is played */
50
50
  threeMinRecapFr?: string;
51
- /** Absent when team=TOR,month=now; team=BUF,week=2024-02-10; team=BUF,week=now; team=TOR,week=now; team=UTA,week=now. Low sample count */
51
+ /** Absent before the game is played */
52
52
  condensedGameFr?: string;
53
- /** Absent when team=BUF,week=2024-02-10 */
53
+ /** Only present before the game starts */
54
54
  ticketsLink?: string;
55
- /** Absent when team=BUF,week=2024-02-10 */
55
+ /** Only present before the game starts */
56
56
  ticketsLinkFr?: string;
57
57
  }
58
58
  export interface ClubScheduleGameAwayTeam {
@@ -64,21 +64,14 @@ export interface ClubScheduleGameAwayTeam {
64
64
  logo: string;
65
65
  darkLogo: string;
66
66
  awaySplitSquad: boolean;
67
- /** Absent when team=BUF,week=now; team=TOR,week=now; team=UTA,week=now */
67
+ /** Absent before the game is played */
68
68
  score?: number;
69
- /** Absent when team=BUF,week=now */
70
69
  airlineLink?: string;
71
- /** Absent when team=BUF,week=now */
72
70
  airlineDesc?: string;
73
- /** Absent when team=BUF,week=now */
74
71
  hotelLink?: string;
75
- /** Absent when team=BUF,week=now */
76
72
  hotelDesc?: string;
77
- /** Absent when team=BUF,week=2024-02-10 */
78
73
  radioLink?: string;
79
- /** Absent when team=BUF,week=2024-02-10; team=BUF,week=now; team=TOR,week=now */
80
74
  promoLink?: string;
81
- /** Absent when team=BUF,week=2024-02-10; team=BUF,week=now; team=TOR,week=now */
82
75
  promoDesc?: string;
83
76
  }
84
77
  export interface ScheduleHomeTeam {
@@ -90,27 +83,19 @@ export interface ScheduleHomeTeam {
90
83
  logo: string;
91
84
  darkLogo: string;
92
85
  homeSplitSquad: boolean;
93
- /** Absent when team=BUF,week=now; team=TOR,week=now; team=UTA,week=now */
86
+ /** Absent before the game is played */
94
87
  score?: number;
95
- /** Absent when team=BUF,week=2024-02-10; team=BUF,week=now */
96
88
  hotelLink?: string;
97
- /** Absent when team=BUF,week=2024-02-10; team=BUF,week=now */
98
89
  hotelDesc?: string;
99
- /** Absent when team=BUF,week=2024-02-10; team=BUF,week=now; team=TOR,week=now */
100
90
  airlineLink?: string;
101
- /** Absent when team=BUF,week=2024-02-10; team=BUF,week=now; team=TOR,week=now */
102
91
  airlineDesc?: string;
103
- /** Absent when team=BUF,week=2024-02-10 */
104
92
  radioLink?: string;
105
- /** Absent when team=BUF,week=2024-02-10; team=BUF,week=now; team=TOR,week=now */
106
93
  promoLink?: string;
107
- /** Absent when team=BUF,week=2024-02-10; team=BUF,week=now; team=TOR,week=now */
108
94
  promoDesc?: string;
109
95
  }
110
96
  export interface SpecialEvent {
111
97
  parentId: number;
112
98
  name: LocalizedString;
113
- /** Low sample count */
114
99
  lightLogoUrl?: LocalizedString;
115
100
  }
116
101
  export interface GameWeekDay {
@@ -197,9 +182,7 @@ export interface PlayoffSeriesSchedule {
197
182
  topSeedTeam: PlayoffSeriesTeam;
198
183
  games: PlayoffSeriesScheduleGame[];
199
184
  fullCoverageUrl: PlayoffFullCoverageUrls;
200
- /** Absent when season=20232024,series=o. Low sample count */
201
185
  conferenceAbbrev?: string;
202
- /** Absent when season=20232024,series=o. Low sample count */
203
186
  conferenceName?: string;
204
187
  }
205
188
  export interface PlayoffFullCoverageUrls {
@@ -242,6 +225,20 @@ export interface PlayoffSeriesGameTeam {
242
225
  abbrev: string;
243
226
  score: number;
244
227
  }
228
+ export interface PlayoffSeriesMeta {
229
+ seriesTitle: string;
230
+ teams: PlayoffSeriesMetaTeams;
231
+ }
232
+ export interface PlayoffSeriesMetaTeam {
233
+ name: LocalizedString;
234
+ commonName: LocalizedString;
235
+ tricode: string;
236
+ teamSlug: string;
237
+ }
238
+ export interface PlayoffSeriesMetaTeams {
239
+ topSeed: PlayoffSeriesMetaTeam;
240
+ bottomSeed: PlayoffSeriesMetaTeam;
241
+ }
245
242
  export interface PlayoffSeriesStatus {
246
243
  topSeedWins: number;
247
244
  bottomSeedWins: number;
@@ -289,34 +286,33 @@ export interface ScheduleGame {
289
286
  awayTeam: WeeklyScheduleGameAwayTeam;
290
287
  homeTeam: WeeklyScheduleGameHomeTeam;
291
288
  periodDescriptor: WeeklySchedulePeriodDescriptor;
292
- /** Absent when date=now */
289
+ /** Absent before the game is played */
293
290
  gameOutcome?: GameOutcome;
294
- /** Absent when date=now */
291
+ /** Absent before the game is played */
295
292
  winningGoalie?: WinningGoalie;
296
- /** Absent when date=now */
293
+ /** Absent before the game is played */
297
294
  winningGoalScorer?: WinningGoalie;
298
- /** Absent when date=now */
295
+ /** Absent before the game is played */
299
296
  threeMinRecap?: string;
300
- /** Absent when date=now */
297
+ /** Absent before the game is played */
301
298
  threeMinRecapFr?: string;
302
299
  gameCenterLink: string;
303
- /** Absent when date=now */
300
+ /** Absent before the game is played */
304
301
  condensedGame?: string;
305
- /** Absent when date=now; date=playoff; date=regular. Low sample count */
306
302
  specialEvent?: SpecialEvent;
307
- /** Absent when date=playoff; date=regular. Low sample count */
303
+ /** Only present before the game starts */
308
304
  ticketsLink?: string;
309
- /** Absent when date=playoff; date=regular. Low sample count */
305
+ /** Only present before the game starts */
310
306
  ticketsLinkFr?: string;
311
- /** Absent when date=regular. Low sample count */
307
+ /** Playoff games only */
312
308
  seriesStatus?: SeriesStatus;
313
- /** Absent when date=regular. Low sample count */
309
+ /** Playoff games only */
314
310
  seriesUrl?: string;
315
311
  }
316
312
  export interface TeamSeasonSchedule {
317
313
  previousSeason: number;
318
314
  currentSeason: number;
319
- /** Absent when team=BUF,season=now; team=TOR,season=now; team=UTA,season=now */
315
+ /** Absent for the current season */
320
316
  nextSeason?: number;
321
317
  clubTimezone: string;
322
318
  clubUTCOffset: string;
@@ -341,26 +337,24 @@ export interface TeamSeasonScheduleGame {
341
337
  periodDescriptor: PeriodDescriptor;
342
338
  gameOutcome?: GameOutcome;
343
339
  winningGoalie?: WinningGoalie;
344
- /** Absent when team=BUF,season=19992000 */
340
+ /** Absent before the game is played and for older seasons (for example, 1999-2000) */
345
341
  winningGoalScorer?: WinningGoalie;
346
- /** Absent when team=BUF,season=19992000; team=BUF,season=now; team=TOR,season=now */
347
342
  specialEvent?: SpecialEvent;
348
343
  gameCenterLink: string;
349
- /** Absent when team=BUF,season=19992000 */
344
+ /** Absent before the game is played and for older seasons (for example, 1999-2000) */
350
345
  threeMinRecap?: string;
351
- /** Absent when team=BUF,season=19992000 */
346
+ /** Absent before the game is played and for older seasons (for example, 1999-2000) */
352
347
  condensedGame?: string;
353
- /** Absent when team=BUF,season=19992000 */
348
+ /** Absent before the game is played and for older seasons (for example, 1999-2000) */
354
349
  threeMinRecapFr?: string;
355
- /** Absent when team=BUF,season=20232024; team=BUF,season=now; team=SEA,season=20232024; team=TOR,season=now; team=UTA,season=now. Low sample count */
350
+ /** Playoff games only */
356
351
  seriesStatus?: SeasonScheduleSeriesStatus;
357
- /** Absent when team=BUF,season=20232024; team=BUF,season=now; team=SEA,season=20232024; team=TOR,season=now; team=UTA,season=now. Low sample count */
352
+ /** Playoff games only */
358
353
  seriesUrl?: string;
359
- /** Absent when team=SEA,season=20232024 */
360
354
  condensedGameFr?: string;
361
- /** Absent when team=SEA,season=20232024 */
355
+ /** Only present before the game starts */
362
356
  ticketsLink?: string;
363
- /** Absent when team=SEA,season=20232024 */
357
+ /** Only present before the game starts */
364
358
  ticketsLinkFr?: string;
365
359
  }
366
360
  export interface TeamSeasonScheduleGameAwayTeam {
@@ -373,19 +367,12 @@ export interface TeamSeasonScheduleGameAwayTeam {
373
367
  darkLogo: string;
374
368
  awaySplitSquad: boolean;
375
369
  score?: number;
376
- /** Absent when team=BUF,season=19992000 */
377
370
  hotelLink?: string;
378
- /** Absent when team=BUF,season=19992000 */
379
371
  hotelDesc?: string;
380
- /** Absent when team=BUF,season=19992000 */
381
372
  airlineLink?: string;
382
- /** Absent when team=BUF,season=19992000 */
383
373
  airlineDesc?: string;
384
- /** Absent when team=SEA,season=20232024 */
385
374
  radioLink?: string;
386
- /** Absent when team=SEA,season=20232024 */
387
375
  promoLink?: string;
388
- /** Absent when team=SEA,season=20232024 */
389
376
  promoDesc?: string;
390
377
  }
391
378
  export interface SeasonScheduleSeriesStatus {
@@ -394,7 +381,9 @@ export interface SeasonScheduleSeriesStatus {
394
381
  seriesTitle: string;
395
382
  seriesLetter: string;
396
383
  neededToWin: number;
384
+ topSeedTeamAbbrev: string;
397
385
  topSeedWins: number;
386
+ bottomSeedTeamAbbrev: string;
398
387
  bottomSeedWins: number;
399
388
  gameNumberOfSeries: number;
400
389
  }
@@ -419,9 +408,9 @@ export interface WeeklyScheduleGameAwayTeam {
419
408
  logo: string;
420
409
  darkLogo: string;
421
410
  awaySplitSquad: boolean;
422
- /** Absent when date=now */
411
+ /** Absent before the game is played */
423
412
  score?: number;
424
- /** Absent when date=playoff; date=regular. Low sample count */
413
+ /** Only present before the game starts */
425
414
  radioLink?: string;
426
415
  /** Present only while odds are published for the game. */
427
416
  odds?: TeamOdd[];
@@ -435,9 +424,9 @@ export interface WeeklyScheduleGameHomeTeam {
435
424
  logo: string;
436
425
  darkLogo: string;
437
426
  homeSplitSquad: boolean;
438
- /** Absent when date=now */
427
+ /** Absent before the game is played */
439
428
  score?: number;
440
- /** Absent when date=playoff; date=regular. Low sample count */
429
+ /** Only present before the game starts */
441
430
  radioLink?: string;
442
431
  /** Present only while odds are published for the game. */
443
432
  odds?: TeamOdd[];
@@ -446,7 +435,6 @@ export interface WeeklySchedulePeriodDescriptor {
446
435
  number: number;
447
436
  periodType: PeriodType;
448
437
  maxRegulationPeriods: number;
449
- /** Absent when date=regular. Low sample count */
450
438
  otPeriods?: number;
451
439
  }
452
440
  export interface WinningGoalie {
@@ -2,7 +2,7 @@ import type { GameType, LocalizedString } from '#src/types/common.mjs';
2
2
  export interface LeagueStandings {
3
3
  wildCardIndicator: boolean;
4
4
  standings: StandingsEntry[];
5
- /** Absent when variant=season-2005; variant=season. Low sample count */
5
+ /** Only present for the current standings */
6
6
  standingsDateTimeUtc?: string;
7
7
  }
8
8
  export interface StandingsEntry {
@@ -87,7 +87,6 @@ export interface StandingsEntry {
87
87
  conferenceName?: string;
88
88
  divisionAbbrev?: string;
89
89
  divisionName?: string;
90
- /** Low sample count */
91
90
  clinchIndicator?: string;
92
91
  }
93
92
  export interface StandingsSeason {