@smartico/public-api 0.0.386 → 0.0.388
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 +2 -2
- package/dist/Avatars/AvatarCustomizeErrorCode.d.ts +7 -1
- package/dist/Avatars/AvatarCustomizeResponse.d.ts +16 -0
- package/dist/Avatars/index.d.ts +1 -0
- package/dist/CustomSections/AchCustomSection.d.ts +2 -1
- package/dist/Missions/UserAchievementTask.d.ts +4 -0
- package/dist/SmarticoAPI.d.ts +15 -2
- package/dist/WSAPI/WSAPIAvatars.d.ts +103 -0
- package/dist/WSAPI/WSAPILeaderBoard.d.ts +76 -10
- package/dist/WSAPI/WSAPITypes.d.ts +22 -5
- package/dist/index.js +441 -149
- package/dist/index.js.map +1 -1
- package/dist/index.modern.mjs +280 -29
- package/dist/index.modern.mjs.map +1 -1
- package/docs/SmarticoObject.md +15 -0
- package/docs/api/README.md +2 -0
- package/docs/api/classes/WSAPIAvatars.md +135 -0
- package/docs/api/classes/WSAPIClans.md +3 -5
- package/docs/api/classes/WSAPILeaderBoard.md +86 -10
- package/docs/api/documents/SmarticoObject.md +15 -0
- package/docs/api/enumerations/AvatarCustomizeErrorCode.md +21 -0
- package/docs/api/enumerations/JoinClanErrorCode.md +16 -17
- package/docs/api/interfaces/AvatarCustomizeResponse.md +31 -0
- package/docs/api/interfaces/LeaderBoardDetailsT.md +19 -0
- package/docs/api/interfaces/LeaderBoardUserT.md +14 -2
- package/docs/api/interfaces/TAvatarPrompt.md +2 -2
- package/docs/api/interfaces/TMissionOrBadgeTask.md +16 -0
- package/docs/api/interfaces/UserAchievementTask.md +16 -0
- package/docs/native/PROTOCOL.md +37 -7
- package/docs/ui/avatars/UIGuide_avatarsCustomize.md +69 -0
- package/docs/ui/leaderboard/UIGuide_getLeaderBoard.md +15 -0
- package/package.json +1 -1
- package/src/Avatars/AvatarCustomizeErrorCode.ts +7 -5
- package/src/Avatars/AvatarCustomizeResponse.ts +17 -0
- package/src/Avatars/index.ts +1 -0
- package/src/CustomSections/AchCustomSection.ts +1 -0
- package/src/Leaderboard/LeaderBoards.ts +9 -12
- package/src/Missions/UserAchievement.ts +2 -0
- package/src/Missions/UserAchievementTask.ts +4 -0
- package/src/SmarticoAPI.ts +84 -3
- package/src/WSAPI/WSAPIAvatars.ts +121 -0
- package/src/WSAPI/WSAPILeaderBoard.ts +91 -14
- package/src/WSAPI/WSAPITypes.ts +22 -5
- package/tsconfig.json +3 -1
|
@@ -20,7 +20,9 @@ export class WSAPILeaderBoard extends WSAPIGamePick {
|
|
|
20
20
|
*
|
|
21
21
|
* The leaderboard for each period type is configured separately by
|
|
22
22
|
* the operator. A label may have any combination of DAILY, WEEKLY,
|
|
23
|
-
* and MONTHLY boards configured (or none).
|
|
23
|
+
* and MONTHLY boards configured (or none). To discover which boards
|
|
24
|
+
* exist before loading any standings, call {@link getLeaderBoards}
|
|
25
|
+
* (metadata only) and drive the tab selector from its `period_type_id`s.
|
|
24
26
|
*
|
|
25
27
|
* @remarks
|
|
26
28
|
* **Return value note** — the runtime may return `undefined` if no
|
|
@@ -32,10 +34,13 @@ export class WSAPILeaderBoard extends WSAPIGamePick {
|
|
|
32
34
|
* Pass a `periodType` from {@link LeaderBoardPeriodType}
|
|
33
35
|
* (`DAILY = 1`, `WEEKLY = 2`, `MONTHLY = 3`). Pass
|
|
34
36
|
* `getPreviousPeriod: true` to fetch the most-recently-ended
|
|
35
|
-
* period's snapshot (yesterday's
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
37
|
+
* period's snapshot (yesterday's / last week's / last month's
|
|
38
|
+
* results) instead of the current live period. To reach older
|
|
39
|
+
* snapshots, pass a number instead of a boolean: `1` = previous
|
|
40
|
+
* period, `2` = the one before that, and so on (`0` / `false` =
|
|
41
|
+
* current). Use the snapshot's `create_date` / `version_id` to label
|
|
42
|
+
* which historical run a previous-period board is. How far back
|
|
43
|
+
* snapshots are retained is operator-configured.
|
|
39
44
|
*
|
|
40
45
|
* **Top-20 cap**
|
|
41
46
|
* The server hard-caps `users[]` at 20 entries, ordered by
|
|
@@ -89,10 +94,11 @@ export class WSAPILeaderBoard extends WSAPIGamePick {
|
|
|
89
94
|
* Selects which pre-configured board to
|
|
90
95
|
* fetch; the board itself is bound to one
|
|
91
96
|
* period by the operator.
|
|
92
|
-
* @param getPreviousPeriod
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
* `
|
|
97
|
+
* @param getPreviousPeriod Which period to fetch. `false` (default)
|
|
98
|
+
* = current in-progress period; `true` =
|
|
99
|
+
* the most recent finalized snapshot; a
|
|
100
|
+
* number `n` = the n-th previous snapshot
|
|
101
|
+
* (`1` = previous, `2` = the one before, …).
|
|
96
102
|
* @returns Promise resolving to `LeaderBoardDetailsT`.
|
|
97
103
|
* **At runtime, may resolve to `undefined`**
|
|
98
104
|
* when no board is configured for the
|
|
@@ -135,14 +141,85 @@ export class WSAPILeaderBoard extends WSAPIGamePick {
|
|
|
135
141
|
* // const visitorBoard = await window._smartico.vapi('EN').getLeaderBoard(LeaderBoardPeriodType.DAILY);
|
|
136
142
|
* ```
|
|
137
143
|
*/
|
|
138
|
-
public async getLeaderBoard(periodType: LeaderBoardPeriodType, getPreviousPeriod?: boolean): Promise<LeaderBoardDetailsT> {
|
|
139
|
-
//
|
|
140
|
-
//
|
|
141
|
-
const
|
|
144
|
+
public async getLeaderBoard(periodType: LeaderBoardPeriodType, getPreviousPeriod?: boolean | number): Promise<LeaderBoardDetailsT> {
|
|
145
|
+
// Resolve the snapshot offset: false/omitted → 0 (current), true → 1
|
|
146
|
+
// (previous), or an explicit number for older snapshots.
|
|
147
|
+
const offset = typeof getPreviousPeriod === 'number' ? getPreviousPeriod : getPreviousPeriod ? 1 : 0;
|
|
148
|
+
// Cache per (periodType, offset) so switching tabs or period within the
|
|
149
|
+
// TTL doesn't return a colliding board.
|
|
150
|
+
const cacheKey = `${onUpdateContextKey.LeaderBoards}:${periodType}:${offset}`;
|
|
142
151
|
return OCache.use(
|
|
143
152
|
cacheKey,
|
|
144
153
|
ECacheContext.WSAPI,
|
|
145
|
-
() => this.api.leaderboardsGetT(this.userExtId, periodType,
|
|
154
|
+
() => this.api.leaderboardsGetT(this.userExtId, periodType, offset),
|
|
155
|
+
CACHE_DATA_SEC,
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Returns the list of leaderboards the operator has configured for this
|
|
161
|
+
* label — **metadata only, without participants**. Use it to discover
|
|
162
|
+
* which boards exist (and their period types) so you can render the
|
|
163
|
+
* board/tab selector, then load a specific board's standings on demand
|
|
164
|
+
* with {@link getLeaderBoard}.
|
|
165
|
+
*
|
|
166
|
+
* This is the lightweight discovery counterpart to {@link getLeaderBoard}:
|
|
167
|
+
* it issues one round-trip that returns every board's identity, name,
|
|
168
|
+
* description, rules, `period_type_id`, and prize table, but **not** the
|
|
169
|
+
* ranked players. Fetching the full standings for one board (the top-20
|
|
170
|
+
* `users[]` and the caller's own `me` entry) is what {@link getLeaderBoard}
|
|
171
|
+
* does per period.
|
|
172
|
+
*
|
|
173
|
+
* @remarks
|
|
174
|
+
* **Returned shape**
|
|
175
|
+
* An array of `LeaderBoardDetailsT`, one per configured board, ordered by
|
|
176
|
+
* `period_type_id` ascending (DAILY, WEEKLY, MONTHLY, …). On every entry
|
|
177
|
+
* `users` is an empty array and `me` is `undefined` — this call never
|
|
178
|
+
* carries participant data. Read `period_type_id` from each entry and pass
|
|
179
|
+
* it to {@link getLeaderBoard} to load that board's standings.
|
|
180
|
+
*
|
|
181
|
+
* **Empty result**
|
|
182
|
+
* Resolves to an empty array when the label has no leaderboards configured
|
|
183
|
+
* — treat that as "hide the leaderboard surface".
|
|
184
|
+
*
|
|
185
|
+
* **Cache TTL**
|
|
186
|
+
* Cached for 30 seconds under a dedicated key (independent of
|
|
187
|
+
* {@link getLeaderBoard}'s per-period cache). Repeated calls within the
|
|
188
|
+
* window return the cached list without a round-trip.
|
|
189
|
+
*
|
|
190
|
+
* **Refresh model**: one-shot fetch — no subscription, no push. Board
|
|
191
|
+
* configuration changes surface on the next cache miss.
|
|
192
|
+
*
|
|
193
|
+
* **Idempotency / Side effects**: safe. Read-only.
|
|
194
|
+
*
|
|
195
|
+
* **Visitor mode**: supported. Returns the brand's public board list.
|
|
196
|
+
*
|
|
197
|
+
* @returns Promise resolving to the array of configured boards
|
|
198
|
+
* (metadata only). Empty array when none are configured.
|
|
199
|
+
*
|
|
200
|
+
* @example
|
|
201
|
+
* ```ts
|
|
202
|
+
* const boards = await window._smartico.api.getLeaderBoards();
|
|
203
|
+
*
|
|
204
|
+
* if (boards.length === 0) {
|
|
205
|
+
* console.log('[smartico] no leaderboards configured — hide the leaderboard surface');
|
|
206
|
+
* return;
|
|
207
|
+
* }
|
|
208
|
+
*
|
|
209
|
+
* // Render one tab per board from the lightweight list (no players yet).
|
|
210
|
+
* console.log('[smartico] render leaderboard tabs:', boards.map(b => b.name));
|
|
211
|
+
*
|
|
212
|
+
* // When the user opens a tab, load that board's standings on demand.
|
|
213
|
+
* const first = boards[0];
|
|
214
|
+
* const full = await window._smartico.api.getLeaderBoard(first.period_type_id);
|
|
215
|
+
* console.log('[smartico] loaded standings for', first.name, '—', full?.users.length ?? 0, 'players');
|
|
216
|
+
* ```
|
|
217
|
+
*/
|
|
218
|
+
public async getLeaderBoards(): Promise<LeaderBoardDetailsT[]> {
|
|
219
|
+
return OCache.use(
|
|
220
|
+
`${onUpdateContextKey.LeaderBoards}:list`,
|
|
221
|
+
ECacheContext.WSAPI,
|
|
222
|
+
() => this.api.leaderboardsGetListT(this.userExtId),
|
|
146
223
|
CACHE_DATA_SEC,
|
|
147
224
|
);
|
|
148
225
|
}
|
package/src/WSAPI/WSAPITypes.ts
CHANGED
|
@@ -953,6 +953,10 @@ export interface TMissionOrBadgeTask {
|
|
|
953
953
|
progress: number;
|
|
954
954
|
/** Reward for completing the task in points */
|
|
955
955
|
points_reward: number;
|
|
956
|
+
/** Reward for completing the task in gems */
|
|
957
|
+
gems_reward?: number;
|
|
958
|
+
/** Reward for completing the task in diamonds */
|
|
959
|
+
diamonds_reward?: number;
|
|
956
960
|
/** This is the total number of times the user needs to execute to complete task. e.g. he needs to bet 100 times. Here will be 100 */
|
|
957
961
|
execution_count_expected?: number;
|
|
958
962
|
/** This is the number of times the user has executed 'activity' of the task. e.g. he bet 5 times out of 100. Here will be 5 */
|
|
@@ -1101,9 +1105,16 @@ export interface LeaderBoardDetailsT {
|
|
|
1101
1105
|
rules: string;
|
|
1102
1106
|
/** Period type this board is bound to ({@link LeaderBoardPeriodType}). */
|
|
1103
1107
|
period_type_id: LeaderBoardPeriodType;
|
|
1108
|
+
/** Snapshot version. `0` for the live current period; a positive value
|
|
1109
|
+
* identifies a finalized previous-period snapshot (see `getPreviousPeriod`). */
|
|
1110
|
+
version_id: number;
|
|
1111
|
+
/** Snapshot creation timestamp (Unix ms). `0` for the live current period;
|
|
1112
|
+
* the finalization time for a previous-period snapshot. */
|
|
1113
|
+
create_date: number;
|
|
1104
1114
|
/** Per-place prize table; the array length is the number of paid places. */
|
|
1105
1115
|
rewards: LeaderBoardsRewardsT[];
|
|
1106
|
-
/** Top-20 ranked entries (server-capped), sorted by `position` ASC.
|
|
1116
|
+
/** Top-20 ranked entries (server-capped), sorted by `position` ASC.
|
|
1117
|
+
* Empty when fetched via `getLeaderBoards()` (metadata-only list). */
|
|
1107
1118
|
users: LeaderBoardUserT[];
|
|
1108
1119
|
/** Current user's own entry. `undefined` for visitor sessions.
|
|
1109
1120
|
* For authenticated users, `position === -1` means the user is
|
|
@@ -1128,14 +1139,20 @@ export interface LeaderBoardsRewardsT {
|
|
|
1128
1139
|
export interface LeaderBoardUserT {
|
|
1129
1140
|
/** Display username (operator-defined alias). */
|
|
1130
1141
|
public_username: string;
|
|
1131
|
-
/** Resolved CDN URL for the participant's avatar.
|
|
1142
|
+
/** Resolved CDN URL for the participant's avatar. May be empty when the
|
|
1143
|
+
* participant has no custom avatar — fall back to a level-based default
|
|
1144
|
+
* using `level_id`. */
|
|
1132
1145
|
avatar_url: string;
|
|
1146
|
+
/** The participant's level id — use it to resolve a level-based default
|
|
1147
|
+
* avatar when `avatar_url` is empty. */
|
|
1148
|
+
level_id: number;
|
|
1133
1149
|
/** Rank in the leaderboard (DENSE_RANK over all participants).
|
|
1134
1150
|
* `-1` on the `me` entry signals "unranked / outside the window". */
|
|
1135
1151
|
position: number;
|
|
1136
1152
|
/** Participant's points for this period. */
|
|
1137
1153
|
points: number;
|
|
1138
|
-
/** `true` when this row is the current authenticated user.
|
|
1154
|
+
/** `true` when this row is the current authenticated user. Always `true`
|
|
1155
|
+
* on the `me` entry. */
|
|
1139
1156
|
is_me: boolean;
|
|
1140
1157
|
}
|
|
1141
1158
|
|
|
@@ -1780,9 +1797,9 @@ export interface TAvatarPrompt {
|
|
|
1780
1797
|
name: string;
|
|
1781
1798
|
/** Absolute CDN URL of the prompt's preview icon. */
|
|
1782
1799
|
icon_url: string;
|
|
1783
|
-
/** Currency used to pay for the customization. `0` = points, `1` = gems, `2` = diamonds. */
|
|
1800
|
+
/** Currency used to pay for the customization. `0` = points, `1` = gems, `2` = diamonds, `3` = free. A `cost_value` of `0` is also free. */
|
|
1784
1801
|
cost_currency_type_id: number;
|
|
1785
|
-
/** Cost amount in the currency named by `cost_currency_type_id`. */
|
|
1802
|
+
/** Cost amount in the currency named by `cost_currency_type_id`. `0` = free. */
|
|
1786
1803
|
cost_value: number;
|
|
1787
1804
|
}
|
|
1788
1805
|
|
package/tsconfig.json
CHANGED
|
@@ -90,7 +90,9 @@
|
|
|
90
90
|
"src/Tournaments/GetClanTournamentPlayersResponse.ts",
|
|
91
91
|
"src/Avatars/AvatarDefinition.ts",
|
|
92
92
|
"src/Avatars/AvatarCustomized.ts",
|
|
93
|
-
"src/Avatars/AvatarPrompt.ts"
|
|
93
|
+
"src/Avatars/AvatarPrompt.ts",
|
|
94
|
+
"src/Avatars/AvatarCustomizeResponse.ts",
|
|
95
|
+
"src/Avatars/AvatarCustomizeErrorCode.ts"
|
|
94
96
|
],
|
|
95
97
|
"out": "docs/api",
|
|
96
98
|
"projectDocuments": ["docs/SmarticoObject.md", "docs/Callbacks.md", "docs/Transforms.md"],
|