@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.
- package/LICENSE +21 -0
- package/README.md +82 -0
- package/dist/base/getter.d.ts +272 -0
- package/dist/base/getter.d.ts.map +1 -0
- package/dist/base/getter.js +545 -0
- package/dist/base/getter.js.map +1 -0
- package/dist/base/stage/creator.d.ts +269 -0
- package/dist/base/stage/creator.d.ts.map +1 -0
- package/dist/base/stage/creator.js +735 -0
- package/dist/base/stage/creator.js.map +1 -0
- package/dist/base/updater.d.ts +121 -0
- package/dist/base/updater.d.ts.map +1 -0
- package/dist/base/updater.js +323 -0
- package/dist/base/updater.js.map +1 -0
- package/dist/create.d.ts +25 -0
- package/dist/create.d.ts.map +1 -0
- package/dist/create.js +55 -0
- package/dist/create.js.map +1 -0
- package/dist/delete.d.ts +33 -0
- package/dist/delete.d.ts.map +1 -0
- package/dist/delete.js +57 -0
- package/dist/delete.js.map +1 -0
- package/dist/find.d.ts +60 -0
- package/dist/find.d.ts.map +1 -0
- package/dist/find.js +196 -0
- package/dist/find.js.map +1 -0
- package/dist/get.d.ts +121 -0
- package/dist/get.d.ts.map +1 -0
- package/dist/get.js +420 -0
- package/dist/get.js.map +1 -0
- package/dist/helpers.d.ts +804 -0
- package/dist/helpers.d.ts.map +1 -0
- package/dist/helpers.js +1897 -0
- package/dist/helpers.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/manager.d.ts +60 -0
- package/dist/manager.d.ts.map +1 -0
- package/dist/manager.js +189 -0
- package/dist/manager.js.map +1 -0
- package/dist/ordering.d.ts +7 -0
- package/dist/ordering.d.ts.map +1 -0
- package/dist/ordering.js +147 -0
- package/dist/ordering.js.map +1 -0
- package/dist/reset.d.ts +27 -0
- package/dist/reset.d.ts.map +1 -0
- package/dist/reset.js +82 -0
- package/dist/reset.js.map +1 -0
- package/dist/types.d.ts +260 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/update.d.ts +111 -0
- package/dist/update.d.ts.map +1 -0
- package/dist/update.js +265 -0
- package/dist/update.js.map +1 -0
- package/package.json +67 -0
package/dist/reset.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Reset = void 0;
|
|
4
|
+
const brackets_model_1 = require("brackets-model");
|
|
5
|
+
const updater_1 = require("./base/updater");
|
|
6
|
+
const helpers = require("./helpers");
|
|
7
|
+
class Reset extends updater_1.BaseUpdater {
|
|
8
|
+
/**
|
|
9
|
+
* Resets the results of a match: the match `status`, and each opponent's `forfeit` and `result` properties.
|
|
10
|
+
*
|
|
11
|
+
* After resetting the results, you can update the match scores and complete the match again.
|
|
12
|
+
*
|
|
13
|
+
* This will update related matches accordingly.
|
|
14
|
+
*
|
|
15
|
+
* @param matchId ID of the match.
|
|
16
|
+
*/
|
|
17
|
+
async matchResults(matchId) {
|
|
18
|
+
const stored = await this.storage.select('match', matchId);
|
|
19
|
+
if (!stored)
|
|
20
|
+
throw Error('Match not found.');
|
|
21
|
+
// The user can handle forfeits with matches which have child games in two possible ways:
|
|
22
|
+
//
|
|
23
|
+
// 1. Set forfeits for the parent match directly.
|
|
24
|
+
// --> The child games will never be updated: not locked, not finished, without forfeit. They will just be ignored and never be played.
|
|
25
|
+
// --> To reset the forfeits, the user has to reset the parent match, with `reset.matchResults()`.
|
|
26
|
+
// --> `reset.matchResults()` will be usable **only** to reset the forfeit of the parent match. Otherwise it will throw the error below.
|
|
27
|
+
//
|
|
28
|
+
// 2. Set forfeits for each child game.
|
|
29
|
+
// --> The parent match won't automatically have a forfeit, but will be updated with a computed score according to the forfeited match games.
|
|
30
|
+
// --> To reset the forfeits, the user has to reset each child game on its own, with `reset.matchGameResults()`.
|
|
31
|
+
// --> `reset.matchResults()` will throw the error below in all cases.
|
|
32
|
+
if (!helpers.isMatchForfeitCompleted(stored) &&
|
|
33
|
+
stored.child_count > 0) {
|
|
34
|
+
throw Error('The parent match is controlled by its child games and its result cannot be reset.');
|
|
35
|
+
}
|
|
36
|
+
const stage = await this.storage.select('stage', stored.stage_id);
|
|
37
|
+
if (!stage)
|
|
38
|
+
throw Error('Stage not found.');
|
|
39
|
+
const group = await this.storage.select('group', stored.group_id);
|
|
40
|
+
if (!group)
|
|
41
|
+
throw Error('Group not found.');
|
|
42
|
+
const { roundNumber, roundCount } = await this.getRoundPositionalInfo(stored.round_id);
|
|
43
|
+
const matchLocation = helpers.getMatchLocation(stage.type, group.number);
|
|
44
|
+
const nextMatches = await this.getNextMatches(stored, matchLocation, stage, roundNumber, roundCount);
|
|
45
|
+
if (nextMatches.some((match) => match &&
|
|
46
|
+
match.status >= brackets_model_1.Status.Running &&
|
|
47
|
+
!helpers.isMatchByeCompleted(match)))
|
|
48
|
+
throw Error('The match is locked.');
|
|
49
|
+
helpers.resetMatchResults(stored);
|
|
50
|
+
await this.applyMatchUpdate(stored);
|
|
51
|
+
if (!helpers.isRoundRobin(stage))
|
|
52
|
+
await this.updateRelatedMatches(stored, true, true);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Resets the results of a match game.
|
|
56
|
+
*
|
|
57
|
+
* @param gameId ID of the match game.
|
|
58
|
+
*/
|
|
59
|
+
async matchGameResults(gameId) {
|
|
60
|
+
const stored = await this.storage.select('match_game', gameId);
|
|
61
|
+
if (!stored)
|
|
62
|
+
throw Error('Match game not found.');
|
|
63
|
+
const stage = await this.storage.select('stage', stored.stage_id);
|
|
64
|
+
if (!stage)
|
|
65
|
+
throw Error('Stage not found.');
|
|
66
|
+
const inRoundRobin = helpers.isRoundRobin(stage);
|
|
67
|
+
helpers.resetMatchResults(stored);
|
|
68
|
+
if (!(await this.storage.update('match_game', stored.id, stored)))
|
|
69
|
+
throw Error('Could not update the match game.');
|
|
70
|
+
await this.updateParentMatch(stored.parent_id, inRoundRobin);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Resets the seeding of a stage.
|
|
74
|
+
*
|
|
75
|
+
* @param stageId ID of the stage.
|
|
76
|
+
*/
|
|
77
|
+
async seeding(stageId) {
|
|
78
|
+
await this.updateSeeding(stageId, { seeding: null }, false);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
exports.Reset = Reset;
|
|
82
|
+
//# sourceMappingURL=reset.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reset.js","sourceRoot":"","sources":["../src/reset.ts"],"names":[],"mappings":";;;AAAA,mDAA4C;AAC5C,4CAA6C;AAC7C,qCAAqC;AAErC,MAAa,KAAM,SAAQ,qBAAW;IAClC;;;;;;;;OAQG;IACI,KAAK,CAAC,YAAY,CAAC,OAAW;QACjC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC3D,IAAI,CAAC,MAAM;YAAE,MAAM,KAAK,CAAC,kBAAkB,CAAC,CAAC;QAE7C,yFAAyF;QACzF,EAAE;QACF,iDAAiD;QACjD,0IAA0I;QAC1I,qGAAqG;QACrG,2IAA2I;QAC3I,EAAE;QACF,uCAAuC;QACvC,gJAAgJ;QAChJ,mHAAmH;QACnH,yEAAyE;QACzE,IACI,CAAC,OAAO,CAAC,uBAAuB,CAAC,MAAM,CAAC;YACxC,MAAM,CAAC,WAAW,GAAG,CAAC,EACxB;YACE,MAAM,KAAK,CACP,mFAAmF,CACtF,CAAC;SACL;QAED,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;QAClE,IAAI,CAAC,KAAK;YAAE,MAAM,KAAK,CAAC,kBAAkB,CAAC,CAAC;QAE5C,MAAM,KAAK,GAAG,MAAM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,CAAC,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;QAClE,IAAI,CAAC,KAAK;YAAE,MAAM,KAAK,CAAC,kBAAkB,CAAC,CAAC;QAE5C,MAAM,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;QAEjD,OAAO,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;QAElC,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;YAC7D,MAAM,KAAK,CAAC,kCAAkC,CAAC,CAAC;QAEpD,MAAM,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;IACjE,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,OAAO,CAAC,OAAW;QAC5B,MAAM,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,KAAK,CAAC,CAAC;IAChE,CAAC;CACJ;AAtGD,sBAsGC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
import { Group, Id, Match, MatchGame, Participant, Round, SeedOrdering, Stage, RankingFormula, RankingItem } from 'brackets-model';
|
|
2
|
+
/**
|
|
3
|
+
* A tournament that can contain multiple stages and participants.
|
|
4
|
+
*/
|
|
5
|
+
export interface Tournament {
|
|
6
|
+
/** Unique identifier of the tournament. */
|
|
7
|
+
id: Id;
|
|
8
|
+
/** Name of the tournament. */
|
|
9
|
+
name: string;
|
|
10
|
+
/** Description of the tournament. */
|
|
11
|
+
description?: string | null;
|
|
12
|
+
/** Start date of the tournament. */
|
|
13
|
+
start_date?: Date | null;
|
|
14
|
+
/** End date of the tournament. */
|
|
15
|
+
end_date?: Date | null;
|
|
16
|
+
/** Additional data for the tournament. */
|
|
17
|
+
extra?: Record<string, unknown>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Input type for creating a tournament.
|
|
21
|
+
*/
|
|
22
|
+
export interface InputTournament {
|
|
23
|
+
/** Name of the tournament. */
|
|
24
|
+
name: string;
|
|
25
|
+
/** Description of the tournament. */
|
|
26
|
+
description?: string | null;
|
|
27
|
+
/** Start date of the tournament. */
|
|
28
|
+
start_date?: Date | string | null;
|
|
29
|
+
/** End date of the tournament. */
|
|
30
|
+
end_date?: Date | string | null;
|
|
31
|
+
/** Additional data for the tournament. */
|
|
32
|
+
extra?: Record<string, unknown>;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Type of an object implementing every ordering method.
|
|
36
|
+
*/
|
|
37
|
+
export type OrderingMap = Record<SeedOrdering, <T>(array: T[], ...args: number[]) => T[]>;
|
|
38
|
+
/**
|
|
39
|
+
* Omits the `id` property of a type.
|
|
40
|
+
*/
|
|
41
|
+
export type OmitId<T> = Omit<T, 'id'>;
|
|
42
|
+
/**
|
|
43
|
+
* Defines a T which can be null.
|
|
44
|
+
*/
|
|
45
|
+
export type Nullable<T> = T | null;
|
|
46
|
+
/**
|
|
47
|
+
* An object which maps an ID to another ID.
|
|
48
|
+
*/
|
|
49
|
+
export type IdMapping = Record<Id, Id>;
|
|
50
|
+
/**
|
|
51
|
+
* Used by the library to handle placements. Is `null` if is a BYE. Has a `null` name if it's yet to be determined.
|
|
52
|
+
*/
|
|
53
|
+
export type ParticipantSlot = {
|
|
54
|
+
id: Id | null;
|
|
55
|
+
position?: number;
|
|
56
|
+
} | null;
|
|
57
|
+
/**
|
|
58
|
+
* The library only handles duels. It's one participant versus another participant.
|
|
59
|
+
*/
|
|
60
|
+
export type Duel = [ParticipantSlot, ParticipantSlot];
|
|
61
|
+
/**
|
|
62
|
+
* The side of an opponent.
|
|
63
|
+
*/
|
|
64
|
+
export type Side = 'opponent1' | 'opponent2';
|
|
65
|
+
/**
|
|
66
|
+
* The cumulated scores of the opponents in a match's child games.
|
|
67
|
+
*/
|
|
68
|
+
export type Scores = {
|
|
69
|
+
opponent1: number;
|
|
70
|
+
opponent2: number;
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* The possible levels of data to which we can update the child games count.
|
|
74
|
+
*/
|
|
75
|
+
export type ChildCountLevel = 'stage' | 'group' | 'round' | 'match';
|
|
76
|
+
/**
|
|
77
|
+
* Positional information about a round.
|
|
78
|
+
*/
|
|
79
|
+
export type RoundPositionalInfo = {
|
|
80
|
+
roundNumber: number;
|
|
81
|
+
roundCount: number;
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* The result of an array which was split by parity.
|
|
85
|
+
*/
|
|
86
|
+
export interface ParitySplit<T> {
|
|
87
|
+
even: T[];
|
|
88
|
+
odd: T[];
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Makes an object type deeply partial.
|
|
92
|
+
*/
|
|
93
|
+
export type DeepPartial<T> = T extends object ? {
|
|
94
|
+
[P in keyof T]?: DeepPartial<T[P]>;
|
|
95
|
+
} : T;
|
|
96
|
+
/**
|
|
97
|
+
* Converts all value types to array types.
|
|
98
|
+
*/
|
|
99
|
+
export type ValueToArray<T> = {
|
|
100
|
+
[K in keyof T]: Array<T[K]>;
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* Data type associated to each database table.
|
|
104
|
+
*/
|
|
105
|
+
export interface DataTypes {
|
|
106
|
+
tournament: Tournament;
|
|
107
|
+
stage: Stage;
|
|
108
|
+
group: Group;
|
|
109
|
+
round: Round;
|
|
110
|
+
match: Match;
|
|
111
|
+
match_game: MatchGame;
|
|
112
|
+
participant: Participant;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* The types of table in the storage.
|
|
116
|
+
*/
|
|
117
|
+
export type Table = keyof DataTypes;
|
|
118
|
+
/**
|
|
119
|
+
* Format of the data in a database.
|
|
120
|
+
* Tournament is optional for backwards compatibility with storage implementations
|
|
121
|
+
* that don't support tournaments.
|
|
122
|
+
*/
|
|
123
|
+
export type Database = ValueToArray<Omit<DataTypes, 'tournament'>> & {
|
|
124
|
+
tournament?: Tournament[];
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* Data types for stage/tournament display (excludes tournament entity).
|
|
128
|
+
*/
|
|
129
|
+
export interface StageDataTypes {
|
|
130
|
+
stage: Stage;
|
|
131
|
+
group: Group;
|
|
132
|
+
round: Round;
|
|
133
|
+
match: Match;
|
|
134
|
+
match_game: MatchGame;
|
|
135
|
+
participant: Participant;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Format of the data needed to display a stage or tournament.
|
|
139
|
+
*/
|
|
140
|
+
export type StageData = ValueToArray<StageDataTypes>;
|
|
141
|
+
/**
|
|
142
|
+
* An item in the final standings of an elimination stage. Each item represents a {@link Participant}.
|
|
143
|
+
*/
|
|
144
|
+
export interface FinalStandingsItem {
|
|
145
|
+
id: Id;
|
|
146
|
+
name: string;
|
|
147
|
+
rank: number;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* An item in the final standings of a round-robin stage. Each item represents a {@link Participant}.
|
|
151
|
+
*/
|
|
152
|
+
export interface RoundRobinFinalStandingsItem extends RankingItem {
|
|
153
|
+
groupId: Id;
|
|
154
|
+
name: string;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Options for the final standings of a round-robin stage.
|
|
158
|
+
*/
|
|
159
|
+
export interface RoundRobinFinalStandingsOptions {
|
|
160
|
+
/**
|
|
161
|
+
* A formula required to rank participants in a round-robin stage.
|
|
162
|
+
*
|
|
163
|
+
* See {@link RankingItem} for the possible properties on `item`.
|
|
164
|
+
*
|
|
165
|
+
* The default formula used by the viewer is:
|
|
166
|
+
*
|
|
167
|
+
* @example (item) => 3 * item.wins + 1 * item.draws + 0 * item.losses
|
|
168
|
+
*/
|
|
169
|
+
rankingFormula: RankingFormula;
|
|
170
|
+
/**
|
|
171
|
+
* The maximum number of participants to qualify per group.
|
|
172
|
+
*/
|
|
173
|
+
maxQualifiedParticipantsPerGroup?: number;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Contains the losers and the winner of the bracket.
|
|
177
|
+
*/
|
|
178
|
+
export interface StandardBracketResults {
|
|
179
|
+
/**
|
|
180
|
+
* The list of losers for each round of the bracket.
|
|
181
|
+
*/
|
|
182
|
+
losers: ParticipantSlot[][];
|
|
183
|
+
/**
|
|
184
|
+
* The winner of the bracket.
|
|
185
|
+
*/
|
|
186
|
+
winner: ParticipantSlot;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* This CRUD interface is used by the manager to abstract storage.
|
|
190
|
+
*/
|
|
191
|
+
export interface CrudInterface {
|
|
192
|
+
/**
|
|
193
|
+
* Inserts a value in the database and returns its id.
|
|
194
|
+
*
|
|
195
|
+
* @param table Where to insert.
|
|
196
|
+
* @param value What to insert.
|
|
197
|
+
*/
|
|
198
|
+
insert<T extends Table>(table: T, value: OmitId<DataTypes[T]>): Promise<number>;
|
|
199
|
+
/**
|
|
200
|
+
* Inserts multiple values in the database.
|
|
201
|
+
*
|
|
202
|
+
* @param table Where to insert.
|
|
203
|
+
* @param values What to insert.
|
|
204
|
+
*/
|
|
205
|
+
insert<T extends Table>(table: T, values: OmitId<DataTypes[T]>[]): Promise<boolean>;
|
|
206
|
+
/**
|
|
207
|
+
* Gets all data from a table in the database.
|
|
208
|
+
*
|
|
209
|
+
* @param table Where to get from.
|
|
210
|
+
*/
|
|
211
|
+
select<T extends Table>(table: T): Promise<Array<DataTypes[T]> | null>;
|
|
212
|
+
/**
|
|
213
|
+
* Gets specific data from a table in the database.
|
|
214
|
+
*
|
|
215
|
+
* @param table Where to get from.
|
|
216
|
+
* @param id What to get.
|
|
217
|
+
*/
|
|
218
|
+
select<T extends Table>(table: T, id: Id): Promise<DataTypes[T] | null>;
|
|
219
|
+
/**
|
|
220
|
+
* Gets data from a table in the database with a filter.
|
|
221
|
+
*
|
|
222
|
+
* @param table Where to get from.
|
|
223
|
+
* @param filter An object to filter data.
|
|
224
|
+
*/
|
|
225
|
+
select<T extends Table>(table: T, filter: Partial<DataTypes[T]>): Promise<Array<DataTypes[T]> | null>;
|
|
226
|
+
/**
|
|
227
|
+
* Updates data in a table.
|
|
228
|
+
*
|
|
229
|
+
* @param table Where to update.
|
|
230
|
+
* @param id What to update.
|
|
231
|
+
* @param value How to update.
|
|
232
|
+
*/
|
|
233
|
+
update<T extends Table>(table: T, id: Id, value: DataTypes[T]): Promise<boolean>;
|
|
234
|
+
/**
|
|
235
|
+
* Updates data in a table.
|
|
236
|
+
*
|
|
237
|
+
* @param table Where to update.
|
|
238
|
+
* @param filter An object to filter data.
|
|
239
|
+
* @param value How to update.
|
|
240
|
+
*/
|
|
241
|
+
update<T extends Table>(table: T, filter: Partial<DataTypes[T]>, value: Partial<DataTypes[T]>): Promise<boolean>;
|
|
242
|
+
/**
|
|
243
|
+
* Empties a table completely.
|
|
244
|
+
*
|
|
245
|
+
* @param table Where to delete everything.
|
|
246
|
+
*/
|
|
247
|
+
delete<T extends Table>(table: T): Promise<boolean>;
|
|
248
|
+
/**
|
|
249
|
+
* Delete data in a table, based on a filter.
|
|
250
|
+
*
|
|
251
|
+
* @param table Where to delete in.
|
|
252
|
+
* @param filter An object to filter data.
|
|
253
|
+
*/
|
|
254
|
+
delete<T extends Table>(table: T, filter: Partial<DataTypes[T]>): Promise<boolean>;
|
|
255
|
+
}
|
|
256
|
+
export interface Storage extends CrudInterface {
|
|
257
|
+
selectFirst<T extends Table>(table: T, filter: Partial<DataTypes[T]>, assertUnique?: boolean): Promise<DataTypes[T] | null>;
|
|
258
|
+
selectLast<T extends Table>(table: T, filter: Partial<DataTypes[T]>, assertUnique?: boolean): Promise<DataTypes[T] | null>;
|
|
259
|
+
}
|
|
260
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,EACL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AAE,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAC7B,KAAK,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,GAC7B,OAAO,CAAC,OAAO,CAAC,CAAC;IAEpB;;;;OAIG;IACH,MAAM,CAAC,CAAC,SAAS,KAAK,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAEpD;;;;;OAKG;IACH,MAAM,CAAC,CAAC,SAAS,KAAK,EAClB,KAAK,EAAE,CAAC,EACR,MAAM,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,GAC9B,OAAO,CAAC,OAAO,CAAC,CAAC;CACvB;AAED,MAAM,WAAW,OAAQ,SAAQ,aAAa;IAC1C,WAAW,CAAC,CAAC,SAAS,KAAK,EACvB,KAAK,EAAE,CAAC,EACR,MAAM,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAC7B,YAAY,CAAC,EAAE,OAAO,GACvB,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;IAChC,UAAU,CAAC,CAAC,SAAS,KAAK,EACtB,KAAK,EAAE,CAAC,EACR,MAAM,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAC7B,YAAY,CAAC,EAAE,OAAO,GACvB,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;CACnC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/dist/update.d.ts
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { Id, IdSeeding, Match, MatchGame, Seeding, SeedOrdering } from 'brackets-model';
|
|
2
|
+
import { BaseUpdater } from './base/updater';
|
|
3
|
+
import { ChildCountLevel, DeepPartial } from './types';
|
|
4
|
+
export declare class Update extends BaseUpdater {
|
|
5
|
+
/**
|
|
6
|
+
* Updates partial information of a match. Its id must be given.
|
|
7
|
+
*
|
|
8
|
+
* This will update related matches accordingly.
|
|
9
|
+
*
|
|
10
|
+
* @param match Values to change in a match.
|
|
11
|
+
*/
|
|
12
|
+
match<M extends Match = Match>(match: DeepPartial<M>): Promise<void>;
|
|
13
|
+
/**
|
|
14
|
+
* Updates partial information of a match game. Its id must be given.
|
|
15
|
+
*
|
|
16
|
+
* This will update the parent match accordingly.
|
|
17
|
+
*
|
|
18
|
+
* @param game Values to change in a match game.
|
|
19
|
+
*/
|
|
20
|
+
matchGame<G extends MatchGame = MatchGame>(game: DeepPartial<G>): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Updates the seed ordering of every ordered round in a stage.
|
|
23
|
+
*
|
|
24
|
+
* @param stageId ID of the stage.
|
|
25
|
+
* @param seedOrdering A list of ordering methods.
|
|
26
|
+
*/
|
|
27
|
+
ordering(stageId: Id, seedOrdering: SeedOrdering[]): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Updates the seed ordering of a round.
|
|
30
|
+
*
|
|
31
|
+
* @param roundId ID of the round.
|
|
32
|
+
* @param method Seed ordering method.
|
|
33
|
+
*/
|
|
34
|
+
roundOrdering(roundId: Id, method: SeedOrdering): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* Updates child count of all matches of a given level.
|
|
37
|
+
*
|
|
38
|
+
* @param level The level at which to act.
|
|
39
|
+
* @param id ID of the chosen level.
|
|
40
|
+
* @param childCount The target child count.
|
|
41
|
+
*/
|
|
42
|
+
matchChildCount(level: ChildCountLevel, id: Id, childCount: number): Promise<void>;
|
|
43
|
+
/**
|
|
44
|
+
* Updates the seeding of a stage.
|
|
45
|
+
*
|
|
46
|
+
* @param stageId ID of the stage.
|
|
47
|
+
* @param seeding The new seeding.
|
|
48
|
+
* @param keepSameSize Whether to keep the same size as before for the stage. **Default:** false.
|
|
49
|
+
*/
|
|
50
|
+
seeding(stageId: Id, seeding: Seeding, keepSameSize?: boolean): Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* Updates the seeding of a stage (with a list of IDs).
|
|
53
|
+
*
|
|
54
|
+
* @param stageId ID of the stage.
|
|
55
|
+
* @param seedingIds The new seeding, containing only IDs.
|
|
56
|
+
* @param keepSameSize Whether to keep the same size as before for the stage. **Default:** false.
|
|
57
|
+
*/
|
|
58
|
+
seedingIds(stageId: Id, seedingIds: IdSeeding, keepSameSize?: boolean): Promise<void>;
|
|
59
|
+
/**
|
|
60
|
+
* Confirms the seeding of a stage.
|
|
61
|
+
*
|
|
62
|
+
* This will convert TBDs to BYEs and propagate them.
|
|
63
|
+
*
|
|
64
|
+
* @param stageId ID of the stage.
|
|
65
|
+
*/
|
|
66
|
+
confirmSeeding(stageId: Id): Promise<void>;
|
|
67
|
+
/**
|
|
68
|
+
* Update the seed ordering of a round.
|
|
69
|
+
*
|
|
70
|
+
* @param round The round of which to update the ordering.
|
|
71
|
+
* @param method The new ordering method.
|
|
72
|
+
*/
|
|
73
|
+
private updateRoundOrdering;
|
|
74
|
+
/**
|
|
75
|
+
* Updates child count of all matches of a stage.
|
|
76
|
+
*
|
|
77
|
+
* @param stageId ID of the stage.
|
|
78
|
+
* @param childCount The target child count.
|
|
79
|
+
*/
|
|
80
|
+
private updateStageMatchChildCount;
|
|
81
|
+
/**
|
|
82
|
+
* Updates child count of all matches of a group.
|
|
83
|
+
*
|
|
84
|
+
* @param groupId ID of the group.
|
|
85
|
+
* @param childCount The target child count.
|
|
86
|
+
*/
|
|
87
|
+
private updateGroupMatchChildCount;
|
|
88
|
+
/**
|
|
89
|
+
* Updates child count of all matches of a round.
|
|
90
|
+
*
|
|
91
|
+
* @param roundId ID of the round.
|
|
92
|
+
* @param childCount The target child count.
|
|
93
|
+
*/
|
|
94
|
+
private updateRoundMatchChildCount;
|
|
95
|
+
/**
|
|
96
|
+
* Updates the ordering of participants in a round's matches.
|
|
97
|
+
*
|
|
98
|
+
* @param roundNumber The number of the round.
|
|
99
|
+
* @param matches The matches of the round.
|
|
100
|
+
* @param positions The new positions.
|
|
101
|
+
*/
|
|
102
|
+
private applyRoundOrdering;
|
|
103
|
+
/**
|
|
104
|
+
* Adds or deletes match games of a match based on a target child count.
|
|
105
|
+
*
|
|
106
|
+
* @param match The match of which child games need to be adjusted.
|
|
107
|
+
* @param targetChildCount The target child count.
|
|
108
|
+
*/
|
|
109
|
+
private adjustMatchChildGames;
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=update.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../src/update.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,EAAE,EACF,SAAS,EACT,KAAK,EACL,SAAS,EAET,OAAO,EACP,YAAY,EAEf,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAGvD,qBAAa,MAAO,SAAQ,WAAW;IACnC;;;;;;OAMG;IACU,KAAK,CAAC,CAAC,SAAS,KAAK,GAAG,KAAK,EACtC,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,GACtB,OAAO,CAAC,IAAI,CAAC;IAShB;;;;;;OAMG;IACU,SAAS,CAAC,CAAC,SAAS,SAAS,GAAG,SAAS,EAClD,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,GACrB,OAAO,CAAC,IAAI,CAAC;IAMhB;;;;;OAKG;IACU,QAAQ,CACjB,OAAO,EAAE,EAAE,EACX,YAAY,EAAE,YAAY,EAAE,GAC7B,OAAO,CAAC,IAAI,CAAC;IAchB;;;;;OAKG;IACU,aAAa,CACtB,OAAO,EAAE,EAAE,EACX,MAAM,EAAE,YAAY,GACrB,OAAO,CAAC,IAAI,CAAC;IAYhB;;;;;;OAMG;IACU,eAAe,CACxB,KAAK,EAAE,eAAe,EACtB,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