@hadoku/prefs-client 1.2.2 → 1.2.3

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/dist/games.d.ts CHANGED
@@ -163,10 +163,16 @@ interface StatsFilter {
163
163
  /** Only the matches whose scalar match attr is one of the values: `{ format: ['standard', 'modern'] }`. */
164
164
  match?: Readonly<Record<string, readonly string[]>>;
165
165
  }
166
+ /**
167
+ * One rating pool, or several: a read given several spans any of them, and a
168
+ * profile answers one `ratings` row per pool the player has. Needs a prefs-api
169
+ * (or game-stats) that reads `mode` repeated; one older answers the first only.
170
+ */
171
+ type ModeScope = string | readonly string[];
166
172
  /** `player` is a registry name; omit it for the caller. */
167
173
  interface PlayerScope extends StatsFilter {
168
174
  player?: string;
169
- mode?: string;
175
+ mode?: ModeScope;
170
176
  }
171
177
  declare function createGameStatsClient(opts: GameStatsClientOptions): {
172
178
  profile: (s?: PlayerScope) => Promise<ProfileView>;
@@ -175,9 +181,10 @@ declare function createGameStatsClient(opts: GameStatsClientOptions): {
175
181
  before?: number;
176
182
  }) => Promise<MatchPage>;
177
183
  match: (matchId: string) => Promise<MatchView>;
184
+ /** The rating board is one pool; an outcome board (`games`, `wins`, …) may span several. */
178
185
  leaderboard: (s?: {
179
186
  by?: LeaderboardBy;
180
- mode?: string;
187
+ mode?: ModeScope;
181
188
  limit?: number;
182
189
  }) => Promise<{
183
190
  by: LeaderboardBy;
@@ -202,4 +209,4 @@ interface RecordMatchOptions extends GameStatsClientOptions {
202
209
  /** Server-side: report one finished match. Safe to retry with the same matchId. */
203
210
  declare function recordMatch(opts: RecordMatchOptions, report: MatchReport): Promise<RecordMatchResult>;
204
211
 
205
- export { type BreakdownRow, type CounterTotals, DEFAULT_MODE, GAME_ID_PATTERN, type GameStatsClient, type GameStatsClientOptions, GameStatsError, type LeaderboardBy, type LeaderboardRow, MATCH_ID_PATTERN, type MatchPage, type MatchReport, type MatchSeatReport, type MatchView, type OutcomeTotals, type PlayerScope, type ProfileView, type RecordMatchOptions, type RecordMatchResult, STARTING_RATING, STAT_KEY_PATTERN, STAT_LIMITS, type SeatKind, type SeatOutcome, type SeatView, type StatAttr, type StatAttrs, type StatCounters, type StatsFilter, createGameStatsClient, outcomesFor, recordMatch, winRate };
212
+ export { type BreakdownRow, type CounterTotals, DEFAULT_MODE, GAME_ID_PATTERN, type GameStatsClient, type GameStatsClientOptions, GameStatsError, type LeaderboardBy, type LeaderboardRow, MATCH_ID_PATTERN, type MatchPage, type MatchReport, type MatchSeatReport, type MatchView, type ModeScope, type OutcomeTotals, type PlayerScope, type ProfileView, type RecordMatchOptions, type RecordMatchResult, STARTING_RATING, STAT_KEY_PATTERN, STAT_LIMITS, type SeatKind, type SeatOutcome, type SeatView, type StatAttr, type StatAttrs, type StatCounters, type StatsFilter, createGameStatsClient, outcomesFor, recordMatch, winRate };
package/dist/games.js CHANGED
@@ -49,7 +49,8 @@ function query({
49
49
  const q = new URLSearchParams();
50
50
  for (const [k, v] of Object.entries(params)) {
51
51
  if (v === void 0 || v === false) continue;
52
- q.set(k, v === true ? "1" : String(v));
52
+ if (typeof v === "object") for (const each of v) q.append(k, each);
53
+ else q.set(k, v === true ? "1" : String(v));
53
54
  }
54
55
  for (const [k, values] of Object.entries(match ?? {})) {
55
56
  for (const v of values) q.append(`match.${k}`, v);
@@ -65,6 +66,7 @@ function createGameStatsClient(opts) {
65
66
  profile: (s = {}) => get(`/profile${query({ ...s })}`),
66
67
  matches: (s = {}) => get(`/matches${query({ ...s })}`),
67
68
  match: (matchId) => get(`/matches/${encodeURIComponent(matchId)}`),
69
+ /** The rating board is one pool; an outcome board (`games`, `wins`, …) may span several. */
68
70
  leaderboard: (s = {}) => get(`/leaderboard${query({ ...s })}`),
69
71
  /**
70
72
  * Outcome totals grouped by one attr. `player: '*'` spans everyone.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hadoku/prefs-client",
3
- "version": "1.2.2",
4
- "gitHead": "61667d5e696acc4d7e4b1869e35c3d42638ea96b",
3
+ "version": "1.2.3",
4
+ "gitHead": "755e0d4de5670334fb73f8cbbc3f0a07f1907614",
5
5
  "description": "Client SDK for the hadoku unified preferences store. Wraps /prefs/api/v1/* with localStorage caching, debounced writes, Zod-validated reads, and a usePrefs() React hook, plus match history, ratings and leaderboards for every game (./games), the one resolved avatar per user (./avatar), and the avatar cosmetics renderer (./cosmetics), and room history (./rooms).",
6
6
  "type": "module",
7
7
  "main": "./dist/index.js",