### getOrdering Source: https://drarig29.github.io/brackets-docs/reference/manager/classes/StageCreator.html Gets the ordering for a stage. ```APIDOC ## getOrdering ### Description Gets the ordering for a stage. ### Parameters - **stageId** (Id) - Required - ID of the stage. ### Returns Ordering ``` -------------------------------- ### isMatchStarted Source: https://drarig29.github.io/brackets-docs/reference/manager/functions/helpers.isMatchStarted.html Checks if a match is started. This is score-based. A completed or archived match is seen as "started" as well. The status progression is Locked > Waiting > Ready > [Running > Completed > Archived]. ```APIDOC ## Function isMatchStarted ### Description Checks if a match is started. This is score-based. A completed or archived match is seen as "started" as well. ### Signature isMatchStarted(match): boolean ### Parameters #### match: object Partial match results. - `opponent1` (object | null) - Optional - First opponent of the match. - `opponent2` (object | null) - Optional - Second opponent of the match. - `status` (Status) - Optional - Status of the match. ### Returns - boolean - True if the match is considered started, false otherwise. ``` -------------------------------- ### getSlots Source: https://drarig29.github.io/brackets-docs/reference/manager/classes/StageCreator.html Gets all slots for a stage. ```APIDOC ## getSlots ### Description Gets all slots for a stage. ### Parameters - **stageId** (Id) - Required - ID of the stage. ### Returns ParticipantSlot[] ``` -------------------------------- ### Update Match with Scores and Result Source: https://drarig29.github.io/brackets-docs/user-guide/updating-matches This example updates a match by providing scores and a specific result for one opponent. The library infers the other opponent's result and the match status. ```javascript // The second opponent's result is inferred, as well as the status. await manager.update.match({ id: 42, opponent1: { score: 3, result: 'win' }, opponent2: { score: 1 }, }); ``` -------------------------------- ### select (all from table) Source: https://drarig29.github.io/brackets-docs/reference/manager/interfaces/CrudInterface.html Gets all data from a table in the database. ```APIDOC ## select(table: T): Promise ### Description Gets all data from a table in the database. ### Parameters #### Path Parameters - **table** (T) - Required - Where to get from. ### Returns Promise ``` -------------------------------- ### RoundRobin Ranking Formula Example Source: https://drarig29.github.io/brackets-docs/reference/manager/interfaces/RoundRobinFinalStandingsOptions.html Defines a custom ranking formula for participants in a round-robin stage. This example calculates scores based on wins, draws, and losses. ```typescript (item) => 3 * item.wins + 1 * item.draws + 0 * item.losses ``` -------------------------------- ### getMajorOrdering Source: https://drarig29.github.io/brackets-docs/reference/manager/classes/StageCreator.html Gets the major ordering for a stage. ```APIDOC ## getMajorOrdering ### Description Gets the major ordering for a stage. ### Parameters - **stageId** (Id) - Required - ID of the stage. ### Returns Ordering ``` -------------------------------- ### getMinorOrdering Source: https://drarig29.github.io/brackets-docs/reference/manager/classes/StageCreator.html Gets the minor ordering for a stage. ```APIDOC ## getMinorOrdering ### Description Gets the minor ordering for a stage. ### Parameters - **stageId** (Id) - Required - ID of the stage. ### Returns Ordering ``` -------------------------------- ### getRoundRobinOrdering Source: https://drarig29.github.io/brackets-docs/reference/manager/classes/StageCreator.html Gets the round robin ordering for a stage. ```APIDOC ## getRoundRobinOrdering ### Description Gets the round robin ordering for a stage. ### Parameters - **stageId** (Id) - Required - ID of the stage. ### Returns Ordering ``` -------------------------------- ### loserBracket Source: https://drarig29.github.io/brackets-docs/reference/manager/classes/Find.html Gets the loser bracket. ```APIDOC ## loserBracket ### Description Gets the loser bracket. ### Parameters #### Path Parameters - **stageId** (Id) - Required - ID of the stage. ### Returns Promise ``` -------------------------------- ### getPreviousMatches Source: https://drarig29.github.io/brackets-docs/reference/manager/classes/Find.html Gets the matches that lead up to a specified match. ```APIDOC ## getPreviousMatches * getPreviousMatches(match, matchLocation, stage, roundNumber): Promise * Gets the matches leading to the given match. #### Parameters * ##### match: Match The current match. * ##### matchLocation: GroupType Location of the current match. * ##### stage: Stage The parent stage. * ##### roundNumber: number Number of the round. #### Returns Promise ``` -------------------------------- ### getNextSideConsolationFinalDoubleElimination Source: https://drarig29.github.io/brackets-docs/reference/manager/functions/helpers.getNextSideConsolationFinalDoubleElimination.html Gets the side the loser of the current match in the loser bracket will go in the next match. ```APIDOC ## Function getNextSideConsolationFinalDoubleElimination ### Description Gets the side the loser of the current match in loser bracket will go in the next match. ### Parameters #### Path Parameters * **roundNumber** (number) - Required - Number of the current round. ### Returns * **Side** - The side the loser will go to in the next match. ``` -------------------------------- ### makePairs(array): [T, T][] Source: https://drarig29.github.io/brackets-docs/reference/manager/functions/helpers.makePairs.html This function takes an array and returns a new array where each element is a pair of consecutive elements from the original array. For example, [1, 2, 3, 4] becomes [[1, 2], [3, 4]]. ```APIDOC ## Function makePairs ### Description Makes pairs with each element and its next one. ### Parameters #### array: T[] A list of elements. ### Returns [T, T][] ### Example ``` [1, 2, 3, 4] --> [[1, 2], [3, 4]] ``` ``` -------------------------------- ### run Source: https://drarig29.github.io/brackets-docs/reference/manager/classes/StageCreator.html Initiates the stage creation process. ```APIDOC ## run ### Description Run the creation process. ### Method POST (assumed, as it initiates a process) ### Endpoint /stages/run #### Returns Promise ``` -------------------------------- ### Get Next Round Matches Source: https://drarig29.github.io/brackets-docs/user-guide/helpers Fetch all matches for the next round of a tournament stage. Useful for scheduling upcoming games. Consider filtering by group ID for finals and using helper functions for match status. ```javascript // Given a current round, load the next round and its matches const nextRound = await storage.selectFirst('round', { stage_id: currentRound.stage_id, number: currentRound.number + 1, }); if (nextRound) { const nextMatches = await storage.select('match', { round_id: nextRound.id }); // nextMatches contains every match to prepare for the next round } ``` -------------------------------- ### Update Match by Querying Participant IDs Source: https://drarig29.github.io/brackets-docs/user-guide/updating-matches When updating a match, you can query by participant IDs to ensure the correct opponents are updated, especially if their positions within the match might change. The example shows updating scores while preserving original participant IDs. ```javascript await manager.update.match({ id: 42, opponent1: { id: 1, score: 3 }, opponent2: { id: 0, score: 1 }, }); ``` ```json { "id": 42, "opponent1": { "id": 0, "score": 1 }, // The position in the match is **unchanged** "opponent2": { "id": 1, "score": 3 } } ``` -------------------------------- ### run Source: https://drarig29.github.io/brackets-docs/reference/manager/classes/StageCreator.html Runs the stage creation process. ```APIDOC ## run ### Description Runs the stage creation process. ### Returns Promise ``` -------------------------------- ### constructor Source: https://drarig29.github.io/brackets-docs/reference/manager/classes/BracketsManager.html Creates an instance of BracketsManager, which will handle all the stuff from the library. ```APIDOC ## constructor * new BracketsManager(storageInterface, verbose?): BracketsManager * Creates an instance of BracketsManager, which will handle all the stuff from the library. #### Parameters * ##### storageInterface: CrudInterface An implementation of CrudInterface. * ##### `Optional` verbose: boolean Whether to log CRUD operations. `Optional` #### Returns BracketsManager ``` -------------------------------- ### getStageNumber Source: https://drarig29.github.io/brackets-docs/reference/manager/classes/StageCreator.html Gets the number of a stage. ```APIDOC ## getStageNumber ### Description Gets the number of a stage. ### Parameters - **stageId** (Id) - Required - ID of the stage. ### Returns number ``` -------------------------------- ### constructor Source: https://drarig29.github.io/brackets-docs/reference/viewer/classes/BracketsViewer.html Initializes a new instance of the BracketsViewer class. ```APIDOC ## constructor * new BracketsViewer(): BracketsViewer * #### Returns BracketsViewer ``` -------------------------------- ### getSlotsUsingNames Source: https://drarig29.github.io/brackets-docs/reference/manager/classes/StageCreator.html Gets slots by their names. ```APIDOC ## getSlotsUsingNames ### Description Gets slots by their names. ### Parameters - **stageId** (Id) - Required - ID of the stage. - **slotNames** (string[]) - Required - Array of slot names. ### Returns ParticipantSlot[] ``` -------------------------------- ### constructor Source: https://drarig29.github.io/brackets-docs/reference/manager/classes/Find.html Creates an instance of a Storage getter. ```APIDOC ## constructor * new Find(storage): Find * Creates an instance of a Storage getter. #### Parameters * ##### storage: Storage The implementation of Storage. #### Returns Find ``` -------------------------------- ### getSlotsUsingIds Source: https://drarig29.github.io/brackets-docs/reference/manager/classes/StageCreator.html Gets slots by their IDs. ```APIDOC ## getSlotsUsingIds ### Description Gets slots by their IDs. ### Parameters - **stageId** (Id) - Required - ID of the stage. - **slotIds** (Id[]) - Required - Array of slot IDs. ### Returns ParticipantSlot[] ``` -------------------------------- ### Initialize Brackets Manager Source: https://drarig29.github.io/brackets-docs/getting-started Create an instance of the BracketsManager, passing in the chosen storage implementation. This manager will handle tournament data operations. ```javascript const { BracketsManager } = require('brackets-manager'); const manager = new BracketsManager(storage); ``` -------------------------------- ### Create Stage with Custom Participants and Extra Fields Source: https://drarig29.github.io/brackets-docs/user-guide/extra-fields Use `Seeding` with `CustomParticipant` objects when creating a stage to attach arbitrary metadata. Any additional keys on these objects are forwarded to storage. SQL/Prisma backends with fixed schemas may ignore unsupported fields. ```javascript await manager.create.stage({ tournamentId: 1, name: 'Groups', type: 'round_robin', seeding: [ { name: 'Alpha', region: 'EU', seed: 1, logoUrl: 'https://…' }, { name: 'Bravo', region: 'NA', seed: 2 }, { name: 'Charlie', sponsor: 'Acme' }, 'Delta', // also fine ], settings: { groupCount: 2, seedOrdering: ['groups.effort_balanced'] }, }); ``` -------------------------------- ### Initialize JSON Database Storage Source: https://drarig29.github.io/brackets-docs/getting-started Instantiate the JsonDatabase class from the brackets-json-db package to manage tournament data stored in a JSON file. ```javascript const { JsonDatabase } = require('brackets-json-db'); const storage = new JsonDatabase(); ``` -------------------------------- ### createStage Source: https://drarig29.github.io/brackets-docs/reference/manager/classes/StageCreator.html Creates a new, empty tournament stage. ```APIDOC ## createStage ### Description Creates a new stage. ### Method createStage() ### Returns Promise ``` -------------------------------- ### getCurrentDuels Source: https://drarig29.github.io/brackets-docs/reference/manager/classes/StageCreator.html Gets the current duels for a stage. ```APIDOC ## getCurrentDuels ### Description Gets the current duels for a stage. ### Parameters - **stageId** (Id) - Required - ID of the stage. ### Returns Duel[] ``` -------------------------------- ### constructor Source: https://drarig29.github.io/brackets-docs/reference/manager/classes/StageCreator.html Creates an instance of StageCreator, which will handle the creation of the stage. ```APIDOC ## constructor ### Description Creates an instance of StageCreator, which will handle the creation of the stage. ### Parameters - **storage** (Storage) - Required - The implementation of Storage. - **stage** (InputStage) - Required - The stage to create. ### Returns StageCreator ``` -------------------------------- ### makeRoundRobinDistribution Source: https://drarig29.github.io/brackets-docs/reference/manager/functions/helpers.makeRoundRobinDistribution.html Distributes participants in rounds for a round-robin group. Each participant plays each other once, and each participant plays once in each round. ```APIDOC ## Function makeRoundRobinDistribution ### Description Distributes participants in rounds for a round-robin group. Conditions: * Each participant plays each other once. * Each participant plays once in each round. ### Type Parameters * #### T ### Parameters * ##### participants: T[] The participants to distribute. ### Returns * [T, T][][] A 2D array representing the round-robin distribution. ``` -------------------------------- ### getRoundRobinGroups Source: https://drarig29.github.io/brackets-docs/reference/manager/classes/StageCreator.html Gets the round robin groups for a stage. ```APIDOC ## getRoundRobinGroups ### Description Gets the round robin groups for a stage. ### Parameters - **stageId** (Id) - Required - ID of the stage. ### Returns RoundRobinGroup[] ``` -------------------------------- ### createStage Source: https://drarig29.github.io/brackets-docs/reference/manager/classes/StageCreator.html Creates a stage. ```APIDOC ## createStage ### Description Creates a stage. ### Parameters - **stageId** (Id) - Required - ID of the stage. - **slots** (ParticipantSlot[]) - Required - List of slots. ### Returns Promise ``` -------------------------------- ### getMatchesChildCount Source: https://drarig29.github.io/brackets-docs/reference/manager/classes/StageCreator.html Gets the child count for matches in a stage. ```APIDOC ## getMatchesChildCount ### Description Gets the child count for matches in a stage. ### Parameters - **stageId** (Id) - Required - ID of the stage. ### Returns number ``` -------------------------------- ### import Source: https://drarig29.github.io/brackets-docs/reference/manager/classes/BracketsManager.html Imports data in the database. ```APIDOC ## import * import(data, normalizeIds?): Promise * Imports data in the database. #### Parameters * ##### data: ValueToArray Data to import. * ##### normalizeIds: boolean = false Enable ID normalization: all IDs (and references to them) are remapped to consecutive IDs starting from 0. #### Returns Promise ``` -------------------------------- ### getOriginPosition Source: https://drarig29.github.io/brackets-docs/reference/manager/functions/helpers.getOriginPosition.html Gets the origin position of a side of a match. ```APIDOC ## Function getOriginPosition * getOriginPosition(match, side): number * Gets the origin position of a side of a match. #### Parameters * ##### match: Match The match. * ##### side: Side The side. #### Returns number ``` -------------------------------- ### makeFinalStandings Source: https://drarig29.github.io/brackets-docs/reference/manager/functions/helpers.makeFinalStandings.html Creates the final standings by processing a list of participants grouped by their ranking. ```APIDOC ## Function makeFinalStandings * makeFinalStandings(grouped): FinalStandingsItem[] * Makes final standings based on participants grouped by ranking. #### Parameters * ##### grouped: Participant[][] A list of participants grouped by ranking. #### Returns FinalStandingsItem[] ``` -------------------------------- ### Render Tournament Bracket with Viewer Source: https://drarig29.github.io/brackets-docs/getting-started Use the window.bracketsViewer.render() function to display the tournament bracket. Pass in the structured data for stages, matches, match games, and participants. ```javascript window.bracketsViewer.render({ stages: data.stage, matches: data.match, matchGames: data.match_game, participants: data.participant, }) ``` -------------------------------- ### select (filtered) Source: https://drarig29.github.io/brackets-docs/reference/manager/interfaces/CrudInterface.html Gets data from a table in the database with a filter. ```APIDOC ## select(table: T, filter: Partial): Promise ### Description Gets data from a table in the database with a filter. ### Parameters #### Path Parameters - **table** (T) - Required - Where to get from. - **filter** (Partial) - Required - An object to filter data. ### Returns Promise ``` -------------------------------- ### render Source: https://drarig29.github.io/brackets-docs/reference/viewer/classes/BracketsViewer.html Renders bracket data. If multiple stages are provided, they will all be displayed without visual distinction based on their tournament. ```APIDOC ## Methods ### render * render(data, config?): Promise * Renders data generated with `brackets-manager.js`. If multiple stages are given, they will all be displayed. Stages won't be discriminated visually based on the tournament they belong to. #### Parameters * ##### data: ViewerData The data to display. * ##### `Optional` config: Partial An optional configuration for the viewer. `Optional` #### Returns Promise ``` -------------------------------- ### Create Stage with TBD Slots using Size Only Source: https://drarig29.github.io/brackets-docs/user-guide/seeding When participant data is not yet available, provide only the `size` to create a stage with TBD slots that can be filled later. ```javascript await manager.create.stage({ tournamentId: 1, name: 'Open Bracket', type: 'single_elimination', settings: { size: 16, seedOrdering: ['inner_outer'], }, }); ``` -------------------------------- ### getStandardBracketFirstRoundOrdering Source: https://drarig29.github.io/brackets-docs/reference/manager/classes/StageCreator.html Gets the ordering for the first round of a standard bracket. ```APIDOC ## getStandardBracketFirstRoundOrdering ### Description Gets the ordering for the first round of a standard bracket. ### Parameters - **stageId** (Id) - Required - ID of the stage. ### Returns Ordering ``` -------------------------------- ### getNextMatches Source: https://drarig29.github.io/brackets-docs/reference/manager/classes/Find.html Gets the subsequent matches for the opponents of a given match. ```APIDOC ## getNextMatches * getNextMatches(match, matchLocation, stage, roundNumber, roundCount): Promise<(null | Match)[]> * Gets the match(es) where the opponents of the current match will go just after. #### Parameters * ##### match: Match The current match. * ##### matchLocation: GroupType Location of the current match. * ##### stage: Stage The parent stage. * ##### roundNumber: number The number of the current round. * ##### roundCount: number Count of rounds. #### Returns Promise<(null | Match)> ``` -------------------------------- ### setExisting Source: https://drarig29.github.io/brackets-docs/reference/manager/classes/StageCreator.html Sets an existing stage. ```APIDOC ## setExisting ### Description Sets an existing stage. ### Parameters - **stageId** (Id) - Required - ID of the stage. ### Returns Promise ``` -------------------------------- ### select (specific by id) Source: https://drarig29.github.io/brackets-docs/reference/manager/interfaces/CrudInterface.html Gets specific data from a table in the database. ```APIDOC ## select(table: T, id: Id): Promise ### Description Gets specific data from a table in the database. ### Parameters #### Path Parameters - **table** (T) - Required - Where to get from. - **id** (Id) - Required - What to get. ### Returns Promise ``` -------------------------------- ### Update Constructor Source: https://drarig29.github.io/brackets-docs/reference/manager/classes/Update.html Creates an instance of a Storage getter. ```APIDOC ## constructor * new Update(storage): Update * Creates an instance of a Storage getter. #### Parameters * ##### storage: Storage The implementation of Storage. #### Returns Update ``` -------------------------------- ### getStageNumber Source: https://drarig29.github.io/brackets-docs/reference/manager/classes/StageCreator.html Gets the current stage number based on existing stages. ```APIDOC ## getStageNumber ### Description Gets the current stage number based on existing stages. ### Method GET (assumed, as it's a retrieval operation) ### Endpoint /stages/number #### Returns Promise ``` -------------------------------- ### Methods.stage Source: https://drarig29.github.io/brackets-docs/reference/manager/interfaces/CallableCreate.html Creates a stage for an existing tournament. The tournament itself will not be created. ```APIDOC ## stage(data: InputStage): Promise ### Description Creates a stage for an existing tournament. The tournament won't be created. ### Parameters #### data: InputStage The stage to create. ### Returns Promise ``` -------------------------------- ### Match select() Source: https://drarig29.github.io/brackets-docs/user-guide/storage Selects match records from the database. ```APIDOC ## select('match'): Promise ### Description Selects all match records from the 'match' table. ### Parameters #### Path Parameters - **'match'** (string) - Required - Specifies the 'match' table. ## select('match', id: Id): Promise ### Description Selects a single match record by its ID from the 'match' table. ### Parameters #### Path Parameters - **'match'** (string) - Required - Specifies the 'match' table. - **id** (Id) - Required - The ID of the match to retrieve. ## select('match', filter: { round_id: Id }): Promise ### Description Selects match records associated with a specific round ID from the 'match' table. ### Parameters #### Path Parameters - **'match'** (string) - Required - Specifies the 'match' table. #### Query Parameters - **filter** (object) - Required - Filter object containing `round_id`. - **round_id** (Id) - Required - The ID of the round. ## select('match', filter: { stage_id: Id }): Promise ### Description Selects match records associated with a specific stage ID from the 'match' table. ### Parameters #### Path Parameters - **'match'** (string) - Required - Specifies the 'match' table. #### Query Parameters - **filter** (object) - Required - Filter object containing `stage_id`. - **stage_id** (Id) - Required - The ID of the stage. ## select('match', filter: { group_id: Id }): Promise ### Description Selects match records associated with a specific group ID from the 'match' table. ### Parameters #### Path Parameters - **'match'** (string) - Required - Specifies the 'match' table. #### Query Parameters - **filter** (object) - Required - Filter object containing `group_id`. - **group_id** (Id) - Required - The ID of the group. ``` -------------------------------- ### getNextMatches Source: https://drarig29.github.io/brackets-docs/reference/manager/classes/Get.html Gets the subsequent matches where the opponents of the current match will proceed. ```APIDOC ## getNextMatches ### Description Gets the match(es) where the opponents of the current match will go just after. ### Method getNextMatches(match: Match, matchLocation: GroupType, stage: Stage, roundNumber: number, roundCount: number) ### Parameters #### Path Parameters - **match** (Match) - Required - The current match. - **matchLocation** (GroupType) - Required - Location of the current match. - **stage** (Stage) - Required - The parent stage. - **roundNumber** (number) - Required - The number of the current round. - **roundCount** (number) - Required - Count of rounds. ### Returns Promise<(null | Match[])> ``` -------------------------------- ### Match selectFirst() Source: https://drarig29.github.io/brackets-docs/user-guide/storage Selects the first match matching the specified criteria. ```APIDOC ## selectFirst('match', filter: { round_id: Id, number: number }): Promise ### Description Selects the first match that matches the provided round ID and match number. ### Parameters #### Path Parameters - **'match'** (string) - Required - Specifies the 'match' table. #### Query Parameters - **filter** (object) - Required - Filter object containing `round_id` and `number`. - **round_id** (Id) - Required - The ID of the round. - **number** (number) - Required - The match number. ## selectFirst('match', filter: { group_id: Id, number: number }): Promise ### Description Selects the first match that matches the provided group ID and match number. ### Parameters #### Path Parameters - **'match'** (string) - Required - Specifies the 'match' table. #### Query Parameters - **filter** (object) - Required - Filter object containing `group_id` and `number`. - **group_id** (Id) - Required - The ID of the group. - **number** (number) - Required - The match number. ``` -------------------------------- ### getUpdatedMatchResults Source: https://drarig29.github.io/brackets-docs/reference/manager/functions/helpers.getUpdatedMatchResults.html Gets the values which need to be updated in a match when it's updated on insertion. ```APIDOC ## Function getUpdatedMatchResults ### Description Gets the values which need to be updated in a match when it's updated on insertion. ### Type Parameters #### T extends MatchResults ### Parameters #### match: T The up to date match. #### existing: T The base match. #### enableByes: boolean Whether to use BYEs or TBDs for `null` values in an input seeding. ### Returns T ``` -------------------------------- ### applyMatchUpdate Source: https://drarig29.github.io/brackets-docs/reference/manager/classes/Reset.html Updates the opponents and status of a match and its child games. ```APIDOC ## applyMatchUpdate * applyMatchUpdate(match): Promise * Updates the opponents and status of a match and its child games. #### Parameters * ##### match: Match A match. #### Returns Promise ``` -------------------------------- ### getNextSide Source: https://drarig29.github.io/brackets-docs/reference/manager/functions/helpers.getNextSide.html Gets the side the winner of the current match will go to in the next match. ```APIDOC ## Function getNextSide ### Description Gets the side the winner of the current match will go to in the next match. ### Signature getNextSide(matchNumber: number, roundNumber: number, roundCount: number, matchLocation: GroupType): Side ### Parameters #### matchNumber - **Type**: number - **Description**: Number of the current match. #### roundNumber - **Type**: number - **Description**: Number of the current round. #### roundCount - **Type**: number - **Description**: Count of rounds. #### matchLocation - **Type**: GroupType - **Description**: Location of the current match. ### Returns - **Type**: Side ``` -------------------------------- ### getSide(matchNumber) Source: https://drarig29.github.io/brackets-docs/reference/manager/functions/helpers.getSide.html Gets the side where the winner of the given match will go in the next match. ```APIDOC ## Function getSide ### Description Gets the side where the winner of the given match will go in the next match. ### Parameters #### matchNumber (number) - Required Number of the match. ### Returns Side ``` -------------------------------- ### createStandardBracket Source: https://drarig29.github.io/brackets-docs/reference/manager/classes/StageCreator.html Creates a standard bracket. ```APIDOC ## createStandardBracket ### Description Creates a standard bracket. ### Parameters - **stageId** (Id) - Required - ID of the stage. - **slots** (ParticipantSlot[]) - Required - List of slots. ### Returns Promise ``` -------------------------------- ### createMatch Source: https://drarig29.github.io/brackets-docs/reference/manager/classes/StageCreator.html Creates a match, possibly with match games. ```APIDOC ## createMatch ### Description Creates a match, possibly with match games. * If `childCount` is 0, then there is no children. The score of the match is directly its intrinsic score. * If `childCount` is greater than 0, then the score of the match will automatically be calculated based on its child games. ### Parameters - **stageId** (Id) - Required - ID of the parent stage. - **groupId** (Id) - Required - ID of the parent group. - **roundId** (Id) - Required - ID of the parent round. - **matchNumber** (number) - Required - Number in the round. - **opponents** (Duel) - Required - The two opponents matching against each other. - **childCount** (number) - Required - Child count for this match (number of games). ### Returns Promise ``` -------------------------------- ### normalizeIds Source: https://drarig29.github.io/brackets-docs/reference/manager/functions/helpers.normalizeIds.html Normalizes IDs in a database. All IDs (and references to them) are remapped to consecutive IDs starting from 0. ```APIDOC ## Function normalizeIds ### Description Normalizes IDs in a database. All IDs (and references to them) are remapped to consecutive IDs starting from 0. ### Parameters #### data (ValueToArray) - Required Data to normalize. ### Returns Database ``` -------------------------------- ### Functions Source: https://drarig29.github.io/brackets-docs/reference/manager/modules/helpers.html A comprehensive list of functions available in the helpers module for bracket management. ```APIDOC ### Functions assertRoundRobin balanceByes byeLoser byeWinner byeWinnerToGrandFinal convertMatchesToSeeding convertSlotsToSeeding convertTBDtoBYE ensureEquallySized ensureEvenSized ensureNoDuplicates ensureNotRoundRobin ensureNotTied ensureOrderingSupported ensureValidSize extractParticipantsFromSeeding findLoserMatchNumber findParticipant findPosition fixSeeding getChildGamesResults getDiagonalMatchNumber getFractionOfFinal getGrandFinalDecisiveMatch getInferredResult getLoser getLoserCountFromWbForLbRound getLoserOrdering getLoserRoundMatchCount getLosers getLowerBracketRoundCount getMatchLocation getMatchResult getMatchStatus getNearestPowerOfTwo getNextSide getNextSideConsolationFinalDoubleElimination getNextSideLoserBracket getNonNull getOpponentId getOriginPosition getOtherSide getParentMatchResults getRanking getRoundPairCount getSeedCount getSeeds getSide getUpdatedMatchResults getUpperBracketRoundCount getWinner handleGivenStatus handleOpponentsInversion hasBye invertOpponents isDefined isDoubleEliminationNecessary isFinalGroup isLoserBracket isMajorRound isMatchByeCompleted isMatchCompleted isMatchDrawCompleted isMatchForfeitCompleted isMatchOngoing isMatchParticipantLocked isMatchPending isMatchResultCompleted isMatchStale isMatchStarted isMatchUpdateLocked isMatchWinCompleted isMinorRound isOrderingSupportedLoserBracket isOrderingSupportedUpperBracket isParticipantInMatch isPowerOfTwo isRoundCompleted isRoundRobin isSeedingWithIds isWinnerBracket makeFinalStandings makeGroups makeNormalizedIdMapping makePairs makeRoundRobinDistribution makeRoundRobinMatches mapParticipantsIdsToDatabase mapParticipantsNamesToDatabase mapParticipantsToDatabase minScoreToWinBestOfX normalizeIds normalizeParticipant resetMatchResults resetNextOpponent setArraySize setCompleted setExtraFields setForfeits setMatchResults setNextOpponent setParentMatchCompleted setResults setScores sortSeeding splitBy splitByParity toResult toResultWithPosition transitionToMajor transitionToMinor uniqueBy ``` -------------------------------- ### upperBracket Source: https://drarig29.github.io/brackets-docs/reference/manager/classes/Find.html Gets the upper bracket (the only bracket if single elimination or the winner bracket in double elimination). ```APIDOC ## upperBracket ### Description Gets the upper bracket (the only bracket if single elimination or the winner bracket in double elimination). ### Parameters #### Path Parameters - **stageId** (Id) - Required - ID of the stage. ### Returns Promise ``` -------------------------------- ### getUpperBracket Source: https://drarig29.github.io/brackets-docs/reference/manager/classes/Find.html Gets the upper bracket (the only bracket if single elimination or the winner bracket in double elimination). ```APIDOC ## getUpperBracket ### Description Gets the upper bracket (the only bracket if single elimination or the winner bracket in double elimination). ### Parameters #### Path Parameters - **stageId** (Id) - Required - ID of the stage. ### Returns Promise ``` -------------------------------- ### getNextSideLoserBracket Source: https://drarig29.github.io/brackets-docs/reference/manager/functions/helpers.getNextSideLoserBracket.html Gets the side the winner of the current match in the loser bracket will go in the next match. ```APIDOC ## Function getNextSideLoserBracket ### Description Gets the side the winner of the current match in loser bracket will go in the next match. ### Signature getNextSideLoserBracket(matchNumber: number, nextMatch: Match, roundNumber: number): Side ### Parameters #### matchNumber (number) - Required Number of the match. #### nextMatch (Match) - Required The next match. #### roundNumber (number) - Required Number of the current round. ### Returns Side ``` -------------------------------- ### setExisting Source: https://drarig29.github.io/brackets-docs/reference/manager/classes/StageCreator.html Enables update mode for an existing stage. ```APIDOC ## setExisting ### Description Enables the update mode. ### Method PUT (assumed, as it modifies state) ### Endpoint /stages/{stageId}/existing #### Parameters ##### Path Parameters - **stageId** (Id) - Required - ID of the stage. ##### Request Body - **enableByes** (boolean) - Required - Whether to use BYEs or TBDs for `null` values in an input seeding. Set to `true` when `confirmSeeding()` is called. #### Returns void ``` -------------------------------- ### getRoundPositionalInfo Source: https://drarig29.github.io/brackets-docs/reference/manager/classes/Find.html Gets the positional information (number in group and total number of rounds in group) of a round based on its id. ```APIDOC ## getRoundPositionalInfo ### Description Gets the positional information (number in group and total number of rounds in group) of a round based on its id. ### Parameters #### Path Parameters - **roundId** (Id) - Required - ID of the round. ### Returns Promise ``` -------------------------------- ### convertSlotsToSeeding Source: https://drarig29.github.io/brackets-docs/reference/manager/functions/helpers.convertSlotsToSeeding.html Converts a list of slots to an input seeding. ```APIDOC ## Function convertSlotsToSeeding ### Description Converts a list of slots to an input seeding. ### Parameters #### slots (ParticipantSlot[]) - Required The slots to convert. ### Returns Seeding ``` -------------------------------- ### createRound Source: https://drarig29.github.io/brackets-docs/reference/manager/classes/StageCreator.html Creates a round, which contain matches. ```APIDOC ## createRound ### Description Creates a round, which contain matches. ### Parameters - **stageId** (Id) - Required - ID of the parent stage. - **groupId** (Id) - Required - ID of the parent group. - **roundNumber** (number) - Required - Number of the round. - **matchCount** (number) - Required - Number of matches in the round. - **duels** (Duel[]) - Required - List of duels for the round. - **matchNumberStart** (number) - Optional - Starting number for matches in the round. ### Returns Promise ``` -------------------------------- ### Get Current Stage and Round Source: https://drarig29.github.io/brackets-docs/user-guide/helpers Retrieve the current stage and round of a tournament. Handles cases where the tournament might be completed. ```javascript const currentStage = await manager.get.currentStage(tournamentId); if (!currentStage) { // Tournament completed } const currentRound = await manager.get.currentRound(currentStage.id); ``` -------------------------------- ### MatchGame Interface Properties Source: https://drarig29.github.io/brackets-docs/reference/model/interfaces/MatchGame.html This snippet details the properties available for the MatchGame interface. ```APIDOC ## Interface MatchGame A game of a match. ### Properties - **id** (number) - ID of the match game. - **number** (number) - The number of the match game in its parent match. - **opponent1** (null | ParticipantResult) - First opponent of the match. - **opponent2** (null | ParticipantResult) - Second opponent of the match. - **parent_id** (Id) - ID of the parent match. - **stage_id** (Id) - ID of the parent stage. - **status** (Status) - Status of the match. ``` -------------------------------- ### Reset Stage Seeding Source: https://drarig29.github.io/brackets-docs/user-guide/seeding Resets the seeding of a stage to an empty state, setting all match opponents to TBDs. This is useful for starting over with seeding. ```javascript await manager.reset.seeding(stageId); ``` -------------------------------- ### Connection Interface Source: https://drarig29.github.io/brackets-docs/reference/viewer/interfaces/Connection.html Represents the connection information for a match, including optional previous and next connections. ```APIDOC ## Interface Connection Contains the information about the connections of a match. ### Properties #### `Optional` connectPrevious connectPrevious?: ConnectionType #### `Optional` connectNext connectNext?: ConnectionType ``` -------------------------------- ### BracketsManager Class Methods Source: https://drarig29.github.io/brackets-docs/reference/manager The BracketsManager class provides methods for managing brackets, including Delete, Find, Get, Reset, StageCreator, and Update operations. ```APIDOC ## BracketsManager ### Description Provides methods for managing brackets. ### Methods - **Delete**: Deletes a bracket. - **Find**: Finds brackets based on certain criteria. - **Get**: Retrieves a specific bracket. - **Reset**: Resets a bracket. - **StageCreator**: Creates a stage for brackets. - **Update**: Updates an existing bracket. ``` -------------------------------- ### BracketsManager Class Source: https://drarig29.github.io/brackets-docs/reference/manager/index.html The BracketsManager class provides methods for managing brackets, including operations like Delete, Find, Get, Reset, StageCreator, and Update. ```APIDOC ## BracketsManager ### Description Provides methods for managing brackets. ### Methods - `Delete` - `Find` - `Get` - `Reset` - `StageCreator` - `Update` ``` -------------------------------- ### Get Current Round of a Stage Source: https://drarig29.github.io/brackets-docs/reference/manager/classes/Get.html Fetches the round that is not yet completed due to ongoing matches. Returns null if all matches in the stage are finished. Requires the stage ID. ```typescript const tournamentId = 3; const currentStage = await manager.get.currentStage(tournamentId); const currentRound = await manager.get.currentRound(currentStage.id); ``` -------------------------------- ### getMajorOrdering Source: https://drarig29.github.io/brackets-docs/reference/manager/classes/StageCreator.html Safely retrieves the unique major ordering configuration for the loser's bracket. ```APIDOC ## getMajorOrdering ### Description Safely gets the only major ordering for the lower bracket. ### Method getMajorOrdering(participantCount) ### Parameters #### Path Parameters - **participantCount** (number) - Required - Number of participants in the stage. ### Returns SeedOrdering ``` -------------------------------- ### Get Current Matches for a Stage Source: https://drarig29.github.io/brackets-docs/reference/manager/classes/Get.html Retrieves matches that are currently ongoing or ready to be played within a specific stage. Useful for displaying active games. Requires the stage ID. ```typescript const tournamentId = 3; const currentStage = await manager.get.currentStage(tournamentId); const currentMatches = await manager.get.currentMatches(currentStage.id); ``` -------------------------------- ### Create a Tournament Stage Source: https://drarig29.github.io/brackets-docs/getting-started Use the manager to create a new tournament stage. This includes defining the stage name, tournament ID, type (e.g., 'single_elimination'), and initial seeding. ```javascript await manager.create.stage({ name: 'Example stage', tournamentId: 0, // type: 'single_elimination', seeding: [ 'Team 1', 'Team 2', 'Team 3', 'Team 4', 'Team 5', 'Team 6', 'Team 7', 'Team 8', ], }); ``` -------------------------------- ### getSeeds(inLoserBracket, roundNumber, roundCountLB, matchCount) Source: https://drarig29.github.io/brackets-docs/reference/manager/functions/helpers.getSeeds.html Gets the default list of seeds for a round's matches. This function is useful for initializing match seeds based on tournament structure. ```APIDOC ## Function getSeeds * getSeeds(inLoserBracket, roundNumber, roundCountLB, matchCount): number[] * Gets the default list of seeds for a round's matches. #### Parameters * ##### inLoserBracket: boolean Whether the match is in the loser bracket. * ##### roundNumber: number The number of the current round. * ##### roundCountLB: number The count of rounds in loser bracket. * ##### matchCount: number The count of matches in the round. #### Returns number[] ``` -------------------------------- ### Create Round Robin Stage with Object Seeding Source: https://drarig29.github.io/brackets-docs/user-guide/seeding Provide participant objects with custom fields (e.g., `region`) for a round-robin stage. Participants without IDs will be automatically registered. ```javascript await manager.create.stage({ tournamentId: 1, name: 'Groups', type: 'round_robin', seeding: [ { id: 10, name: 'Alpha', region: 'EU' }, { name: 'Bravo', region: 'NA' }, 'Charlie', 'Delta', ], settings: { groupCount: 2, seedOrdering: ['groups.effort_balanced'], }, }); ``` -------------------------------- ### Create Double Elimination Stage with ID Seeding Source: https://drarig29.github.io/brackets-docs/user-guide/seeding Use a list of existing participant IDs and BYEs (`null`) to create a double elimination stage. Participants must already exist in the tournament. ```javascript await manager.create.stage({ tournamentId: 1, name: 'Playoffs', type: 'double_elimination', seedingIds: [1, 2, 3, 4, 5, 6, null, null], settings: { size: 8, seedOrdering: ['inner_outer', 'natural'], balanceByes: true, grandFinal: 'simple', }, }); ``` -------------------------------- ### CallableCreate.stage Source: https://drarig29.github.io/brackets-docs/reference/manager/interfaces/CallableCreate.html Creates a stage for an existing tournament. The tournament itself will not be created. ```APIDOC ## stage(stage: InputStage): Promise ### Description Creates a stage for an existing tournament. The tournament won't be created. ### Parameters #### stage: InputStage A stage to create. ### Returns Promise ### Deprecated Please use `manager.create.stage()` instead. ``` -------------------------------- ### getMinorOrdering Source: https://drarig29.github.io/brackets-docs/reference/manager/classes/StageCreator.html Safely retrieves a minor ordering configuration for the loser's bracket based on its index. ```APIDOC ## getMinorOrdering ### Description Safely gets a minor ordering for the lower bracket by its index. ### Method getMinorOrdering(participantCount, index, minorRoundCount) ### Parameters #### Path Parameters - **participantCount** (number) - Required - Number of participants in the stage. - **index** (number) - Required - Index of the minor round. - **minorRoundCount** (number) - Required - Number of minor rounds. ### Returns undefined | SeedOrdering ``` -------------------------------- ### RoundRobinFinalStandingsItem Properties Source: https://drarig29.github.io/brackets-docs/reference/manager/interfaces/RoundRobinFinalStandingsItem.html The RoundRobinFinalStandingsItem interface includes properties inherited from RankingItem, along with specific metrics for round-robin play. ```APIDOC ## Interface RoundRobinFinalStandingsItem An item in the final standings of a round-robin stage. Each item represents a Participant. ### Properties - **draws** (number): Number of matches that ended in a draw. - **forfeits** (number): Number of matches forfeited by the participant. - **groupId** (Id): The group ID of the participant. - **id** (Id): ID of the participant. - **losses** (number): Number of matches lost by the participant. - **name** (string): Name of the participant. - **played** (number): Number of matches played by the participant. - **points** (number): Total points of the participant. - **rank** (number): Resulting rank of the participant. - **scoreAgainst** (number): Total score in favor of the opponents. - **scoreDifference** (number): Difference between scoreFor and scoreAgainst. - **scoreFor** (number): Total score in favor of the participant. - **wins** (number): Number of matches won by the participant. ``` -------------------------------- ### Match Interface Properties Source: https://drarig29.github.io/brackets-docs/reference/model/interfaces/Match.html This snippet details the properties available for the Match interface. ```APIDOC ## Interface Match A match of a round. ### Properties - **child_count** (number): The count of match games this match has. Can be `0` if it's a simple match, or a positive number for "Best Of" matches. - **group_id** (Id): ID of the parent group. - **id** (Id): ID of the match. - **number** (number): The number of the match in its round. - **opponent1** (null | ParticipantResult): First opponent of the match. - **opponent2** (null | ParticipantResult): Second opponent of the match. - **round_id** (Id): ID of the parent round. - **stage_id** (Id): ID of the parent stage. - **status** (Status): Status of the match. ``` -------------------------------- ### createDoubleEliminationSkipFirstRound Source: https://drarig29.github.io/brackets-docs/reference/manager/classes/StageCreator.html Creates a double elimination stage with skip first round option. ```APIDOC ## createDoubleEliminationSkipFirstRound ### Description Creates a double elimination stage with skip first round option. ### Parameters - **stageId** (Id) - Required - ID of the stage. - **slots** (ParticipantSlot[]) - Required - A list of slots. ### Returns Promise ``` -------------------------------- ### Round-robin Seed Ordering Source: https://drarig29.github.io/brackets-docs/user-guide/ordering Use the 'groups.effort_balanced' method for round-robin tournaments to spread seeds across groups and balance strengths. ```javascript await manager.create.stage({ tournamentId: 1, name: 'Groups', type: 'round_robin', seeding: ['A','B','C','D','E','F','G','H'], settings: { groupCount: 2, seedOrdering: ['groups.effort_balanced'], }, }); ``` -------------------------------- ### RoundRobinFinalStandingsOptions Source: https://drarig29.github.io/brackets-docs/reference/manager/interfaces/RoundRobinFinalStandingsOptions.html Options for configuring the final standings of a round-robin stage, including the maximum number of qualified participants per group and the ranking formula. ```APIDOC ## Interface: RoundRobinFinalStandingsOptions ### Description Options for the final standings of a round-robin stage. ### Properties #### `maxQualifiedParticipantsPerGroup` (Optional) - **Type**: `number` - **Description**: The maximum number of participants to qualify per group. #### `rankingFormula` - **Type**: `RankingFormula` - **Description**: A formula required to rank participants in a round-robin stage. See `RankingItem` for the possible properties on `item`. ##### Example Ranking Formula ```javascript (item) => 3 * item.wins + 1 * item.draws + 0 * item.losses ``` ``` -------------------------------- ### roundRobin Source: https://drarig29.github.io/brackets-docs/reference/manager/classes/StageCreator.html Creates a round robin stage. ```APIDOC ## roundRobin ### Description Creates a round robin stage. ### Parameters - **stageId** (Id) - Required - ID of the stage. - **slots** (ParticipantSlot[]) - Required - A list of slots. ### Returns Promise ``` -------------------------------- ### roundRobin Source: https://drarig29.github.io/brackets-docs/reference/manager/classes/StageCreator.html Creates a round-robin stage, distributing participants into groups and rounds. ```APIDOC ## roundRobin ### Description Creates a round-robin stage. Group count must be given. It will distribute participants in groups and rounds. ### Method POST (assumed, as it creates a resource) ### Endpoint /stages/round-robin #### Returns Promise ``` -------------------------------- ### makeRoundRobinMatches Source: https://drarig29.github.io/brackets-docs/reference/manager/functions/helpers.makeRoundRobinMatches.html Generates a list of rounds containing the matches of a round-robin group. It takes an array of participants and an optional mode. ```APIDOC ## Function makeRoundRobinMatches ### Description Makes a list of rounds containing the matches of a round-robin group. ### Type Parameters #### T ### Parameters #### participants: T[] Required. The participants to distribute. #### mode: RoundRobinMode = 'simple' Optional. The round-robin mode. Defaults to 'simple'. ### Returns [T, T][][] A list of rounds, where each round is a list of matches, and each match is a pair of participants. ```