@opprs/db-prisma 2.2.0 → 2.2.1-canary.11b4651

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