@wral/hsot-data 0.1.15 → 0.3.0

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
@@ -14,6 +14,7 @@ exactly one of these elements.
14
14
  | `<hsot-rankings>` | The weekly Top 25 with movement + rank history | `sport`, `gender` (poll family), `season`, deep link `?poll=YYYY-MM-DD` |
15
15
  | `<hsot-school>` | School hub: hero, team tabs, schedule, roster (headed by the season's roster photo when one is set; positions render as a list, "WR/CB"; a College column appears when a player carries a commitment), honors | `school-id`, `sport` (initial tab, deep link `?sport=`), `season` |
16
16
  | `<hsot-boxscore>` | Game detail: line score (stored `periodScores`, or derived from the scoring plays when nothing wrote one — `src/lib/line-score.mjs`, shown only when it reconciles with the score), the desk's scoring-play log when a game carries one (period, clock, play, running score), coverage, season context; game notes keep their line breaks | `game-id`, `refresh-interval` |
17
+ | `<hsot-brackets>` | Playoff brackets: a sport's tournaments for the season, rounds as columns laid out from the winner edges (seedings place round one; `GET /tournaments/{id}/edges` is the tree), group tabs for split brackets (East / West / Championship), scores and the champion once played | `sport`, `season`, `tournament-id` (pin one; otherwise `?tournament=` or the bracket in play), `refresh-interval` |
17
18
  | `<hsot-school-search>` | "Find Your School" typeahead for the right rail (standalone: fetches `GET /schools?q=` itself, no injected client) | `api`, `school-href`, `limit`, `placeholder` |
18
19
 
19
20
  The live status pill on every component reads the game clock beside the
@@ -31,8 +32,10 @@ Shared attributes on every data component (`hsot-school-search` takes only
31
32
  Alternatively set the `.client` **property** to any object with the client
32
33
  method surface (see `src/lib/client.mjs`) — the demo client, a test double,
33
34
  or the future `@wral/sdk-hsot`. The property wins over the attribute.
34
- - `game-href`, `school-href`, `section-href` — link templates with `{sport}`,
35
- `{id}` and `{view}` tokens for cross-page links. Defaults follow the
35
+ - `game-href`, `school-href`, `section-href`, `report-href` — link templates
36
+ with `{sport}`, `{id}` and `{view}` tokens for cross-page links
37
+ (`report-href` is the "Report a Score" page, default
38
+ `/report-a-score/?game={id}`). Defaults follow the
36
39
  sport-first hierarchy: `/{sport}/game/{id}/`, `/school/{id}/`,
37
40
  `/{sport}/{view}/`. The site's URL space belongs to Studio publications, so
38
41
  these are overridable per mount.
@@ -87,6 +90,16 @@ so the components never know what lives there:
87
90
 
88
91
  Without slotted rail content the view renders full width, unchanged.
89
92
 
93
+ ## Reporting a score
94
+
95
+ The "Report a Score" page is its own package,
96
+ [web-components.hsot-score-report](https://bitbucket.org/cbcnm/web-components.hsot-score-report)
97
+ (`<hsot-score-report>`), with no dependency on this one. These components
98
+ only link to it: `hsot-boxscore` renders "Report a score for this game" and
99
+ `hsot-scores` renders "report a score" in its toolbar, both from the
100
+ `report-href` template (default `/report-a-score/?game={id}`; `reportHref()`
101
+ in `src/lib/hrefs.mjs` drops the parameter when there is no game).
102
+
90
103
  ## Derivation lives here, for now
91
104
 
92
105
  Standings, records, streaks and rank badges are **derived client-side** from
@@ -0,0 +1,49 @@
1
+ function m(l = {}) {
2
+ const i = Object.entries(l).filter(([, r]) => r != null && r !== "");
3
+ if (!i.length) return "";
4
+ const c = new URLSearchParams();
5
+ return i.forEach(([r, u]) => c.set(r, String(u))), `?${c.toString()}`;
6
+ }
7
+ function $({ baseUrl: l, token: i = "", fetchFn: c } = {}) {
8
+ if (!l) throw new Error("createClient requires a baseUrl");
9
+ const r = l.replace(/\/+$/, ""), u = c || ((...t) => fetch(...t));
10
+ async function a(t) {
11
+ const s = { Accept: "application/json" };
12
+ i && (s.Authorization = `Bearer ${i}`);
13
+ const n = await u(`${r}${t}`, { headers: s });
14
+ if (!n.ok) {
15
+ const o = new Error(`api-hsot ${n.status} on ${t}`);
16
+ throw o.status = n.status, o;
17
+ }
18
+ return n.json();
19
+ }
20
+ async function e(t, s = {}) {
21
+ const n = [];
22
+ let o = null;
23
+ for (let f = 0; f < 50; f += 1) {
24
+ const h = m(o ? { ...s, cursor: o } : s), g = await a(`${t}${h}`);
25
+ if (n.push(...g.items || []), o = g.nextCursor || null, !o) break;
26
+ }
27
+ return { items: n, total: n.length, nextCursor: null };
28
+ }
29
+ return {
30
+ listSchools: (t) => e("/schools", t),
31
+ getSchool: (t) => a(`/schools/${t}`),
32
+ listTeams: (t) => e("/teams", t),
33
+ getTeam: (t) => a(`/teams/${t}`),
34
+ listConferences: (t) => e("/conferences", t),
35
+ listPlayers: (t) => e("/players", t),
36
+ listRosters: (t) => e("/rosters", t),
37
+ listGames: (t) => e("/games", t),
38
+ getGame: (t) => a(`/games/${t}`),
39
+ listTournaments: (t) => e("/tournaments", t),
40
+ listSeedings: (t, s) => e(`/tournaments/${t}/seedings`, s),
41
+ listEdges: (t, s) => e(`/tournaments/${t}/edges`, s),
42
+ listRankings: (t) => e("/rankings", t),
43
+ listSports: () => a("/sports")
44
+ };
45
+ }
46
+ export {
47
+ $ as createClient,
48
+ $ as default
49
+ };
package/dist/define.mjs CHANGED
@@ -1,19 +1,20 @@
1
- import { c as e, H as n, b as c, a, e as i, d as h } from "./hsot-school-search-CPsDpIgS.js";
2
- const r = {
1
+ import { a as e, d as c, H as n, c as a, b as i, f as r, e as h } from "./hsot-brackets-Cc0zj07F.js";
2
+ const l = {
3
3
  "hsot-scores": h,
4
- "hsot-standings": i,
5
- "hsot-rankings": a,
6
- "hsot-school": c,
4
+ "hsot-standings": r,
5
+ "hsot-rankings": i,
6
+ "hsot-school": a,
7
7
  "hsot-boxscore": n,
8
- "hsot-school-search": e
8
+ "hsot-school-search": c,
9
+ "hsot-brackets": e
9
10
  };
10
- function l() {
11
+ function f() {
11
12
  const s = globalThis?.customElements;
12
13
  if (s)
13
- for (const [o, t] of Object.entries(r))
14
+ for (const [o, t] of Object.entries(l))
14
15
  s.get(o) || s.define(o, t);
15
16
  }
16
- typeof window < "u" && globalThis.customElements && l();
17
+ typeof window < "u" && globalThis.customElements && f();
17
18
  export {
18
- l as defineAll
19
+ f as defineAll
19
20
  };