nhl-api-ts 0.0.0-stage → 0.2.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.
- package/LICENSE +21 -0
- package/README.md +315 -2
- package/dist/api/edge.d.mts +180 -0
- package/dist/api/edge.mjs +184 -0
- package/dist/api/game-center.d.mts +84 -0
- package/dist/api/game-center.mjs +74 -0
- package/dist/api/helpers.d.mts +47 -0
- package/dist/api/helpers.mjs +106 -0
- package/dist/api/misc.d.mts +40 -0
- package/dist/api/misc.mjs +43 -0
- package/dist/api/players.d.mts +28 -0
- package/dist/api/players.mjs +18 -0
- package/dist/api/query/builder.d.mts +22 -0
- package/dist/api/query/builder.mjs +30 -0
- package/dist/api/query/filters.d.mts +93 -0
- package/dist/api/query/filters.mjs +118 -0
- package/dist/api/query/index.d.mts +4 -0
- package/dist/api/query/index.mjs +4 -0
- package/dist/api/query/sorting/goalie-sorts.d.mts +61 -0
- package/dist/api/query/sorting/goalie-sorts.mjs +54 -0
- package/dist/api/query/sorting/sorting-options.d.mts +136 -0
- package/dist/api/query/sorting/sorting-options.mjs +94 -0
- package/dist/api/schedule.d.mts +117 -0
- package/dist/api/schedule.mjs +131 -0
- package/dist/api/standings.d.mts +29 -0
- package/dist/api/standings.mjs +38 -0
- package/dist/api/stats.d.mts +153 -0
- package/dist/api/stats.mjs +166 -0
- package/dist/api/teams.d.mts +59 -0
- package/dist/api/teams.mjs +91 -0
- package/dist/cli/colors.d.mts +14 -0
- package/dist/cli/colors.mjs +13 -0
- package/dist/cli/commands.d.mts +27 -0
- package/dist/cli/commands.mjs +695 -0
- package/dist/cli/run.d.mts +9 -0
- package/dist/cli/run.mjs +313 -0
- package/dist/cli.d.mts +2 -0
- package/dist/cli.mjs +13 -0
- package/dist/config.d.mts +20 -0
- package/dist/config.mjs +4 -0
- package/dist/context.d.mts +6 -0
- package/dist/context.mjs +1 -0
- package/dist/errors.d.mts +35 -0
- package/dist/errors.mjs +49 -0
- package/dist/http-client.d.mts +27 -0
- package/dist/http-client.mjs +95 -0
- package/dist/index.d.mts +22 -0
- package/dist/index.mjs +15 -0
- package/dist/nhl-client.d.mts +101 -0
- package/dist/nhl-client.mjs +40 -0
- package/dist/types/common.d.mts +81 -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 +1194 -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 +42 -0
- package/dist/types/players.mjs +1 -0
- package/dist/types/schedule.d.mts +456 -0
- package/dist/types/schedule.mjs +1 -0
- package/dist/types/standings.d.mts +104 -0
- package/dist/types/standings.mjs +1 -0
- package/dist/types/stats.d.mts +1086 -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 +4 -0
- package/dist/utils.mjs +3 -0
- package/package.json +85 -3
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { toQuery, validateFilter } from '#src/api/query/filters.mjs';
|
|
2
|
+
/**
|
|
3
|
+
* Builds and validates a query string from a list of filters. Invalid
|
|
4
|
+
* filters are skipped and their errors collected; valid filters are joined
|
|
5
|
+
* with " and ".
|
|
6
|
+
*/
|
|
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) {
|
|
10
|
+
const outputFilters = [];
|
|
11
|
+
const errors = [];
|
|
12
|
+
for (const filter of filters) {
|
|
13
|
+
const error = validateFilter(filter);
|
|
14
|
+
if (error) {
|
|
15
|
+
errors.push(error);
|
|
16
|
+
continue;
|
|
17
|
+
}
|
|
18
|
+
outputFilters.push(toQuery(filter));
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
query: outputFilters.join(' and '),
|
|
22
|
+
filters,
|
|
23
|
+
errors,
|
|
24
|
+
factQuery,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/** True if there are no validation errors. */
|
|
28
|
+
export function isValidQuery(context) {
|
|
29
|
+
return context.errors.length === 0;
|
|
30
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { Id } from '#src/utils.mjs';
|
|
2
|
+
export declare const PositionTypes: {
|
|
3
|
+
readonly ALL_FORWARDS: 'F';
|
|
4
|
+
readonly CENTER: 'C';
|
|
5
|
+
readonly LEFT_WING: 'L';
|
|
6
|
+
readonly RIGHT_WING: 'R';
|
|
7
|
+
readonly DEFENSE: 'D';
|
|
8
|
+
};
|
|
9
|
+
export type PositionTypes = (typeof PositionTypes)[keyof typeof PositionTypes];
|
|
10
|
+
/** Goalie decision. W=win, L=loss, O=overtime loss. */
|
|
11
|
+
export type Decision = 'W' | 'L' | 'O';
|
|
12
|
+
export interface StatusQueryOptions {
|
|
13
|
+
/** Only current active players. */
|
|
14
|
+
isActive?: boolean;
|
|
15
|
+
/** Only Hall of Fame players. Takes precedence over `isActive`. */
|
|
16
|
+
isHallOfFame?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export type Filter = {
|
|
19
|
+
kind: 'decision';
|
|
20
|
+
decision: Decision;
|
|
21
|
+
} | {
|
|
22
|
+
kind: 'draft';
|
|
23
|
+
year: Id;
|
|
24
|
+
round?: Id;
|
|
25
|
+
} | {
|
|
26
|
+
kind: 'experience';
|
|
27
|
+
isRookie: boolean;
|
|
28
|
+
} | {
|
|
29
|
+
kind: 'franchise';
|
|
30
|
+
franchiseId: Id;
|
|
31
|
+
} | {
|
|
32
|
+
kind: 'gameType';
|
|
33
|
+
gameType: Id;
|
|
34
|
+
} | {
|
|
35
|
+
kind: 'homeRoad';
|
|
36
|
+
homeRoad: string;
|
|
37
|
+
} | {
|
|
38
|
+
kind: 'nationality';
|
|
39
|
+
nationCode: string;
|
|
40
|
+
} | {
|
|
41
|
+
kind: 'opponent';
|
|
42
|
+
opponentId: Id;
|
|
43
|
+
} | {
|
|
44
|
+
kind: 'position';
|
|
45
|
+
position: PositionTypes;
|
|
46
|
+
} | {
|
|
47
|
+
kind: 'season';
|
|
48
|
+
start: Id;
|
|
49
|
+
end: Id;
|
|
50
|
+
} | {
|
|
51
|
+
kind: 'shootCatch';
|
|
52
|
+
shootCatch: string;
|
|
53
|
+
} | {
|
|
54
|
+
kind: 'status';
|
|
55
|
+
isActive: boolean;
|
|
56
|
+
isHallOfFame: boolean;
|
|
57
|
+
};
|
|
58
|
+
export declare const filter: {
|
|
59
|
+
/** @param decision W, L, O */
|
|
60
|
+
readonly decision: (decision: Decision) => Filter;
|
|
61
|
+
/**
|
|
62
|
+
* @param year Draft year
|
|
63
|
+
* @param round Optional draft round. The API seems to default this to "1".
|
|
64
|
+
*/
|
|
65
|
+
readonly draft: (year: Id, round?: Id) => Filter;
|
|
66
|
+
/** isRookie: true = rookies only, false = veterans only. */
|
|
67
|
+
readonly experience: (isRookie: boolean) => Filter;
|
|
68
|
+
readonly franchise: (franchiseId: Id) => Filter;
|
|
69
|
+
/** @param gameType 1=Preseason, 2=Regular season, 3=Playoffs */
|
|
70
|
+
readonly gameType: (gameType: Id) => Filter;
|
|
71
|
+
/** @param homeRoad H or R to indicate home or road games. */
|
|
72
|
+
readonly homeRoad: (homeRoad: string) => Filter;
|
|
73
|
+
/**
|
|
74
|
+
* Country/Nationality codes can be found via the `client.misc.countries()`
|
|
75
|
+
* endpoint, e.g. "CAN", "USA", "SWE", "FIN", "CZE", "RUS".
|
|
76
|
+
*/
|
|
77
|
+
readonly nationality: (nationCode: string) => Filter;
|
|
78
|
+
/** @param opponentId The ID of the opponent franchise. */
|
|
79
|
+
readonly opponent: (opponentId: Id) => Filter;
|
|
80
|
+
readonly position: (position: PositionTypes) => Filter;
|
|
81
|
+
/** Seasons in YYYYYYYY format, e.g. 20232024. */
|
|
82
|
+
readonly season: (start: Id, end: Id) => Filter;
|
|
83
|
+
/** @param shootCatch L or R */
|
|
84
|
+
readonly shootCatch: (shootCatch: string) => Filter;
|
|
85
|
+
/**
|
|
86
|
+
* Player status. Not supplying either option matches active and inactive
|
|
87
|
+
* players.
|
|
88
|
+
*/
|
|
89
|
+
readonly status: ({ isActive, isHallOfFame, }?: StatusQueryOptions) => Filter;
|
|
90
|
+
};
|
|
91
|
+
export declare function toQuery(filter: Filter): string;
|
|
92
|
+
/** Returns an error message if the filter is invalid, otherwise undefined. */
|
|
93
|
+
export declare function validateFilter(filter: Filter): string | undefined;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
export const PositionTypes = {
|
|
2
|
+
ALL_FORWARDS: 'F',
|
|
3
|
+
CENTER: 'C',
|
|
4
|
+
LEFT_WING: 'L',
|
|
5
|
+
RIGHT_WING: 'R',
|
|
6
|
+
DEFENSE: 'D',
|
|
7
|
+
};
|
|
8
|
+
export const filter = {
|
|
9
|
+
/** @param decision W, L, O */
|
|
10
|
+
decision: (decision) => ({ kind: 'decision', decision }),
|
|
11
|
+
/**
|
|
12
|
+
* @param year Draft year
|
|
13
|
+
* @param round Optional draft round. The API seems to default this to "1".
|
|
14
|
+
*/
|
|
15
|
+
draft: (year, round) => ({ kind: 'draft', year, round }),
|
|
16
|
+
/** isRookie: true = rookies only, false = veterans only. */
|
|
17
|
+
experience: (isRookie) => ({
|
|
18
|
+
kind: 'experience',
|
|
19
|
+
isRookie,
|
|
20
|
+
}),
|
|
21
|
+
franchise: (franchiseId) => ({ kind: 'franchise', franchiseId }),
|
|
22
|
+
/** @param gameType 1=Preseason, 2=Regular season, 3=Playoffs */
|
|
23
|
+
gameType: (gameType) => ({ kind: 'gameType', gameType }),
|
|
24
|
+
/** @param homeRoad H or R to indicate home or road games. */
|
|
25
|
+
homeRoad: (homeRoad) => ({ kind: 'homeRoad', homeRoad }),
|
|
26
|
+
/**
|
|
27
|
+
* Country/Nationality codes can be found via the `client.misc.countries()`
|
|
28
|
+
* endpoint, e.g. "CAN", "USA", "SWE", "FIN", "CZE", "RUS".
|
|
29
|
+
*/
|
|
30
|
+
nationality: (nationCode) => ({
|
|
31
|
+
kind: 'nationality',
|
|
32
|
+
nationCode,
|
|
33
|
+
}),
|
|
34
|
+
/** @param opponentId The ID of the opponent franchise. */
|
|
35
|
+
opponent: (opponentId) => ({ kind: 'opponent', opponentId }),
|
|
36
|
+
position: (position) => ({
|
|
37
|
+
kind: 'position',
|
|
38
|
+
position,
|
|
39
|
+
}),
|
|
40
|
+
/** Seasons in YYYYYYYY format, e.g. 20232024. */
|
|
41
|
+
season: (start, end) => ({ kind: 'season', start, end }),
|
|
42
|
+
/** @param shootCatch L or R */
|
|
43
|
+
shootCatch: (shootCatch) => ({
|
|
44
|
+
kind: 'shootCatch',
|
|
45
|
+
shootCatch,
|
|
46
|
+
}),
|
|
47
|
+
/**
|
|
48
|
+
* Player status. Not supplying either option matches active and inactive
|
|
49
|
+
* players.
|
|
50
|
+
*/
|
|
51
|
+
status: ({ isActive = false, isHallOfFame = false, } = {}) => ({
|
|
52
|
+
kind: 'status',
|
|
53
|
+
isActive,
|
|
54
|
+
isHallOfFame,
|
|
55
|
+
}),
|
|
56
|
+
};
|
|
57
|
+
export function toQuery(filter) {
|
|
58
|
+
switch (filter.kind) {
|
|
59
|
+
case 'decision': {
|
|
60
|
+
return `decision='${filter.decision}'`;
|
|
61
|
+
}
|
|
62
|
+
case 'draft': {
|
|
63
|
+
return filter.round
|
|
64
|
+
? `draftYear=${filter.year} and draftRound=${filter.round}`
|
|
65
|
+
: `draftYear=${filter.year}`;
|
|
66
|
+
}
|
|
67
|
+
case 'experience': {
|
|
68
|
+
return `isRookie='${filter.isRookie ? '1' : '0'}'`;
|
|
69
|
+
}
|
|
70
|
+
case 'franchise': {
|
|
71
|
+
return `franchiseId=${filter.franchiseId}`;
|
|
72
|
+
}
|
|
73
|
+
case 'gameType': {
|
|
74
|
+
return `gameTypeId=${filter.gameType}`;
|
|
75
|
+
}
|
|
76
|
+
case 'homeRoad': {
|
|
77
|
+
return `homeRoad='${filter.homeRoad}'`;
|
|
78
|
+
}
|
|
79
|
+
case 'nationality': {
|
|
80
|
+
return `nationalityCode='${filter.nationCode}'`;
|
|
81
|
+
}
|
|
82
|
+
case 'opponent': {
|
|
83
|
+
return `opponentFranchiseId=${filter.opponentId}`;
|
|
84
|
+
}
|
|
85
|
+
case 'position': {
|
|
86
|
+
// All forwards require an OR clause
|
|
87
|
+
if (filter.position === PositionTypes.ALL_FORWARDS) {
|
|
88
|
+
return (`(positionCode='${PositionTypes.LEFT_WING}' ` +
|
|
89
|
+
`or positionCode='${PositionTypes.RIGHT_WING}' ` +
|
|
90
|
+
`or positionCode='${PositionTypes.CENTER}')`);
|
|
91
|
+
}
|
|
92
|
+
return `positionCode='${filter.position}'`;
|
|
93
|
+
}
|
|
94
|
+
case 'season': {
|
|
95
|
+
return `seasonId >= ${filter.start} and seasonId <= ${filter.end}`;
|
|
96
|
+
}
|
|
97
|
+
case 'shootCatch': {
|
|
98
|
+
return `shootsCatches='${filter.shootCatch}'`;
|
|
99
|
+
}
|
|
100
|
+
case 'status': {
|
|
101
|
+
if (filter.isHallOfFame) {
|
|
102
|
+
return 'isInHallOfFame=1';
|
|
103
|
+
}
|
|
104
|
+
if (filter.isActive) {
|
|
105
|
+
return 'active=1';
|
|
106
|
+
}
|
|
107
|
+
return '';
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/** Returns an error message if the filter is invalid, otherwise undefined. */
|
|
112
|
+
export function validateFilter(filter) {
|
|
113
|
+
if (filter.kind === 'decision' &&
|
|
114
|
+
!['W', 'L', 'O'].includes(filter.decision)) {
|
|
115
|
+
return 'Decision value must be one of [W, L, O]';
|
|
116
|
+
}
|
|
117
|
+
return undefined;
|
|
118
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { buildQuery, isValidQuery, type QueryContext, } from '#src/api/query/builder.mjs';
|
|
2
|
+
export * from '#src/api/query/filters.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';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { buildQuery, isValidQuery, } from '#src/api/query/builder.mjs';
|
|
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, } from '#src/api/query/sorting/sorting-options.mjs';
|
|
@@ -0,0 +1,61 @@
|
|
|
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;
|
|
57
|
+
/**
|
|
58
|
+
* Default sorting criteria for goalie stats reports. Falls back to the
|
|
59
|
+
* goalie summary sort for unknown report types.
|
|
60
|
+
*/
|
|
61
|
+
export declare function goalieStatsSorts(report: string): SortExpr[];
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
const goalieSummaryDefaultSorting = [
|
|
2
|
+
{ property: 'wins', direction: 'DESC' },
|
|
3
|
+
{ property: 'gamesPlayed', direction: 'ASC' },
|
|
4
|
+
{ property: 'playerId', direction: 'ASC' },
|
|
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;
|
|
46
|
+
/**
|
|
47
|
+
* Default sorting criteria for goalie stats reports. Falls back to the
|
|
48
|
+
* goalie summary sort for unknown report types.
|
|
49
|
+
*/
|
|
50
|
+
export function goalieStatsSorts(report) {
|
|
51
|
+
return ((Object.hasOwn(sortingLookup, report)
|
|
52
|
+
? sortingLookup[report]
|
|
53
|
+
: undefined) ?? goalieSummaryDefaultSorting);
|
|
54
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
export interface SortExpr {
|
|
2
|
+
property: string;
|
|
3
|
+
direction: 'ASC' | 'DESC' | 'ASC_CI' | 'DESC_CI' | (string & {});
|
|
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;
|
|
129
|
+
/** Skater report types that have a default sort configured. */
|
|
130
|
+
export declare const SKATER_REPORT_TYPES: string[];
|
|
131
|
+
/**
|
|
132
|
+
* Default sort criteria for a skater stats report. Falls back to the skater
|
|
133
|
+
* summary sort for unknown report types.
|
|
134
|
+
*/
|
|
135
|
+
export declare function defaultSortForReport(report: string): SortExpr[];
|
|
136
|
+
export {};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
const skaterSummaryDefaultSorting = [
|
|
2
|
+
{ property: 'points', direction: 'DESC' },
|
|
3
|
+
{ property: 'gamesPlayed', direction: 'ASC' },
|
|
4
|
+
{ property: 'playerId', direction: 'ASC' },
|
|
5
|
+
];
|
|
6
|
+
const defaultSortingByReport = {
|
|
7
|
+
summary: skaterSummaryDefaultSorting,
|
|
8
|
+
bios: [
|
|
9
|
+
{ property: 'lastName', direction: 'ASC_CI' },
|
|
10
|
+
{ property: 'skaterFullName', direction: 'ASC_CI' },
|
|
11
|
+
{ property: 'playerId', direction: 'ASC' },
|
|
12
|
+
],
|
|
13
|
+
faceoffpercentages: [
|
|
14
|
+
{ property: 'totalFaceoffs', direction: 'DESC' },
|
|
15
|
+
{ property: 'playerId', direction: 'ASC' },
|
|
16
|
+
],
|
|
17
|
+
faceoffwins: [
|
|
18
|
+
{ property: 'totalFaceoffWins', direction: 'DESC' },
|
|
19
|
+
{ property: 'faceoffWinPct', direction: 'DESC' },
|
|
20
|
+
{ property: 'playerId', direction: 'ASC' },
|
|
21
|
+
],
|
|
22
|
+
goalsForAgainst: [
|
|
23
|
+
{ property: 'evenStrengthGoalDifference', direction: 'DESC' },
|
|
24
|
+
{ property: 'playerId', direction: 'ASC' },
|
|
25
|
+
],
|
|
26
|
+
realtime: [
|
|
27
|
+
{ property: 'hits', direction: 'DESC' },
|
|
28
|
+
{ property: 'playerId', direction: 'ASC' },
|
|
29
|
+
],
|
|
30
|
+
penalties: [
|
|
31
|
+
{ property: 'penaltyMinutes', direction: 'DESC' },
|
|
32
|
+
{ property: 'playerId', direction: 'ASC' },
|
|
33
|
+
],
|
|
34
|
+
penaltykill: [
|
|
35
|
+
{ property: 'shTimeOnIce', direction: 'DESC' },
|
|
36
|
+
{ property: 'playerId', direction: 'ASC' },
|
|
37
|
+
],
|
|
38
|
+
penaltyShots: [
|
|
39
|
+
{ property: 'penaltyShotsGoals', direction: 'DESC' },
|
|
40
|
+
{ property: 'playerId', direction: 'ASC' },
|
|
41
|
+
],
|
|
42
|
+
powerplay: [
|
|
43
|
+
{ property: 'ppTimeOnIce', direction: 'DESC' },
|
|
44
|
+
{ property: 'playerId', direction: 'ASC' },
|
|
45
|
+
],
|
|
46
|
+
puckPossessions: [
|
|
47
|
+
{ property: 'satPct', direction: 'DESC' },
|
|
48
|
+
{ property: 'playerId', direction: 'ASC' },
|
|
49
|
+
],
|
|
50
|
+
summaryshooting: [
|
|
51
|
+
{ property: 'satTotal', direction: 'DESC' },
|
|
52
|
+
{ property: 'usatTotal', direction: 'DESC' },
|
|
53
|
+
{ property: 'playerId', direction: 'ASC' },
|
|
54
|
+
],
|
|
55
|
+
percentages: [
|
|
56
|
+
{ property: 'satPercentage', direction: 'DESC' },
|
|
57
|
+
{ property: 'playerId', direction: 'ASC' },
|
|
58
|
+
],
|
|
59
|
+
scoringRates: [
|
|
60
|
+
{ property: 'pointsPer605v5', direction: 'DESC' },
|
|
61
|
+
{ property: 'goalsPer605v5', direction: 'DESC' },
|
|
62
|
+
{ property: 'playerId', direction: 'ASC' },
|
|
63
|
+
],
|
|
64
|
+
scoringpergame: [
|
|
65
|
+
{ property: 'pointsPerGame', direction: 'DESC' },
|
|
66
|
+
{ property: 'goalsPerGame', direction: 'DESC' },
|
|
67
|
+
{ property: 'playerId', direction: 'ASC' },
|
|
68
|
+
],
|
|
69
|
+
shootout: [
|
|
70
|
+
{ property: 'shootoutGoals', direction: 'DESC' },
|
|
71
|
+
{ property: 'playerId', direction: 'ASC' },
|
|
72
|
+
],
|
|
73
|
+
shottype: [
|
|
74
|
+
{ property: 'shootingPct', direction: 'DESC' },
|
|
75
|
+
{ property: 'shootingPctBat', direction: 'DESC' },
|
|
76
|
+
{ property: 'playerId', direction: 'ASC' },
|
|
77
|
+
],
|
|
78
|
+
timeonice: [
|
|
79
|
+
{ property: 'timeOnIce', direction: 'DESC' },
|
|
80
|
+
{ property: 'playerId', direction: 'ASC' },
|
|
81
|
+
],
|
|
82
|
+
};
|
|
83
|
+
const sortingLookup = defaultSortingByReport;
|
|
84
|
+
/** Skater report types that have a default sort configured. */
|
|
85
|
+
export const SKATER_REPORT_TYPES = Object.keys(defaultSortingByReport);
|
|
86
|
+
/**
|
|
87
|
+
* Default sort criteria for a skater stats report. Falls back to the skater
|
|
88
|
+
* summary sort for unknown report types.
|
|
89
|
+
*/
|
|
90
|
+
export function defaultSortForReport(report) {
|
|
91
|
+
return ((Object.hasOwn(sortingLookup, report)
|
|
92
|
+
? sortingLookup[report]
|
|
93
|
+
: undefined) ?? skaterSummaryDefaultSorting);
|
|
94
|
+
}
|