@smartico/public-api 0.0.387 → 0.0.389

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
@@ -76,7 +76,7 @@ The SDK surface is split across one class per feature area, joined by an interna
76
76
  | **MiniGames / SAW** | [`WSAPIMiniGames`](docs/api/classes/WSAPIMiniGames.md) | `getMiniGames`, `getMiniGamesHistory`, `playMiniGame`, `miniGameWinAcknowledgeRequest`, `playMiniGameBatch` | [`getMiniGames`](docs/ui/minigames/UIGuide_getMiniGames.md) · [`getMiniGamesHistory`](docs/ui/minigames/UIGuide_getMiniGamesHistory.md) · [`playMiniGame`](docs/ui/minigames/UIGuide_playMiniGame.md) · [`playMiniGameBatch`](docs/ui/minigames/UIGuide_playMiniGameBatch.md) |
77
77
  | **Avatars** | [`WSAPIAvatars`](docs/api/classes/WSAPIAvatars.md) | `getAvatarsList`, `getAvatarsCustomized`, `getAvatarPrompts`, `setAvatar`, `avatarsCustomize` | [`getAvatarsList`](docs/ui/avatars/UIGuide_getAvatarsList.md) · [`getAvatarsCustomized`](docs/ui/avatars/UIGuide_getAvatarsCustomized.md) · [`getAvatarPrompts`](docs/ui/avatars/UIGuide_getAvatarPrompts.md) · [`setAvatar`](docs/ui/avatars/UIGuide_setAvatar.md) · [`avatarsCustomize`](docs/ui/avatars/UIGuide_avatarsCustomize.md) |
78
78
  | **Game Pick (sports / quiz)** | [`WSAPIGamePick`](docs/api/classes/WSAPIGamePick.md) | `gamePickGet*`, `gamePickSubmit*` (9 methods) | [`gamePickGetActiveRounds`](docs/ui/gamepick/UIGuide_gamePickGetActiveRounds.md) · [`gamePickGetActiveRound`](docs/ui/gamepick/UIGuide_gamePickGetActiveRound.md) · [`gamePickGetHistory`](docs/ui/gamepick/UIGuide_gamePickGetHistory.md) · [`gamePickGetBoard`](docs/ui/gamepick/UIGuide_gamePickGetBoard.md) · [`gamePickSubmitSelection`](docs/ui/gamepick/UIGuide_gamePickSubmitSelection.md) · [`gamePickSubmitSelectionQuiz`](docs/ui/gamepick/UIGuide_gamePickSubmitSelectionQuiz.md) · [`gamePickGetUserInfo`](docs/ui/gamepick/UIGuide_gamePickGetUserInfo.md) · [`gamePickGetGameInfo`](docs/ui/gamepick/UIGuide_gamePickGetGameInfo.md) · [`gamePickGetRoundInfoForUser`](docs/ui/gamepick/UIGuide_gamePickGetRoundInfoForUser.md) |
79
- | **Leaderboard** | [`WSAPILeaderBoard`](docs/api/classes/WSAPILeaderBoard.md) | `getLeaderBoard` | [`getLeaderBoard`](docs/ui/leaderboard/UIGuide_getLeaderBoard.md) |
79
+ | **Leaderboard** | [`WSAPILeaderBoard`](docs/api/classes/WSAPILeaderBoard.md) | `getLeaderBoard`, `getLeaderBoards` | [`getLeaderBoard`](docs/ui/leaderboard/UIGuide_getLeaderBoard.md) |
80
80
  | **Inbox / Messages / Engagement** | [`WSAPIInbox`](docs/api/classes/WSAPIInbox.md) | `getInboxMessages`, `getInboxUnreadCount`, `getInboxMessageBody`, `markInboxMessageAsRead`, `markAllInboxMessagesAsRead`, `markUnmarkInboxMessageAsFavorite`, `deleteInboxMessage`, `deleteAllInboxMessages`, `reportImpressionEvent`, `reportClickEvent` | [`getInboxMessages`](docs/ui/inbox/UIGuide_getInboxMessages.md) · [`getInboxMessageBody`](docs/ui/inbox/UIGuide_getInboxMessageBody.md) · [`markInboxMessageAsRead`](docs/ui/inbox/UIGuide_markInboxMessageAsRead.md) · [`markUnmarkInboxMessageAsFavorite`](docs/ui/inbox/UIGuide_markUnmarkInboxMessageAsFavorite.md) · [`deleteInboxMessage`](docs/ui/inbox/UIGuide_deleteInboxMessage.md) |
81
81
 
82
82
  The shared return / param types live in [`WSAPITypes`](docs/api/classes/WSAPITypes.md). For the full type / enum / interface listing, see [`docs/api/globals.md`](docs/api/globals.md).
@@ -43,5 +43,6 @@ export declare enum LiquidEntityData {
43
43
  Badges = 9,
44
44
  Tournament = 10,
45
45
  Raffles = 11,
46
- SingleRaffle = 12
46
+ SingleRaffle = 12,
47
+ Clans = 13
47
48
  }
@@ -158,8 +158,10 @@ declare class SmarticoAPI {
158
158
  tournamentsGetInfo(user_ext_id: string, tournamentInstanceId: number, force_language?: string): Promise<GetTournamentInfoResponse>;
159
159
  tournamentsGetInfoT(user_ext_id: string, tournamentInstanceId: number): Promise<TTournamentDetailed>;
160
160
  clanTournamentGetPlayers(user_ext_id: string, tournament_instance_id: number, clan_id: number, force_language?: string): Promise<TClanTournamentPlayers>;
161
- leaderboardGet(user_ext_id: string, period_type_id?: LeaderBoardPeriodType, prevPeriod?: boolean, force_language?: string): Promise<LeaderBoardDetails>;
162
- leaderboardsGetT(user_ext_id: string, period_type_id?: LeaderBoardPeriodType, prevPeriod?: boolean): Promise<LeaderBoardDetailsT>;
161
+ leaderboardGet(user_ext_id: string, period_type_id?: LeaderBoardPeriodType, prevPeriod?: boolean | number, force_language?: string): Promise<LeaderBoardDetails>;
162
+ leaderboardsGetT(user_ext_id: string, period_type_id?: LeaderBoardPeriodType, prevPeriod?: boolean | number): Promise<LeaderBoardDetailsT>;
163
+ leaderboardsGetList(user_ext_id: string, force_language?: string): Promise<LeaderBoardDetails[]>;
164
+ leaderboardsGetListT(user_ext_id: string): Promise<LeaderBoardDetailsT[]>;
163
165
  levelsGet(user_ext_id: string, force_language?: string): Promise<GetLevelMapResponse>;
164
166
  levelsGetT(user_ext_id: string): Promise<TLevel[]>;
165
167
  getLevelCurrent(user_ext_id: string): Promise<TLevelCurrent>;
@@ -193,7 +195,6 @@ declare class SmarticoAPI {
193
195
  avatarsGetPrompts(user_ext_id: string): Promise<GetAvatarPromptsResponse>;
194
196
  avatarSetAvatar(user_ext_id: string, avatar_id: string, avatar_real_id: number): Promise<SetAvatarResponse>;
195
197
  avatarsCustomize(params: {
196
- label_id: number;
197
198
  user_id: number;
198
199
  prompt_id: number;
199
200
  avatar_url: string;
@@ -354,7 +354,6 @@ export declare class WSAPIAvatars extends WSAPIMiniGames {
354
354
  *
355
355
  * **Visitor mode**: not supported (throws).
356
356
  *
357
- * @param props.label_id Numeric Smartico label (brand) ID the user belongs to.
358
357
  * @param props.user_id Numeric Smartico user ID.
359
358
  * @param props.prompt_id Style-prompt ID (`prompt_id`) from {@link getAvatarPrompts}.
360
359
  * @param props.avatar_url CDN URL of the base avatar to customize.
@@ -364,13 +363,12 @@ export declare class WSAPIAvatars extends WSAPIMiniGames {
364
363
  *
365
364
  * @example
366
365
  * ```ts
367
- * // label_id / user_id identify the Smartico user being customized.
366
+ * // user_id identifies the Smartico user being customized.
368
367
  * const prompts = await window._smartico.api.getAvatarPrompts();
369
368
  * const prompt = prompts[0];
370
369
  *
371
370
  * console.log('[smartico] generating avatar — show a spinner for ~5-20s and disable the Generate button');
372
371
  * const result = await window._smartico.api.avatarsCustomize({
373
- * label_id,
374
372
  * user_id,
375
373
  * prompt_id: prompt.prompt_id,
376
374
  * avatar_url: baseAvatar.avatar_url,
@@ -390,7 +388,6 @@ export declare class WSAPIAvatars extends WSAPIMiniGames {
390
388
  * ```
391
389
  */
392
390
  avatarsCustomize(props: {
393
- label_id: number;
394
391
  user_id: number;
395
392
  prompt_id: number;
396
393
  avatar_url: string;
@@ -12,7 +12,9 @@ export declare class WSAPILeaderBoard extends WSAPIGamePick {
12
12
  *
13
13
  * The leaderboard for each period type is configured separately by
14
14
  * the operator. A label may have any combination of DAILY, WEEKLY,
15
- * and MONTHLY boards configured (or none).
15
+ * and MONTHLY boards configured (or none). To discover which boards
16
+ * exist before loading any standings, call {@link getLeaderBoards}
17
+ * (metadata only) and drive the tab selector from its `period_type_id`s.
16
18
  *
17
19
  * @remarks
18
20
  * **Return value note** — the runtime may return `undefined` if no
@@ -24,10 +26,13 @@ export declare class WSAPILeaderBoard extends WSAPIGamePick {
24
26
  * Pass a `periodType` from {@link LeaderBoardPeriodType}
25
27
  * (`DAILY = 1`, `WEEKLY = 2`, `MONTHLY = 3`). Pass
26
28
  * `getPreviousPeriod: true` to fetch the most-recently-ended
27
- * period's snapshot (yesterday's results, last week's results,
28
- * last month's results) instead of the current live period. The
29
- * SDK only exposes one period back — older snapshots are not
30
- * reachable through this method.
29
+ * period's snapshot (yesterday's / last week's / last month's
30
+ * results) instead of the current live period. To reach older
31
+ * snapshots, pass a number instead of a boolean: `1` = previous
32
+ * period, `2` = the one before that, and so on (`0` / `false` =
33
+ * current). Use the snapshot's `create_date` / `version_id` to label
34
+ * which historical run a previous-period board is. How far back
35
+ * snapshots are retained is operator-configured.
31
36
  *
32
37
  * **Top-20 cap**
33
38
  * The server hard-caps `users[]` at 20 entries, ordered by
@@ -81,10 +86,11 @@ export declare class WSAPILeaderBoard extends WSAPIGamePick {
81
86
  * Selects which pre-configured board to
82
87
  * fetch; the board itself is bound to one
83
88
  * period by the operator.
84
- * @param getPreviousPeriod When `true`, returns the most recent
85
- * finalized snapshot for that period type
86
- * (e.g. last week's results). Defaults to
87
- * `false` (current in-progress period).
89
+ * @param getPreviousPeriod Which period to fetch. `false` (default)
90
+ * = current in-progress period; `true` =
91
+ * the most recent finalized snapshot; a
92
+ * number `n` = the n-th previous snapshot
93
+ * (`1` = previous, `2` = the one before, …).
88
94
  * @returns Promise resolving to `LeaderBoardDetailsT`.
89
95
  * **At runtime, may resolve to `undefined`**
90
96
  * when no board is configured for the
@@ -127,5 +133,65 @@ export declare class WSAPILeaderBoard extends WSAPIGamePick {
127
133
  * // const visitorBoard = await window._smartico.vapi('EN').getLeaderBoard(LeaderBoardPeriodType.DAILY);
128
134
  * ```
129
135
  */
130
- getLeaderBoard(periodType: LeaderBoardPeriodType, getPreviousPeriod?: boolean): Promise<LeaderBoardDetailsT>;
136
+ getLeaderBoard(periodType: LeaderBoardPeriodType, getPreviousPeriod?: boolean | number): Promise<LeaderBoardDetailsT>;
137
+ /**
138
+ * Returns the list of leaderboards the operator has configured for this
139
+ * label — **metadata only, without participants**. Use it to discover
140
+ * which boards exist (and their period types) so you can render the
141
+ * board/tab selector, then load a specific board's standings on demand
142
+ * with {@link getLeaderBoard}.
143
+ *
144
+ * This is the lightweight discovery counterpart to {@link getLeaderBoard}:
145
+ * it issues one round-trip that returns every board's identity, name,
146
+ * description, rules, `period_type_id`, and prize table, but **not** the
147
+ * ranked players. Fetching the full standings for one board (the top-20
148
+ * `users[]` and the caller's own `me` entry) is what {@link getLeaderBoard}
149
+ * does per period.
150
+ *
151
+ * @remarks
152
+ * **Returned shape**
153
+ * An array of `LeaderBoardDetailsT`, one per configured board, ordered by
154
+ * `period_type_id` ascending (DAILY, WEEKLY, MONTHLY, …). On every entry
155
+ * `users` is an empty array and `me` is `undefined` — this call never
156
+ * carries participant data. Read `period_type_id` from each entry and pass
157
+ * it to {@link getLeaderBoard} to load that board's standings.
158
+ *
159
+ * **Empty result**
160
+ * Resolves to an empty array when the label has no leaderboards configured
161
+ * — treat that as "hide the leaderboard surface".
162
+ *
163
+ * **Cache TTL**
164
+ * Cached for 30 seconds under a dedicated key (independent of
165
+ * {@link getLeaderBoard}'s per-period cache). Repeated calls within the
166
+ * window return the cached list without a round-trip.
167
+ *
168
+ * **Refresh model**: one-shot fetch — no subscription, no push. Board
169
+ * configuration changes surface on the next cache miss.
170
+ *
171
+ * **Idempotency / Side effects**: safe. Read-only.
172
+ *
173
+ * **Visitor mode**: supported. Returns the brand's public board list.
174
+ *
175
+ * @returns Promise resolving to the array of configured boards
176
+ * (metadata only). Empty array when none are configured.
177
+ *
178
+ * @example
179
+ * ```ts
180
+ * const boards = await window._smartico.api.getLeaderBoards();
181
+ *
182
+ * if (boards.length === 0) {
183
+ * console.log('[smartico] no leaderboards configured — hide the leaderboard surface');
184
+ * return;
185
+ * }
186
+ *
187
+ * // Render one tab per board from the lightweight list (no players yet).
188
+ * console.log('[smartico] render leaderboard tabs:', boards.map(b => b.name));
189
+ *
190
+ * // When the user opens a tab, load that board's standings on demand.
191
+ * const first = boards[0];
192
+ * const full = await window._smartico.api.getLeaderBoard(first.period_type_id);
193
+ * console.log('[smartico] loaded standings for', first.name, '—', full?.users.length ?? 0, 'players');
194
+ * ```
195
+ */
196
+ getLeaderBoards(): Promise<LeaderBoardDetailsT[]>;
131
197
  }
@@ -1044,9 +1044,16 @@ export interface LeaderBoardDetailsT {
1044
1044
  rules: string;
1045
1045
  /** Period type this board is bound to ({@link LeaderBoardPeriodType}). */
1046
1046
  period_type_id: LeaderBoardPeriodType;
1047
+ /** Snapshot version. `0` for the live current period; a positive value
1048
+ * identifies a finalized previous-period snapshot (see `getPreviousPeriod`). */
1049
+ version_id: number;
1050
+ /** Snapshot creation timestamp (Unix ms). `0` for the live current period;
1051
+ * the finalization time for a previous-period snapshot. */
1052
+ create_date: number;
1047
1053
  /** Per-place prize table; the array length is the number of paid places. */
1048
1054
  rewards: LeaderBoardsRewardsT[];
1049
- /** Top-20 ranked entries (server-capped), sorted by `position` ASC. */
1055
+ /** Top-20 ranked entries (server-capped), sorted by `position` ASC.
1056
+ * Empty when fetched via `getLeaderBoards()` (metadata-only list). */
1050
1057
  users: LeaderBoardUserT[];
1051
1058
  /** Current user's own entry. `undefined` for visitor sessions.
1052
1059
  * For authenticated users, `position === -1` means the user is
@@ -1069,14 +1076,20 @@ export interface LeaderBoardsRewardsT {
1069
1076
  export interface LeaderBoardUserT {
1070
1077
  /** Display username (operator-defined alias). */
1071
1078
  public_username: string;
1072
- /** Resolved CDN URL for the participant's avatar. */
1079
+ /** Resolved CDN URL for the participant's avatar. May be empty when the
1080
+ * participant has no custom avatar — fall back to a level-based default
1081
+ * using `level_id`. */
1073
1082
  avatar_url: string;
1083
+ /** The participant's level id — use it to resolve a level-based default
1084
+ * avatar when `avatar_url` is empty. */
1085
+ level_id: number;
1074
1086
  /** Rank in the leaderboard (DENSE_RANK over all participants).
1075
1087
  * `-1` on the `me` entry signals "unranked / outside the window". */
1076
1088
  position: number;
1077
1089
  /** Participant's points for this period. */
1078
1090
  points: number;
1079
- /** `true` when this row is the current authenticated user. */
1091
+ /** `true` when this row is the current authenticated user. Always `true`
1092
+ * on the `me` entry. */
1080
1093
  is_me: boolean;
1081
1094
  }
1082
1095
  /**