nhle-api 0.5.1 → 0.5.3
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/CHANGELOG.md +59 -9
- package/lib/index.cjs +461 -487
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +2483 -514
- package/lib/index.d.ts +2483 -514
- package/lib/index.js +461 -487
- package/lib/index.js.map +1 -1
- package/package.json +6 -7
package/lib/index.cjs
CHANGED
|
@@ -468,6 +468,9 @@ var getSeason = (date) => {
|
|
|
468
468
|
return `${year}${parseInt(year, 10) + 1}`;
|
|
469
469
|
};
|
|
470
470
|
var getCurrentSeason = () => getSeason(/* @__PURE__ */ new Date());
|
|
471
|
+
/* @__PURE__ */ new Date(
|
|
472
|
+
`${getCurrentSeason().slice(4, 8)}-06-30`
|
|
473
|
+
);
|
|
471
474
|
|
|
472
475
|
// src/constants/edge-adv.ts
|
|
473
476
|
var edge_adv_exports = {};
|
|
@@ -968,6 +971,21 @@ var Year = arktype.type(`${nhl_exports.START_YEAR} <= number <= ${nhl_exports.EN
|
|
|
968
971
|
return v >= nhl_exports.START_YEAR && v <= nhl_exports.END_YEAR;
|
|
969
972
|
})
|
|
970
973
|
).describe(`a valid year from ${nhl_exports.START_YEAR} to ${nhl_exports.END_YEAR}`);
|
|
974
|
+
var NHLMonth = arktype.type("Date | string").narrow((v) => {
|
|
975
|
+
if (typeof v === "string") {
|
|
976
|
+
return /^\d{4}-\d{2}$/.test(v);
|
|
977
|
+
} else if (v instanceof Date) {
|
|
978
|
+
return true;
|
|
979
|
+
}
|
|
980
|
+
return false;
|
|
981
|
+
}).pipe((v) => typeof v === "string" ? v : v.toISOString().slice(0, 7)).describe(
|
|
982
|
+
"a valid month, either as a string (formatted as YYYY-MM) or a Date object"
|
|
983
|
+
);
|
|
984
|
+
var NHLDate = arktype.type("Date | string.date.iso").pipe(
|
|
985
|
+
(v) => typeof v === "string" ? new Date(v).toISOString().slice(0, 10) : v.toISOString().slice(0, 10)
|
|
986
|
+
).describe(
|
|
987
|
+
"a valid date, either as a string (ISO date string) or a Date object"
|
|
988
|
+
);
|
|
971
989
|
var Season = arktype.type("number.integer | string.numeric.parse").narrow((v) => {
|
|
972
990
|
const yr = Math.trunc(v / 1e4);
|
|
973
991
|
return typeof Year(yr) === "number" && yr + 1 === v % 1e4;
|
|
@@ -978,12 +996,15 @@ var TeamAbbrev = arktype.type.enumerated(
|
|
|
978
996
|
nhl_exports.InactiveTeamsEnum
|
|
979
997
|
)
|
|
980
998
|
).describe("a valid NHL team abbreviation");
|
|
981
|
-
var TeamId = arktype.type.enumerated(
|
|
999
|
+
var TeamId = arktype.type.enumerated(
|
|
1000
|
+
...Object.values(nhl_exports.TeamsEnum),
|
|
1001
|
+
...Object.values(nhl_exports.InactiveTeamsEnum)
|
|
1002
|
+
).describe("a valid NHL team ID");
|
|
982
1003
|
var GameType = arktype.type.enumerated(
|
|
983
1004
|
...Object.keys(
|
|
984
1005
|
nhl_exports.GameTypeEnum
|
|
985
1006
|
)
|
|
986
|
-
).pipe((v) => nhl_exports.GameTypeEnum[v]).or(arktype.type(
|
|
1007
|
+
).pipe((v) => nhl_exports.GameTypeEnum[v]).or(arktype.type("1|2|3|4|19")).describe("a valid NHL game type (e.g., REG, PRE, POST)");
|
|
987
1008
|
var GameNumber = arktype.type("number").atLeast(1).atMost(82 * 32 / 2).or(
|
|
988
1009
|
arktype.type("string.numeric.parse").narrow((v) => {
|
|
989
1010
|
return v >= 1 && v <= 82 * 32 / 2;
|
|
@@ -992,21 +1013,6 @@ var GameNumber = arktype.type("number").atLeast(1).atMost(82 * 32 / 2).or(
|
|
|
992
1013
|
var DraftRound = arktype.type("1 <= number <= 7").or(arktype.type(/^(1|2|3|4|5|6|7)$/)).pipe((v) => typeof v === "number" ? v.toString() : v).describe("a valid NHL draft round (1-7)");
|
|
993
1014
|
arktype.type("1 <= number <= 4").or(arktype.type(/^(1|2|3|4)$/)).pipe((v) => typeof v === "number" ? v.toString() : v).describe("a valid NHL playoff round (1-4)");
|
|
994
1015
|
var EventId = arktype.type("number.integer | string.numeric.parse").narrow((v) => Number.isInteger(v) && v > 0).describe("a positive integer representing an NHL event ID");
|
|
995
|
-
var NHLDate = arktype.type("Date | string.date.iso").pipe(
|
|
996
|
-
(v) => typeof v === "string" ? new Date(v).toISOString().slice(0, 10) : v.toISOString().slice(0, 10)
|
|
997
|
-
).describe(
|
|
998
|
-
"a valid date, either as a string (ISO date string) or a Date object"
|
|
999
|
-
);
|
|
1000
|
-
arktype.type("Date | string").narrow((v) => {
|
|
1001
|
-
if (typeof v === "string") {
|
|
1002
|
-
return /^\d{4}-\d{2}$/.test(v);
|
|
1003
|
-
} else if (v instanceof Date) {
|
|
1004
|
-
return true;
|
|
1005
|
-
}
|
|
1006
|
-
return false;
|
|
1007
|
-
}).pipe((v) => typeof v === "string" ? v : v.toISOString().slice(0, 7)).describe(
|
|
1008
|
-
"a valid month, either as a string (formatted as YYYY-MM) or a Date object"
|
|
1009
|
-
);
|
|
1010
1016
|
arktype.type("1|2|3|4|19").describe(
|
|
1011
1017
|
"a valid NHL game type code (1=PRE, 2=REG, 3=POST, 4=ASG, 19=INTL)"
|
|
1012
1018
|
);
|
|
@@ -1026,7 +1032,7 @@ var GameId = arktype.type("number.integer | string.numeric.parse").narrow((v) =>
|
|
|
1026
1032
|
var SeriesLetter = arktype.type.enumerated(...Object.values(nhl_exports.SeriesLetterEnum)).describe("a valid NHL playoff series letter (A-O)");
|
|
1027
1033
|
arktype.type.enumerated(...Object.values(nhl_exports.GameStateEnum)).describe("a valid NHL game state");
|
|
1028
1034
|
var CountryCode = arktype.type(/^[a-zA-Z]{2}$/).pipe((v) => v.toLowerCase()).describe("a valid ISO 3166-1 alpha-2 country code, e.g. US, CA, RU");
|
|
1029
|
-
var PostalCode = arktype.type(/^[a-zA-Z]\d[a-zA-Z]
|
|
1035
|
+
var PostalCode = arktype.type(/^[a-zA-Z]\d[a-zA-Z][ -]?\d[a-zA-Z]\d$/).or(arktype.type(/^\d{5}$/)).describe(
|
|
1030
1036
|
"a valid postal code, either US ZIP code (5 digit) or Canadian postal code (A1A 1A1 format; space required)"
|
|
1031
1037
|
);
|
|
1032
1038
|
var PlayerId = arktype.type("number").atLeast(nhl_exports.PLAYER_ID_RANGE.MIN).atMost(nhl_exports.PLAYER_ID_RANGE.MAX).or(
|
|
@@ -1100,10 +1106,6 @@ var BaseParams = arktype.type({
|
|
|
1100
1106
|
(v) => v ?? nhl_exports.GameTypeEnum.REG
|
|
1101
1107
|
)
|
|
1102
1108
|
});
|
|
1103
|
-
arktype.type({
|
|
1104
|
-
season: Season.or("undefined").optional(),
|
|
1105
|
-
gameType: GameType.or("undefined").optional()
|
|
1106
|
-
});
|
|
1107
1109
|
BaseParams.merge({
|
|
1108
1110
|
playerId: PlayerId,
|
|
1109
1111
|
season: Season
|
|
@@ -1138,7 +1140,9 @@ var SeriesParams = arktype.type({
|
|
|
1138
1140
|
var ScheduleParams = arktype.type({
|
|
1139
1141
|
team: TeamAbbrev,
|
|
1140
1142
|
date: NHLDate.or("undefined").pipe((v) => v ?? getCurrentDate()),
|
|
1141
|
-
|
|
1143
|
+
month: NHLMonth.or("undefined").pipe(
|
|
1144
|
+
(v) => v ?? getCurrentDate().slice(0, 7)
|
|
1145
|
+
)
|
|
1142
1146
|
});
|
|
1143
1147
|
|
|
1144
1148
|
// src/utils/utils.ts
|
|
@@ -1151,8 +1155,71 @@ function route(template, params) {
|
|
|
1151
1155
|
return route2;
|
|
1152
1156
|
}
|
|
1153
1157
|
|
|
1154
|
-
// src/api/gamecenter/
|
|
1155
|
-
var
|
|
1158
|
+
// src/api/gamecenter/_paths.ts
|
|
1159
|
+
var _teamPaths = {
|
|
1160
|
+
rosterSeasons: "roster-season/{team}",
|
|
1161
|
+
roster: "roster/{team}/{season}",
|
|
1162
|
+
prospects: "prospects/{team}",
|
|
1163
|
+
clubStats: "club-stats/{team}/{season}/{gameType}",
|
|
1164
|
+
clubStatsSeason: "club-stats-season/{team}",
|
|
1165
|
+
standings: "standings/{date}",
|
|
1166
|
+
standingsSeason: "standings-season",
|
|
1167
|
+
clubSchedule: {
|
|
1168
|
+
season: "club-schedule-season/{team}/{season}",
|
|
1169
|
+
month: "club-schedule/{team}/month/{month}",
|
|
1170
|
+
week: "club-schedule/{team}/week/{date}"
|
|
1171
|
+
}
|
|
1172
|
+
};
|
|
1173
|
+
var _scorePaths = {
|
|
1174
|
+
score: "score/{date}",
|
|
1175
|
+
scoreboard: {
|
|
1176
|
+
now: "scoreboard/now",
|
|
1177
|
+
byTeam: "scoreboard/{team}/now",
|
|
1178
|
+
byDate: "scoreboard/{date}"
|
|
1179
|
+
}
|
|
1180
|
+
};
|
|
1181
|
+
var _playerPaths = {
|
|
1182
|
+
landing: "player/{playerId}/landing",
|
|
1183
|
+
gameLog: "player/{playerId}/game-log/{season}/{gameType}",
|
|
1184
|
+
spotlight: "player-spotlight",
|
|
1185
|
+
statsLeaders: {
|
|
1186
|
+
skaters: "skater-stats-leaders/{season}/{gameType}",
|
|
1187
|
+
goalies: "goalie-stats-leaders/{season}/{gameType}"
|
|
1188
|
+
},
|
|
1189
|
+
playerSearch: "https://search.d3.nhle.com/api/v1/search/player"
|
|
1190
|
+
};
|
|
1191
|
+
var _miscPaths = {
|
|
1192
|
+
season: "season",
|
|
1193
|
+
metaPlayoffSeries: "meta/playoff-series/{year}/{seriesLetter}",
|
|
1194
|
+
metaGame: "meta/game/{gameId}",
|
|
1195
|
+
postalLookup: "postal-lookup/{postalCode}",
|
|
1196
|
+
location: "location",
|
|
1197
|
+
partnerGame: "partner-game/{countryCode}/now"
|
|
1198
|
+
};
|
|
1199
|
+
var _gamePaths = {
|
|
1200
|
+
schedule: "schedule/{date}",
|
|
1201
|
+
scheduleCalendar: "schedule-calendar/{date}",
|
|
1202
|
+
playoffBracket: "playoff-bracket/{year}",
|
|
1203
|
+
playoffSeries: "playoff-series/carousel/{season}",
|
|
1204
|
+
playoffSeriesSchedule: "schedule/playoff-series/{season}/{seriesLetter}",
|
|
1205
|
+
gamecenter: {
|
|
1206
|
+
playByPlay: "gamecenter/{gameId}/play-by-play",
|
|
1207
|
+
reports: "gamecenter/{gameId}/right-rail",
|
|
1208
|
+
landing: "gamecenter/{gameId}/landing",
|
|
1209
|
+
boxscore: "gamecenter/{gameId}/boxscore"
|
|
1210
|
+
},
|
|
1211
|
+
wsc: {
|
|
1212
|
+
gameStory: "wsc/game-story/{gameId}",
|
|
1213
|
+
playByPlay: "wsc/play-by-play/{gameId}"
|
|
1214
|
+
},
|
|
1215
|
+
pptReplay: {
|
|
1216
|
+
goal: "ppt-replay/goal/{gameId}/{eventId}",
|
|
1217
|
+
event: "ppt-replay/{gameId}/{eventId}"
|
|
1218
|
+
},
|
|
1219
|
+
whereToWatch: "where-to-watch",
|
|
1220
|
+
networkTVSchedule: "network/tv-schedule/{date}"
|
|
1221
|
+
};
|
|
1222
|
+
var _draftPaths = {
|
|
1156
1223
|
draftPicks: {
|
|
1157
1224
|
byYearAndRound: "draft/picks/{year}/{round}",
|
|
1158
1225
|
byYear: "draft/picks/{year}/all"
|
|
@@ -1160,58 +1227,103 @@ var _paths = {
|
|
|
1160
1227
|
draftRankings: "draft/rankings/{year}/{type}",
|
|
1161
1228
|
draftTracker: "draft-tracker/picks/now"
|
|
1162
1229
|
};
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
goaliesNA: "3",
|
|
1167
|
-
goaliesIntl: "4"
|
|
1168
|
-
};
|
|
1169
|
-
var picks = (year, round) => {
|
|
1230
|
+
|
|
1231
|
+
// src/api/gamecenter/draft.ts
|
|
1232
|
+
async function picks(year, round) {
|
|
1170
1233
|
const parsed = DraftParams({ year, round });
|
|
1171
1234
|
if (isParseError(parsed)) {
|
|
1172
|
-
return
|
|
1235
|
+
return {
|
|
1173
1236
|
status: "error",
|
|
1174
1237
|
error: new ValidationError(parsed.summary, {
|
|
1175
|
-
endpoint:
|
|
1238
|
+
endpoint: _draftPaths.draftPicks.byYearAndRound
|
|
1176
1239
|
})
|
|
1177
|
-
}
|
|
1240
|
+
};
|
|
1178
1241
|
}
|
|
1179
1242
|
if (parsed.year && !parsed.round)
|
|
1180
|
-
return client_default.get(route(
|
|
1181
|
-
return client_default.get(route(
|
|
1182
|
-
}
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1243
|
+
return client_default.get(route(_draftPaths.draftPicks.byYear, parsed));
|
|
1244
|
+
return client_default.get(route(_draftPaths.draftPicks.byYearAndRound, parsed));
|
|
1245
|
+
}
|
|
1246
|
+
async function tracker() {
|
|
1247
|
+
return client_default.get(_draftPaths.draftTracker);
|
|
1248
|
+
}
|
|
1249
|
+
function rankings(year) {
|
|
1250
|
+
const DraftRankingsEnum = {
|
|
1251
|
+
skatersNA: "1",
|
|
1252
|
+
skatersIntl: "2",
|
|
1253
|
+
goaliesNA: "3",
|
|
1254
|
+
goaliesIntl: "4"
|
|
1255
|
+
};
|
|
1256
|
+
const getRankings = async (type2) => {
|
|
1186
1257
|
const parsedYear = Year(year ?? getCurrentYear());
|
|
1187
1258
|
if (isParseError(parsedYear)) {
|
|
1188
|
-
return
|
|
1259
|
+
return {
|
|
1189
1260
|
status: "error",
|
|
1190
1261
|
error: new ValidationError(parsedYear.summary, {
|
|
1191
|
-
endpoint:
|
|
1262
|
+
endpoint: _draftPaths.draftRankings
|
|
1192
1263
|
})
|
|
1193
|
-
}
|
|
1264
|
+
};
|
|
1194
1265
|
}
|
|
1195
1266
|
return client_default.get(
|
|
1196
|
-
route(
|
|
1267
|
+
route(_draftPaths.draftRankings, {
|
|
1197
1268
|
year: parsedYear,
|
|
1198
1269
|
type: type2
|
|
1199
1270
|
})
|
|
1200
1271
|
);
|
|
1201
1272
|
};
|
|
1202
1273
|
return {
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1274
|
+
/**
|
|
1275
|
+
* Get North American skater draft rankings
|
|
1276
|
+
* @returns Promise resolving to NA skater rankings
|
|
1277
|
+
*/
|
|
1278
|
+
skatersNA: async () => getRankings(DraftRankingsEnum.skatersNA),
|
|
1279
|
+
/**
|
|
1280
|
+
* Get International skater draft rankings
|
|
1281
|
+
* @returns Promise resolving to International skater rankings
|
|
1282
|
+
*/
|
|
1283
|
+
skatersIntl: async () => getRankings(DraftRankingsEnum.skatersIntl),
|
|
1284
|
+
/**
|
|
1285
|
+
* Get North American goalie draft rankings
|
|
1286
|
+
* @returns Promise resolving to NA goalie rankings
|
|
1287
|
+
*/
|
|
1288
|
+
goaliesNA: async () => getRankings(DraftRankingsEnum.goaliesNA),
|
|
1289
|
+
/**
|
|
1290
|
+
* Get International goalie draft rankings
|
|
1291
|
+
* @returns Promise resolving to International goalie rankings
|
|
1292
|
+
*/
|
|
1293
|
+
goaliesIntl: async () => getRankings(DraftRankingsEnum.goaliesIntl),
|
|
1294
|
+
/**
|
|
1295
|
+
* Get all draft rankings (NA/Intl skaters and goalies)
|
|
1296
|
+
* @returns Promise resolving to array of all rankings
|
|
1297
|
+
*/
|
|
1298
|
+
all: async () => {
|
|
1299
|
+
const unwrapAPIResponse = (apiResponse) => {
|
|
1300
|
+
if (apiResponse.status === "success") {
|
|
1301
|
+
return apiResponse.data;
|
|
1302
|
+
}
|
|
1303
|
+
throw apiResponse.error;
|
|
1304
|
+
};
|
|
1305
|
+
const response = await Promise.all([
|
|
1306
|
+
getRankings(DraftRankingsEnum.skatersNA),
|
|
1307
|
+
getRankings(DraftRankingsEnum.skatersIntl),
|
|
1308
|
+
getRankings(DraftRankingsEnum.goaliesNA),
|
|
1309
|
+
getRankings(DraftRankingsEnum.goaliesIntl)
|
|
1310
|
+
]);
|
|
1311
|
+
try {
|
|
1312
|
+
const dataOnly = response.map((r) => unwrapAPIResponse(r));
|
|
1313
|
+
const newResponse = {
|
|
1314
|
+
status: "success",
|
|
1315
|
+
data: dataOnly
|
|
1316
|
+
};
|
|
1317
|
+
return newResponse;
|
|
1318
|
+
} catch (error) {
|
|
1319
|
+
return {
|
|
1320
|
+
status: "error",
|
|
1321
|
+
error
|
|
1322
|
+
};
|
|
1323
|
+
}
|
|
1324
|
+
}
|
|
1213
1325
|
};
|
|
1214
|
-
}
|
|
1326
|
+
}
|
|
1215
1327
|
|
|
1216
1328
|
// src/api/gamecenter/game.ts
|
|
1217
1329
|
var game_exports = {};
|
|
@@ -1230,248 +1342,206 @@ __export(game_exports, {
|
|
|
1230
1342
|
whereToWatch: () => whereToWatch,
|
|
1231
1343
|
wsc: () => wsc
|
|
1232
1344
|
});
|
|
1233
|
-
|
|
1234
|
-
schedule: "schedule/{date}",
|
|
1235
|
-
scheduleCalendar: "schedule-calendar/{date}",
|
|
1236
|
-
playoffBracket: "playoff-bracket/{year}",
|
|
1237
|
-
playoffSeries: "playoff-series/{season}",
|
|
1238
|
-
playoffSeriesSchedule: "schedule/playoff-series/{season}/{seriesLetter}",
|
|
1239
|
-
gamecenter: {
|
|
1240
|
-
playByPlay: "gamecenter/{gameId}/play-by-play",
|
|
1241
|
-
reports: "gamecenter/{gameId}/right-rail",
|
|
1242
|
-
landing: "gamecenter/{gameId}/landing",
|
|
1243
|
-
boxscore: "gamecenter/{gameId}/boxscore"
|
|
1244
|
-
},
|
|
1245
|
-
wsc: {
|
|
1246
|
-
gameStory: "wsc/game-story/{gameId}",
|
|
1247
|
-
playByPlay: "wsc/play-by-play/{gameId}"
|
|
1248
|
-
},
|
|
1249
|
-
pptReplay: {
|
|
1250
|
-
goal: "ppt-replay/{gameId}/goal/{eventId}",
|
|
1251
|
-
event: "ppt-replay/{date}"
|
|
1252
|
-
},
|
|
1253
|
-
whereToWatch: "where-to-watch",
|
|
1254
|
-
networkTVSchedule: "network/tv-schedule/{date}"
|
|
1255
|
-
};
|
|
1256
|
-
var playByPlay = (gameId) => {
|
|
1345
|
+
async function playByPlay(gameId) {
|
|
1257
1346
|
const parsedGameId = GameId(gameId);
|
|
1258
1347
|
if (isParseError(parsedGameId)) {
|
|
1259
|
-
return
|
|
1348
|
+
return {
|
|
1260
1349
|
status: "error",
|
|
1261
1350
|
error: new ValidationError(parsedGameId.summary, {
|
|
1262
|
-
endpoint:
|
|
1351
|
+
endpoint: _gamePaths.gamecenter.playByPlay
|
|
1263
1352
|
})
|
|
1264
|
-
}
|
|
1353
|
+
};
|
|
1265
1354
|
}
|
|
1266
1355
|
return client_default.get(
|
|
1267
|
-
route(
|
|
1356
|
+
route(_gamePaths.gamecenter.playByPlay, { gameId: parsedGameId })
|
|
1268
1357
|
);
|
|
1269
|
-
}
|
|
1270
|
-
|
|
1358
|
+
}
|
|
1359
|
+
async function reports(gameId) {
|
|
1271
1360
|
const parsedGameId = GameId(gameId);
|
|
1272
1361
|
if (isParseError(parsedGameId)) {
|
|
1273
|
-
return
|
|
1362
|
+
return {
|
|
1274
1363
|
status: "error",
|
|
1275
1364
|
error: new ValidationError(parsedGameId.summary, {
|
|
1276
|
-
endpoint:
|
|
1365
|
+
endpoint: _gamePaths.gamecenter.reports
|
|
1277
1366
|
})
|
|
1278
|
-
}
|
|
1367
|
+
};
|
|
1279
1368
|
}
|
|
1280
1369
|
return client_default.get(
|
|
1281
|
-
route(
|
|
1370
|
+
route(_gamePaths.gamecenter.reports, { gameId: parsedGameId })
|
|
1282
1371
|
);
|
|
1283
|
-
}
|
|
1284
|
-
|
|
1372
|
+
}
|
|
1373
|
+
async function landing(gameId) {
|
|
1285
1374
|
const parsedGameId = GameId(gameId);
|
|
1286
1375
|
if (isParseError(parsedGameId)) {
|
|
1287
|
-
return
|
|
1376
|
+
return {
|
|
1288
1377
|
status: "error",
|
|
1289
1378
|
error: new ValidationError(parsedGameId.summary, {
|
|
1290
|
-
endpoint:
|
|
1379
|
+
endpoint: _gamePaths.gamecenter.landing
|
|
1291
1380
|
})
|
|
1292
|
-
}
|
|
1381
|
+
};
|
|
1293
1382
|
}
|
|
1294
1383
|
return client_default.get(
|
|
1295
|
-
route(
|
|
1384
|
+
route(_gamePaths.gamecenter.landing, { gameId: parsedGameId })
|
|
1296
1385
|
);
|
|
1297
|
-
}
|
|
1298
|
-
|
|
1386
|
+
}
|
|
1387
|
+
async function boxscore(gameId) {
|
|
1299
1388
|
const parsedGameId = GameId(gameId);
|
|
1300
1389
|
if (isParseError(parsedGameId)) {
|
|
1301
|
-
return
|
|
1390
|
+
return {
|
|
1302
1391
|
status: "error",
|
|
1303
1392
|
error: new ValidationError(parsedGameId.summary, {
|
|
1304
|
-
endpoint:
|
|
1393
|
+
endpoint: _gamePaths.gamecenter.boxscore
|
|
1305
1394
|
})
|
|
1306
|
-
}
|
|
1395
|
+
};
|
|
1307
1396
|
}
|
|
1308
1397
|
return client_default.get(
|
|
1309
|
-
route(
|
|
1398
|
+
route(_gamePaths.gamecenter.boxscore, { gameId: parsedGameId })
|
|
1310
1399
|
);
|
|
1311
|
-
}
|
|
1400
|
+
}
|
|
1312
1401
|
var wsc = {
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
* @param gameId - The unique identifier for the game
|
|
1316
|
-
* @returns Promise resolving to game story data
|
|
1317
|
-
*/
|
|
1318
|
-
gameStory: (gameId) => {
|
|
1319
|
-
const parsedGameId = GameId(gameId);
|
|
1320
|
-
if (isParseError(parsedGameId)) {
|
|
1321
|
-
return Promise.resolve({
|
|
1322
|
-
status: "error",
|
|
1323
|
-
error: new ValidationError(parsedGameId.summary, {
|
|
1324
|
-
endpoint: _paths2.wsc.gameStory
|
|
1325
|
-
})
|
|
1326
|
-
});
|
|
1327
|
-
}
|
|
1328
|
-
return client_default.get(
|
|
1329
|
-
route(_paths2.wsc.gameStory, { gameId: parsedGameId })
|
|
1330
|
-
);
|
|
1331
|
-
},
|
|
1332
|
-
/**
|
|
1333
|
-
* Get play-by-play data for a specific game
|
|
1334
|
-
* @param gameId - The unique identifier for the game
|
|
1335
|
-
* @returns Promise resolving to play-by-play data
|
|
1336
|
-
*/
|
|
1337
|
-
playByPlay: (gameId) => {
|
|
1338
|
-
const parsedGameId = GameId(gameId);
|
|
1339
|
-
if (isParseError(parsedGameId)) {
|
|
1340
|
-
return Promise.resolve({
|
|
1341
|
-
status: "error",
|
|
1342
|
-
error: new ValidationError(parsedGameId.summary, {
|
|
1343
|
-
endpoint: _paths2.wsc.playByPlay
|
|
1344
|
-
})
|
|
1345
|
-
});
|
|
1346
|
-
}
|
|
1347
|
-
return client_default.get(
|
|
1348
|
-
route(_paths2.wsc.playByPlay, { gameId: parsedGameId })
|
|
1349
|
-
);
|
|
1350
|
-
}
|
|
1402
|
+
gameStory: wscGameStory,
|
|
1403
|
+
playByPlay: wscPlayByPlay
|
|
1351
1404
|
};
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
return
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
* @param date - Date to get event replay data for (Date object or ISO date string)
|
|
1376
|
-
* @returns Promise resolving to event replay data
|
|
1377
|
-
*/
|
|
1378
|
-
event: async (date) => {
|
|
1379
|
-
const parsedDate = NHLDate(date);
|
|
1380
|
-
if (isParseError(parsedDate)) {
|
|
1381
|
-
return Promise.resolve({
|
|
1382
|
-
status: "error",
|
|
1383
|
-
error: new ValidationError(parsedDate.summary, {
|
|
1384
|
-
endpoint: _paths2.pptReplay.event
|
|
1385
|
-
})
|
|
1386
|
-
});
|
|
1387
|
-
}
|
|
1388
|
-
return client_default.get(
|
|
1389
|
-
route(_paths2.pptReplay.event, { date: parsedDate })
|
|
1390
|
-
);
|
|
1405
|
+
async function wscGameStory(gameId) {
|
|
1406
|
+
const parsedGameId = GameId(gameId);
|
|
1407
|
+
if (isParseError(parsedGameId)) {
|
|
1408
|
+
return {
|
|
1409
|
+
status: "error",
|
|
1410
|
+
error: new ValidationError(parsedGameId.summary, {
|
|
1411
|
+
endpoint: _gamePaths.wsc.gameStory
|
|
1412
|
+
})
|
|
1413
|
+
};
|
|
1414
|
+
}
|
|
1415
|
+
return client_default.get(
|
|
1416
|
+
route(_gamePaths.wsc.gameStory, { gameId: parsedGameId })
|
|
1417
|
+
);
|
|
1418
|
+
}
|
|
1419
|
+
async function wscPlayByPlay(gameId) {
|
|
1420
|
+
const parsedGameId = GameId(gameId);
|
|
1421
|
+
if (isParseError(parsedGameId)) {
|
|
1422
|
+
return {
|
|
1423
|
+
status: "error",
|
|
1424
|
+
error: new ValidationError(parsedGameId.summary, {
|
|
1425
|
+
endpoint: _gamePaths.wsc.playByPlay
|
|
1426
|
+
})
|
|
1427
|
+
};
|
|
1391
1428
|
}
|
|
1429
|
+
return client_default.get(
|
|
1430
|
+
route(_gamePaths.wsc.playByPlay, { gameId: parsedGameId })
|
|
1431
|
+
);
|
|
1432
|
+
}
|
|
1433
|
+
var pptReplay = {
|
|
1434
|
+
goal: pptReplayGoal,
|
|
1435
|
+
event: pptReplayEvent
|
|
1392
1436
|
};
|
|
1393
|
-
|
|
1437
|
+
async function pptReplayGoal(gameId, eventId) {
|
|
1438
|
+
const parsed = GameIdAndEventId({ gameId, eventId });
|
|
1439
|
+
if (isParseError(parsed)) {
|
|
1440
|
+
return {
|
|
1441
|
+
status: "error",
|
|
1442
|
+
error: new ValidationError(parsed.summary, {
|
|
1443
|
+
endpoint: _gamePaths.pptReplay.goal
|
|
1444
|
+
})
|
|
1445
|
+
};
|
|
1446
|
+
}
|
|
1447
|
+
return client_default.get(route(_gamePaths.pptReplay.goal, { gameId, eventId }));
|
|
1448
|
+
}
|
|
1449
|
+
async function pptReplayEvent(gameId, eventId) {
|
|
1450
|
+
const parsed = GameIdAndEventId({ gameId, eventId });
|
|
1451
|
+
if (isParseError(parsed)) {
|
|
1452
|
+
return {
|
|
1453
|
+
status: "error",
|
|
1454
|
+
error: new ValidationError(parsed.summary, {
|
|
1455
|
+
endpoint: _gamePaths.pptReplay.event
|
|
1456
|
+
})
|
|
1457
|
+
};
|
|
1458
|
+
}
|
|
1459
|
+
return client_default.get(route(_gamePaths.pptReplay.event, { gameId, eventId }));
|
|
1460
|
+
}
|
|
1461
|
+
async function schedule(date) {
|
|
1394
1462
|
const parsedDate = NHLDate(date ?? getCurrentDate());
|
|
1395
1463
|
if (isParseError(parsedDate)) {
|
|
1396
|
-
return
|
|
1464
|
+
return {
|
|
1397
1465
|
status: "error",
|
|
1398
1466
|
error: new ValidationError(parsedDate.summary, {
|
|
1399
|
-
endpoint:
|
|
1467
|
+
endpoint: _gamePaths.schedule
|
|
1400
1468
|
})
|
|
1401
|
-
}
|
|
1469
|
+
};
|
|
1402
1470
|
}
|
|
1403
|
-
return client_default.get(route(
|
|
1404
|
-
}
|
|
1405
|
-
|
|
1471
|
+
return client_default.get(route(_gamePaths.schedule, { date: parsedDate }));
|
|
1472
|
+
}
|
|
1473
|
+
async function scheduleCalendar(date) {
|
|
1406
1474
|
const parsedDate = NHLDate(date);
|
|
1407
1475
|
if (isParseError(parsedDate)) {
|
|
1408
|
-
return
|
|
1476
|
+
return {
|
|
1409
1477
|
status: "error",
|
|
1410
1478
|
error: new ValidationError(parsedDate.summary, {
|
|
1411
|
-
endpoint:
|
|
1479
|
+
endpoint: _gamePaths.scheduleCalendar
|
|
1412
1480
|
})
|
|
1413
|
-
}
|
|
1481
|
+
};
|
|
1414
1482
|
}
|
|
1415
1483
|
return client_default.get(
|
|
1416
|
-
route(
|
|
1484
|
+
route(_gamePaths.scheduleCalendar, { date: parsedDate })
|
|
1417
1485
|
);
|
|
1418
|
-
}
|
|
1419
|
-
|
|
1486
|
+
}
|
|
1487
|
+
async function playoffBracket(year) {
|
|
1420
1488
|
const parsedYear = Year(year ?? getCurrentYear());
|
|
1421
1489
|
if (isParseError(parsedYear)) {
|
|
1422
|
-
return
|
|
1490
|
+
return {
|
|
1423
1491
|
status: "error",
|
|
1424
1492
|
error: new ValidationError(parsedYear.summary, {
|
|
1425
|
-
endpoint:
|
|
1493
|
+
endpoint: _gamePaths.playoffBracket
|
|
1426
1494
|
})
|
|
1427
|
-
}
|
|
1495
|
+
};
|
|
1428
1496
|
}
|
|
1429
|
-
return client_default.get(route(
|
|
1430
|
-
}
|
|
1431
|
-
|
|
1497
|
+
return client_default.get(route(_gamePaths.playoffBracket, { year: parsedYear }));
|
|
1498
|
+
}
|
|
1499
|
+
async function playoffSeries(season) {
|
|
1432
1500
|
const parsedSeason = Season(season ?? getCurrentSeason());
|
|
1433
1501
|
if (isParseError(parsedSeason)) {
|
|
1434
|
-
return
|
|
1502
|
+
return {
|
|
1435
1503
|
status: "error",
|
|
1436
1504
|
error: new ValidationError(parsedSeason.summary, {
|
|
1437
|
-
endpoint:
|
|
1505
|
+
endpoint: _gamePaths.playoffSeries
|
|
1438
1506
|
})
|
|
1439
|
-
}
|
|
1507
|
+
};
|
|
1440
1508
|
}
|
|
1441
1509
|
return client_default.get(
|
|
1442
|
-
route(
|
|
1510
|
+
route(_gamePaths.playoffSeries, { season: parsedSeason })
|
|
1443
1511
|
);
|
|
1444
|
-
}
|
|
1445
|
-
|
|
1512
|
+
}
|
|
1513
|
+
async function playoffSeriesSchedule(seriesLetter, season) {
|
|
1446
1514
|
const parsed = SeriesAndSeasonParams({
|
|
1447
1515
|
seriesLetter,
|
|
1448
1516
|
season: season ?? getCurrentSeason()
|
|
1449
1517
|
});
|
|
1450
1518
|
if (isParseError(parsed)) {
|
|
1451
|
-
return
|
|
1519
|
+
return {
|
|
1452
1520
|
status: "error",
|
|
1453
1521
|
error: new ValidationError(parsed.summary, {
|
|
1454
|
-
endpoint:
|
|
1522
|
+
endpoint: _gamePaths.playoffSeriesSchedule
|
|
1455
1523
|
})
|
|
1456
|
-
}
|
|
1524
|
+
};
|
|
1457
1525
|
}
|
|
1458
|
-
return client_default.get(route(
|
|
1459
|
-
}
|
|
1460
|
-
|
|
1461
|
-
|
|
1526
|
+
return client_default.get(route(_gamePaths.playoffSeriesSchedule, parsed));
|
|
1527
|
+
}
|
|
1528
|
+
async function whereToWatch() {
|
|
1529
|
+
return client_default.get(_gamePaths.whereToWatch);
|
|
1530
|
+
}
|
|
1531
|
+
async function networkTVSchedule(date) {
|
|
1462
1532
|
const parsedDate = NHLDate(date ?? getCurrentDate());
|
|
1463
1533
|
if (isParseError(parsedDate)) {
|
|
1464
|
-
return
|
|
1534
|
+
return {
|
|
1465
1535
|
status: "error",
|
|
1466
1536
|
error: new ValidationError(parsedDate.summary, {
|
|
1467
|
-
endpoint:
|
|
1537
|
+
endpoint: _gamePaths.networkTVSchedule
|
|
1468
1538
|
})
|
|
1469
|
-
}
|
|
1539
|
+
};
|
|
1470
1540
|
}
|
|
1471
1541
|
return client_default.get(
|
|
1472
|
-
route(
|
|
1542
|
+
route(_gamePaths.networkTVSchedule, { date: parsedDate })
|
|
1473
1543
|
);
|
|
1474
|
-
}
|
|
1544
|
+
}
|
|
1475
1545
|
|
|
1476
1546
|
// src/api/gamecenter/misc.ts
|
|
1477
1547
|
var misc_exports = {};
|
|
@@ -1482,89 +1552,68 @@ __export(misc_exports, {
|
|
|
1482
1552
|
postalLookup: () => postalLookup,
|
|
1483
1553
|
seasons: () => seasons
|
|
1484
1554
|
});
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
metaGame: "meta/game/{gameId}",
|
|
1489
|
-
postalLookup: "postal-lookup/{postalCode}",
|
|
1490
|
-
location: "location",
|
|
1491
|
-
partnerGame: "partner-game/{countryCode}/now"
|
|
1492
|
-
};
|
|
1493
|
-
var seasons = () => {
|
|
1494
|
-
return client_default.get(_paths3.season);
|
|
1495
|
-
};
|
|
1555
|
+
async function seasons() {
|
|
1556
|
+
return client_default.get(_miscPaths.season);
|
|
1557
|
+
}
|
|
1496
1558
|
var meta = {
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
*
|
|
1500
|
-
* @param year - The year in YYYY format
|
|
1501
|
-
* @param seriesLetter - Single letter identifier for the playoff series
|
|
1502
|
-
* @returns Promise resolving to playoff series meta information
|
|
1503
|
-
*/
|
|
1504
|
-
playoffSeries: (seriesLetter, year) => {
|
|
1505
|
-
const parsed = SeriesParams({ year, seriesLetter });
|
|
1506
|
-
if (isParseError(parsed)) {
|
|
1507
|
-
return Promise.resolve({
|
|
1508
|
-
status: "error",
|
|
1509
|
-
error: new ValidationError(parsed.summary, {
|
|
1510
|
-
endpoint: _paths3.metaPlayoffSeries
|
|
1511
|
-
})
|
|
1512
|
-
});
|
|
1513
|
-
}
|
|
1514
|
-
return client_default.get(route(_paths3.metaPlayoffSeries, parsed));
|
|
1515
|
-
},
|
|
1516
|
-
/**
|
|
1517
|
-
* Get meta information for a specific game
|
|
1518
|
-
*
|
|
1519
|
-
* @param gameId - The unique game identifier
|
|
1520
|
-
* @returns Promise resolving to game meta information
|
|
1521
|
-
*/
|
|
1522
|
-
game: (gameId) => {
|
|
1523
|
-
const parsedGameId = GameId(gameId);
|
|
1524
|
-
if (isParseError(parsedGameId)) {
|
|
1525
|
-
return Promise.resolve({
|
|
1526
|
-
status: "error",
|
|
1527
|
-
error: new ValidationError(parsedGameId.summary, {
|
|
1528
|
-
endpoint: _paths3.metaGame
|
|
1529
|
-
})
|
|
1530
|
-
});
|
|
1531
|
-
}
|
|
1532
|
-
return client_default.get(
|
|
1533
|
-
route(_paths3.metaGame, { gameId: parsedGameId })
|
|
1534
|
-
);
|
|
1535
|
-
}
|
|
1559
|
+
game: metaGame,
|
|
1560
|
+
playoffSeries: metaPlayoffSeries
|
|
1536
1561
|
};
|
|
1537
|
-
|
|
1562
|
+
async function metaGame(gameId) {
|
|
1563
|
+
const parsedGameId = GameId(gameId);
|
|
1564
|
+
if (isParseError(parsedGameId)) {
|
|
1565
|
+
return {
|
|
1566
|
+
status: "error",
|
|
1567
|
+
error: new ValidationError(parsedGameId.summary, {
|
|
1568
|
+
endpoint: _miscPaths.metaGame
|
|
1569
|
+
})
|
|
1570
|
+
};
|
|
1571
|
+
}
|
|
1572
|
+
return client_default.get(route(_miscPaths.metaGame, { gameId: parsedGameId }));
|
|
1573
|
+
}
|
|
1574
|
+
async function metaPlayoffSeries(seriesLetter, year) {
|
|
1575
|
+
const parsed = SeriesParams({ year, seriesLetter });
|
|
1576
|
+
if (isParseError(parsed)) {
|
|
1577
|
+
return {
|
|
1578
|
+
status: "error",
|
|
1579
|
+
error: new ValidationError(parsed.summary, {
|
|
1580
|
+
endpoint: _miscPaths.metaPlayoffSeries
|
|
1581
|
+
})
|
|
1582
|
+
};
|
|
1583
|
+
}
|
|
1584
|
+
return client_default.get(route(_miscPaths.metaPlayoffSeries, parsed));
|
|
1585
|
+
}
|
|
1586
|
+
async function postalLookup(postalCode) {
|
|
1538
1587
|
const parsedPostalCode = PostalCode(postalCode);
|
|
1539
1588
|
if (isParseError(parsedPostalCode)) {
|
|
1540
|
-
return
|
|
1589
|
+
return {
|
|
1541
1590
|
status: "error",
|
|
1542
1591
|
error: new ValidationError(parsedPostalCode.summary, {
|
|
1543
|
-
endpoint:
|
|
1592
|
+
endpoint: _miscPaths.postalLookup
|
|
1544
1593
|
})
|
|
1545
|
-
}
|
|
1594
|
+
};
|
|
1546
1595
|
}
|
|
1547
1596
|
return client_default.get(
|
|
1548
|
-
route(
|
|
1597
|
+
route(_miscPaths.postalLookup, { postalCode: parsedPostalCode })
|
|
1549
1598
|
);
|
|
1550
|
-
}
|
|
1551
|
-
|
|
1552
|
-
return client_default.get(
|
|
1553
|
-
}
|
|
1554
|
-
|
|
1599
|
+
}
|
|
1600
|
+
async function location() {
|
|
1601
|
+
return client_default.get(_miscPaths.location);
|
|
1602
|
+
}
|
|
1603
|
+
async function partnerGame(countryCode) {
|
|
1555
1604
|
const parsedCountryCode = CountryCode(countryCode);
|
|
1556
1605
|
if (isParseError(parsedCountryCode)) {
|
|
1557
|
-
return
|
|
1606
|
+
return {
|
|
1558
1607
|
status: "error",
|
|
1559
1608
|
error: new ValidationError(parsedCountryCode.summary, {
|
|
1560
|
-
endpoint:
|
|
1609
|
+
endpoint: _miscPaths.partnerGame
|
|
1561
1610
|
})
|
|
1562
|
-
}
|
|
1611
|
+
};
|
|
1563
1612
|
}
|
|
1564
1613
|
return client_default.get(
|
|
1565
|
-
route(
|
|
1614
|
+
route(_miscPaths.partnerGame, { countryCode: parsedCountryCode })
|
|
1566
1615
|
);
|
|
1567
|
-
}
|
|
1616
|
+
}
|
|
1568
1617
|
|
|
1569
1618
|
// src/api/gamecenter/player.ts
|
|
1570
1619
|
var player_exports = {};
|
|
@@ -1575,325 +1624,250 @@ __export(player_exports, {
|
|
|
1575
1624
|
spotlight: () => spotlight,
|
|
1576
1625
|
statsLeaders: () => statsLeaders
|
|
1577
1626
|
});
|
|
1578
|
-
var
|
|
1579
|
-
landing: "player/{playerId}/landing",
|
|
1580
|
-
gameLog: "player/{playerId}/game-log/{season}/{gameType}",
|
|
1581
|
-
spotlight: "player-spotlight",
|
|
1582
|
-
statsLeaders: {
|
|
1583
|
-
skaters: "skater-stats-leaders/{season}/{gameType}",
|
|
1584
|
-
goalies: "goalie-stats-leaders/{season}/{gameType}"
|
|
1585
|
-
},
|
|
1586
|
-
playerSearch: "https://search.d3.nhle.com/api/v1/search/player"
|
|
1587
|
-
};
|
|
1588
|
-
var nhlPlayerSearch = createNHLClient(_paths4.playerSearch);
|
|
1627
|
+
var nhlPlayerSearch = createNHLClient(_playerPaths.playerSearch);
|
|
1589
1628
|
var searchUrlParams = { culture: "en", q: "" };
|
|
1590
|
-
|
|
1629
|
+
async function landing2(playerId) {
|
|
1591
1630
|
const parsedPlayerId = PlayerId(playerId);
|
|
1592
1631
|
if (isParseError(parsedPlayerId)) {
|
|
1593
|
-
return
|
|
1632
|
+
return {
|
|
1594
1633
|
status: "error",
|
|
1595
1634
|
error: new ValidationError(parsedPlayerId.summary, {
|
|
1596
|
-
endpoint:
|
|
1635
|
+
endpoint: _playerPaths.landing
|
|
1597
1636
|
})
|
|
1598
|
-
}
|
|
1637
|
+
};
|
|
1599
1638
|
}
|
|
1600
1639
|
return client_default.get(
|
|
1601
|
-
route(
|
|
1640
|
+
route(_playerPaths.landing, { playerId: parsedPlayerId })
|
|
1602
1641
|
);
|
|
1603
|
-
}
|
|
1604
|
-
|
|
1642
|
+
}
|
|
1643
|
+
async function gameLog(playerId, season, gameType) {
|
|
1605
1644
|
const Parser = BaseParams.merge({
|
|
1606
1645
|
playerId: PlayerId
|
|
1607
1646
|
});
|
|
1608
1647
|
const parsed = Parser({ playerId, season, gameType });
|
|
1609
1648
|
if (isParseError(parsed)) {
|
|
1610
|
-
return
|
|
1649
|
+
return {
|
|
1611
1650
|
status: "error",
|
|
1612
1651
|
error: new ValidationError(parsed.summary, {
|
|
1613
|
-
endpoint:
|
|
1652
|
+
endpoint: _playerPaths.gameLog
|
|
1614
1653
|
})
|
|
1615
|
-
}
|
|
1654
|
+
};
|
|
1616
1655
|
}
|
|
1617
|
-
return client_default.get(route(
|
|
1618
|
-
}
|
|
1619
|
-
|
|
1620
|
-
return client_default.get(
|
|
1621
|
-
}
|
|
1622
|
-
|
|
1656
|
+
return client_default.get(route(_playerPaths.gameLog, parsed));
|
|
1657
|
+
}
|
|
1658
|
+
async function spotlight() {
|
|
1659
|
+
return client_default.get(_playerPaths.spotlight);
|
|
1660
|
+
}
|
|
1661
|
+
async function search(query) {
|
|
1623
1662
|
return nhlPlayerSearch.get("", {
|
|
1624
1663
|
...searchUrlParams,
|
|
1625
1664
|
q: query
|
|
1626
1665
|
});
|
|
1627
|
-
}
|
|
1666
|
+
}
|
|
1628
1667
|
var statsLeaders = {
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
* @param season - The season identifier (optional)
|
|
1632
|
-
* @param gameType - The game type identifier (optional)
|
|
1633
|
-
* @returns Promise resolving to skater stats leaders
|
|
1634
|
-
*/
|
|
1635
|
-
skaters: (season, gameType) => {
|
|
1636
|
-
const parsed = BaseParams({ season, gameType });
|
|
1637
|
-
if (isParseError(parsed)) {
|
|
1638
|
-
return Promise.resolve({
|
|
1639
|
-
status: "error",
|
|
1640
|
-
error: new ValidationError(parsed.summary, {
|
|
1641
|
-
endpoint: _paths4.statsLeaders.skaters
|
|
1642
|
-
})
|
|
1643
|
-
});
|
|
1644
|
-
}
|
|
1645
|
-
return client_default.get(route(_paths4.statsLeaders.skaters, parsed));
|
|
1646
|
-
},
|
|
1647
|
-
/**
|
|
1648
|
-
* Get goalie stats leaders
|
|
1649
|
-
* @param season - The season identifier (optional)
|
|
1650
|
-
* @param gameType - The game type identifier (optional)
|
|
1651
|
-
* @returns Promise resolving to goalie stats leaders
|
|
1652
|
-
*/
|
|
1653
|
-
goalies: (season, gameType) => {
|
|
1654
|
-
const parsed = BaseParams({ season, gameType });
|
|
1655
|
-
if (isParseError(parsed)) {
|
|
1656
|
-
return Promise.resolve({
|
|
1657
|
-
status: "error",
|
|
1658
|
-
error: new ValidationError(parsed.summary, {
|
|
1659
|
-
endpoint: _paths4.statsLeaders.goalies
|
|
1660
|
-
})
|
|
1661
|
-
});
|
|
1662
|
-
}
|
|
1663
|
-
return client_default.get(route(_paths4.statsLeaders.goalies, parsed));
|
|
1664
|
-
}
|
|
1668
|
+
skaters: statsLeadersSkaters,
|
|
1669
|
+
goalies: statsLeadersGoalies
|
|
1665
1670
|
};
|
|
1671
|
+
async function statsLeadersSkaters(season, gameType) {
|
|
1672
|
+
const parsed = BaseParams({ season, gameType });
|
|
1673
|
+
if (isParseError(parsed)) {
|
|
1674
|
+
return {
|
|
1675
|
+
status: "error",
|
|
1676
|
+
error: new ValidationError(parsed.summary, {
|
|
1677
|
+
endpoint: _playerPaths.statsLeaders.skaters
|
|
1678
|
+
})
|
|
1679
|
+
};
|
|
1680
|
+
}
|
|
1681
|
+
return client_default.get(route(_playerPaths.statsLeaders.skaters, parsed));
|
|
1682
|
+
}
|
|
1683
|
+
async function statsLeadersGoalies(season, gameType) {
|
|
1684
|
+
const parsed = BaseParams({ season, gameType });
|
|
1685
|
+
if (isParseError(parsed)) {
|
|
1686
|
+
return {
|
|
1687
|
+
status: "error",
|
|
1688
|
+
error: new ValidationError(parsed.summary, {
|
|
1689
|
+
endpoint: _playerPaths.statsLeaders.goalies
|
|
1690
|
+
})
|
|
1691
|
+
};
|
|
1692
|
+
}
|
|
1693
|
+
return client_default.get(route(_playerPaths.statsLeaders.goalies, parsed));
|
|
1694
|
+
}
|
|
1666
1695
|
|
|
1667
1696
|
// src/api/gamecenter/score.ts
|
|
1668
|
-
|
|
1669
|
-
score: "score/{date}",
|
|
1670
|
-
scoreboard: {
|
|
1671
|
-
now: "scoreboard/now",
|
|
1672
|
-
byTeam: "scoreboard/{team}/now",
|
|
1673
|
-
byDate: "scoreboard/{date}"
|
|
1674
|
-
}
|
|
1675
|
-
};
|
|
1676
|
-
var score = (date) => {
|
|
1697
|
+
async function score(date) {
|
|
1677
1698
|
const parsed = NHLDate(date ?? getCurrentDate());
|
|
1678
1699
|
if (isParseError(parsed)) {
|
|
1679
|
-
return
|
|
1700
|
+
return {
|
|
1680
1701
|
status: "error",
|
|
1681
1702
|
error: new ValidationError(parsed.summary, {
|
|
1682
|
-
endpoint:
|
|
1703
|
+
endpoint: _scorePaths.score
|
|
1683
1704
|
})
|
|
1684
|
-
}
|
|
1705
|
+
};
|
|
1685
1706
|
}
|
|
1686
|
-
return client_default.get(route(
|
|
1687
|
-
}
|
|
1688
|
-
|
|
1707
|
+
return client_default.get(route(_scorePaths.score, { date: parsed }));
|
|
1708
|
+
}
|
|
1709
|
+
async function scoreboard() {
|
|
1710
|
+
return client_default.get(_scorePaths.scoreboard.now);
|
|
1711
|
+
}
|
|
1689
1712
|
scoreboard.team = async (team) => {
|
|
1690
1713
|
const parsed = TeamAbbrev(team);
|
|
1691
1714
|
if (isParseError(parsed)) {
|
|
1692
|
-
return
|
|
1715
|
+
return {
|
|
1693
1716
|
status: "error",
|
|
1694
1717
|
error: new ValidationError(parsed.summary, {
|
|
1695
|
-
endpoint:
|
|
1718
|
+
endpoint: _scorePaths.scoreboard.byTeam
|
|
1696
1719
|
})
|
|
1697
|
-
}
|
|
1720
|
+
};
|
|
1698
1721
|
}
|
|
1699
1722
|
return client_default.get(
|
|
1700
|
-
route(
|
|
1723
|
+
route(_scorePaths.scoreboard.byTeam, { team: parsed })
|
|
1701
1724
|
);
|
|
1702
1725
|
};
|
|
1703
1726
|
scoreboard.date = async (date) => {
|
|
1704
1727
|
const parsed = NHLDate(date);
|
|
1705
1728
|
if (isParseError(parsed)) {
|
|
1706
|
-
return
|
|
1729
|
+
return {
|
|
1707
1730
|
status: "error",
|
|
1708
1731
|
error: new ValidationError(parsed.summary, {
|
|
1709
|
-
endpoint:
|
|
1732
|
+
endpoint: _scorePaths.scoreboard.byDate
|
|
1710
1733
|
})
|
|
1711
|
-
}
|
|
1734
|
+
};
|
|
1712
1735
|
}
|
|
1713
1736
|
return client_default.get(
|
|
1714
|
-
route(
|
|
1737
|
+
route(_scorePaths.scoreboard.byDate, { date: parsed })
|
|
1715
1738
|
);
|
|
1716
1739
|
};
|
|
1717
1740
|
|
|
1718
1741
|
// src/api/gamecenter/team.ts
|
|
1719
1742
|
var team_exports = {};
|
|
1720
1743
|
__export(team_exports, {
|
|
1721
|
-
clubStats: () => clubStats,
|
|
1722
|
-
clubStatsSeason: () => clubStatsSeason,
|
|
1723
1744
|
prospects: () => prospects,
|
|
1724
1745
|
roster: () => roster,
|
|
1725
1746
|
rosterSeasons: () => rosterSeasons,
|
|
1726
1747
|
schedule: () => schedule2,
|
|
1727
1748
|
standings: () => standings,
|
|
1728
|
-
standingsSeason: () => standingsSeason
|
|
1749
|
+
standingsSeason: () => standingsSeason,
|
|
1750
|
+
stats: () => stats,
|
|
1751
|
+
statsSeason: () => statsSeason
|
|
1729
1752
|
});
|
|
1730
|
-
|
|
1731
|
-
rosterSeasons: "roster-season/{team}",
|
|
1732
|
-
roster: "roster/{team}/{season}",
|
|
1733
|
-
prospects: "prospects/{team}",
|
|
1734
|
-
clubStats: "club-stats/{team}/{season}/{gameType}",
|
|
1735
|
-
clubStatsSeason: "club-stats-season/{team}",
|
|
1736
|
-
standings: "standings/{date}",
|
|
1737
|
-
standingsSeason: "standings-season",
|
|
1738
|
-
clubSchedule: "club-schedule/{team}/{period}/{date}",
|
|
1739
|
-
clubScheduleSeason: "club-schedule-season/{team}/{season}"
|
|
1740
|
-
};
|
|
1741
|
-
var rosterSeasons = (team) => {
|
|
1753
|
+
async function rosterSeasons(team) {
|
|
1742
1754
|
const parsed = TeamAbbrev(team);
|
|
1743
1755
|
if (isParseError(parsed)) {
|
|
1744
|
-
return
|
|
1756
|
+
return {
|
|
1745
1757
|
status: "error",
|
|
1746
1758
|
error: new ValidationError(parsed.summary, {
|
|
1747
|
-
endpoint:
|
|
1759
|
+
endpoint: _teamPaths.rosterSeasons
|
|
1748
1760
|
})
|
|
1749
|
-
}
|
|
1761
|
+
};
|
|
1750
1762
|
}
|
|
1751
|
-
return client_default.get(route(
|
|
1752
|
-
}
|
|
1753
|
-
|
|
1763
|
+
return client_default.get(route(_teamPaths.rosterSeasons, { team: parsed }));
|
|
1764
|
+
}
|
|
1765
|
+
async function roster(team, season) {
|
|
1754
1766
|
const parsed = TeamAndSeasonParams({ team, season });
|
|
1755
1767
|
if (isParseError(parsed)) {
|
|
1756
|
-
return
|
|
1768
|
+
return {
|
|
1757
1769
|
status: "error",
|
|
1758
1770
|
error: new ValidationError(parsed.summary, {
|
|
1759
|
-
endpoint:
|
|
1771
|
+
endpoint: _teamPaths.roster
|
|
1760
1772
|
})
|
|
1761
|
-
}
|
|
1773
|
+
};
|
|
1762
1774
|
}
|
|
1763
|
-
return client_default.get(route(
|
|
1764
|
-
}
|
|
1765
|
-
|
|
1775
|
+
return client_default.get(route(_teamPaths.roster, parsed));
|
|
1776
|
+
}
|
|
1777
|
+
async function prospects(team) {
|
|
1766
1778
|
const parsed = TeamAbbrev(team);
|
|
1767
1779
|
if (isParseError(parsed)) {
|
|
1768
|
-
return
|
|
1780
|
+
return {
|
|
1769
1781
|
status: "error",
|
|
1770
1782
|
error: new ValidationError(parsed.summary, {
|
|
1771
|
-
endpoint:
|
|
1783
|
+
endpoint: _teamPaths.prospects
|
|
1772
1784
|
})
|
|
1773
|
-
}
|
|
1785
|
+
};
|
|
1774
1786
|
}
|
|
1775
|
-
return client_default.get(route(
|
|
1776
|
-
}
|
|
1777
|
-
|
|
1787
|
+
return client_default.get(route(_teamPaths.prospects, { team: parsed }));
|
|
1788
|
+
}
|
|
1789
|
+
async function stats(team, season, gameType) {
|
|
1778
1790
|
const Parser = BaseParams.merge({
|
|
1779
1791
|
team: TeamAbbrev
|
|
1780
1792
|
});
|
|
1781
1793
|
const parsed = Parser({ team, season, gameType });
|
|
1782
1794
|
if (isParseError(parsed)) {
|
|
1783
|
-
return
|
|
1795
|
+
return {
|
|
1784
1796
|
status: "error",
|
|
1785
1797
|
error: new ValidationError(parsed.summary, {
|
|
1786
|
-
endpoint:
|
|
1798
|
+
endpoint: _teamPaths.clubStats
|
|
1787
1799
|
})
|
|
1788
|
-
}
|
|
1800
|
+
};
|
|
1789
1801
|
}
|
|
1790
|
-
return client_default.get(route(
|
|
1791
|
-
}
|
|
1792
|
-
|
|
1802
|
+
return client_default.get(route(_teamPaths.clubStats, parsed));
|
|
1803
|
+
}
|
|
1804
|
+
async function statsSeason(team) {
|
|
1793
1805
|
const parsed = TeamAbbrev(team);
|
|
1794
1806
|
if (isParseError(parsed)) {
|
|
1795
|
-
return
|
|
1807
|
+
return {
|
|
1796
1808
|
status: "error",
|
|
1797
1809
|
error: new ValidationError(parsed.summary, {
|
|
1798
|
-
endpoint:
|
|
1810
|
+
endpoint: _teamPaths.clubStatsSeason
|
|
1799
1811
|
})
|
|
1800
|
-
}
|
|
1812
|
+
};
|
|
1801
1813
|
}
|
|
1802
|
-
return client_default.get(route(
|
|
1803
|
-
}
|
|
1804
|
-
|
|
1814
|
+
return client_default.get(route(_teamPaths.clubStatsSeason, { team: parsed }));
|
|
1815
|
+
}
|
|
1816
|
+
async function standings(date) {
|
|
1805
1817
|
const parsed = NHLDate(date ?? getCurrentDate());
|
|
1806
1818
|
if (isParseError(parsed)) {
|
|
1807
|
-
return
|
|
1819
|
+
return {
|
|
1808
1820
|
status: "error",
|
|
1809
1821
|
error: new ValidationError(parsed.summary, {
|
|
1810
|
-
endpoint:
|
|
1822
|
+
endpoint: _teamPaths.standings
|
|
1811
1823
|
})
|
|
1812
|
-
}
|
|
1824
|
+
};
|
|
1813
1825
|
}
|
|
1814
|
-
return client_default.get(route(
|
|
1815
|
-
}
|
|
1816
|
-
|
|
1817
|
-
return client_default.get(
|
|
1818
|
-
}
|
|
1819
|
-
|
|
1820
|
-
const parsed = ScheduleParams({ team, date,
|
|
1826
|
+
return client_default.get(route(_teamPaths.standings, { date: parsed }));
|
|
1827
|
+
}
|
|
1828
|
+
async function standingsSeason() {
|
|
1829
|
+
return client_default.get(_teamPaths.standingsSeason);
|
|
1830
|
+
}
|
|
1831
|
+
async function scheduleWeek(team, date) {
|
|
1832
|
+
const parsed = ScheduleParams({ team, date, month: void 0 });
|
|
1821
1833
|
if (isParseError(parsed)) {
|
|
1822
|
-
return
|
|
1834
|
+
return {
|
|
1823
1835
|
status: "error",
|
|
1824
1836
|
error: new ValidationError(parsed.summary, {
|
|
1825
|
-
endpoint:
|
|
1837
|
+
endpoint: _teamPaths.clubSchedule.week
|
|
1826
1838
|
})
|
|
1827
|
-
}
|
|
1839
|
+
};
|
|
1828
1840
|
}
|
|
1829
|
-
|
|
1830
|
-
|
|
1841
|
+
return client_default.get(route(_teamPaths.clubSchedule.week, parsed));
|
|
1842
|
+
}
|
|
1843
|
+
async function scheduleMonth(team, date) {
|
|
1844
|
+
const parsed = ScheduleParams({ team, month: date, date: void 0 });
|
|
1845
|
+
if (isParseError(parsed)) {
|
|
1846
|
+
return {
|
|
1847
|
+
status: "error",
|
|
1848
|
+
error: new ValidationError(parsed.summary, {
|
|
1849
|
+
endpoint: _teamPaths.clubSchedule.month
|
|
1850
|
+
})
|
|
1851
|
+
};
|
|
1831
1852
|
}
|
|
1832
|
-
return client_default.get(route(
|
|
1833
|
-
}
|
|
1834
|
-
|
|
1853
|
+
return client_default.get(route(_teamPaths.clubSchedule.month, parsed));
|
|
1854
|
+
}
|
|
1855
|
+
async function scheduleSeason(team, season) {
|
|
1835
1856
|
const parsed = TeamAndSeasonParams({ team, season });
|
|
1836
1857
|
if (isParseError(parsed)) {
|
|
1837
|
-
return
|
|
1858
|
+
return {
|
|
1838
1859
|
status: "error",
|
|
1839
1860
|
error: new ValidationError(parsed.summary, {
|
|
1840
|
-
endpoint:
|
|
1861
|
+
endpoint: _teamPaths.clubSchedule.season
|
|
1841
1862
|
})
|
|
1842
|
-
}
|
|
1863
|
+
};
|
|
1843
1864
|
}
|
|
1844
|
-
return client_default.get(route(
|
|
1845
|
-
}
|
|
1865
|
+
return client_default.get(route(_teamPaths.clubSchedule.season, parsed));
|
|
1866
|
+
}
|
|
1846
1867
|
var schedule2 = {
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
* @returns A promise that resolves to the full season schedule for the specified team and season
|
|
1851
|
-
* @example
|
|
1852
|
-
* ```ts
|
|
1853
|
-
* // Get the full season schedule for the Boston Bruins for the 2022-2023 season
|
|
1854
|
-
* schedule.season('BOS', 20222023).then((data) => {
|
|
1855
|
-
* console.log(data);
|
|
1856
|
-
* });
|
|
1857
|
-
* ```
|
|
1858
|
-
*/
|
|
1859
|
-
season: clubScheduleSeason,
|
|
1860
|
-
/**
|
|
1861
|
-
* Get the team schedule for any seven-day period
|
|
1862
|
-
* @param team - The team abbreviation
|
|
1863
|
-
* @param date - The date indicating the start of the seven-day period.
|
|
1864
|
-
* If not provided, defaults to the current date. format: 'YYYY-MM'
|
|
1865
|
-
* @returns A promise that resolves to the club schedule for the specified week
|
|
1866
|
-
*
|
|
1867
|
-
* @example
|
|
1868
|
-
* ```ts
|
|
1869
|
-
* import { schedule } from 'nhle-api';
|
|
1870
|
-
*
|
|
1871
|
-
* // Get the schedule for the Chicago Blackhawks for the week of November 4, 2023
|
|
1872
|
-
* // This returns the schedule from November 4 to November 10, 2023
|
|
1873
|
-
* schedule.week('CHI', '2023-11-04').then((data) => {
|
|
1874
|
-
* console.log(data);
|
|
1875
|
-
* });
|
|
1876
|
-
* ```
|
|
1877
|
-
*/
|
|
1878
|
-
week: (team, date) => clubSchedule(team, date, "week"),
|
|
1879
|
-
/**
|
|
1880
|
-
* Get the team schedule for any month
|
|
1881
|
-
* @param team - The team abbreviation
|
|
1882
|
-
* @param date - The date indicating the month to get the schedule for.
|
|
1883
|
-
* If not provided, defaults to the current month. format: 'YYYY-MM'
|
|
1884
|
-
* @returns A promise that resolves to the club schedule for the specified month
|
|
1885
|
-
*
|
|
1886
|
-
* @example
|
|
1887
|
-
* ```ts
|
|
1888
|
-
* import { schedule } from 'nhle-api';
|
|
1889
|
-
*
|
|
1890
|
-
* // Get the schedule for the Toronto Maple Leafs for November 2023
|
|
1891
|
-
* schedule.month('TOR', '2023-11').then((data) => {
|
|
1892
|
-
* console.log(data);
|
|
1893
|
-
* });
|
|
1894
|
-
* ```
|
|
1895
|
-
*/
|
|
1896
|
-
month: (team, date) => clubSchedule(team, date, "month")
|
|
1868
|
+
season: scheduleSeason,
|
|
1869
|
+
week: scheduleWeek,
|
|
1870
|
+
month: scheduleMonth
|
|
1897
1871
|
};
|
|
1898
1872
|
|
|
1899
1873
|
exports.EDGE = EDGE;
|