football-docs 0.16.0 → 0.16.2

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.
package/README.md CHANGED
@@ -276,10 +276,10 @@ As environment variables in the server's MCP configuration:
276
276
  | Transfermarkt | 5 | identity-surfaces, data-provenance |
277
277
  | STATSports | 70 | api-access, api-endpoints, data-model, drill-kpi-metrics (all 319 DrillKpiV7 fields), identity-surfaces, data-provenance |
278
278
  | Firstbeat | 79 | api-access, api-endpoints, data-model, variables (100 scalars, 17 time series), identity-surfaces, data-provenance |
279
- | Hawkin Dynamics | 67 | api-access, api-endpoints, data-model, test-metrics (535 metrics across 13 test types), identity-surfaces, data-provenance |
279
+ | Hawkin Dynamics | 69 | api-access, api-endpoints, data-model, test-metrics (535 metrics across 13 test types), identity-surfaces, data-provenance |
280
280
  | VALD | 318 | api-access, api-endpoints, per-product endpoints and schemas (tenants, profiles, forcedecks, nordbord, forceframe, smartspeed, dynamo, humantrak), identity-surfaces, data-provenance |
281
281
 
282
- **3,394 searchable chunks** across 30 providers and tools.
282
+ **3,396 searchable chunks** across 30 providers and tools.
283
283
 
284
284
  STATSports, Firstbeat, Hawkin Dynamics and VALD sell wearables and testing devices.
285
285
  Their APIs return a customer's own athlete data, which includes personal and health
@@ -463,6 +463,13 @@ git tag -a v0.11.0 -m "v0.11.0"
463
463
  git push origin v0.11.0
464
464
  ```
465
465
 
466
+ 3. The release job attaches `site-stats.json` (version, chunk and provider counts,
467
+ tools, per-provider chunks; `pnpm site:stats` prints the same) to the GitHub
468
+ Release. In nutmeg-site, `pnpm football-docs:release` reads it from the latest
469
+ release, rebuilds the football-docs section and saves the announcement card as
470
+ `cards/football-docs-v<version>.png`. Update its "What's new" text, then
471
+ `pnpm deploy` there.
472
+
466
473
  Release notes come from the body of the `chore: release vX.Y.Z` commit, so write
467
474
  that message as the release notes you want readers to see. The workflow reads it
468
475
  from the second parent when the tag sits on a merge commit, strips the commit
package/data/docs.db CHANGED
Binary file
@@ -15,6 +15,13 @@ import { type Env, FetchError, type PaperContext } from "./core.js";
15
15
  import type { PaperRecord } from "./records.js";
16
16
  import { type Section } from "./text.js";
17
17
  export declare const FORMAT = "football-docs/paper-text/v1";
18
+ /**
19
+ * The version of the text extraction. Raise it when extraction changes in a
20
+ * way that makes stored text wrong; open copies saved under an older version
21
+ * are then fetched again. (2: MathML formulas kept once, not twice.) Papers
22
+ * the user supplied are kept, since only they can supply them again.
23
+ */
24
+ export declare const TEXT_VERSION = 2;
18
25
  export type Access = "open" | "user";
19
26
  export type StoredPaper = {
20
27
  format: typeof FORMAT;
@@ -31,6 +38,8 @@ export type StoredPaper = {
31
38
  zotero?: string;
32
39
  sha256?: string;
33
40
  savedAt: string;
41
+ /** TEXT_VERSION when saved; absent on entries saved before versions existed. */
42
+ textVersion?: number;
34
43
  sections: Section[];
35
44
  };
36
45
  /** Passage length for user papers: FOOTBALL_DOCS_PAPERS_PASSAGE_CHARS, 50 to 1000, default 200. */
@@ -19,6 +19,13 @@ import { fileURLToPath } from "node:url";
19
19
  import { apiKey, FetchError, readCacheJson, readCapped, reason, USER_AGENT, writeCacheJson } from "./core.js";
20
20
  import { isPdf, pdfSections, readPdf, splitSections } from "./text.js";
21
21
  export const FORMAT = "football-docs/paper-text/v1";
22
+ /**
23
+ * The version of the text extraction. Raise it when extraction changes in a
24
+ * way that makes stored text wrong; open copies saved under an older version
25
+ * are then fetched again. (2: MathML formulas kept once, not twice.) Papers
26
+ * the user supplied are kept, since only they can supply them again.
27
+ */
28
+ export const TEXT_VERSION = 2;
22
29
  const TEXT_DIR = "text";
23
30
  const INDEX_FILE = "library.json";
24
31
  const MAX_LOCAL_PDF_BYTES = 100 * 1024 * 1024;
@@ -62,19 +69,29 @@ export function canonicalKey(key) {
62
69
  }
63
70
  export function saveEntry(ctx, entry) {
64
71
  const file = fileFor(entry.key);
65
- writeCacheJson(textDir(ctx), file, entry);
72
+ writeCacheJson(textDir(ctx), file, { ...entry, textVersion: TEXT_VERSION });
66
73
  const index = readIndex(ctx);
67
74
  for (const alias of aliasesOf(entry))
68
75
  index.aliases[canonicalKey(alias)] = file;
69
76
  writeCacheJson(ctx.cacheDir, INDEX_FILE, index);
70
77
  }
71
- export function loadEntry(ctx, key) {
78
+ /** The entry filed under a key, whatever its text version. */
79
+ function loadAnyEntry(ctx, key) {
72
80
  const file = readIndex(ctx).aliases[canonicalKey(key)];
73
81
  if (!file)
74
82
  return null;
75
83
  const entry = readCacheJson(textDir(ctx), file);
76
84
  return entry?.format === FORMAT ? entry : null;
77
85
  }
86
+ export function loadEntry(ctx, key) {
87
+ const entry = loadAnyEntry(ctx, key);
88
+ if (!entry)
89
+ return null;
90
+ // An open copy read by an older extractor is read again.
91
+ if (entry.access === "open" && (entry.textVersion ?? 1) < TEXT_VERSION)
92
+ return null;
93
+ return entry;
94
+ }
78
95
  /** User papers whose metadata names this DOI. */
79
96
  export function userEntriesFor(ctx, doi) {
80
97
  const dir = textDir(ctx);
@@ -96,7 +113,7 @@ export function listEntries(ctx) {
96
113
  }
97
114
  /** Remove one entry and its aliases. Returns the removed entry, if any. */
98
115
  export function forgetEntry(ctx, key) {
99
- const entry = loadEntry(ctx, key);
116
+ const entry = loadAnyEntry(ctx, key);
100
117
  if (!entry)
101
118
  return null;
102
119
  const file = fileFor(entry.key);
@@ -12,6 +12,7 @@
12
12
  * - It does not ask the Wayback Machine to save a page; it only reads what is
13
13
  * there and gives the save link.
14
14
  */
15
+ import { parseHTML } from "linkedom";
15
16
  import { type PaperContext, type ServiceLog } from "./core.js";
16
17
  import { type Section } from "./text.js";
17
18
  export type Lookup = (host: string) => Promise<string[]>;
@@ -39,6 +40,7 @@ export type Snapshots = {
39
40
  export declare function snapshotDate(timestamp: string): string;
40
41
  /** The earliest and latest Wayback snapshots of a URL. */
41
42
  export declare function waybackSnapshots(ctx: PaperContext, url: string): Promise<Snapshots>;
43
+ type Doc = ReturnType<typeof parseHTML>["document"];
42
44
  export type WebPage = {
43
45
  title?: string;
44
46
  author?: string;
@@ -51,6 +53,15 @@ export type WebPage = {
51
53
  sections: Section[];
52
54
  text: string;
53
55
  };
56
+ /**
57
+ * Replace each MathML formula with one text form. LaTeXML pages (arXiv HTML)
58
+ * carry every formula twice, as rendered MathML and as a LaTeX annotation, so
59
+ * their text read "13×1013\times 10" and a quote with maths in it could not
60
+ * match. A simple formula becomes its rendered text ("13×10", "M=192"), which
61
+ * is what a reader quotes; one with subscripts, fractions and the like
62
+ * becomes its LaTeX source as inline code, which keeps its structure.
63
+ */
64
+ export declare function flattenMath(document: Doc): void;
54
65
  export declare function extractPage(html: string, pageUrl: string): WebPage;
55
66
  /** The text of a fetched HTML page, PDF or plain-text file. */
56
67
  export declare function pageText(page: FetchedPage): Promise<WebPage & {
@@ -83,3 +94,4 @@ export type WebSourceResult = {
83
94
  isError?: boolean;
84
95
  };
85
96
  export declare function readWebSource(ctx: PaperContext, args: WebSourceArgs, log: ServiceLog, lookup?: Lookup): Promise<WebSourceResult>;
97
+ export {};
@@ -233,9 +233,39 @@ function licenceLink(document) {
233
233
  const cc = Array.from(document.querySelectorAll("a[href*='creativecommons.org/licenses/'], a[href*='creativecommons.org/publicdomain/']"))[0];
234
234
  return cc?.getAttribute("href") ?? undefined;
235
235
  }
236
+ /** MathML elements that give a formula structure plain text cannot show. */
237
+ const STRUCTURED_MATH = "msub, msup, msubsup, mfrac, msqrt, mroot, munder, mover, munderover, mtable, mmultiscripts";
238
+ /**
239
+ * Replace each MathML formula with one text form. LaTeXML pages (arXiv HTML)
240
+ * carry every formula twice, as rendered MathML and as a LaTeX annotation, so
241
+ * their text read "13×1013\times 10" and a quote with maths in it could not
242
+ * match. A simple formula becomes its rendered text ("13×10", "M=192"), which
243
+ * is what a reader quotes; one with subscripts, fractions and the like
244
+ * becomes its LaTeX source as inline code, which keeps its structure.
245
+ */
246
+ export function flattenMath(document) {
247
+ for (const math of Array.from(document.querySelectorAll("math"))) {
248
+ const latex = (math.querySelector('annotation[encoding="application/x-tex"]')?.textContent ??
249
+ math.getAttribute("alttext") ??
250
+ "").trim();
251
+ for (const annotation of Array.from(math.querySelectorAll("annotation, annotation-xml")))
252
+ annotation.remove();
253
+ const rendered = (math.textContent ?? "").replace(/\s+/g, "");
254
+ const structured = latex && math.querySelector(STRUCTURED_MATH);
255
+ if (structured || !rendered) {
256
+ const code = document.createElement("code");
257
+ code.textContent = latex || rendered;
258
+ math.replaceWith(code);
259
+ }
260
+ else {
261
+ math.replaceWith(document.createTextNode(rendered));
262
+ }
263
+ }
264
+ }
236
265
  export function extractPage(html, pageUrl) {
237
266
  const withBase = html.includes("<base ") ? html : html.replace(/(<head[^>]*>)/i, `$1<base href="${pageUrl}">`);
238
267
  const { document } = parseHTML(withBase);
268
+ flattenMath(document);
239
269
  const facts = {
240
270
  title: meta(document, "og:title", "twitter:title", "citation_title") ?? plainText(document.querySelector("title")?.textContent),
241
271
  author: meta(document, "citation_author", "author", "article:author") ?? jsonLdField(document, "author"),
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  source_type: curated
3
3
  source_url: https://connect.hawkindynamics.com/api
4
- upstream_version: Hawkin Force Platform API 1.15 (OpenAPI 3.0.3)
4
+ upstream_version: Hawkin Force Platform API 1.16 (OpenAPI 3.0.3)
5
5
  crawled_at: 2026-09-30
6
6
  ---
7
7
 
@@ -11,7 +11,7 @@ crawled_at: 2026-09-30
11
11
 
12
12
  Hawkin Dynamics makes force plates. The Hawkin Force Platform API returns an
13
13
  organisation's own test results (jumps, isometric tests and others), force-time
14
- data and athlete records. The reference page labels it "Beta API · v1.15".
14
+ data and athlete records. The reference page labels it "Beta API · v1.16".
15
15
 
16
16
  - Reference page: https://connect.hawkindynamics.com/api
17
17
  - OpenAPI 3.0.3 document: inline on the reference page (its "Download OpenAPI Spec"
@@ -91,10 +91,11 @@ From the spec's description and the `GET /api/v1` parameters:
91
91
 
92
92
  ## Version history
93
93
 
94
- The reference page's changelog, checked 2026-09-30:
94
+ The reference page's changelog, checked 2026-10-01:
95
95
 
96
96
  | Date | Version | Change, as the page states it |
97
97
  |---|---|---|
98
+ | Sep 2026 | v1.16 | Response-shape query params on Get Tests: `useNulls` (default `true`; `false` returns the string `"N/A"` instead of `null` for non-calculable metrics), `rounding` (default `false`) and `nestMetrics` (default `false`; metrics as a `metrics` array, see `TestNested`). For customers migrating from a legacy named endpoint; new integrations should leave the defaults |
98
99
  | Jul 2026 | v1.15 | New `GET /api/v1/cop/{test_id}`; force-time shear forces, moments and `eid`; `rsi` is an array; `timestamp` is an integer; non-calculable metrics are `null`, not `"N/A"`; tests include `active`; metrics use `testTypeName`; test types return a bare array; teams, groups and tags include `count`; team-scoped token behaviour documented |
99
100
  | May 2026 | v1.14 | Athlete profile fields `image`, `position`, `dob`, `sport`, `height`, `lastTestedOn`; `includeInactive` on athletes documented |
100
101
  | Apr 2026 | v1.13 | `includeInactive` and cursor pagination (`paginate`, `cursor`) on Get Tests |
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  source_type: curated
3
3
  source_url: https://connect.hawkindynamics.com/api
4
- upstream_version: Hawkin Force Platform API 1.15 (OpenAPI 3.0.3)
4
+ upstream_version: Hawkin Force Platform API 1.16 (OpenAPI 3.0.3)
5
5
  crawled_at: 2026-09-30
6
6
  ---
7
7
 
@@ -10,7 +10,7 @@ crawled_at: 2026-09-30
10
10
  ## Endpoint inventory
11
11
 
12
12
  All 14 operations in the Hawkin Force Platform API spec
13
- (`info.version` "1.15"), from the OpenAPI document published inline on
13
+ (`info.version` "1.16"), from the OpenAPI document published inline on
14
14
  https://connect.hawkindynamics.com/api. Paths are relative to the regional base URL
15
15
  (see Hawkin Dynamics API access), for example
16
16
  `https://cloud.hawkindynamics.com/api/v1/athletes`.
@@ -62,6 +62,9 @@ Parameters:
62
62
  - `groupId` (query, string) — Filter by one or more group IDs (comma-separated, max 10). Can only be used with `from`/`to` parameters.
63
63
  - `testTypeId` (query, string) — Filter by a specific test type ID. Can only be used with `from`/`to` parameters.
64
64
  - `includeInactive` (query, boolean) default `true` — Default true. Set to false to return only active tests.
65
+ - `useNulls` (query, boolean) default `true` — Default true. Non-calculable metric values are returned as `null`. Set to false to receive the string `"N/A"` instead. Intended for customers migrating from a legacy named endpoint that returned `"N/A"`; new integrations should leave the default. Omit to keep the default; any value other than `true` is treated as false.
66
+ - `rounding` (query, boolean) default `false` — Default false. Set to true to round each metric value to its standard display precision. Has no effect when `nestMetrics=true` (nested metric values are never rounded). Intended for customers migrating from a legacy named endpoint that returned rounded values; new integrations should leave the default. Omit to keep the default; any value other than `true` is treated as false.
67
+ - `nestMetrics` (query, boolean) default `false` — Default false. Set to true to return each test's metrics as a `metrics` array of `{metricId, metricLabel, metricUnits, metricValue}` objects (see the `TestNested` schema) instead of flat metric-name keys. Only metrics with a numeric value are included. Intended for customers migrating from a legacy named endpoint that returned nested metrics; new integrations should leave the default. Omit to keep the default; any value other than `true` is treated as false.
65
68
  - `includeEid` (query, boolean) default `false` — Default false. Set to true to include the hardware `eid` (equipment ID) on each returned test record.
66
69
  - `paginate` (query, boolean) — Set to true to enable paginated responses (1,000 tests per page).
67
70
  - `cursor` (query, string) — Firestore document ID from previous response's nextCursor. Omit on first request.
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  source_type: curated
3
3
  source_url: https://connect.hawkindynamics.com/api
4
- upstream_version: Hawkin Force Platform API 1.15 (OpenAPI 3.0.3)
4
+ upstream_version: Hawkin Force Platform API 1.16 (OpenAPI 3.0.3)
5
5
  crawled_at: 2026-09-30
6
6
  ---
7
7
 
@@ -68,7 +68,7 @@ marked **Personal data** hold data about an identifiable athlete. On `Athlete`,
68
68
  | `active` | `boolean` | | | | Whether the test is active (not archived). Included by default because the public endpoint uses includeInactive=true; set includeInactive=false to return only active tests. |
69
69
  <!-- generated:hawkin-schema-test end -->
70
70
 
71
- Besides the fields above, a `Test` has `additionalProperties` of type `number`, nullable, described as: "Metric values keyed by metric name (e.g. 'Jump Height(m)'). Non-calculable metrics are returned as null (the public endpoint uses useNulls=true), not the string 'N/A'."
71
+ Besides the fields above, a `Test` has `additionalProperties` of type `number`, nullable, described as: "Metric values keyed by metric name (e.g. 'Jump Height(m)'). Non-calculable metrics are returned as null by default (useNulls=true); with useNulls=false they are the string 'N/A'. Values are unrounded unless rounding=true. Omitted entirely when nestMetrics=true (see TestNested)."
72
72
 
73
73
  The reference page's Metrics section says something different: "The id shown for each metric is the property name you'll see in API responses". The metric `id` values are camelCase (for example `jumpHeight`), while the spec's example key is `Jump Height(m)`, which is the metric's `label` followed by its `units` in brackets. The two statements disagree; check a live response before relying on either.
74
74
 
@@ -77,7 +77,7 @@ The reference page's Metrics section says something different: "The id shown for
77
77
  <!-- generated:hawkin-schema-testsresponse start -->
78
78
  | Field | Type | Format | Nullable | Required | Description |
79
79
  |---|---|---|---|---|---|
80
- | `data` | array of `Test` | | | | |
80
+ | `data` | array of `Test` | | | | Test records. Each item is a Test, or a TestNested when the request was made with nestMetrics=true. |
81
81
  | `count` | `integer` | | | | |
82
82
  | `lastTestTime` | `integer` | | | | Unix timestamp of the most recent test |
83
83
  | `lastSyncTime` | `integer` | | | | Unix timestamp to use as syncFrom in your next request |
@@ -85,6 +85,37 @@ The reference page's Metrics section says something different: "The id shown for
85
85
  | `nextCursor` | `string` | | yes | | Cursor for next page. Null on last page. Only present when paginate=true. |
86
86
  <!-- generated:hawkin-schema-testsresponse end -->
87
87
 
88
+ ## `TestNested`
89
+
90
+ Shape of each test when the request was made with nestMetrics=true. Metadata fields match Test; metrics move into a `metrics` array and are never rounded.
91
+
92
+ <!-- generated:hawkin-schema-testnested start -->
93
+ | Field | Type | Format | Nullable | Required | Description |
94
+ |---|---|---|---|---|---|
95
+ | `id` | `string` | | | | |
96
+ | `testType` | `TestType` | | | | |
97
+ | `athlete` | `AthleteRef` | | | | |
98
+ | `timestamp` | `integer` | | | | Unix timestamp of the test |
99
+ | `segment` | `string` | | | | Test type and trial number within session |
100
+ | `active` | `boolean` | | | | Whether the test is active (not archived). Present when includeInactive=true (the default). |
101
+ | `metrics` | array of `NestedMetric` | | | | |
102
+ <!-- generated:hawkin-schema-testnested end -->
103
+
104
+ ## `NestedMetric`
105
+
106
+ One metric on a test when the request was made with nestMetrics=true. Only metrics with a numeric value are included (from the `nestMetrics` parameter's description).
107
+
108
+ <!-- generated:hawkin-schema-nestedmetric start -->
109
+ | Field | Type | Format | Nullable | Required | Description |
110
+ |---|---|---|---|---|---|
111
+ | `metricId` | `string` | | | | Stable metric ID |
112
+ | `metricLabel` | `string` | | | | Metric label |
113
+ | `metricUnits` | `string` | | | | Units, may be empty |
114
+ | `metricValue` | `number` | | | | Unrounded metric value |
115
+ <!-- generated:hawkin-schema-nestedmetric end -->
116
+
117
+ In this shape each metric carries its `metricId` (for example `jumpHeight`), its `metricLabel` and its `metricUnits` as separate fields, rather than a single `Jump Height(m)` style key.
118
+
88
119
  ## `Athlete`
89
120
 
90
121
  <!-- generated:hawkin-schema-athlete start -->
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  source_type: curated
3
3
  source_url: https://connect.hawkindynamics.com/api
4
- upstream_version: Hawkin Force Platform API 1.15 (OpenAPI 3.0.3)
4
+ upstream_version: Hawkin Force Platform API 1.16 (OpenAPI 3.0.3)
5
5
  crawled_at: 2026-09-30
6
6
  ---
7
7
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "football-docs",
3
- "version": "0.16.0",
3
+ "version": "0.16.2",
4
4
  "description": "Searchable football data provider documentation for AI coding agents. Like Context7 for football data.",
5
5
  "type": "module",
6
6
  "packageManager": "pnpm@10.34.4",
@@ -21,6 +21,7 @@
21
21
  "discover": "tsx src/crawl.ts --discover",
22
22
  "impect:truth": "tsx src/impect-truth.ts",
23
23
  "statsbomb:truth": "tsx src/statsbomb-truth.ts",
24
+ "site:stats": "tsx scripts/site-stats.ts",
24
25
  "lint": "biome check src/",
25
26
  "lint:fix": "biome check --write src/",
26
27
  "prepublishOnly": "pnpm build && pnpm ingest",