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