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/helpers.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Context } from '#src/context.mjs';
|
|
2
|
-
import type {
|
|
2
|
+
import type { AllPlayersEntry, PlayerSummaryStatistics } from '#src/types/index.mjs';
|
|
3
|
+
import type { Id } from '#src/utils.mjs';
|
|
3
4
|
/**
|
|
4
5
|
* Gets all game IDs for a specified season by querying every team's
|
|
5
6
|
* schedule. Games appear once per participating team, so ids may repeat.
|
|
@@ -9,11 +10,11 @@ import type { Id, JsonObject } from '#src/utils.mjs';
|
|
|
9
10
|
* @param params.apiSleepRate Seconds to sleep between team requests. Defaults to 1.
|
|
10
11
|
* @example await client.helpers.gameIdsBySeason({ season: '20232024', gameTypes: [2] })
|
|
11
12
|
*/
|
|
12
|
-
export declare
|
|
13
|
+
export declare function gameIdsBySeason(ctx: Context, { season, gameTypes, apiSleepRate, }: {
|
|
13
14
|
season: Id;
|
|
14
15
|
gameTypes?: number[];
|
|
15
16
|
apiSleepRate?: number;
|
|
16
|
-
})
|
|
17
|
+
}): Promise<number[]>;
|
|
17
18
|
/**
|
|
18
19
|
* Gets every rostered player across all NHL teams for a given season. Each
|
|
19
20
|
* player gets a `team` abbreviation and flattened `firstName` / `lastName`.
|
|
@@ -22,10 +23,10 @@ export declare const gameIdsBySeason: (ctx: Context, { season, gameTypes, apiSle
|
|
|
22
23
|
* @param params.apiSleepRate Seconds to sleep between team requests. Defaults to 0.5.
|
|
23
24
|
* @example await client.helpers.allPlayers({ season: '20232024' })
|
|
24
25
|
*/
|
|
25
|
-
export declare
|
|
26
|
+
export declare function allPlayers(ctx: Context, { season, apiSleepRate }: {
|
|
26
27
|
season: Id;
|
|
27
28
|
apiSleepRate?: number;
|
|
28
|
-
})
|
|
29
|
+
}): Promise<AllPlayersEntry[]>;
|
|
29
30
|
/**
|
|
30
31
|
* Gets summary statistics for every skater in a given season, merged with
|
|
31
32
|
* the roster info from `allPlayers` (stat fields win on key collisions).
|
|
@@ -35,10 +36,10 @@ export declare const allPlayers: (ctx: Context, { season, apiSleepRate }: {
|
|
|
35
36
|
* @param params.apiSleepRate Seconds to sleep between team requests. Defaults to 1.
|
|
36
37
|
* @example await client.helpers.allPlayersSummaryStatistics({ season: '20232024' })
|
|
37
38
|
*/
|
|
38
|
-
export declare
|
|
39
|
+
export declare function allPlayersSummaryStatistics(ctx: Context, { season, apiSleepRate }: {
|
|
39
40
|
season: Id;
|
|
40
41
|
apiSleepRate?: number;
|
|
41
|
-
})
|
|
42
|
+
}): Promise<PlayerSummaryStatistics[]>;
|
|
42
43
|
export declare const helpersApi: {
|
|
43
44
|
readonly gameIdsBySeason: typeof gameIdsBySeason;
|
|
44
45
|
readonly allPlayers: typeof allPlayers;
|
package/dist/api/helpers.mjs
CHANGED
|
@@ -12,7 +12,7 @@ import { teams as fetchTeams, teamRoster } from '#src/api/teams.mjs';
|
|
|
12
12
|
* @param params.apiSleepRate Seconds to sleep between team requests. Defaults to 1.
|
|
13
13
|
* @example await client.helpers.gameIdsBySeason({ season: '20232024', gameTypes: [2] })
|
|
14
14
|
*/
|
|
15
|
-
export
|
|
15
|
+
export async function gameIdsBySeason(ctx, { season, gameTypes, apiSleepRate = 1, }) {
|
|
16
16
|
const teams = await fetchTeams(ctx);
|
|
17
17
|
const gameIds = [];
|
|
18
18
|
for (const team of teams) {
|
|
@@ -33,7 +33,7 @@ export const gameIdsBySeason = async (ctx, { season, gameTypes, apiSleepRate = 1
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
return gameIds;
|
|
36
|
-
}
|
|
36
|
+
}
|
|
37
37
|
/**
|
|
38
38
|
* Gets every rostered player across all NHL teams for a given season. Each
|
|
39
39
|
* player gets a `team` abbreviation and flattened `firstName` / `lastName`.
|
|
@@ -42,7 +42,7 @@ export const gameIdsBySeason = async (ctx, { season, gameTypes, apiSleepRate = 1
|
|
|
42
42
|
* @param params.apiSleepRate Seconds to sleep between team requests. Defaults to 0.5.
|
|
43
43
|
* @example await client.helpers.allPlayers({ season: '20232024' })
|
|
44
44
|
*/
|
|
45
|
-
export
|
|
45
|
+
export async function allPlayers(ctx, { season, apiSleepRate = 0.5 }) {
|
|
46
46
|
const teams = await fetchTeams(ctx);
|
|
47
47
|
console.error('Fetching all player base stats. This may take a while...');
|
|
48
48
|
const outData = [];
|
|
@@ -63,7 +63,7 @@ export const allPlayers = async (ctx, { season, apiSleepRate = 0.5 }) => {
|
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
return outData;
|
|
66
|
-
}
|
|
66
|
+
}
|
|
67
67
|
/**
|
|
68
68
|
* Gets summary statistics for every skater in a given season, merged with
|
|
69
69
|
* the roster info from `allPlayers` (stat fields win on key collisions).
|
|
@@ -73,7 +73,7 @@ export const allPlayers = async (ctx, { season, apiSleepRate = 0.5 }) => {
|
|
|
73
73
|
* @param params.apiSleepRate Seconds to sleep between team requests. Defaults to 1.
|
|
74
74
|
* @example await client.helpers.allPlayersSummaryStatistics({ season: '20232024' })
|
|
75
75
|
*/
|
|
76
|
-
export
|
|
76
|
+
export async function allPlayersSummaryStatistics(ctx, { season, apiSleepRate = 1 }) {
|
|
77
77
|
console.error('WARNING: This method will take a while to run. In the event of rate limiting, you may need to increase the api_sleep_rate.');
|
|
78
78
|
const players = await allPlayers(ctx, { season, apiSleepRate });
|
|
79
79
|
const teams = await fetchTeams(ctx);
|
|
@@ -98,7 +98,7 @@ export const allPlayersSummaryStatistics = async (ctx, { season, apiSleepRate =
|
|
|
98
98
|
: undefined;
|
|
99
99
|
return player ? { ...player, ...statEntry } : statEntry;
|
|
100
100
|
});
|
|
101
|
-
}
|
|
101
|
+
}
|
|
102
102
|
export const helpersApi = {
|
|
103
103
|
gameIdsBySeason,
|
|
104
104
|
allPlayers,
|
package/dist/api/misc.d.mts
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
import type { Context } from '#src/context.mjs';
|
|
2
|
-
import type {
|
|
2
|
+
import type { Country, DraftYear, GlossaryEntry, SeasonRules, StatsConfig } from '#src/types/index.mjs';
|
|
3
3
|
/**
|
|
4
4
|
* Gets the full NHL glossary of statistical terms and abbreviations.
|
|
5
5
|
*
|
|
6
6
|
* @example https://api.nhle.com/stats/rest/en/glossary?sort=fullName
|
|
7
7
|
*/
|
|
8
|
-
export declare
|
|
8
|
+
export declare function glossary(ctx: Context): Promise<GlossaryEntry[]>;
|
|
9
9
|
/**
|
|
10
10
|
* Gets the stats API configuration, including available report types and
|
|
11
11
|
* filters.
|
|
12
12
|
*
|
|
13
13
|
* @example https://api.nhle.com/stats/rest/en/config
|
|
14
14
|
*/
|
|
15
|
-
export declare
|
|
15
|
+
export declare function config(ctx: Context): Promise<StatsConfig>;
|
|
16
16
|
/**
|
|
17
17
|
* Gets the list of countries recognized by the NHL.
|
|
18
18
|
*
|
|
19
19
|
* @example https://api.nhle.com/stats/rest/en/country
|
|
20
20
|
*/
|
|
21
|
-
export declare
|
|
21
|
+
export declare function countries(ctx: Context): Promise<Country[]>;
|
|
22
22
|
/**
|
|
23
23
|
* Gets rules and metadata for every NHL season on record.
|
|
24
24
|
*
|
|
25
25
|
* @example https://api.nhle.com/stats/rest/en/season
|
|
26
26
|
*/
|
|
27
|
-
export declare
|
|
27
|
+
export declare function seasonSpecificRulesAndInfo(ctx: Context): Promise<SeasonRules[]>;
|
|
28
28
|
/**
|
|
29
29
|
* Gets the number of rounds for each NHL draft year.
|
|
30
30
|
*
|
|
31
31
|
* @example https://api.nhle.com/stats/rest/en/draft
|
|
32
32
|
*/
|
|
33
|
-
export declare
|
|
33
|
+
export declare function draftYearAndRounds(ctx: Context): Promise<DraftYear[]>;
|
|
34
34
|
export declare const miscApi: {
|
|
35
35
|
readonly glossary: typeof glossary;
|
|
36
36
|
readonly config: typeof config;
|
package/dist/api/misc.mjs
CHANGED
|
@@ -8,32 +8,42 @@ async function getData(ctx, resource) {
|
|
|
8
8
|
*
|
|
9
9
|
* @example https://api.nhle.com/stats/rest/en/glossary?sort=fullName
|
|
10
10
|
*/
|
|
11
|
-
export
|
|
11
|
+
export async function glossary(ctx) {
|
|
12
|
+
return getData(ctx, 'stats/rest/en/glossary?sort=fullName');
|
|
13
|
+
}
|
|
12
14
|
/**
|
|
13
15
|
* Gets the stats API configuration, including available report types and
|
|
14
16
|
* filters.
|
|
15
17
|
*
|
|
16
18
|
* @example https://api.nhle.com/stats/rest/en/config
|
|
17
19
|
*/
|
|
18
|
-
export
|
|
20
|
+
export async function config(ctx) {
|
|
21
|
+
return (await ctx.get(Endpoint.API_CORE, 'stats/rest/en/config')).json();
|
|
22
|
+
}
|
|
19
23
|
/**
|
|
20
24
|
* Gets the list of countries recognized by the NHL.
|
|
21
25
|
*
|
|
22
26
|
* @example https://api.nhle.com/stats/rest/en/country
|
|
23
27
|
*/
|
|
24
|
-
export
|
|
28
|
+
export async function countries(ctx) {
|
|
29
|
+
return getData(ctx, 'stats/rest/en/country');
|
|
30
|
+
}
|
|
25
31
|
/**
|
|
26
32
|
* Gets rules and metadata for every NHL season on record.
|
|
27
33
|
*
|
|
28
34
|
* @example https://api.nhle.com/stats/rest/en/season
|
|
29
35
|
*/
|
|
30
|
-
export
|
|
36
|
+
export async function seasonSpecificRulesAndInfo(ctx) {
|
|
37
|
+
return getData(ctx, 'stats/rest/en/season');
|
|
38
|
+
}
|
|
31
39
|
/**
|
|
32
40
|
* Gets the number of rounds for each NHL draft year.
|
|
33
41
|
*
|
|
34
42
|
* @example https://api.nhle.com/stats/rest/en/draft
|
|
35
43
|
*/
|
|
36
|
-
export
|
|
44
|
+
export async function draftYearAndRounds(ctx) {
|
|
45
|
+
return getData(ctx, 'stats/rest/en/draft');
|
|
46
|
+
}
|
|
37
47
|
export const miscApi = {
|
|
38
48
|
glossary,
|
|
39
49
|
config,
|
package/dist/api/players.d.mts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import type { Context } from '#src/context.mjs';
|
|
2
|
-
import type {
|
|
2
|
+
import type { Prospects, Roster } from '#src/types/index.mjs';
|
|
3
|
+
import type { Id } from '#src/utils.mjs';
|
|
3
4
|
/**
|
|
4
5
|
* Gets prospects for a specific team, grouped by position.
|
|
5
6
|
*
|
|
6
7
|
* @param params.teamAbbr Team abbreviation, e.g. BUF, TOR
|
|
7
8
|
* @example https://api-web.nhle.com/v1/prospects/BUF
|
|
8
9
|
*/
|
|
9
|
-
export declare
|
|
10
|
+
export declare function prospectsByTeam(ctx: Context, { teamAbbr }: {
|
|
10
11
|
teamAbbr: string;
|
|
11
|
-
})
|
|
12
|
+
}): Promise<Prospects>;
|
|
12
13
|
/**
|
|
13
14
|
* Gets the roster for a given team and season, grouped by position
|
|
14
15
|
* (forwards, defensemen, goalies). Same data as `teams.teamRoster`.
|
|
@@ -17,10 +18,10 @@ export declare const prospectsByTeam: (ctx: Context, { teamAbbr }: {
|
|
|
17
18
|
* @param params.season Season in YYYYYYYY format, e.g. 20232024
|
|
18
19
|
* @example https://api-web.nhle.com/v1/roster/BUF/20232024
|
|
19
20
|
*/
|
|
20
|
-
export declare
|
|
21
|
+
export declare function playersByTeam(ctx: Context, { teamAbbr, season }: {
|
|
21
22
|
teamAbbr: string;
|
|
22
23
|
season: Id;
|
|
23
|
-
})
|
|
24
|
+
}): Promise<Roster>;
|
|
24
25
|
export declare const playersApi: {
|
|
25
26
|
readonly prospectsByTeam: typeof prospectsByTeam;
|
|
26
27
|
readonly playersByTeam: typeof playersByTeam;
|
package/dist/api/players.mjs
CHANGED
|
@@ -5,7 +5,9 @@ import { Endpoint } from '#src/http-client.mjs';
|
|
|
5
5
|
* @param params.teamAbbr Team abbreviation, e.g. BUF, TOR
|
|
6
6
|
* @example https://api-web.nhle.com/v1/prospects/BUF
|
|
7
7
|
*/
|
|
8
|
-
export
|
|
8
|
+
export async function prospectsByTeam(ctx, { teamAbbr }) {
|
|
9
|
+
return (await ctx.get(Endpoint.API_WEB_V1, `prospects/${teamAbbr}`)).json();
|
|
10
|
+
}
|
|
9
11
|
/**
|
|
10
12
|
* Gets the roster for a given team and season, grouped by position
|
|
11
13
|
* (forwards, defensemen, goalies). Same data as `teams.teamRoster`.
|
|
@@ -14,5 +16,7 @@ export const prospectsByTeam = async (ctx, { teamAbbr }) => (await ctx.get(Endpo
|
|
|
14
16
|
* @param params.season Season in YYYYYYYY format, e.g. 20232024
|
|
15
17
|
* @example https://api-web.nhle.com/v1/roster/BUF/20232024
|
|
16
18
|
*/
|
|
17
|
-
export
|
|
19
|
+
export async function playersByTeam(ctx, { teamAbbr, season }) {
|
|
20
|
+
return (await ctx.get(Endpoint.API_WEB_V1, `roster/${teamAbbr}/${season}`)).json();
|
|
21
|
+
}
|
|
18
22
|
export const playersApi = { prospectsByTeam, playersByTeam };
|
|
@@ -15,6 +15,8 @@ export interface QueryContext {
|
|
|
15
15
|
* filters are skipped and their errors collected; valid filters are joined
|
|
16
16
|
* with " and ".
|
|
17
17
|
*/
|
|
18
|
+
/** Fact filter `buildQuery` applies unless told otherwise. */
|
|
19
|
+
export declare const DEFAULT_FACT_QUERY = "gamesPlayed>=1";
|
|
18
20
|
export declare function buildQuery(filters: readonly Filter[], factQuery?: string): QueryContext;
|
|
19
21
|
/** True if there are no validation errors. */
|
|
20
22
|
export declare function isValidQuery(context: QueryContext): boolean;
|
|
@@ -4,7 +4,9 @@ import { toQuery, validateFilter } from '#src/api/query/filters.mjs';
|
|
|
4
4
|
* filters are skipped and their errors collected; valid filters are joined
|
|
5
5
|
* with " and ".
|
|
6
6
|
*/
|
|
7
|
-
|
|
7
|
+
/** Fact filter `buildQuery` applies unless told otherwise. */
|
|
8
|
+
export const DEFAULT_FACT_QUERY = 'gamesPlayed>=1';
|
|
9
|
+
export function buildQuery(filters, factQuery = DEFAULT_FACT_QUERY) {
|
|
8
10
|
const outputFilters = [];
|
|
9
11
|
const errors = [];
|
|
10
12
|
for (const filter of filters) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { buildQuery, isValidQuery, type QueryContext, } from '#src/api/query/builder.mjs';
|
|
2
2
|
export * from '#src/api/query/filters.mjs';
|
|
3
|
-
export { goalieStatsSorts } from '#src/api/query/sorting/goalie-sorts.mjs';
|
|
4
|
-
export { defaultSortForReport, SKATER_REPORT_TYPES, type SortExpr, } from '#src/api/query/sorting/sorting-options.mjs';
|
|
3
|
+
export { type GoalieReportType, goalieStatsSorts, } from '#src/api/query/sorting/goalie-sorts.mjs';
|
|
4
|
+
export { defaultSortForReport, SKATER_REPORT_TYPES, type SkaterReportType, type SortExpr, } from '#src/api/query/sorting/sorting-options.mjs';
|
package/dist/api/query/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { buildQuery, isValidQuery, } from '#src/api/query/builder.mjs';
|
|
2
2
|
export * from '#src/api/query/filters.mjs';
|
|
3
|
-
export { goalieStatsSorts } from '#src/api/query/sorting/goalie-sorts.mjs';
|
|
3
|
+
export { goalieStatsSorts, } from '#src/api/query/sorting/goalie-sorts.mjs';
|
|
4
4
|
export { defaultSortForReport, SKATER_REPORT_TYPES, } from '#src/api/query/sorting/sorting-options.mjs';
|
|
@@ -1,4 +1,59 @@
|
|
|
1
1
|
import type { SortExpr } from '#src/api/query/sorting/sorting-options.mjs';
|
|
2
|
+
/** Default sort criteria per goalie report type. */
|
|
3
|
+
export declare const goalieSortingByReport: {
|
|
4
|
+
summary: SortExpr[];
|
|
5
|
+
advanced: ({
|
|
6
|
+
property: string;
|
|
7
|
+
direction: "DESC";
|
|
8
|
+
} | {
|
|
9
|
+
property: string;
|
|
10
|
+
direction: "ASC";
|
|
11
|
+
})[];
|
|
12
|
+
bios: ({
|
|
13
|
+
property: string;
|
|
14
|
+
direction: "ASC_CI";
|
|
15
|
+
} | {
|
|
16
|
+
property: string;
|
|
17
|
+
direction: "ASC";
|
|
18
|
+
})[];
|
|
19
|
+
daysrest: ({
|
|
20
|
+
property: string;
|
|
21
|
+
direction: "DESC";
|
|
22
|
+
} | {
|
|
23
|
+
property: string;
|
|
24
|
+
direction: "ASC";
|
|
25
|
+
})[];
|
|
26
|
+
penaltyShots: ({
|
|
27
|
+
property: string;
|
|
28
|
+
direction: "DESC";
|
|
29
|
+
} | {
|
|
30
|
+
property: string;
|
|
31
|
+
direction: "ASC";
|
|
32
|
+
})[];
|
|
33
|
+
savesByStrength: ({
|
|
34
|
+
property: string;
|
|
35
|
+
direction: "DESC";
|
|
36
|
+
} | {
|
|
37
|
+
property: string;
|
|
38
|
+
direction: "ASC";
|
|
39
|
+
})[];
|
|
40
|
+
shootout: ({
|
|
41
|
+
property: string;
|
|
42
|
+
direction: "DESC";
|
|
43
|
+
} | {
|
|
44
|
+
property: string;
|
|
45
|
+
direction: "ASC";
|
|
46
|
+
})[];
|
|
47
|
+
startedVsRelieved: ({
|
|
48
|
+
property: string;
|
|
49
|
+
direction: "DESC";
|
|
50
|
+
} | {
|
|
51
|
+
property: string;
|
|
52
|
+
direction: "ASC";
|
|
53
|
+
})[];
|
|
54
|
+
};
|
|
55
|
+
/** Goalie report types that have a default sort configured. */
|
|
56
|
+
export type GoalieReportType = keyof typeof goalieSortingByReport;
|
|
2
57
|
/**
|
|
3
58
|
* Default sorting criteria for goalie stats reports. Falls back to the
|
|
4
59
|
* goalie summary sort for unknown report types.
|
|
@@ -3,57 +3,52 @@ const goalieSummaryDefaultSorting = [
|
|
|
3
3
|
{ property: 'gamesPlayed', direction: 'ASC' },
|
|
4
4
|
{ property: 'playerId', direction: 'ASC' },
|
|
5
5
|
];
|
|
6
|
+
/** Default sort criteria per goalie report type. */
|
|
7
|
+
export const goalieSortingByReport = {
|
|
8
|
+
summary: goalieSummaryDefaultSorting,
|
|
9
|
+
advanced: [
|
|
10
|
+
{ property: 'qualityStart', direction: 'DESC' },
|
|
11
|
+
{ property: 'goalsAgainstAverage', direction: 'ASC' },
|
|
12
|
+
{ property: 'playerId', direction: 'ASC' },
|
|
13
|
+
],
|
|
14
|
+
bios: [
|
|
15
|
+
{ property: 'lastName', direction: 'ASC_CI' },
|
|
16
|
+
{ property: 'goalieFullName', direction: 'ASC_CI' },
|
|
17
|
+
{ property: 'playerId', direction: 'ASC' },
|
|
18
|
+
],
|
|
19
|
+
daysrest: [
|
|
20
|
+
{ property: 'wins', direction: 'DESC' },
|
|
21
|
+
{ property: 'savePct', direction: 'DESC' },
|
|
22
|
+
{ property: 'playerId', direction: 'ASC' },
|
|
23
|
+
],
|
|
24
|
+
penaltyShots: [
|
|
25
|
+
{ property: 'penaltyShotsSaves', direction: 'DESC' },
|
|
26
|
+
{ property: 'penaltyShotSavePct', direction: 'DESC' },
|
|
27
|
+
{ property: 'playerId', direction: 'ASC' },
|
|
28
|
+
],
|
|
29
|
+
savesByStrength: [
|
|
30
|
+
{ property: 'wins', direction: 'DESC' },
|
|
31
|
+
{ property: 'savePct', direction: 'DESC' },
|
|
32
|
+
{ property: 'playerId', direction: 'ASC' },
|
|
33
|
+
],
|
|
34
|
+
shootout: [
|
|
35
|
+
{ property: 'shootoutWins', direction: 'DESC' },
|
|
36
|
+
{ property: 'shootoutSavePct', direction: 'DESC' },
|
|
37
|
+
{ property: 'playerId', direction: 'ASC' },
|
|
38
|
+
],
|
|
39
|
+
startedVsRelieved: [
|
|
40
|
+
{ property: 'gamesStarted', direction: 'DESC' },
|
|
41
|
+
{ property: 'gamesStartedSavePct', direction: 'DESC' },
|
|
42
|
+
{ property: 'playerId', direction: 'ASC' },
|
|
43
|
+
],
|
|
44
|
+
};
|
|
45
|
+
const sortingLookup = goalieSortingByReport;
|
|
6
46
|
/**
|
|
7
47
|
* Default sorting criteria for goalie stats reports. Falls back to the
|
|
8
48
|
* goalie summary sort for unknown report types.
|
|
9
49
|
*/
|
|
10
50
|
export function goalieStatsSorts(report) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
case 'advanced':
|
|
15
|
-
return [
|
|
16
|
-
{ property: 'qualityStart', direction: 'DESC' },
|
|
17
|
-
{ property: 'goalsAgainstAverage', direction: 'ASC' },
|
|
18
|
-
{ property: 'playerId', direction: 'ASC' },
|
|
19
|
-
];
|
|
20
|
-
case 'bios':
|
|
21
|
-
return [
|
|
22
|
-
{ property: 'lastName', direction: 'ASC_CI' },
|
|
23
|
-
{ property: 'goalieFullName', direction: 'ASC_CI' },
|
|
24
|
-
{ property: 'playerId', direction: 'ASC' },
|
|
25
|
-
];
|
|
26
|
-
case 'daysrest':
|
|
27
|
-
return [
|
|
28
|
-
{ property: 'wins', direction: 'DESC' },
|
|
29
|
-
{ property: 'savePct', direction: 'DESC' },
|
|
30
|
-
{ property: 'playerId', direction: 'ASC' },
|
|
31
|
-
];
|
|
32
|
-
case 'penaltyShots':
|
|
33
|
-
return [
|
|
34
|
-
{ property: 'penaltyShotsSaves', direction: 'DESC' },
|
|
35
|
-
{ property: 'penaltyShotSavePct', direction: 'DESC' },
|
|
36
|
-
{ property: 'playerId', direction: 'ASC' },
|
|
37
|
-
];
|
|
38
|
-
case 'savesByStrength':
|
|
39
|
-
return [
|
|
40
|
-
{ property: 'wins', direction: 'DESC' },
|
|
41
|
-
{ property: 'savePct', direction: 'DESC' },
|
|
42
|
-
{ property: 'playerId', direction: 'ASC' },
|
|
43
|
-
];
|
|
44
|
-
case 'shootout':
|
|
45
|
-
return [
|
|
46
|
-
{ property: 'shootoutWins', direction: 'DESC' },
|
|
47
|
-
{ property: 'shootoutSavePct', direction: 'DESC' },
|
|
48
|
-
{ property: 'playerId', direction: 'ASC' },
|
|
49
|
-
];
|
|
50
|
-
case 'startedVsRelieved':
|
|
51
|
-
return [
|
|
52
|
-
{ property: 'gamesStarted', direction: 'DESC' },
|
|
53
|
-
{ property: 'gamesStartedSavePct', direction: 'DESC' },
|
|
54
|
-
{ property: 'playerId', direction: 'ASC' },
|
|
55
|
-
];
|
|
56
|
-
default:
|
|
57
|
-
return goalieSummaryDefaultSorting;
|
|
58
|
-
}
|
|
51
|
+
return ((Object.hasOwn(sortingLookup, report)
|
|
52
|
+
? sortingLookup[report]
|
|
53
|
+
: undefined) ?? goalieSummaryDefaultSorting);
|
|
59
54
|
}
|
|
@@ -2,6 +2,130 @@ export interface SortExpr {
|
|
|
2
2
|
property: string;
|
|
3
3
|
direction: 'ASC' | 'DESC' | 'ASC_CI' | 'DESC_CI' | (string & {});
|
|
4
4
|
}
|
|
5
|
+
declare const defaultSortingByReport: {
|
|
6
|
+
summary: SortExpr[];
|
|
7
|
+
bios: ({
|
|
8
|
+
property: string;
|
|
9
|
+
direction: "ASC_CI";
|
|
10
|
+
} | {
|
|
11
|
+
property: string;
|
|
12
|
+
direction: "ASC";
|
|
13
|
+
})[];
|
|
14
|
+
faceoffpercentages: ({
|
|
15
|
+
property: string;
|
|
16
|
+
direction: "DESC";
|
|
17
|
+
} | {
|
|
18
|
+
property: string;
|
|
19
|
+
direction: "ASC";
|
|
20
|
+
})[];
|
|
21
|
+
faceoffwins: ({
|
|
22
|
+
property: string;
|
|
23
|
+
direction: "DESC";
|
|
24
|
+
} | {
|
|
25
|
+
property: string;
|
|
26
|
+
direction: "ASC";
|
|
27
|
+
})[];
|
|
28
|
+
goalsForAgainst: ({
|
|
29
|
+
property: string;
|
|
30
|
+
direction: "DESC";
|
|
31
|
+
} | {
|
|
32
|
+
property: string;
|
|
33
|
+
direction: "ASC";
|
|
34
|
+
})[];
|
|
35
|
+
realtime: ({
|
|
36
|
+
property: string;
|
|
37
|
+
direction: "DESC";
|
|
38
|
+
} | {
|
|
39
|
+
property: string;
|
|
40
|
+
direction: "ASC";
|
|
41
|
+
})[];
|
|
42
|
+
penalties: ({
|
|
43
|
+
property: string;
|
|
44
|
+
direction: "DESC";
|
|
45
|
+
} | {
|
|
46
|
+
property: string;
|
|
47
|
+
direction: "ASC";
|
|
48
|
+
})[];
|
|
49
|
+
penaltykill: ({
|
|
50
|
+
property: string;
|
|
51
|
+
direction: "DESC";
|
|
52
|
+
} | {
|
|
53
|
+
property: string;
|
|
54
|
+
direction: "ASC";
|
|
55
|
+
})[];
|
|
56
|
+
penaltyShots: ({
|
|
57
|
+
property: string;
|
|
58
|
+
direction: "DESC";
|
|
59
|
+
} | {
|
|
60
|
+
property: string;
|
|
61
|
+
direction: "ASC";
|
|
62
|
+
})[];
|
|
63
|
+
powerplay: ({
|
|
64
|
+
property: string;
|
|
65
|
+
direction: "DESC";
|
|
66
|
+
} | {
|
|
67
|
+
property: string;
|
|
68
|
+
direction: "ASC";
|
|
69
|
+
})[];
|
|
70
|
+
puckPossessions: ({
|
|
71
|
+
property: string;
|
|
72
|
+
direction: "DESC";
|
|
73
|
+
} | {
|
|
74
|
+
property: string;
|
|
75
|
+
direction: "ASC";
|
|
76
|
+
})[];
|
|
77
|
+
summaryshooting: ({
|
|
78
|
+
property: string;
|
|
79
|
+
direction: "DESC";
|
|
80
|
+
} | {
|
|
81
|
+
property: string;
|
|
82
|
+
direction: "ASC";
|
|
83
|
+
})[];
|
|
84
|
+
percentages: ({
|
|
85
|
+
property: string;
|
|
86
|
+
direction: "DESC";
|
|
87
|
+
} | {
|
|
88
|
+
property: string;
|
|
89
|
+
direction: "ASC";
|
|
90
|
+
})[];
|
|
91
|
+
scoringRates: ({
|
|
92
|
+
property: string;
|
|
93
|
+
direction: "DESC";
|
|
94
|
+
} | {
|
|
95
|
+
property: string;
|
|
96
|
+
direction: "ASC";
|
|
97
|
+
})[];
|
|
98
|
+
scoringpergame: ({
|
|
99
|
+
property: string;
|
|
100
|
+
direction: "DESC";
|
|
101
|
+
} | {
|
|
102
|
+
property: string;
|
|
103
|
+
direction: "ASC";
|
|
104
|
+
})[];
|
|
105
|
+
shootout: ({
|
|
106
|
+
property: string;
|
|
107
|
+
direction: "DESC";
|
|
108
|
+
} | {
|
|
109
|
+
property: string;
|
|
110
|
+
direction: "ASC";
|
|
111
|
+
})[];
|
|
112
|
+
shottype: ({
|
|
113
|
+
property: string;
|
|
114
|
+
direction: "DESC";
|
|
115
|
+
} | {
|
|
116
|
+
property: string;
|
|
117
|
+
direction: "ASC";
|
|
118
|
+
})[];
|
|
119
|
+
timeonice: ({
|
|
120
|
+
property: string;
|
|
121
|
+
direction: "DESC";
|
|
122
|
+
} | {
|
|
123
|
+
property: string;
|
|
124
|
+
direction: "ASC";
|
|
125
|
+
})[];
|
|
126
|
+
};
|
|
127
|
+
/** Skater report types that have a default sort configured. */
|
|
128
|
+
export type SkaterReportType = keyof typeof defaultSortingByReport;
|
|
5
129
|
/** Skater report types that have a default sort configured. */
|
|
6
130
|
export declare const SKATER_REPORT_TYPES: string[];
|
|
7
131
|
/**
|
|
@@ -9,3 +133,4 @@ export declare const SKATER_REPORT_TYPES: string[];
|
|
|
9
133
|
* summary sort for unknown report types.
|
|
10
134
|
*/
|
|
11
135
|
export declare function defaultSortForReport(report: string): SortExpr[];
|
|
136
|
+
export {};
|
|
@@ -80,6 +80,7 @@ const defaultSortingByReport = {
|
|
|
80
80
|
{ property: 'playerId', direction: 'ASC' },
|
|
81
81
|
],
|
|
82
82
|
};
|
|
83
|
+
const sortingLookup = defaultSortingByReport;
|
|
83
84
|
/** Skater report types that have a default sort configured. */
|
|
84
85
|
export const SKATER_REPORT_TYPES = Object.keys(defaultSortingByReport);
|
|
85
86
|
/**
|
|
@@ -87,7 +88,7 @@ export const SKATER_REPORT_TYPES = Object.keys(defaultSortingByReport);
|
|
|
87
88
|
* summary sort for unknown report types.
|
|
88
89
|
*/
|
|
89
90
|
export function defaultSortForReport(report) {
|
|
90
|
-
return ((Object.hasOwn(
|
|
91
|
-
?
|
|
91
|
+
return ((Object.hasOwn(sortingLookup, report)
|
|
92
|
+
? sortingLookup[report]
|
|
92
93
|
: undefined) ?? skaterSummaryDefaultSorting);
|
|
93
94
|
}
|