# OMX Worked Examples

Each file is a complete meet document that validates against
[`meet-document.schema.json`](/omx/schemas/meet-document-v1.schema.json), and against the strict check for its
kind: `registration-document-v1` for a registration example, `results-document-v1` for a results
one. Each also passes `omx-check.mjs`. Together they exercise every optional block at least once.

The examples use two invented products: ExampleRegistration (system id `examplereg`) writes the
registration documents, and ExampleTimer (`exampletimer`) writes the results.

Each registration example (`"kind": "registration"`) has a results twin, named `-returned.json`:
the same meet handed on by Meet Operations as a `full` results document (`"kind": "results"`,
`"update": "full"`), the whole meet as it stands. Compare each pair side by side:

- The meet, events, teams, and athletes carry Meet Operations' own `id`, with Registration's id kept
  in `external_ids` under `examplereg`, beside every other system's id Registration sent. Entries
  carry no `external_ids`: a Publisher finds an entry through its athlete and its event.
- Each registration entry comes back as one entry per round, each with its own id and a `round`.
- Records the timer created carry no Registration id, and `meet.origin` names the product the meet
  started in.
- A results document lists only the athletes its entries name and their teams, so a scratched
  athlete is gone. It carries no destinations, tokens, birth dates, contact details, chips, notes, or
  Registration's own extra fields.

| File                                                                           | Sport        | What it demonstrates                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| ------------------------------------------------------------------------------ | ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [`xc-invitational.json`](/omx/examples/xc-invitational.json)                   | `xc`         | ExampleRegistration as Registration and Publisher. The meet's MileSplit and Athletic.net ids and athletes' Athletic.net ids in `external_ids`, divisions with gendered names, bibs assigned at registration, an athlete sent with only a last initial, a scratch, and two destinations: ExampleRegistration asking for `live` delivery with `start_lists`, and a state records database left on the default, `final`                                                                                                                                                                                                                                                                                                                                                                                                                               |
| [`xc-invitational-returned.json`](/omx/examples/xc-invitational-returned.json) | `xc`         | The XC meet's results, as sent to ExampleRegistration: a walk-up athlete with no Registration id, `meet.origin`, every record's ExampleRegistration id beside its other systems' ids, an `official` race and an `unofficial` one, a tie shown as two equal places, a DQ that keeps its time, a DNF, a bib raced under that differs from the one Registration proposed, split `markers` with `time_ms` splits, no heats (a race with no gun time recorded lists none), and a scored race: Longwood 21 (1-2-4-6-8) [10-12] and Oviedo 35 (3-5-7-9-11) [13], scorers and displacers listed by `role`, and Winter Park, too small to score, listed `complete: false` with no points, its runners skipped in everyone's scoring positions. Because ExampleRegistration asked for `start_lists`, the JV races are `upcoming` with heat-sheet `e` entries |
| [`tf-outdoor-dual.json`](/omx/examples/tf-outdoor-dual.json)                   | `tf-outdoor` | Field events with imperial marks in `in`, a 4x100 relay with a letter and alternates, hurdle height and implement weight, and season-best seeds Meet Operations draws the 100m from                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| [`tf-outdoor-dual-returned.json`](/omx/examples/tf-outdoor-dual-returned.json) | `tf-outdoor` | The dual meet's results: each round's `scheduled_at`, lanes, a race's wind on its heat, wind per long jump attempt in the `field_series`, long jump and high jump series, relay legs in running order, a tie that splits points, a DQ, a DNS, a finisher with no time, a walk-up, each entry's team `points`, girls' and boys' team scores as separate blocks, and one event's standings listing the entries that scored, with their `role`                                                                                                                                                                                                                                                                                                                                                                                                        |
| [`tf-indoor-open.json`](/omx/examples/tf-indoor-open.json)                     | `tf-indoor`  | A registration site's meet: an open and a masters division, a mixed medley relay, a women's pentathlon entered on the multi-event with no component events listed, and a destination asking for `final`, the default                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| [`tf-indoor-open-returned.json`](/omx/examples/tf-indoor-open-returned.json)   | `tf-indoor`  | The open meet's results: the banked 200m `track` the meet ran on, prelims and finals with `qualified` `Q` and `q` on the prelim entries and the final marked `final`, two entries per finalist, a round `under_review`, the pentathlon at both levels with its five component events built by the timer and each component entry's `multi_points`, pole vault and weight throw series, DMR legs, and walk-ups                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| [`road-5k.json`](/omx/examples/road-5k.json)                                   | `run`        | Races open to every gender (`C`), award `groups` with award counts, chips, start waves with an `offset_ms`, a kids race beside the 5K, an age given without a birth date, and minors sent with only a last initial                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| [`road-5k-returned.json`](/omx/examples/road-5k-returned.json)                 | `run`        | The road race's results: gun time in `result` and net time in `net_result`, a round placed overall by gun and in groups by net (`place_by`), `group_places` naming groups, splits at named `markers`, waves, the heat's start time, transponder timing, and the age each runner was placed by                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |

Live and partial results are not examples; they are fixtures, each one of these documents with a
named change. [`c111-partial`](/omx/fixtures/c111-partial.omx.json) is a `partial` document carrying
one round, sent after a `full` one, and [`c114-race-in-progress`](/omx/fixtures/c114-race-in-progress.omx.json)
is a road race under way: the round `started`, finishers so far with their places, and runners still on the
course as `s` with their splits. The [fixture index](/omx/fixtures/index.json) lists them all.

## What Registration should copy

Start from the example closest to your sport and replace the ids with your own. Rules that are easy
to miss:

- `omx` is `version`, `kind` (`"registration"`), and `generator` (`id`, `name`, and optional
  `version`). Its `id` is your system id, from the spec's System ids table if you are listed.
- Every `id` is yours, is a string, and never changes for the life of the meet. Meet Operations
  hands your meet, event, team, and athlete ids back in `external_ids`, under your system id. Ids you
  hold on other systems go in `external_ids` under theirs, never your own. Entries carry none.
- An athlete is entered at most once in an event. Every relay entry carries a `letter`, and team +
  letter + event names one relay entry: that is how a result finds its way back to your entry.
- A mark's `value` is in the unit you measured in: integer `ms`, `mm`, or `pt`, or decimal `in`.
  Do not convert imperial marks to metric. `display` is optional and is only ever shown, never
  parsed.
- A scratch stays in `entries` with `status: "scr"`. The only statuses you send are `e`, `scr`, and
  `wait`.
- Times carry a UTC offset. Dates do not.
- Every event has a `code` the spec defines for the meet's sport, and the code is the whole event. A
  race's code is its advertised distance, and each distance has one code (`HMAR`, never `21097`). No
  product writes a code of its own. An athlete in a multi-event has one entry, on the multi-event,
  for any gender.
- Every value is one this version defines. An extra field of your own may carry your product's name
  as a prefix.
- An event open to every gender, a mixed relay included, is `C`. Leave an athlete's `gender` out
  when they did not state one.
- An athlete carries `age`, as you compute it for this meet, or `birth_date`, never both.
- A bib, when you assign one, is the athlete's. A runner with two bibs in one meet is two athletes.
- The document URL answers cross-origin requests, so a browser-based Meet Operations product can fetch it.
- `publish.token` is a different secret from whatever protects the document URL, with at least 128
  bits of randomness. The example tokens are random 32-character base62 strings behind a prefix.
  Choose each destination's `deliver` and `content` deliberately.
- Do not send what Meet Operations fills in or decides: `meet.origin`, `track`, `markers`, rounds,
  heats, lanes, results, places, points, team scores, `omx.update`, or `omx.updated_at`. They are part
  of the format, but they are not yours to write.

The example documents are dedicated to the public domain under [CC0 1.0](https://creativecommons.org/publicdomain/zero/1.0/): copy them as a starting point with no notice required.
