football-docs 0.17.8 → 0.17.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/README.md +13 -11
  2. package/data/docs.db +0 -0
  3. package/dist/impect-truth.d.ts +8 -0
  4. package/dist/impect-truth.js +100 -4
  5. package/dist/index.js +1 -0
  6. package/dist/provider-truth.js +7 -4
  7. package/dist/reep.d.ts +1 -1
  8. package/dist/reep.js +78 -20
  9. package/dist/skillcorner-spec.d.ts +45 -0
  10. package/dist/skillcorner-spec.js +395 -0
  11. package/docs/fast-forward/api.md +12 -5
  12. package/docs/fast-forward/benchmarks.md +2 -2
  13. package/docs/fast-forward/concepts-coordinate-systems.md +2 -2
  14. package/docs/fast-forward/concepts-dataset.md +9 -3
  15. package/docs/fast-forward/concepts-distributed-compute.md +2 -2
  16. package/docs/fast-forward/concepts-filelike.md +2 -2
  17. package/docs/fast-forward/concepts-layouts.md +2 -2
  18. package/docs/fast-forward/concepts-orientations.md +6 -6
  19. package/docs/fast-forward/concepts-transformations.md +2 -2
  20. package/docs/fast-forward/getting-started.md +2 -2
  21. package/docs/fast-forward/index.md +4 -4
  22. package/docs/fast-forward/providers-cdf.md +2 -2
  23. package/docs/fast-forward/providers-gradientsports.md +2 -2
  24. package/docs/fast-forward/providers-hawkeye.md +2 -2
  25. package/docs/fast-forward/providers-optavision.md +2 -2
  26. package/docs/fast-forward/providers-respovision.md +2 -2
  27. package/docs/fast-forward/providers-scisports.md +2 -2
  28. package/docs/fast-forward/providers-secondspectrum.md +43 -4
  29. package/docs/fast-forward/providers-signality.md +2 -2
  30. package/docs/fast-forward/providers-skillcorner.md +64 -18
  31. package/docs/fast-forward/providers-sportec.md +2 -2
  32. package/docs/fast-forward/providers-statsperform.md +2 -2
  33. package/docs/fast-forward/providers-tracab.md +2 -2
  34. package/docs/fast-forward/providers.md +3 -3
  35. package/docs/fast-forward/reporting-issues.md +2 -2
  36. package/docs/free-sources/understat.md +6 -0
  37. package/docs/impect/concepts.md +7 -4
  38. package/docs/impect/coordinate-system.md +7 -6
  39. package/docs/impect/data-model.md +58 -19
  40. package/docs/impect/event-types.md +8 -6
  41. package/docs/impect/identity-surfaces.md +12 -12
  42. package/docs/impect/kpi-definitions.md +135 -111
  43. package/docs/impect/overview.md +56 -18
  44. package/docs/reep/api.md +52 -69
  45. package/docs/reep/data-provenance.md +9 -4
  46. package/docs/reep/download-duckdb-csv.md +109 -84
  47. package/docs/reep/identity-and-ids.md +55 -40
  48. package/docs/reep/overview.md +50 -43
  49. package/docs/skillcorner/api-access.md +12 -2
  50. package/docs/skillcorner/api-endpoints.md +13 -5
  51. package/docs/skillcorner/data-model.md +5 -4
  52. package/docs/skillcorner/dynamic-events-delivered-values.md +41 -0
  53. package/docs/skillcorner/dynamic-events.md +518 -0
  54. package/docs/skillcorner/physical-data.md +27 -5
  55. package/docs/vald/api-endpoints.md +1 -1
  56. package/docs/vald/profiles.md +2 -0
  57. package/package.json +3 -1
  58. package/providers.json +9 -7
package/README.md CHANGED
@@ -293,7 +293,7 @@ metrics:sources` re-checks every card quote against its live source.
293
293
 
294
294
  | Provider | Chunks | Categories |
295
295
  |----------|--------|------------|
296
- | fast-forward | 250 | overview, getting-started, data-model, coordinate-system, orientations, layouts, transformations, distributed-compute, api-reference, 12 provider format pages |
296
+ | fast-forward | 255 | overview, getting-started, data-model, coordinate-system, orientations, layouts, transformations, distributed-compute, api-reference, 12 provider format pages |
297
297
  | StatsBomb | 244 | event-types, data-model, coordinate-system, api-access, api-endpoints, charting-lineups, xg-model, iq-metrics, player/team stats, player-mapping, identity-surfaces, data-provenance |
298
298
  | unravelsports | 202 | overview, installation, quickstart, concepts, graph converters, pressing intensity, formation detection, models, utils, american-football |
299
299
  | Wyscout | 165 | event-types, data-model, coordinate-system, api-access, api-endpoints, charting-analysis-metrics, glossary, identity-surfaces, data-provenance |
@@ -302,8 +302,8 @@ metrics:sources` re-checks every card quote against its live source.
302
302
  | SportMonks | 568 | full v3 endpoint reference (fixtures, livescores, leagues, seasons, states, types, statistics, brackets), syntax and includes, filtering, rate limits, error codes, changelog, plus curated event-types, data-model, api-access, charting-season-stories, identity-surfaces, data-provenance |
303
303
  | databallpy | 63 | data-model, overview, usage |
304
304
  | mplsoccer | 65 | overview, pitch-types, visualizations |
305
- | Impect | 79 | overview, data-model, event-types, coordinate-system, concepts, kpi-definitions, identity-surfaces, data-provenance |
306
- | SkillCorner | 52 | api-access, api-endpoints, data-model, physical-data, coordinate-system, concepts, identity-surfaces, data-provenance |
305
+ | Impect | 82 | overview, data-model, event-types, coordinate-system, concepts, kpi-definitions, identity-surfaces, data-provenance |
306
+ | SkillCorner | 80 | api-access, api-endpoints, data-model, dynamic-events, dynamic-events-delivered-values, physical-data, coordinate-system, concepts, identity-surfaces, data-provenance |
307
307
  | Free sources | 70 | overview, fbref, understat, football-data-columns, contextual-story-joins, xg-timelines, data-provenance |
308
308
  | soccerdata | 40 | overview, data-sources, usage |
309
309
  | TransferRoom | 45 | api-access, api-endpoints, charting-availability, data-model, identity-surfaces, data-provenance |
@@ -315,7 +315,7 @@ metrics:sources` re-checks every card quote against its live source.
315
315
  | Driblab | 34 | api-access, api-endpoints, data-model, data-provenance |
316
316
  | API-Football | 29 | api-access, data-model, identity-surfaces |
317
317
  | ESPN | 21 | api-access, scoreboard, match-summary, teams-and-standings, identity-and-coverage |
318
- | Reep | 33 | overview, identity-and-ids, download-duckdb-csv, api, data-provenance |
318
+ | Reep | 35 | overview, identity-and-ids, download-duckdb-csv, api, data-provenance |
319
319
  | TheSportsDB | 20 | api-access, api-endpoints, livescore, identity-surfaces, data-provenance |
320
320
  | FotMob | 5 | identity-surfaces, data-provenance |
321
321
  | Soccerdonna | 5 | identity-surfaces, data-provenance |
@@ -326,7 +326,7 @@ metrics:sources` re-checks every card quote against its live source.
326
326
  | VALD | 318 | api-access, api-endpoints, per-product endpoints and schemas (tenants, profiles, forcedecks, nordbord, forceframe, smartspeed, dynamo, humantrak), identity-surfaces, data-provenance |
327
327
  | Metric cards | 101 | xg, npxg, xg_assisted, xa, ppda, progressive_passes, progressive_carries, xt, vaep, field_tilt, pass_completion; see [Metric cards](#metric-cards) |
328
328
 
329
- **3,551 searchable chunks** across 32 providers and tools (the metric cards count as one).
329
+ **3,589 searchable chunks** across 32 providers and tools (the metric cards count as one).
330
330
 
331
331
  STATSports, Firstbeat, Hawkin Dynamics and VALD sell wearables and testing devices.
332
332
  Their APIs return a customer's own athlete data, which includes personal and health
@@ -341,11 +341,12 @@ for source status and [coverage notes](docs/espn/identity-and-coverage.md) for t
341
341
  tested requests and limitations.
342
342
 
343
343
  > **Impect** documentation is built solely from the public
344
- > [ImpectAPI/open-data](https://github.com/ImpectAPI/open-data) repository — a
345
- > static Bundesliga 2023/24 snapshot, representative of Impect's structure and
346
- > metric definitions rather than a complete or current mirror. Impect's
347
- > commercial API is deliberately not documented here. Every enum value, KPI name
348
- > and field name in `docs/impect/` is validated against that repository in CI
344
+ > [ImpectAPI/open-data](https://github.com/ImpectAPI/open-data) repository
345
+ > (release v2.0, with notes for v1.0) — a static Bundesliga 2023/24 snapshot,
346
+ > representative of Impect's structure and metric definitions rather than a
347
+ > complete or current mirror. Impect's commercial API is deliberately not
348
+ > documented here. Every enum value, KPI name, `inverted` flag and field name in
349
+ > `docs/impect/` is validated against that repository in CI
349
350
  > (`pnpm impect:truth`, `src/__tests__/impect-open-data-validation.test.ts`).
350
351
  > Data source: **Impect**; use is subject to the repository's own Terms of Use.
351
352
 
@@ -363,10 +364,11 @@ trusting them.
363
364
  | BeSoccer | The vendor's published Postman collection — request vocabulary and parameters | `src/__tests__/provider-truth.test.ts` |
364
365
  | Driblab | The vendor's published API guide — endpoint paths and methods. Field and group names are not in CI: the guide disagrees with the live API on them, so the docs follow the live API, checked by hand on 2026-09-22 | `src/__tests__/provider-truth.test.ts` |
365
366
  | Impect | The public [open-data](https://github.com/ImpectAPI/open-data) repository | `src/__tests__/impect-open-data-validation.test.ts` |
367
+ | SkillCorner (dynamic events) | Field names, Events columns and ID-to-name lists checked against every `*_dynamic_events.csv` in the public [open data](https://github.com/SkillCorner/opendata) at a pinned commit (`data/skillcorner-open-data-truth.json`). `dynamic-events-delivered-values.md` is checked against the distinct values, types and forms in those files, and must cover each delivered value and type that the specification does not give. Regenerate with `pnpm skillcorner:truth`. `dynamic-events.md` itself is built from the spec PDF by `pnpm skillcorner:spec` (`--check` to diff). `pnpm check:upstream` reports a newer open-data commit or a changed PDF | `src/__tests__/skillcorner-open-data-validation.test.ts` |
366
368
  | StatsBomb | ID and name pairs observed in a sample of the public [open data](https://github.com/statsbomb/open-data) (three matches per competition-season, at a pinned commit). IDs the sample lacks must be listed in both the Open Data Events specification and kloppy's parser. Regenerate with `pnpm statsbomb:truth` | `src/__tests__/statsbomb-truth.test.ts` |
367
369
  | Opta | Stats Perform's F24 appendices, which have no machine-readable form. `data/opta-truth.json` holds each ID the docs use, with its label, checked by hand. The test also rejects the wrong meanings earlier docs gave some IDs (`WRONG_MEANINGS` in `src/opta-truth.ts`) | `src/__tests__/opta-truth.test.ts` |
368
370
  | SportMonks | Type and state IDs as SportMonks publishes them on its definitions pages and in the types spreadsheet linked from its Types page (`data/sportmonks-types-truth.json`, fetched 2026-09-30). Not the full list: the complete one needs an API key | `src/__tests__/sportmonks-truth.test.ts` |
369
- | Reep | The public OpenAPI spec (endpoint paths and methods), and one release's file list, manifest and table columns read from its CSV headers (CSV table list, columns used in the SQL examples, exclusions) | `src/__tests__/provider-truth.test.ts`, `src/__tests__/reep.test.ts` |
371
+ | Reep | The public OpenAPI spec (endpoint paths and methods), and one release's file list, manifest and table columns read from its CSV headers (CSV table list, columns used in the SQL examples, licence, entity types and dropped IDs; `resolve_entity` offers exactly the release's entity types) | `src/__tests__/provider-truth.test.ts`, `src/__tests__/reep.test.ts` |
370
372
  | STATSports, Firstbeat, Hawkin Dynamics, VALD | Each vendor's public OpenAPI spec (STATSports v5 to v7, Firstbeat's `openapi.json`, the document inline on Hawkin's API reference page, VALD's eight product specs) — endpoint paths and methods, and every field name in the docs' schema tables. The STATSports `DrillKpiV7` table and the Hawkin metric tables must list the spec's and `metrics.json`'s entries in full. Firstbeat's variable list has no machine-readable source and is copied by hand from its public variables page | `src/__tests__/provider-truth.test.ts`, `src/__tests__/wearable-vendors.test.ts` |
371
373
 
372
374
  ESPN has a separate observation check in `src/__tests__/espn.test.ts`. It validates
package/data/docs.db CHANGED
Binary file
@@ -33,6 +33,14 @@ export interface ImpectTruth {
33
33
  enums: Record<string, string[]>;
34
34
  /** KPI id (as string) -> machine name, from kpi_definitions.json. */
35
35
  kpis: Record<string, string>;
36
+ /** KPI ids (as strings) whose `inverted` flag is true in kpi_definitions.json. */
37
+ invertedKpis: string[];
38
+ /**
39
+ * Every object key observed at any depth in each file family, by the
40
+ * family's name under data/ (events, matches, kpi_definitions, ...).
41
+ * Keys only, never values.
42
+ */
43
+ fields: Record<string, string[]>;
36
44
  /** ISO and FIFA country codes from countries.json. */
37
45
  countryCodes: string[];
38
46
  }
@@ -48,6 +48,16 @@ const DOCUMENTED_ONLY = [
48
48
  "FEMALE",
49
49
  "NATIONAL_TEAM",
50
50
  ];
51
+ /**
52
+ * Observed in the previous release (tag v1.0, commit d412b35) and no longer
53
+ * emitted in the current one. The docs name them only in a v1.0 note.
54
+ */
55
+ const V1_ONLY = ["BALL_OUT_OF_UNKNOWN"];
56
+ /**
57
+ * Field names Documentation.pdf describes as dataV4+ that are absent from the
58
+ * snapshot's JSON, so the generator cannot observe them.
59
+ */
60
+ const DOCUMENTED_ONLY_FIELDS = ["opponent", "dribble", "gk", "woodwork", "divePoint"];
51
61
  /** Values the docs name only to rule them out, as negative examples. */
52
62
  const NON_MEMBERS = ["BUILD_UP", "COUNTER_ATTACK"];
53
63
  /** Tokens that are not Impect data values at all. */
@@ -83,12 +93,33 @@ function collect(records, path) {
83
93
  }
84
94
  return [...out].sort();
85
95
  }
96
+ /** Add every object key found at any depth of `value` to `out`. */
97
+ function collectKeys(value, out) {
98
+ if (Array.isArray(value)) {
99
+ for (const item of value)
100
+ collectKeys(item, out);
101
+ }
102
+ else if (value !== null && typeof value === "object") {
103
+ for (const [key, child] of Object.entries(value)) {
104
+ out.add(key);
105
+ collectKeys(child, out);
106
+ }
107
+ }
108
+ }
86
109
  function readJson(path) {
87
110
  return JSON.parse(readFileSync(path, "utf-8"));
88
111
  }
89
112
  /** Build the truth file from a local clone of the open-data repository. */
90
113
  export function generateTruth(openDataDir, commit, generatedAt) {
91
114
  const dataDir = resolve(openDataDir, "data");
115
+ const fields = {};
116
+ const keysOf = (family, value) => {
117
+ fields[family] ??= new Set();
118
+ collectKeys(value, fields[family]);
119
+ };
120
+ const readFamily = (family) => readdirSync(resolve(dataDir, family))
121
+ .filter((f) => f.endsWith(".json"))
122
+ .map((f) => readJson(resolve(dataDir, family, f)));
92
123
  const eventFiles = readdirSync(resolve(dataDir, "events")).filter((f) => f.endsWith(".json"));
93
124
  const enums = {};
94
125
  const add = (field, values) => {
@@ -100,6 +131,7 @@ export function generateTruth(openDataDir, commit, generatedAt) {
100
131
  for (const file of eventFiles) {
101
132
  const events = readJson(resolve(dataDir, "events", file));
102
133
  eventCount += events.length;
134
+ keysOf("events", events);
103
135
  add("actionType", collect(events, "actionType"));
104
136
  add("action", collect(events, "action"));
105
137
  add("result", collect(events, "result"));
@@ -118,9 +150,12 @@ export function generateTruth(openDataDir, commit, generatedAt) {
118
150
  add("pitchPosition", collect(events, `${end}.pitchPosition`));
119
151
  }
120
152
  }
153
+ keysOf("events_kpis", readFamily("events_kpis"));
154
+ keysOf("player_kpis", readFamily("player_kpis"));
121
155
  // BANK and UNKNOWN appear only in lineups, never on events.
122
156
  for (const file of readdirSync(resolve(dataDir, "lineups")).filter((f) => f.endsWith(".json"))) {
123
157
  const lineup = readJson(resolve(dataDir, "lineups", file));
158
+ keysOf("lineups", lineup);
124
159
  for (const side of ["squadHome", "squadAway"]) {
125
160
  const squad = lineup[side];
126
161
  if (!squad)
@@ -139,25 +174,38 @@ export function generateTruth(openDataDir, commit, generatedAt) {
139
174
  const players = readdirSync(iterationDir)
140
175
  .filter((f) => f.endsWith(".json"))
141
176
  .flatMap((f) => readJson(resolve(iterationDir, f)));
177
+ keysOf("players", players);
142
178
  add("leg", collect(players, "leg"));
143
179
  add("gender", collect(players, "gender"));
144
180
  const squads = readdirSync(resolve(dataDir, "squads"))
145
181
  .filter((f) => f.endsWith(".json"))
146
182
  .flatMap((f) => readJson(resolve(dataDir, "squads", f)));
183
+ keysOf("squads", squads);
147
184
  add("squadType", collect(squads, "type"));
148
185
  const iterations = readJson(resolve(dataDir, "iterations.json"));
186
+ keysOf("iterations", iterations);
149
187
  add("dataVersion", collect(iterations, "dataVersion"));
188
+ add("ageGroup", collect(iterations, "competition.ageGroup"));
150
189
  const kpiDefs = readJson(resolve(dataDir, "kpi_definitions.json"));
190
+ keysOf("kpi_definitions", kpiDefs);
151
191
  const kpis = {};
152
192
  for (const kpi of kpiDefs)
153
193
  kpis[String(kpi.id)] = kpi.name;
194
+ const invertedKpis = kpiDefs
195
+ .filter((kpi) => kpi.inverted === true)
196
+ .map((kpi) => kpi.id)
197
+ .sort((a, b) => a - b)
198
+ .map(String);
154
199
  const countries = readJson(resolve(dataDir, "countries.json"));
200
+ keysOf("countries", countries);
155
201
  const countryCodes = [
156
202
  ...new Set([...collect(countries, "isoCode"), ...collect(countries, "fifaCode")]),
157
203
  ].sort();
158
204
  const matches = readdirSync(resolve(dataDir, "matches"))
159
205
  .filter((f) => f.endsWith(".json"))
160
206
  .flatMap((f) => readJson(resolve(dataDir, "matches", f)));
207
+ keysOf("matches", matches);
208
+ add("resultType", collect(matches, "resultType"));
161
209
  return {
162
210
  source: {
163
211
  repo: OPEN_DATA_REPO,
@@ -170,7 +218,11 @@ export function generateTruth(openDataDir, commit, generatedAt) {
170
218
  .sort(([a], [b]) => a.localeCompare(b))
171
219
  .map(([field, values]) => [field, [...values].sort()])),
172
220
  kpis,
221
+ invertedKpis,
173
222
  countryCodes,
223
+ fields: Object.fromEntries(Object.entries(fields)
224
+ .sort(([a], [b]) => a.localeCompare(b))
225
+ .map(([family, keys]) => [family, [...keys].sort()])),
174
226
  };
175
227
  }
176
228
  /** Every SCREAMING_SNAKE_CASE token inside a backtick code span. */
@@ -192,6 +244,7 @@ export function validateImpectDocs(docs, truth) {
192
244
  ...Object.values(truth.kpis),
193
245
  ...truth.countryCodes,
194
246
  ...DOCUMENTED_ONLY,
247
+ ...V1_ONLY,
195
248
  ...NON_MEMBERS,
196
249
  ...ALLOWLIST,
197
250
  ]);
@@ -206,9 +259,11 @@ export function validateImpectDocs(docs, truth) {
206
259
  violations.push(`${file}: "${token}" is not present in the open-data repository — invented, renamed, or needs an explicit entry in impect-truth.ts`);
207
260
  }
208
261
  }
209
- // The KPI index table maps ID -> name; both must match the source file.
210
- for (const row of text.matchAll(/^\|\s*`(\d+)`\s*\|\s*`([A-Z][A-Z0-9_]*)`\s*\|/gm)) {
211
- const [, id, name] = row;
262
+ // The KPI index table maps ID -> name (and, where a row has the column,
263
+ // the inverted flag); each must match the source file.
264
+ const inverted = new Set(truth.invertedKpis);
265
+ for (const row of text.matchAll(/^\|\s*`(\d+)`\s*\|\s*`([A-Z][A-Z0-9_]*)`\s*\|[^|\n]*\|(?:\s*(yes|no)\s*\|)?/gm)) {
266
+ const [, id, name, flag] = row;
212
267
  const actual = truth.kpis[id];
213
268
  if (actual === undefined) {
214
269
  violations.push(`${file}: KPI id ${id} does not exist in kpi_definitions.json`);
@@ -216,6 +271,46 @@ export function validateImpectDocs(docs, truth) {
216
271
  else if (actual !== name) {
217
272
  violations.push(`${file}: KPI id ${id} is "${actual}" in the source, documented as "${name}"`);
218
273
  }
274
+ if (flag !== undefined && (flag === "yes") !== inverted.has(id)) {
275
+ violations.push(`${file}: KPI id ${id} is documented as inverted=${flag}, source says ${inverted.has(id) ? "yes" : "no"}`);
276
+ }
277
+ }
278
+ violations.push(...validateFieldTables(file, text, truth));
279
+ }
280
+ return violations;
281
+ }
282
+ /**
283
+ * In a section headed with a data path (`## Matches — \`data/matches/...\``),
284
+ * every field named in the first cell of a table row must be a key observed
285
+ * somewhere in that file family.
286
+ */
287
+ function validateFieldTables(file, text, truth) {
288
+ const violations = [];
289
+ let family;
290
+ for (const line of text.split("\n")) {
291
+ const heading = line.match(/^## .*`data\/([a-z_]+)(?:\/|\.json)/);
292
+ if (heading) {
293
+ family = heading[1];
294
+ continue;
295
+ }
296
+ if (line.startsWith("## ")) {
297
+ family = undefined;
298
+ continue;
299
+ }
300
+ if (!family || !line.startsWith("|"))
301
+ continue;
302
+ const known = truth.fields[family];
303
+ if (!known) {
304
+ violations.push(`${file}: section for data/${family} has no field list in the truth file`);
305
+ family = undefined;
306
+ continue;
307
+ }
308
+ const firstCell = line.split("|")[1] ?? "";
309
+ for (const match of firstCell.matchAll(/`([a-z][A-Za-z0-9]*)`/g)) {
310
+ const field = match[1];
311
+ if (!known.includes(field) && !DOCUMENTED_ONLY_FIELDS.includes(field)) {
312
+ violations.push(`${file}: field "${field}" is not present in data/${family}`);
313
+ }
219
314
  }
220
315
  }
221
316
  return violations;
@@ -242,7 +337,8 @@ function main() {
242
337
  console.log(`Wrote ${TRUTH_PATH}\n` +
243
338
  ` ${truth.source.events} events across ${truth.source.matches} matches\n` +
244
339
  ` ${Object.keys(truth.enums).length} enums, ${enumCount} members\n` +
245
- ` ${Object.keys(truth.kpis).length} KPI definitions`);
340
+ ` ${Object.keys(truth.kpis).length} KPI definitions (${truth.invertedKpis.length} inverted)\n` +
341
+ ` ${Object.keys(truth.fields).length} file families with field lists`);
246
342
  }
247
343
  const isDirectRun = process.argv[1]?.endsWith("impect-truth.ts") || process.argv[1]?.endsWith("impect-truth.js");
248
344
  if (isDirectRun) {
package/dist/index.js CHANGED
@@ -178,6 +178,7 @@ export function createFootballDocsServer() {
178
178
  "Look up by provider + id (pass namespace too, e.g. transfermarkt 'spieler', opta 'person'), by reep_id, or by name.",
179
179
  "Sources, in order: a local copy of the free register (REEP_DUCKDB_PATH), then the Reep API (REEP_API_KEY; keys are",
180
180
  "issued by hand on request, never self-service). With neither set, it returns setup steps and a DuckDB query.",
181
+ "Name search needs the local file: on the current release the Reep API publishes no search (HTTP 410).",
181
182
  "Keeping the local file current: Reep publishes a download release weekly or less often; new matching reaches the",
182
183
  "Reep API daily. Every local answer ends with the file's release stamp checked",
183
184
  "against https://data.reep.football/releases/latest.json. If it says the file is out of date, tell the user and offer",
@@ -56,13 +56,16 @@ const TOKEN_ALLOWLIST = {
56
56
  mplsoccer: [],
57
57
  floodlight: ["PATH"],
58
58
  databallpy: [],
59
- // HTTP verbs in the endpoint tables.
60
- skillcorner: ["GET", "POST"],
59
+ // HTTP verbs in the endpoint tables, and the boolean spelling of the Dynamic
60
+ // Events CSV Specifications, quoted in dynamic-events-delivered-values.md.
61
+ skillcorner: ["GET", "POST", "TRUE", "FALSE"],
61
62
  // Match-official position codes emitted when include_officials=True. They come
62
63
  // from the Rust core rather than a Python enum, so introspection cannot see them.
63
64
  // FOURTH is the fourth official: the Rust core emits "4TH" and 0.3.0 relabels it
64
- // via _OFFICIAL_POSITION_RELABEL in fastforward._dataset.
65
- "fast-forward": ["REF", "AREF", "VAR", "AVAR", "FOURTH"],
65
+ // via _OFFICIAL_POSITION_RELABEL in fastforward._dataset. UNK is the position the
66
+ // 0.4.0 Second Spectrum mapping-file loader gives every player; it sits in the same
67
+ // Rust position-code table.
68
+ "fast-forward": ["REF", "AREF", "VAR", "AVAR", "FOURTH", "UNK"],
66
69
  // A torchmetrics metric the training loop tracks, not an unravel symbol.
67
70
  unravelsports: ["AUROC"],
68
71
  };
package/dist/reep.d.ts CHANGED
@@ -15,7 +15,7 @@
15
15
  export declare const REEP_CONTACT = "getintouch+nutmeg@withqwerty.com";
16
16
  export declare const REEP_DOWNLOAD_URL = "https://reep.football/downloads/duckdb";
17
17
  export declare const REEP_LATEST_URL = "https://data.reep.football/releases/latest.json";
18
- export declare const ENTITY_TYPES: readonly ["player", "coach", "referee", "team", "competition", "season", "stage", "venue", "match", "transfer", "award"];
18
+ export declare const ENTITY_TYPES: readonly ["player", "coach", "referee", "team", "competition", "season", "stage", "venue", "match"];
19
19
  export type EntityType = (typeof ENTITY_TYPES)[number];
20
20
  export type ResolveEntityArgs = {
21
21
  name?: string;
package/dist/reep.js CHANGED
@@ -31,8 +31,6 @@ export const ENTITY_TYPES = [
31
31
  "stage",
32
32
  "venue",
33
33
  "match",
34
- "transfer",
35
- "award",
36
34
  ];
37
35
  const textResult = (text, isError = false) => ({
38
36
  isError: isError || undefined,
@@ -69,6 +67,18 @@ function hasColumn(register, table, column) {
69
67
  }
70
68
  return known;
71
69
  }
70
+ /**
71
+ * Releases up to 2026-10-19.1 ship an entity_search table and record why a Reep ID
72
+ * left the register (redirects.reason). From 2026-11-23.1 a release publishes the
73
+ * mapping only: names are in entities and the two alias tables, redirects hold
74
+ * merges only, and a withdrawn ID leaves no trace.
75
+ */
76
+ function hasSearchTable(register) {
77
+ return hasColumn(register, "entity_search", "search_text");
78
+ }
79
+ function hasRedirectReason(register) {
80
+ return hasColumn(register, "redirects", "reason");
81
+ }
72
82
  function hasUpstreamStatus(register) {
73
83
  return hasColumn(register, "bridges", "upstream_status");
74
84
  }
@@ -132,7 +142,8 @@ async function followRedirects(register, start) {
132
142
  let current = start;
133
143
  const seen = new Set([start]);
134
144
  for (let hop = 0; hop < 5; hop++) {
135
- const next = await register.query("SELECT to_id, reason FROM redirects WHERE from_id = $id", { id: current });
145
+ const reason = (await hasRedirectReason(register)) ? "reason" : "NULL AS reason";
146
+ const next = await register.query(`SELECT to_id, ${reason} FROM redirects WHERE from_id = $id`, { id: current });
136
147
  if (!next.length)
137
148
  return { id: current };
138
149
  const to = next[0].to_id == null ? "" : String(next[0].to_id).trim();
@@ -183,12 +194,34 @@ async function localLookup(register, q) {
183
194
  else {
184
195
  const pattern = `%${q.name.replace(/[\\%_]/g, (c) => `\\${c}`)}%`;
185
196
  const params = { pattern };
186
- let sql = "SELECT reep_id, bridge_count FROM entity_search WHERE search_text ILIKE $pattern ESCAPE '\\'";
187
- if (q.type) {
188
- sql += " AND entity_type = $type";
197
+ if (q.type)
189
198
  params.type = q.type;
199
+ let sql;
200
+ if (await hasSearchTable(register)) {
201
+ sql = "SELECT reep_id, bridge_count FROM entity_search WHERE search_text ILIKE $pattern ESCAPE '\\'";
202
+ if (q.type)
203
+ sql += " AND entity_type = $type";
204
+ sql += " ORDER BY bridge_count DESC, reep_id";
205
+ }
206
+ else {
207
+ // An entity named exactly as asked (in any of its names) ranks first, then by provider IDs.
208
+ params.exact = q.name.toLowerCase();
209
+ const sources = ["SELECT reep_id, lower(canonical_name) = $exact AS exact FROM entities WHERE canonical_name ILIKE $pattern ESCAPE '\\'"];
210
+ for (const table of ["provider_aliases", "overlay_aliases"]) {
211
+ if (await hasColumn(register, table, "alias")) {
212
+ sources.push(`SELECT reep_id, lower(alias) = $exact AS exact FROM ${table} WHERE alias ILIKE $pattern ESCAPE '\\'`);
213
+ }
214
+ }
215
+ sql = [
216
+ `WITH hits AS (${sources.join(" UNION ALL ")}),`,
217
+ "named AS (SELECT reep_id, bool_or(exact) AS exact FROM hits GROUP BY reep_id)",
218
+ "SELECT n.reep_id, n.exact, count(b.reep_id) AS bridge_count",
219
+ "FROM named n JOIN entities e USING (reep_id) LEFT JOIN bridges b USING (reep_id)",
220
+ q.type ? "WHERE e.entity_type = $type" : "",
221
+ "GROUP BY n.reep_id, n.exact ORDER BY n.exact DESC, bridge_count DESC, n.reep_id",
222
+ ].join(" ");
190
223
  }
191
- ids = (await register.query(`${sql} ORDER BY bridge_count DESC LIMIT ${MAX_RESULTS}`, params)).map((r) => ({
224
+ ids = (await register.query(`${sql} LIMIT ${MAX_RESULTS}`, params)).map((r) => ({
192
225
  reep_id: String(r.reep_id),
193
226
  bridge_count: Number(r.bridge_count),
194
227
  }));
@@ -404,6 +437,18 @@ async function apiLookup(q, key, base, fetchImpl) {
404
437
  return textResult("The Reep API rate limit or monthly lookup allowance is used up (HTTP 429). For bulk work, use the free " +
405
438
  `download instead: set REEP_DUCKDB_PATH to a copy of ${REEP_DOWNLOAD_URL}. To raise the limit, email ${REEP_CONTACT}.`, true);
406
439
  }
440
+ if (response.status === 410) {
441
+ // A mapping-only release answers 410 not_published on /search and the change feed.
442
+ const error = (await response.json().catch(() => null));
443
+ const why = [error?.error, error?.message].filter(Boolean).join(": ");
444
+ const name = q.kind === "name"
445
+ ? " The API publishes no name search on this release. The free download answers it: set REEP_DUCKDB_PATH " +
446
+ `to a copy of ${REEP_DOWNLOAD_URL}, or run this query against the file:\n\n\`\`\`sql\n${sqlFor(q)}\n\`\`\`\n\n` +
447
+ "Or look the entity up by a provider ID (provider + id) instead."
448
+ : "";
449
+ return textResult(`The Reep API does not publish this on the current release (HTTP 410${why ? `, ${why}` : ""}).${name}` +
450
+ `${footer ? `\n\n${footer}` : ""}`, q.kind !== "name");
451
+ }
407
452
  if (response.status === 404) {
408
453
  // Keep the API's own error code and message: a removed entity leaves a
409
454
  // tombstone, and "not found" alone would hide that it was ever published.
@@ -442,9 +487,8 @@ function sqlFor(q) {
442
487
  const quote = (s) => `'${s.replace(/'/g, "''")}'`;
443
488
  if (q.kind === "provider") {
444
489
  return [
445
- "-- A bridge can name a merged Reep ID: follow its redirect to the survivor. An empty",
446
- "-- to_id is a tombstone (the ID was withdrawn or withheld), not a merge.",
447
- "SELECT b.reep_id AS bridged_id, r.reason AS redirect_reason, e.reep_id, e.canonical_name, e.entity_type,",
490
+ "-- A bridge can name a merged Reep ID: follow its redirect to the survivor.",
491
+ "SELECT b.reep_id AS bridged_id, e.reep_id, e.canonical_name, e.entity_type,",
448
492
  " o.provider, o.namespace, o.external_id",
449
493
  "FROM bridges b",
450
494
  "LEFT JOIN redirects r ON r.from_id = b.reep_id",
@@ -458,12 +502,12 @@ function sqlFor(q) {
458
502
  }
459
503
  if (q.kind === "reep_id") {
460
504
  return [
461
- "-- First check for a tombstone: a redirect with an empty to_id means the ID was withdrawn",
462
- "-- or withheld, not merged.",
463
- `SELECT from_id, to_id, reason FROM redirects WHERE from_id = ${quote(q.reepId)};`,
505
+ "-- First check for a merge: a row here names the survivor in to_id. Releases up to",
506
+ "-- 2026-10-19.1 also list withdrawn IDs here, with an empty to_id. Later ones do not.",
507
+ `SELECT from_id, to_id FROM redirects WHERE from_id = ${quote(q.reepId)};`,
464
508
  "",
465
- "-- Then follow a merge redirect to the survivor, and list every provider ID, including",
466
- "-- any still attached to an ID merged into it (bridged_on names that ID).",
509
+ "-- Then list every provider ID of the ID or its survivor, including any still attached",
510
+ "-- to an ID merged into it (bridged_on names that ID).",
467
511
  "SELECT e.reep_id, e.canonical_name, e.entity_type, b.provider, b.namespace, b.external_id, b.reep_id AS bridged_on",
468
512
  "FROM entities e",
469
513
  "JOIN bridges b ON b.reep_id = e.reep_id OR b.reep_id IN (SELECT from_id FROM redirects WHERE to_id = e.reep_id)",
@@ -472,11 +516,21 @@ function sqlFor(q) {
472
516
  "ORDER BY b.provider, b.namespace;",
473
517
  ].join("\n");
474
518
  }
519
+ const like = quote(`%${q.name}%`);
520
+ const exact = quote(q.name.toLowerCase());
475
521
  return [
476
- "SELECT reep_id, canonical_name, entity_type, bridge_count",
477
- "FROM entity_search",
478
- `WHERE search_text ILIKE ${quote(`%${q.name}%`)}${q.type ? ` AND entity_type = ${quote(q.type)}` : ""}`,
479
- "ORDER BY bridge_count DESC",
522
+ "-- Names are in entities and in the two alias tables. An exact name ranks first, then the",
523
+ "-- entities with the most provider IDs.",
524
+ "WITH hits AS (",
525
+ ` SELECT reep_id, lower(canonical_name) = ${exact} AS exact FROM entities WHERE canonical_name ILIKE ${like}`,
526
+ ` UNION ALL SELECT reep_id, lower(alias) = ${exact} FROM provider_aliases WHERE alias ILIKE ${like}`,
527
+ ` UNION ALL SELECT reep_id, lower(alias) = ${exact} FROM overlay_aliases WHERE alias ILIKE ${like}`,
528
+ "), named AS (SELECT reep_id, bool_or(exact) AS exact FROM hits GROUP BY reep_id)",
529
+ "SELECT e.reep_id, e.canonical_name, e.entity_type, count(b.reep_id) AS bridge_count",
530
+ "FROM named n JOIN entities e USING (reep_id) LEFT JOIN bridges b USING (reep_id)",
531
+ ...(q.type ? [`WHERE e.entity_type = ${quote(q.type)}`] : []),
532
+ "GROUP BY e.reep_id, e.canonical_name, e.entity_type, n.exact",
533
+ "ORDER BY n.exact DESC, bridge_count DESC, e.reep_id",
480
534
  "LIMIT 10;",
481
535
  ].join("\n");
482
536
  }
@@ -550,7 +604,11 @@ export async function resolveEntity(args, options = {}) {
550
604
  return textResult(`${tombstoneText(tombstone)}\n\n${note}`);
551
605
  const gone = tombstones.map((t) => tombstoneText(t)).join("\n\n");
552
606
  if (!found.length) {
553
- return textResult(`${gone || "No Reep entity matches that query in the local register."}\n\n${note}`);
607
+ const untraced = q.kind === "reep_id" && !gone && !(await hasRedirectReason(register))
608
+ ? " This release records merges but not withdrawals: a Reep ID from an earlier release that is not here " +
609
+ "(and is not mistyped) was withdrawn or withheld, and has no survivor to map to."
610
+ : "";
611
+ return textResult(`${gone || `No Reep entity matches that query in the local register.${untraced}`}\n\n${note}`);
554
612
  }
555
613
  return textResult(`Found ${found.length} result(s) in the local Reep register:\n\n${formatFound(found)}${namespaceNote(q, found)}` +
556
614
  `${gone ? `\n\n${gone}` : ""}\n\n${note}`);
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Builds docs/skillcorner/dynamic-events.md from SkillCorner's Dynamic Events
3
+ * CSV Specifications PDF, so the attribute tables stay word for word.
4
+ *
5
+ * The tables come from the PDF: rows are split at the PDF's drawn row borders
6
+ * and cells at its column headers. The intro and the framing line are ours and
7
+ * live here. The changelog is copied from PDF pages 2-3 and lives here too;
8
+ * the script fails if its words differ from those pages.
9
+ *
10
+ * Maintainer-only; needs the network unless --pdf is given, so it is not run
11
+ * in CI. `pnpm check:upstream` reports when the PDF's hash changes.
12
+ *
13
+ * Usage:
14
+ * pnpm skillcorner:spec # download the PDF, write the page
15
+ * pnpm skillcorner:spec --check # diff only; exit 1 if the page differs
16
+ * pnpm skillcorner:spec --pdf spec.pdf # use a local copy
17
+ */
18
+ export declare const SPEC_URL = "https://26560301.fs1.hubspotusercontent-eu1.net/hubfs/26560301/Guides/Dynamic%20Events/20250216%20-%20Dynamic%20Events%20CSV%20Specifications.pdf";
19
+ /** SHA-256 of the PDF the page was built from. check_upstream.py reads this line. */
20
+ export declare const SPEC_SHA256 = "1b737ffc6882eca1501b6fefab69893fddb8703a8411034256d682453739699a";
21
+ type Row = {
22
+ attr: string;
23
+ type: string;
24
+ desc: string[];
25
+ vals: string[];
26
+ ticks: string[];
27
+ };
28
+ type Section = {
29
+ title: string;
30
+ intro: ({
31
+ heading: string;
32
+ } | {
33
+ text: string;
34
+ })[];
35
+ rows: Row[];
36
+ };
37
+ /** The attribute tables of the PDF, one section per theme. */
38
+ export declare function extractSections(data: Uint8Array): Promise<{
39
+ sections: Section[];
40
+ pages: string[];
41
+ }>;
42
+ export declare function renderPage(sections: Section[]): string;
43
+ /** Words of the changelog as the PDF prints them, from pages 2-3. */
44
+ export declare function changelogWordsDiffer(pages: string[]): string | null;
45
+ export {};