@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,269 @@
1
+ import { Id, InputStage, SeedOrdering, Stage } from 'brackets-model';
2
+ import { Storage, ParticipantSlot } from '../../types';
3
+ import { BracketsManager } from '../..';
4
+ /**
5
+ * Creates a stage.
6
+ *
7
+ * @param this Instance of BracketsManager.
8
+ * @param stage The stage to create.
9
+ */
10
+ export declare function create(this: BracketsManager, stage: InputStage): Promise<Stage>;
11
+ export declare class StageCreator {
12
+ private storage;
13
+ private stage;
14
+ private readonly seedOrdering;
15
+ private updateMode;
16
+ private enableByesInUpdate;
17
+ private currentStageId;
18
+ /**
19
+ * Creates an instance of StageCreator, which will handle the creation of the stage.
20
+ *
21
+ * @param storage The implementation of Storage.
22
+ * @param stage The stage to create.
23
+ */
24
+ constructor(storage: Storage, stage: InputStage);
25
+ /**
26
+ * Run the creation process.
27
+ */
28
+ run(): Promise<Stage>;
29
+ /**
30
+ * Enables the update mode.
31
+ *
32
+ * @param stageId ID of the stage.
33
+ * @param enableByes Whether to use BYEs or TBDs for `null` values in an input seeding.
34
+ */
35
+ setExisting(stageId: Id, enableByes: boolean): void;
36
+ /**
37
+ * Creates a round-robin stage.
38
+ *
39
+ * Group count must be given. It will distribute participants in groups and rounds.
40
+ */
41
+ private roundRobin;
42
+ /**
43
+ * Creates a single elimination stage.
44
+ *
45
+ * One bracket and optionally a consolation final between semi-final losers.
46
+ */
47
+ private singleElimination;
48
+ /**
49
+ * Creates a double elimination stage.
50
+ *
51
+ * One upper bracket (winner bracket, WB), one lower bracket (loser bracket, LB) and optionally a grand final
52
+ * between the winner of both bracket, which can be simple or double.
53
+ */
54
+ private doubleElimination;
55
+ /**
56
+ * Creates a double elimination stage with skip first round option.
57
+ *
58
+ * @param stageId ID of the stage.
59
+ * @param slots A list of slots.
60
+ */
61
+ private createDoubleEliminationSkipFirstRound;
62
+ /**
63
+ * Creates a double elimination stage.
64
+ *
65
+ * @param stageId ID of the stage.
66
+ * @param slots A list of slots.
67
+ */
68
+ private createDoubleElimination;
69
+ /**
70
+ * Creates a round-robin group.
71
+ *
72
+ * This will make as many rounds as needed to let each participant match every other once.
73
+ *
74
+ * @param stageId ID of the parent stage.
75
+ * @param groupNumber Number of the group in the stage.
76
+ * @param slots A list of slots.
77
+ */
78
+ private createRoundRobinGroup;
79
+ /**
80
+ * Creates a standard bracket, which is the only one in single elimination and the upper one in double elimination.
81
+ *
82
+ * This will make as many rounds as needed to end with one winner.
83
+ *
84
+ * @param stageId ID of the parent stage.
85
+ * @param groupNumber Number of the group in the stage.
86
+ * @param slots A list of slots.
87
+ */
88
+ private createStandardBracket;
89
+ /**
90
+ * Creates a lower bracket, alternating between major and minor rounds.
91
+ *
92
+ * - A major round is a regular round.
93
+ * - A minor round matches the previous (major) round's winners against upper bracket losers of the corresponding round.
94
+ *
95
+ * @param stageId ID of the parent stage.
96
+ * @param groupNumber Number of the group in the stage.
97
+ * @param losers One list of losers per upper bracket round.
98
+ */
99
+ private createLowerBracket;
100
+ /**
101
+ * Creates a bracket with rounds that only have 1 match each. Used for finals.
102
+ *
103
+ * @param stageId ID of the parent stage.
104
+ * @param groupNumber Number of the group in the stage.
105
+ * @param duels A list of duels.
106
+ * @param overrides Optional overrides.
107
+ */
108
+ private createUniqueMatchBracket;
109
+ /**
110
+ * Creates a round, which contain matches.
111
+ *
112
+ * @param stageId ID of the parent stage.
113
+ * @param groupId ID of the parent group.
114
+ * @param roundNumber Number in the group.
115
+ * @param matchCount Duel/match count.
116
+ * @param duels A list of duels.
117
+ * @param matchNumberStart Optionally give the starting point for the match numbers. Starts at 1 by default.
118
+ */
119
+ private createRound;
120
+ /**
121
+ * Creates a match, possibly with match games.
122
+ *
123
+ * - If `childCount` is 0, then there is no children. The score of the match is directly its intrinsic score.
124
+ * - If `childCount` is greater than 0, then the score of the match will automatically be calculated based on its child games.
125
+ *
126
+ * @param stageId ID of the parent stage.
127
+ * @param groupId ID of the parent group.
128
+ * @param roundId ID of the parent round.
129
+ * @param matchNumber Number in the round.
130
+ * @param opponents The two opponents matching against each other.
131
+ * @param childCount Child count for this match (number of games).
132
+ */
133
+ private createMatch;
134
+ /**
135
+ * Gets the duels for the current round based on the previous one. No ordering is done, it must be done beforehand for the first round.
136
+ *
137
+ * @param previousDuels Duels of the previous round.
138
+ * @param currentDuelCount Count of duels (matches) in the current round.
139
+ */
140
+ private getCurrentDuels;
141
+ /**
142
+ * Returns a list of slots.
143
+ * - If `seeding` was given, inserts them in the storage.
144
+ * - If `size` was given, only returns a list of empty slots.
145
+ *
146
+ * @param positions An optional list of positions (seeds) for a manual ordering.
147
+ */
148
+ getSlots(positions?: number[]): Promise<ParticipantSlot[]>;
149
+ /**
150
+ * Returns the list of slots with a seeding containing names. Participants may be added to database.
151
+ *
152
+ * @param seeding The seeding (names).
153
+ * @param positions An optional list of positions (seeds) for a manual ordering.
154
+ */
155
+ private getSlotsUsingNames;
156
+ /**
157
+ * Returns the list of slots with a seeding containing IDs. No database mutation.
158
+ *
159
+ * @param seeding The seeding (IDs).
160
+ * @param positions An optional list of positions (seeds) for a manual ordering.
161
+ */
162
+ private getSlotsUsingIds;
163
+ /**
164
+ * Gets the current stage number based on existing stages.
165
+ */
166
+ private getStageNumber;
167
+ /**
168
+ * Safely gets `matchesChildCount` in the stage input settings.
169
+ */
170
+ private getMatchesChildCount;
171
+ /**
172
+ * Safely gets an ordering by its index in the stage input settings.
173
+ *
174
+ * @param orderingIndex Index of the ordering.
175
+ * @param stageType A value indicating if the method should be a group method or not.
176
+ * @param defaultMethod The default method to use if not given.
177
+ */
178
+ private getOrdering;
179
+ /**
180
+ * Gets the duels in groups for a round-robin stage.
181
+ */
182
+ private getRoundRobinGroups;
183
+ /**
184
+ * Returns the ordering method for the groups in a round-robin stage.
185
+ */
186
+ getRoundRobinOrdering(): SeedOrdering;
187
+ /**
188
+ * Returns the ordering method for the first round of the upper bracket of an elimination stage.
189
+ */
190
+ getStandardBracketFirstRoundOrdering(): SeedOrdering;
191
+ /**
192
+ * Safely gets the only major ordering for the lower bracket.
193
+ *
194
+ * @param participantCount Number of participants in the stage.
195
+ */
196
+ private getMajorOrdering;
197
+ /**
198
+ * Safely gets a minor ordering for the lower bracket by its index.
199
+ *
200
+ * @param participantCount Number of participants in the stage.
201
+ * @param index Index of the minor round.
202
+ * @param minorRoundCount Number of minor rounds.
203
+ */
204
+ private getMinorOrdering;
205
+ /**
206
+ * Inserts a stage or finds an existing one.
207
+ *
208
+ * @param stage The stage to insert.
209
+ */
210
+ private insertStage;
211
+ /**
212
+ * Inserts a group or finds an existing one.
213
+ *
214
+ * @param group The group to insert.
215
+ */
216
+ private insertGroup;
217
+ /**
218
+ * Inserts a round or finds an existing one.
219
+ *
220
+ * @param round The round to insert.
221
+ */
222
+ private insertRound;
223
+ /**
224
+ * Inserts a match or updates an existing one.
225
+ *
226
+ * @param match The match to insert.
227
+ * @param existing An existing match corresponding to the current one.
228
+ */
229
+ private insertMatch;
230
+ /**
231
+ * Inserts a match game or finds an existing one (and updates it).
232
+ *
233
+ * @param matchGame The match game to insert.
234
+ */
235
+ private insertMatchGame;
236
+ /**
237
+ * Inserts missing participants.
238
+ *
239
+ * @param participants The list of participants to process.
240
+ */
241
+ private registerParticipants;
242
+ /**
243
+ * Creates a new stage.
244
+ */
245
+ private createStage;
246
+ /**
247
+ * Creates a consolation final for the semi final losers of an upper bracket (single or double elimination).
248
+ *
249
+ * @param stageId ID of the stage.
250
+ * @param losers The semi final losers who will play the consolation final.
251
+ * @param overrides Optional overrides.
252
+ */
253
+ private createConsolationFinal;
254
+ /**
255
+ * Creates a grand final (none, simple or double) for winners of both bracket in a double elimination stage.
256
+ *
257
+ * @param stageId ID of the stage.
258
+ * @param winnerWb The winner of the winner bracket.
259
+ * @param winnerLb The winner of the loser bracket.
260
+ */
261
+ private createGrandFinal;
262
+ /**
263
+ * Ensures that the seed ordering list is stored even if it was not given in the first place.
264
+ *
265
+ * @param stageId ID of the stage.
266
+ */
267
+ private ensureSeedOrdering;
268
+ }
269
+ //# sourceMappingURL=creator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"creator.d.ts","sourceRoot":"","sources":["../../../src/base/stage/creator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,EAAE,EAAE,UAAU,EAAiD,YAAY,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAE3H,OAAO,EAAQ,OAAO,EAAU,eAAe,EAA0B,MAAM,aAAa,CAAC;AAC7F,OAAO,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAGxC;;;;;GAKG;AACH,wBAAsB,MAAM,CAAC,IAAI,EAAE,eAAe,EAAE,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,KAAK,CAAC,CAGrF;AAID,qBAAa,YAAY;IAErB,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,KAAK,CAAa;IAC1B,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAiB;IAC9C,OAAO,CAAC,UAAU,CAAU;IAC5B,OAAO,CAAC,kBAAkB,CAAU;IACpC,OAAO,CAAC,cAAc,CAAM;IAE5B;;;;;OAKG;gBACS,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU;IA0B/C;;OAEG;IACU,GAAG,IAAI,OAAO,CAAC,KAAK,CAAC;IAyBlC;;;;;OAKG;IACI,WAAW,CAAC,OAAO,EAAE,EAAE,EAAE,UAAU,EAAE,OAAO,GAAG,IAAI;IAM1D;;;;OAIG;YACW,UAAU;IAUxB;;;;OAIG;YACW,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