tbarequest 1.0.4 → 1.0.6

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/dist/index.mjs ADDED
@@ -0,0 +1,1331 @@
1
+ import { ArkErrors, type } from "arktype";
2
+
3
+ //#region src/utils.ts
4
+ async function tryCatch(promise) {
5
+ try {
6
+ return {
7
+ data: await promise,
8
+ error: null
9
+ };
10
+ } catch (error) {
11
+ return {
12
+ data: null,
13
+ error
14
+ };
15
+ }
16
+ }
17
+
18
+ //#endregion
19
+ //#region src/types/schemas/teams.ts
20
+ const Team_Simple = type({
21
+ key: "string",
22
+ team_number: "number",
23
+ nickname: "string",
24
+ name: "string",
25
+ city: "string | null",
26
+ state_prov: "string | null",
27
+ country: "string | null"
28
+ });
29
+ const Team = Team_Simple.and({
30
+ postal_code: "string | null",
31
+ "website?": "string | null",
32
+ rookie_year: "number | null"
33
+ });
34
+ const Award_Recipient = type({
35
+ team_key: "string | null",
36
+ awardee: "string | null"
37
+ });
38
+ const Award = type({
39
+ name: "string",
40
+ award_type: "number",
41
+ event_key: "string",
42
+ recipient_list: Award_Recipient.array(),
43
+ year: "number"
44
+ });
45
+ const Team_Robot = type({
46
+ year: "number",
47
+ robot_name: "string",
48
+ key: "string",
49
+ team_key: "string"
50
+ });
51
+ const Media = type({
52
+ type: "string",
53
+ foreign_key: "string",
54
+ "details?": type({ "[string]": "unknown" }),
55
+ preferred: "boolean?",
56
+ team_keys: "string[]",
57
+ direct_url: "string?",
58
+ view_url: "string?"
59
+ });
60
+
61
+ //#endregion
62
+ //#region src/types/schemas/districts.ts
63
+ const District_List = type({
64
+ abbreviation: "string",
65
+ display_name: "string",
66
+ key: "string",
67
+ year: "number"
68
+ });
69
+ const District_Ranking = type({
70
+ team_key: "string",
71
+ rank: "number",
72
+ rookie_bonus: "number?",
73
+ point_total: "number",
74
+ event_point: type({
75
+ district_cmp: "boolean",
76
+ total: "number",
77
+ alliance_points: "number",
78
+ elim_points: "number",
79
+ award_points: "number",
80
+ event_key: "string",
81
+ qual_points: "number"
82
+ }).array().optional()
83
+ });
84
+ const District_Advancement = type({
85
+ dcmp: "boolean",
86
+ cmp: "boolean"
87
+ });
88
+
89
+ //#endregion
90
+ //#region src/types/schemas/events.ts
91
+ const Webcast = type({
92
+ type: "'youtube' | 'twitch' | 'ustream' | 'iframe' | 'html5' | 'rtmp' | 'livestream' | 'direct_link' | 'mms' | 'justin' | 'stemtv' | 'dacast'",
93
+ channel: "string",
94
+ "date?": "string | null",
95
+ file: "(string | null)?"
96
+ });
97
+ const Event_Simple = type({
98
+ key: "string",
99
+ name: "string",
100
+ event_code: "string",
101
+ event_type: "number",
102
+ district: type(District_List, "|", "null"),
103
+ city: "string | null",
104
+ state_prov: "string | null",
105
+ country: "string | null",
106
+ start_date: "string",
107
+ end_date: "string",
108
+ year: "number"
109
+ });
110
+ const Event = Event_Simple.and({
111
+ short_name: "string | null",
112
+ event_type_string: "string",
113
+ week: "number | null",
114
+ address: "string | null",
115
+ postal_code: "string | null",
116
+ gmaps_place_id: "string | null",
117
+ gmaps_url: "string | null",
118
+ lat: "number | null",
119
+ lng: "number | null",
120
+ location_name: "string | null",
121
+ timezone: "string | null",
122
+ website: "string | null",
123
+ first_event_id: "string | null",
124
+ first_event_code: "string | null",
125
+ webcasts: Webcast.array(),
126
+ division_keys: "string[]",
127
+ parent_event_key: "string | null",
128
+ playoff_type: "number | null",
129
+ playoff_type_string: "string | null"
130
+ });
131
+ const WLT_Record = type({
132
+ wins: "number",
133
+ losses: "number",
134
+ ties: "number"
135
+ });
136
+ const Team_Event_Status_rank = type({
137
+ num_teams: "number | null",
138
+ ranking: type({
139
+ matches_played: "number | null",
140
+ qual_average: "number | null",
141
+ sort_orders: "number[] | null",
142
+ rank: "number | null",
143
+ dq: "number | null",
144
+ team_key: "string | null"
145
+ }).optional(),
146
+ sort_order_info: type({
147
+ precision: "number | null",
148
+ name: "string | null"
149
+ }, "|", "null").array(),
150
+ status: "string | null"
151
+ }).partial();
152
+ const Team_Event_Status_alliance_backup = type({
153
+ in: "string?",
154
+ out: "string?"
155
+ });
156
+ const Team_Event_Status_alliance = type({
157
+ name: "(string | null)?",
158
+ number: "number",
159
+ backup: type(Team_Event_Status_alliance_backup, "|", "null").optional(),
160
+ pick: "number"
161
+ });
162
+ const Team_Event_Status_playoff = type({
163
+ "level?": "'qm' | 'ef' | 'qf' | 'sf' | 'f'",
164
+ current_level_record: type(WLT_Record, "|", "null").optional(),
165
+ record: type(WLT_Record, "|", "null").optional(),
166
+ "status?": "'won' | 'eliminated' | 'playing'",
167
+ "playoff_average?": "number | null"
168
+ });
169
+ const Team_Event_Status = type({
170
+ alliance_status_str: "string?",
171
+ playoff_status_str: "string?",
172
+ overall_status_str: "string?",
173
+ next_match_key: "(string | null)?",
174
+ last_match_key: "(string | null)?",
175
+ playoff: type(Team_Event_Status_playoff, "|", "null").optional(),
176
+ qual: type(Team_Event_Status_rank, "|", "null").optional(),
177
+ alliance: type(Team_Event_Status_alliance, "|", "null").optional()
178
+ });
179
+ const Elimination_Alliance = type({
180
+ name: "(string | null)?",
181
+ backup: type({
182
+ in: "string",
183
+ out: "string"
184
+ }, "|", "null").optional(),
185
+ declines: "string[]",
186
+ picks: "string[]",
187
+ status: type({
188
+ playoff_average: "number | null",
189
+ level: "string",
190
+ record: type(WLT_Record, "|", "null"),
191
+ current_level_record: type(WLT_Record, "|", "null"),
192
+ status: "string"
193
+ }).partial().optional()
194
+ });
195
+
196
+ //#endregion
197
+ //#region src/types/schemas/matches.ts
198
+ const reef = type({
199
+ botRow: {
200
+ nodeA: "boolean",
201
+ nodeB: "boolean",
202
+ nodeC: "boolean",
203
+ nodeD: "boolean",
204
+ nodeE: "boolean",
205
+ nodeF: "boolean",
206
+ nodeG: "boolean",
207
+ nodeH: "boolean",
208
+ nodeI: "boolean",
209
+ nodeJ: "boolean",
210
+ nodeK: "boolean",
211
+ nodeL: "boolean"
212
+ },
213
+ midRow: {
214
+ nodeA: "boolean",
215
+ nodeB: "boolean",
216
+ nodeC: "boolean",
217
+ nodeD: "boolean",
218
+ nodeE: "boolean",
219
+ nodeF: "boolean",
220
+ nodeG: "boolean",
221
+ nodeH: "boolean",
222
+ nodeI: "boolean",
223
+ nodeJ: "boolean",
224
+ nodeK: "boolean",
225
+ nodeL: "boolean"
226
+ },
227
+ topRow: {
228
+ nodeA: "boolean",
229
+ nodeB: "boolean",
230
+ nodeC: "boolean",
231
+ nodeD: "boolean",
232
+ nodeE: "boolean",
233
+ nodeF: "boolean",
234
+ nodeG: "boolean",
235
+ nodeH: "boolean",
236
+ nodeI: "boolean",
237
+ nodeJ: "boolean",
238
+ nodeK: "boolean",
239
+ nodeL: "boolean"
240
+ },
241
+ trough: "number",
242
+ tba_botRowCount: "number",
243
+ tba_midRowCount: "number",
244
+ tba_topRowCount: "number"
245
+ });
246
+ const matchScoreBreakdownYearsAlliances = {
247
+ "2015": type({
248
+ adjust_points: "number",
249
+ auto_points: "number",
250
+ container_count_level1: "number",
251
+ container_count_level2: "number",
252
+ container_count_level3: "number",
253
+ container_count_level4: "number",
254
+ container_count_level5: "number",
255
+ container_count_level6: "number",
256
+ container_points: "number",
257
+ container_set: "boolean",
258
+ foul_count: "number",
259
+ foul_points: "number",
260
+ litter_count_container: "number",
261
+ litter_count_landfill: "number",
262
+ litter_count_unprocessed: "number",
263
+ litter_points: "number",
264
+ robot_set: "boolean",
265
+ teleop_points: "number",
266
+ total_points: "number",
267
+ tote_count_far: "number",
268
+ tote_count_near: "number",
269
+ tote_points: "number",
270
+ tote_set: "boolean",
271
+ tote_stack: "boolean"
272
+ }).partial(),
273
+ "2016": type({
274
+ adjustPoints: "number",
275
+ autoBoulderPoints: "number",
276
+ autoBouldersHigh: "number",
277
+ autoBouldersLow: "number",
278
+ autoCrossingPoints: "number",
279
+ autoPoints: "number",
280
+ autoReachPoints: "number",
281
+ breachPoints: "number",
282
+ capturePoints: "number",
283
+ foulCount: "number",
284
+ foulPoints: "number",
285
+ position1crossings: "number",
286
+ position2: "string",
287
+ position2crossings: "number",
288
+ position3: "string",
289
+ position3crossings: "number",
290
+ position4: "string",
291
+ position4crossings: "number",
292
+ position5: "string",
293
+ position5crossings: "number",
294
+ robot1Auto: "'Crossed' | 'Reached' | 'None'",
295
+ robot2Auto: "string",
296
+ robot3Auto: "string",
297
+ tba_rpEarned: "number",
298
+ techFoulCount: "number",
299
+ teleopBoulderPoints: "number",
300
+ teleopBouldersHigh: "number",
301
+ teleopBouldersLow: "number",
302
+ teleopChallengePoints: "number",
303
+ teleopCrossingPoints: "number",
304
+ teleopDefensesBreached: "boolean",
305
+ teleopPoints: "number",
306
+ teleopScalePoints: "number",
307
+ teleopTowerCaptured: "boolean",
308
+ totalPoints: "number",
309
+ towerEndStrength: "number",
310
+ towerFaceA: "string",
311
+ towerFaceB: "string",
312
+ towerFaceC: "string"
313
+ }).partial(),
314
+ "2017": type({
315
+ adjustPoints: "number",
316
+ autoFuelHigh: "number",
317
+ autoFuelLow: "number",
318
+ autoFuelPoints: "number",
319
+ autoMobilityPoints: "number",
320
+ autoPoints: "number",
321
+ autoRotorPoints: "number",
322
+ foulCount: "number",
323
+ foulPoints: "number",
324
+ kPaBonusPoints: "number",
325
+ kPaRankingPointAchieved: "boolean",
326
+ robot1Auto: "'Unknown' | 'Mobility' | 'None'",
327
+ robot2Auto: "'Unknown' | 'Mobility' | 'None'",
328
+ robot3Auto: "'Unknown' | 'Mobility' | 'None'",
329
+ rotor1Auto: "boolean",
330
+ rotor1Engaged: "boolean",
331
+ rotor2Auto: "boolean",
332
+ rotor2Engaged: "boolean",
333
+ rotor3Engaged: "boolean",
334
+ rotor4Engaged: "boolean",
335
+ rotorBonusPoints: "number",
336
+ rotorRankingPointAchieved: "boolean",
337
+ tba_rpEarned: "number",
338
+ techFoulCount: "number",
339
+ teleopFuelHigh: "number",
340
+ teleopFuelLow: "number",
341
+ teleopFuelPoints: "number",
342
+ teleopPoints: "number",
343
+ teleopRotorPoints: "number",
344
+ teleopTakeoffPoints: "number",
345
+ totalPoints: "number",
346
+ touchpadFar: "string",
347
+ touchpadMiddle: "string",
348
+ touchpadNear: "string"
349
+ }).partial(),
350
+ "2018": type({
351
+ adjustPoints: "number",
352
+ autoOwnershipPoints: "number",
353
+ autoPoints: "number",
354
+ autoQuestRankingPoint: "boolean",
355
+ autoRobot1: "string",
356
+ autoRobot2: "string",
357
+ autoRobot3: "string",
358
+ autoRunPoints: "number",
359
+ autoScaleOwnershipSec: "number",
360
+ autoSwitchAtZero: "boolean",
361
+ autoSwitchOwnershipSec: "number",
362
+ endgamePoints: "number",
363
+ endgameRobot1: "string",
364
+ endgameRobot2: "string",
365
+ endgameRobot3: "string",
366
+ faceTheBossRankingPoint: "boolean",
367
+ foulCount: "number",
368
+ foulPoints: "number",
369
+ rp: "number",
370
+ tba_gameData: "string",
371
+ techFoulCount: "number",
372
+ teleopOwnershipPoints: "number",
373
+ teleopPoints: "number",
374
+ teleopScaleBoostSec: "number",
375
+ teleopScaleForceSec: "number",
376
+ teleopScaleOwnershipSec: "number",
377
+ teleopSwitchBoostSec: "number",
378
+ teleopSwitchForceSec: "number",
379
+ teleopSwitchOwnershipSec: "number",
380
+ totalPoints: "number",
381
+ vaultBoostPlayed: "number",
382
+ vaultBoostTotal: "number",
383
+ vaultForcePlayed: "number",
384
+ vaultForceTotal: "number",
385
+ vaultLevitatePlayed: "number",
386
+ vaultLevitateTotal: "number",
387
+ vaultPoints: "number"
388
+ }).partial(),
389
+ "2019": type({
390
+ adjustPoints: "number",
391
+ autoPoints: "number",
392
+ bay1: "string",
393
+ bay2: "string",
394
+ bay3: "string",
395
+ bay4: "string",
396
+ bay5: "string",
397
+ bay6: "string",
398
+ bay7: "string",
399
+ bay8: "string",
400
+ cargoPoints: "number",
401
+ completeRocketRankingPoint: "boolean",
402
+ completedRocketFar: "boolean",
403
+ completedRocketNear: "boolean",
404
+ endgameRobot1: "string",
405
+ endgameRobot2: "string",
406
+ endgameRobot3: "string",
407
+ foulCount: "number",
408
+ foulPoints: "number",
409
+ habClimbPoints: "number",
410
+ habDockingRankingPoint: "boolean",
411
+ habLineRobot1: "string",
412
+ habLineRobot2: "string",
413
+ habLineRobot3: "string",
414
+ hatchPanelPoints: "number",
415
+ lowLeftRocketFar: "string",
416
+ lowLeftRocketNear: "string",
417
+ lowRightRocketFar: "string",
418
+ lowRightRocketNear: "string",
419
+ midLeftRocketFar: "string",
420
+ midLeftRocketNear: "string",
421
+ midRightRocketFar: "string",
422
+ midRightRocketNear: "string",
423
+ preMatchBay1: "string",
424
+ preMatchBay2: "string",
425
+ preMatchBay3: "string",
426
+ preMatchBay6: "string",
427
+ preMatchBay7: "string",
428
+ preMatchBay8: "string",
429
+ preMatchLevelRobot1: "string",
430
+ preMatchLevelRobot2: "string",
431
+ preMatchLevelRobot3: "string",
432
+ rp: "number",
433
+ sandStormBonusPoints: "number",
434
+ techFoulCount: "number",
435
+ teleopPoints: "number",
436
+ topLeftRocketFar: "string",
437
+ topLeftRocketNear: "string",
438
+ topRightRocketFar: "string",
439
+ topRightRocketNear: "string",
440
+ totalPoints: "number"
441
+ }).partial(),
442
+ "2020": type({
443
+ adjustPoints: "number",
444
+ autoCellPoints: "number",
445
+ autoCellsBottom: "number",
446
+ autoCellsInner: "number",
447
+ autoCellsOuter: "number",
448
+ autoInitLinePoints: "number",
449
+ autoPoints: "number",
450
+ controlPanelPoints: "number",
451
+ endgamePoints: "number",
452
+ endgameRobot1: "string",
453
+ endgameRobot2: "string",
454
+ endgameRobot3: "string",
455
+ endgameRungIsLevel: "string",
456
+ foulCount: "number",
457
+ foulPoints: "number",
458
+ initLineRobot1: "string",
459
+ initLineRobot2: "string",
460
+ initLineRobot3: "string",
461
+ rp: "number",
462
+ shieldEnergizedRankingPoint: "boolean",
463
+ shieldOperationalRankingPoint: "boolean",
464
+ stage1Activated: "boolean",
465
+ stage2Activated: "boolean",
466
+ stage3Activated: "boolean",
467
+ stage3TargetColor: "string",
468
+ tba_numRobotsHanging: "number",
469
+ tba_shieldEnergizedRankingPointFromFoul: "boolean",
470
+ techFoulCount: "number",
471
+ teleopCellPoints: "number",
472
+ teleopCellsBottom: "number",
473
+ teleopCellsInner: "number",
474
+ teleopCellsOuter: "number",
475
+ teleopPoints: "number",
476
+ totalPoints: "number"
477
+ }).partial(),
478
+ "2022": type({
479
+ adjustPoints: "number",
480
+ autoCargoLowerBlue: "number",
481
+ autoCargoLowerFar: "number",
482
+ autoCargoLowerNear: "number",
483
+ autoCargoLowerRed: "number",
484
+ autoCargoPoints: "number",
485
+ autoCargoTotal: "number",
486
+ autoCargoUpperBlue: "number",
487
+ autoCargoUpperFar: "number",
488
+ autoCargoUpperNear: "number",
489
+ autoCargoUpperRed: "number",
490
+ autoPoints: "number",
491
+ autoTaxiPoints: "number",
492
+ cargoBonusRankingPoint: "boolean",
493
+ endgamePoints: "number",
494
+ endgameRobot1: "'Transversal' | 'High' | 'Mid' | 'Low' | 'None'",
495
+ endgameRobot2: "'Transversal' | 'High' | 'Mid' | 'Low' | 'None'",
496
+ endgameRobot3: "'Transversal' | 'High' | 'Mid' | 'Low' | 'None'",
497
+ foulCount: "number",
498
+ foulPoints: "number",
499
+ hangarBonusRankingPoint: "boolean",
500
+ matchCargoTotal: "number",
501
+ quintetAchieved: "boolean",
502
+ rp: "number",
503
+ taxiRobot1: "'Yes' | 'No'",
504
+ taxiRobot2: "'Yes' | 'No'",
505
+ taxiRobot3: "'Yes' | 'No'",
506
+ techFoulCount: "number",
507
+ teleopCargoLowerBlue: "number",
508
+ teleopCargoLowerFar: "number",
509
+ teleopCargoLowerNear: "number",
510
+ teleopCargoLowerRed: "number",
511
+ teleopCargoPoints: "number",
512
+ teleopCargoTotal: "number",
513
+ teleopCargoUpperBlue: "number",
514
+ teleopCargoUpperFar: "number",
515
+ teleopCargoUpperNear: "number",
516
+ teleopCargoUpperRed: "number",
517
+ teleopPoints: "number",
518
+ totalPoints: "number"
519
+ }).partial(),
520
+ "2023": type({
521
+ activationBonusAchieved: "boolean",
522
+ adjustPoints: "number",
523
+ autoBridgeState: "'NotLevel' | 'Level'",
524
+ autoChargeStationPoints: "number",
525
+ autoChargeStationRobot1: "'None' | 'Docked'",
526
+ autoChargeStationRobot2: "'None' | 'Docked'",
527
+ autoChargeStationRobot3: "'None' | 'Docked'",
528
+ autoCommunity: {
529
+ B: "('None' | 'Cube' | 'Cone')[]",
530
+ M: "('None' | 'Cube' | 'Cone')[]",
531
+ T: "('None' | 'Cube' | 'Cone')[]"
532
+ },
533
+ autoDocked: "boolean",
534
+ autoGamePieceCount: "number",
535
+ autoGamePiecePoints: "number",
536
+ autoMobilityPoints: "number",
537
+ autoPoints: "number",
538
+ coopGamePieceCount: "number",
539
+ coopertitionCriteriaMet: "boolean",
540
+ endGameBridgeState: "'NotLevel' | 'Level'",
541
+ endGameChargeStationPoints: "number",
542
+ endGameChargeStationRobot1: "'None' | 'Docked' | 'Parked'",
543
+ endGameChargeStationRobot2: "'None' | 'Docked' | 'Parked'",
544
+ endGameChargeStationRobot3: "'None' | 'Docked' | 'Parked'",
545
+ endGameParkPoints: "number",
546
+ foulCount: "number",
547
+ foulPoints: "number",
548
+ linkPoints: "number",
549
+ links: type({
550
+ nodes: "number[]",
551
+ row: "'Bottom' | 'Mid' | 'Top'"
552
+ }).array(),
553
+ mobilityRobot1: "'Yes' | 'No'",
554
+ mobilityRobot2: "'Yes' | 'No'",
555
+ mobilityRobot3: "'Yes' | 'No'",
556
+ rp: "number",
557
+ sustainabilityBonusAchieved: "boolean",
558
+ techFoulCount: "number",
559
+ teleopCommunity: {
560
+ B: "('None' | 'Cube' | 'Cone')[]",
561
+ M: "('None' | 'Cube' | 'Cone')[]",
562
+ T: "('None' | 'Cube' | 'Cone')[]"
563
+ },
564
+ teleopGamePieceCount: "number",
565
+ teleopGamePiecePoints: "number",
566
+ teleopPoints: "number",
567
+ totalChargeStationPoints: "number",
568
+ totalPoints: "number"
569
+ }).partial(),
570
+ "2024": type({
571
+ adjustPoints: "number",
572
+ autoAmpNoteCount: "number",
573
+ autoAmpNotePoints: "number",
574
+ autoLeavePoints: "number",
575
+ autoLineRobot1: "string",
576
+ autoLineRobot2: "string",
577
+ autoLineRobot3: "string",
578
+ autoPoints: "number",
579
+ autoSpeakerNoteCount: "number",
580
+ autoSpeakerNotePoints: "number",
581
+ autoTotalNotePoints: "number",
582
+ coopNotePlayed: "boolean",
583
+ coopertitionBonusAchieved: "boolean",
584
+ coopertitionCriteriaMet: "boolean",
585
+ endGameHarmonyPoints: "number",
586
+ endGameNoteInTrapPoints: "number",
587
+ endGameOnStagePoints: "number",
588
+ endGameParkPoints: "number",
589
+ endGameRobot1: "string",
590
+ endGameRobot2: "string",
591
+ endGameRobot3: "string",
592
+ endGameSpotLightBonusPoints: "number",
593
+ endGameTotalStagePoints: "number",
594
+ ensembleBonusAchieved: "boolean",
595
+ ensembleBonusOnStageRobotsThreshold: "number",
596
+ ensembleBonusStagePointsThreshold: "number",
597
+ foulCount: "number",
598
+ foulPoints: "number",
599
+ g206Penalty: "boolean",
600
+ g408Penalty: "boolean",
601
+ g424Penalty: "boolean",
602
+ melodyBonusAchieved: "boolean",
603
+ melodyBonusThreshold: "number",
604
+ melodyBonusThresholdCoop: "number",
605
+ melodyBonusThresholdNonCoop: "number",
606
+ micCenterStage: "boolean",
607
+ micStageLeft: "boolean",
608
+ micStageRight: "boolean",
609
+ rp: "number",
610
+ techFoulCount: "number",
611
+ teleopAmpNoteCount: "number",
612
+ teleopAmpNotePoints: "number",
613
+ teleopPoints: "number",
614
+ teleopSpeakerNoteAmplifiedCount: "number",
615
+ teleopSpeakerNoteAmplifiedPoints: "number",
616
+ teleopSpeakerNoteCount: "number",
617
+ teleopSpeakerNotePoints: "number",
618
+ teleopTotalNotePoints: "number",
619
+ totalPoints: "number",
620
+ trapCenterStage: "boolean",
621
+ trapStageLeft: "boolean",
622
+ trapStageRight: "boolean"
623
+ }).partial(),
624
+ "2025": type({
625
+ adjustPoints: "number",
626
+ algaePoints: "number",
627
+ autoBonusAchieved: "boolean",
628
+ autoCoralCount: "number",
629
+ autoCoralPoints: "number",
630
+ autoLineRobot1: "'Yes' | 'No'",
631
+ autoLineRobot2: "'Yes' | 'No'",
632
+ autoLineRobot3: "'Yes' | 'No'",
633
+ autoMobilityPoints: "number",
634
+ autoPoints: "number",
635
+ autoReef: reef,
636
+ bargeBonusAchieved: "boolean",
637
+ coopertitionCriteriaMet: "boolean",
638
+ coralBonusAchieved: "boolean",
639
+ endGameBargePoints: "number",
640
+ endGameRobot1: "'None' | 'Parked' | 'ShallowCage' | 'DeepCage'",
641
+ endGameRobot2: "'None' | 'Parked' | 'ShallowCage' | 'DeepCage'",
642
+ endGameRobot3: "'None' | 'Parked' | 'ShallowCage' | 'DeepCage'",
643
+ foulCount: "number",
644
+ foulPoints: "number",
645
+ g206Penalty: "boolean",
646
+ g410Penalty: "boolean",
647
+ g418Penalty: "boolean",
648
+ g428Penalty: "boolean",
649
+ netAlgaeCount: "number",
650
+ rp: "number",
651
+ techFoulCount: "number",
652
+ teleopCoralCount: "number",
653
+ teleopCoralPoints: "number",
654
+ teleopPoints: "number",
655
+ teleopReef: reef,
656
+ totalPoints: "number",
657
+ wallAlgaeCount: "number"
658
+ }).partial(),
659
+ "2026": type({
660
+ adjustPoints: "number",
661
+ autoTowerPoints: "number",
662
+ autoTowerRobot1: "'Level1' | 'Level2' | 'Level3' | 'None'",
663
+ autoTowerRobot2: "'Level1' | 'Level2' | 'Level3' | 'None'",
664
+ autoTowerRobot3: "'Level1' | 'Level2' | 'Level3' | 'None'",
665
+ endGameTowerPoints: "number",
666
+ endGameTowerRobot1: "'Level1' | 'Level2' | 'Level3' | 'None'",
667
+ endGameTowerRobot2: "'Level1' | 'Level2' | 'Level3' | 'None'",
668
+ endGameTowerRobot3: "'Level1' | 'Level2' | 'Level3' | 'None'",
669
+ energizedAcheived: "boolean",
670
+ foulPoints: "number",
671
+ g206Penalty: "boolean",
672
+ hubScore: {
673
+ autoCount: "number",
674
+ autoPoints: "number",
675
+ endgameCount: "number",
676
+ endgamePoints: "number",
677
+ shift1Count: "number",
678
+ shift1Points: "number",
679
+ shift2Count: "number",
680
+ shift2Points: "number",
681
+ shift3Count: "number",
682
+ shift3Points: "number",
683
+ shift4Count: "number",
684
+ shift4Points: "number",
685
+ teleopCount: "number",
686
+ teleopPoints: "number",
687
+ totalCount: "number",
688
+ totalPoints: "number",
689
+ transitionCount: "number",
690
+ transitionPoints: "number"
691
+ },
692
+ majorFoulCount: "number",
693
+ minorFoulCount: "number",
694
+ rp: "number",
695
+ superchargedAcheived: "boolean",
696
+ totalAutoPoints: "number",
697
+ totalPoints: "number",
698
+ totalTeleopPoints: "number",
699
+ totalTowerPoints: "number",
700
+ traversalAchieved: "boolean"
701
+ }).partial()
702
+ };
703
+ const matchScoreBreakdownYearsMatches = {
704
+ "2015": type({
705
+ red: matchScoreBreakdownYearsAlliances["2015"],
706
+ blue: matchScoreBreakdownYearsAlliances["2015"],
707
+ coopertition: "'None' | 'Unknown' | 'Stack'",
708
+ coopertition_points: "number",
709
+ yearOfCompetition: "2015"
710
+ }),
711
+ "2016": type({
712
+ red: matchScoreBreakdownYearsAlliances["2016"],
713
+ blue: matchScoreBreakdownYearsAlliances["2016"],
714
+ yearOfCompetition: "2016"
715
+ }),
716
+ "2017": type({
717
+ red: matchScoreBreakdownYearsAlliances["2017"],
718
+ blue: matchScoreBreakdownYearsAlliances["2017"],
719
+ yearOfCompetition: "2017"
720
+ }),
721
+ "2018": type({
722
+ red: matchScoreBreakdownYearsAlliances["2018"],
723
+ blue: matchScoreBreakdownYearsAlliances["2018"],
724
+ yearOfCompetition: "2018"
725
+ }),
726
+ "2019": type({
727
+ red: matchScoreBreakdownYearsAlliances["2019"],
728
+ blue: matchScoreBreakdownYearsAlliances["2019"],
729
+ yearOfCompetition: "2019"
730
+ }),
731
+ "2020": type({
732
+ red: matchScoreBreakdownYearsAlliances["2020"],
733
+ blue: matchScoreBreakdownYearsAlliances["2020"],
734
+ yearOfCompetition: "2020"
735
+ }),
736
+ "2022": type({
737
+ red: matchScoreBreakdownYearsAlliances["2022"],
738
+ blue: matchScoreBreakdownYearsAlliances["2022"],
739
+ yearOfCompetition: "2022"
740
+ }),
741
+ "2023": type({
742
+ red: matchScoreBreakdownYearsAlliances["2023"],
743
+ blue: matchScoreBreakdownYearsAlliances["2023"],
744
+ yearOfCompetition: "2023"
745
+ }),
746
+ "2024": type({
747
+ red: matchScoreBreakdownYearsAlliances["2024"],
748
+ blue: matchScoreBreakdownYearsAlliances["2024"],
749
+ yearOfCompetition: "2024"
750
+ }),
751
+ "2025": type({
752
+ red: matchScoreBreakdownYearsAlliances["2025"],
753
+ blue: matchScoreBreakdownYearsAlliances["2025"],
754
+ yearOfCompetition: "2025"
755
+ }),
756
+ "2026": type({
757
+ red: matchScoreBreakdownYearsAlliances["2026"],
758
+ blue: matchScoreBreakdownYearsAlliances["2026"],
759
+ yearOfCompetition: "2026"
760
+ })
761
+ };
762
+ const msb = matchScoreBreakdownYearsMatches;
763
+ const Match_alliance = type({
764
+ score: "number | null",
765
+ team_keys: "string[]",
766
+ surrogate_team_keys: "string[]",
767
+ dq_team_keys: "string[]"
768
+ });
769
+ const Match_Simple = type({
770
+ key: "string",
771
+ comp_level: "'qm' | 'ef' | 'qf' | 'sf' |'f'",
772
+ set_number: "number",
773
+ match_number: "number",
774
+ alliances: type({
775
+ red: Match_alliance,
776
+ blue: Match_alliance
777
+ }),
778
+ winning_alliance: "'red' | 'blue' | ''",
779
+ event_key: "string",
780
+ time: "number | null",
781
+ actual_time: "number | null",
782
+ predicted_time: "number | null"
783
+ });
784
+ const Match = Match_Simple.and({
785
+ videos: type({
786
+ type: "string",
787
+ key: "string"
788
+ }).array(),
789
+ score_breakdown: msb["2015"].or(msb["2016"]).or(msb["2017"]).or(msb["2018"]).or(msb["2019"]).or(msb["2020"]).or(msb["2022"]).or(msb["2023"]).or(msb["2024"]).or(msb["2025"])
790
+ });
791
+
792
+ //#endregion
793
+ //#region src/types/endpoints/teams.ts
794
+ const teamEndpoints = {
795
+ "/teams/{page_num}": {
796
+ schema: Team.array(),
797
+ arguments: type(["number"])
798
+ },
799
+ "/teams/{page_num}/simple": {
800
+ schema: Team_Simple.array(),
801
+ arguments: type(["number"])
802
+ },
803
+ "/teams/{page_num}/keys": {
804
+ schema: type("string[]"),
805
+ arguments: type(["number"])
806
+ },
807
+ "/teams/{year}/{page_num}": {
808
+ schema: Team.array(),
809
+ arguments: type(["number", "number"])
810
+ },
811
+ "/teams/{year}/{page_num}/simple": {
812
+ schema: Team_Simple.array(),
813
+ arguments: type(["number", "number"])
814
+ },
815
+ "/teams/{year}/{page_num}/keys": {
816
+ schema: type("string[]"),
817
+ arguments: type(["number", "number"])
818
+ },
819
+ "/team/{team_key}": {
820
+ schema: Team,
821
+ arguments: type(["string"])
822
+ },
823
+ "/team/{team_key}/simple": {
824
+ schema: Team_Simple,
825
+ arguments: type(["string"])
826
+ },
827
+ "/team/{team_key}/history": {
828
+ schema: type({
829
+ events: Event.array(),
830
+ awards: Award.array()
831
+ }),
832
+ arguments: type(["string"])
833
+ },
834
+ "/team/{team_key}/years_participated": {
835
+ schema: type("number[]"),
836
+ arguments: type(["string"])
837
+ },
838
+ "/team/{team_key}/districts": {
839
+ schema: District_List.array(),
840
+ arguments: type(["string"])
841
+ },
842
+ "/team/{team_key}/robots": {
843
+ schema: Team_Robot.array(),
844
+ arguments: type(["string"])
845
+ },
846
+ "/team/{team_key}/events": {
847
+ schema: Event.array(),
848
+ arguments: type(["string"])
849
+ },
850
+ "/team/{team_key}/events/simple": {
851
+ schema: Event_Simple.array(),
852
+ arguments: type(["string"])
853
+ },
854
+ "/team/{team_key}/events/keys": {
855
+ schema: type("string[]"),
856
+ arguments: type(["string"])
857
+ },
858
+ "/team/{team_key}/events/{year}": {
859
+ schema: Event.array(),
860
+ arguments: type(["string", "number"])
861
+ },
862
+ "/team/{team_key}/events/{year}/simple": {
863
+ schema: Event_Simple.array(),
864
+ arguments: type(["string", "number"])
865
+ },
866
+ "/team/{team_key}/events/{year}/keys": {
867
+ schema: type("string[]"),
868
+ arguments: type(["string", "number"])
869
+ },
870
+ "/team/{team_key}/events/{year}/statuses": {
871
+ schema: type({ "[string]": Team_Event_Status }),
872
+ arguments: type(["string", "number"])
873
+ },
874
+ "/team/{team_key}/event/{event_key}/matches": {
875
+ schema: Match.array(),
876
+ arguments: type(["string", "string"]),
877
+ transformMatch: ({ key: eventKey }, schema) => {
878
+ if (eventKey && parseInt(eventKey.slice(0, 4)) && Array.isArray(schema) && schema.every((v) => v && typeof v === "object")) for (const member of schema) member["score_breakdown"]["yearOfCompetition"] = parseInt(eventKey.slice(0, 4));
879
+ return schema;
880
+ }
881
+ },
882
+ "/team/{team_key}/event/{event_key}/matches/simple": {
883
+ schema: Match_Simple.array(),
884
+ arguments: type(["string", "string"])
885
+ },
886
+ "/team/{team_key}/event/{event_key}/matches/keys": {
887
+ schema: type("string[]"),
888
+ arguments: type(["string", "string"])
889
+ },
890
+ "/team/{team_key}/event/{event_key}/awards": {
891
+ schema: Award.array(),
892
+ arguments: type(["string", "string"])
893
+ },
894
+ "/team/{team_key}/event/{event_key}/status": {
895
+ schema: type(Team_Event_Status, "|", "null"),
896
+ arguments: type(["string", "string"])
897
+ },
898
+ "/team/{team_key}/awards": {
899
+ schema: Award.array(),
900
+ arguments: type(["string"])
901
+ },
902
+ "/team/{team_key}/awards/{year}": {
903
+ schema: Award.array(),
904
+ arguments: type(["string", "number"])
905
+ },
906
+ "/team/{team_key}/matches/{year}": {
907
+ schema: Match.array(),
908
+ arguments: type(["string", "number"]),
909
+ transformMatch: ({ year }, schema) => {
910
+ if (year && Array.isArray(schema) && schema.every((v) => v && typeof v === "object")) for (const member of schema) member["score_breakdown"]["yearOfCompetition"] = year;
911
+ return schema;
912
+ }
913
+ },
914
+ "/team/{team_key}/matches/{year}/simple": {
915
+ schema: Match_Simple.array(),
916
+ arguments: type(["string", "number"])
917
+ },
918
+ "/team/{team_key}/matches/{year}/keys": {
919
+ schema: type("string[]"),
920
+ arguments: type(["string", "number"])
921
+ },
922
+ "/team/{team_key}/media/{year}": {
923
+ schema: Media.array(),
924
+ arguments: type(["string", "number"])
925
+ },
926
+ "/team/{team_key}/media/tag/{media_tag}": {
927
+ schema: Media.array(),
928
+ arguments: type(["string", "string"])
929
+ },
930
+ "/team/{team_key}/media/tag/{media_tag}/{year}": {
931
+ schema: Media.array(),
932
+ arguments: type([
933
+ "string",
934
+ "string",
935
+ "number"
936
+ ])
937
+ },
938
+ "/team/{team_key}/social_media": {
939
+ schema: Media.array(),
940
+ arguments: type(["string"])
941
+ }
942
+ };
943
+
944
+ //#endregion
945
+ //#region src/types/schemas/status.ts
946
+ const API_Status_App_Version = type({
947
+ min_app_version: "number",
948
+ latest_app_version: "number"
949
+ });
950
+
951
+ //#endregion
952
+ //#region src/types/endpoints/status.ts
953
+ const status = type({
954
+ current_season: "number",
955
+ max_season: "number",
956
+ is_datafeed_down: "boolean",
957
+ down_events: "string[]",
958
+ ios: API_Status_App_Version,
959
+ android: API_Status_App_Version
960
+ });
961
+ const statusEndpoints = { "/status": {
962
+ schema: status,
963
+ arguments: type([])
964
+ } };
965
+
966
+ //#endregion
967
+ //#region src/types/endpoints/events.ts
968
+ const rankings = type({
969
+ rankings: type({
970
+ matches_played: "number",
971
+ qual_average: "number | null",
972
+ extra_stats: "number[]",
973
+ sort_orders: "number[] | null",
974
+ record: type(WLT_Record, "|", "null"),
975
+ rank: "number",
976
+ dq: "number",
977
+ team_key: "string"
978
+ }).array(),
979
+ extra_stats_info: type({
980
+ precision: "number",
981
+ name: "string"
982
+ }).array(),
983
+ sort_order_info: type({
984
+ precision: "number",
985
+ name: "string"
986
+ }).array()
987
+ });
988
+ const eventPoints = type({
989
+ points: type({ "[string]": type({
990
+ total: "number",
991
+ alliance_points: "number",
992
+ elim_points: "number",
993
+ award_points: "number",
994
+ qual_points: "number"
995
+ }) }),
996
+ "tiebreakers?": type({ "[string]": type({
997
+ highest_qual_scores: "number[]",
998
+ qual_points: "number"
999
+ }).partial() })
1000
+ });
1001
+ const eventEndpoints = {
1002
+ "/events/{year}": {
1003
+ schema: Event.array(),
1004
+ arguments: type(["number"])
1005
+ },
1006
+ "/events/{year}/simple": {
1007
+ schema: Event_Simple.array(),
1008
+ arguments: type(["number"])
1009
+ },
1010
+ "/events/{year}/keys": {
1011
+ schema: type("string[]"),
1012
+ arguments: type(["number"])
1013
+ },
1014
+ "/event/{event_key}": {
1015
+ schema: Event,
1016
+ arguments: type(["string"])
1017
+ },
1018
+ "/event/{event_key}/simple": {
1019
+ schema: Event_Simple,
1020
+ arguments: type(["string"])
1021
+ },
1022
+ "/event/{event_key}/alliances": {
1023
+ schema: type(Elimination_Alliance.array(), "|", "null"),
1024
+ arguments: type(["string"])
1025
+ },
1026
+ "/event/{event_key}/insights": {
1027
+ schema: type({
1028
+ qual: "unknown",
1029
+ playoff: "unknown"
1030
+ }, "|", "null"),
1031
+ arguments: type(["string"])
1032
+ },
1033
+ "/event/{event_key}/oprs": {
1034
+ schema: type({
1035
+ oprs: { "[string]": "number" },
1036
+ dprs: { "[string]": "number" },
1037
+ ccwms: { "[string]": "number" }
1038
+ }),
1039
+ arguments: type(["string"])
1040
+ },
1041
+ "/event/{event_key}/coprs": {
1042
+ schema: type({ "[string]": { "[string]": "number" } }),
1043
+ arguments: type(["string"])
1044
+ },
1045
+ "/event/{event_key}/predictions": {
1046
+ schema: type({ "[string]": "unknown" }, "|", "null"),
1047
+ arguments: type(["string"])
1048
+ },
1049
+ "/event/{event_key}/rankings": {
1050
+ schema: type(rankings, "|", "null"),
1051
+ arguments: type(["string"])
1052
+ },
1053
+ "/event/{event_key}/district_points": {
1054
+ schema: type(eventPoints, "|", "null"),
1055
+ arguments: type(["string"])
1056
+ },
1057
+ "/event/{event_key}/regional_champs_pool_points": {
1058
+ schema: type(eventPoints, "|", "null"),
1059
+ arguments: type(["string"])
1060
+ },
1061
+ "/event/{event_key}/advancement_points": {
1062
+ schema: type(eventPoints, "|", "null"),
1063
+ arguments: type(["string"])
1064
+ },
1065
+ "/event/{event_key}/teams": {
1066
+ schema: Team.array(),
1067
+ arguments: type(["string"])
1068
+ },
1069
+ "/event/{event_key}/teams/simple": {
1070
+ schema: Team_Simple.array(),
1071
+ arguments: type(["string"])
1072
+ },
1073
+ "/event/{event_key}/teams/keys": {
1074
+ schema: type("string[]"),
1075
+ arguments: type(["string"])
1076
+ },
1077
+ "/event/{event_key}/teams/statuses": {
1078
+ schema: type({ "[string]": Team_Event_Status }),
1079
+ arguments: type(["string"])
1080
+ },
1081
+ "/event/{event_key}/matches": {
1082
+ schema: Match.array(),
1083
+ arguments: type(["string"]),
1084
+ transformMatch: ({ key }, schema) => {
1085
+ if (key && parseInt(key.slice(0, 4)) && Array.isArray(schema) && schema.every((v) => v && typeof v === "object")) for (const member of schema) member["score_breakdown"]["yearOfCompetition"] = parseInt(key.slice(0, 4));
1086
+ return schema;
1087
+ }
1088
+ },
1089
+ "/event/{event_key}/matches/simple": {
1090
+ schema: Match_Simple.array(),
1091
+ arguments: type(["string"])
1092
+ },
1093
+ "/event/{event_key}/matches/keys": {
1094
+ schema: type("string[]"),
1095
+ arguments: type(["string"])
1096
+ },
1097
+ "/event/{event_key}/awards": {
1098
+ schema: Award.array(),
1099
+ arguments: type(["string"])
1100
+ },
1101
+ "/event/{event_key}/team_media": {
1102
+ schema: Media.array(),
1103
+ arguments: type(["string"])
1104
+ }
1105
+ };
1106
+
1107
+ //#endregion
1108
+ //#region src/types/endpoints/matches.ts
1109
+ const matchEndpoints = {
1110
+ "/match/{match_key}": {
1111
+ schema: Match,
1112
+ arguments: type(["string"]),
1113
+ transformMatch: ({ key: eventKey }, schema) => {
1114
+ if (eventKey && parseInt(eventKey.slice(0, 4)) && typeof schema === "object" && schema) {
1115
+ let newSchema = schema;
1116
+ newSchema["score_breakdown"]["yearOfCompetition"] = parseInt(eventKey.slice(0, 4));
1117
+ return newSchema;
1118
+ }
1119
+ return schema;
1120
+ }
1121
+ },
1122
+ "/match/{match_key}/simple": {
1123
+ schema: Match_Simple,
1124
+ arguments: type(["string"])
1125
+ }
1126
+ };
1127
+
1128
+ //#endregion
1129
+ //#region src/types/endpoints/districts.ts
1130
+ const districtEndpoints = {
1131
+ "/districts/{year}": {
1132
+ schema: District_List.array(),
1133
+ arguments: type(["number"])
1134
+ },
1135
+ "/district/{district_abbreviation}/history": {
1136
+ schema: District_List.array(),
1137
+ arguments: type(["string"])
1138
+ },
1139
+ "/district/{district_key}/events": {
1140
+ schema: Event.array(),
1141
+ arguments: type(["string"])
1142
+ },
1143
+ "/district/{district_key}/awards": {
1144
+ schema: Award.array(),
1145
+ arguments: type(["string"])
1146
+ },
1147
+ "/district/{district_key}/events/simple": {
1148
+ schema: Event_Simple.array(),
1149
+ arguments: type(["string"])
1150
+ },
1151
+ "/district/{district_key}/events/keys": {
1152
+ schema: type("string[]"),
1153
+ arguments: type(["string"])
1154
+ },
1155
+ "/district/{district_key}/teams": {
1156
+ schema: Team.array(),
1157
+ arguments: type(["string"])
1158
+ },
1159
+ "/district/{district_key}/teams/simple": {
1160
+ schema: Team_Simple.array(),
1161
+ arguments: type(["string"])
1162
+ },
1163
+ "/district/{district_key}/teams/keys": {
1164
+ schema: type("string[]"),
1165
+ arguments: type(["string"])
1166
+ },
1167
+ "/district/{district_key}/rankings": {
1168
+ schema: type(District_Ranking.array(), "|", "null"),
1169
+ arguments: type(["string"])
1170
+ },
1171
+ "/district/{district_key}/advancement": {
1172
+ schema: type({ "[string]": District_Advancement }, "|", "null"),
1173
+ arguments: type(["string"])
1174
+ }
1175
+ };
1176
+
1177
+ //#endregion
1178
+ //#region src/types/schemas/regionalAdvancements.ts
1179
+ const Regional_Advancement = type({
1180
+ cmp: "boolean",
1181
+ cmp_status: "'NotInvited' | 'PreQualified' | 'EventQualified' | 'PoolQualified' | 'Declined'",
1182
+ qualifying_event: "string?",
1183
+ qualifying_award_name: "string?",
1184
+ qualifying_pool_week: "number?"
1185
+ });
1186
+ const Regional_Ranking = type({
1187
+ team_key: "string",
1188
+ rank: "number",
1189
+ rookie_bonus: "number?",
1190
+ point_total: "number",
1191
+ single_event_bonus: "number?",
1192
+ event_points: type({
1193
+ total: "number",
1194
+ alliance_points: "number",
1195
+ elim_points: "number",
1196
+ award_points: "number",
1197
+ event_key: "string",
1198
+ qual_points: "number"
1199
+ }).array()
1200
+ });
1201
+
1202
+ //#endregion
1203
+ //#region src/types/endpoints/regionalAdvancements.ts
1204
+ const regionalAdvancementEndpoints = {
1205
+ "/regional_advancement/{year}": {
1206
+ schema: type({ "[string]": Regional_Advancement }),
1207
+ arguments: type(["number"])
1208
+ },
1209
+ "/regional_advancement/{year}/rankings": {
1210
+ schema: Regional_Ranking.array(),
1211
+ arguments: type(["number"])
1212
+ }
1213
+ };
1214
+
1215
+ //#endregion
1216
+ //#region src/types/schemas/insights.ts
1217
+ const LeaderboardInsights = type({
1218
+ data: {
1219
+ rankings: type({
1220
+ value: "number",
1221
+ keys: "string[]"
1222
+ }).array(),
1223
+ key_type: "'team' | 'event' | 'match'"
1224
+ },
1225
+ name: "string",
1226
+ year: "number"
1227
+ });
1228
+ const NotablesInsight = type({
1229
+ data: { entries: type({
1230
+ context: "string[]",
1231
+ team_key: "string"
1232
+ }).array() },
1233
+ name: "string",
1234
+ year: "number"
1235
+ });
1236
+
1237
+ //#endregion
1238
+ //#region src/types/endpoints/insights.ts
1239
+ const insightEndpoints = {
1240
+ "/insights/leaderboards/{year}": {
1241
+ schema: LeaderboardInsights.array(),
1242
+ arguments: type(["number"])
1243
+ },
1244
+ "/insights/notables/{year}": {
1245
+ schema: NotablesInsight.array(),
1246
+ arguments: type(["number"])
1247
+ }
1248
+ };
1249
+
1250
+ //#endregion
1251
+ //#region src/types/endpoints/index.ts
1252
+ const Search_Index = type({
1253
+ teams: type({
1254
+ key: "string",
1255
+ nickname: "string"
1256
+ }).array(),
1257
+ events: type({
1258
+ key: "string",
1259
+ name: "string"
1260
+ }).array()
1261
+ });
1262
+ const searchIndex = { "/search_index": {
1263
+ schema: Search_Index,
1264
+ arguments: type([])
1265
+ } };
1266
+ const endpoints = {
1267
+ ...statusEndpoints,
1268
+ ...teamEndpoints,
1269
+ ...eventEndpoints,
1270
+ ...matchEndpoints,
1271
+ ...districtEndpoints,
1272
+ ...regionalAdvancementEndpoints,
1273
+ ...insightEndpoints,
1274
+ ...searchIndex
1275
+ };
1276
+
1277
+ //#endregion
1278
+ //#region src/index.ts
1279
+ function createTBACaller(api_key) {
1280
+ return async (endpoint, ...args) => await TBA(endpoint, api_key, ...args);
1281
+ }
1282
+ async function TBA(endpoint, api_key, ...args) {
1283
+ let numArg = -1;
1284
+ const filledEndpoint = endpoint.replace(/{(.+?)}/g, () => {
1285
+ numArg++;
1286
+ return args[numArg].toString();
1287
+ });
1288
+ const result = await tryCatch(fetch(`https://www.thebluealliance.com/api/v3${filledEndpoint}`, { headers: { "X-TBA-Auth-Key": api_key } }));
1289
+ if (result.error) return {
1290
+ data: null,
1291
+ error: result.error
1292
+ };
1293
+ if (result.data.status !== 200) return {
1294
+ data: null,
1295
+ error: /* @__PURE__ */ new Error(`${result.data.status} - ${result.data.statusText}`)
1296
+ };
1297
+ const json = await tryCatch(result.data.json());
1298
+ if (json.error) return {
1299
+ data: null,
1300
+ error: /* @__PURE__ */ new Error(`JSON didn't parse for endpoint ${endpoint}. Please contact the developers of the TBArequest package with this error: ${json.error.message}`)
1301
+ };
1302
+ if ("transformMatch" in endpoints[endpoint]) {
1303
+ let data;
1304
+ switch (endpoint) {
1305
+ case "/event/{event_key}/matches":
1306
+ case "/match/{match_key}":
1307
+ data = { key: args[0] };
1308
+ break;
1309
+ case "/team/{team_key}/event/{event_key}/matches":
1310
+ data = { key: args[1] };
1311
+ break;
1312
+ case "/team/{team_key}/matches/{year}":
1313
+ data = { year: args[1] };
1314
+ break;
1315
+ default: data = {};
1316
+ }
1317
+ json.data = endpoints[endpoint].transformMatch(data, json.data);
1318
+ }
1319
+ let schema = endpoints[endpoint].schema(json.data);
1320
+ if (schema instanceof ArkErrors) return {
1321
+ data: null,
1322
+ error: /* @__PURE__ */ new Error(`Schema for endpoint ${endpoint} didn't work. Please contact the developers of the TBArequest package with this error: ${schema}`)
1323
+ };
1324
+ return {
1325
+ data: schema,
1326
+ error: null
1327
+ };
1328
+ }
1329
+
1330
+ //#endregion
1331
+ export { createTBACaller };