@opprs/db-prisma 2.2.0 → 2.2.1-canary.090cc41

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.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as _prisma_client_runtime_library from '@prisma/client/runtime/library';
2
2
  import * as _prisma_client from '@prisma/client';
3
- import { PrismaClient, Player, Prisma, EventBoosterType, Tournament, TournamentResult, User } from '@prisma/client';
4
- export { EventBoosterType, Player, Prisma, Role, Tournament, TournamentResult, User } from '@prisma/client';
3
+ import { PrismaClient, Player, Prisma, OpprPlayerRanking, OpprRankingChangeType, OpprRankingHistory, EventBoosterType, TournamentFormatType, Tournament, Round, Match, MatchResult, Entry, Standing, User, ApiKey, Location, PostStatus, BlogPost, BlogTag } from '@prisma/client';
4
+ export { Entry, EventBoosterType, Location, Match, MatchResult, OpprPlayerRanking, OpprRankingChangeType, OpprRankingHistory, Player, Prisma, Role, Round, Standing, Tournament, TournamentFormatType, User } from '@prisma/client';
5
5
 
6
6
  declare const prisma: PrismaClient<_prisma_client.Prisma.PrismaClientOptions, never, _prisma_client_runtime_library.DefaultArgs>;
7
7
  /**
@@ -25,24 +25,17 @@ declare function testConnection(): Promise<boolean>;
25
25
  */
26
26
  interface CreatePlayerInput {
27
27
  externalId?: string;
28
+ playerNumber?: number;
28
29
  name?: string;
29
- rating?: number;
30
- ratingDeviation?: number;
31
- ranking?: number;
32
- isRated?: boolean;
33
30
  eventCount?: number;
31
+ lastEventDate?: Date;
34
32
  }
35
33
  /**
36
34
  * Input for updating a player
37
35
  */
38
36
  interface UpdatePlayerInput {
39
37
  name?: string;
40
- rating?: number;
41
- ratingDeviation?: number;
42
- ranking?: number;
43
- isRated?: boolean;
44
38
  eventCount?: number;
45
- lastRatingUpdate?: Date;
46
39
  lastEventDate?: Date;
47
40
  }
48
41
  /**
@@ -56,7 +49,7 @@ interface FindPlayersOptions {
56
49
  include?: Prisma.PlayerInclude;
57
50
  }
58
51
  /**
59
- * Creates a new player
52
+ * Creates a new player with auto-generated playerNumber
60
53
  */
61
54
  declare function createPlayer(data: CreatePlayerInput): Promise<Player>;
62
55
  /**
@@ -67,6 +60,10 @@ declare function findPlayerById(id: string, include?: Prisma.PlayerInclude): Pro
67
60
  * Finds a player by external ID
68
61
  */
69
62
  declare function findPlayerByExternalId(externalId: string, include?: Prisma.PlayerInclude): Promise<Player | null>;
63
+ /**
64
+ * Finds a player by player number
65
+ */
66
+ declare function findPlayerByPlayerNumber(playerNumber: number, include?: Prisma.PlayerInclude): Promise<Player | null>;
70
67
  /**
71
68
  * Finds a player through their linked User's email
72
69
  */
@@ -75,26 +72,10 @@ declare function findPlayerByUserEmail(email: string, include?: Prisma.PlayerInc
75
72
  * Finds multiple players with optional filters
76
73
  */
77
74
  declare function findPlayers(options?: FindPlayersOptions): Promise<Player[]>;
78
- /**
79
- * Gets all rated players (has 5+ events)
80
- */
81
- declare function getRatedPlayers(options?: Omit<FindPlayersOptions, 'where'>): Promise<Player[]>;
82
- /**
83
- * Gets top players by rating
84
- */
85
- declare function getTopPlayersByRating(limit?: number): Promise<Player[]>;
86
- /**
87
- * Gets top players by ranking
88
- */
89
- declare function getTopPlayersByRanking(limit?: number): Promise<Player[]>;
90
75
  /**
91
76
  * Updates a player
92
77
  */
93
78
  declare function updatePlayer(id: string, data: UpdatePlayerInput): Promise<Player>;
94
- /**
95
- * Updates player rating after a tournament
96
- */
97
- declare function updatePlayerRating(id: string, rating: number, ratingDeviation: number, eventCount?: number): Promise<Player>;
98
79
  /**
99
80
  * Deletes a player
100
81
  */
@@ -104,7 +85,7 @@ declare function deletePlayer(id: string): Promise<Player>;
104
85
  */
105
86
  declare function countPlayers(where?: Prisma.PlayerWhereInput): Promise<number>;
106
87
  /**
107
- * Gets player with their tournament results
88
+ * Gets player with their tournament standings
108
89
  */
109
90
  declare function getPlayerWithResults(id: string): Promise<{
110
91
  results: ({
@@ -114,10 +95,14 @@ declare function getPlayerWithResults(id: string): Promise<{
114
95
  createdAt: Date;
115
96
  updatedAt: Date;
116
97
  externalId: string | null;
117
- location: string | null;
98
+ externalUrl: string | null;
99
+ description: string | null;
118
100
  date: Date;
101
+ locationId: string | null;
102
+ organizerId: string | null;
119
103
  tgpConfig: Prisma.JsonValue | null;
120
104
  eventBooster: _prisma_client.$Enums.EventBoosterType;
105
+ qualifyingFormat: _prisma_client.$Enums.TournamentFormatType;
121
106
  allowsOptOut: boolean;
122
107
  baseValue: number | null;
123
108
  tvaRating: number | null;
@@ -131,9 +116,10 @@ declare function getPlayerWithResults(id: string): Promise<{
131
116
  id: string;
132
117
  createdAt: Date;
133
118
  updatedAt: Date;
134
- playerId: string;
135
119
  tournamentId: string;
120
+ playerId: string;
136
121
  position: number;
122
+ isFinals: boolean;
137
123
  optedOut: boolean;
138
124
  linearPoints: number | null;
139
125
  dynamicPoints: number | null;
@@ -143,17 +129,21 @@ declare function getPlayerWithResults(id: string): Promise<{
143
129
  decayedPoints: number | null;
144
130
  efficiency: number | null;
145
131
  })[];
146
- tournamentResults: ({
132
+ standings: ({
147
133
  tournament: {
148
134
  name: string;
149
135
  id: string;
150
136
  createdAt: Date;
151
137
  updatedAt: Date;
152
138
  externalId: string | null;
153
- location: string | null;
139
+ externalUrl: string | null;
140
+ description: string | null;
154
141
  date: Date;
142
+ locationId: string | null;
143
+ organizerId: string | null;
155
144
  tgpConfig: Prisma.JsonValue | null;
156
145
  eventBooster: _prisma_client.$Enums.EventBoosterType;
146
+ qualifyingFormat: _prisma_client.$Enums.TournamentFormatType;
157
147
  allowsOptOut: boolean;
158
148
  baseValue: number | null;
159
149
  tvaRating: number | null;
@@ -167,9 +157,10 @@ declare function getPlayerWithResults(id: string): Promise<{
167
157
  id: string;
168
158
  createdAt: Date;
169
159
  updatedAt: Date;
170
- playerId: string;
171
160
  tournamentId: string;
161
+ playerId: string;
172
162
  position: number;
163
+ isFinals: boolean;
173
164
  optedOut: boolean;
174
165
  linearPoints: number | null;
175
166
  dynamicPoints: number | null;
@@ -184,12 +175,8 @@ declare function getPlayerWithResults(id: string): Promise<{
184
175
  createdAt: Date;
185
176
  updatedAt: Date;
186
177
  externalId: string | null;
187
- rating: number;
188
- ratingDeviation: number;
189
- ranking: number | null;
190
- isRated: boolean;
178
+ playerNumber: number;
191
179
  eventCount: number;
192
- lastRatingUpdate: Date;
193
180
  lastEventDate: Date | null;
194
181
  } | null>;
195
182
  /**
@@ -197,16 +184,155 @@ declare function getPlayerWithResults(id: string): Promise<{
197
184
  */
198
185
  declare function searchPlayers(query: string, limit?: number): Promise<Player[]>;
199
186
 
187
+ /**
188
+ * Input for creating a new OPPR player ranking
189
+ */
190
+ interface CreateOpprPlayerRankingInput {
191
+ playerId: string;
192
+ rating?: number;
193
+ ratingDeviation?: number;
194
+ ranking?: number;
195
+ isRated?: boolean;
196
+ }
197
+ /**
198
+ * Input for updating an OPPR player ranking
199
+ */
200
+ interface UpdateOpprPlayerRankingInput {
201
+ rating?: number;
202
+ ratingDeviation?: number;
203
+ ranking?: number;
204
+ isRated?: boolean;
205
+ lastRatingUpdate?: Date;
206
+ }
207
+ /**
208
+ * Options for querying OPPR rankings
209
+ */
210
+ interface FindOpprPlayerRankingsOptions {
211
+ take?: number;
212
+ skip?: number;
213
+ orderBy?: Prisma.OpprPlayerRankingOrderByWithRelationInput;
214
+ where?: Prisma.OpprPlayerRankingWhereInput;
215
+ include?: Prisma.OpprPlayerRankingInclude;
216
+ }
217
+ /**
218
+ * Input for creating a ranking history record
219
+ */
220
+ interface CreateOpprRankingHistoryInput {
221
+ opprPlayerRankingId: string;
222
+ rating: number;
223
+ ratingDeviation: number;
224
+ ranking?: number;
225
+ isRated: boolean;
226
+ changeType: OpprRankingChangeType;
227
+ tournamentId?: string;
228
+ notes?: string;
229
+ }
230
+ /**
231
+ * Gets or creates an OPPR player ranking for a player
232
+ */
233
+ declare function getOrCreateOpprPlayerRanking(playerId: string): Promise<OpprPlayerRanking>;
234
+ /**
235
+ * Creates a new OPPR player ranking
236
+ */
237
+ declare function createOpprPlayerRanking(data: CreateOpprPlayerRankingInput): Promise<OpprPlayerRanking>;
238
+ /**
239
+ * Finds OPPR ranking by ID
240
+ */
241
+ declare function findOpprPlayerRankingById(id: string, include?: Prisma.OpprPlayerRankingInclude): Promise<OpprPlayerRanking | null>;
242
+ /**
243
+ * Finds OPPR ranking by player ID
244
+ */
245
+ declare function findOpprPlayerRankingByPlayerId(playerId: string, include?: Prisma.OpprPlayerRankingInclude): Promise<OpprPlayerRanking | null>;
246
+ /**
247
+ * Finds multiple OPPR rankings with optional filters
248
+ */
249
+ declare function findOpprPlayerRankings(options?: FindOpprPlayerRankingsOptions): Promise<OpprPlayerRanking[]>;
250
+ /**
251
+ * Gets all rated players ordered by rating (highest first)
252
+ */
253
+ declare function getTopPlayersByOpprRating(limit?: number): Promise<OpprPlayerRanking[]>;
254
+ /**
255
+ * Gets all ranked players ordered by world ranking (best first)
256
+ */
257
+ declare function getTopPlayersByOpprRanking(limit?: number): Promise<OpprPlayerRanking[]>;
258
+ /**
259
+ * Gets all rated players
260
+ */
261
+ declare function getRatedOpprPlayers(options?: Omit<FindOpprPlayerRankingsOptions, 'where'>): Promise<OpprPlayerRanking[]>;
262
+ /**
263
+ * Updates OPPR player ranking
264
+ */
265
+ declare function updateOpprPlayerRanking(playerId: string, data: UpdateOpprPlayerRankingInput): Promise<OpprPlayerRanking>;
266
+ /**
267
+ * Updates rating after a tournament and creates history record
268
+ */
269
+ declare function updateOpprRatingAfterTournament(playerId: string, newRating: number, newRD: number, tournamentId: string, eventCount?: number): Promise<OpprPlayerRanking>;
270
+ /**
271
+ * Updates world rankings for all players (batch operation)
272
+ */
273
+ declare function updateWorldRankings(rankings: Array<{
274
+ playerId: string;
275
+ ranking: number;
276
+ }>): Promise<void>;
277
+ /**
278
+ * Applies RD decay for inactive players
279
+ */
280
+ declare function applyRDDecayForInactivePlayers(thresholdDays?: number, decayPerDay?: number, maxRD?: number): Promise<number>;
281
+ /**
282
+ * Deletes OPPR player ranking (cascades to history)
283
+ */
284
+ declare function deleteOpprPlayerRanking(playerId: string): Promise<OpprPlayerRanking>;
285
+ /**
286
+ * Counts OPPR rankings
287
+ */
288
+ declare function countOpprPlayerRankings(where?: Prisma.OpprPlayerRankingWhereInput): Promise<number>;
289
+ /**
290
+ * Creates a ranking history record
291
+ */
292
+ declare function createOpprRankingHistory(data: CreateOpprRankingHistoryInput): Promise<OpprRankingHistory>;
293
+ /**
294
+ * Gets ranking history for a player
295
+ */
296
+ declare function getOpprRankingHistory(playerId: string, limit?: number): Promise<OpprRankingHistory[]>;
297
+ /**
298
+ * Gets ranking history for a specific time period
299
+ */
300
+ declare function getOpprRankingHistoryByDateRange(playerId: string, startDate: Date, endDate: Date): Promise<OpprRankingHistory[]>;
301
+ /**
302
+ * Gets the most recent history record for a player
303
+ */
304
+ declare function getLatestOpprRankingHistory(playerId: string): Promise<OpprRankingHistory | null>;
305
+ /**
306
+ * Counts ranking history records
307
+ */
308
+ declare function countOpprRankingHistory(where?: Prisma.OpprRankingHistoryWhereInput): Promise<number>;
309
+
310
+ /**
311
+ * Generates a unique player number with collision handling.
312
+ * Retries up to MAX_RETRIES times if collision occurs.
313
+ *
314
+ * @throws Error if unable to generate unique number after max retries
315
+ */
316
+ declare function generateUniquePlayerNumber(): Promise<number>;
317
+ /**
318
+ * Validates that a player number is in the valid range
319
+ */
320
+ declare function isValidPlayerNumber(playerNumber: number): boolean;
321
+
200
322
  /**
201
323
  * Input for creating a new tournament
202
324
  */
203
325
  interface CreateTournamentInput {
204
326
  externalId?: string;
327
+ externalUrl?: string;
205
328
  name: string;
206
- location?: string;
329
+ description?: string;
207
330
  date: Date;
331
+ locationId?: string;
332
+ organizerId?: string;
208
333
  tgpConfig?: Prisma.InputJsonValue;
209
334
  eventBooster?: EventBoosterType;
335
+ qualifyingFormat?: TournamentFormatType;
210
336
  allowsOptOut?: boolean;
211
337
  baseValue?: number;
212
338
  tvaRating?: number;
@@ -220,11 +346,15 @@ interface CreateTournamentInput {
220
346
  * Input for updating a tournament
221
347
  */
222
348
  interface UpdateTournamentInput {
349
+ externalUrl?: string | null;
223
350
  name?: string;
224
- location?: string;
351
+ description?: string | null;
225
352
  date?: Date;
353
+ locationId?: string | null;
354
+ organizerId?: string | null;
226
355
  tgpConfig?: Prisma.InputJsonValue;
227
356
  eventBooster?: EventBoosterType;
357
+ qualifyingFormat?: TournamentFormatType;
228
358
  allowsOptOut?: boolean;
229
359
  baseValue?: number;
230
360
  tvaRating?: number;
@@ -289,31 +419,28 @@ declare function deleteTournament(id: string): Promise<Tournament>;
289
419
  */
290
420
  declare function countTournaments(where?: Prisma.TournamentWhereInput): Promise<number>;
291
421
  /**
292
- * Gets tournament with all results and player details
422
+ * Gets tournament with all standings and player details
293
423
  */
294
424
  declare function getTournamentWithResults(id: string): Promise<({
295
- results: ({
425
+ standings: ({
296
426
  player: {
297
427
  name: string | null;
298
428
  id: string;
299
429
  createdAt: Date;
300
430
  updatedAt: Date;
301
431
  externalId: string | null;
302
- rating: number;
303
- ratingDeviation: number;
304
- ranking: number | null;
305
- isRated: boolean;
432
+ playerNumber: number;
306
433
  eventCount: number;
307
- lastRatingUpdate: Date;
308
434
  lastEventDate: Date | null;
309
435
  };
310
436
  } & {
311
437
  id: string;
312
438
  createdAt: Date;
313
439
  updatedAt: Date;
314
- playerId: string;
315
440
  tournamentId: string;
441
+ playerId: string;
316
442
  position: number;
443
+ isFinals: boolean;
317
444
  optedOut: boolean;
318
445
  linearPoints: number | null;
319
446
  dynamicPoints: number | null;
@@ -329,10 +456,81 @@ declare function getTournamentWithResults(id: string): Promise<({
329
456
  createdAt: Date;
330
457
  updatedAt: Date;
331
458
  externalId: string | null;
332
- location: string | null;
459
+ externalUrl: string | null;
460
+ description: string | null;
461
+ date: Date;
462
+ locationId: string | null;
463
+ organizerId: string | null;
464
+ tgpConfig: Prisma.JsonValue | null;
465
+ eventBooster: _prisma_client.$Enums.EventBoosterType;
466
+ qualifyingFormat: _prisma_client.$Enums.TournamentFormatType;
467
+ allowsOptOut: boolean;
468
+ baseValue: number | null;
469
+ tvaRating: number | null;
470
+ tvaRanking: number | null;
471
+ totalTVA: number | null;
472
+ tgp: number | null;
473
+ eventBoosterMultiplier: number | null;
474
+ firstPlaceValue: number | null;
475
+ }) | null>;
476
+ /**
477
+ * Gets tournament with rounds, matches, and entries
478
+ */
479
+ declare function getTournamentWithMatches(id: string): Promise<({
480
+ rounds: ({
481
+ matches: ({
482
+ entries: ({
483
+ player: {
484
+ name: string | null;
485
+ id: string;
486
+ createdAt: Date;
487
+ updatedAt: Date;
488
+ externalId: string | null;
489
+ playerNumber: number;
490
+ eventCount: number;
491
+ lastEventDate: Date | null;
492
+ };
493
+ } & {
494
+ result: _prisma_client.$Enums.MatchResult;
495
+ id: string;
496
+ createdAt: Date;
497
+ updatedAt: Date;
498
+ playerId: string;
499
+ position: number | null;
500
+ matchId: string;
501
+ })[];
502
+ } & {
503
+ number: number | null;
504
+ id: string;
505
+ createdAt: Date;
506
+ updatedAt: Date;
507
+ tournamentId: string;
508
+ roundId: string | null;
509
+ machineName: string | null;
510
+ })[];
511
+ } & {
512
+ number: number;
513
+ name: string | null;
514
+ id: string;
515
+ createdAt: Date;
516
+ updatedAt: Date;
517
+ tournamentId: string;
518
+ isFinals: boolean;
519
+ })[];
520
+ } & {
521
+ name: string;
522
+ id: string;
523
+ createdAt: Date;
524
+ updatedAt: Date;
525
+ externalId: string | null;
526
+ externalUrl: string | null;
527
+ description: string | null;
333
528
  date: Date;
529
+ locationId: string | null;
530
+ organizerId: string | null;
334
531
  tgpConfig: Prisma.JsonValue | null;
335
532
  eventBooster: _prisma_client.$Enums.EventBoosterType;
533
+ qualifyingFormat: _prisma_client.$Enums.TournamentFormatType;
336
534
  allowsOptOut: boolean;
337
535
  baseValue: number | null;
338
536
  tvaRating: number | null;
@@ -343,7 +541,7 @@ declare function getTournamentWithResults(id: string): Promise<({
343
541
  firstPlaceValue: number | null;
344
542
  }) | null>;
345
543
  /**
346
- * Searches tournaments by name or location
544
+ * Searches tournaments by name or location name
347
545
  */
348
546
  declare function searchTournaments(query: string, limit?: number): Promise<Tournament[]>;
349
547
  /**
@@ -351,28 +549,25 @@ declare function searchTournaments(query: string, limit?: number): Promise<Tourn
351
549
  */
352
550
  declare function getTournamentStats(id: string): Promise<{
353
551
  tournament: {
354
- results: ({
552
+ standings: ({
355
553
  player: {
356
554
  name: string | null;
357
555
  id: string;
358
556
  createdAt: Date;
359
557
  updatedAt: Date;
360
558
  externalId: string | null;
361
- rating: number;
362
- ratingDeviation: number;
363
- ranking: number | null;
364
- isRated: boolean;
559
+ playerNumber: number;
365
560
  eventCount: number;
366
- lastRatingUpdate: Date;
367
561
  lastEventDate: Date | null;
368
562
  };
369
563
  } & {
370
564
  id: string;
371
565
  createdAt: Date;
372
566
  updatedAt: Date;
373
- playerId: string;
374
567
  tournamentId: string;
568
+ playerId: string;
375
569
  position: number;
570
+ isFinals: boolean;
376
571
  optedOut: boolean;
377
572
  linearPoints: number | null;
378
573
  dynamicPoints: number | null;
@@ -388,10 +583,14 @@ declare function getTournamentStats(id: string): Promise<{
388
583
  createdAt: Date;
389
584
  updatedAt: Date;
390
585
  externalId: string | null;
391
- location: string | null;
586
+ externalUrl: string | null;
587
+ description: string | null;
392
588
  date: Date;
589
+ locationId: string | null;
590
+ organizerId: string | null;
393
591
  tgpConfig: Prisma.JsonValue | null;
394
592
  eventBooster: _prisma_client.$Enums.EventBoosterType;
593
+ qualifyingFormat: _prisma_client.$Enums.TournamentFormatType;
395
594
  allowsOptOut: boolean;
396
595
  baseValue: number | null;
397
596
  tvaRating: number | null;
@@ -409,12 +608,342 @@ declare function getTournamentStats(id: string): Promise<{
409
608
  } | null>;
410
609
 
411
610
  /**
412
- * Input for creating a tournament result
611
+ * Input for creating a new round
612
+ */
613
+ interface CreateRoundInput {
614
+ tournamentId: string;
615
+ number: number;
616
+ name?: string;
617
+ isFinals?: boolean;
618
+ }
619
+ /**
620
+ * Input for updating a round
621
+ */
622
+ interface UpdateRoundInput {
623
+ number?: number;
624
+ name?: string;
625
+ isFinals?: boolean;
626
+ }
627
+ /**
628
+ * Options for querying rounds
629
+ */
630
+ interface FindRoundsOptions {
631
+ take?: number;
632
+ skip?: number;
633
+ orderBy?: Prisma.RoundOrderByWithRelationInput | Prisma.RoundOrderByWithRelationInput[];
634
+ where?: Prisma.RoundWhereInput;
635
+ include?: Prisma.RoundInclude;
636
+ }
637
+ /**
638
+ * Creates a new round
639
+ */
640
+ declare function createRound(data: CreateRoundInput): Promise<Round>;
641
+ /**
642
+ * Creates multiple rounds at once
643
+ */
644
+ declare function createManyRounds(data: CreateRoundInput[]): Promise<Prisma.BatchPayload>;
645
+ /**
646
+ * Finds a round by ID
413
647
  */
414
- interface CreateResultInput {
648
+ declare function findRoundById(id: string, include?: Prisma.RoundInclude): Promise<Round | null>;
649
+ /**
650
+ * Finds a round by tournament, number, and isFinals
651
+ */
652
+ declare function findRoundByTournamentAndNumber(tournamentId: string, number: number, isFinals: boolean, include?: Prisma.RoundInclude): Promise<Round | null>;
653
+ /**
654
+ * Finds multiple rounds with optional filters
655
+ */
656
+ declare function findRounds(options?: FindRoundsOptions): Promise<Round[]>;
657
+ /**
658
+ * Gets all rounds for a specific tournament
659
+ */
660
+ declare function getTournamentRounds(tournamentId: string, options?: Omit<FindRoundsOptions, 'where'>): Promise<Round[]>;
661
+ /**
662
+ * Gets qualifying rounds for a tournament
663
+ */
664
+ declare function getQualifyingRounds(tournamentId: string, options?: Omit<FindRoundsOptions, 'where'>): Promise<Round[]>;
665
+ /**
666
+ * Gets finals rounds for a tournament
667
+ */
668
+ declare function getFinalsRounds(tournamentId: string, options?: Omit<FindRoundsOptions, 'where'>): Promise<Round[]>;
669
+ /**
670
+ * Updates a round
671
+ */
672
+ declare function updateRound(id: string, data: UpdateRoundInput): Promise<Round>;
673
+ /**
674
+ * Deletes a round
675
+ */
676
+ declare function deleteRound(id: string): Promise<Round>;
677
+ /**
678
+ * Deletes all rounds for a tournament
679
+ */
680
+ declare function deleteRoundsByTournament(tournamentId: string): Promise<Prisma.BatchPayload>;
681
+ /**
682
+ * Counts total rounds
683
+ */
684
+ declare function countRounds(where?: Prisma.RoundWhereInput): Promise<number>;
685
+ /**
686
+ * Gets a round with all its matches
687
+ */
688
+ declare function getRoundWithMatches(id: string): Promise<({
689
+ matches: ({
690
+ entries: ({
691
+ player: {
692
+ name: string | null;
693
+ id: string;
694
+ createdAt: Date;
695
+ updatedAt: Date;
696
+ externalId: string | null;
697
+ playerNumber: number;
698
+ eventCount: number;
699
+ lastEventDate: Date | null;
700
+ };
701
+ } & {
702
+ result: _prisma_client.$Enums.MatchResult;
703
+ id: string;
704
+ createdAt: Date;
705
+ updatedAt: Date;
706
+ playerId: string;
707
+ position: number | null;
708
+ matchId: string;
709
+ })[];
710
+ } & {
711
+ number: number | null;
712
+ id: string;
713
+ createdAt: Date;
714
+ updatedAt: Date;
715
+ tournamentId: string;
716
+ roundId: string | null;
717
+ machineName: string | null;
718
+ })[];
719
+ } & {
720
+ number: number;
721
+ name: string | null;
722
+ id: string;
723
+ createdAt: Date;
724
+ updatedAt: Date;
725
+ tournamentId: string;
726
+ isFinals: boolean;
727
+ }) | null>;
728
+
729
+ /**
730
+ * Input for creating a new match
731
+ */
732
+ interface CreateMatchInput {
733
+ tournamentId: string;
734
+ roundId?: string;
735
+ number?: number;
736
+ machineName?: string;
737
+ }
738
+ /**
739
+ * Input for updating a match
740
+ */
741
+ interface UpdateMatchInput {
742
+ roundId?: string | null;
743
+ number?: number;
744
+ machineName?: string;
745
+ }
746
+ /**
747
+ * Options for querying matches
748
+ */
749
+ interface FindMatchesOptions {
750
+ take?: number;
751
+ skip?: number;
752
+ orderBy?: Prisma.MatchOrderByWithRelationInput | Prisma.MatchOrderByWithRelationInput[];
753
+ where?: Prisma.MatchWhereInput;
754
+ include?: Prisma.MatchInclude;
755
+ }
756
+ /**
757
+ * Creates a new match
758
+ */
759
+ declare function createMatch(data: CreateMatchInput): Promise<Match>;
760
+ /**
761
+ * Creates multiple matches at once
762
+ */
763
+ declare function createManyMatches(data: CreateMatchInput[]): Promise<Prisma.BatchPayload>;
764
+ /**
765
+ * Finds a match by ID
766
+ */
767
+ declare function findMatchById(id: string, include?: Prisma.MatchInclude): Promise<Match | null>;
768
+ /**
769
+ * Finds multiple matches with optional filters
770
+ */
771
+ declare function findMatches(options?: FindMatchesOptions): Promise<Match[]>;
772
+ /**
773
+ * Gets all matches for a specific tournament
774
+ */
775
+ declare function getTournamentMatches(tournamentId: string, options?: Omit<FindMatchesOptions, 'where'>): Promise<Match[]>;
776
+ /**
777
+ * Gets all matches for a specific round
778
+ */
779
+ declare function getRoundMatches(roundId: string, options?: Omit<FindMatchesOptions, 'where'>): Promise<Match[]>;
780
+ /**
781
+ * Updates a match
782
+ */
783
+ declare function updateMatch(id: string, data: UpdateMatchInput): Promise<Match>;
784
+ /**
785
+ * Deletes a match
786
+ */
787
+ declare function deleteMatch(id: string): Promise<Match>;
788
+ /**
789
+ * Deletes all matches for a tournament
790
+ */
791
+ declare function deleteMatchesByTournament(tournamentId: string): Promise<Prisma.BatchPayload>;
792
+ /**
793
+ * Deletes all matches for a round
794
+ */
795
+ declare function deleteMatchesByRound(roundId: string): Promise<Prisma.BatchPayload>;
796
+ /**
797
+ * Counts total matches
798
+ */
799
+ declare function countMatches(where?: Prisma.MatchWhereInput): Promise<number>;
800
+ /**
801
+ * Gets a match with all its entries and player details
802
+ */
803
+ declare function getMatchWithEntries(id: string): Promise<({
804
+ round: {
805
+ number: number;
806
+ name: string | null;
807
+ id: string;
808
+ createdAt: Date;
809
+ updatedAt: Date;
810
+ tournamentId: string;
811
+ isFinals: boolean;
812
+ } | null;
813
+ entries: ({
814
+ player: {
815
+ name: string | null;
816
+ id: string;
817
+ createdAt: Date;
818
+ updatedAt: Date;
819
+ externalId: string | null;
820
+ playerNumber: number;
821
+ eventCount: number;
822
+ lastEventDate: Date | null;
823
+ };
824
+ } & {
825
+ result: _prisma_client.$Enums.MatchResult;
826
+ id: string;
827
+ createdAt: Date;
828
+ updatedAt: Date;
829
+ playerId: string;
830
+ position: number | null;
831
+ matchId: string;
832
+ })[];
833
+ } & {
834
+ number: number | null;
835
+ id: string;
836
+ createdAt: Date;
837
+ updatedAt: Date;
838
+ tournamentId: string;
839
+ roundId: string | null;
840
+ machineName: string | null;
841
+ }) | null>;
842
+ /**
843
+ * Gets matches for a player in a tournament
844
+ */
845
+ declare function getPlayerTournamentMatches(playerId: string, tournamentId: string, include?: Prisma.MatchInclude): Promise<Match[]>;
846
+
847
+ /**
848
+ * Input for creating a new entry
849
+ */
850
+ interface CreateEntryInput {
851
+ matchId: string;
415
852
  playerId: string;
853
+ result: MatchResult;
854
+ position?: number;
855
+ }
856
+ /**
857
+ * Input for updating an entry
858
+ */
859
+ interface UpdateEntryInput {
860
+ result?: MatchResult;
861
+ position?: number;
862
+ }
863
+ /**
864
+ * Options for querying entries
865
+ */
866
+ interface FindEntriesOptions {
867
+ take?: number;
868
+ skip?: number;
869
+ orderBy?: Prisma.EntryOrderByWithRelationInput;
870
+ where?: Prisma.EntryWhereInput;
871
+ include?: Prisma.EntryInclude;
872
+ }
873
+ /**
874
+ * Creates a new entry
875
+ */
876
+ declare function createEntry(data: CreateEntryInput): Promise<Entry>;
877
+ /**
878
+ * Creates multiple entries at once
879
+ */
880
+ declare function createManyEntries(data: CreateEntryInput[]): Promise<Prisma.BatchPayload>;
881
+ /**
882
+ * Finds an entry by ID
883
+ */
884
+ declare function findEntryById(id: string, include?: Prisma.EntryInclude): Promise<Entry | null>;
885
+ /**
886
+ * Finds an entry by match and player
887
+ */
888
+ declare function findEntryByMatchAndPlayer(matchId: string, playerId: string, include?: Prisma.EntryInclude): Promise<Entry | null>;
889
+ /**
890
+ * Finds multiple entries with optional filters
891
+ */
892
+ declare function findEntries(options?: FindEntriesOptions): Promise<Entry[]>;
893
+ /**
894
+ * Gets all entries for a specific match
895
+ */
896
+ declare function getMatchEntries(matchId: string, options?: Omit<FindEntriesOptions, 'where'>): Promise<Entry[]>;
897
+ /**
898
+ * Gets all entries for a specific player
899
+ */
900
+ declare function getPlayerEntries(playerId: string, options?: Omit<FindEntriesOptions, 'where'>): Promise<Entry[]>;
901
+ /**
902
+ * Gets player entries in a tournament
903
+ */
904
+ declare function getPlayerTournamentEntries(playerId: string, tournamentId: string, include?: Prisma.EntryInclude): Promise<Entry[]>;
905
+ /**
906
+ * Updates an entry
907
+ */
908
+ declare function updateEntry(id: string, data: UpdateEntryInput): Promise<Entry>;
909
+ /**
910
+ * Deletes an entry
911
+ */
912
+ declare function deleteEntry(id: string): Promise<Entry>;
913
+ /**
914
+ * Deletes all entries for a match
915
+ */
916
+ declare function deleteEntriesByMatch(matchId: string): Promise<Prisma.BatchPayload>;
917
+ /**
918
+ * Counts total entries
919
+ */
920
+ declare function countEntries(where?: Prisma.EntryWhereInput): Promise<number>;
921
+ /**
922
+ * Gets player statistics from entries
923
+ */
924
+ declare function getPlayerEntryStats(playerId: string): Promise<{
925
+ totalMatches: number;
926
+ wins: number;
927
+ losses: number;
928
+ ties: number;
929
+ winRate: number;
930
+ } | null>;
931
+
932
+ /**
933
+ * Merged standing with calculated position for points
934
+ */
935
+ interface MergedStanding extends Standing {
936
+ mergedPosition: number;
937
+ isFinalist: boolean;
938
+ }
939
+ /**
940
+ * Input for creating a new standing
941
+ */
942
+ interface CreateStandingInput {
416
943
  tournamentId: string;
944
+ playerId: string;
417
945
  position: number;
946
+ isFinals?: boolean;
418
947
  optedOut?: boolean;
419
948
  linearPoints?: number;
420
949
  dynamicPoints?: number;
@@ -425,9 +954,9 @@ interface CreateResultInput {
425
954
  efficiency?: number;
426
955
  }
427
956
  /**
428
- * Input for updating a tournament result
957
+ * Input for updating a standing
429
958
  */
430
- interface UpdateResultInput {
959
+ interface UpdateStandingInput {
431
960
  position?: number;
432
961
  optedOut?: boolean;
433
962
  linearPoints?: number;
@@ -439,67 +968,80 @@ interface UpdateResultInput {
439
968
  efficiency?: number;
440
969
  }
441
970
  /**
442
- * Options for querying results
971
+ * Options for querying standings
443
972
  */
444
- interface FindResultsOptions {
973
+ interface FindStandingsOptions {
445
974
  take?: number;
446
975
  skip?: number;
447
- orderBy?: Prisma.TournamentResultOrderByWithRelationInput;
448
- where?: Prisma.TournamentResultWhereInput;
449
- include?: Prisma.TournamentResultInclude;
976
+ orderBy?: Prisma.StandingOrderByWithRelationInput;
977
+ where?: Prisma.StandingWhereInput;
978
+ include?: Prisma.StandingInclude;
450
979
  }
451
980
  /**
452
- * Creates a new tournament result
981
+ * Creates a new standing
982
+ */
983
+ declare function createStanding(data: CreateStandingInput): Promise<Standing>;
984
+ /**
985
+ * Creates multiple standings at once
986
+ */
987
+ declare function createManyStandings(data: CreateStandingInput[]): Promise<Prisma.BatchPayload>;
988
+ /**
989
+ * Finds a standing by ID
990
+ */
991
+ declare function findStandingById(id: string, include?: Prisma.StandingInclude): Promise<Standing | null>;
992
+ /**
993
+ * Finds a standing by player, tournament, and isFinals
453
994
  */
454
- declare function createResult(data: CreateResultInput): Promise<TournamentResult>;
995
+ declare function findStandingByPlayerAndTournament(playerId: string, tournamentId: string, isFinals: boolean, include?: Prisma.StandingInclude): Promise<Standing | null>;
455
996
  /**
456
- * Creates multiple tournament results at once
997
+ * Finds multiple standings with optional filters
457
998
  */
458
- declare function createManyResults(data: CreateResultInput[]): Promise<Prisma.BatchPayload>;
999
+ declare function findStandings(options?: FindStandingsOptions): Promise<Standing[]>;
459
1000
  /**
460
- * Finds a result by ID
1001
+ * Gets all standings for a specific player
461
1002
  */
462
- declare function findResultById(id: string, include?: Prisma.TournamentResultInclude): Promise<TournamentResult | null>;
1003
+ declare function getPlayerStandings(playerId: string, options?: Omit<FindStandingsOptions, 'where'>): Promise<Standing[]>;
463
1004
  /**
464
- * Finds a result by player and tournament
1005
+ * Gets all standings for a specific tournament
465
1006
  */
466
- declare function findResultByPlayerAndTournament(playerId: string, tournamentId: string, include?: Prisma.TournamentResultInclude): Promise<TournamentResult | null>;
1007
+ declare function getTournamentStandings(tournamentId: string, options?: Omit<FindStandingsOptions, 'where'>): Promise<Standing[]>;
467
1008
  /**
468
- * Finds multiple results with optional filters
1009
+ * Gets qualifying standings for a tournament
469
1010
  */
470
- declare function findResults(options?: FindResultsOptions): Promise<TournamentResult[]>;
1011
+ declare function getQualifyingStandings(tournamentId: string, options?: Omit<FindStandingsOptions, 'where'>): Promise<Standing[]>;
471
1012
  /**
472
- * Gets all results for a specific player
1013
+ * Gets finals standings for a tournament
473
1014
  */
474
- declare function getPlayerResults(playerId: string, options?: Omit<FindResultsOptions, 'where'>): Promise<TournamentResult[]>;
1015
+ declare function getFinalsStandings(tournamentId: string, options?: Omit<FindStandingsOptions, 'where'>): Promise<Standing[]>;
475
1016
  /**
476
- * Gets all results for a specific tournament
1017
+ * Gets merged standings for point calculation.
1018
+ * Finalists get their finals position, non-finalists get qualifying position + finalist count
477
1019
  */
478
- declare function getTournamentResults(tournamentId: string, options?: Omit<FindResultsOptions, 'where'>): Promise<TournamentResult[]>;
1020
+ declare function getMergedStandings(tournamentId: string): Promise<MergedStanding[]>;
479
1021
  /**
480
1022
  * Gets top N finishes for a player
481
1023
  */
482
- declare function getPlayerTopFinishes(playerId: string, limit?: number): Promise<TournamentResult[]>;
1024
+ declare function getPlayerTopFinishes(playerId: string, limit?: number): Promise<Standing[]>;
483
1025
  /**
484
- * Updates a tournament result
1026
+ * Updates a standing
485
1027
  */
486
- declare function updateResult(id: string, data: UpdateResultInput): Promise<TournamentResult>;
1028
+ declare function updateStanding(id: string, data: UpdateStandingInput): Promise<Standing>;
487
1029
  /**
488
- * Updates result points and decay information
1030
+ * Updates standing points and decay information
489
1031
  */
490
- declare function updateResultPoints(id: string, linearPoints: number, dynamicPoints: number, totalPoints: number): Promise<TournamentResult>;
1032
+ declare function updateStandingPoints(id: string, linearPoints: number, dynamicPoints: number, totalPoints: number): Promise<Standing>;
491
1033
  /**
492
- * Deletes a tournament result
1034
+ * Deletes a standing
493
1035
  */
494
- declare function deleteResult(id: string): Promise<TournamentResult>;
1036
+ declare function deleteStanding(id: string): Promise<Standing>;
495
1037
  /**
496
- * Deletes all results for a tournament
1038
+ * Deletes all standings for a tournament
497
1039
  */
498
- declare function deleteResultsByTournament(tournamentId: string): Promise<Prisma.BatchPayload>;
1040
+ declare function deleteStandingsByTournament(tournamentId: string): Promise<Prisma.BatchPayload>;
499
1041
  /**
500
- * Counts total results
1042
+ * Counts total standings
501
1043
  */
502
- declare function countResults(where?: Prisma.TournamentResultWhereInput): Promise<number>;
1044
+ declare function countStandings(where?: Prisma.StandingWhereInput): Promise<number>;
503
1045
  /**
504
1046
  * Gets player statistics across all tournaments
505
1047
  */
@@ -517,7 +1059,7 @@ declare function getPlayerStats(playerId: string): Promise<{
517
1059
  highestPoints: number;
518
1060
  } | null>;
519
1061
  /**
520
- * Calculates and updates time decay for all results
1062
+ * Calculates and updates time decay for all standings
521
1063
  * Based on OPPR time decay rules:
522
1064
  * - 0-1 years: 100%
523
1065
  * - 1-2 years: 75%
@@ -528,9 +1070,10 @@ declare function recalculateTimeDecay(referenceDate?: Date): Promise<{
528
1070
  id: string;
529
1071
  createdAt: Date;
530
1072
  updatedAt: Date;
531
- playerId: string;
532
1073
  tournamentId: string;
1074
+ playerId: string;
533
1075
  position: number;
1076
+ isFinals: boolean;
534
1077
  optedOut: boolean;
535
1078
  linearPoints: number | null;
536
1079
  dynamicPoints: number | null;
@@ -549,6 +1092,9 @@ interface CreateUserInput {
549
1092
  passwordHash: string;
550
1093
  playerId?: string;
551
1094
  role?: 'USER' | 'ADMIN';
1095
+ tosAcceptedAt?: Date;
1096
+ privacyPolicyAcceptedAt?: Date;
1097
+ codeOfConductAcceptedAt?: Date;
552
1098
  }
553
1099
  /**
554
1100
  * Input for updating a user
@@ -569,13 +1115,13 @@ interface UserWithPlayer {
569
1115
  role: 'USER' | 'ADMIN';
570
1116
  createdAt: Date;
571
1117
  updatedAt: Date;
1118
+ tosAcceptedAt: Date | null;
1119
+ privacyPolicyAcceptedAt: Date | null;
1120
+ codeOfConductAcceptedAt: Date | null;
572
1121
  player: {
573
1122
  id: string;
1123
+ playerNumber: number;
574
1124
  name: string | null;
575
- rating: number;
576
- ratingDeviation: number;
577
- ranking: number | null;
578
- isRated: boolean;
579
1125
  eventCount: number;
580
1126
  } | null;
581
1127
  }
@@ -641,26 +1187,402 @@ declare function findUsers(params: {
641
1187
  */
642
1188
  declare function linkPlayerToUser(userId: string, playerId: string | null): Promise<UserWithPlayer>;
643
1189
 
1190
+ /**
1191
+ * Maximum number of API keys allowed per user
1192
+ */
1193
+ declare const MAX_API_KEYS_PER_USER = 5;
1194
+ /**
1195
+ * Input for creating a new API key
1196
+ */
1197
+ interface CreateApiKeyInput {
1198
+ name: string;
1199
+ keyPrefix: string;
1200
+ keyHash: string;
1201
+ userId: string;
1202
+ expiresAt?: Date | null;
1203
+ }
1204
+ /**
1205
+ * API key with user info (for authentication)
1206
+ */
1207
+ interface ApiKeyWithUser {
1208
+ id: string;
1209
+ name: string;
1210
+ keyPrefix: string;
1211
+ keyHash: string;
1212
+ expiresAt: Date | null;
1213
+ lastUsedAt: Date | null;
1214
+ createdAt: Date;
1215
+ userId: string;
1216
+ user: {
1217
+ id: string;
1218
+ email: string;
1219
+ role: 'USER' | 'ADMIN';
1220
+ };
1221
+ }
1222
+ /**
1223
+ * API key info for listing (without sensitive data)
1224
+ */
1225
+ interface ApiKeyInfo {
1226
+ id: string;
1227
+ name: string;
1228
+ keyPrefix: string;
1229
+ expiresAt: Date | null;
1230
+ lastUsedAt: Date | null;
1231
+ createdAt: Date;
1232
+ }
1233
+ /**
1234
+ * Creates a new API key
1235
+ */
1236
+ declare function createApiKey(data: CreateApiKeyInput): Promise<ApiKey>;
1237
+ /**
1238
+ * Finds an API key by ID
1239
+ */
1240
+ declare function findApiKeyById(id: string): Promise<ApiKey | null>;
1241
+ /**
1242
+ * Finds API keys by prefix with user data (for authentication)
1243
+ * Returns all keys matching the prefix so we can verify the hash
1244
+ */
1245
+ declare function findApiKeysByPrefix(keyPrefix: string): Promise<ApiKeyWithUser[]>;
1246
+ /**
1247
+ * Gets all API keys for a user (without sensitive data)
1248
+ */
1249
+ declare function getUserApiKeys(userId: string): Promise<ApiKeyInfo[]>;
1250
+ /**
1251
+ * Counts API keys for a user
1252
+ */
1253
+ declare function countUserApiKeys(userId: string): Promise<number>;
1254
+ /**
1255
+ * Updates the lastUsedAt timestamp for an API key
1256
+ */
1257
+ declare function updateApiKeyLastUsed(id: string): Promise<void>;
1258
+ /**
1259
+ * Deletes an API key
1260
+ */
1261
+ declare function deleteApiKey(id: string): Promise<ApiKey>;
1262
+ /**
1263
+ * Deletes an API key only if it belongs to the specified user
1264
+ * Returns null if the key doesn't exist or doesn't belong to the user
1265
+ */
1266
+ declare function deleteUserApiKey(id: string, userId: string): Promise<ApiKey | null>;
1267
+
1268
+ /**
1269
+ * Input for creating a new location
1270
+ */
1271
+ interface CreateLocationInput {
1272
+ externalId?: string;
1273
+ name: string;
1274
+ address?: string;
1275
+ city?: string;
1276
+ state?: string;
1277
+ country?: string;
1278
+ }
1279
+ /**
1280
+ * Input for updating a location
1281
+ */
1282
+ interface UpdateLocationInput {
1283
+ name?: string;
1284
+ address?: string | null;
1285
+ city?: string | null;
1286
+ state?: string | null;
1287
+ country?: string | null;
1288
+ }
1289
+ /**
1290
+ * Options for querying locations
1291
+ */
1292
+ interface FindLocationsOptions {
1293
+ take?: number;
1294
+ skip?: number;
1295
+ orderBy?: Prisma.LocationOrderByWithRelationInput;
1296
+ where?: Prisma.LocationWhereInput;
1297
+ include?: Prisma.LocationInclude;
1298
+ }
1299
+ /**
1300
+ * Creates a new location
1301
+ */
1302
+ declare function createLocation(data: CreateLocationInput): Promise<Location>;
1303
+ /**
1304
+ * Finds a location by ID
1305
+ */
1306
+ declare function findLocationById(id: string, include?: Prisma.LocationInclude): Promise<Location | null>;
1307
+ /**
1308
+ * Finds a location by external ID
1309
+ */
1310
+ declare function findLocationByExternalId(externalId: string, include?: Prisma.LocationInclude): Promise<Location | null>;
1311
+ /**
1312
+ * Finds multiple locations with optional filters
1313
+ */
1314
+ declare function findLocations(options?: FindLocationsOptions): Promise<Location[]>;
1315
+ /**
1316
+ * Searches locations by name or city
1317
+ */
1318
+ declare function searchLocations(query: string, limit?: number): Promise<Location[]>;
1319
+ /**
1320
+ * Updates a location
1321
+ */
1322
+ declare function updateLocation(id: string, data: UpdateLocationInput): Promise<Location>;
1323
+ /**
1324
+ * Deletes a location
1325
+ */
1326
+ declare function deleteLocation(id: string): Promise<Location>;
1327
+ /**
1328
+ * Counts total locations
1329
+ */
1330
+ declare function countLocations(where?: Prisma.LocationWhereInput): Promise<number>;
1331
+ /**
1332
+ * Gets location with its tournaments
1333
+ */
1334
+ declare function getLocationWithTournaments(id: string): Promise<({
1335
+ tournaments: {
1336
+ name: string;
1337
+ id: string;
1338
+ createdAt: Date;
1339
+ updatedAt: Date;
1340
+ externalId: string | null;
1341
+ externalUrl: string | null;
1342
+ description: string | null;
1343
+ date: Date;
1344
+ locationId: string | null;
1345
+ organizerId: string | null;
1346
+ tgpConfig: Prisma.JsonValue | null;
1347
+ eventBooster: _prisma_client.$Enums.EventBoosterType;
1348
+ qualifyingFormat: _prisma_client.$Enums.TournamentFormatType;
1349
+ allowsOptOut: boolean;
1350
+ baseValue: number | null;
1351
+ tvaRating: number | null;
1352
+ tvaRanking: number | null;
1353
+ totalTVA: number | null;
1354
+ tgp: number | null;
1355
+ eventBoosterMultiplier: number | null;
1356
+ firstPlaceValue: number | null;
1357
+ }[];
1358
+ } & {
1359
+ name: string;
1360
+ id: string;
1361
+ createdAt: Date;
1362
+ updatedAt: Date;
1363
+ externalId: string | null;
1364
+ address: string | null;
1365
+ city: string | null;
1366
+ state: string | null;
1367
+ country: string | null;
1368
+ }) | null>;
1369
+
1370
+ /**
1371
+ * BlogPost with author and tags included
1372
+ */
1373
+ type BlogPostWithRelations = BlogPost & {
1374
+ author: {
1375
+ id: string;
1376
+ email: string;
1377
+ };
1378
+ tags: {
1379
+ id: string;
1380
+ name: string;
1381
+ slug: string;
1382
+ }[];
1383
+ };
1384
+ /**
1385
+ * Input for creating a new blog post
1386
+ */
1387
+ interface CreateBlogPostInput {
1388
+ title: string;
1389
+ slug: string;
1390
+ content: string;
1391
+ excerpt?: string;
1392
+ status?: PostStatus;
1393
+ publishedAt?: Date;
1394
+ featuredImageUrl?: string;
1395
+ featuredImageAlt?: string;
1396
+ metaTitle?: string;
1397
+ metaDescription?: string;
1398
+ ogTitle?: string;
1399
+ ogDescription?: string;
1400
+ ogImageUrl?: string;
1401
+ authorId: string;
1402
+ tagIds?: string[];
1403
+ }
1404
+ /**
1405
+ * Input for updating a blog post
1406
+ */
1407
+ interface UpdateBlogPostInput {
1408
+ title?: string;
1409
+ slug?: string;
1410
+ content?: string;
1411
+ excerpt?: string | null;
1412
+ status?: PostStatus;
1413
+ publishedAt?: Date | null;
1414
+ featuredImageUrl?: string | null;
1415
+ featuredImageAlt?: string | null;
1416
+ metaTitle?: string | null;
1417
+ metaDescription?: string | null;
1418
+ ogTitle?: string | null;
1419
+ ogDescription?: string | null;
1420
+ ogImageUrl?: string | null;
1421
+ tagIds?: string[];
1422
+ }
1423
+ /**
1424
+ * Options for querying blog posts
1425
+ */
1426
+ interface FindBlogPostsOptions {
1427
+ take?: number;
1428
+ skip?: number;
1429
+ orderBy?: Prisma.BlogPostOrderByWithRelationInput;
1430
+ where?: Prisma.BlogPostWhereInput;
1431
+ include?: Prisma.BlogPostInclude;
1432
+ }
1433
+ /**
1434
+ * Creates a new blog post
1435
+ */
1436
+ declare function createBlogPost(data: CreateBlogPostInput): Promise<BlogPostWithRelations>;
1437
+ /**
1438
+ * Finds a blog post by ID
1439
+ */
1440
+ declare function findBlogPostById(id: string): Promise<BlogPostWithRelations | null>;
1441
+ /**
1442
+ * Finds a blog post by slug
1443
+ */
1444
+ declare function findBlogPostBySlug(slug: string): Promise<BlogPostWithRelations | null>;
1445
+ /**
1446
+ * Finds multiple blog posts with optional filters
1447
+ */
1448
+ declare function findBlogPosts(options?: FindBlogPostsOptions): Promise<BlogPostWithRelations[]>;
1449
+ /**
1450
+ * Finds only published blog posts (for public access)
1451
+ */
1452
+ declare function findPublishedBlogPosts(options?: Omit<FindBlogPostsOptions, 'where'> & {
1453
+ tagSlug?: string;
1454
+ }): Promise<BlogPostWithRelations[]>;
1455
+ /**
1456
+ * Searches blog posts by title or content
1457
+ */
1458
+ declare function searchBlogPosts(query: string, limit?: number, publishedOnly?: boolean): Promise<BlogPostWithRelations[]>;
1459
+ /**
1460
+ * Updates a blog post
1461
+ */
1462
+ declare function updateBlogPost(id: string, data: UpdateBlogPostInput): Promise<BlogPostWithRelations>;
1463
+ /**
1464
+ * Deletes a blog post
1465
+ */
1466
+ declare function deleteBlogPost(id: string): Promise<BlogPost>;
1467
+ /**
1468
+ * Counts total blog posts
1469
+ */
1470
+ declare function countBlogPosts(where?: Prisma.BlogPostWhereInput): Promise<number>;
1471
+ /**
1472
+ * Counts published blog posts (for public access)
1473
+ */
1474
+ declare function countPublishedBlogPosts(tagSlug?: string): Promise<number>;
1475
+
1476
+ /**
1477
+ * Input for creating a new blog tag
1478
+ */
1479
+ interface CreateBlogTagInput {
1480
+ name: string;
1481
+ slug: string;
1482
+ description?: string;
1483
+ }
1484
+ /**
1485
+ * Input for updating a blog tag
1486
+ */
1487
+ interface UpdateBlogTagInput {
1488
+ name?: string;
1489
+ slug?: string;
1490
+ description?: string | null;
1491
+ }
1492
+ /**
1493
+ * Options for querying blog tags
1494
+ */
1495
+ interface FindBlogTagsOptions {
1496
+ take?: number;
1497
+ skip?: number;
1498
+ orderBy?: Prisma.BlogTagOrderByWithRelationInput;
1499
+ where?: Prisma.BlogTagWhereInput;
1500
+ include?: Prisma.BlogTagInclude;
1501
+ }
1502
+ /**
1503
+ * Creates a new blog tag
1504
+ */
1505
+ declare function createBlogTag(data: CreateBlogTagInput): Promise<BlogTag>;
1506
+ /**
1507
+ * Finds a blog tag by ID
1508
+ */
1509
+ declare function findBlogTagById(id: string): Promise<BlogTag | null>;
1510
+ /**
1511
+ * Finds a blog tag by slug
1512
+ */
1513
+ declare function findBlogTagBySlug(slug: string): Promise<BlogTag | null>;
1514
+ /**
1515
+ * Finds multiple blog tags with optional filters
1516
+ */
1517
+ declare function findBlogTags(options?: FindBlogTagsOptions): Promise<BlogTag[]>;
1518
+ /**
1519
+ * Searches blog tags by name
1520
+ */
1521
+ declare function searchBlogTags(query: string, limit?: number): Promise<BlogTag[]>;
1522
+ /**
1523
+ * Updates a blog tag
1524
+ */
1525
+ declare function updateBlogTag(id: string, data: UpdateBlogTagInput): Promise<BlogTag>;
1526
+ /**
1527
+ * Deletes a blog tag
1528
+ */
1529
+ declare function deleteBlogTag(id: string): Promise<BlogTag>;
1530
+ /**
1531
+ * Counts total blog tags
1532
+ */
1533
+ declare function countBlogTags(where?: Prisma.BlogTagWhereInput): Promise<number>;
1534
+ /**
1535
+ * Gets blog tag with post count
1536
+ */
1537
+ declare function getBlogTagWithPostCount(id: string): Promise<({
1538
+ _count: {
1539
+ posts: number;
1540
+ };
1541
+ } & {
1542
+ name: string;
1543
+ id: string;
1544
+ createdAt: Date;
1545
+ updatedAt: Date;
1546
+ description: string | null;
1547
+ slug: string;
1548
+ }) | null>;
1549
+ /**
1550
+ * Gets all blog tags with post counts
1551
+ */
1552
+ declare function getBlogTagsWithPostCounts(): Promise<({
1553
+ _count: {
1554
+ posts: number;
1555
+ };
1556
+ } & {
1557
+ name: string;
1558
+ id: string;
1559
+ createdAt: Date;
1560
+ updatedAt: Date;
1561
+ description: string | null;
1562
+ slug: string;
1563
+ })[]>;
1564
+
644
1565
  /**
645
1566
  * Re-export Prisma generated types
646
1567
  */
647
1568
 
648
1569
  /**
649
- * Player with full tournament results
1570
+ * Player with full tournament standings
650
1571
  */
651
1572
  interface PlayerWithResults {
652
1573
  player: Player;
653
- results: TournamentResultWithTournament[];
1574
+ results: StandingWithTournament[];
654
1575
  stats: PlayerStatistics;
655
1576
  }
656
1577
  /**
657
- * Tournament result with tournament details
1578
+ * Standing with tournament details
658
1579
  */
659
- interface TournamentResultWithTournament {
1580
+ interface StandingWithTournament {
660
1581
  id: string;
661
1582
  position: number;
662
- totalPoints: number;
663
- decayedPoints: number;
1583
+ isFinals: boolean;
1584
+ totalPoints: number | null;
1585
+ decayedPoints: number | null;
664
1586
  tournament: {
665
1587
  id: string;
666
1588
  name: string;
@@ -700,4 +1622,4 @@ interface ConnectionStatus {
700
1622
  error?: string;
701
1623
  }
702
1624
 
703
- export { type ConnectionStatus, type CreatePlayerInput, type CreateResultInput, type CreateTournamentInput, type CreateUserInput, type FindPlayersOptions, type FindResultsOptions, type FindTournamentsOptions, type PlayerStatistics, type PlayerWithResults, type TournamentResultWithTournament, type TournamentStatistics, type UpdatePlayerInput, type UpdateResultInput, type UpdateTournamentInput, type UpdateUserInput, type UserWithPlayer, connect, countPlayers, countResults, countTournaments, countUsers, createManyResults, createPlayer, createResult, createTournament, createUser, createUserWithPlayer, deletePlayer, deleteResult, deleteResultsByTournament, deleteTournament, deleteUser, disconnect, findPlayerByExternalId, findPlayerById, findPlayerByUserEmail, findPlayers, findResultById, findResultByPlayerAndTournament, findResults, findTournamentByExternalId, findTournamentById, findTournaments, findUserByEmail, findUserById, findUsers, getMajorTournaments, getPlayerResults, getPlayerStats, getPlayerTopFinishes, getPlayerWithResults, getRatedPlayers, getRecentTournaments, getTopPlayersByRanking, getTopPlayersByRating, getTournamentResults, getTournamentStats, getTournamentWithResults, getTournamentsByBoosterType, getTournamentsByDateRange, getUserByEmailWithPlayer, getUserWithPlayer, linkPlayerToUser, prisma, recalculateTimeDecay, searchPlayers, searchTournaments, testConnection, updatePlayer, updatePlayerRating, updateResult, updateResultPoints, updateTournament, updateUser, updateUserRefreshToken };
1625
+ export { type ApiKeyInfo, type ApiKeyWithUser, type BlogPostWithRelations, type ConnectionStatus, type CreateApiKeyInput, type CreateBlogPostInput, type CreateBlogTagInput, type CreateEntryInput, type CreateLocationInput, type CreateMatchInput, type CreateOpprPlayerRankingInput, type CreateOpprRankingHistoryInput, type CreatePlayerInput, type CreateRoundInput, type CreateStandingInput, type CreateTournamentInput, type CreateUserInput, type FindBlogPostsOptions, type FindBlogTagsOptions, type FindEntriesOptions, type FindLocationsOptions, type FindMatchesOptions, type FindOpprPlayerRankingsOptions, type FindPlayersOptions, type FindRoundsOptions, type FindStandingsOptions, type FindTournamentsOptions, MAX_API_KEYS_PER_USER, type MergedStanding, type PlayerStatistics, type PlayerWithResults, type StandingWithTournament, type TournamentStatistics, type UpdateBlogPostInput, type UpdateBlogTagInput, type UpdateEntryInput, type UpdateLocationInput, type UpdateMatchInput, type UpdateOpprPlayerRankingInput, type UpdatePlayerInput, type UpdateRoundInput, type UpdateStandingInput, type UpdateTournamentInput, type UpdateUserInput, type UserWithPlayer, applyRDDecayForInactivePlayers, connect, countBlogPosts, countBlogTags, countEntries, countLocations, countMatches, countOpprPlayerRankings, countOpprRankingHistory, countPlayers, countPublishedBlogPosts, countRounds, countStandings, countTournaments, countUserApiKeys, countUsers, createApiKey, createBlogPost, createBlogTag, createEntry, createLocation, createManyEntries, createManyMatches, createManyRounds, createManyStandings, createMatch, createOpprPlayerRanking, createOpprRankingHistory, createPlayer, createRound, createStanding, createTournament, createUser, createUserWithPlayer, deleteApiKey, deleteBlogPost, deleteBlogTag, deleteEntriesByMatch, deleteEntry, deleteLocation, deleteMatch, deleteMatchesByRound, deleteMatchesByTournament, deleteOpprPlayerRanking, deletePlayer, deleteRound, deleteRoundsByTournament, deleteStanding, deleteStandingsByTournament, deleteTournament, deleteUser, deleteUserApiKey, disconnect, findApiKeyById, findApiKeysByPrefix, findBlogPostById, findBlogPostBySlug, findBlogPosts, findBlogTagById, findBlogTagBySlug, findBlogTags, findEntries, findEntryById, findEntryByMatchAndPlayer, findLocationByExternalId, findLocationById, findLocations, findMatchById, findMatches, findOpprPlayerRankingById, findOpprPlayerRankingByPlayerId, findOpprPlayerRankings, findPlayerByExternalId, findPlayerById, findPlayerByPlayerNumber, findPlayerByUserEmail, findPlayers, findPublishedBlogPosts, findRoundById, findRoundByTournamentAndNumber, findRounds, findStandingById, findStandingByPlayerAndTournament, findStandings, findTournamentByExternalId, findTournamentById, findTournaments, findUserByEmail, findUserById, findUsers, generateUniquePlayerNumber, getBlogTagWithPostCount, getBlogTagsWithPostCounts, getFinalsRounds, getFinalsStandings, getLatestOpprRankingHistory, getLocationWithTournaments, getMajorTournaments, getMatchEntries, getMatchWithEntries, getMergedStandings, getOpprRankingHistory, getOpprRankingHistoryByDateRange, getOrCreateOpprPlayerRanking, getPlayerEntries, getPlayerEntryStats, getPlayerStandings, getPlayerStats, getPlayerTopFinishes, getPlayerTournamentEntries, getPlayerTournamentMatches, getPlayerWithResults, getQualifyingRounds, getQualifyingStandings, getRatedOpprPlayers, getRecentTournaments, getRoundMatches, getRoundWithMatches, getTopPlayersByOpprRanking, getTopPlayersByOpprRating, getTournamentMatches, getTournamentRounds, getTournamentStandings, getTournamentStats, getTournamentWithMatches, getTournamentWithResults, getTournamentsByBoosterType, getTournamentsByDateRange, getUserApiKeys, getUserByEmailWithPlayer, getUserWithPlayer, isValidPlayerNumber, linkPlayerToUser, prisma, recalculateTimeDecay, searchBlogPosts, searchBlogTags, searchLocations, searchPlayers, searchTournaments, testConnection, updateApiKeyLastUsed, updateBlogPost, updateBlogTag, updateEntry, updateLocation, updateMatch, updateOpprPlayerRanking, updateOpprRatingAfterTournament, updatePlayer, updateRound, updateStanding, updateStandingPoints, updateTournament, updateUser, updateUserRefreshToken, updateWorldRankings };