nhl-api-ts 0.1.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.
- package/README.md +31 -6
- package/dist/api/edge.d.mts +25 -24
- package/dist/api/edge.mjs +69 -23
- package/dist/api/game-center.d.mts +16 -15
- package/dist/api/game-center.mjs +20 -8
- package/dist/api/helpers.d.mts +8 -7
- package/dist/api/helpers.mjs +6 -6
- package/dist/api/misc.d.mts +6 -6
- package/dist/api/misc.mjs +15 -5
- package/dist/api/players.d.mts +6 -5
- package/dist/api/players.mjs +6 -2
- package/dist/api/query/builder.d.mts +2 -0
- package/dist/api/query/builder.mjs +3 -1
- package/dist/api/query/index.d.mts +2 -2
- package/dist/api/query/index.mjs +1 -1
- package/dist/api/query/sorting/goalie-sorts.d.mts +55 -0
- package/dist/api/query/sorting/goalie-sorts.mjs +43 -48
- package/dist/api/query/sorting/sorting-options.d.mts +125 -0
- package/dist/api/query/sorting/sorting-options.mjs +3 -2
- package/dist/api/schedule.d.mts +22 -21
- package/dist/api/schedule.mjs +26 -14
- package/dist/api/standings.d.mts +5 -4
- package/dist/api/standings.mjs +4 -4
- package/dist/api/stats.d.mts +22 -17
- package/dist/api/stats.mjs +38 -16
- package/dist/api/teams.d.mts +9 -8
- package/dist/api/teams.mjs +10 -6
- package/dist/cli/colors.d.mts +2 -2
- package/dist/cli/colors.mjs +6 -2
- package/dist/cli/commands.mjs +36 -26
- package/dist/cli/run.mjs +7 -5
- package/dist/http-client.mjs +2 -2
- package/dist/index.d.mts +2 -1
- package/dist/nhl-client.d.mts +14 -10
- package/dist/nhl-client.mjs +9 -7
- package/dist/types/common.d.mts +80 -0
- package/dist/types/common.mjs +2 -0
- package/dist/types/edge.d.mts +1024 -0
- package/dist/types/edge.mjs +1 -0
- package/dist/types/game-center.d.mts +1137 -0
- package/dist/types/game-center.mjs +1 -0
- package/dist/types/helpers.d.mts +17 -0
- package/dist/types/helpers.mjs +1 -0
- package/dist/types/index.d.mts +10 -0
- package/dist/types/index.mjs +1 -0
- package/dist/types/misc.d.mts +68 -0
- package/dist/types/misc.mjs +2 -0
- package/dist/types/players.d.mts +41 -0
- package/dist/types/players.mjs +1 -0
- package/dist/types/schedule.d.mts +428 -0
- package/dist/types/schedule.mjs +1 -0
- package/dist/types/standings.d.mts +103 -0
- package/dist/types/standings.mjs +1 -0
- package/dist/types/stats.d.mts +1082 -0
- package/dist/types/stats.mjs +1 -0
- package/dist/types/teams.d.mts +29 -0
- package/dist/types/teams.mjs +1 -0
- package/dist/utils.d.mts +1 -2
- package/dist/utils.mjs +3 -1
- package/package.json +7 -20
- package/dist/api/query/errors.d.mts +0 -3
- package/dist/api/query/errors.mjs +0 -6
- package/dist/api/query/filters/base.d.mts +0 -4
- package/dist/api/query/filters/base.mjs +0 -2
- package/dist/api/query/filters/decision.d.mts +0 -13
- package/dist/api/query/filters/decision.mjs +0 -26
- package/dist/api/query/filters/draft.d.mts +0 -15
- package/dist/api/query/filters/draft.mjs +0 -27
- package/dist/api/query/filters/experience.d.mts +0 -9
- package/dist/api/query/filters/experience.mjs +0 -17
- package/dist/api/query/filters/franchise.d.mts +0 -9
- package/dist/api/query/filters/franchise.mjs +0 -15
- package/dist/api/query/filters/game-type.d.mts +0 -10
- package/dist/api/query/filters/game-type.mjs +0 -16
- package/dist/api/query/filters/goalie-sorts.d.mts +0 -3
- package/dist/api/query/filters/goalie-sorts.mjs +0 -55
- package/dist/api/query/filters/home-road.d.mts +0 -9
- package/dist/api/query/filters/home-road.mjs +0 -16
- package/dist/api/query/filters/index.d.mts +0 -14
- package/dist/api/query/filters/index.mjs +0 -14
- package/dist/api/query/filters/nationality.d.mts +0 -12
- package/dist/api/query/filters/nationality.mjs +0 -19
- package/dist/api/query/filters/opponent.d.mts +0 -10
- package/dist/api/query/filters/opponent.mjs +0 -16
- package/dist/api/query/filters/position.d.mts +0 -16
- package/dist/api/query/filters/position.mjs +0 -28
- package/dist/api/query/filters/season.d.mts +0 -14
- package/dist/api/query/filters/season.mjs +0 -24
- package/dist/api/query/filters/shoot-catch.d.mts +0 -9
- package/dist/api/query/filters/shoot-catch.mjs +0 -16
- package/dist/api/query/filters/status.d.mts +0 -20
- package/dist/api/query/filters/status.mjs +0 -28
- package/dist/logging.d.mts +0 -14
- package/dist/logging.mjs +0 -13
package/dist/api/teams.mjs
CHANGED
|
@@ -5,7 +5,9 @@ async function fetchStandingsData(ctx, date) {
|
|
|
5
5
|
}
|
|
6
6
|
/** Converts a raw standings entry into a `Team`. */
|
|
7
7
|
export function toTeam(teamData) {
|
|
8
|
-
|
|
8
|
+
function nestedDefault(key) {
|
|
9
|
+
return teamData[key]?.default ?? '';
|
|
10
|
+
}
|
|
9
11
|
return {
|
|
10
12
|
conference: {
|
|
11
13
|
abbr: teamData.conferenceAbbrev ?? '',
|
|
@@ -66,11 +68,11 @@ export function withFranchiseIds(teams, franchises) {
|
|
|
66
68
|
* @param params.date Date in YYYY-MM-DD format. Defaults to "now".
|
|
67
69
|
* @example await client.teams.teams()
|
|
68
70
|
*/
|
|
69
|
-
export
|
|
71
|
+
export async function teams(ctx, { date = 'now' } = {}) {
|
|
70
72
|
const standingsData = await fetchStandingsData(ctx, date);
|
|
71
73
|
const franchiseData = await franchises(ctx);
|
|
72
74
|
return withFranchiseIds(standingsData.map(toTeam), franchiseData);
|
|
73
|
-
}
|
|
75
|
+
}
|
|
74
76
|
/**
|
|
75
77
|
* Get the roster for the given team and season.
|
|
76
78
|
*
|
|
@@ -78,14 +80,16 @@ export const teams = async (ctx, { date = 'now' } = {}) => {
|
|
|
78
80
|
* @param params.season Season in YYYYYYYY format, e.g. 20232024
|
|
79
81
|
* @example https://api-web.nhle.com/v1/roster/BUF/20232024
|
|
80
82
|
*/
|
|
81
|
-
export
|
|
83
|
+
export async function teamRoster(ctx, { teamAbbr, season }) {
|
|
84
|
+
return (await ctx.get(Endpoint.API_WEB_V1, `roster/${teamAbbr}/${season}`)).json();
|
|
85
|
+
}
|
|
82
86
|
/**
|
|
83
87
|
* Get a list of all past and current NHL franchises.
|
|
84
88
|
*
|
|
85
89
|
* @example https://api.nhle.com/stats/rest/en/franchise
|
|
86
90
|
*/
|
|
87
|
-
export
|
|
91
|
+
export async function franchises(ctx) {
|
|
88
92
|
const response = await (await ctx.get(Endpoint.API_STATS, 'en/franchise')).json();
|
|
89
93
|
return response.data ?? [];
|
|
90
|
-
}
|
|
94
|
+
}
|
|
91
95
|
export const teamsApi = { teams, teamRoster, franchises };
|
package/dist/cli/colors.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { styleText } from 'node:util';
|
|
2
2
|
export type Style = Parameters<typeof styleText>[0];
|
|
3
|
-
export declare
|
|
4
|
-
export declare
|
|
3
|
+
export declare function toStdout(format: Style): (text: string) => string;
|
|
4
|
+
export declare function toStderr(format: Style): (text: string) => string;
|
|
5
5
|
export declare const colors: {
|
|
6
6
|
dim: (text: string) => string;
|
|
7
7
|
pass: (text: string) => string;
|
package/dist/cli/colors.mjs
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { styleText } from 'node:util';
|
|
2
|
-
export
|
|
3
|
-
|
|
2
|
+
export function toStdout(format) {
|
|
3
|
+
return (text) => styleText(format, text, { stream: process.stdout });
|
|
4
|
+
}
|
|
5
|
+
export function toStderr(format) {
|
|
6
|
+
return (text) => styleText(format, text, { stream: process.stderr });
|
|
7
|
+
}
|
|
4
8
|
export const colors = {
|
|
5
9
|
dim: toStdout('dim'),
|
|
6
10
|
pass: toStdout(['bold', 'green']),
|
package/dist/cli/commands.mjs
CHANGED
|
@@ -5,7 +5,9 @@ import { SKATER_REPORT_TYPES } from '#src/api/query/sorting/sorting-options.mjs'
|
|
|
5
5
|
export class UsageError extends Error {
|
|
6
6
|
}
|
|
7
7
|
// ---- Reusable argument specs ------------------------------------------------
|
|
8
|
-
|
|
8
|
+
function req(spec) {
|
|
9
|
+
return { ...spec, required: true };
|
|
10
|
+
}
|
|
9
11
|
const teamAbbr = req({
|
|
10
12
|
name: 'teamAbbr',
|
|
11
13
|
type: 'string',
|
|
@@ -26,11 +28,13 @@ const playerId = req({
|
|
|
26
28
|
type: 'string',
|
|
27
29
|
description: 'NHL player id, e.g. 8478402',
|
|
28
30
|
});
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
function date(description = 'Date in YYYY-MM-DD format') {
|
|
32
|
+
return {
|
|
33
|
+
name: 'date',
|
|
34
|
+
type: 'string',
|
|
35
|
+
description,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
34
38
|
const gameTypeId = {
|
|
35
39
|
name: 'gameTypeId',
|
|
36
40
|
type: 'int',
|
|
@@ -48,29 +52,35 @@ const start = {
|
|
|
48
52
|
description: 'Pagination offset',
|
|
49
53
|
default: '0',
|
|
50
54
|
};
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
55
|
+
function limit(def) {
|
|
56
|
+
return {
|
|
57
|
+
name: 'limit',
|
|
58
|
+
type: 'int',
|
|
59
|
+
description: 'Max results',
|
|
60
|
+
default: def,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function factCayenneExp(def) {
|
|
64
|
+
return {
|
|
65
|
+
name: 'factCayenneExp',
|
|
66
|
+
type: 'string',
|
|
67
|
+
description: 'Base fact filter expression',
|
|
68
|
+
default: def,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
63
71
|
const defaultCayenneExp = {
|
|
64
72
|
name: 'defaultCayenneExp',
|
|
65
73
|
type: 'string',
|
|
66
74
|
description: 'Overrides the generated cayenneExp filter entirely',
|
|
67
75
|
};
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
76
|
+
function apiSleepRate(def) {
|
|
77
|
+
return {
|
|
78
|
+
name: 'apiSleepRate',
|
|
79
|
+
type: 'number',
|
|
80
|
+
description: 'Seconds to sleep between per-team requests',
|
|
81
|
+
default: def,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
74
84
|
// ---- Edge -------------------------------------------------------------------
|
|
75
85
|
const edgeSeasonArgs = [
|
|
76
86
|
{ ...season, description: `${season.description}. Defaults to current` },
|
|
@@ -81,7 +91,7 @@ const edgeSeasonArgs = [
|
|
|
81
91
|
default: '2',
|
|
82
92
|
},
|
|
83
93
|
];
|
|
84
|
-
|
|
94
|
+
function edgeCommand(name, method, idKind, description) {
|
|
85
95
|
const idArg = idKind === 'player'
|
|
86
96
|
? [playerId]
|
|
87
97
|
: idKind === 'team'
|
|
@@ -101,7 +111,7 @@ const edgeCommand = (name, method, idKind, description) => {
|
|
|
101
111
|
// biome-ignore lint/suspicious/noExplicitAny: dispatch by method name
|
|
102
112
|
client.edge[method].call(client.edge, values),
|
|
103
113
|
};
|
|
104
|
-
}
|
|
114
|
+
}
|
|
105
115
|
// ---- Stats query-context filters --------------------------------------------
|
|
106
116
|
const queryFilterArgs = [
|
|
107
117
|
{
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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);
|
package/dist/http-client.mjs
CHANGED
|
@@ -73,11 +73,11 @@ export async function readErrorMessage(response, url) {
|
|
|
73
73
|
* @throws NHLApiException For other unexpected errors
|
|
74
74
|
*/
|
|
75
75
|
export function createGet(config) {
|
|
76
|
-
|
|
76
|
+
function debug(message) {
|
|
77
77
|
if (config.debug) {
|
|
78
78
|
console.error(`nhl-api-ts.http_client - DEBUG - ${message}`);
|
|
79
79
|
}
|
|
80
|
-
}
|
|
80
|
+
}
|
|
81
81
|
return async (endpoint, resource, queryParams) => {
|
|
82
82
|
const fullUrl = buildUrl(endpoint, resource, queryParams);
|
|
83
83
|
debug(`GET: ${fullUrl}`);
|
package/dist/index.d.mts
CHANGED
|
@@ -18,4 +18,5 @@ export type { Context, Get } from '#src/context.mjs';
|
|
|
18
18
|
export * from '#src/errors.mjs';
|
|
19
19
|
export { buildUrl, createGet, Endpoint, type QueryParams, type QueryParamValue, } from '#src/http-client.mjs';
|
|
20
20
|
export { createNHLClient, type NHLClient } from '#src/nhl-client.mjs';
|
|
21
|
-
export type
|
|
21
|
+
export type * from '#src/types/index.mjs';
|
|
22
|
+
export type { Id } from '#src/utils.mjs';
|
package/dist/nhl-client.d.mts
CHANGED
|
@@ -1,8 +1,20 @@
|
|
|
1
|
+
import { type GoalieStatsSummaryParams, type SkaterStatsWithQueryContextParams, statsApi } from '#src/api/stats.mjs';
|
|
1
2
|
import { type ClientOptions } from '#src/config.mjs';
|
|
2
3
|
import type { Context } from '#src/context.mjs';
|
|
4
|
+
import type { GoalieReportRows, SkaterReportRows, StatsApiPage } from '#src/types/index.mjs';
|
|
3
5
|
type Bound<Module> = {
|
|
4
6
|
[Method in keyof Module]: Module[Method] extends (ctx: Context, ...args: infer Args) => infer MethodResponse ? (...args: Args) => MethodResponse : never;
|
|
5
7
|
};
|
|
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;
|
|
6
18
|
/**
|
|
7
19
|
* Builds the main client used to access the NHL API.
|
|
8
20
|
*
|
|
@@ -11,7 +23,7 @@ type Bound<Module> = {
|
|
|
11
23
|
* const client = createNHLClient({ debug: true }); // for a lil extra logging
|
|
12
24
|
* const teams = await client.teams.teams();
|
|
13
25
|
*/
|
|
14
|
-
export declare
|
|
26
|
+
export declare function createNHLClient(options?: ClientOptions): {
|
|
15
27
|
readonly config: Readonly<import("#src/config.mjs").Config>;
|
|
16
28
|
readonly teams: Bound<{
|
|
17
29
|
readonly teams: typeof import("#src/api/teams.mjs").teams;
|
|
@@ -42,15 +54,7 @@ export declare const createNHLClient: (options?: ClientOptions) => {
|
|
|
42
54
|
readonly seasonSeriesMatchup: typeof import("#src/api/game-center.mjs").seasonSeriesMatchup;
|
|
43
55
|
readonly gameStory: typeof import("#src/api/game-center.mjs").gameStory;
|
|
44
56
|
}>;
|
|
45
|
-
readonly stats:
|
|
46
|
-
readonly gametypesPerSeasonDirectoryByTeam: typeof import("#src/api/stats.mjs").gametypesPerSeasonDirectoryByTeam;
|
|
47
|
-
readonly playerCareerStats: typeof import("#src/api/stats.mjs").playerCareerStats;
|
|
48
|
-
readonly playerGameLog: typeof import("#src/api/stats.mjs").playerGameLog;
|
|
49
|
-
readonly teamSummary: typeof import("#src/api/stats.mjs").teamSummary;
|
|
50
|
-
readonly skaterStatsSummary: typeof import("#src/api/stats.mjs").skaterStatsSummary;
|
|
51
|
-
readonly skaterStatsWithQueryContext: typeof import("#src/api/stats.mjs").skaterStatsWithQueryContext;
|
|
52
|
-
readonly goalieStatsSummary: typeof import("#src/api/stats.mjs").goalieStatsSummary;
|
|
53
|
-
}>;
|
|
57
|
+
readonly stats: StatsClient;
|
|
54
58
|
readonly misc: Bound<{
|
|
55
59
|
readonly glossary: typeof import("#src/api/misc.mjs").glossary;
|
|
56
60
|
readonly config: typeof import("#src/api/misc.mjs").config;
|
package/dist/nhl-client.mjs
CHANGED
|
@@ -5,15 +5,17 @@ import { miscApi } from '#src/api/misc.mjs';
|
|
|
5
5
|
import { playersApi } from '#src/api/players.mjs';
|
|
6
6
|
import { scheduleApi } from '#src/api/schedule.mjs';
|
|
7
7
|
import { standingsApi } from '#src/api/standings.mjs';
|
|
8
|
-
import { statsApi } from '#src/api/stats.mjs';
|
|
8
|
+
import { statsApi, } from '#src/api/stats.mjs';
|
|
9
9
|
import { teamsApi } from '#src/api/teams.mjs';
|
|
10
10
|
import { resolveConfig } from '#src/config.mjs';
|
|
11
11
|
import { createGet } from '#src/http-client.mjs';
|
|
12
12
|
import { sleep } from '#src/utils.mjs';
|
|
13
|
-
|
|
14
|
-
key,
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
function bind(ctx, api) {
|
|
14
|
+
return Object.fromEntries(Object.entries(api).map(([key, fn]) => [
|
|
15
|
+
key,
|
|
16
|
+
(...args) => fn(ctx, ...args),
|
|
17
|
+
]));
|
|
18
|
+
}
|
|
17
19
|
/**
|
|
18
20
|
* Builds the main client used to access the NHL API.
|
|
19
21
|
*
|
|
@@ -22,7 +24,7 @@ const bind = (ctx, api) => Object.fromEntries(Object.entries(api).map(([key, fn]
|
|
|
22
24
|
* const client = createNHLClient({ debug: true }); // for a lil extra logging
|
|
23
25
|
* const teams = await client.teams.teams();
|
|
24
26
|
*/
|
|
25
|
-
export
|
|
27
|
+
export function createNHLClient(options = {}) {
|
|
26
28
|
const config = resolveConfig(options);
|
|
27
29
|
const ctx = { get: createGet(config), sleep };
|
|
28
30
|
return {
|
|
@@ -37,4 +39,4 @@ export const createNHLClient = (options = {}) => {
|
|
|
37
39
|
players: bind(ctx, playersApi),
|
|
38
40
|
edge: bind(ctx, edgeApi),
|
|
39
41
|
};
|
|
40
|
-
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A string union that still accepts values the SDK doesn't know about yet.
|
|
3
|
+
* Autocomplete lists `Known`, but a new value from the NHL doesn't break
|
|
4
|
+
* consumers.
|
|
5
|
+
*/
|
|
6
|
+
export type OpenUnion<Known extends string> = Known | (string & {});
|
|
7
|
+
/** A name or label with optional translations; `default` is always present. */
|
|
8
|
+
export interface LocalizedString {
|
|
9
|
+
default: string;
|
|
10
|
+
cs?: string;
|
|
11
|
+
de?: string;
|
|
12
|
+
es?: string;
|
|
13
|
+
fi?: string;
|
|
14
|
+
fr?: string;
|
|
15
|
+
sk?: string;
|
|
16
|
+
sv?: string;
|
|
17
|
+
}
|
|
18
|
+
/** 1 = preseason, 2 = regular season, 3 = playoffs. Other codes (4 = all-star) exist. */
|
|
19
|
+
export type GameType = 1 | 2 | 3 | (number & {});
|
|
20
|
+
/** Season in YYYYYYYY form, e.g. 20232024. */
|
|
21
|
+
export type SeasonId = number;
|
|
22
|
+
export type GameState = OpenUnion<'FUT' | 'PRE' | 'LIVE' | 'CRIT' | 'FINAL' | 'OFF'>;
|
|
23
|
+
export type GameScheduleState = OpenUnion<'OK' | 'PPD' | 'SUSP' | 'CNCL' | 'TBD'>;
|
|
24
|
+
export type PeriodType = OpenUnion<'REG' | 'OT' | 'SO'>;
|
|
25
|
+
export type PositionCode = OpenUnion<'C' | 'L' | 'R' | 'D' | 'G'>;
|
|
26
|
+
export type ShootsCatches = OpenUnion<'L' | 'R'>;
|
|
27
|
+
export type ZoneCode = OpenUnion<'O' | 'N' | 'D'>;
|
|
28
|
+
export type ShotType = OpenUnion<'wrist' | 'snap' | 'slap' | 'backhand' | 'tip-in' | 'deflected' | 'wrap-around' | 'bat'>;
|
|
29
|
+
/** Envelope of the stats API (`api.nhle.com/stats/rest`) for paged reports. */
|
|
30
|
+
export interface StatsApiPage<Row> {
|
|
31
|
+
data: Row[];
|
|
32
|
+
total: number;
|
|
33
|
+
}
|
|
34
|
+
export interface GameOutcome {
|
|
35
|
+
lastPeriodType: PeriodType;
|
|
36
|
+
otPeriods?: number;
|
|
37
|
+
}
|
|
38
|
+
export interface PeriodDescriptor {
|
|
39
|
+
number: number;
|
|
40
|
+
periodType: PeriodType;
|
|
41
|
+
maxRegulationPeriods: number;
|
|
42
|
+
}
|
|
43
|
+
export interface SeriesStatus {
|
|
44
|
+
round: number;
|
|
45
|
+
seriesAbbrev: string;
|
|
46
|
+
seriesTitle: string;
|
|
47
|
+
seriesLetter: string;
|
|
48
|
+
neededToWin: number;
|
|
49
|
+
topSeedTeamAbbrev: string;
|
|
50
|
+
topSeedWins: number;
|
|
51
|
+
bottomSeedTeamAbbrev: string;
|
|
52
|
+
bottomSeedWins: number;
|
|
53
|
+
gameNumberOfSeries: number;
|
|
54
|
+
}
|
|
55
|
+
export interface TeamLogo {
|
|
56
|
+
light: string;
|
|
57
|
+
dark: string;
|
|
58
|
+
}
|
|
59
|
+
export interface TvBroadcast {
|
|
60
|
+
id: number;
|
|
61
|
+
market: string;
|
|
62
|
+
countryCode: string;
|
|
63
|
+
network: string;
|
|
64
|
+
sequenceNumber: number;
|
|
65
|
+
}
|
|
66
|
+
export interface OddsPartner {
|
|
67
|
+
partnerId: number;
|
|
68
|
+
country: string;
|
|
69
|
+
name: string;
|
|
70
|
+
imageUrl: string;
|
|
71
|
+
siteUrl: string;
|
|
72
|
+
bgColor: string;
|
|
73
|
+
textColor: string;
|
|
74
|
+
accentColor: string;
|
|
75
|
+
}
|
|
76
|
+
/** A betting provider's price for one side of a game. */
|
|
77
|
+
export interface TeamOdd {
|
|
78
|
+
providerId: number;
|
|
79
|
+
value: string;
|
|
80
|
+
}
|