Skip to main content

Installation

Requirements​

  • Node.js 24 or later for server-side and build-time use (engines.node is >=24).
  • No runtime dependencies: installing the factory adds one package.
  • TypeScript declarations ship with the package; there is no @types package to add.

Add to a project​

pnpm add tods-competition-factory
# - or -
yarn add tods-competition-factory
# - or -
npm i tods-competition-factory

Include in a project​

The package ships both an ES module build and a CommonJS build, and the right one is chosen from how it is loaded.

// ES modules
import { tournamentEngine, mocksEngine, tools } from 'tods-competition-factory';

// CommonJS
const { tournamentEngine, mocksEngine, tools } = require('tods-competition-factory');

Named imports are preferred over import * as factory: the package declares no side effects, so a bundler keeps only what is imported.

Entry points​

ImportWhat it provides
tods-competition-factoryEngines, governors, tools, fixtures, constants, enums and types
tods-competition-factory/governorsThe governors alone, for assembling a custom engine
tods-competition-factory/score-entry-stateA headless score-entry state engine
tods-competition-factory/schema/tournament.schema.jsonThe JSON Schema of a tournament record
import { scoreGovernor, drawsGovernor } from 'tods-competition-factory/governors';

Only these entry points are supported. Paths inside dist/ are not part of the package's interface.

Check the installation​

import { askEngine } from 'tods-competition-factory';

askEngine.version(); // the installed version, e.g. '7.40.0'

A first tournament​

The mocks engine generates a complete tournament record, which an engine then holds as its state:

import { mocksEngine, tournamentEngine } from 'tods-competition-factory';

const { tournamentRecord } = mocksEngine.generateTournamentRecord({
drawProfiles: [{ drawSize: 8 }],
});

tournamentEngine.setState(tournamentRecord);

const { matchUps } = tournamentEngine.allTournamentMatchUps();
console.log(matchUps.length); // 7

Where next​