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.
@@ -0,0 +1,1216 @@
1
+ 'use strict';
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __export = (target, all) => {
5
+ for (var name in all)
6
+ __defProp(target, name, { get: all[name], enumerable: true });
7
+ };
8
+
9
+ // src/constants/edge-adv.ts
10
+ var edge_adv_exports = {};
11
+ __export(edge_adv_exports, {
12
+ PositionFilterEnum: () => PositionFilterEnum,
13
+ SaveLocationCategoryEnum: () => SaveLocationCategoryEnum,
14
+ SaveLocationSortEnum: () => SaveLocationSortEnum,
15
+ SavePercentage5v5SortEnum: () => SavePercentage5v5SortEnum,
16
+ SavePercentageSortEnum: () => SavePercentageSortEnum,
17
+ ShotLocationCategoryEnum: () => ShotLocationCategoryEnum,
18
+ ShotLocationSortEnum: () => ShotLocationSortEnum,
19
+ ShotSpeedSortEnum: () => ShotSpeedSortEnum,
20
+ SkatersStrengthEnum: () => SkatersStrengthEnum,
21
+ SkatingDistanceSortEnum: () => SkatingDistanceSortEnum,
22
+ SkatingSpeedSortEnum: () => SkatingSpeedSortEnum,
23
+ ZoneTimeSortEnum: () => ZoneTimeSortEnum
24
+ });
25
+ var SaveLocationCategoryEnum = {
26
+ /** Save Percentage */
27
+ "SV%": "save-pctg",
28
+ /** Saves */
29
+ SV: "saves",
30
+ /** Shots Against */
31
+ SA: "shots-against",
32
+ /** Goals Against */
33
+ GA: "goals-against"
34
+ };
35
+ var ShotLocationSortEnum = {
36
+ /** All shot locations */
37
+ ALL: "all",
38
+ /** High-danger (i.e. close-range) shot locations */
39
+ HIGH: "high",
40
+ /** Mid-range shot locations */
41
+ MID: "mid",
42
+ /** Long-range shot locations */
43
+ LONG: "long"
44
+ };
45
+ var SaveLocationSortEnum = ShotLocationSortEnum;
46
+ var SavePercentage5v5SortEnum = {
47
+ /**5v5 Save %: The percentage of shots a goalie stops at even strength (5-on-5). */
48
+ "5v5-SV%": "save-pctg",
49
+ /**5v5 Save % in Close Situations: A “close situation” is the time during which a game is tied in the first or second period, or within one goal in the third period. This stats helps how goalies perform in high-pressure situations.*/
50
+ "5v5-SV%-Close": "save-pctg-close",
51
+ /**5v5 Shots Against: The total number of shots a goalie faces at even strength (5-on-5).*/
52
+ "5v5-SA": "shots",
53
+ /**5v5 Shots Against per 60 Minutes: The total number of shots a goalie faces at even strength (5-on-5) normalized to a 60-minute game. */
54
+ "5v5-SA/60": "shots-per-60"
55
+ };
56
+ var SavePercentageSortEnum = {
57
+ /** Starts above .900 */
58
+ GAMES: "games",
59
+ /** Percentage of starts above .900 */
60
+ PCTG: "pctg"
61
+ };
62
+ var PositionFilterEnum = {
63
+ /** Center */
64
+ ALL: "all",
65
+ /** Left Wing */
66
+ FWD: "forwards",
67
+ /** Right Wing */
68
+ DEF: "defense"
69
+ };
70
+ var SkatersStrengthEnum = {
71
+ /** All strengths */
72
+ ALL: "all",
73
+ /** Even strength */
74
+ ES: "es",
75
+ /** Power play */
76
+ PP: "pp",
77
+ /** Short-handed */
78
+ PK: "pk"
79
+ };
80
+ var ShotSpeedSortEnum = {
81
+ /** Hardest shot recorded by player */
82
+ MAX: "max",
83
+ /** Shots over 100 mph */
84
+ "OVER-100": "over-100",
85
+ /** Shots between 90 and 99 mph */
86
+ "90-99": "90-99",
87
+ /** Shots between 80 and 89 mph */
88
+ "80-89": "80-89",
89
+ /** Shots between 70 and 79 mph */
90
+ "70-79": "70-79"
91
+ };
92
+ var SkatingSpeedSortEnum = {
93
+ /** Fastest skating speed recorded by player */
94
+ TOP: "max",
95
+ /** Speed bursts recorded over 22 mph */
96
+ "OVER-22": "over-22",
97
+ /** Speed bursts recorded between 20 and 22 mph */
98
+ "20-22": "20-22",
99
+ /** Speed bursts recorded between 18 and 20 mph */
100
+ "18-20": "18-20"
101
+ };
102
+ var SkatingDistanceSortEnum = {
103
+ /** Total distance skated */
104
+ TOTAL: "total",
105
+ /** Average distance skated per 60 minutes */
106
+ "PER-60": "per-60",
107
+ /** Maximum distance skated in a single period */
108
+ "MAX-PERIOD": "max-period",
109
+ /** Maximum distance skated in a single game */
110
+ "MAX-GAME": "max-game"
111
+ };
112
+ var ShotLocationCategoryEnum = {
113
+ /** Total shots on goal */
114
+ SOG: "sog",
115
+ /** Total goals */
116
+ G: "goals",
117
+ /** Shooting percentage */
118
+ "SH%": "shooting-pctg"
119
+ };
120
+ var ZoneTimeSortEnum = {
121
+ /** Percentage of time spent in the offensive zone */
122
+ OZ: "offensive",
123
+ /** Percentage of time spent in the defensive zone */
124
+ DZ: "defensive",
125
+ /** Percentage of time spent in the neutral zone */
126
+ NZ: "neutral"
127
+ };
128
+
129
+ // src/constants/nhl.ts
130
+ var nhl_exports = {};
131
+ __export(nhl_exports, {
132
+ CURRENT: () => CURRENT,
133
+ END_SEASON: () => END_SEASON,
134
+ END_YEAR: () => END_YEAR,
135
+ GameStateEnum: () => GameStateEnum,
136
+ GameTypeEnum: () => GameTypeEnum,
137
+ InactiveTeamsEnum: () => InactiveTeamsEnum,
138
+ InactiveTeamsReverseEnum: () => InactiveTeamsReverseEnum,
139
+ PLAYER_ID_RANGE: () => PLAYER_ID_RANGE,
140
+ PeriodTypeEnum: () => PeriodTypeEnum,
141
+ PlayoffSeriesEnum: () => PlayoffSeriesEnum,
142
+ SEASON_RANGE: () => SEASON_RANGE,
143
+ START_SEASON: () => START_SEASON,
144
+ START_YEAR: () => START_YEAR,
145
+ SeasonsArray: () => SeasonsArray,
146
+ SeriesLetterByRound: () => SeriesLetterByRound,
147
+ SeriesLetterEnum: () => SeriesLetterEnum,
148
+ TEAM_ID_RANGE: () => TEAM_ID_RANGE,
149
+ TeamsEnum: () => TeamsEnum,
150
+ TeamsReverseEnum: () => TeamsReverseEnum,
151
+ YEAR_RANGE: () => YEAR_RANGE
152
+ });
153
+
154
+ // src/utils/date.ts
155
+ var NHL_TIMEZONE = "America/New_York";
156
+ var getNHLDate = (date) => new Intl.DateTimeFormat("en-CA", {
157
+ timeZone: NHL_TIMEZONE,
158
+ year: "numeric",
159
+ month: "2-digit",
160
+ day: "2-digit"
161
+ }).format(date);
162
+ var getCurrentNHLDate = () => getNHLDate(/* @__PURE__ */ new Date());
163
+ var getNHLMonth = (date) => {
164
+ return new Intl.DateTimeFormat("en-CA", {
165
+ timeZone: NHL_TIMEZONE,
166
+ year: "numeric",
167
+ month: "2-digit"
168
+ }).format(date);
169
+ };
170
+ var getCurrentNHLMonth = () => getNHLMonth(/* @__PURE__ */ new Date());
171
+ var getYear = (date) => new Intl.DateTimeFormat("en-CA", {
172
+ timeZone: NHL_TIMEZONE,
173
+ year: "numeric"
174
+ }).format(date);
175
+ var getCurrentNHLYear = () => getYear(/* @__PURE__ */ new Date());
176
+ var getSeason = (date) => {
177
+ const format = new Intl.DateTimeFormat("en-CA", {
178
+ timeZone: NHL_TIMEZONE,
179
+ year: "numeric",
180
+ month: "numeric"
181
+ }).formatToParts(date instanceof Date ? date : new Date(date));
182
+ const month = format.find((part) => part.type === "month")?.value;
183
+ const year = format.find((part) => part.type === "year")?.value;
184
+ if (!year) {
185
+ throw new Error("Invalid date provided, could not extract year");
186
+ }
187
+ if (month && parseInt(month, 10) < 7) {
188
+ return `${parseInt(year, 10) - 1}${year}`;
189
+ }
190
+ return `${year}${parseInt(year, 10) + 1}`;
191
+ };
192
+ var getCurrentSeason = () => getSeason(/* @__PURE__ */ new Date());
193
+ var NHL_START_DATE = /* @__PURE__ */ new Date("1917-12-01");
194
+ var NHL_END_DATE = /* @__PURE__ */ new Date(
195
+ `${getCurrentSeason().slice(4, 8)}-06-30`
196
+ );
197
+
198
+ // src/constants/nhl.ts
199
+ var TeamsEnum = {
200
+ /** Anaheim Ducks */
201
+ ANA: 24,
202
+ /** Boston Bruins */
203
+ BOS: 6,
204
+ /** Buffalo Sabres */
205
+ BUF: 7,
206
+ /** Calgary Flames */
207
+ CGY: 20,
208
+ /** Carolina Hurricanes */
209
+ CAR: 12,
210
+ /** Chicago Blackhawks */
211
+ CHI: 16,
212
+ /** Colorado Avalanche */
213
+ COL: 21,
214
+ /** Columbus Blue Jackets */
215
+ CBJ: 29,
216
+ /** Dallas Stars */
217
+ DAL: 25,
218
+ /** Detroit Red Wings */
219
+ DET: 17,
220
+ /** Edmonton Oilers */
221
+ EDM: 22,
222
+ /** Florida Panthers */
223
+ FLA: 13,
224
+ /** Los Angeles Kings */
225
+ LAK: 26,
226
+ /** Minnesota Wild*/
227
+ MIN: 30,
228
+ /** Montreal Canadiens */
229
+ MTL: 8,
230
+ /** New Jersey Devils */
231
+ NJD: 1,
232
+ /** Nashville Predators */
233
+ NSH: 18,
234
+ /** New York Islanders */
235
+ NYI: 2,
236
+ /** New York Rangers */
237
+ NYR: 3,
238
+ /** Ottawa Senators */
239
+ OTT: 9,
240
+ /** Philadelphia Flyers */
241
+ PHI: 4,
242
+ /** Pittsburgh Penguins */
243
+ PIT: 5,
244
+ /** San Jose Sharks */
245
+ SJS: 28,
246
+ /** Seattle Kraken */
247
+ SEA: 55,
248
+ /** St. Louis Blues */
249
+ STL: 19,
250
+ /** Tampa Bay Lightning */
251
+ TBL: 14,
252
+ /** Toronto Maple Leafs */
253
+ TOR: 10,
254
+ /** Utah Hockey Club */
255
+ UTA: 59,
256
+ /** Vancouver Canucks */
257
+ VAN: 23,
258
+ /** Vegas Golden Knights */
259
+ VGK: 54,
260
+ /** Winnipeg Jets */
261
+ WPG: 52,
262
+ /** Washington Capitals */
263
+ WSH: 15
264
+ };
265
+ var TeamsReverseEnum = Object.fromEntries(
266
+ Object.entries(TeamsEnum).map(([key, value]) => [value, key])
267
+ );
268
+ var InactiveTeamsEnum = {
269
+ /** Atlanta Flames (not active) */
270
+ AFM: 47,
271
+ /** Arizona Coyotes (not active) */
272
+ ARI: 53,
273
+ /** Atlanta Thrashers (not active) */
274
+ ATL: 11,
275
+ /** Brooklyn Americans - (not active) */
276
+ BRK: 51,
277
+ /** California Golden Seals (aka Bay Area Seals) - (not active) */
278
+ CGS: 56,
279
+ /** Cleveland Barons - (not active) */
280
+ CLE: 49,
281
+ /** Colorado Rockies - (not active) */
282
+ CLR: 35,
283
+ /** Detroit Cougars - (not active) */
284
+ DCG: 40,
285
+ /** Detroit Falcons - (not active) */
286
+ DFL: 50,
287
+ /** Hamilton Tigers - (not active) */
288
+ HAM: 37,
289
+ /** Hartford Whalers - (not active) */
290
+ HFD: 34,
291
+ /** Kansas City Scouts - (not active) */
292
+ KCS: 48,
293
+ /** Montreal Maroons - (not active) */
294
+ MMR: 43,
295
+ /** Minnesota North Stars - (not active) */
296
+ MNS: 31,
297
+ /** Montreal Wanderers - (not active) */
298
+ MWN: 41,
299
+ /** New York Americans - (not active) */
300
+ NYA: 44,
301
+ /** California Seals (aka Oakland Seals) - (not active) */
302
+ OAK: 46,
303
+ /** Phoenix Coyotes - (not active) */
304
+ PHX: 27,
305
+ /** Pittsburgh Pirates - (not active) */
306
+ PIR: 38,
307
+ /** Quebec Bulldogs - (not active) */
308
+ QBD: 42,
309
+ /** Philadelphia Quakers - (not active) */
310
+ QUA: 39,
311
+ /** Quebec Nordiques - (not active) */
312
+ QUE: 32,
313
+ /** Ottawa Senators (original franchise) - (not active) */
314
+ SEN: 36,
315
+ /** St. Louis Eagles - (not active) */
316
+ SLE: 45,
317
+ /** Toronto Hockey Club (aka Toronto Arenas) - (not active) */
318
+ TAN: 57,
319
+ /** Toronto St. Patricks - (not active) */
320
+ TSP: 58,
321
+ /** Winnipeg Jets (original franchise) - (not active) */
322
+ WIN: 33
323
+ };
324
+ var InactiveTeamsReverseEnum = Object.fromEntries(
325
+ Object.entries(InactiveTeamsEnum).map(([key, value]) => [value, key])
326
+ );
327
+ var SeasonsArray = [
328
+ 19171918,
329
+ 19181919,
330
+ 19191920,
331
+ 19201921,
332
+ 19211922,
333
+ 19221923,
334
+ 19231924,
335
+ 19241925,
336
+ 19251926,
337
+ 19261927,
338
+ 19271928,
339
+ 19281929,
340
+ 19291930,
341
+ 19301931,
342
+ 19311932,
343
+ 19321933,
344
+ 19331934,
345
+ 19341935,
346
+ 19351936,
347
+ 19361937,
348
+ 19371938,
349
+ 19381939,
350
+ 19391940,
351
+ 19401941,
352
+ 19411942,
353
+ 19421943,
354
+ 19431944,
355
+ 19441945,
356
+ 19451946,
357
+ 19461947,
358
+ 19471948,
359
+ 19481949,
360
+ 19491950,
361
+ 19501951,
362
+ 19511952,
363
+ 19521953,
364
+ 19531954,
365
+ 19541955,
366
+ 19551956,
367
+ 19561957,
368
+ 19571958,
369
+ 19581959,
370
+ 19591960,
371
+ 19601961,
372
+ 19611962,
373
+ 19621963,
374
+ 19631964,
375
+ 19641965,
376
+ 19651966,
377
+ 19661967,
378
+ 19671968,
379
+ 19681969,
380
+ 19691970,
381
+ 19701971,
382
+ 19711972,
383
+ 19721973,
384
+ 19731974,
385
+ 19741975,
386
+ 19751976,
387
+ 19761977,
388
+ 19771978,
389
+ 19781979,
390
+ 19791980,
391
+ 19801981,
392
+ 19811982,
393
+ 19821983,
394
+ 19831984,
395
+ 19841985,
396
+ 19851986,
397
+ 19861987,
398
+ 19871988,
399
+ 19881989,
400
+ 19891990,
401
+ 19901991,
402
+ 19911992,
403
+ 19921993,
404
+ 19931994,
405
+ 19941995,
406
+ 19951996,
407
+ 19961997,
408
+ 19971998,
409
+ 19981999,
410
+ 19992e3,
411
+ 20002001,
412
+ 20012002,
413
+ 20022003,
414
+ 20032004,
415
+ 20052006,
416
+ 20062007,
417
+ 20072008,
418
+ 20082009,
419
+ 20092010,
420
+ 20102011,
421
+ 20112012,
422
+ 20122013,
423
+ 20132014,
424
+ 20142015,
425
+ 20152016,
426
+ 20162017,
427
+ 20172018,
428
+ 20182019,
429
+ 20192020,
430
+ 20202021,
431
+ 20212022,
432
+ 20222023,
433
+ 20232024,
434
+ 20242025,
435
+ 20252026
436
+ ];
437
+ var SeriesLetterEnum = {
438
+ /** Atlantic Division Round 1: D1 vs WC# */
439
+ A: "A",
440
+ /** Atlantic Division Round 1: D2 vs D3 */
441
+ B: "B",
442
+ /** Metropolitan Division Round 1: D1 vs WC# */
443
+ C: "C",
444
+ /** Metropolitan Division Round 1: D2 vs D3 */
445
+ D: "D",
446
+ /** Central Division Round 1: D1 vs WC# */
447
+ E: "E",
448
+ /** Central Division Round 1: D2 vs D3 */
449
+ F: "F",
450
+ /** Pacific Division Round 1: D1 vs WC# */
451
+ G: "G",
452
+ /** Pacific Division Round 1: D2 vs D3 */
453
+ H: "H",
454
+ /** Atlantic Division Round 2: Aw vs Bw */
455
+ I: "I",
456
+ /** Metropolitan Division Round 2: Cw vs Dw */
457
+ J: "J",
458
+ /** Central Division Round 2: Ew vs Fw */
459
+ K: "K",
460
+ /** Pacific Division Round 2: Gw vs Hw */
461
+ L: "L",
462
+ /** Eastern Conference Finals */
463
+ M: "M",
464
+ /** Western Conference Finals*/
465
+ N: "N",
466
+ /** Stanley Cup Finals */
467
+ O: "O"
468
+ };
469
+ var SeriesLetterByRound = {
470
+ R1: ["A", "B", "C", "D", "E", "F", "G", "H"],
471
+ R2: ["I", "J", "K", "L"],
472
+ CF: ["M", "N"],
473
+ SCF: ["O"]
474
+ };
475
+ var PlayoffSeriesEnum = {
476
+ Atlantic_R1_D1_vs_WC: "A",
477
+ Atlantic_R1_D2_vs_D3: "B",
478
+ Metropolitan_R1_D1_vs_WC: "C",
479
+ Metropolitan_R1_D2_vs_D3: "D",
480
+ Central_R1_D1_vs_WC: "E",
481
+ Central_R1_D2_vs_D3: "F",
482
+ Pacific_R1_D1_vs_WC: "G",
483
+ Pacific_R1_D2_vs_D3: "H",
484
+ Atlantic_R2_Aw_vs_Bw: "I",
485
+ Metropolitan_R2_Cw_vs_Dw: "J",
486
+ Central_R2_Ew_vs_Fw: "K",
487
+ Pacific_R2_Gw_vs_Hw: "L",
488
+ Eastern_Conference_Finals: "M",
489
+ Western_Conference_Finals: "N",
490
+ Stanley_Cup_Finals: "O"
491
+ };
492
+ var GameStateEnum = {
493
+ /** Future */
494
+ FUT: "FUT",
495
+ /** Live */
496
+ LIV: "LIV",
497
+ /** Finished */
498
+ FIN: "FIN"
499
+ };
500
+ var PeriodTypeEnum = {
501
+ /** Regulation */
502
+ REG: "REG",
503
+ /** Overtime */
504
+ OT: "OT",
505
+ /** Shootout */
506
+ SO: "SO"
507
+ };
508
+ var GameTypeEnum = {
509
+ /** Pre-season */
510
+ PRE: 1,
511
+ /** Regular season */
512
+ REG: 2,
513
+ /** Post-season (aka playoffs) */
514
+ POST: 3,
515
+ /** All-Star Game (unconfirmed) */
516
+ ASG: 4,
517
+ /** International (unconfirmed) */
518
+ INTL: 19
519
+ };
520
+ var SEASON_RANGE = {
521
+ START: SeasonsArray[0],
522
+ END: SeasonsArray.at(-1)
523
+ };
524
+ var START_SEASON = SEASON_RANGE.START;
525
+ var END_SEASON = SEASON_RANGE.END;
526
+ var YEAR_RANGE = {
527
+ START: parseInt(SEASON_RANGE.START.toString().slice(0, 4), 10),
528
+ END: parseInt(SEASON_RANGE.END.toString().slice(4, 8), 10)
529
+ };
530
+ var START_YEAR = YEAR_RANGE.START;
531
+ var END_YEAR = YEAR_RANGE.END;
532
+ var CURRENT = {
533
+ /** The season for today's date, so the default never goes stale. */
534
+ SEASON: Number(getCurrentSeason()),
535
+ YEAR: YEAR_RANGE.END
536
+ };
537
+ var PLAYER_ID_RANGE = { MIN: 8444e3, MAX: 8489999 };
538
+ var TEAM_ID_RANGE = { MIN: 1, MAX: 59 };
539
+
540
+ // src/constants/index.ts
541
+ ({ ...edge_adv_exports });
542
+
543
+ // src/utils/cayenne-query-builder.ts
544
+ var CayenneQueryBuilder = class {
545
+ conditions = [];
546
+ currentLogicalOp = "and";
547
+ groupStack = [];
548
+ /**
549
+ * Start a new logical group
550
+ * All subsequent conditions will be added to this group until endGroup() is called
551
+ * @returns This builder instance for chaining
552
+ * @example
553
+ * builder
554
+ * .equals('field1', 'value1')
555
+ * .group()
556
+ * .equals('field2', 'value2')
557
+ * .or()
558
+ * .equals('field3', 'value3')
559
+ * .endGroup()
560
+ * // Generates: "field1=value1 and (field2=value2 or field3=value3)"
561
+ */
562
+ group() {
563
+ this.groupStack.push({
564
+ conditions: this.conditions,
565
+ logicalOp: this.currentLogicalOp
566
+ });
567
+ this.conditions = [];
568
+ this.currentLogicalOp = "and";
569
+ return this;
570
+ }
571
+ /**
572
+ * End the current logical group
573
+ * @returns This builder instance for chaining
574
+ * @throws Error if there's no open group
575
+ */
576
+ endGroup() {
577
+ if (this.groupStack.length === 0) {
578
+ throw new Error("Cannot end group: no open group found");
579
+ }
580
+ const groupConditions = this.conditions;
581
+ const parent = this.groupStack.pop();
582
+ if (!parent) {
583
+ throw new Error("Failed to restore parent context");
584
+ }
585
+ this.conditions = parent.conditions;
586
+ const groupLogicalOp = parent.logicalOp;
587
+ this.currentLogicalOp = parent.logicalOp;
588
+ const group = {
589
+ type: "group",
590
+ conditions: groupConditions,
591
+ logicalOp: groupLogicalOp
592
+ };
593
+ this.conditions.push(group);
594
+ return this;
595
+ }
596
+ /**
597
+ * Set the logical operator to AND for subsequent conditions
598
+ * @returns This builder instance for chaining
599
+ */
600
+ and() {
601
+ this.currentLogicalOp = "and";
602
+ return this;
603
+ }
604
+ /**
605
+ * Set the logical operator to OR for subsequent conditions
606
+ * @returns This builder instance for chaining
607
+ */
608
+ or() {
609
+ this.currentLogicalOp = "or";
610
+ return this;
611
+ }
612
+ /**
613
+ * Add an equality condition
614
+ * @param field - The field name to filter on
615
+ * @param value - The value to match
616
+ * @returns This builder instance for chaining
617
+ */
618
+ equals(field, value) {
619
+ this.conditions.push({
620
+ field,
621
+ operator: "=",
622
+ value,
623
+ logicalOp: this.currentLogicalOp
624
+ });
625
+ return this;
626
+ }
627
+ /**
628
+ * Add a not-equal condition
629
+ * @param field - The field name to filter on
630
+ * @param value - The value to exclude
631
+ * @returns This builder instance for chaining
632
+ */
633
+ notEquals(field, value) {
634
+ this.conditions.push({
635
+ field,
636
+ operator: "!=",
637
+ value,
638
+ logicalOp: this.currentLogicalOp
639
+ });
640
+ return this;
641
+ }
642
+ /**
643
+ * Add a less-than condition
644
+ * @param field - The field name to filter on
645
+ * @param value - The upper bound (exclusive)
646
+ * @returns This builder instance for chaining
647
+ */
648
+ lessThan(field, value) {
649
+ this.conditions.push({
650
+ field,
651
+ operator: "<",
652
+ value,
653
+ logicalOp: this.currentLogicalOp
654
+ });
655
+ return this;
656
+ }
657
+ /**
658
+ * Add a greater-than condition
659
+ * @param field - The field name to filter on
660
+ * @param value - The lower bound (exclusive)
661
+ * @returns This builder instance for chaining
662
+ */
663
+ greaterThan(field, value) {
664
+ this.conditions.push({
665
+ field,
666
+ operator: ">",
667
+ value,
668
+ logicalOp: this.currentLogicalOp
669
+ });
670
+ return this;
671
+ }
672
+ /**
673
+ * Add a less-than-or-equal condition
674
+ * @param field - The field name to filter on
675
+ * @param value - The upper bound (inclusive)
676
+ * @returns This builder instance for chaining
677
+ */
678
+ lessThanOrEqual(field, value) {
679
+ this.conditions.push({
680
+ field,
681
+ operator: "<=",
682
+ value,
683
+ logicalOp: this.currentLogicalOp
684
+ });
685
+ return this;
686
+ }
687
+ /**
688
+ * Add a greater-than-or-equal condition
689
+ * @param field - The field name to filter on
690
+ * @param value - The lower bound (inclusive)
691
+ * @returns This builder instance for chaining
692
+ */
693
+ greaterThanOrEqual(field, value) {
694
+ this.conditions.push({
695
+ field,
696
+ operator: ">=",
697
+ value,
698
+ logicalOp: this.currentLogicalOp
699
+ });
700
+ return this;
701
+ }
702
+ /**
703
+ * Add an IN condition to match multiple values
704
+ * @param field - The field name to filter on
705
+ * @param values - Array of values to match against
706
+ * @returns This builder instance for chaining
707
+ * @example
708
+ * builder.in('playerId', [8476791, 8477933, 8478402])
709
+ * // Generates: "playerId in (8476791, 8477933, 8478402)"
710
+ */
711
+ in(field, values) {
712
+ if (values.length === 0) {
713
+ throw new Error("IN condition requires at least one value");
714
+ }
715
+ this.conditions.push({
716
+ field,
717
+ operator: "in",
718
+ value: values,
719
+ logicalOp: this.currentLogicalOp
720
+ });
721
+ return this;
722
+ }
723
+ /**
724
+ * Add a LIKE condition for pattern matching
725
+ * @param field - The field name to filter on
726
+ * @param pattern - The pattern to match (supports % for wildcards)
727
+ * @returns This builder instance for chaining
728
+ * @example
729
+ * builder.like('playerName', '%McDavid%')
730
+ * // Generates: "playerName like '%McDavid%'"
731
+ */
732
+ like(field, pattern) {
733
+ this.conditions.push({
734
+ field,
735
+ operator: "like",
736
+ value: pattern,
737
+ logicalOp: this.currentLogicalOp
738
+ });
739
+ return this;
740
+ }
741
+ /**
742
+ * Add a raw condition string
743
+ * Useful for complex expressions or unsupported operators
744
+ * @param condition - The raw condition string (e.g., "playerId=8476791")
745
+ * @returns This builder instance for chaining
746
+ */
747
+ raw(condition) {
748
+ this.conditions.push({
749
+ field: "__raw__",
750
+ operator: "=",
751
+ value: condition,
752
+ logicalOp: this.currentLogicalOp
753
+ });
754
+ return this;
755
+ }
756
+ /**
757
+ * Build the cayenneExp string
758
+ * @returns The formatted cayenneExp string ready for API consumption
759
+ */
760
+ build() {
761
+ if (this.groupStack.length > 0) {
762
+ throw new Error(
763
+ `Cannot build: ${this.groupStack.length} group(s) still open. Call endGroup() to close them.`
764
+ );
765
+ }
766
+ const buildExpression = (items, depth = 0) => {
767
+ return items.map((item, index) => {
768
+ let expr = "";
769
+ if ("type" in item && item.type === "group") {
770
+ const groupExpr = buildExpression(
771
+ item.conditions,
772
+ depth + 1
773
+ );
774
+ expr = `(${groupExpr})`;
775
+ } else if ("field" in item) {
776
+ const condition = item;
777
+ if (condition.field === "__raw__") {
778
+ expr = String(condition.value);
779
+ } else if (condition.operator === "in") {
780
+ const values = Array.isArray(condition.value) ? condition.value.join(", ") : condition.value;
781
+ expr = `${condition.field} in (${values})`;
782
+ } else if (condition.operator === "like") {
783
+ expr = `${condition.field} like '${condition.value}'`;
784
+ } else {
785
+ expr = `${condition.field}${condition.operator}${condition.value}`;
786
+ }
787
+ }
788
+ if (index < items.length - 1) {
789
+ const nextItem = items[index + 1];
790
+ if (nextItem) {
791
+ const nextLogicalOp = ("logicalOp" in nextItem ? nextItem.logicalOp : void 0) || "and";
792
+ expr += ` ${nextLogicalOp}`;
793
+ }
794
+ }
795
+ return expr;
796
+ }).join(" ");
797
+ };
798
+ return buildExpression(this.conditions);
799
+ }
800
+ /**
801
+ * Clear all conditions
802
+ * @returns This builder instance for chaining
803
+ */
804
+ clear() {
805
+ this.conditions = [];
806
+ return this;
807
+ }
808
+ /**
809
+ * Get the number of conditions currently in the builder
810
+ */
811
+ count() {
812
+ return this.conditions.length;
813
+ }
814
+ };
815
+ function createCayenneQuery() {
816
+ return new CayenneQueryBuilder();
817
+ }
818
+ function buildCayenneExp(filters) {
819
+ const builder = new CayenneQueryBuilder();
820
+ Object.entries(filters).forEach(([field, value]) => {
821
+ builder.equals(field, value);
822
+ });
823
+ return builder.build();
824
+ }
825
+
826
+ // src/utils/normalize.ts
827
+ var alternateAbbreviations = {
828
+ CLS: "CBJ",
829
+ CAL: "CGY",
830
+ LA: "LAK",
831
+ "L.A": "LAK",
832
+ MON: "MTL",
833
+ NJ: "NJD",
834
+ "N.J": "NJD",
835
+ SJ: "SJS",
836
+ "S.J": "SJS",
837
+ TB: "TBL",
838
+ "T.B": "TBL",
839
+ UTAH: "UTA"
840
+ // confirm if the NHL has a standard for players with no team associated
841
+ // NA: 'N/A',
842
+ // '(N/A)': 'N/A',
843
+ };
844
+ var normalizeAbbrev = (abbrev) => {
845
+ const upperAbbrev = abbrev.toUpperCase();
846
+ return alternateAbbreviations[upperAbbrev] ?? upperAbbrev;
847
+ };
848
+
849
+ // src/utils/team-branding.ts
850
+ var TEAM_BRANDING = {
851
+ ANA: {
852
+ name: "Anaheim Ducks",
853
+ primaryColor: "#F47A38",
854
+ colors: {
855
+ orange: "#F47A38",
856
+ metallicGold: "#B9975B",
857
+ silver: "#C1C6C8",
858
+ black: "#000000"
859
+ }
860
+ },
861
+ BOS: {
862
+ name: "Boston Bruins",
863
+ primaryColor: "#FFB81C",
864
+ colors: { gold: "#FFB81C", black: "#000000" }
865
+ },
866
+ BUF: {
867
+ name: "Buffalo Sabres",
868
+ primaryColor: "#003087",
869
+ colors: {
870
+ royalBlue: "#003087",
871
+ gold: "#FFB81C",
872
+ white: "#FFFFFF"
873
+ }
874
+ },
875
+ CGY: {
876
+ name: "Calgary Flames",
877
+ primaryColor: "#D2001C",
878
+ colors: { red: "#D2001C", yellow: "#FAAF19", white: "#FFFFFF" }
879
+ },
880
+ CAR: {
881
+ name: "Carolina Hurricanes",
882
+ primaryColor: "#CE1126",
883
+ colors: {
884
+ red: "#CE1126",
885
+ white: "#FFFFFF",
886
+ gray: "#A4A9AD",
887
+ black: "#000000"
888
+ }
889
+ },
890
+ CHI: {
891
+ name: "Chicago Blackhawks",
892
+ primaryColor: "#CF0A2C",
893
+ colors: {
894
+ red: "#CF0A2C",
895
+ orange: "#FF671B",
896
+ green: "#00833E",
897
+ yellow: "#FFD100",
898
+ tan: "#D18A00",
899
+ blue: "#001970",
900
+ black: "#000000",
901
+ white: "#FFFFFF"
902
+ }
903
+ },
904
+ COL: {
905
+ name: "Colorado Avalanche",
906
+ primaryColor: "#6F263D",
907
+ colors: {
908
+ burgundy: "#6F263D",
909
+ blue: "#236192",
910
+ silver: "#A2AAAD",
911
+ black: "#000000"
912
+ }
913
+ },
914
+ CBJ: {
915
+ name: "Columbus Blue Jackets",
916
+ primaryColor: "#002654",
917
+ colors: {
918
+ unionBlue: "#002654",
919
+ goalRed: "#CE1126",
920
+ capitalSilver: "#A4A9AD"
921
+ }
922
+ },
923
+ DAL: {
924
+ name: "Dallas Stars",
925
+ primaryColor: "#006847",
926
+ colors: {
927
+ victoryGreen: "#006847",
928
+ silver: "#8F8F8C",
929
+ black: "#111111"
930
+ }
931
+ },
932
+ DET: {
933
+ name: "Detroit Red Wings",
934
+ primaryColor: "#CE1126",
935
+ colors: { red: "#CE1126", white: "#FFFFFF" }
936
+ },
937
+ EDM: {
938
+ name: "Edmonton Oilers",
939
+ primaryColor: "#041E42",
940
+ colors: { blue: "#041E42", orange: "#FF4C00" }
941
+ },
942
+ FLA: {
943
+ name: "Florida Panthers",
944
+ primaryColor: "#041E42",
945
+ colors: { navy: "#041E42", red: "#C8102E", tan: "#B9975B" }
946
+ },
947
+ LAK: {
948
+ name: "Los Angeles Kings",
949
+ primaryColor: "#111111",
950
+ colors: { black: "#111111", silver: "#A2AAAD", white: "#FFFFFF" }
951
+ },
952
+ MIN: {
953
+ name: "Minnesota Wild",
954
+ primaryColor: "#A6192E",
955
+ colors: {
956
+ ironRangeRed: "#A6192E",
957
+ forestGreen: "#154734",
958
+ gold: "#EAAA00",
959
+ minnesotaWheat: "#DDCBA4"
960
+ }
961
+ },
962
+ MTL: {
963
+ name: "Montreal Canadiens",
964
+ primaryColor: "#AF1E2D",
965
+ colors: { red: "#AF1E2D", blue: "#192168" }
966
+ },
967
+ NJD: {
968
+ name: "New Jersey Devils",
969
+ primaryColor: "#CE1126",
970
+ colors: { red: "#CE1126", black: "#000000", white: "#FFFFFF" }
971
+ },
972
+ NSH: {
973
+ name: "Nashville Predators",
974
+ primaryColor: "#FFB81C",
975
+ colors: { gold: "#FFB81C", navyBlue: "#041E42", white: "#FFFFFF" }
976
+ },
977
+ NYI: {
978
+ name: "New York Islanders",
979
+ primaryColor: "#00539B",
980
+ colors: { blue: "#00539B", orange: "#F47D30" }
981
+ },
982
+ NYR: {
983
+ name: "New York Rangers",
984
+ primaryColor: "#0038A8",
985
+ colors: { blue: "#0038A8", red: "#CE1126", white: "#FFFFFF" }
986
+ },
987
+ OTT: {
988
+ name: "Ottawa Senators",
989
+ primaryColor: "#000000",
990
+ colors: {
991
+ black: "#000000",
992
+ red: "#DA1A32",
993
+ gold: "#B79257",
994
+ white: "#FFFFFF"
995
+ }
996
+ },
997
+ PHI: {
998
+ name: "Philadelphia Flyers",
999
+ primaryColor: "#F74902",
1000
+ colors: {
1001
+ flyersOrange: "#F74902",
1002
+ black: "#000000",
1003
+ white: "#FFFFFF"
1004
+ }
1005
+ },
1006
+ PIT: {
1007
+ name: "Pittsburgh Penguins",
1008
+ primaryColor: "#000000",
1009
+ colors: {
1010
+ black: "#000000",
1011
+ gold: "#CFC493",
1012
+ yellow: "#FCB514",
1013
+ white: "#FFFFFF"
1014
+ }
1015
+ },
1016
+ SJS: {
1017
+ name: "San Jose Sharks",
1018
+ primaryColor: "#006D75",
1019
+ colors: {
1020
+ teal: "#006D75",
1021
+ orange: "#EA7200",
1022
+ black: "#000000",
1023
+ white: "#FFFFFF"
1024
+ }
1025
+ },
1026
+ SEA: {
1027
+ name: "Seattle Kraken",
1028
+ primaryColor: "#001628",
1029
+ colors: {
1030
+ deepSeaBlue: "#001628",
1031
+ iceBlue: "#99D9D9",
1032
+ boundlessBlue: "#355464",
1033
+ shadowBlue: "#68A2B9",
1034
+ redAlert: "#E9072B"
1035
+ }
1036
+ },
1037
+ STL: {
1038
+ name: "St. Louis Blues",
1039
+ primaryColor: "#002F87",
1040
+ colors: {
1041
+ blue: "#002F87",
1042
+ yellow: "#FCB514",
1043
+ navyBlue: "#041E42",
1044
+ white: "#FFFFFF"
1045
+ }
1046
+ },
1047
+ TBL: {
1048
+ name: "Tampa Bay Lightning",
1049
+ primaryColor: "#002868",
1050
+ colors: { blue: "#002868", white: "#FFFFFF" }
1051
+ },
1052
+ TOR: {
1053
+ name: "Toronto Maple Leafs",
1054
+ primaryColor: "#00205B",
1055
+ colors: { blue: "#00205B", white: "#FFFFFF" }
1056
+ },
1057
+ UTA: {
1058
+ name: "Utah Mammoth",
1059
+ primaryColor: "#69B3E7",
1060
+ colors: {
1061
+ mountainBlue: "#69B3E7",
1062
+ rockBlack: "#010101",
1063
+ saltWhite: "#FFFFFF"
1064
+ }
1065
+ },
1066
+ VAN: {
1067
+ name: "Vancouver Canucks",
1068
+ primaryColor: "#00205B",
1069
+ colors: {
1070
+ blue: "#00205B",
1071
+ green: "#00843D",
1072
+ darkBlue: "#041C2C",
1073
+ gray: "#99999A",
1074
+ white: "#FFFFFF"
1075
+ }
1076
+ },
1077
+ VGK: {
1078
+ name: "Vegas Golden Knights",
1079
+ primaryColor: "#B4975A",
1080
+ colors: {
1081
+ gold: "#B4975A",
1082
+ steelGray: "#333F42",
1083
+ red: "#C8102E",
1084
+ black: "#000000",
1085
+ white: "#FFFFFF"
1086
+ }
1087
+ },
1088
+ WSH: {
1089
+ name: "Washington Capitals",
1090
+ primaryColor: "#041E42",
1091
+ colors: { navy: "#041E42", red: "#C8102E", white: "#FFFFFF" }
1092
+ },
1093
+ WPG: {
1094
+ name: "Winnipeg Jets",
1095
+ primaryColor: "#041E42",
1096
+ colors: {
1097
+ navy: "#041E42",
1098
+ blue: "#004C97",
1099
+ red: "#AC162C",
1100
+ maroon: "#7B303E",
1101
+ darkGray: "#55565A",
1102
+ silver: "#8E9090",
1103
+ white: "#FFFFFF"
1104
+ }
1105
+ }
1106
+ };
1107
+ var HISTORICAL_TEAM_COLORS = {
1108
+ ANA: {
1109
+ period: "1993-2006",
1110
+ colors: {
1111
+ green: "#00685E",
1112
+ purple: "#532A44",
1113
+ yellow: "#FCC72C",
1114
+ black: "#241E24"
1115
+ }
1116
+ },
1117
+ ARI: {
1118
+ period: "1996-2014",
1119
+ colors: {
1120
+ brickRed: "#8C2633",
1121
+ green: "#154734",
1122
+ desertSand: "#DDCBA4",
1123
+ brown: "#A9431E",
1124
+ purple: "#5F259F"
1125
+ }
1126
+ },
1127
+ BUF: {
1128
+ period: "2006-2020",
1129
+ colors: {
1130
+ navyBlue: "#002654",
1131
+ yellow: "#FCB514",
1132
+ silver: "#ADAFAA",
1133
+ red: "#C8102E"
1134
+ }
1135
+ },
1136
+ CGY: {
1137
+ period: "1994-2020",
1138
+ colors: {
1139
+ red: "#C8102E",
1140
+ gold: "#F1BE48",
1141
+ black: "#111111",
1142
+ white: "#FFFFFF"
1143
+ }
1144
+ },
1145
+ LAK: {
1146
+ period: "1967-1988",
1147
+ colors: {
1148
+ purple: "#572A84",
1149
+ goldenYellow: "#FFC80C",
1150
+ white: "#FFFFFF"
1151
+ }
1152
+ },
1153
+ OTT: {
1154
+ period: "2007-2020",
1155
+ colors: {
1156
+ red: "#C52032",
1157
+ gold: "#C2912C",
1158
+ black: "#000000",
1159
+ white: "#FFFFFF"
1160
+ }
1161
+ }
1162
+ };
1163
+ var NHL_LOGO_ASSET_URL = "https://assets.nhle.com/logos/nhl/svg";
1164
+ function getTeamBranding(abbreviation) {
1165
+ const normalized = normalizeAbbrev(
1166
+ abbreviation
1167
+ );
1168
+ return TEAM_BRANDING[normalized];
1169
+ }
1170
+ function getTeamLogoUrl(abbreviation, options = {}) {
1171
+ const normalized = normalizeAbbrev(
1172
+ abbreviation
1173
+ );
1174
+ if (!getTeamBranding(normalized)) {
1175
+ throw new RangeError(
1176
+ `Unknown active NHL team abbreviation: ${abbreviation}`
1177
+ );
1178
+ }
1179
+ const theme = options.theme ?? "light";
1180
+ const secondary = options.secondary ? "_secondary" : "";
1181
+ return `${NHL_LOGO_ASSET_URL}/${normalized}${secondary}_${theme}.svg`;
1182
+ }
1183
+
1184
+ // src/utils/utils.ts
1185
+ function resolvePath(template, params) {
1186
+ let resolvedPath = template;
1187
+ for (const [key, value] of Object.entries(params)) {
1188
+ if (value === void 0) continue;
1189
+ resolvedPath = resolvedPath.replace(`{${key}}`, String(value));
1190
+ }
1191
+ return resolvedPath;
1192
+ }
1193
+
1194
+ exports.CayenneQueryBuilder = CayenneQueryBuilder;
1195
+ exports.HISTORICAL_TEAM_COLORS = HISTORICAL_TEAM_COLORS;
1196
+ exports.NHL = nhl_exports;
1197
+ exports.NHL_END_DATE = NHL_END_DATE;
1198
+ exports.NHL_START_DATE = NHL_START_DATE;
1199
+ exports.NHL_TIMEZONE = NHL_TIMEZONE;
1200
+ exports.TEAM_BRANDING = TEAM_BRANDING;
1201
+ exports.buildCayenneExp = buildCayenneExp;
1202
+ exports.createCayenneQuery = createCayenneQuery;
1203
+ exports.getCurrentNHLDate = getCurrentNHLDate;
1204
+ exports.getCurrentNHLMonth = getCurrentNHLMonth;
1205
+ exports.getCurrentNHLYear = getCurrentNHLYear;
1206
+ exports.getCurrentSeason = getCurrentSeason;
1207
+ exports.getNHLDate = getNHLDate;
1208
+ exports.getNHLMonth = getNHLMonth;
1209
+ exports.getSeason = getSeason;
1210
+ exports.getTeamBranding = getTeamBranding;
1211
+ exports.getTeamLogoUrl = getTeamLogoUrl;
1212
+ exports.getYear = getYear;
1213
+ exports.normalizeAbbrev = normalizeAbbrev;
1214
+ exports.resolvePath = resolvePath;
1215
+ //# sourceMappingURL=toolkit.cjs.map
1216
+ //# sourceMappingURL=toolkit.cjs.map