Publishing Governor
The Publishing Governor provides methods for controlling the public visibility of tournament information through publish state management. These methods work in conjunction with Time Items to track what's published and when.
import { publishingGovernor } from 'tods-competition-factory';
See Publishing Concepts for comprehensive coverage of publishing workflows, rationale, and best practices.
Overview
Publishing operates at multiple levels of granularity:
- Tournament Level: Participants, Order of Play
- Event Level: All draws, specific draws (flights), seeding
- Draw Level: Entire draws, specific stages (MAIN, QUALIFYING, CONSOLATION)
- Structure Level: Specific structures, round-by-round visibility
All publishing methods:
- Update publish state via Time Items
- Trigger subscription notifications
- Support
removePriorValuesto clear previous publish state - Enable fine-grained control over information release
getPublishState
Returns publishing details for tournament, event(s), and/or draws, enabling queries about current publish state before making changes.
Return All Publish State
const { publishState } = engine.getPublishState();
// Tournament-level state
const participantsPublished = publishState.tournament.participants.published;
const orderOfPlayPublished = publishState.tournament.orderOfPlay.published;
// Event-level state (accessed by eventId)
const eventState = publishState['eventId'].status;
const {
published, // boolean - is event published?
publishedDrawIds, // array of published draw IDs
drawDetails, // granular stage/structure details
} = eventState;
Query Specific Event
const { publishState } = engine.getPublishState({ eventId });
const eventPublished = publishState.status.published;
const publishedDraws = publishState.status.publishedDrawIds;
Query Specific Draw
const { publishState } = engine.getPublishState({ drawId });
const drawPublished = publishState.status.published;
// When only specific stages or structures are published
const drawPublishDetail = publishState.status.drawDetail;
// Example structure: { stages: ['MAIN'], structures: { [structureId]: { roundLimit: 2 } } }
Use Cases:
- Verify current state before publishing
- Display publish status in admin UI
- Determine if re-publishing is needed
- Query embargo status
publishEvent
Publishes event draws and structures with fine-grained control over visibility. Generates optimized eventData payload and triggers PUBLISH_EVENT subscription notifications.
Key Features:
- Publishes entire events or specific draws (flights)
- Stage-level control (MAIN, QUALIFYING, CONSOLATION)
- Structure and round-level granularity
- Embargo support for scheduled publication
- Privacy policy application
- Subscription notification with prepared payload
const { eventData } = engine.publishEvent({
eventId, // required - event to publish
// Draw selection (choose one approach)
drawIdsToAdd, // array - publish specific draws
drawIdsToRemove, // array - unpublish specific draws
drawDetails, // object - granular control (see below)
// Data preparation
eventDataParams, // optional - params for getEventData (not persisted)
policyDefinitions, // optional - privacy policies to apply
// State management
removePriorValues, // optional boolean - clear previous timeItems
});
Publishing Patterns
Publish All Draws in Event
engine.publishEvent({ eventId });
Publish Specific Draws (Flights)
// Shorthand
engine.publishEvent({
eventId,
drawIdsToAdd: ['drawId1', 'drawId2'],
});
// Remove draws from publication
engine.publishEvent({
eventId,
drawIdsToRemove: ['drawId3'],
});
Publish by Stage
import { stageConstants } from 'tods-competition-factory';
engine.publishEvent({
eventId,
drawDetails: {
[drawId]: {
stagesToAdd: [stageConstants.QUALIFYING],
publishingDetail: { published: true },
},
},
});
Round-by-Round Publishing
// Publish only first round of a structure
engine.publishEvent({
eventId,
drawDetails: {
[drawId]: {
structureDetails: {
[structureId]: {
roundLimit: 1,
published: true,
},
},
},
},
});
// Expand to include more rounds
engine.publishEvent({
eventId,
drawDetails: {
[drawId]: {
structureDetails: {
[structureId]: {
roundLimit: 3, // Now shows rounds 1-3
published: true,
},
},
},
},
});
Publishing with Embargo
const embargoTime = new Date('2024-06-15T10:00:00Z').toISOString();
engine.publishEvent({
eventId,
drawDetails: {
[drawId]: {
publishingDetail: {
published: true,
embargo: embargoTime, // Don't display until this time
},
},
},
});
Publishing with Privacy Policies
import { policyConstants } from 'tods-competition-factory';
const privacyPolicy = {
participant: {
contacts: false,
addresses: false,
individualParticipants: {
contacts: false,
addresses: false,
},
},
};
const { eventData } = engine.publishEvent({
eventId,
policyDefinitions: {
[policyConstants.POLICY_TYPE_PARTICIPANT]: privacyPolicy,
},
});
Customizing Event Data Payload
Event data parameters are not persisted in publish state. Client applications must pass their own parameters when querying with usePublishState: true.
// Server-side publishing
const { eventData } = engine.publishEvent({
eventId,
eventDataParams: {
allParticipantResults: true,
participantsProfile: {
withISO2: true,
withIOC: true,
},
},
});
// Client must pass same params when querying
const { eventData: clientData } = engine.getEventData({
eventId,
usePublishState: true,
allParticipantResults: true,
participantsProfile: { withISO2: true, withIOC: true },
});
See: Publishing Concepts for details on eventData structure.
publishEventSeeding
Publishes event seeding information separately from draw structures, enabling flexible control over when seeding becomes publicly visible.
Why Separate Seeding Publication:
- Prevent participants from knowing seeded positions before draws finalized
- Announce seeded players separately from draw structure
- Update seeding without re-publishing entire draw
- Different scales for different stages
engine.publishEventSeeding({
eventId, // required
// Scale selection
seedingScaleNames, // optional - array of scale names
stageSeedingScaleNames, // optional - { MAIN: 'scale1', QUALIFYING: 'scale2' }
// Draw selection
drawIds, // optional - publish specific draws only
// State management
removePriorValues, // optional boolean - clear previous timeItems
});
Examples
Publish All Seeding
engine.publishEventSeeding({ eventId });
Publish Specific Scales
engine.publishEventSeeding({
eventId,
seedingScaleNames: ['U18', 'WTN'],
});
Different Scales per Stage
engine.publishEventSeeding({
eventId,
stageSeedingScaleNames: {
MAIN: 'U18',
QUALIFYING: 'U18Q',
},
});
Publish Specific Flights
engine.publishEventSeeding({
eventId,
drawIds: ['flight1', 'flight2'],
});
publishOrderOfPlay
Publishes scheduled matchUps (Order of Play), controlling visibility of which matches are scheduled for which courts and times.
Why Order of Play Publishing:
- Prepare schedules internally before announcing
- Make scheduling changes before public release
- Coordinate releases with media partners
- Publish each day's schedule separately
engine.publishOrderOfPlay({
scheduledDates, // optional - array of dates to publish
eventIds, // optional - array of events to publish
removePriorValues, // optional boolean - clear previous timeItems
});