@mshowes/brackets-manager 1.8.1

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.
Files changed (59) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +82 -0
  3. package/dist/base/getter.d.ts +272 -0
  4. package/dist/base/getter.d.ts.map +1 -0
  5. package/dist/base/getter.js +545 -0
  6. package/dist/base/getter.js.map +1 -0
  7. package/dist/base/stage/creator.d.ts +269 -0
  8. package/dist/base/stage/creator.d.ts.map +1 -0
  9. package/dist/base/stage/creator.js +735 -0
  10. package/dist/base/stage/creator.js.map +1 -0
  11. package/dist/base/updater.d.ts +121 -0
  12. package/dist/base/updater.d.ts.map +1 -0
  13. package/dist/base/updater.js +323 -0
  14. package/dist/base/updater.js.map +1 -0
  15. package/dist/create.d.ts +25 -0
  16. package/dist/create.d.ts.map +1 -0
  17. package/dist/create.js +55 -0
  18. package/dist/create.js.map +1 -0
  19. package/dist/delete.d.ts +33 -0
  20. package/dist/delete.d.ts.map +1 -0
  21. package/dist/delete.js +57 -0
  22. package/dist/delete.js.map +1 -0
  23. package/dist/find.d.ts +60 -0
  24. package/dist/find.d.ts.map +1 -0
  25. package/dist/find.js +196 -0
  26. package/dist/find.js.map +1 -0
  27. package/dist/get.d.ts +121 -0
  28. package/dist/get.d.ts.map +1 -0
  29. package/dist/get.js +420 -0
  30. package/dist/get.js.map +1 -0
  31. package/dist/helpers.d.ts +804 -0
  32. package/dist/helpers.d.ts.map +1 -0
  33. package/dist/helpers.js +1897 -0
  34. package/dist/helpers.js.map +1 -0
  35. package/dist/index.d.ts +11 -0
  36. package/dist/index.d.ts.map +1 -0
  37. package/dist/index.js +21 -0
  38. package/dist/index.js.map +1 -0
  39. package/dist/manager.d.ts +60 -0
  40. package/dist/manager.d.ts.map +1 -0
  41. package/dist/manager.js +189 -0
  42. package/dist/manager.js.map +1 -0
  43. package/dist/ordering.d.ts +7 -0
  44. package/dist/ordering.d.ts.map +1 -0
  45. package/dist/ordering.js +147 -0
  46. package/dist/ordering.js.map +1 -0
  47. package/dist/reset.d.ts +27 -0
  48. package/dist/reset.d.ts.map +1 -0
  49. package/dist/reset.js +82 -0
  50. package/dist/reset.js.map +1 -0
  51. package/dist/types.d.ts +260 -0
  52. package/dist/types.d.ts.map +1 -0
  53. package/dist/types.js +3 -0
  54. package/dist/types.js.map +1 -0
  55. package/dist/update.d.ts +111 -0
  56. package/dist/update.d.ts.map +1 -0
  57. package/dist/update.js +265 -0
  58. package/dist/update.js.map +1 -0
  59. package/package.json +67 -0
@@ -0,0 +1,545 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BaseGetter = void 0;
4
+ const helpers = require("../helpers");
5
+ class BaseGetter {
6
+ /**
7
+ * Creates an instance of a Storage getter.
8
+ *
9
+ * @param storage The implementation of Storage.
10
+ */
11
+ constructor(storage) {
12
+ this.storage = storage;
13
+ }
14
+ /**
15
+ * Gets all the rounds that contain ordered participants.
16
+ *
17
+ * @param stage The stage to get rounds from.
18
+ */
19
+ async getOrderedRounds(stage) {
20
+ if (!(stage === null || stage === void 0 ? void 0 : stage.settings.size))
21
+ throw Error('The stage has no size.');
22
+ if (stage.type === 'single_elimination')
23
+ return this.getOrderedRoundsSingleElimination(stage.id);
24
+ return this.getOrderedRoundsDoubleElimination(stage.id);
25
+ }
26
+ /**
27
+ * Gets all the rounds that contain ordered participants in a single elimination stage.
28
+ *
29
+ * @param stageId ID of the stage.
30
+ */
31
+ async getOrderedRoundsSingleElimination(stageId) {
32
+ return [await this.getUpperBracketFirstRound(stageId)];
33
+ }
34
+ /**
35
+ * Gets all the rounds that contain ordered participants in a double elimination stage.
36
+ *
37
+ * @param stageId ID of the stage.
38
+ */
39
+ async getOrderedRoundsDoubleElimination(stageId) {
40
+ // Getting all rounds instead of cherry-picking them is the least expensive.
41
+ const rounds = await this.storage.select('round', { stage_id: stageId });
42
+ if (!rounds)
43
+ throw Error('Error getting rounds.');
44
+ const loserBracket = await this.getLoserBracket(stageId);
45
+ if (!loserBracket)
46
+ throw Error('Loser bracket not found.');
47
+ const firstRoundWB = rounds[0];
48
+ const roundsLB = rounds.filter(r => r.group_id === loserBracket.id);
49
+ const orderedRoundsLB = roundsLB.filter(r => helpers.isOrderingSupportedLoserBracket(r.number, roundsLB.length));
50
+ return [firstRoundWB, ...orderedRoundsLB];
51
+ }
52
+ /**
53
+ * Gets the positional information (number in group and total number of rounds in group) of a round based on its id.
54
+ *
55
+ * @param roundId ID of the round.
56
+ */
57
+ async getRoundPositionalInfo(roundId) {
58
+ const round = await this.storage.select('round', roundId);
59
+ if (!round)
60
+ throw Error('Round not found.');
61
+ const rounds = await this.storage.select('round', { group_id: round.group_id });
62
+ if (!rounds)
63
+ throw Error('Error getting rounds.');
64
+ return {
65
+ roundNumber: round.number,
66
+ roundCount: rounds.length,
67
+ };
68
+ }
69
+ /**
70
+ * Gets the matches leading to the given match.
71
+ *
72
+ * @param match The current match.
73
+ * @param matchLocation Location of the current match.
74
+ * @param stage The parent stage.
75
+ * @param roundNumber Number of the round.
76
+ */
77
+ async getPreviousMatches(match, matchLocation, stage, roundNumber) {
78
+ if (matchLocation === 'loser_bracket')
79
+ return this.getPreviousMatchesLB(match, stage, roundNumber);
80
+ if (matchLocation === 'final_group')
81
+ return this.getPreviousMatchesFinal(match, stage, roundNumber);
82
+ if (roundNumber === 1)
83
+ return []; // The match is in the first round of an upper bracket.
84
+ return this.getMatchesBeforeMajorRound(match, roundNumber);
85
+ }
86
+ /**
87
+ * Gets the matches leading to the given match, which is in a final group (consolation final or grand final).
88
+ *
89
+ * @param match The current match.
90
+ * @param stage The parent stage.
91
+ * @param roundNumber Number of the current round.
92
+ */
93
+ async getPreviousMatchesFinal(match, stage, roundNumber) {
94
+ if (stage.type === 'single_elimination')
95
+ return this.getPreviousMatchesFinalSingleElimination(match, stage);
96
+ return this.getPreviousMatchesFinalDoubleElimination(match, roundNumber);
97
+ }
98
+ /**
99
+ * Gets the matches leading to the given match, which is in a final group (consolation final).
100
+ *
101
+ * @param match The current match.
102
+ * @param stage The parent stage.
103
+ */
104
+ async getPreviousMatchesFinalSingleElimination(match, stage) {
105
+ const upperBracket = await this.getUpperBracket(match.stage_id);
106
+ const upperBracketRoundCount = helpers.getUpperBracketRoundCount(stage.settings.size);
107
+ const semiFinalsRound = await this.storage.selectFirst('round', {
108
+ group_id: upperBracket.id,
109
+ number: upperBracketRoundCount - 1, // Second to last round
110
+ });
111
+ if (!semiFinalsRound)
112
+ throw Error('Semi finals round not found.');
113
+ const semiFinalMatches = await this.storage.select('match', {
114
+ round_id: semiFinalsRound.id,
115
+ });
116
+ if (!semiFinalMatches)
117
+ throw Error('Error getting semi final matches.');
118
+ // In single elimination, both the final and consolation final have the same previous matches.
119
+ return semiFinalMatches;
120
+ }
121
+ /**
122
+ * Gets the matches leading to the given match, which is in a final group (grand final).
123
+ *
124
+ * @param match The current match.
125
+ * @param roundNumber Number of the current round.
126
+ */
127
+ async getPreviousMatchesFinalDoubleElimination(match, roundNumber) {
128
+ if (roundNumber > 1) // Double grand final
129
+ return [await this.findMatch(match.group_id, roundNumber - 1, 1)];
130
+ const winnerBracket = await this.getUpperBracket(match.stage_id);
131
+ const lastRoundWB = await this.getLastRound(winnerBracket.id);
132
+ const winnerBracketFinalMatch = await this.storage.selectFirst('match', {
133
+ round_id: lastRoundWB.id,
134
+ number: 1,
135
+ });
136
+ if (!winnerBracketFinalMatch)
137
+ throw Error('Match not found.');
138
+ const loserBracket = await this.getLoserBracket(match.stage_id);
139
+ if (!loserBracket)
140
+ throw Error('Loser bracket not found.');
141
+ const lastRoundLB = await this.getLastRound(loserBracket.id);
142
+ const loserBracketFinalMatch = await this.storage.selectFirst('match', {
143
+ round_id: lastRoundLB.id,
144
+ number: 1,
145
+ });
146
+ if (!loserBracketFinalMatch)
147
+ throw Error('Match not found.');
148
+ return [winnerBracketFinalMatch, loserBracketFinalMatch];
149
+ }
150
+ /**
151
+ * Gets the matches leading to a given match from the loser bracket.
152
+ *
153
+ * @param match The current match.
154
+ * @param stage The parent stage.
155
+ * @param roundNumber Number of the round.
156
+ */
157
+ async getPreviousMatchesLB(match, stage, roundNumber) {
158
+ if (stage.settings.skipFirstRound && roundNumber === 1)
159
+ return [];
160
+ if (helpers.hasBye(match))
161
+ return []; // Shortcut because we are coming from propagateByes().
162
+ const winnerBracket = await this.getUpperBracket(match.stage_id);
163
+ const actualRoundNumberWB = Math.ceil((roundNumber + 1) / 2);
164
+ const roundNumberWB = stage.settings.skipFirstRound ? actualRoundNumberWB - 1 : actualRoundNumberWB;
165
+ if (roundNumber === 1)
166
+ return this.getMatchesBeforeFirstRoundLB(match, winnerBracket.id, roundNumberWB);
167
+ if (helpers.isMajorRound(roundNumber))
168
+ return this.getMatchesBeforeMajorRound(match, roundNumber);
169
+ return this.getMatchesBeforeMinorRoundLB(match, winnerBracket.id, roundNumber, roundNumberWB);
170
+ }
171
+ /**
172
+ * Gets the matches leading to a given match in a major round (every round of upper bracket or specific ones in lower bracket).
173
+ *
174
+ * @param match The current match.
175
+ * @param roundNumber Number of the round.
176
+ */
177
+ async getMatchesBeforeMajorRound(match, roundNumber) {
178
+ return [
179
+ await this.findMatch(match.group_id, roundNumber - 1, match.number * 2 - 1),
180
+ await this.findMatch(match.group_id, roundNumber - 1, match.number * 2),
181
+ ];
182
+ }
183
+ /**
184
+ * Gets the matches leading to a given match in the first round of the loser bracket.
185
+ *
186
+ * @param match The current match.
187
+ * @param winnerBracketId ID of the winner bracket.
188
+ * @param roundNumberWB The number of the previous round in the winner bracket.
189
+ */
190
+ async getMatchesBeforeFirstRoundLB(match, winnerBracketId, roundNumberWB) {
191
+ return [
192
+ await this.findMatch(winnerBracketId, roundNumberWB, helpers.getOriginPosition(match, 'opponent1')),
193
+ await this.findMatch(winnerBracketId, roundNumberWB, helpers.getOriginPosition(match, 'opponent2')),
194
+ ];
195
+ }
196
+ /**
197
+ * Gets the matches leading to a given match in a minor round of the loser bracket.
198
+ *
199
+ * @param match The current match.
200
+ * @param winnerBracketId ID of the winner bracket.
201
+ * @param roundNumber Number of the current round.
202
+ * @param roundNumberWB The number of the previous round in the winner bracket.
203
+ */
204
+ async getMatchesBeforeMinorRoundLB(match, winnerBracketId, roundNumber, roundNumberWB) {
205
+ const matchNumber = helpers.getOriginPosition(match, 'opponent1');
206
+ return [
207
+ await this.findMatch(winnerBracketId, roundNumberWB, matchNumber),
208
+ await this.findMatch(match.group_id, roundNumber - 1, match.number),
209
+ ];
210
+ }
211
+ /**
212
+ * Gets the match(es) where the opponents of the current match will go just after.
213
+ *
214
+ * @param match The current match.
215
+ * @param matchLocation Location of the current match.
216
+ * @param stage The parent stage.
217
+ * @param roundNumber The number of the current round.
218
+ * @param roundCount Count of rounds.
219
+ */
220
+ async getNextMatches(match, matchLocation, stage, roundNumber, roundCount) {
221
+ switch (matchLocation) {
222
+ case 'single_bracket':
223
+ return this.getNextMatchesUpperBracket(match, stage, roundNumber, roundCount);
224
+ case 'winner_bracket':
225
+ return this.getNextMatchesWB(match, stage, roundNumber, roundCount);
226
+ case 'loser_bracket':
227
+ return this.getNextMatchesLB(match, stage, roundNumber, roundCount);
228
+ case 'final_group':
229
+ return this.getNextMatchesFinal(match, stage, roundNumber, roundCount);
230
+ default:
231
+ throw Error('Unknown bracket kind.');
232
+ }
233
+ }
234
+ /**
235
+ * Gets the match(es) where the opponents of the current match of winner bracket will go just after.
236
+ *
237
+ * @param match The current match.
238
+ * @param stage The parent stage.
239
+ * @param roundNumber The number of the current round.
240
+ * @param roundCount Count of rounds.
241
+ */
242
+ async getNextMatchesWB(match, stage, roundNumber, roundCount) {
243
+ const loserBracket = await this.getLoserBracket(match.stage_id);
244
+ if (loserBracket === null) // Only one match in the stage, there is no loser bracket.
245
+ return [];
246
+ const actualRoundNumber = stage.settings.skipFirstRound ? roundNumber + 1 : roundNumber;
247
+ const roundNumberLB = actualRoundNumber > 1 ? (actualRoundNumber - 1) * 2 : 1;
248
+ const participantCount = stage.settings.size;
249
+ const method = helpers.getLoserOrdering(stage.settings.seedOrdering, roundNumberLB);
250
+ const actualMatchNumberLB = helpers.findLoserMatchNumber(participantCount, roundNumberLB, match.number, method);
251
+ return [
252
+ ...await this.getNextMatchesUpperBracket(match, stage, roundNumber, roundCount),
253
+ await this.findMatch(loserBracket.id, roundNumberLB, actualMatchNumberLB),
254
+ ];
255
+ }
256
+ /**
257
+ * Gets the match(es) where the opponents of the current match of an upper bracket will go just after.
258
+ *
259
+ * @param match The current match.
260
+ * @param stage The parent stage.
261
+ * @param roundNumber The number of the current round.
262
+ * @param roundCount Count of rounds.
263
+ */
264
+ async getNextMatchesUpperBracket(match, stage, roundNumber, roundCount) {
265
+ if (stage.type === 'single_elimination')
266
+ return this.getNextMatchesUpperBracketSingleElimination(match, stage.type, roundNumber, roundCount);
267
+ return this.getNextMatchesUpperBracketDoubleElimination(match, stage.type, roundNumber, roundCount);
268
+ }
269
+ /**
270
+ * Gets the match(es) where the opponents of the current match of the unique bracket of a single elimination will go just after.
271
+ *
272
+ * @param match The current match.
273
+ * @param stageType Type of the stage.
274
+ * @param roundNumber The number of the current round.
275
+ * @param roundCount Count of rounds.
276
+ */
277
+ async getNextMatchesUpperBracketSingleElimination(match, stageType, roundNumber, roundCount) {
278
+ if (roundNumber === roundCount - 1) {
279
+ const finalGroupId = await this.getFinalGroupId(match.stage_id, stageType);
280
+ const consolationFinal = await this.getFinalGroupFirstMatch(finalGroupId);
281
+ return [
282
+ await this.getDiagonalMatch(match.group_id, roundNumber, match.number),
283
+ ...consolationFinal ? [consolationFinal] : [],
284
+ ];
285
+ }
286
+ if (roundNumber === roundCount)
287
+ return [];
288
+ return [await this.getDiagonalMatch(match.group_id, roundNumber, match.number)];
289
+ }
290
+ /**
291
+ * Gets the match(es) where the opponents of the current match of the unique bracket of a double elimination will go just after.
292
+ *
293
+ * @param match The current match.
294
+ * @param stageType Type of the stage.
295
+ * @param roundNumber The number of the current round.
296
+ * @param roundCount Count of rounds.
297
+ */
298
+ async getNextMatchesUpperBracketDoubleElimination(match, stageType, roundNumber, roundCount) {
299
+ if (roundNumber === roundCount) {
300
+ const finalGroupId = await this.getFinalGroupId(match.stage_id, stageType);
301
+ return [await this.getFinalGroupFirstMatch(finalGroupId)];
302
+ }
303
+ return [await this.getDiagonalMatch(match.group_id, roundNumber, match.number)];
304
+ }
305
+ /**
306
+ * Gets the match(es) where the opponents of the current match of loser bracket will go just after.
307
+ *
308
+ * @param match The current match.
309
+ * @param stage The parent stage.
310
+ * @param roundNumber The number of the current round.
311
+ * @param roundCount Count of rounds.
312
+ */
313
+ async getNextMatchesLB(match, stage, roundNumber, roundCount) {
314
+ if (roundNumber === roundCount - 1) {
315
+ const finalGroupId = await this.getFinalGroupId(match.stage_id, stage.type);
316
+ const consolationFinal = await this.getConsolationFinalMatchDoubleElimination(finalGroupId);
317
+ return [
318
+ ...await this.getMatchAfterMajorRoundLB(match, roundNumber),
319
+ ...consolationFinal ? [consolationFinal] : [], // Loser goes in consolation.
320
+ ];
321
+ }
322
+ if (roundNumber === roundCount) {
323
+ const finalGroupId = await this.getFinalGroupId(match.stage_id, stage.type);
324
+ const grandFinal = await this.getFinalGroupFirstMatch(finalGroupId);
325
+ const consolationFinal = await this.getConsolationFinalMatchDoubleElimination(finalGroupId);
326
+ return [
327
+ grandFinal,
328
+ ...consolationFinal ? [consolationFinal] : [], // Returned array is length 1 if no consolation final.
329
+ ];
330
+ }
331
+ if (helpers.isMajorRound(roundNumber))
332
+ return this.getMatchAfterMajorRoundLB(match, roundNumber);
333
+ return this.getMatchAfterMinorRoundLB(match, roundNumber);
334
+ }
335
+ /**
336
+ * Gets the first match of the final group (consolation final or grand final).
337
+ *
338
+ * @param finalGroupId ID of the final group.
339
+ */
340
+ async getFinalGroupFirstMatch(finalGroupId) {
341
+ if (finalGroupId === null)
342
+ return null; // `null` is required for `getNextMatchesWB()` because of how `applyToNextMatches()` works.
343
+ return this.findMatch(finalGroupId, 1, 1);
344
+ }
345
+ /**
346
+ * Gets the consolation final in a double elimination tournament.
347
+ *
348
+ * @param finalGroupId ID of the final group.
349
+ */
350
+ async getConsolationFinalMatchDoubleElimination(finalGroupId) {
351
+ if (finalGroupId === null)
352
+ return null;
353
+ return this.storage.selectFirst('match', {
354
+ group_id: finalGroupId,
355
+ number: 2, // Used to differentiate grand final and consolation final matches in the same final group.
356
+ });
357
+ }
358
+ /**
359
+ * Gets the match following the current match, which is in the final group (consolation final or grand final).
360
+ *
361
+ * @param match The current match.
362
+ * @param stage The parent stage.
363
+ * @param roundNumber The number of the current round.
364
+ * @param roundCount The count of rounds.
365
+ */
366
+ async getNextMatchesFinal(match, stage, roundNumber, roundCount) {
367
+ if (roundNumber === roundCount)
368
+ return [];
369
+ if (stage.settings.consolationFinal && match.number === 1 && roundNumber === roundCount - 1)
370
+ return []; // Current match is the last grand final match.
371
+ return [await this.findMatch(match.group_id, roundNumber + 1, 1)];
372
+ }
373
+ /**
374
+ * Gets the match where the opponents of the current match of a winner bracket's major round will go just after.
375
+ *
376
+ * @param match The current match.
377
+ * @param roundNumber The number of the current round.
378
+ */
379
+ async getMatchAfterMajorRoundLB(match, roundNumber) {
380
+ return [await this.getParallelMatch(match.group_id, roundNumber, match.number)];
381
+ }
382
+ /**
383
+ * Gets the match where the opponents of the current match of a winner bracket's minor round will go just after.
384
+ *
385
+ * @param match The current match.
386
+ * @param roundNumber The number of the current round.
387
+ */
388
+ async getMatchAfterMinorRoundLB(match, roundNumber) {
389
+ return [await this.getDiagonalMatch(match.group_id, roundNumber, match.number)];
390
+ }
391
+ /**
392
+ * Returns the good seeding ordering based on the stage's type.
393
+ *
394
+ * @param stageType The type of the stage.
395
+ * @param create A reference to a Create instance.
396
+ */
397
+ static getSeedingOrdering(stageType, create) {
398
+ return stageType === 'round_robin' ? create.getRoundRobinOrdering() : create.getStandardBracketFirstRoundOrdering();
399
+ }
400
+ /**
401
+ * Returns the matches which contain the seeding of a stage based on its type.
402
+ *
403
+ * @param stageId ID of the stage.
404
+ * @param stageType The type of the stage.
405
+ */
406
+ async getSeedingMatches(stageId, stageType) {
407
+ if (stageType === 'round_robin')
408
+ return this.storage.select('match', { stage_id: stageId });
409
+ try {
410
+ const firstRound = await this.getUpperBracketFirstRound(stageId);
411
+ return this.storage.select('match', { round_id: firstRound.id });
412
+ }
413
+ catch {
414
+ return []; // The stage may have not been created yet.
415
+ }
416
+ }
417
+ /**
418
+ * Gets the first round of the upper bracket.
419
+ *
420
+ * @param stageId ID of the stage.
421
+ */
422
+ async getUpperBracketFirstRound(stageId) {
423
+ // Considering the database is ordered, this round will always be the first round of the upper bracket.
424
+ const firstRound = await this.storage.selectFirst('round', { stage_id: stageId, number: 1 }, false);
425
+ if (!firstRound)
426
+ throw Error('Round not found.');
427
+ return firstRound;
428
+ }
429
+ /**
430
+ * Gets the last round of a group.
431
+ *
432
+ * @param groupId ID of the group.
433
+ */
434
+ async getLastRound(groupId) {
435
+ const round = await this.storage.selectLast('round', { group_id: groupId }, false);
436
+ if (!round)
437
+ throw Error('Error getting rounds.');
438
+ return round;
439
+ }
440
+ /**
441
+ * Returns the id of the final group (containing consolation final, or grand final, or both).
442
+ *
443
+ * @param stageId ID of the stage.
444
+ * @param stageType Type of the stage.
445
+ */
446
+ async getFinalGroupId(stageId, stageType) {
447
+ const groupNumber = stageType === 'single_elimination' ? 2 /* single bracket + final */ : 3 /* winner bracket + loser bracket + final */;
448
+ const finalGroup = await this.storage.selectFirst('group', { stage_id: stageId, number: groupNumber });
449
+ if (!finalGroup)
450
+ return null;
451
+ return finalGroup.id;
452
+ }
453
+ /**
454
+ * Gets the upper bracket (the only bracket if single elimination or the winner bracket in double elimination).
455
+ *
456
+ * @param stageId ID of the stage.
457
+ */
458
+ async getUpperBracket(stageId) {
459
+ const winnerBracket = await this.storage.selectFirst('group', { stage_id: stageId, number: 1 });
460
+ if (!winnerBracket)
461
+ throw Error('Winner bracket not found.');
462
+ return winnerBracket;
463
+ }
464
+ /**
465
+ * Gets the loser bracket.
466
+ *
467
+ * @param stageId ID of the stage.
468
+ */
469
+ async getLoserBracket(stageId) {
470
+ return this.storage.selectFirst('group', { stage_id: stageId, number: 2 });
471
+ }
472
+ /**
473
+ * Gets the corresponding match in the next round ("diagonal match") the usual way.
474
+ *
475
+ * Just like from Round 1 to Round 2 in a single elimination stage.
476
+ *
477
+ * @param groupId ID of the group.
478
+ * @param roundNumber Number of the round in its parent group.
479
+ * @param matchNumber Number of the match in its parent round.
480
+ */
481
+ async getDiagonalMatch(groupId, roundNumber, matchNumber) {
482
+ return this.findMatch(groupId, roundNumber + 1, helpers.getDiagonalMatchNumber(matchNumber));
483
+ }
484
+ /**
485
+ * Gets the corresponding match in the next round ("parallel match") the "major round to minor round" way.
486
+ *
487
+ * Just like from Round 1 to Round 2 in the loser bracket of a double elimination stage.
488
+ *
489
+ * @param groupId ID of the group.
490
+ * @param roundNumber Number of the round in its parent group.
491
+ * @param matchNumber Number of the match in its parent round.
492
+ */
493
+ async getParallelMatch(groupId, roundNumber, matchNumber) {
494
+ return this.findMatch(groupId, roundNumber + 1, matchNumber);
495
+ }
496
+ /**
497
+ * Finds a match in a given group. The match must have the given number in a round of which the number in group is given.
498
+ *
499
+ * **Example:** In group of id 1, give me the 4th match in the 3rd round.
500
+ *
501
+ * @param groupId ID of the group.
502
+ * @param roundNumber Number of the round in its parent group.
503
+ * @param matchNumber Number of the match in its parent round.
504
+ */
505
+ async findMatch(groupId, roundNumber, matchNumber) {
506
+ const round = await this.storage.selectFirst('round', {
507
+ group_id: groupId,
508
+ number: roundNumber,
509
+ });
510
+ if (!round)
511
+ throw Error('Round not found.');
512
+ const match = await this.storage.selectFirst('match', {
513
+ round_id: round.id,
514
+ number: matchNumber,
515
+ });
516
+ if (!match)
517
+ throw Error('Match not found.');
518
+ return match;
519
+ }
520
+ /**
521
+ * Finds a match game based on its `id` or based on the combination of its `parent_id` and `number`.
522
+ *
523
+ * @param game Values to change in a match game.
524
+ */
525
+ async findMatchGame(game) {
526
+ if (game.id !== undefined) {
527
+ const stored = await this.storage.select('match_game', game.id);
528
+ if (!stored)
529
+ throw Error('Match game not found.');
530
+ return stored;
531
+ }
532
+ if (game.parent_id !== undefined && game.number) {
533
+ const stored = await this.storage.selectFirst('match_game', {
534
+ parent_id: game.parent_id,
535
+ number: game.number,
536
+ });
537
+ if (!stored)
538
+ throw Error('Match game not found.');
539
+ return stored;
540
+ }
541
+ throw Error('No match game id nor parent id and number given.');
542
+ }
543
+ }
544
+ exports.BaseGetter = BaseGetter;
545
+ //# sourceMappingURL=getter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getter.js","sourceRoot":"","sources":["../../src/base/getter.ts"],"names":[],"mappings":";;;AAIA,sCAAsC;AAEtC,MAAa,UAAU;IAInB;;;;OAIG;IACH,YAAY,OAAgB;QACxB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IAC3B,CAAC;IAED;;;;OAIG;IACO,KAAK,CAAC,gBAAgB,CAAC,KAAY;QACzC,IAAI,CAAC,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,QAAQ,CAAC,IAAI,CAAA;YAAE,MAAM,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAEjE,IAAI,KAAK,CAAC,IAAI,KAAK,oBAAoB;YACnC,OAAO,IAAI,CAAC,iCAAiC,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAE5D,OAAO,IAAI,CAAC,iCAAiC,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAC5D,CAAC;IAED;;;;OAIG;IACK,KAAK,CAAC,iCAAiC,CAAC,OAAW;QACvD,OAAO,CAAC,MAAM,IAAI,CAAC,yBAAyB,CAAC,OAAO,CAAC,CAAC,CAAC;IAC3D,CAAC;IAED;;;;OAIG;IACK,KAAK,CAAC,iCAAiC,CAAC,OAAW;QACvD,4EAA4E;QAC5E,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CA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