nhle-api 0.5.4 → 0.6.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/lib/index.js CHANGED
@@ -27,86 +27,52 @@ __export(goalies_exports, {
27
27
  top10: () => top10
28
28
  });
29
29
 
30
- // src/config/env.ts
31
- function parseTimeout() {
32
- const timeout = process.env.NHLE_API_TIMEOUT;
33
- if (!timeout) return 5e3;
34
- const parsed = parseInt(timeout, 10);
35
- if (Number.isNaN(parsed) || parsed <= 0) {
36
- console.warn(
37
- `Invalid NHLE_API_TIMEOUT: "${timeout}". Using default 5000ms`
38
- );
39
- return 5e3;
40
- }
41
- return parsed;
42
- }
43
- function parseLanguage() {
44
- const language = process.env.NHLE_API_LANGUAGE?.toLowerCase();
45
- if (language === "fr") return "fr";
46
- if (language && language !== "en") {
47
- console.warn(
48
- `Invalid NHLE_API_LANGUAGE: "${language}". Using default 'en'`
49
- );
50
- }
51
- return "en";
52
- }
53
- function parseLogLevel() {
54
- const logLevel = process.env.NHLE_API_LOGLEVEL?.toLowerCase();
55
- const validLevels = [
56
- "silent",
57
- "error",
58
- "warn",
59
- "info",
60
- "debug"
61
- ];
62
- if (!logLevel) return "warn";
63
- if (validLevels.includes(logLevel)) {
64
- return logLevel;
65
- }
66
- console.warn(
67
- `Invalid NHLE_API_LOGLEVEL: "${logLevel}". Valid options: ${validLevels.join(", ")}. Using default 'warn'`
68
- );
69
- return "warn";
70
- }
71
- var envConfig = {
72
- /**
73
- * Request timeout in milliseconds
74
- * Set via NHLE_API_TIMEOUT environment variable
75
- * @default 5000
76
- */
77
- timeout: parseTimeout(),
78
- /**
79
- * Language code for API responses
80
- * Set via NHLE_API_LANGUAGE environment variable
81
- * @default 'en'
82
- */
83
- language: parseLanguage(),
84
- /**
85
- * Logging level for the client
86
- * Set via NHLE_API_LOGLEVEL environment variable
87
- * @default 'warn'
88
- */
89
- logLevel: parseLogLevel()
30
+ // src/config/index.ts
31
+ var config = {
32
+ timeout: 5e3,
33
+ language: "en",
34
+ logLevel: "warn"
90
35
  };
91
- function logEnvConfig() {
92
- const vars = {
93
- timeout: process.env.NHLE_API_TIMEOUT,
94
- language: process.env.NHLE_API_LANGUAGE,
95
- logLevel: process.env.NHLE_API_LOGLEVEL
96
- };
97
- const configured = Object.entries(vars).filter(
98
- ([, v]) => v !== void 0
99
- );
100
- if (configured.length > 0) {
101
- console.debug("NHL API Environment Configuration:", {
102
- ...Object.fromEntries(configured),
103
- resolvedTimeout: envConfig.timeout,
104
- resolvedLanguage: envConfig.language,
105
- resolvedLogLevel: envConfig.logLevel
106
- });
107
- }
36
+ function logConfig() {
37
+ console.debug("NHL API Configuration:", config);
108
38
  }
109
39
 
40
+ // src/logging/index.ts
41
+ var levelRank = {
42
+ silent: 0,
43
+ error: 1,
44
+ warn: 2,
45
+ info: 3,
46
+ debug: 4
47
+ };
48
+ function isEnabled(level, threshold) {
49
+ return levelRank[level] > 0 && levelRank[level] <= levelRank[threshold];
50
+ }
51
+ function writeLog(level, message, context, threshold = config.logLevel) {
52
+ if (!isEnabled(level, threshold)) return;
53
+ const args = context === void 0 ? [message] : [message, context];
54
+ switch (level) {
55
+ case "error":
56
+ console.error(...args);
57
+ break;
58
+ case "warn":
59
+ console.warn(...args);
60
+ break;
61
+ case "info":
62
+ console.info(...args);
63
+ break;
64
+ case "debug":
65
+ console.debug(...args);
66
+ break;
67
+ }
68
+ }
69
+ var logger = {
70
+ error: (message, context) => writeLog("error", message, context),
71
+ warn: (message, context) => writeLog("warn", message, context),
72
+ info: (message, context) => writeLog("info", message, context),
73
+ debug: (message, context) => writeLog("debug", message, context)
74
+ };
75
+
110
76
  // src/errors/index.ts
111
77
  var ErrorCategory = {
112
78
  /** Network-level errors (connection refused, timeout, etc.) */
@@ -125,6 +91,7 @@ var ErrorCategory = {
125
91
  VALIDATION: "VALIDATION"
126
92
  };
127
93
  var LogLevel = {
94
+ NONE: 0,
128
95
  ERROR: 1,
129
96
  WARN: 2,
130
97
  INFO: 3,
@@ -191,18 +158,30 @@ var APIError = class extends NHLError {
191
158
  super(message, ErrorCategory.API_ERROR, context);
192
159
  }
193
160
  };
161
+ var ParseError = class extends NHLError {
162
+ constructor(message, context = {}) {
163
+ super(message, ErrorCategory.PARSE, context);
164
+ }
165
+ };
194
166
  var ValidationError = class extends NHLError {
195
167
  constructor(message, context = {}) {
196
168
  super(message, ErrorCategory.VALIDATION, context);
197
169
  }
198
170
  };
199
171
  var ErrorHandler = class {
200
- config;
201
- constructor(config = {}) {
202
- this.config = {
203
- logLevel: config.logLevel ?? LogLevel.ERROR,
204
- logger: config.logger ?? this.defaultLogger.bind(this),
205
- includeStack: config.includeStack ?? true
172
+ overrides;
173
+ /**
174
+ * @param config - Overrides; an unset `logLevel` follows the shared
175
+ * `config.logLevel` at log time.
176
+ */
177
+ constructor(config2 = {}) {
178
+ this.overrides = { ...config2 };
179
+ }
180
+ get config() {
181
+ return {
182
+ logLevel: this.overrides.logLevel ?? toErrorLogLevel(config.logLevel),
183
+ logger: this.overrides.logger ?? this.defaultLogger.bind(this),
184
+ includeStack: this.overrides.includeStack ?? true
206
185
  };
207
186
  }
208
187
  /**
@@ -210,8 +189,12 @@ var ErrorHandler = class {
210
189
  */
211
190
  defaultLogger(level, message, context) {
212
191
  if (level > this.config.logLevel) return;
213
- const logFn = level === LogLevel.ERROR ? console.error : level === LogLevel.WARN ? console.warn : console.log;
214
- logFn(`[NHL API] ${message}`, context);
192
+ writeLog(
193
+ toClientLogLevel(level),
194
+ `[NHL API] ${message}`,
195
+ context,
196
+ toClientThreshold(this.config.logLevel)
197
+ );
215
198
  }
216
199
  /**
217
200
  * Log an error based on configuration
@@ -309,10 +292,41 @@ var ErrorHandler = class {
309
292
  /**
310
293
  * Update configuration
311
294
  */
312
- configure(config) {
313
- this.config = { ...this.config, ...config };
295
+ configure(config2) {
296
+ this.overrides = { ...this.overrides, ...config2 };
314
297
  }
315
298
  };
299
+ function toErrorLogLevel(level) {
300
+ switch (level) {
301
+ case "silent":
302
+ return LogLevel.NONE;
303
+ case "error":
304
+ return LogLevel.ERROR;
305
+ case "warn":
306
+ return LogLevel.WARN;
307
+ case "info":
308
+ return LogLevel.INFO;
309
+ case "debug":
310
+ return LogLevel.DEBUG;
311
+ }
312
+ }
313
+ function toClientLogLevel(level) {
314
+ switch (level) {
315
+ case LogLevel.ERROR:
316
+ return "error";
317
+ case LogLevel.WARN:
318
+ return "warn";
319
+ case LogLevel.INFO:
320
+ return "info";
321
+ case LogLevel.DEBUG:
322
+ return "debug";
323
+ default:
324
+ return "debug";
325
+ }
326
+ }
327
+ function toClientThreshold(level) {
328
+ return level === LogLevel.NONE ? "silent" : toClientLogLevel(level);
329
+ }
316
330
  new ErrorHandler();
317
331
 
318
332
  // src/client/index.ts
@@ -320,26 +334,42 @@ var BASE_URLS = {
320
334
  gamecenter: "https://api-web.nhle.com/v1",
321
335
  edgeStats: "https://api.nhle.com/stats/rest"
322
336
  };
323
- var DEFAULT_CONFIG = {
324
- baseUrl: BASE_URLS.gamecenter,
325
- timeout: envConfig.timeout,
326
- headers: {
327
- Accept: "application/json"
328
- },
329
- language: envConfig.language
337
+ var DEFAULT_HEADERS = {
338
+ Accept: "application/json"
330
339
  };
331
340
  var NHLClient = class {
332
- config;
341
+ options;
333
342
  errorHandler;
334
343
  /**
335
344
  * Creates a new NHL API client instance
336
- * @param baseURL - Optional custom base URL or predefined API endpoint key
345
+ *
346
+ * Options left unset (timeout, language) follow the shared `config`
347
+ * object at request time, so changing `config` after import still
348
+ * applies to this client.
349
+ *
350
+ * @param baseURLOrOptions - Base URL, or client options
337
351
  * @param errorConfig - Optional error handling configuration
352
+ *
353
+ * @example
354
+ * const client = new NHLClient('https://api-web.nhle.com/v1');
355
+ * const slow = new NHLClient({ timeout: 15000, language: 'fr' });
338
356
  */
339
- constructor(baseURL, errorConfig) {
340
- this.config = { ...DEFAULT_CONFIG };
341
- if (baseURL) this.config.baseUrl = baseURL;
342
- this.errorHandler = new ErrorHandler(errorConfig);
357
+ constructor(baseURLOrOptions, errorConfig) {
358
+ const options = typeof baseURLOrOptions === "string" ? { baseUrl: baseURLOrOptions } : baseURLOrOptions ?? {};
359
+ const { errorConfig: optionsErrorConfig, ...clientOptions } = options;
360
+ this.options = clientOptions;
361
+ this.errorHandler = new ErrorHandler(
362
+ errorConfig ?? optionsErrorConfig
363
+ );
364
+ }
365
+ /** Base URL, timeout, headers and language in effect for the next request. */
366
+ get config() {
367
+ return {
368
+ baseUrl: this.options.baseUrl ?? BASE_URLS.gamecenter,
369
+ timeout: this.options.timeout ?? config.timeout,
370
+ headers: { ...DEFAULT_HEADERS, ...this.options.headers },
371
+ language: this.options.language ?? config.language
372
+ };
343
373
  }
344
374
  /**
345
375
  * Helper to build URL with query parameters
@@ -364,18 +394,16 @@ var NHLClient = class {
364
394
  * @returns Promise resolving to an APIResponse containing either data or error
365
395
  */
366
396
  async get(endpoint, params) {
397
+ const { timeout, headers, language } = this.config;
367
398
  const url = this.buildUrl(endpoint, params);
368
399
  const controller = new AbortController();
369
- const timeoutId = setTimeout(
370
- () => controller.abort(),
371
- this.config.timeout
372
- );
400
+ const timeoutId = setTimeout(() => controller.abort(), timeout);
373
401
  try {
374
402
  const response = await fetch(url, {
375
403
  method: "GET",
376
404
  headers: {
377
- ...this.config.headers,
378
- "Accept-Language": this.config.language
405
+ ...headers,
406
+ "Accept-Language": language
379
407
  },
380
408
  signal: controller.signal
381
409
  });
@@ -417,15 +445,15 @@ var NHLClient = class {
417
445
  * Configure error handling behavior
418
446
  * @param config - Error configuration options
419
447
  */
420
- configureErrorHandling(config) {
421
- this.errorHandler.configure(config);
448
+ configureErrorHandling(config2) {
449
+ this.errorHandler.configure(config2);
422
450
  }
423
451
  };
424
- function createNHLClient(baseURL, errorConfig) {
425
- return new NHLClient(baseURL, errorConfig);
452
+ function createNHLClient(baseURLOrOptions, errorConfig) {
453
+ return new NHLClient(baseURLOrOptions, errorConfig);
426
454
  }
427
455
  var nhlClient = createNHLClient(BASE_URLS.gamecenter);
428
- createNHLClient(BASE_URLS.edgeStats);
456
+ var edgeStatsClient = createNHLClient(BASE_URLS.edgeStats);
429
457
 
430
458
  // src/constants/edge-adv.ts
431
459
  var edge_adv_exports = {};
@@ -547,9 +575,6 @@ var ZoneTimeSortEnum = {
547
575
  NZ: "neutral"
548
576
  };
549
577
 
550
- // src/constants/edge-stats.ts
551
- var edge_stats_exports = {};
552
-
553
578
  // src/constants/nhl.ts
554
579
  var nhl_exports = {};
555
580
  __export(nhl_exports, {
@@ -574,6 +599,50 @@ __export(nhl_exports, {
574
599
  TeamsReverseEnum: () => TeamsReverseEnum,
575
600
  YEAR_RANGE: () => YEAR_RANGE
576
601
  });
602
+
603
+ // src/utils/date.ts
604
+ var NHL_TIMEZONE = "America/New_York";
605
+ var getNHLDate = (date) => new Intl.DateTimeFormat("en-CA", {
606
+ timeZone: NHL_TIMEZONE,
607
+ year: "numeric",
608
+ month: "2-digit",
609
+ day: "2-digit"
610
+ }).format(date);
611
+ var getCurrentNHLDate = () => getNHLDate(/* @__PURE__ */ new Date());
612
+ var getNHLMonth = (date) => {
613
+ return new Intl.DateTimeFormat("en-CA", {
614
+ timeZone: NHL_TIMEZONE,
615
+ year: "numeric",
616
+ month: "2-digit"
617
+ }).format(date);
618
+ };
619
+ var getYear = (date) => new Intl.DateTimeFormat("en-CA", {
620
+ timeZone: NHL_TIMEZONE,
621
+ year: "numeric"
622
+ }).format(date);
623
+ var getCurrentNHLYear = () => getYear(/* @__PURE__ */ new Date());
624
+ var getSeason = (date) => {
625
+ const format = new Intl.DateTimeFormat("en-CA", {
626
+ timeZone: NHL_TIMEZONE,
627
+ year: "numeric",
628
+ month: "numeric"
629
+ }).formatToParts(date instanceof Date ? date : new Date(date));
630
+ const month = format.find((part) => part.type === "month")?.value;
631
+ const year = format.find((part) => part.type === "year")?.value;
632
+ if (!year) {
633
+ throw new Error("Invalid date provided, could not extract year");
634
+ }
635
+ if (month && parseInt(month, 10) < 7) {
636
+ return `${parseInt(year, 10) - 1}${year}`;
637
+ }
638
+ return `${year}${parseInt(year, 10) + 1}`;
639
+ };
640
+ var getCurrentSeason = () => getSeason(/* @__PURE__ */ new Date());
641
+ /* @__PURE__ */ new Date(
642
+ `${getCurrentSeason().slice(4, 8)}-06-30`
643
+ );
644
+
645
+ // src/constants/nhl.ts
577
646
  var TeamsEnum = {
578
647
  /** Anaheim Ducks */
579
648
  ANA: 24,
@@ -908,54 +977,26 @@ var YEAR_RANGE = {
908
977
  var START_YEAR = YEAR_RANGE.START;
909
978
  var END_YEAR = YEAR_RANGE.END;
910
979
  var CURRENT = {
911
- SEASON: SEASON_RANGE.END,
980
+ /** The season for today's date, so the default never goes stale. */
981
+ SEASON: Number(getCurrentSeason()),
912
982
  YEAR: YEAR_RANGE.END
913
983
  };
914
984
  var PLAYER_ID_RANGE = { MIN: 8444e3, MAX: 8489999 };
915
985
  var TEAM_ID_RANGE = { MIN: 1, MAX: 59 };
916
986
 
917
987
  // src/constants/index.ts
918
- var EDGE = { ...edge_adv_exports, ...edge_stats_exports };
919
-
920
- // src/utils/date.ts
921
- var NHL_TIMEZONE = "America/New_York";
922
- var getDate = (date) => new Intl.DateTimeFormat("en-CA", {
923
- timeZone: NHL_TIMEZONE,
924
- year: "numeric",
925
- month: "2-digit",
926
- day: "2-digit"
927
- }).format(date);
928
- var getCurrentDate = () => getDate(/* @__PURE__ */ new Date());
929
- var getYear = (date) => new Intl.DateTimeFormat("en-CA", {
930
- timeZone: NHL_TIMEZONE,
931
- year: "numeric"
932
- }).format(date);
933
- var getCurrentYear = () => getYear(/* @__PURE__ */ new Date());
934
- var getSeason = (date) => {
935
- const format = new Intl.DateTimeFormat("en-CA", {
936
- timeZone: NHL_TIMEZONE,
937
- year: "numeric",
938
- month: "numeric"
939
- }).formatToParts(date instanceof Date ? date : new Date(date));
940
- const month = format.find((part) => part.type === "month")?.value;
941
- const year = format.find((part) => part.type === "year")?.value;
942
- if (!year) {
943
- throw new Error("Invalid date provided, could not extract year");
944
- }
945
- if (month && parseInt(month, 10) < 7) {
946
- return `${parseInt(year, 10) - 1}${year}`;
947
- }
948
- return `${year}${parseInt(year, 10) + 1}`;
949
- };
950
- var getCurrentSeason = () => getSeason(/* @__PURE__ */ new Date());
951
- /* @__PURE__ */ new Date(
952
- `${getCurrentSeason().slice(4, 8)}-06-30`
953
- );
988
+ var EDGE = { ...edge_adv_exports };
954
989
 
955
990
  // src/utils/schemas.ts
956
991
  function isParseError(value) {
957
992
  return value instanceof type.errors;
958
993
  }
994
+ function invalidParams(errors, endpoint) {
995
+ return {
996
+ success: false,
997
+ error: new ValidationError(errors.summary, { endpoint })
998
+ };
999
+ }
959
1000
  var Year = type(`${nhl_exports.START_YEAR} <= number <= ${nhl_exports.END_YEAR}`).or(
960
1001
  type("string.numeric.parse").narrow((v) => {
961
1002
  return v >= nhl_exports.START_YEAR && v <= nhl_exports.END_YEAR;
@@ -968,11 +1009,11 @@ var NHLMonth = type("Date | string").narrow((v) => {
968
1009
  return true;
969
1010
  }
970
1011
  return false;
971
- }).pipe((v) => typeof v === "string" ? v : v.toISOString().slice(0, 7)).describe(
1012
+ }).pipe((v) => typeof v === "string" ? v : getNHLMonth(v)).describe(
972
1013
  "a valid month, either as a string (formatted as YYYY-MM) or a Date object"
973
1014
  );
974
1015
  var NHLDate = type("Date | string.date.iso").pipe(
975
- (v) => typeof v === "string" ? new Date(v).toISOString().slice(0, 10) : v.toISOString().slice(0, 10)
1016
+ (v) => typeof v === "string" ? new Date(v).toISOString().slice(0, 10) : getNHLDate(v)
976
1017
  ).describe(
977
1018
  "a valid date, either as a string (ISO date string) or a Date object"
978
1019
  );
@@ -1022,8 +1063,10 @@ var GameId = type("number.integer | string.numeric.parse").narrow((v) => {
1022
1063
  var SeriesLetter = type.enumerated(...Object.values(nhl_exports.SeriesLetterEnum)).describe("a valid NHL playoff series letter (A-O)");
1023
1064
  type.enumerated(...Object.values(nhl_exports.GameStateEnum)).describe("a valid NHL game state");
1024
1065
  var CountryCode = type(/^[a-zA-Z]{2}$/).pipe((v) => v.toLowerCase()).describe("a valid ISO 3166-1 alpha-2 country code, e.g. US, CA, RU");
1025
- var PostalCode = type(/^[a-zA-Z]\d[a-zA-Z][ -]?\d[a-zA-Z]\d$/).or(type(/^\d{5}$/)).describe(
1026
- "a valid postal code, either US ZIP code (5 digit) or Canadian postal code (A1A 1A1 format; space required)"
1066
+ var PostalCode = type(/^[a-zA-Z]\d[a-zA-Z][ -]?\d[a-zA-Z]\d$/).or(type(/^\d{5}$/)).pipe(
1067
+ (v) => v.length === 5 ? v : `${v.slice(0, 3)} ${v.slice(-3)}`.toUpperCase()
1068
+ ).describe(
1069
+ "a valid postal code, either US ZIP code (5 digit) or Canadian postal code (A1A 1A1, A1A1A1 or A1A-1A1)"
1027
1070
  );
1028
1071
  var PlayerId = type("number").atLeast(nhl_exports.PLAYER_ID_RANGE.MIN).atMost(nhl_exports.PLAYER_ID_RANGE.MAX).or(
1029
1072
  type("string.numeric.parse").narrow((v) => {
@@ -1079,7 +1122,7 @@ var SkatingDistanceSort = type.enumerated(
1079
1122
  ...Object.keys(
1080
1123
  EDGE.SkatingDistanceSortEnum
1081
1124
  )
1082
- );
1125
+ ).pipe((v) => EDGE.SkatingDistanceSortEnum[v]);
1083
1126
  var ShotLocationCategory = type.enumerated(
1084
1127
  ...Object.keys(
1085
1128
  EDGE.ShotLocationCategoryEnum
@@ -1090,6 +1133,11 @@ var ZoneTimeSort = type.enumerated(
1090
1133
  EDGE.ZoneTimeSortEnum
1091
1134
  )
1092
1135
  ).pipe((v) => EDGE.ZoneTimeSortEnum[v]);
1136
+ function withDefault(schema, fallback) {
1137
+ const resolved = schema.assert(fallback);
1138
+ const optional = schema.or("undefined").pipe((v) => v ?? resolved);
1139
+ return [optional, "=", fallback];
1140
+ }
1093
1141
  var BaseParams = type({
1094
1142
  season: Season.or("undefined").pipe((v) => v ?? nhl_exports.CURRENT.SEASON),
1095
1143
  gameType: GameType.or("undefined").pipe(
@@ -1104,8 +1152,8 @@ var TeamParams = BaseParams.merge({
1104
1152
  teamId: TeamId
1105
1153
  });
1106
1154
  var top10Params = BaseParams.merge({
1107
- position: PositionFilter.default("ALL"),
1108
- strength: SkatersStrength.default("ALL")
1155
+ position: withDefault(PositionFilter, "ALL"),
1156
+ strength: withDefault(SkatersStrength, "ALL")
1109
1157
  });
1110
1158
  var DraftParams = type({
1111
1159
  year: Year.or("undefined").pipe((v) => v ?? nhl_exports.CURRENT.YEAR),
@@ -1129,9 +1177,9 @@ var SeriesParams = type({
1129
1177
  });
1130
1178
  var ScheduleParams = type({
1131
1179
  team: TeamAbbrev,
1132
- date: NHLDate.or("undefined").pipe((v) => v ?? getCurrentDate()),
1180
+ date: NHLDate.or("undefined").pipe((v) => v ?? getCurrentNHLDate()),
1133
1181
  month: NHLMonth.or("undefined").pipe(
1134
- (v) => v ?? getCurrentDate().slice(0, 7)
1182
+ (v) => v ?? getCurrentNHLDate().slice(0, 7)
1135
1183
  )
1136
1184
  });
1137
1185
 
@@ -1162,71 +1210,71 @@ var goaliesPaths = {
1162
1210
  /** Goalie top 10 leaders. */
1163
1211
  top10: {
1164
1212
  /** Top 10 goalies by save percentage. */
1165
- SavePercentage: "edge/goalie-5v5-top-10/{sortBy}/{season}/{gameType}",
1213
+ savePercentage: "edge/goalie-edge-save-pctg-top-10/{sortBy}/{season}/{gameType}",
1166
1214
  /** Top 10 goalies by 5v5 save percentage. */
1167
- SavePercentage5v5: "edge/goalie-edge-save-pctg-top-10/{sortBy}/{season}/{gameType}",
1215
+ savePercentage5v5: "edge/goalie-5v5-top-10/{sortBy}/{season}/{gameType}",
1168
1216
  /** Top 10 goalies by shot location. */
1169
- SaveLocation: "edge/goalie-shot-location-top-10/{category}/{sortBy}/{season}/{gameType}"
1217
+ saveLocation: "edge/goalie-shot-location-top-10/{category}/{sortBy}/{season}/{gameType}"
1170
1218
  }
1171
1219
  };
1172
1220
  var skatersPaths = {
1173
1221
  /** Skater detail page. */
1174
- player: "skater-detail/{playerId}/{season}/{gameType}",
1222
+ player: "edge/skater-detail/{playerId}/{season}/{gameType}",
1175
1223
  /** Skater comparison data. */
1176
- compare: "skater-comparison/{playerId}/{season}/{gameType}",
1224
+ compare: "edge/skater-comparison/{playerId}/{season}/{gameType}",
1177
1225
  /** Skater leaders landing page. */
1178
- leaders: "skater-landing/{season}/{gameType}",
1226
+ leaders: "edge/skater-landing/{season}/{gameType}",
1179
1227
  /** Skater shot location analysis. */
1180
- shotLocation: "skater-shot-location-detail/{playerId}/{season}/{gameType}",
1228
+ shotLocation: "edge/skater-shot-location-detail/{playerId}/{season}/{gameType}",
1181
1229
  /** Skater shot speed analysis. */
1182
- shotSpeed: "skater-shot-speed-detail/{playerId}/{season}/{gameType}",
1230
+ shotSpeed: "edge/skater-shot-speed-detail/{playerId}/{season}/{gameType}",
1183
1231
  /** Skater skating distance analysis. */
1184
- skatingDistance: "skater-skating-distance-detail/{playerId}/{season}/{gameType}",
1232
+ skatingDistance: "edge/skater-skating-distance-detail/{playerId}/{season}/{gameType}",
1185
1233
  /** Skater skating speed analysis. */
1186
- skatingSpeed: "skater-skating-speed-detail/{playerId}/{season}/{gameType}",
1234
+ skatingSpeed: "edge/skater-skating-speed-detail/{playerId}/{season}/{gameType}",
1187
1235
  /** Skater zone time analysis. */
1188
- zoneTime: "skater-zone-time/{playerId}/{season}/{gameType}",
1236
+ zoneTime: "edge/skater-zone-time/{playerId}/{season}/{gameType}",
1189
1237
  /** Skater top 10 leaders. */
1190
1238
  top10: {
1191
1239
  /** Top 10 skaters by shot location. */
1192
- shotLocation: "skater-shot-location-top-10/{position}/{category}/{sortBy}/{season}/{gameType}",
1240
+ shotLocation: "edge/skater-shot-location-top-10/{position}/{category}/{sortBy}/{season}/{gameType}",
1193
1241
  /** Top 10 skaters by shot speed. */
1194
- shotSpeed: "skater-shot-speed-top-10/{position}/{sortBy}/{season}/{gameType}",
1242
+ shotSpeed: "edge/skater-shot-speed-top-10/{position}/{sortBy}/{season}/{gameType}",
1195
1243
  /** Top 10 skaters by skating distance. */
1196
- skatingDistance: "skater-distance-top-10/{position}/{strength}/{sortBy}/{season}/{gameType}",
1244
+ skatingDistance: "edge/skater-distance-top-10/{position}/{strength}/{sortBy}/{season}/{gameType}",
1197
1245
  /** Top 10 skaters by skating speed. */
1198
- skatingSpeed: "skater-speed-top-10/{position}/{sortBy}/{season}/{gameType}",
1246
+ skatingSpeed: "edge/skater-speed-top-10/{position}/{sortBy}/{season}/{gameType}",
1199
1247
  /** Top 10 skaters by zone time. */
1200
- zoneTime: "skater-zone-time-top-10/{position}/{strength}/{sortBy}/{season}/{gameType}"
1248
+ zoneTime: "edge/skater-zone-time-top-10/{position}/{strength}/{sortBy}/{season}/{gameType}"
1201
1249
  }
1202
1250
  };
1203
1251
  var teamsPaths = {
1204
1252
  /** Team statistics detail page. */
1205
- stats: "edge/team-comparison/{teamId}/{season}/{gameType}",
1253
+ stats: "edge/team-detail/{teamId}/{season}/{gameType}",
1206
1254
  /** Team comparison data. */
1207
- compare: "edge/team-detail/{teamId}/{season}/{gameType}",
1255
+ compare: "edge/team-comparison/{teamId}/{season}/{gameType}",
1208
1256
  /** Team leaders landing page. */
1209
1257
  leaders: "edge/team-landing/{season}/{gameType}",
1210
1258
  /** Team shot location analysis. */
1211
1259
  shotLocation: "edge/team-shot-location-detail/{teamId}/{season}/{gameType}",
1212
1260
  /** Team shot speed analysis. */
1213
- shotSpeed: "edge/team-shot-location-top-10/{position}/{category}/{sortBy}/{season}/{gameType}",
1261
+ shotSpeed: "edge/team-shot-speed-detail/{teamId}/{season}/{gameType}",
1214
1262
  /** Team skating distance analysis. */
1215
- skatingDistance: "edge/team-shot-speed-detail/{teamId}/{season}/{gameType}",
1263
+ skatingDistance: "edge/team-skating-distance-detail/{teamId}/{season}/{gameType}",
1216
1264
  /** Team skating speed analysis. */
1217
- skatingSpeed: "edge/team-shot-speed-top-10/{position}/{sortBy}/{season}/{gameType}",
1265
+ skatingSpeed: "edge/team-skating-speed-detail/{teamId}/{season}/{gameType}",
1218
1266
  /** Team zone time analysis. */
1219
- zoneTime: "edge/team-skating-distance-detail/{teamId}/{season}/{gameType}",
1267
+ zoneTime: "edge/team-zone-time-details/{teamId}/{season}/{gameType}",
1220
1268
  /** Team top 10 leaders. */
1221
1269
  top10: {
1222
1270
  /** Top 10 teams by shot location. */
1223
- shotLocation: "edge/team-skating-distance-top-10/{position}/{strength}/{sortBy}/{season}/{gameType}",
1271
+ shotLocation: "edge/team-shot-location-top-10/{position}/{category}/{sortBy}/{season}/{gameType}",
1224
1272
  /** Top 10 teams by shot speed. */
1225
- shotSpeed: "edge/team-skating-speed-detail/{teamId}/{season}/{gameType}",
1273
+ shotSpeed: "edge/team-shot-speed-top-10/{position}/{sortBy}/{season}/{gameType}",
1226
1274
  /** Top 10 teams by skating distance. */
1227
- skatingDistance: "edge/team-skating-speed-top-10/{position}/{sortBy}/{season}/{gameType}",
1275
+ skatingDistance: "edge/team-skating-distance-top-10/{position}/{strength}/{sortBy}/{season}/{gameType}",
1228
1276
  /** Top 10 teams by skating speed. */
1229
- skatingSpeed: "edge/team-zone-time-details/{teamId}/{season}/{gameType}",
1277
+ skatingSpeed: "edge/team-skating-speed-top-10/{position}/{sortBy}/{season}/{gameType}",
1230
1278
  /** Top 10 teams by zone time. */
1231
1279
  zoneTime: "edge/team-zone-time-top-10/{strength}/{sortBy}/{season}/{gameType}"
1232
1280
  }
@@ -1239,67 +1287,38 @@ var summaryPaths = {
1239
1287
  // src/api/edge-adv/goalies.ts
1240
1288
  async function player(playerId, season, gameType) {
1241
1289
  const parsed = PlayerParams({ playerId, season, gameType });
1242
- if (isParseError(parsed))
1243
- return Promise.reject(
1244
- new NHLError(parsed.summary, "VALIDATION", {
1245
- endpoint: goaliesPaths.player
1246
- })
1247
- );
1290
+ if (isParseError(parsed)) return invalidParams(parsed, goaliesPaths.player);
1248
1291
  const path = resolvePath(goaliesPaths.player, parsed);
1249
1292
  return nhlClient.get(path);
1250
1293
  }
1251
1294
  async function compare(playerId, season, gameType) {
1252
1295
  const parsed = PlayerParams({ playerId, season, gameType });
1253
- if (isParseError(parsed))
1254
- return Promise.reject(
1255
- new NHLError(parsed.summary, "VALIDATION", {
1256
- endpoint: goaliesPaths.compare
1257
- })
1258
- );
1296
+ if (isParseError(parsed)) return invalidParams(parsed, goaliesPaths.compare);
1259
1297
  const path = resolvePath(goaliesPaths.compare, parsed);
1260
1298
  return nhlClient.get(path);
1261
1299
  }
1262
1300
  async function leaders(season, gameType) {
1263
1301
  const parsed = BaseParams({ season, gameType });
1264
- if (isParseError(parsed))
1265
- return Promise.reject(
1266
- new NHLError(parsed.summary, "VALIDATION", {
1267
- endpoint: goaliesPaths.leaders
1268
- })
1269
- );
1302
+ if (isParseError(parsed)) return invalidParams(parsed, goaliesPaths.leaders);
1270
1303
  const path = resolvePath(goaliesPaths.leaders, parsed);
1271
1304
  return nhlClient.get(path);
1272
1305
  }
1273
1306
  async function savePercentage5v5(playerId, season, gameType) {
1274
1307
  const parsed = PlayerParams({ playerId, season, gameType });
1275
1308
  if (isParseError(parsed))
1276
- return Promise.reject(
1277
- new NHLError(parsed.summary, "VALIDATION", {
1278
- endpoint: goaliesPaths.savePercentage5v5
1279
- })
1280
- );
1309
+ return invalidParams(parsed, goaliesPaths.savePercentage5v5);
1281
1310
  const path = resolvePath(goaliesPaths.savePercentage5v5, parsed);
1282
1311
  return nhlClient.get(path);
1283
1312
  }
1284
1313
  async function savePercentage(playerId, season, gameType) {
1285
1314
  const parsed = PlayerParams({ playerId, season, gameType });
1286
- if (isParseError(parsed))
1287
- return Promise.reject(
1288
- new NHLError(parsed.summary, "VALIDATION", {
1289
- endpoint: goaliesPaths.savePercentage
1290
- })
1291
- );
1315
+ if (isParseError(parsed)) return invalidParams(parsed, goaliesPaths.savePercentage);
1292
1316
  const path = resolvePath(goaliesPaths.savePercentage, parsed);
1293
1317
  return nhlClient.get(path);
1294
1318
  }
1295
1319
  async function saveLocation(playerId, season, gameType) {
1296
1320
  const parsed = PlayerParams({ playerId, season, gameType });
1297
- if (isParseError(parsed))
1298
- return Promise.reject(
1299
- new NHLError(parsed.summary, "VALIDATION", {
1300
- endpoint: goaliesPaths.saveLocation
1301
- })
1302
- );
1321
+ if (isParseError(parsed)) return invalidParams(parsed, goaliesPaths.saveLocation);
1303
1322
  const path = resolvePath(goaliesPaths.saveLocation, parsed);
1304
1323
  return nhlClient.get(path);
1305
1324
  }
@@ -1310,36 +1329,28 @@ var top10 = {
1310
1329
  };
1311
1330
  async function top10SavePercentage(season, gameType, sortBy) {
1312
1331
  const Parser = BaseParams.merge({
1313
- sortBy: SavePercentageSort.default("GAMES")
1332
+ sortBy: withDefault(SavePercentageSort, "GAMES")
1314
1333
  });
1315
1334
  const parsed = Parser({ season, gameType, sortBy });
1316
1335
  if (isParseError(parsed))
1317
- return Promise.reject(
1318
- new NHLError(parsed.summary, "VALIDATION", {
1319
- endpoint: goaliesPaths.top10.SavePercentage
1320
- })
1321
- );
1322
- const path = resolvePath(goaliesPaths.top10.SavePercentage, parsed);
1336
+ return invalidParams(parsed, goaliesPaths.top10.savePercentage);
1337
+ const path = resolvePath(goaliesPaths.top10.savePercentage, parsed);
1323
1338
  return nhlClient.get(path);
1324
1339
  }
1325
1340
  async function top10SavePercentage5v5(season, gameType, sortBy) {
1326
1341
  const Parser = BaseParams.merge({
1327
- sortBy: SavePercentage5v5Sort.default("5v5-SV%")
1342
+ sortBy: withDefault(SavePercentage5v5Sort, "5v5-SV%")
1328
1343
  });
1329
1344
  const parsed = Parser({ season, gameType, sortBy });
1330
1345
  if (isParseError(parsed))
1331
- return Promise.reject(
1332
- new NHLError(parsed.summary, "VALIDATION", {
1333
- endpoint: goaliesPaths.top10.SavePercentage5v5
1334
- })
1335
- );
1336
- const path = resolvePath(goaliesPaths.top10.SavePercentage5v5, parsed);
1346
+ return invalidParams(parsed, goaliesPaths.top10.savePercentage5v5);
1347
+ const path = resolvePath(goaliesPaths.top10.savePercentage5v5, parsed);
1337
1348
  return nhlClient.get(path);
1338
1349
  }
1339
1350
  async function top10SaveLocation(season, gameType, category, sortBy) {
1340
1351
  const Parser = BaseParams.merge({
1341
- category: SaveLocationCategory.default("SV%"),
1342
- sortBy: SaveLocationSort.default("ALL")
1352
+ category: withDefault(SaveLocationCategory, "SV%"),
1353
+ sortBy: withDefault(SaveLocationSort, "ALL")
1343
1354
  });
1344
1355
  const parsed = Parser({
1345
1356
  season,
@@ -1348,12 +1359,8 @@ async function top10SaveLocation(season, gameType, category, sortBy) {
1348
1359
  sortBy
1349
1360
  });
1350
1361
  if (isParseError(parsed))
1351
- return Promise.reject(
1352
- new NHLError(parsed.summary, "VALIDATION", {
1353
- endpoint: goaliesPaths.top10.SaveLocation
1354
- })
1355
- );
1356
- const path = resolvePath(goaliesPaths.top10.SaveLocation, parsed);
1362
+ return invalidParams(parsed, goaliesPaths.top10.saveLocation);
1363
+ const path = resolvePath(goaliesPaths.top10.saveLocation, parsed);
1357
1364
  return nhlClient.get(path);
1358
1365
  }
1359
1366
 
@@ -1372,89 +1379,50 @@ __export(skaters_exports, {
1372
1379
  });
1373
1380
  async function detail(playerId, season, gameType) {
1374
1381
  const parsed = PlayerParams({ playerId, season, gameType });
1375
- if (isParseError(parsed))
1376
- return Promise.reject(
1377
- new NHLError(parsed.summary, "VALIDATION", {
1378
- endpoint: skatersPaths.player
1379
- })
1380
- );
1382
+ if (isParseError(parsed)) return invalidParams(parsed, skatersPaths.player);
1381
1383
  const path = resolvePath(skatersPaths.player, parsed);
1382
1384
  return nhlClient.get(path);
1383
1385
  }
1384
1386
  async function shotLocation(playerId, season, gameType) {
1385
1387
  const parsed = PlayerParams({ playerId, season, gameType });
1386
- if (isParseError(parsed))
1387
- return Promise.reject(
1388
- new NHLError(parsed.summary, "VALIDATION", {
1389
- endpoint: skatersPaths.shotLocation
1390
- })
1391
- );
1388
+ if (isParseError(parsed)) return invalidParams(parsed, skatersPaths.shotLocation);
1392
1389
  const path = resolvePath(skatersPaths.shotLocation, parsed);
1393
1390
  return nhlClient.get(path);
1394
1391
  }
1395
1392
  async function shotSpeed(playerId, season, gameType) {
1396
1393
  const parsed = PlayerParams({ playerId, season, gameType });
1397
- if (isParseError(parsed))
1398
- return Promise.reject(
1399
- new NHLError(parsed.summary, "VALIDATION", {
1400
- endpoint: skatersPaths.shotSpeed
1401
- })
1402
- );
1394
+ if (isParseError(parsed)) return invalidParams(parsed, skatersPaths.shotSpeed);
1403
1395
  const path = resolvePath(skatersPaths.shotSpeed, parsed);
1404
1396
  return nhlClient.get(path);
1405
1397
  }
1406
1398
  async function skatingDistance(playerId, season, gameType) {
1407
1399
  const parsed = PlayerParams({ playerId, season, gameType });
1408
1400
  if (isParseError(parsed))
1409
- return Promise.reject(
1410
- new NHLError(parsed.summary, "VALIDATION", {
1411
- endpoint: skatersPaths.skatingDistance
1412
- })
1413
- );
1401
+ return invalidParams(parsed, skatersPaths.skatingDistance);
1414
1402
  const path = resolvePath(skatersPaths.skatingDistance, parsed);
1415
1403
  return nhlClient.get(path);
1416
1404
  }
1417
1405
  async function skatingSpeed(playerId, season, gameType) {
1418
1406
  const parsed = PlayerParams({ playerId, season, gameType });
1419
- if (isParseError(parsed))
1420
- return Promise.reject(
1421
- new NHLError(parsed.summary, "VALIDATION", {
1422
- endpoint: skatersPaths.skatingSpeed
1423
- })
1424
- );
1407
+ if (isParseError(parsed)) return invalidParams(parsed, skatersPaths.skatingSpeed);
1425
1408
  const path = resolvePath(skatersPaths.skatingSpeed, parsed);
1426
1409
  return nhlClient.get(path);
1427
1410
  }
1428
1411
  async function zoneTime(playerId, season, gameType) {
1429
1412
  const parsed = PlayerParams({ playerId, season, gameType });
1430
- if (isParseError(parsed))
1431
- return Promise.reject(
1432
- new NHLError(parsed.summary, "VALIDATION", {
1433
- endpoint: skatersPaths.zoneTime
1434
- })
1435
- );
1413
+ if (isParseError(parsed)) return invalidParams(parsed, skatersPaths.zoneTime);
1436
1414
  const path = resolvePath(skatersPaths.zoneTime, parsed);
1437
1415
  return nhlClient.get(path);
1438
1416
  }
1439
1417
  async function comparison(playerId, season, gameType) {
1440
1418
  const parsed = PlayerParams({ playerId, season, gameType });
1441
- if (isParseError(parsed))
1442
- return Promise.reject(
1443
- new NHLError(parsed.summary, "VALIDATION", {
1444
- endpoint: skatersPaths.compare
1445
- })
1446
- );
1419
+ if (isParseError(parsed)) return invalidParams(parsed, skatersPaths.compare);
1447
1420
  const path = resolvePath(skatersPaths.compare, parsed);
1448
1421
  return nhlClient.get(path);
1449
1422
  }
1450
1423
  async function leaders2(season, gameType) {
1451
1424
  const parsed = BaseParams({ season, gameType });
1452
- if (isParseError(parsed))
1453
- return Promise.reject(
1454
- new NHLError(parsed.summary, "VALIDATION", {
1455
- endpoint: skatersPaths.leaders
1456
- })
1457
- );
1425
+ if (isParseError(parsed)) return invalidParams(parsed, skatersPaths.leaders);
1458
1426
  const path = resolvePath(skatersPaths.leaders, parsed);
1459
1427
  return nhlClient.get(path);
1460
1428
  }
@@ -1467,7 +1435,7 @@ var top102 = {
1467
1435
  };
1468
1436
  async function top10Distance(season, gameType, position, strength, sortBy) {
1469
1437
  const parsed = top10Params.merge({
1470
- sortBy: SkatingDistanceSort.default("TOTAL")
1438
+ sortBy: withDefault(SkatingDistanceSort, "TOTAL")
1471
1439
  })({
1472
1440
  season,
1473
1441
  gameType,
@@ -1476,18 +1444,14 @@ async function top10Distance(season, gameType, position, strength, sortBy) {
1476
1444
  sortBy
1477
1445
  });
1478
1446
  if (isParseError(parsed))
1479
- return Promise.reject(
1480
- new NHLError(parsed.summary, "VALIDATION", {
1481
- endpoint: skatersPaths.top10.skatingDistance
1482
- })
1483
- );
1447
+ return invalidParams(parsed, skatersPaths.top10.skatingDistance);
1484
1448
  const path = resolvePath(skatersPaths.top10.skatingDistance, parsed);
1485
1449
  return nhlClient.get(path);
1486
1450
  }
1487
1451
  async function top10ShotLocation(season, gameType, position, category, sortBy) {
1488
1452
  const parsed = top10Params.merge({
1489
- category: ShotLocationCategory.default("G"),
1490
- sortBy: ShotLocationSort.default("ALL")
1453
+ category: withDefault(ShotLocationCategory, "G"),
1454
+ sortBy: withDefault(ShotLocationSort, "ALL")
1491
1455
  })({
1492
1456
  season,
1493
1457
  gameType,
@@ -1496,17 +1460,13 @@ async function top10ShotLocation(season, gameType, position, category, sortBy) {
1496
1460
  sortBy
1497
1461
  });
1498
1462
  if (isParseError(parsed))
1499
- return Promise.reject(
1500
- new NHLError(parsed.summary, "VALIDATION", {
1501
- endpoint: skatersPaths.top10.shotLocation
1502
- })
1503
- );
1463
+ return invalidParams(parsed, skatersPaths.top10.shotLocation);
1504
1464
  const path = resolvePath(skatersPaths.top10.shotLocation, parsed);
1505
1465
  return nhlClient.get(path);
1506
1466
  }
1507
1467
  async function top10ShotSpeed(season, gameType, position, sortBy) {
1508
1468
  const parsed = top10Params.merge({
1509
- sortBy: ShotSpeedSort.default("MAX")
1469
+ sortBy: withDefault(ShotSpeedSort, "MAX")
1510
1470
  })({
1511
1471
  season,
1512
1472
  gameType,
@@ -1514,17 +1474,13 @@ async function top10ShotSpeed(season, gameType, position, sortBy) {
1514
1474
  sortBy
1515
1475
  });
1516
1476
  if (isParseError(parsed))
1517
- return Promise.reject(
1518
- new NHLError(parsed.summary, "VALIDATION", {
1519
- endpoint: skatersPaths.top10.shotSpeed
1520
- })
1521
- );
1477
+ return invalidParams(parsed, skatersPaths.top10.shotSpeed);
1522
1478
  const path = resolvePath(skatersPaths.top10.shotSpeed, parsed);
1523
1479
  return nhlClient.get(path);
1524
1480
  }
1525
1481
  async function top10Speed(season, gameType, position, sortBy) {
1526
1482
  const parsed = top10Params.merge({
1527
- sortBy: SkatingSpeedSort.default("TOP")
1483
+ sortBy: withDefault(SkatingSpeedSort, "TOP")
1528
1484
  })({
1529
1485
  season,
1530
1486
  gameType,
@@ -1532,17 +1488,13 @@ async function top10Speed(season, gameType, position, sortBy) {
1532
1488
  sortBy
1533
1489
  });
1534
1490
  if (isParseError(parsed))
1535
- return Promise.reject(
1536
- new NHLError(parsed.summary, "VALIDATION", {
1537
- endpoint: skatersPaths.top10.skatingSpeed
1538
- })
1539
- );
1491
+ return invalidParams(parsed, skatersPaths.top10.skatingSpeed);
1540
1492
  const path = resolvePath(skatersPaths.top10.skatingSpeed, parsed);
1541
1493
  return nhlClient.get(path);
1542
1494
  }
1543
1495
  async function top10ZoneTime(season, gameType, position, strength, sortBy) {
1544
1496
  const parsed = top10Params.merge({
1545
- sortBy: ZoneTimeSort.default("OZ")
1497
+ sortBy: withDefault(ZoneTimeSort, "OZ")
1546
1498
  })({
1547
1499
  season,
1548
1500
  gameType,
@@ -1550,12 +1502,7 @@ async function top10ZoneTime(season, gameType, position, strength, sortBy) {
1550
1502
  strength,
1551
1503
  sortBy
1552
1504
  });
1553
- if (isParseError(parsed))
1554
- return Promise.reject(
1555
- new NHLError(parsed.summary, "VALIDATION", {
1556
- endpoint: skatersPaths.top10.zoneTime
1557
- })
1558
- );
1505
+ if (isParseError(parsed)) return invalidParams(parsed, skatersPaths.top10.zoneTime);
1559
1506
  const path = resolvePath(skatersPaths.top10.zoneTime, parsed);
1560
1507
  return nhlClient.get(path);
1561
1508
  }
@@ -1580,90 +1527,51 @@ __export(teams_exports, {
1580
1527
  });
1581
1528
  async function stats(teamId, season, gameType) {
1582
1529
  const parsed = TeamParams({ teamId, season, gameType });
1583
- if (isParseError(parsed))
1584
- return Promise.reject(
1585
- new NHLError(parsed.summary, "VALIDATION", {
1586
- endpoint: teamsPaths.stats
1587
- })
1588
- );
1530
+ if (isParseError(parsed)) return invalidParams(parsed, teamsPaths.stats);
1589
1531
  const path = resolvePath(teamsPaths.stats, parsed);
1590
1532
  return nhlClient.get(path);
1591
1533
  }
1592
1534
  async function compare2(teamId, season, gameType) {
1593
1535
  gameType ??= "REG";
1594
1536
  const parsed = TeamParams({ teamId, season, gameType });
1595
- if (isParseError(parsed))
1596
- return Promise.reject(
1597
- new NHLError(parsed.summary, "VALIDATION", {
1598
- endpoint: teamsPaths.compare
1599
- })
1600
- );
1537
+ if (isParseError(parsed)) return invalidParams(parsed, teamsPaths.compare);
1601
1538
  const path = resolvePath(teamsPaths.compare, parsed);
1602
1539
  return nhlClient.get(path);
1603
1540
  }
1604
1541
  async function leaders3(season, gameType) {
1605
1542
  const parsed = BaseParams({ season, gameType });
1606
- if (isParseError(parsed))
1607
- return Promise.reject(
1608
- new NHLError(parsed.summary, "VALIDATION", {
1609
- endpoint: teamsPaths.leaders
1610
- })
1611
- );
1543
+ if (isParseError(parsed)) return invalidParams(parsed, teamsPaths.leaders);
1612
1544
  const path = resolvePath(teamsPaths.leaders, parsed);
1613
1545
  return nhlClient.get(path);
1614
1546
  }
1615
1547
  async function shotLocation2(teamId, season, gameType) {
1616
1548
  const parsed = TeamParams({ teamId, season, gameType });
1617
- if (isParseError(parsed))
1618
- return Promise.reject(
1619
- new NHLError(parsed.summary, "VALIDATION", {
1620
- endpoint: teamsPaths.shotLocation
1621
- })
1622
- );
1549
+ if (isParseError(parsed)) return invalidParams(parsed, teamsPaths.shotLocation);
1623
1550
  const path = resolvePath(teamsPaths.shotLocation, parsed);
1624
1551
  return nhlClient.get(path);
1625
1552
  }
1626
1553
  async function shotSpeed2(teamId, season, gameType) {
1627
1554
  const parsed = TeamParams({ teamId, season, gameType });
1628
- if (isParseError(parsed))
1629
- return Promise.reject(
1630
- new NHLError(parsed.summary, "VALIDATION", {
1631
- endpoint: teamsPaths.shotSpeed
1632
- })
1633
- );
1555
+ if (isParseError(parsed)) return invalidParams(parsed, teamsPaths.shotSpeed);
1634
1556
  const path = resolvePath(teamsPaths.shotSpeed, parsed);
1635
1557
  return nhlClient.get(path);
1636
1558
  }
1637
1559
  async function skatingDistance2(teamId, season, gameType) {
1638
1560
  const parsed = TeamParams({ teamId, season, gameType });
1639
1561
  if (isParseError(parsed))
1640
- return Promise.reject(
1641
- new NHLError(parsed.summary, "VALIDATION", {
1642
- endpoint: teamsPaths.skatingDistance
1643
- })
1644
- );
1562
+ return invalidParams(parsed, teamsPaths.skatingDistance);
1645
1563
  const path = resolvePath(teamsPaths.skatingDistance, parsed);
1646
1564
  return nhlClient.get(path);
1647
1565
  }
1648
1566
  async function skatingSpeed2(teamId, season, gameType) {
1649
1567
  const parsed = TeamParams({ teamId, season, gameType });
1650
- if (isParseError(parsed))
1651
- return Promise.reject(
1652
- new NHLError(parsed.summary, "VALIDATION", {
1653
- endpoint: teamsPaths.skatingSpeed
1654
- })
1655
- );
1568
+ if (isParseError(parsed)) return invalidParams(parsed, teamsPaths.skatingSpeed);
1656
1569
  const path = resolvePath(teamsPaths.skatingSpeed, parsed);
1657
1570
  return nhlClient.get(path);
1658
1571
  }
1659
1572
  async function zoneTime2(teamId, season, gameType) {
1660
1573
  const parsed = TeamParams({ teamId, season, gameType });
1661
- if (isParseError(parsed))
1662
- return Promise.reject(
1663
- new NHLError(parsed.summary, "VALIDATION", {
1664
- endpoint: teamsPaths.zoneTime
1665
- })
1666
- );
1574
+ if (isParseError(parsed)) return invalidParams(parsed, teamsPaths.zoneTime);
1667
1575
  const path = resolvePath(teamsPaths.zoneTime, parsed);
1668
1576
  return nhlClient.get(path);
1669
1577
  }
@@ -1676,9 +1584,9 @@ var top103 = {
1676
1584
  };
1677
1585
  async function top10ShotLocation2(season, gameType, position, category, sortBy) {
1678
1586
  const Parser = BaseParams.merge({
1679
- position: PositionFilter.default("ALL"),
1680
- category: ShotLocationCategory.default("G"),
1681
- sortBy: ShotLocationSort.default("ALL")
1587
+ position: withDefault(PositionFilter, "ALL"),
1588
+ category: withDefault(ShotLocationCategory, "G"),
1589
+ sortBy: withDefault(ShotLocationSort, "ALL")
1682
1590
  });
1683
1591
  const parsed = Parser({
1684
1592
  season,
@@ -1688,18 +1596,14 @@ async function top10ShotLocation2(season, gameType, position, category, sortBy)
1688
1596
  sortBy
1689
1597
  });
1690
1598
  if (isParseError(parsed))
1691
- return Promise.reject(
1692
- new NHLError(parsed.summary, "VALIDATION", {
1693
- endpoint: teamsPaths.shotLocation
1694
- })
1695
- );
1599
+ return invalidParams(parsed, teamsPaths.top10.shotLocation);
1696
1600
  const path = resolvePath(teamsPaths.top10.shotLocation, parsed);
1697
1601
  return nhlClient.get(path);
1698
1602
  }
1699
1603
  async function top10ShotSpeed2(season, gameType, position, sortBy) {
1700
1604
  const Parser = BaseParams.merge({
1701
- position: PositionFilter.default("ALL"),
1702
- sortBy: ShotSpeedSort.default("MAX")
1605
+ position: withDefault(PositionFilter, "ALL"),
1606
+ sortBy: withDefault(ShotSpeedSort, "MAX")
1703
1607
  });
1704
1608
  const parsed = Parser({
1705
1609
  season,
@@ -1708,19 +1612,15 @@ async function top10ShotSpeed2(season, gameType, position, sortBy) {
1708
1612
  sortBy
1709
1613
  });
1710
1614
  if (isParseError(parsed))
1711
- return Promise.reject(
1712
- new NHLError(parsed.summary, "VALIDATION", {
1713
- endpoint: teamsPaths.shotSpeed
1714
- })
1715
- );
1615
+ return invalidParams(parsed, teamsPaths.top10.shotSpeed);
1716
1616
  const path = resolvePath(teamsPaths.top10.shotSpeed, parsed);
1717
1617
  return nhlClient.get(path);
1718
1618
  }
1719
1619
  async function top10SkatingDistance(season, gameType, position, strength, sortBy) {
1720
1620
  const Parser = BaseParams.merge({
1721
- position: PositionFilter.default("ALL"),
1722
- strength: SkatersStrength.default("ALL"),
1723
- sortBy: SkatingDistanceSort.default("TOTAL")
1621
+ position: withDefault(PositionFilter, "ALL"),
1622
+ strength: withDefault(SkatersStrength, "ALL"),
1623
+ sortBy: withDefault(SkatingDistanceSort, "TOTAL")
1724
1624
  });
1725
1625
  const parsed = Parser({
1726
1626
  season,
@@ -1730,18 +1630,14 @@ async function top10SkatingDistance(season, gameType, position, strength, sortBy
1730
1630
  sortBy
1731
1631
  });
1732
1632
  if (isParseError(parsed))
1733
- return Promise.reject(
1734
- new NHLError(parsed.summary, "VALIDATION", {
1735
- endpoint: teamsPaths.skatingDistance
1736
- })
1737
- );
1633
+ return invalidParams(parsed, teamsPaths.top10.skatingDistance);
1738
1634
  const path = resolvePath(teamsPaths.top10.skatingDistance, parsed);
1739
1635
  return nhlClient.get(path);
1740
1636
  }
1741
1637
  async function top10SkatingSpeed(season, gameType, position, sortBy) {
1742
1638
  const Parser = BaseParams.merge({
1743
- position: PositionFilter.default("ALL"),
1744
- sortBy: SkatingSpeedSort.default("TOP")
1639
+ position: withDefault(PositionFilter, "ALL"),
1640
+ sortBy: withDefault(SkatingSpeedSort, "TOP")
1745
1641
  });
1746
1642
  const parsed = Parser({
1747
1643
  season,
@@ -1750,18 +1646,14 @@ async function top10SkatingSpeed(season, gameType, position, sortBy) {
1750
1646
  sortBy
1751
1647
  });
1752
1648
  if (isParseError(parsed))
1753
- return Promise.reject(
1754
- new NHLError(parsed.summary, "VALIDATION", {
1755
- endpoint: teamsPaths.skatingSpeed
1756
- })
1757
- );
1649
+ return invalidParams(parsed, teamsPaths.top10.skatingSpeed);
1758
1650
  const path = resolvePath(teamsPaths.top10.skatingSpeed, parsed);
1759
1651
  return nhlClient.get(path);
1760
1652
  }
1761
1653
  async function top10ZoneTime2(season, gameType, strength, sortBy) {
1762
1654
  const Parser = BaseParams.merge({
1763
- strength: SkatersStrength.default("ALL"),
1764
- sortBy: ZoneTimeSort.default("OZ")
1655
+ strength: withDefault(SkatersStrength, "ALL"),
1656
+ sortBy: withDefault(ZoneTimeSort, "OZ")
1765
1657
  });
1766
1658
  const parsed = Parser({
1767
1659
  season,
@@ -1769,22 +1661,569 @@ async function top10ZoneTime2(season, gameType, strength, sortBy) {
1769
1661
  strength,
1770
1662
  sortBy
1771
1663
  });
1772
- if (isParseError(parsed))
1773
- return Promise.reject(
1774
- new NHLError(parsed.summary, "VALIDATION", {
1775
- endpoint: teamsPaths.zoneTime
1776
- })
1777
- );
1664
+ if (isParseError(parsed)) return invalidParams(parsed, teamsPaths.top10.zoneTime);
1778
1665
  const path = resolvePath(teamsPaths.top10.zoneTime, parsed);
1779
1666
  return nhlClient.get(path);
1780
1667
  }
1781
1668
 
1669
+ // src/api/edge-stats/index.ts
1670
+ var edge_stats_exports = {};
1671
+ __export(edge_stats_exports, {
1672
+ goalies: () => goalies_exports2,
1673
+ misc: () => misc_exports,
1674
+ season: () => season_game_exports,
1675
+ skaters: () => skaters_exports2,
1676
+ teams: () => teams_exports2
1677
+ });
1678
+
1679
+ // src/api/edge-stats/goalies.ts
1680
+ var goalies_exports2 = {};
1681
+ __export(goalies_exports2, {
1682
+ getLeaders: () => getLeaders,
1683
+ getMilestones: () => getMilestones,
1684
+ getStats: () => getStats,
1685
+ getStatsWithBuilder: () => getStatsWithBuilder,
1686
+ getStatsWithFilters: () => getStatsWithFilters,
1687
+ getStatsWithParams: () => getStatsWithParams
1688
+ });
1689
+
1690
+ // src/utils/cayenne-query-builder.ts
1691
+ var CayenneQueryBuilder = class {
1692
+ conditions = [];
1693
+ currentLogicalOp = "and";
1694
+ groupStack = [];
1695
+ /**
1696
+ * Start a new logical group
1697
+ * All subsequent conditions will be added to this group until endGroup() is called
1698
+ * @returns This builder instance for chaining
1699
+ * @example
1700
+ * builder
1701
+ * .equals('field1', 'value1')
1702
+ * .group()
1703
+ * .equals('field2', 'value2')
1704
+ * .or()
1705
+ * .equals('field3', 'value3')
1706
+ * .endGroup()
1707
+ * // Generates: "field1=value1 and (field2=value2 or field3=value3)"
1708
+ */
1709
+ group() {
1710
+ this.groupStack.push({
1711
+ conditions: this.conditions,
1712
+ logicalOp: this.currentLogicalOp
1713
+ });
1714
+ this.conditions = [];
1715
+ this.currentLogicalOp = "and";
1716
+ return this;
1717
+ }
1718
+ /**
1719
+ * End the current logical group
1720
+ * @returns This builder instance for chaining
1721
+ * @throws Error if there's no open group
1722
+ */
1723
+ endGroup() {
1724
+ if (this.groupStack.length === 0) {
1725
+ throw new Error("Cannot end group: no open group found");
1726
+ }
1727
+ const groupConditions = this.conditions;
1728
+ const parent = this.groupStack.pop();
1729
+ if (!parent) {
1730
+ throw new Error("Failed to restore parent context");
1731
+ }
1732
+ this.conditions = parent.conditions;
1733
+ const groupLogicalOp = parent.logicalOp;
1734
+ this.currentLogicalOp = parent.logicalOp;
1735
+ const group = {
1736
+ type: "group",
1737
+ conditions: groupConditions,
1738
+ logicalOp: groupLogicalOp
1739
+ };
1740
+ this.conditions.push(group);
1741
+ return this;
1742
+ }
1743
+ /**
1744
+ * Set the logical operator to AND for subsequent conditions
1745
+ * @returns This builder instance for chaining
1746
+ */
1747
+ and() {
1748
+ this.currentLogicalOp = "and";
1749
+ return this;
1750
+ }
1751
+ /**
1752
+ * Set the logical operator to OR for subsequent conditions
1753
+ * @returns This builder instance for chaining
1754
+ */
1755
+ or() {
1756
+ this.currentLogicalOp = "or";
1757
+ return this;
1758
+ }
1759
+ /**
1760
+ * Add an equality condition
1761
+ * @param field - The field name to filter on
1762
+ * @param value - The value to match
1763
+ * @returns This builder instance for chaining
1764
+ */
1765
+ equals(field, value) {
1766
+ this.conditions.push({
1767
+ field,
1768
+ operator: "=",
1769
+ value,
1770
+ logicalOp: this.currentLogicalOp
1771
+ });
1772
+ return this;
1773
+ }
1774
+ /**
1775
+ * Add a not-equal condition
1776
+ * @param field - The field name to filter on
1777
+ * @param value - The value to exclude
1778
+ * @returns This builder instance for chaining
1779
+ */
1780
+ notEquals(field, value) {
1781
+ this.conditions.push({
1782
+ field,
1783
+ operator: "!=",
1784
+ value,
1785
+ logicalOp: this.currentLogicalOp
1786
+ });
1787
+ return this;
1788
+ }
1789
+ /**
1790
+ * Add a less-than condition
1791
+ * @param field - The field name to filter on
1792
+ * @param value - The upper bound (exclusive)
1793
+ * @returns This builder instance for chaining
1794
+ */
1795
+ lessThan(field, value) {
1796
+ this.conditions.push({
1797
+ field,
1798
+ operator: "<",
1799
+ value,
1800
+ logicalOp: this.currentLogicalOp
1801
+ });
1802
+ return this;
1803
+ }
1804
+ /**
1805
+ * Add a greater-than condition
1806
+ * @param field - The field name to filter on
1807
+ * @param value - The lower bound (exclusive)
1808
+ * @returns This builder instance for chaining
1809
+ */
1810
+ greaterThan(field, value) {
1811
+ this.conditions.push({
1812
+ field,
1813
+ operator: ">",
1814
+ value,
1815
+ logicalOp: this.currentLogicalOp
1816
+ });
1817
+ return this;
1818
+ }
1819
+ /**
1820
+ * Add a less-than-or-equal condition
1821
+ * @param field - The field name to filter on
1822
+ * @param value - The upper bound (inclusive)
1823
+ * @returns This builder instance for chaining
1824
+ */
1825
+ lessThanOrEqual(field, value) {
1826
+ this.conditions.push({
1827
+ field,
1828
+ operator: "<=",
1829
+ value,
1830
+ logicalOp: this.currentLogicalOp
1831
+ });
1832
+ return this;
1833
+ }
1834
+ /**
1835
+ * Add a greater-than-or-equal condition
1836
+ * @param field - The field name to filter on
1837
+ * @param value - The lower bound (inclusive)
1838
+ * @returns This builder instance for chaining
1839
+ */
1840
+ greaterThanOrEqual(field, value) {
1841
+ this.conditions.push({
1842
+ field,
1843
+ operator: ">=",
1844
+ value,
1845
+ logicalOp: this.currentLogicalOp
1846
+ });
1847
+ return this;
1848
+ }
1849
+ /**
1850
+ * Add an IN condition to match multiple values
1851
+ * @param field - The field name to filter on
1852
+ * @param values - Array of values to match against
1853
+ * @returns This builder instance for chaining
1854
+ * @example
1855
+ * builder.in('playerId', [8476791, 8477933, 8478402])
1856
+ * // Generates: "playerId in (8476791, 8477933, 8478402)"
1857
+ */
1858
+ in(field, values) {
1859
+ if (values.length === 0) {
1860
+ throw new Error("IN condition requires at least one value");
1861
+ }
1862
+ this.conditions.push({
1863
+ field,
1864
+ operator: "in",
1865
+ value: values,
1866
+ logicalOp: this.currentLogicalOp
1867
+ });
1868
+ return this;
1869
+ }
1870
+ /**
1871
+ * Add a LIKE condition for pattern matching
1872
+ * @param field - The field name to filter on
1873
+ * @param pattern - The pattern to match (supports % for wildcards)
1874
+ * @returns This builder instance for chaining
1875
+ * @example
1876
+ * builder.like('playerName', '%McDavid%')
1877
+ * // Generates: "playerName like '%McDavid%'"
1878
+ */
1879
+ like(field, pattern) {
1880
+ this.conditions.push({
1881
+ field,
1882
+ operator: "like",
1883
+ value: pattern,
1884
+ logicalOp: this.currentLogicalOp
1885
+ });
1886
+ return this;
1887
+ }
1888
+ /**
1889
+ * Add a raw condition string
1890
+ * Useful for complex expressions or unsupported operators
1891
+ * @param condition - The raw condition string (e.g., "playerId=8476791")
1892
+ * @returns This builder instance for chaining
1893
+ */
1894
+ raw(condition) {
1895
+ this.conditions.push({
1896
+ field: "__raw__",
1897
+ operator: "=",
1898
+ value: condition,
1899
+ logicalOp: this.currentLogicalOp
1900
+ });
1901
+ return this;
1902
+ }
1903
+ /**
1904
+ * Build the cayenneExp string
1905
+ * @returns The formatted cayenneExp string ready for API consumption
1906
+ */
1907
+ build() {
1908
+ if (this.groupStack.length > 0) {
1909
+ throw new Error(
1910
+ `Cannot build: ${this.groupStack.length} group(s) still open. Call endGroup() to close them.`
1911
+ );
1912
+ }
1913
+ const buildExpression = (items, depth = 0) => {
1914
+ return items.map((item, index) => {
1915
+ let expr = "";
1916
+ if ("type" in item && item.type === "group") {
1917
+ const groupExpr = buildExpression(
1918
+ item.conditions,
1919
+ depth + 1
1920
+ );
1921
+ expr = `(${groupExpr})`;
1922
+ } else if ("field" in item) {
1923
+ const condition = item;
1924
+ if (condition.field === "__raw__") {
1925
+ expr = String(condition.value);
1926
+ } else if (condition.operator === "in") {
1927
+ const values = Array.isArray(condition.value) ? condition.value.join(", ") : condition.value;
1928
+ expr = `${condition.field} in (${values})`;
1929
+ } else if (condition.operator === "like") {
1930
+ expr = `${condition.field} like '${condition.value}'`;
1931
+ } else {
1932
+ expr = `${condition.field}${condition.operator}${condition.value}`;
1933
+ }
1934
+ }
1935
+ if (index < items.length - 1) {
1936
+ const nextItem = items[index + 1];
1937
+ if (nextItem) {
1938
+ const nextLogicalOp = ("logicalOp" in nextItem ? nextItem.logicalOp : void 0) || "and";
1939
+ expr += ` ${nextLogicalOp}`;
1940
+ }
1941
+ }
1942
+ return expr;
1943
+ }).join(" ");
1944
+ };
1945
+ return buildExpression(this.conditions);
1946
+ }
1947
+ /**
1948
+ * Clear all conditions
1949
+ * @returns This builder instance for chaining
1950
+ */
1951
+ clear() {
1952
+ this.conditions = [];
1953
+ return this;
1954
+ }
1955
+ /**
1956
+ * Get the number of conditions currently in the builder
1957
+ */
1958
+ count() {
1959
+ return this.conditions.length;
1960
+ }
1961
+ };
1962
+ function createCayenneQuery() {
1963
+ return new CayenneQueryBuilder();
1964
+ }
1965
+ function buildCayenneExp(filters) {
1966
+ const builder = new CayenneQueryBuilder();
1967
+ Object.entries(filters).forEach(([field, value]) => {
1968
+ builder.equals(field, value);
1969
+ });
1970
+ return builder.build();
1971
+ }
1972
+
1973
+ // src/api/edge-stats/paths.ts
1974
+ var dataPaths = {
1975
+ /** Goalie-related statistics and reports. */
1976
+ goalie: {
1977
+ /** Goalie leader boards by stat category. */
1978
+ leaders: {
1979
+ /** Goals-against average leaders. */
1980
+ gaa: "{lang}/leaders/goalies/gaa",
1981
+ /** Save percentage leaders. */
1982
+ savePctg: "{lang}/leaders/goalies/savePctg",
1983
+ /** Shutouts leaders. */
1984
+ shutouts: "{lang}/leaders/goalies/shutouts"
1985
+ },
1986
+ /** Goalie statistical reports. */
1987
+ report: "{lang}/goalie/{report}",
1988
+ /** Goalie career milestones. */
1989
+ milestones: "{lang}/milestones/goalies"
1990
+ },
1991
+ /** Skater/player-related statistics and reports. */
1992
+ skater: {
1993
+ /** Player directory and information. */
1994
+ players: "{lang}/players",
1995
+ /** Skater leader boards by stat category. */
1996
+ leaders: {
1997
+ /** Assists leaders. */
1998
+ assists: "{lang}/leaders/skaters/assists",
1999
+ /** Goals leaders. */
2000
+ goals: "{lang}/leaders/skaters/goals",
2001
+ /** Points leaders. */
2002
+ points: "{lang}/leaders/skaters/points"
2003
+ },
2004
+ /** Skater career milestones. */
2005
+ milestones: "{lang}/milestones/skaters",
2006
+ /** Skater statistical reports. */
2007
+ report: "{lang}/skater/{report}"
2008
+ },
2009
+ /** Team-related statistics and reports. */
2010
+ team: {
2011
+ /** All teams data. */
2012
+ all: "{lang}/team",
2013
+ /** Team data by team ID. */
2014
+ byId: "{lang}/team/id/{teamId}",
2015
+ /** Team statistical reports. */
2016
+ report: "{lang}/team/{report}"
2017
+ },
2018
+ /** Season-related data. */
2019
+ season: "{lang}/season",
2020
+ /** Game-related data. */
2021
+ game: "{lang}/game",
2022
+ /** Draft-related data. */
2023
+ draft: "{lang}/draft",
2024
+ /** Configuration data for skater, goalie, and team reports. */
2025
+ config: "{lang}/config",
2026
+ /** Country data. */
2027
+ countries: "{lang}/country",
2028
+ /** Shift chart data. */
2029
+ shiftCharts: "{lang}/shiftcharts",
2030
+ /** Glossary data. */
2031
+ glossary: "{lang}/glossary",
2032
+ /** Franchise data. */
2033
+ franchises: "{lang}/franchise"
2034
+ };
2035
+
2036
+ // src/api/edge-stats/query.ts
2037
+ function reportParams(params = {}) {
2038
+ return { ...params, cayenneExp: params.cayenneExp ?? "" };
2039
+ }
2040
+ function filterParams(filters = {}, sorting = {}, pagination = {}) {
2041
+ const conditions = {};
2042
+ for (const [field, value] of Object.entries(filters)) {
2043
+ if (value !== void 0 && value !== "") conditions[field] = value;
2044
+ }
2045
+ const params = {
2046
+ cayenneExp: buildCayenneExp(conditions)
2047
+ };
2048
+ if (sorting.sortBy) params.sort = sorting.sortBy;
2049
+ if (sorting.direction) params.dir = sorting.direction;
2050
+ if (pagination.limit !== void 0) params.limit = pagination.limit;
2051
+ if (pagination.start !== void 0) params.start = pagination.start;
2052
+ return params;
2053
+ }
2054
+
2055
+ // src/api/edge-stats/goalies.ts
2056
+ async function getLeaders(statCategory, params = {}, lang = config.language) {
2057
+ const path = resolvePath(dataPaths.goalie.leaders[statCategory], { lang });
2058
+ return edgeStatsClient.get(path, params);
2059
+ }
2060
+ async function getStats(report = "summary", params = {}, lang = config.language) {
2061
+ const path = resolvePath(dataPaths.goalie.report, { lang, report });
2062
+ return edgeStatsClient.get(
2063
+ path,
2064
+ reportParams(params)
2065
+ );
2066
+ }
2067
+ async function getStatsWithParams(report, params, lang = config.language) {
2068
+ return getStats(report, params, lang);
2069
+ }
2070
+ async function getStatsWithBuilder(report, buildQuery, lang = config.language) {
2071
+ return getStats(report, buildQuery(new CayenneQueryBuilder()), lang);
2072
+ }
2073
+ async function getStatsWithFilters(report, filters, sorting, pagination, lang = config.language) {
2074
+ return getStats(
2075
+ report,
2076
+ filterParams(filters, sorting, pagination),
2077
+ lang
2078
+ );
2079
+ }
2080
+ async function getMilestones(lang = config.language) {
2081
+ const path = resolvePath(dataPaths.goalie.milestones, { lang });
2082
+ return edgeStatsClient.get(path);
2083
+ }
2084
+
2085
+ // src/api/edge-stats/misc.ts
2086
+ var misc_exports = {};
2087
+ __export(misc_exports, {
2088
+ getConfig: () => getConfig,
2089
+ getCountries: () => getCountries,
2090
+ getFranchises: () => getFranchises,
2091
+ getGlossary: () => getGlossary
2092
+ });
2093
+ async function getConfig(lang = config.language) {
2094
+ const path = resolvePath(dataPaths.config, { lang });
2095
+ return edgeStatsClient.get(path);
2096
+ }
2097
+ async function getCountries(lang = config.language) {
2098
+ const path = resolvePath(dataPaths.countries, { lang });
2099
+ return edgeStatsClient.get(path);
2100
+ }
2101
+ async function getGlossary(lang = config.language) {
2102
+ const path = resolvePath(dataPaths.glossary, { lang });
2103
+ return edgeStatsClient.get(path);
2104
+ }
2105
+ async function getFranchises(lang = config.language) {
2106
+ const path = resolvePath(dataPaths.franchises, { lang });
2107
+ return edgeStatsClient.get(path);
2108
+ }
2109
+
2110
+ // src/api/edge-stats/season-game.ts
2111
+ var season_game_exports = {};
2112
+ __export(season_game_exports, {
2113
+ getDraft: () => getDraft,
2114
+ getGames: () => getGames,
2115
+ getSeasons: () => getSeasons,
2116
+ getShiftChart: () => getShiftChart
2117
+ });
2118
+ async function getSeasons(lang = config.language) {
2119
+ const path = resolvePath(dataPaths.season, { lang });
2120
+ return edgeStatsClient.get(path);
2121
+ }
2122
+ async function getGames(params = {}, lang = config.language) {
2123
+ const path = resolvePath(dataPaths.game, { lang });
2124
+ return edgeStatsClient.get(path, params);
2125
+ }
2126
+ async function getShiftChart(gameId, lang = config.language) {
2127
+ const path = resolvePath(dataPaths.shiftCharts, { lang });
2128
+ const cayenneExp = `gameId=${gameId}`;
2129
+ return edgeStatsClient.get(path, {
2130
+ cayenneExp
2131
+ });
2132
+ }
2133
+ async function getDraft(lang = config.language) {
2134
+ const path = resolvePath(dataPaths.draft, { lang });
2135
+ return edgeStatsClient.get(path);
2136
+ }
2137
+
2138
+ // src/api/edge-stats/skaters.ts
2139
+ var skaters_exports2 = {};
2140
+ __export(skaters_exports2, {
2141
+ getLeaders: () => getLeaders2,
2142
+ getMilestones: () => getMilestones2,
2143
+ getPlayerInfo: () => getPlayerInfo,
2144
+ getStats: () => getStats2,
2145
+ getStatsWithBuilder: () => getStatsWithBuilder2,
2146
+ getStatsWithFilters: () => getStatsWithFilters2,
2147
+ getStatsWithParams: () => getStatsWithParams2
2148
+ });
2149
+ async function getPlayerInfo(params = {}, lang = config.language) {
2150
+ const path = resolvePath(dataPaths.skater.players, { lang });
2151
+ return edgeStatsClient.get(path, params);
2152
+ }
2153
+ async function getLeaders2(statCategory, params = {}, lang = config.language) {
2154
+ const path = resolvePath(dataPaths.skater.leaders[statCategory], { lang });
2155
+ return edgeStatsClient.get(path, params);
2156
+ }
2157
+ async function getMilestones2(lang = config.language) {
2158
+ const path = resolvePath(dataPaths.skater.milestones, { lang });
2159
+ return edgeStatsClient.get(path);
2160
+ }
2161
+ async function getStats2(report = "summary", params = {}, lang = config.language) {
2162
+ const path = resolvePath(dataPaths.skater.report, { lang, report });
2163
+ return edgeStatsClient.get(
2164
+ path,
2165
+ reportParams(params)
2166
+ );
2167
+ }
2168
+ async function getStatsWithParams2(report, params, lang = config.language) {
2169
+ return getStats2(report, params, lang);
2170
+ }
2171
+ async function getStatsWithBuilder2(report, buildQuery, lang = config.language) {
2172
+ return getStats2(report, buildQuery(new CayenneQueryBuilder()), lang);
2173
+ }
2174
+ async function getStatsWithFilters2(report, filters, sorting, pagination, lang = config.language) {
2175
+ return getStats2(
2176
+ report,
2177
+ filterParams(filters, sorting, pagination),
2178
+ lang
2179
+ );
2180
+ }
2181
+
2182
+ // src/api/edge-stats/teams.ts
2183
+ var teams_exports2 = {};
2184
+ __export(teams_exports2, {
2185
+ getAll: () => getAll,
2186
+ getById: () => getById,
2187
+ getStats: () => getStats3,
2188
+ getStatsWithBuilder: () => getStatsWithBuilder3,
2189
+ getStatsWithFilters: () => getStatsWithFilters3,
2190
+ getStatsWithParams: () => getStatsWithParams3
2191
+ });
2192
+ async function getAll(params = {}, lang = config.language) {
2193
+ const path = resolvePath(dataPaths.team.all, { lang });
2194
+ return edgeStatsClient.get(path, params);
2195
+ }
2196
+ async function getById(teamId, params = {}, lang = config.language) {
2197
+ const path = resolvePath(dataPaths.team.byId, { lang, teamId });
2198
+ return edgeStatsClient.get(path, params);
2199
+ }
2200
+ async function getStats3(report = "summary", params = {}, lang = config.language) {
2201
+ const path = resolvePath(dataPaths.team.report, { lang, report });
2202
+ return edgeStatsClient.get(
2203
+ path,
2204
+ reportParams(params)
2205
+ );
2206
+ }
2207
+ async function getStatsWithParams3(report, params, lang = config.language) {
2208
+ return getStats3(report, params, lang);
2209
+ }
2210
+ async function getStatsWithBuilder3(report, buildQuery, lang = config.language) {
2211
+ return getStats3(report, buildQuery(new CayenneQueryBuilder()), lang);
2212
+ }
2213
+ async function getStatsWithFilters3(report, filters, sorting, pagination, lang = config.language) {
2214
+ return getStats3(
2215
+ report,
2216
+ filterParams(filters, sorting, pagination),
2217
+ lang
2218
+ );
2219
+ }
2220
+
1782
2221
  // src/api/gamecenter/index.ts
1783
2222
  var gamecenter_exports = {};
1784
2223
  __export(gamecenter_exports, {
1785
2224
  draft: () => draft_exports,
1786
2225
  game: () => game_exports,
1787
- misc: () => misc_exports,
2226
+ misc: () => misc_exports2,
1788
2227
  player: () => player_exports,
1789
2228
  score: () => score,
1790
2229
  scoreboard: () => scoreboard,
@@ -1954,7 +2393,7 @@ function rankings(year) {
1954
2393
  goaliesIntl: "4"
1955
2394
  };
1956
2395
  const getRankings = async (type2) => {
1957
- const parsedYear = Year(year ?? getCurrentYear());
2396
+ const parsedYear = Year(year ?? getCurrentNHLYear());
1958
2397
  if (isParseError(parsedYear)) {
1959
2398
  return {
1960
2399
  success: false,
@@ -2155,7 +2594,7 @@ async function pptReplayEvent(gameId, eventId) {
2155
2594
  return nhlClient.get(path);
2156
2595
  }
2157
2596
  async function schedule(date) {
2158
- const parsedDate = NHLDate(date ?? getCurrentDate());
2597
+ const parsedDate = NHLDate(date ?? getCurrentNHLDate());
2159
2598
  if (isParseError(parsedDate)) {
2160
2599
  return {
2161
2600
  success: false,
@@ -2181,7 +2620,7 @@ async function scheduleCalendar(date) {
2181
2620
  return nhlClient.get(path);
2182
2621
  }
2183
2622
  async function playoffBracket(year) {
2184
- const parsedYear = Year(year ?? getCurrentYear());
2623
+ const parsedYear = Year(year ?? getCurrentNHLYear());
2185
2624
  if (isParseError(parsedYear)) {
2186
2625
  return {
2187
2626
  success: false,
@@ -2227,7 +2666,7 @@ async function whereToWatch() {
2227
2666
  return nhlClient.get(path);
2228
2667
  }
2229
2668
  async function networkTVSchedule(date) {
2230
- const parsedDate = NHLDate(date ?? getCurrentDate());
2669
+ const parsedDate = NHLDate(date ?? getCurrentNHLDate());
2231
2670
  if (isParseError(parsedDate)) {
2232
2671
  return {
2233
2672
  success: false,
@@ -2241,8 +2680,8 @@ async function networkTVSchedule(date) {
2241
2680
  }
2242
2681
 
2243
2682
  // src/api/gamecenter/misc.ts
2244
- var misc_exports = {};
2245
- __export(misc_exports, {
2683
+ var misc_exports2 = {};
2684
+ __export(misc_exports2, {
2246
2685
  location: () => location,
2247
2686
  meta: () => meta,
2248
2687
  partnerGame: () => partnerGame,
@@ -2398,7 +2837,7 @@ async function statsLeadersGoalies(season, gameType) {
2398
2837
 
2399
2838
  // src/api/gamecenter/score.ts
2400
2839
  async function score(date) {
2401
- const parsed = NHLDate(date ?? getCurrentDate());
2840
+ const parsed = NHLDate(date ?? getCurrentNHLDate());
2402
2841
  if (isParseError(parsed)) {
2403
2842
  return {
2404
2843
  success: false,
@@ -2521,7 +2960,7 @@ async function statsSeason(team) {
2521
2960
  return nhlClient.get(path);
2522
2961
  }
2523
2962
  async function standings(date) {
2524
- const parsed = NHLDate(date ?? getCurrentDate());
2963
+ const parsed = NHLDate(date ?? getCurrentNHLDate());
2525
2964
  if (isParseError(parsed)) {
2526
2965
  return {
2527
2966
  success: false,
@@ -2581,6 +3020,49 @@ var schedule2 = {
2581
3020
  month: scheduleMonth
2582
3021
  };
2583
3022
 
2584
- export { EDGE, nhl_exports as NHL, edge_adv_exports2 as adv, envConfig, gamecenter_exports as gc, logEnvConfig };
3023
+ // src/api/video.ts
3024
+ var video_exports = {};
3025
+ __export(video_exports, {
3026
+ metadata: () => metadata
3027
+ });
3028
+ var ACCOUNT_ID = "6415718365001";
3029
+ var POLICY_KEY = "BCpkADawqM3l37Vq8trLJ95vVwxubXYZXYglAopEZXQTHTWX3YdalyF9xmkuknxjBgiMYwt8VZ_OZ1jAjYxz_yzuNh_cjC3uOaMspVTD-hZfNUHtNnBnhVD0Gmsih8TBF8QlQFXiCQM3W_u4ydJ1qK2Rx8ZutCUg3PHb7Q";
3030
+ var brightcoveClient = createNHLClient({
3031
+ baseUrl: `https://edge.api.brightcove.com/playback/v1/accounts/${ACCOUNT_ID}`,
3032
+ headers: { Accept: `application/json;pk=${POLICY_KEY}` }
3033
+ });
3034
+ async function metadata(videoId) {
3035
+ const result = await brightcoveClient.get(
3036
+ `videos/${encodeURIComponent(String(videoId))}`
3037
+ );
3038
+ if (!result.success) return result;
3039
+ const video = result.data;
3040
+ const mp4 = video.sources.filter((s) => s.container === "MP4" && s.src?.startsWith("https:")).sort((a, b) => (b.width ?? 0) - (a.width ?? 0));
3041
+ return {
3042
+ success: true,
3043
+ data: {
3044
+ id: video.id,
3045
+ title: video.name,
3046
+ description: video.description,
3047
+ longDescription: video.long_description,
3048
+ duration: video.duration,
3049
+ publishedAt: video.published_at,
3050
+ poster: video.poster,
3051
+ thumbnail: video.thumbnail,
3052
+ url: mp4[0]?.src ?? null,
3053
+ sources: video.sources.map((s) => ({
3054
+ src: s.src,
3055
+ ...s.type && { type: s.type },
3056
+ ...s.container && { container: s.container },
3057
+ ...s.codec && { codec: s.codec },
3058
+ ...s.width && { width: s.width },
3059
+ ...s.height && { height: s.height }
3060
+ })),
3061
+ tags: video.tags
3062
+ }
3063
+ };
3064
+ }
3065
+
3066
+ export { APIError, BASE_URLS, CayenneQueryBuilder, ClientError, EDGE, ErrorCategory, ErrorHandler, LogLevel as ErrorLogLevel, nhl_exports as NHL, NHLClient, NHLError, NetworkError, NotFoundError, ParseError, RateLimitError, ServerError, ValidationError, edge_adv_exports2 as adv, buildCayenneExp, config, createCayenneQuery, createNHLClient, gamecenter_exports as gc, logConfig, logger, edge_stats_exports as stats, video_exports as video, writeLog };
2585
3067
  //# sourceMappingURL=index.js.map
2586
3068
  //# sourceMappingURL=index.js.map