Installation
Requirements
- Node.js 24 or later for server-side and build-time use (
engines.nodeis>=24). - No runtime dependencies: installing the factory adds one package.
- TypeScript declarations ship with the package; there is no
@typespackage 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
| Import | What it provides |
|---|---|
tods-competition-factory | Engines, governors, tools, fixtures, constants, enums and types |
tods-competition-factory/governors | The governors alone, for assembling a custom engine |
tods-competition-factory/score-entry-state | A headless score-entry state engine |
tods-competition-factory/schema/tournament.schema.json | The 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
- Mutation Engines: which engine to use on a client and on a server.
- Engine Methods: how methods are called and what they return.
- Governors: the methods, grouped by what they act on.
- Migration to 8.0.0: what to change now to be ready for the next major release.