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
package/dist/cli/run.mjs CHANGED
@@ -5,7 +5,9 @@ import { MODULES, UsageError, } from '#src/cli/commands.mjs';
5
5
  import { NHLApiException } from '#src/errors.mjs';
6
6
  import { createNHLClient } from '#src/nhl-client.mjs';
7
7
  const BIN = 'nhl-api-ts';
8
- const kebab = (name) => name.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase();
8
+ function kebab(name) {
9
+ return name.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase();
10
+ }
9
11
  const GLOBAL_OPTIONS = {
10
12
  help: { type: 'boolean', short: 'h' },
11
13
  version: { type: 'boolean', short: 'v' },
@@ -84,7 +86,7 @@ function commandHelp(mod, cmd) {
84
86
  ]
85
87
  .filter(Boolean)
86
88
  .join(' ');
87
- const describe = (arg) => {
89
+ function describe(arg) {
88
90
  const extras = [
89
91
  arg.choices ? `one of: ${arg.choices.join(', ')}` : '',
90
92
  arg.default !== undefined ? `default: ${arg.default}` : '',
@@ -92,7 +94,7 @@ function commandHelp(mod, cmd) {
92
94
  return extras.length
93
95
  ? `${arg.description} (${extras.join('; ')})`
94
96
  : arg.description;
95
- };
97
+ }
96
98
  const sections = [`Usage: ${usage}`, cmd.description];
97
99
  if (required.length) {
98
100
  sections.push(`Arguments (positional, or as flags):\n${table(required.map((arg) => [
@@ -250,10 +252,10 @@ export async function runCli(argv, io) {
250
252
  const [moduleName, commandName] = findTargets(argv);
251
253
  const mod = MODULES.find((moduleSpec) => moduleSpec.name === moduleName);
252
254
  const cmd = mod?.commands.find((command) => command.name === commandName);
253
- const usageError = (message, help) => {
255
+ function usageError(message, help) {
254
256
  io.stderr(`${colors.error(`error: ${message}`)}\n\n${help}`);
255
257
  return 2;
256
- };
258
+ }
257
259
  let parsed;
258
260
  try {
259
261
  parsed = parseCommand(argv, cmd);
@@ -8,7 +8,8 @@ export declare const Endpoint: {
8
8
  };
9
9
  export type Endpoint = (typeof Endpoint)[keyof typeof Endpoint];
10
10
  export type QueryParamValue = string | number | boolean | null | undefined;
11
- export type QueryParams = Record<string, QueryParamValue>;
11
+ /** An array value repeats the key once per element (`include=a&include=b`). */
12
+ export type QueryParams = Record<string, QueryParamValue | readonly QueryParamValue[]>;
12
13
  export declare function buildUrl(endpoint: Endpoint, resource: string, queryParams?: QueryParams): string;
13
14
  /** Maps a non-2xx HTTP status to the matching NHLApiException subclass. */
14
15
  export declare function errorForStatus(status: number, message: string): NHLApiException;
@@ -18,7 +18,14 @@ export function buildUrl(endpoint, resource, queryParams) {
18
18
  }
19
19
  const search = new URLSearchParams();
20
20
  for (const [key, value] of Object.entries(queryParams)) {
21
- search.append(key, paramToString(value));
21
+ if (Array.isArray(value)) {
22
+ for (const item of value) {
23
+ search.append(key, paramToString(item));
24
+ }
25
+ }
26
+ else {
27
+ search.append(key, paramToString(value));
28
+ }
22
29
  }
23
30
  const qs = search.toString();
24
31
  if (!qs) {
@@ -73,11 +80,11 @@ export async function readErrorMessage(response, url) {
73
80
  * @throws NHLApiException For other unexpected errors
74
81
  */
75
82
  export function createGet(config) {
76
- const debug = (message) => {
83
+ function debug(message) {
77
84
  if (config.debug) {
78
85
  console.error(`nhl-api-ts.http_client - DEBUG - ${message}`);
79
86
  }
80
- };
87
+ }
81
88
  return async (endpoint, resource, queryParams) => {
82
89
  const fullUrl = buildUrl(endpoint, resource, queryParams);
83
90
  debug(`GET: ${fullUrl}`);
package/dist/index.d.mts CHANGED
@@ -1,15 +1,21 @@
1
- export type { EdgePlayerParams, EdgeSeasonParams, EdgeTeamParams, } from '#src/api/edge.mjs';
1
+ export type { DraftPicksParams, DraftRankingsParams, DraftRound, } from '#src/api/draft.mjs';
2
+ export * as draft from '#src/api/draft.mjs';
3
+ export { ProspectCategory } from '#src/api/draft.mjs';
4
+ export type { EdgeGoalie5v5SortBy, EdgeGoalieSavePercentageSortBy, EdgeGoalieShotLocationSortBy, EdgeGoalieShotLocationTop10Params, EdgePlayerParams, EdgePosition, EdgePositionTop10Params, EdgeSeasonParams, EdgeShotLocationCategory, EdgeShotLocationSortBy, EdgeShotLocationTop10Params, EdgeShotSpeedSortBy, EdgeSkatingDistanceSortBy, EdgeSkatingSpeedSortBy, EdgeStrength, EdgeStrengthTop10Params, EdgeTeamParams, EdgeTeamZoneTimeTop10Params, EdgeTop10Params, EdgeZone, } from '#src/api/edge.mjs';
2
5
  export * as edge from '#src/api/edge.mjs';
6
+ export { EdgePositions, EdgeStrengths, EdgeZones } from '#src/api/edge.mjs';
3
7
  export * as gameCenter from '#src/api/game-center.mjs';
4
8
  export * as helpers from '#src/api/helpers.mjs';
9
+ export type { GamesParams } from '#src/api/misc.mjs';
5
10
  export * as misc from '#src/api/misc.mjs';
11
+ export type { PlayerSearchParams } from '#src/api/players.mjs';
6
12
  export * as players from '#src/api/players.mjs';
7
13
  export * from '#src/api/query/index.mjs';
8
14
  export type { DailySchedule } from '#src/api/schedule.mjs';
9
15
  export * as schedule from '#src/api/schedule.mjs';
10
16
  export { normalizeDate } from '#src/api/schedule.mjs';
11
17
  export * as standings from '#src/api/standings.mjs';
12
- export type { GoalieStatsSummaryParams, SkaterStatsSummaryParams, SkaterStatsWithQueryContextParams, TeamSummaryParams, } from '#src/api/stats.mjs';
18
+ export type { GoalieStatsSummaryParams, SkaterStatsSummaryParams, SkaterStatsWithQueryContextParams, StatsApiLeadersParams, StatsLeadersParams, TeamSummaryParams, } from '#src/api/stats.mjs';
13
19
  export * as stats from '#src/api/stats.mjs';
14
20
  export type { Team } from '#src/api/teams.mjs';
15
21
  export * as teams from '#src/api/teams.mjs';
package/dist/index.mjs CHANGED
@@ -1,4 +1,7 @@
1
+ export * as draft from '#src/api/draft.mjs';
2
+ export { ProspectCategory } from '#src/api/draft.mjs';
1
3
  export * as edge from '#src/api/edge.mjs';
4
+ export { EdgePositions, EdgeStrengths, EdgeZones } from '#src/api/edge.mjs';
2
5
  export * as gameCenter from '#src/api/game-center.mjs';
3
6
  export * as helpers from '#src/api/helpers.mjs';
4
7
  export * as misc from '#src/api/misc.mjs';
@@ -1,34 +1,26 @@
1
- import { type GoalieStatsSummaryParams, type SkaterStatsWithQueryContextParams, statsApi } from '#src/api/stats.mjs';
2
1
  import { type ClientOptions } from '#src/config.mjs';
3
2
  import type { Context } from '#src/context.mjs';
4
- import type { GoalieReportRows, SkaterReportRows, StatsApiPage } from '#src/types/index.mjs';
5
3
  type Bound<Module> = {
6
4
  [Method in keyof Module]: Module[Method] extends (ctx: Context, ...args: infer Args) => infer MethodResponse ? (...args: Args) => MethodResponse : never;
7
5
  };
8
- /**
9
- * `Bound` erases generic parameters, so the report-typed stats methods are
10
- * spelled out here (without `ctx`) to keep `reportType` / `statsType`
11
- * flowing into the row type.
12
- */
13
- interface StatsGenericMethods {
14
- skaterStatsWithQueryContext<Report extends keyof SkaterReportRows>(params: SkaterStatsWithQueryContextParams<Report>): Promise<StatsApiPage<SkaterReportRows[Report]>>;
15
- goalieStatsSummary<Report extends keyof GoalieReportRows = 'summary'>(params: GoalieStatsSummaryParams<Report>): Promise<GoalieReportRows[Report][]>;
16
- }
17
- type StatsClient = Omit<Bound<typeof statsApi>, 'skaterStatsWithQueryContext' | 'goalieStatsSummary'> & StatsGenericMethods;
18
6
  /**
19
7
  * Builds the main client used to access the NHL API.
20
8
  *
21
9
  * @example
22
10
  * const client = createNHLClient();
23
- * const client = createNHLClient({ debug: true }); // for a lil extra logging
11
+ * const client = createNHLClient({ debug: true }); // for a little extra logging
24
12
  * const teams = await client.teams.teams();
25
13
  */
26
- export declare const createNHLClient: (options?: ClientOptions) => {
14
+ export declare function createNHLClient(options?: ClientOptions): {
27
15
  readonly config: Readonly<import("#src/config.mjs").Config>;
28
16
  readonly teams: Bound<{
29
17
  readonly teams: typeof import("#src/api/teams.mjs").teams;
30
18
  readonly teamRoster: typeof import("#src/api/teams.mjs").teamRoster;
19
+ readonly rosterSeasons: typeof import("#src/api/teams.mjs").rosterSeasons;
20
+ readonly teamScoreboard: typeof import("#src/api/teams.mjs").teamScoreboard;
31
21
  readonly franchises: typeof import("#src/api/teams.mjs").franchises;
22
+ readonly statsTeams: typeof import("#src/api/teams.mjs").statsTeams;
23
+ readonly teamById: typeof import("#src/api/teams.mjs").teamById;
32
24
  }>;
33
25
  readonly standings: Bound<{
34
26
  readonly leagueStandings: typeof import("#src/api/standings.mjs").leagueStandings;
@@ -43,6 +35,7 @@ export declare const createNHLClient: (options?: ClientOptions) => {
43
35
  readonly calendarSchedule: typeof import("#src/api/schedule.mjs").calendarSchedule;
44
36
  readonly playoffCarousel: typeof import("#src/api/schedule.mjs").playoffCarousel;
45
37
  readonly playoffSeriesSchedule: typeof import("#src/api/schedule.mjs").playoffSeriesSchedule;
38
+ readonly playoffSeriesMeta: typeof import("#src/api/schedule.mjs").playoffSeriesMeta;
46
39
  readonly playoffBracket: typeof import("#src/api/schedule.mjs").playoffBracket;
47
40
  }>;
48
41
  readonly gameCenter: Bound<{
@@ -53,14 +46,54 @@ export declare const createNHLClient: (options?: ClientOptions) => {
53
46
  readonly shiftChartData: typeof import("#src/api/game-center.mjs").shiftChartData;
54
47
  readonly seasonSeriesMatchup: typeof import("#src/api/game-center.mjs").seasonSeriesMatchup;
55
48
  readonly gameStory: typeof import("#src/api/game-center.mjs").gameStory;
49
+ readonly scoreboard: typeof import("#src/api/game-center.mjs").scoreboard;
50
+ readonly wscPlayByPlay: typeof import("#src/api/game-center.mjs").wscPlayByPlay;
51
+ readonly playReplay: typeof import("#src/api/game-center.mjs").playReplay;
52
+ readonly gameMeta: typeof import("#src/api/game-center.mjs").gameMeta;
56
53
  }>;
57
- readonly stats: StatsClient;
54
+ readonly stats: {
55
+ readonly gametypesPerSeasonDirectoryByTeam: (args_0: {
56
+ teamAbbr: string;
57
+ }) => Promise<import("./index.mjs").ClubStatsSeason[]>;
58
+ readonly playerCareerStats: (args_0: {
59
+ playerId: import("#src/utils.mjs").Id;
60
+ }) => Promise<import("./index.mjs").PlayerLanding>;
61
+ readonly playerGameLog: (args_0: {
62
+ playerId: import("#src/utils.mjs").Id;
63
+ seasonId?: import("#src/utils.mjs").Id;
64
+ gameType?: number;
65
+ }) => Promise<import("./index.mjs").GameLogEntry[]>;
66
+ readonly skaterStatsLeaders: (params?: import("#src/api/stats.mjs").StatsLeadersParams<import("./index.mjs").OpenUnion<import("./index.mjs").SkaterLeaderCategory>> | undefined) => Promise<import("./index.mjs").SkaterStatsLeaders>;
67
+ readonly goalieStatsLeaders: (params?: import("#src/api/stats.mjs").StatsLeadersParams<import("./index.mjs").OpenUnion<import("./index.mjs").GoalieLeaderCategory>> | undefined) => Promise<import("./index.mjs").GoalieStatsLeaders>;
68
+ readonly clubStats: (args_0: {
69
+ teamAbbr: string;
70
+ season?: import("#src/utils.mjs").Id;
71
+ gameType?: number;
72
+ }) => Promise<import("./index.mjs").ClubStats>;
73
+ readonly teamSummary: (args_0: import("#src/api/stats.mjs").TeamSummaryParams) => Promise<import("./index.mjs").TeamSummaryRow[]>;
74
+ readonly skaterStatsSummary: (args_0: import("#src/api/stats.mjs").SkaterStatsSummaryParams) => Promise<import("./index.mjs").SkaterSummaryRow[]>;
75
+ readonly skaterMilestones: () => Promise<import("./index.mjs").SkaterMilestone[]>;
76
+ readonly goalieMilestones: () => Promise<import("./index.mjs").GoalieMilestone[]>;
77
+ readonly skaterStatsWithQueryContext: <Report extends keyof import("./index.mjs").SkaterReportRows>(args_0: import("#src/api/stats.mjs").SkaterStatsWithQueryContextParams<Report>) => Promise<import("./index.mjs").StatsApiPage<import("./index.mjs").SkaterReportRows[Report]>>;
78
+ readonly goalieStatsSummary: <Report extends keyof import("./index.mjs").GoalieReportRows = "summary">(args_0: import("#src/api/stats.mjs").GoalieStatsSummaryParams<Report>) => Promise<import("./index.mjs").GoalieReportRows[Report][]>;
79
+ readonly skaterLeaders: <Attribute extends keyof import("./index.mjs").SkaterLeaderRows>(params: import("#src/api/stats.mjs").StatsApiLeadersParams<Attribute>) => Promise<import("./index.mjs").SkaterLeaderRows[Attribute][]>;
80
+ readonly goalieLeaders: <Attribute extends keyof import("./index.mjs").GoalieLeaderRows>(params: import("#src/api/stats.mjs").StatsApiLeadersParams<Attribute>) => Promise<import("./index.mjs").GoalieLeaderRows[Attribute][]>;
81
+ };
58
82
  readonly misc: Bound<{
59
83
  readonly glossary: typeof import("#src/api/misc.mjs").glossary;
60
84
  readonly config: typeof import("#src/api/misc.mjs").config;
61
85
  readonly countries: typeof import("#src/api/misc.mjs").countries;
62
86
  readonly seasonSpecificRulesAndInfo: typeof import("#src/api/misc.mjs").seasonSpecificRulesAndInfo;
63
87
  readonly draftYearAndRounds: typeof import("#src/api/misc.mjs").draftYearAndRounds;
88
+ readonly componentSeasons: typeof import("#src/api/misc.mjs").componentSeasons;
89
+ readonly games: typeof import("#src/api/misc.mjs").games;
90
+ readonly tvSchedule: typeof import("#src/api/misc.mjs").tvSchedule;
91
+ readonly partnerGameOdds: typeof import("#src/api/misc.mjs").partnerGameOdds;
92
+ readonly seasonIds: typeof import("#src/api/misc.mjs").seasonIds;
93
+ readonly meta: typeof import("#src/api/misc.mjs").meta;
94
+ readonly location: typeof import("#src/api/misc.mjs").location;
95
+ readonly postalLookup: typeof import("#src/api/misc.mjs").postalLookup;
96
+ readonly ping: typeof import("#src/api/misc.mjs").ping;
64
97
  }>;
65
98
  readonly helpers: Bound<{
66
99
  readonly gameIdsBySeason: typeof import("#src/api/helpers.mjs").gameIdsBySeason;
@@ -70,6 +103,8 @@ export declare const createNHLClient: (options?: ClientOptions) => {
70
103
  readonly players: Bound<{
71
104
  readonly prospectsByTeam: typeof import("#src/api/players.mjs").prospectsByTeam;
72
105
  readonly playersByTeam: typeof import("#src/api/players.mjs").playersByTeam;
106
+ readonly playerSpotlight: typeof import("#src/api/players.mjs").playerSpotlight;
107
+ readonly playerSearch: typeof import("#src/api/players.mjs").playerSearch;
73
108
  }>;
74
109
  readonly edge: Bound<{
75
110
  readonly skaterDetail: typeof import("#src/api/edge.mjs").skaterDetail;
@@ -95,6 +130,26 @@ export declare const createNHLClient: (options?: ClientOptions) => {
95
130
  readonly teamLanding: typeof import("#src/api/edge.mjs").teamLanding;
96
131
  readonly teamShotSpeedDetail: typeof import("#src/api/edge.mjs").teamShotSpeedDetail;
97
132
  readonly teamSkatingSpeedDetail: typeof import("#src/api/edge.mjs").teamSkatingSpeedDetail;
133
+ readonly skaterDistanceTop10: typeof import("#src/api/edge.mjs").skaterDistanceTop10;
134
+ readonly skaterSpeedTop10: typeof import("#src/api/edge.mjs").skaterSpeedTop10;
135
+ readonly skaterZoneTimeTop10: typeof import("#src/api/edge.mjs").skaterZoneTimeTop10;
136
+ readonly skaterShotSpeedTop10: typeof import("#src/api/edge.mjs").skaterShotSpeedTop10;
137
+ readonly skaterShotLocationTop10: typeof import("#src/api/edge.mjs").skaterShotLocationTop10;
138
+ readonly goalie5v5Top10: typeof import("#src/api/edge.mjs").goalie5v5Top10;
139
+ readonly goalieShotLocationTop10: typeof import("#src/api/edge.mjs").goalieShotLocationTop10;
140
+ readonly goalieSavePercentageTop10: typeof import("#src/api/edge.mjs").goalieSavePercentageTop10;
141
+ readonly teamSkatingDistanceTop10: typeof import("#src/api/edge.mjs").teamSkatingDistanceTop10;
142
+ readonly teamSkatingSpeedTop10: typeof import("#src/api/edge.mjs").teamSkatingSpeedTop10;
143
+ readonly teamZoneTimeTop10: typeof import("#src/api/edge.mjs").teamZoneTimeTop10;
144
+ readonly teamShotSpeedTop10: typeof import("#src/api/edge.mjs").teamShotSpeedTop10;
145
+ readonly teamShotLocationTop10: typeof import("#src/api/edge.mjs").teamShotLocationTop10;
146
+ readonly teamComparison: typeof import("#src/api/edge.mjs").teamComparison;
147
+ readonly byTheNumbers: typeof import("#src/api/edge.mjs").byTheNumbers;
148
+ }>;
149
+ readonly draft: Bound<{
150
+ readonly rankings: typeof import("#src/api/draft.mjs").rankings;
151
+ readonly tracker: typeof import("#src/api/draft.mjs").tracker;
152
+ readonly picks: typeof import("#src/api/draft.mjs").picks;
98
153
  }>;
99
154
  };
100
155
  export type NHLClient = ReturnType<typeof createNHLClient>;
@@ -1,3 +1,4 @@
1
+ import { draftApi } from '#src/api/draft.mjs';
1
2
  import { edgeApi } from '#src/api/edge.mjs';
2
3
  import { gameCenterApi } from '#src/api/game-center.mjs';
3
4
  import { helpersApi } from '#src/api/helpers.mjs';
@@ -5,36 +6,58 @@ import { miscApi } from '#src/api/misc.mjs';
5
6
  import { playersApi } from '#src/api/players.mjs';
6
7
  import { scheduleApi } from '#src/api/schedule.mjs';
7
8
  import { standingsApi } from '#src/api/standings.mjs';
8
- import { statsApi, } from '#src/api/stats.mjs';
9
+ import { statsApi } from '#src/api/stats.mjs';
9
10
  import { teamsApi } from '#src/api/teams.mjs';
10
11
  import { resolveConfig } from '#src/config.mjs';
11
12
  import { createGet } from '#src/http-client.mjs';
12
13
  import { sleep } from '#src/utils.mjs';
13
- const bind = (ctx, api) => Object.fromEntries(Object.entries(api).map(([key, fn]) => [
14
- key,
15
- (...args) => fn(ctx, ...args),
16
- ]));
14
+ /**
15
+ * Binds `ctx` to every function in an API module. Generic methods lose their
16
+ * type parameters here (they're instantiated with their constraints), so
17
+ * override those with `bindFn`.
18
+ */
19
+ function bindModule(ctx, api) {
20
+ return Object.fromEntries(Object.entries(api).map(([key, fn]) => [
21
+ key,
22
+ (...args) => fn(ctx, ...args),
23
+ ]));
24
+ }
25
+ /**
26
+ * Binds `ctx` to a single function. Keeps its generics through higher-order
27
+ * function inference, e.g. so `reportType` / `statsType` still decide the
28
+ * row type.
29
+ */
30
+ function bindFn(ctx, fn) {
31
+ return (...args) => fn(ctx, ...args);
32
+ }
17
33
  /**
18
34
  * Builds the main client used to access the NHL API.
19
35
  *
20
36
  * @example
21
37
  * const client = createNHLClient();
22
- * const client = createNHLClient({ debug: true }); // for a lil extra logging
38
+ * const client = createNHLClient({ debug: true }); // for a little extra logging
23
39
  * const teams = await client.teams.teams();
24
40
  */
25
- export const createNHLClient = (options = {}) => {
41
+ export function createNHLClient(options = {}) {
26
42
  const config = resolveConfig(options);
27
43
  const ctx = { get: createGet(config), sleep };
28
44
  return {
29
45
  config,
30
- teams: bind(ctx, teamsApi),
31
- standings: bind(ctx, standingsApi),
32
- schedule: bind(ctx, scheduleApi),
33
- gameCenter: bind(ctx, gameCenterApi),
34
- stats: bind(ctx, statsApi),
35
- misc: bind(ctx, miscApi),
36
- helpers: bind(ctx, helpersApi),
37
- players: bind(ctx, playersApi),
38
- edge: bind(ctx, edgeApi),
46
+ teams: bindModule(ctx, teamsApi),
47
+ standings: bindModule(ctx, standingsApi),
48
+ schedule: bindModule(ctx, scheduleApi),
49
+ gameCenter: bindModule(ctx, gameCenterApi),
50
+ stats: {
51
+ ...bindModule(ctx, statsApi),
52
+ skaterStatsWithQueryContext: bindFn(ctx, statsApi.skaterStatsWithQueryContext),
53
+ goalieStatsSummary: bindFn(ctx, statsApi.goalieStatsSummary),
54
+ skaterLeaders: bindFn(ctx, statsApi.skaterLeaders),
55
+ goalieLeaders: bindFn(ctx, statsApi.goalieLeaders),
56
+ },
57
+ misc: bindModule(ctx, miscApi),
58
+ helpers: bindModule(ctx, helpersApi),
59
+ players: bindModule(ctx, playersApi),
60
+ edge: bindModule(ctx, edgeApi),
61
+ draft: bindModule(ctx, draftApi),
39
62
  };
40
- };
63
+ }
@@ -33,7 +33,6 @@ export interface StatsApiPage<Row> {
33
33
  }
34
34
  export interface GameOutcome {
35
35
  lastPeriodType: PeriodType;
36
- /** Low sample count */
37
36
  otPeriods?: number;
38
37
  }
39
38
  export interface PeriodDescriptor {
@@ -0,0 +1,97 @@
1
+ import type { LocalizedString, OpenUnion } from '#src/types/common.mjs';
2
+ /** Draft prospect position. Wingers are LW / RW here, not L / R. */
3
+ export type DraftPositionCode = OpenUnion<'C' | 'LW' | 'RW' | 'D' | 'G'>;
4
+ export interface DraftRankingCategory {
5
+ id: number;
6
+ name: string;
7
+ consumerKey: string;
8
+ }
9
+ export interface DraftProspect {
10
+ lastName: string;
11
+ firstName: string;
12
+ positionCode: DraftPositionCode;
13
+ shootsCatches: OpenUnion<'L' | 'R'>;
14
+ heightInInches: number;
15
+ weightInPounds: number;
16
+ lastAmateurClub?: string;
17
+ lastAmateurLeague?: string;
18
+ birthDate: string;
19
+ birthCity: string;
20
+ birthStateProvince?: string;
21
+ birthCountry: string;
22
+ midtermRank?: number;
23
+ finalRank?: number;
24
+ }
25
+ export interface DraftRankings {
26
+ /** Draft year in YYYY format. */
27
+ draftYear: number;
28
+ categoryId: number;
29
+ categoryKey: string;
30
+ draftYears: number[];
31
+ categories: DraftRankingCategory[];
32
+ rankings: DraftProspect[];
33
+ }
34
+ export interface DraftTrackerTvBroadcast {
35
+ id: number;
36
+ market: string;
37
+ countryCode: string;
38
+ network: string;
39
+ sequenceNumber: number;
40
+ }
41
+ export interface DraftTrackerPick {
42
+ pickInRound: number;
43
+ overallPick: number;
44
+ teamId: number;
45
+ teamAbbrev: string;
46
+ teamFullName: LocalizedString;
47
+ teamCommonName: LocalizedString;
48
+ teamPlaceNameWithPreposition: LocalizedString;
49
+ teamLogoLight: string;
50
+ teamLogoDark: string;
51
+ state: string;
52
+ lastName: LocalizedString;
53
+ firstName: LocalizedString;
54
+ positionCode: DraftPositionCode;
55
+ }
56
+ export interface DraftTracker {
57
+ currentDraftDate: string;
58
+ broadcastStartTimeUTC: string;
59
+ tvBroadcasts: DraftTrackerTvBroadcast[];
60
+ logoUrl: string;
61
+ logoFrUrl: string;
62
+ uiAccentColor: string;
63
+ round: number;
64
+ state: string;
65
+ picks: DraftTrackerPick[];
66
+ }
67
+ export interface DraftPick {
68
+ round: number;
69
+ pickInRound: number;
70
+ overallPick: number;
71
+ teamId: number;
72
+ teamAbbrev: string;
73
+ teamName: LocalizedString;
74
+ teamCommonName: LocalizedString;
75
+ teamPlaceNameWithPreposition: LocalizedString;
76
+ displayAbbrev: LocalizedString;
77
+ teamLogoLight: string;
78
+ teamLogoDark: string;
79
+ teamPickHistory: string;
80
+ firstName: LocalizedString;
81
+ lastName: LocalizedString;
82
+ positionCode: DraftPositionCode;
83
+ countryCode: string;
84
+ height: number;
85
+ weight: number;
86
+ amateurLeague: string;
87
+ amateurClubName?: string;
88
+ }
89
+ export interface DraftPicks {
90
+ /** Draft year in YYYY format. */
91
+ draftYear: number;
92
+ draftYears: number[];
93
+ selectableRounds: number[];
94
+ state: string;
95
+ picks: DraftPick[];
96
+ broadcastStartTimeUTC?: string;
97
+ }
@@ -0,0 +1 @@
1
+ export {};