@wral/hsot-data 0.2.0 → 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 +14 -2
- package/dist/client.mjs +49 -0
- package/dist/define.mjs +1 -1
- package/dist/define.standalone.js +536 -508
- package/dist/{hsot-brackets-D5cwGage.js → hsot-brackets-Cc0zj07F.js} +537 -555
- package/dist/index.mjs +16 -15
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -32,8 +32,10 @@ Shared attributes on every data component (`hsot-school-search` takes only
|
|
|
32
32
|
Alternatively set the `.client` **property** to any object with the client
|
|
33
33
|
method surface (see `src/lib/client.mjs`) — the demo client, a test double,
|
|
34
34
|
or the future `@wral/sdk-hsot`. The property wins over the attribute.
|
|
35
|
-
- `game-href`, `school-href`, `section-href` — link templates
|
|
36
|
-
`{id}` and `{view}` tokens for cross-page links
|
|
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
|
|
37
39
|
sport-first hierarchy: `/{sport}/game/{id}/`, `/school/{id}/`,
|
|
38
40
|
`/{sport}/{view}/`. The site's URL space belongs to Studio publications, so
|
|
39
41
|
these are overridable per mount.
|
|
@@ -88,6 +90,16 @@ so the components never know what lives there:
|
|
|
88
90
|
|
|
89
91
|
Without slotted rail content the view renders full width, unchanged.
|
|
90
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
|
+
|
|
91
103
|
## Derivation lives here, for now
|
|
92
104
|
|
|
93
105
|
Standings, records, streaks and rank badges are **derived client-side** from
|
package/dist/client.mjs
ADDED
|
@@ -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