@smartico/public-api 0.0.380 → 0.0.382

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.
Files changed (178) hide show
  1. package/CLAUDE.md +103 -0
  2. package/README.md +32 -10
  3. package/dist/Base/ClassId.d.ts +2 -0
  4. package/dist/Jackpots/JackpotDetails.d.ts +14 -15
  5. package/dist/Jackpots/JackpotPot.d.ts +10 -6
  6. package/dist/MiniGames/SAWGameType.d.ts +3 -1
  7. package/dist/MiniGames/SAWTemplateUI.d.ts +7 -0
  8. package/dist/Raffle/GetRaffleWonPrizesRequest.d.ts +9 -0
  9. package/dist/Raffle/GetRaffleWonPrizesResponse.d.ts +52 -0
  10. package/dist/Raffle/index.d.ts +2 -0
  11. package/dist/SmarticoAPI.d.ts +6 -1
  12. package/dist/SmarticoLib/index.d.ts +5 -1
  13. package/dist/WSAPI/WSAPIAvatars.d.ts +267 -49
  14. package/dist/WSAPI/WSAPIBonuses.d.ts +224 -10
  15. package/dist/WSAPI/WSAPIGamePick.d.ts +538 -253
  16. package/dist/WSAPI/WSAPIGeneral.d.ts +156 -14
  17. package/dist/WSAPI/WSAPIInbox.d.ts +547 -58
  18. package/dist/WSAPI/WSAPIJackpots.d.ts +292 -57
  19. package/dist/WSAPI/WSAPILeaderBoard.d.ts +127 -13
  20. package/dist/WSAPI/WSAPIMiniGames.d.ts +465 -49
  21. package/dist/WSAPI/WSAPIRaffles.d.ts +576 -52
  22. package/dist/WSAPI/WSAPITournaments.d.ts +3 -3
  23. package/dist/WSAPI/WSAPITypes.d.ts +243 -132
  24. package/dist/WSAPI/WSAPIUser.d.ts +193 -43
  25. package/dist/index.js +3412 -616
  26. package/dist/index.js.map +1 -1
  27. package/dist/index.modern.mjs +3395 -609
  28. package/dist/index.modern.mjs.map +1 -1
  29. package/docs/Callbacks.md +162 -0
  30. package/docs/SmarticoObject.md +445 -0
  31. package/docs/Transforms.md +99 -0
  32. package/docs/api/README.md +26 -0
  33. package/docs/api/classes/WSAPIAvatars.md +282 -54
  34. package/docs/api/classes/WSAPIBonuses.md +233 -12
  35. package/docs/api/classes/WSAPIClans.md +380 -10
  36. package/docs/api/classes/WSAPIGamePick.md +555 -26
  37. package/docs/api/classes/WSAPIGeneral.md +165 -16
  38. package/docs/api/classes/WSAPIInbox.md +588 -64
  39. package/docs/api/classes/WSAPIJackpots.md +320 -66
  40. package/docs/api/classes/WSAPILeaderBoard.md +133 -15
  41. package/docs/api/classes/WSAPIMiniGames.md +501 -64
  42. package/docs/api/classes/WSAPIMissions.md +58 -79
  43. package/docs/api/classes/WSAPIRaffles.md +647 -69
  44. package/docs/api/classes/WSAPIStore.md +83 -108
  45. package/docs/api/classes/WSAPITournaments.md +495 -28
  46. package/docs/api/classes/WSAPIUser.md +520 -83
  47. package/docs/api/documents/Callbacks.md +162 -0
  48. package/docs/api/documents/SmarticoObject.md +445 -0
  49. package/docs/api/documents/Transforms.md +99 -0
  50. package/docs/api/enumerations/BonusStatus-1.md +11 -6
  51. package/docs/api/enumerations/JoinClanErrorCode.md +81 -0
  52. package/docs/api/enumerations/TournamentRegistrationError.md +12 -0
  53. package/docs/api/functions/clanTournamentPlayersTransform.md +13 -0
  54. package/docs/api/interfaces/AvatarCustomized.md +25 -0
  55. package/docs/api/interfaces/AvatarDefinition.md +94 -0
  56. package/docs/api/interfaces/AvatarPrompt.md +45 -0
  57. package/docs/api/interfaces/BonusMetaMap-1.md +4 -1
  58. package/docs/api/interfaces/BonusTemplateMetaMap-1.md +9 -4
  59. package/docs/api/interfaces/Clan.md +4 -0
  60. package/docs/api/interfaces/ClanInfo.md +109 -0
  61. package/docs/api/interfaces/ClanMember.md +53 -0
  62. package/docs/api/interfaces/ClanTournamentPlayerRaw.md +67 -0
  63. package/docs/api/interfaces/GemsDiamondsLog.md +43 -0
  64. package/docs/api/interfaces/GetClanInfoResponse.md +61 -0
  65. package/docs/api/interfaces/GetClanTournamentPlayersResponse.md +81 -0
  66. package/docs/api/interfaces/GetRaffleWonPrizesRequest.md +59 -0
  67. package/docs/api/interfaces/GetRaffleWonPrizesResponse.md +95 -0
  68. package/docs/api/interfaces/InboxMarkMessageAction.md +10 -2
  69. package/docs/api/interfaces/JackpotDetails.md +14 -15
  70. package/docs/api/interfaces/JackpotPot.md +9 -6
  71. package/docs/api/interfaces/LeaderBoardDetailsT.md +14 -8
  72. package/docs/api/interfaces/LeaderBoardUserT.md +8 -5
  73. package/docs/api/interfaces/LeaderBoardsRewardsT.md +7 -0
  74. package/docs/api/interfaces/PointsLog.md +43 -0
  75. package/docs/api/interfaces/RaffleWonPrize.md +59 -0
  76. package/docs/api/interfaces/RaffleWonPrizePublicMeta.md +27 -0
  77. package/docs/api/interfaces/RaffleWonPrizeUser.md +43 -0
  78. package/docs/api/interfaces/TAchCategory.md +2 -7
  79. package/docs/api/interfaces/TAvatarCustomized.md +4 -4
  80. package/docs/api/interfaces/TAvatarDefinition.md +13 -14
  81. package/docs/api/interfaces/TAvatarPrompt.md +6 -6
  82. package/docs/api/interfaces/TBonus.md +16 -8
  83. package/docs/api/interfaces/TBuyStoreItemResult.md +4 -29
  84. package/docs/api/interfaces/TClaimBonusResult.md +5 -5
  85. package/docs/api/interfaces/TClan.md +8 -4
  86. package/docs/api/interfaces/TClanInfo.md +47 -0
  87. package/docs/api/interfaces/TClanJoinResult.md +11 -1
  88. package/docs/api/interfaces/TClanTournamentPlayer.md +55 -0
  89. package/docs/api/interfaces/TClanTournamentPlayersResult.md +27 -0
  90. package/docs/api/interfaces/TClans.md +3 -1
  91. package/docs/api/interfaces/TGetTranslations.md +4 -0
  92. package/docs/api/interfaces/TInboxMessage.md +14 -6
  93. package/docs/api/interfaces/TInboxMessageBody.md +18 -12
  94. package/docs/api/interfaces/TLevel.md +17 -20
  95. package/docs/api/interfaces/TLevelCurrent.md +19 -18
  96. package/docs/api/interfaces/TMiniGamePlayBatchResult.md +14 -6
  97. package/docs/api/interfaces/TMiniGamePlayResult.md +9 -4
  98. package/docs/api/interfaces/TMissionClaimRewardResult.md +1 -9
  99. package/docs/api/interfaces/TMissionOptInResult.md +1 -5
  100. package/docs/api/interfaces/TMissionOrBadge.md +4 -7
  101. package/docs/api/interfaces/TRaffleOptinResponse.md +4 -2
  102. package/docs/api/interfaces/TSegmentCheckResult.md +10 -0
  103. package/docs/api/interfaces/TSetAvatarResult.md +3 -3
  104. package/docs/api/interfaces/TStoreItem.md +3 -13
  105. package/docs/api/interfaces/TTournament.md +1 -1
  106. package/docs/api/interfaces/TTournamentDetailed.md +1 -1
  107. package/docs/api/interfaces/TTournamentRegistrationResult.md +4 -2
  108. package/docs/api/interfaces/TUICustomSection.md +23 -19
  109. package/docs/api/interfaces/TUserProfile.md +18 -16
  110. package/docs/api/interfaces/TransformedRaffleClaimPrizeResponse.md +6 -2
  111. package/docs/api/interfaces/UserLevelExtraCountersT.md +9 -2
  112. package/docs/api/type-aliases/ActivityLogEntry.md +3 -0
  113. package/docs/native/ADDING_METHODS.md +7 -2
  114. package/docs/native/PROTOCOL.md +337 -0
  115. package/docs/ui/avatars/UIGuide_getAvatarPrompts.md +100 -0
  116. package/docs/ui/avatars/UIGuide_getAvatarsCustomized.md +90 -0
  117. package/docs/ui/avatars/UIGuide_getAvatarsList.md +105 -0
  118. package/docs/ui/avatars/UIGuide_setAvatar.md +118 -0
  119. package/docs/ui/bonuses/UIGuide_claimBonus.md +144 -0
  120. package/docs/ui/bonuses/UIGuide_getBonuses.md +176 -0
  121. package/docs/ui/gamepick/UIGuide_gamePickGetActiveRound.md +99 -0
  122. package/docs/ui/gamepick/UIGuide_gamePickGetActiveRounds.md +76 -0
  123. package/docs/ui/gamepick/UIGuide_gamePickGetBoard.md +81 -0
  124. package/docs/ui/gamepick/UIGuide_gamePickGetGameInfo.md +78 -0
  125. package/docs/ui/gamepick/UIGuide_gamePickGetHistory.md +55 -0
  126. package/docs/ui/gamepick/UIGuide_gamePickGetRoundInfoForUser.md +71 -0
  127. package/docs/ui/gamepick/UIGuide_gamePickGetUserInfo.md +64 -0
  128. package/docs/ui/gamepick/UIGuide_gamePickSubmitSelection.md +103 -0
  129. package/docs/ui/gamepick/UIGuide_gamePickSubmitSelectionQuiz.md +67 -0
  130. package/docs/ui/general/UIGuide_getCustomSections.md +137 -0
  131. package/docs/ui/general/UIGuide_getRelatedItemsForGame.md +140 -0
  132. package/docs/ui/inbox/UIGuide_deleteInboxMessage.md +135 -0
  133. package/docs/ui/inbox/UIGuide_getInboxMessageBody.md +133 -0
  134. package/docs/ui/inbox/UIGuide_getInboxMessages.md +186 -0
  135. package/docs/ui/inbox/UIGuide_markInboxMessageAsRead.md +122 -0
  136. package/docs/ui/inbox/UIGuide_markUnmarkInboxMessageAsFavorite.md +84 -0
  137. package/docs/ui/jackpots/UIGuide_getJackpotEligibleGames.md +73 -0
  138. package/docs/ui/jackpots/UIGuide_getJackpotWinners.md +83 -0
  139. package/docs/ui/jackpots/UIGuide_jackpotGet.md +138 -0
  140. package/docs/ui/jackpots/UIGuide_jackpotOptIn.md +85 -0
  141. package/docs/ui/jackpots/UIGuide_jackpotOptOut.md +65 -0
  142. package/docs/ui/leaderboard/UIGuide_getLeaderBoard.md +166 -0
  143. package/docs/ui/minigames/UIGuide_getMiniGames.md +153 -0
  144. package/docs/ui/minigames/UIGuide_getMiniGamesHistory.md +90 -0
  145. package/docs/ui/minigames/UIGuide_playMiniGame.md +150 -0
  146. package/docs/ui/minigames/UIGuide_playMiniGameBatch.md +128 -0
  147. package/docs/ui/raffles/UIGuide_claimRafflePrize.md +99 -0
  148. package/docs/ui/raffles/UIGuide_getRaffleDrawRun.md +117 -0
  149. package/docs/ui/raffles/UIGuide_getRaffleDrawRunsHistory.md +92 -0
  150. package/docs/ui/raffles/UIGuide_getRaffleWonPrizes.md +120 -0
  151. package/docs/ui/raffles/UIGuide_getRaffles.md +175 -0
  152. package/docs/ui/raffles/UIGuide_requestRaffleOptin.md +114 -0
  153. package/docs/ui/user/UIGuide_getActivityLog.md +130 -0
  154. package/docs/ui/user/UIGuide_getLevels.md +47 -42
  155. package/package.json +1 -1
  156. package/src/Base/ClassId.ts +2 -0
  157. package/src/Jackpots/JackpotDetails.ts +14 -15
  158. package/src/Jackpots/JackpotPot.ts +10 -6
  159. package/src/MiniGames/SAWGameType.ts +3 -0
  160. package/src/MiniGames/SAWTemplateUI.ts +10 -0
  161. package/src/Raffle/GetRaffleWonPrizesRequest.ts +12 -0
  162. package/src/Raffle/GetRaffleWonPrizesResponse.ts +56 -0
  163. package/src/Raffle/index.ts +3 -1
  164. package/src/SmarticoAPI.ts +14 -1
  165. package/src/SmarticoLib/index.ts +4 -0
  166. package/src/WSAPI/WSAPIAvatars.ts +267 -49
  167. package/src/WSAPI/WSAPIBonuses.ts +224 -10
  168. package/src/WSAPI/WSAPIGamePick.ts +538 -253
  169. package/src/WSAPI/WSAPIGeneral.ts +156 -14
  170. package/src/WSAPI/WSAPIInbox.ts +545 -56
  171. package/src/WSAPI/WSAPIJackpots.ts +297 -61
  172. package/src/WSAPI/WSAPILeaderBoard.ts +127 -13
  173. package/src/WSAPI/WSAPIMiniGames.ts +465 -49
  174. package/src/WSAPI/WSAPIRaffles.ts +592 -64
  175. package/src/WSAPI/WSAPITournaments.ts +3 -3
  176. package/src/WSAPI/WSAPITypes.ts +243 -132
  177. package/src/WSAPI/WSAPIUser.ts +193 -43
  178. package/tsconfig.json +9 -1
@@ -0,0 +1,99 @@
1
+ # Transform functions — raw protocol → friendly types
2
+
3
+ The SDK talks to the Smartico backend over a low-level WebSocket protocol (the
4
+ raw request/response messages documented in the Native Protocol doc, `docs/native/PROTOCOL.md`).
5
+ Those raw messages are shaped for the wire, not for application developers —
6
+ they nest display fields inside `public_meta` / `*PublicMeta` objects, mix
7
+ camelCase and snake_case, carry opaque numeric type ids, JSON-encode some
8
+ values as strings, and include wire-only fields a UI never needs.
9
+
10
+ Rather than hand all that to the consumer, the SDK runs a **transform function**
11
+ over every response, producing a clean, consistently-shaped, friendly object.
12
+ This is why `_smartico.api.*` returns pleasant `T`-prefixed types instead of
13
+ the raw protocol shapes.
14
+
15
+ ## The three naming conventions
16
+
17
+ You'll see this pattern repeated across every domain:
18
+
19
+ | Convention | Where | Meaning |
20
+ |---|---|---|
21
+ | **`T`-prefixed types** (`TStoreItem`, `TAvatarDefinition`, `TClanInfo`, `TMissionOrBadge`, …) | `WSAPITypes.ts` + domain folders | The **friendly** result type returned to the consumer. The `T` distinguishes it from the raw protocol type of the same name (`StoreItem`, `AvatarDefinition`, …). |
22
+ | **`*Transform` functions** (`StoreItemTransform`, `avatarDefinitionTransform`, `clanTournamentPlayersTransform`, …) | `src/<Domain>/*.ts` | Pure functions that map one raw protocol entity to its friendly `T` type. ~30 of them, one per entity. |
23
+ | **`*T` methods** (`storeGetItemsT`, `avatarsGetListT`, `clansGetListT`, …) | `SmarticoAPI` | The "**T**ransformed" variant of a protocol call: send the raw request, then run the matching transform on the response. The `_smartico.api.*` surface is built on these. |
24
+
25
+ **As a consumer you never call transforms directly** — `_smartico.api.*`
26
+ already returns the transformed `T` types. The transforms are the SDK internals
27
+ that produce them. (They are exported from the package, so you *can* reference
28
+ them, but you rarely need to.)
29
+
30
+ ## What a transform actually does
31
+
32
+ Transforms normalize the raw shape in a handful of recurring ways:
33
+
34
+ 1. **Flatten nested metadata** — raw entities bury display fields inside a
35
+ `public_meta` / `*PublicMeta` sub-object; the transform lifts them to the
36
+ top level. (`item.itemPublicMeta.name` → `item.name`.)
37
+ 2. **Normalize casing** — raw fields are inconsistently camelCase
38
+ (`userId`, `userAltName`, `isMe`, `canBuy`); the friendly types are
39
+ consistent snake_case (`user_id`, `public_username`, `is_me`, `can_buy`).
40
+ 3. **Compute convenience fields** — e.g. build an absolute `avatar_url` from a
41
+ relative image path plus the label's avatar domain, so the consumer can use
42
+ it directly in an `<img>`.
43
+ 4. **Resolve opaque ids to named values** — numeric type ids become named enum
44
+ values (e.g. a raw `itemTypeId` becomes a friendly `type`).
45
+ 5. **Parse string-encoded JSON** — fields the server sends as JSON strings
46
+ (e.g. `custom_data`) are parsed into real objects.
47
+ 6. **Drop wire-only / internal fields and junk rows** — the friendly type keeps
48
+ only what a UI needs.
49
+
50
+ ## Before / after example
51
+
52
+ Raw `AvatarDefinition` on the wire (`GET_AVATARS_LIST_RESPONSE`):
53
+
54
+ ```json
55
+ {
56
+ "avatar_real_id": 7,
57
+ "priority": 2,
58
+ "public_meta": { "description": "Knight", "url": "avatars/knight.png" },
59
+ "avatar_source_type_id": 0,
60
+ "is_given": true,
61
+ "is_in_use": false
62
+ }
63
+ ```
64
+
65
+ Friendly `TAvatarDefinition` returned by `_smartico.api.getAvatarsList()`:
66
+
67
+ ```json
68
+ {
69
+ "avatar_real_id": 7,
70
+ "priority": 2,
71
+ "description": "Knight",
72
+ "url": "avatars/knight.png",
73
+ "avatar_url": "https://<avatar-domain>/avatars/knight.png",
74
+ "avatar_source_type_id": 0,
75
+ "is_given": true,
76
+ "is_in_use": false
77
+ }
78
+ ```
79
+
80
+ The transform flattened `public_meta.description` / `public_meta.url` to the top
81
+ level and added the computed absolute `avatar_url`.
82
+
83
+ Casing normalization is most visible in clan-tournament players — the raw
84
+ `players[]` use `userId` / `userAltName` / `isMe`, which the transform renames
85
+ to `user_id` / `public_username` / `is_me`.
86
+
87
+ ## Why this matters for native clients
88
+
89
+ Native clients (Kotlin / Swift) that speak the WebSocket protocol directly —
90
+ see the Native Protocol doc (`docs/native/PROTOCOL.md`) — receive the **raw**
91
+ shapes, not the transformed `T` types. PROTOCOL.md documents those raw shapes precisely
92
+ (nested `public_meta`, camelCase player fields, etc.) and flags where the JS SDK
93
+ adds a computed field (such as `avatar_url`). A native client is responsible for
94
+ doing the equivalent normalization itself if it wants the friendlier shape.
95
+
96
+ In short:
97
+
98
+ - **JS / browser SDK** → call `_smartico.api.*`, get friendly `T` types (transforms applied for you).
99
+ - **Native client** → use the raw protocol from PROTOCOL.md, apply your own mapping.
@@ -1,10 +1,17 @@
1
1
  # Smartico API documentation
2
2
 
3
+ ## Documents
4
+
5
+ - [SmarticoObject](documents/SmarticoObject.md)
6
+ - [Callbacks](documents/Callbacks.md)
7
+ - [Transforms](documents/Transforms.md)
8
+
3
9
  ## Enumerations
4
10
 
5
11
  - [PointChangeSourceType](enumerations/PointChangeSourceType.md)
6
12
  - [UserBalanceType](enumerations/UserBalanceType.md)
7
13
  - [BonusStatus](enumerations/BonusStatus.md)
14
+ - [JoinClanErrorCode](enumerations/JoinClanErrorCode.md)
8
15
  - [ActivityTypeLimited](enumerations/ActivityTypeLimited.md)
9
16
  - [AchCustomSectionType](enumerations/AchCustomSectionType.md)
10
17
  - [AchCustomLayoutTheme](enumerations/AchCustomLayoutTheme.md)
@@ -75,12 +82,20 @@
75
82
 
76
83
  ## Interfaces
77
84
 
85
+ - [PointsLog](interfaces/PointsLog.md)
86
+ - [GemsDiamondsLog](interfaces/GemsDiamondsLog.md)
87
+ - [AvatarCustomized](interfaces/AvatarCustomized.md)
88
+ - [AvatarDefinition](interfaces/AvatarDefinition.md)
89
+ - [AvatarPrompt](interfaces/AvatarPrompt.md)
78
90
  - [AchRelatedGame](interfaces/AchRelatedGame.md)
79
91
  - [Bonus](interfaces/Bonus.md)
80
92
  - [BonusMetaMap](interfaces/BonusMetaMap.md)
81
93
  - [BonusTemplateMetaMap](interfaces/BonusTemplateMetaMap.md)
82
94
  - [ClanPublicMeta](interfaces/ClanPublicMeta.md)
83
95
  - [Clan](interfaces/Clan.md)
96
+ - [ClanMember](interfaces/ClanMember.md)
97
+ - [ClanInfo](interfaces/ClanInfo.md)
98
+ - [GetClanInfoResponse](interfaces/GetClanInfoResponse.md)
84
99
  - [GetCustomSectionsResponse](interfaces/GetCustomSectionsResponse.md)
85
100
  - [UICustomSection](interfaces/UICustomSection.md)
86
101
  - [InboxMessageBody](interfaces/InboxMessageBody.md)
@@ -139,6 +154,11 @@
139
154
  - [GetDrawRunResponse](interfaces/GetDrawRunResponse.md)
140
155
  - [GetRaffleDrawRunsHistoryRequest](interfaces/GetRaffleDrawRunsHistoryRequest.md)
141
156
  - [GetRaffleDrawRunsHistoryResponse](interfaces/GetRaffleDrawRunsHistoryResponse.md)
157
+ - [GetRaffleWonPrizesRequest](interfaces/GetRaffleWonPrizesRequest.md)
158
+ - [RaffleWonPrizePublicMeta](interfaces/RaffleWonPrizePublicMeta.md)
159
+ - [RaffleWonPrize](interfaces/RaffleWonPrize.md)
160
+ - [RaffleWonPrizeUser](interfaces/RaffleWonPrizeUser.md)
161
+ - [GetRaffleWonPrizesResponse](interfaces/GetRaffleWonPrizesResponse.md)
142
162
  - [GetRafflesRequest](interfaces/GetRafflesRequest.md)
143
163
  - [GetRafflesResponse](interfaces/GetRafflesResponse.md)
144
164
  - [RafflePublicMeta](interfaces/RafflePublicMeta.md)
@@ -158,6 +178,10 @@
158
178
  - [StoreCategoryPublicMeta](interfaces/StoreCategoryPublicMeta.md)
159
179
  - [StoreItem](interfaces/StoreItem.md)
160
180
  - [StoreItemPublicMeta](interfaces/StoreItemPublicMeta.md)
181
+ - [ClanTournamentPlayerRaw](interfaces/ClanTournamentPlayerRaw.md)
182
+ - [GetClanTournamentPlayersResponse](interfaces/GetClanTournamentPlayersResponse.md)
183
+ - [TClanTournamentPlayer](interfaces/TClanTournamentPlayer.md)
184
+ - [TClanTournamentPlayersResult](interfaces/TClanTournamentPlayersResult.md)
161
185
  - [GetTournamentInfoResponse](interfaces/GetTournamentInfoResponse.md)
162
186
  - [Tournament](interfaces/Tournament.md)
163
187
  - [ClanLeaderboardEntry](interfaces/ClanLeaderboardEntry.md)
@@ -235,6 +259,7 @@
235
259
 
236
260
  ## Type Aliases
237
261
 
262
+ - [ActivityLogEntry](type-aliases/ActivityLogEntry.md)
238
263
  - [TournamentRegistrationTypeName](type-aliases/TournamentRegistrationTypeName.md)
239
264
 
240
265
  ## Variables
@@ -256,6 +281,7 @@
256
281
  - [StoreCategoryTransform](functions/StoreCategoryTransform.md)
257
282
  - [StoreItemTransform](functions/StoreItemTransform.md)
258
283
  - [StoreItemTypeNamed](functions/StoreItemTypeNamed.md)
284
+ - [clanTournamentPlayersTransform](functions/clanTournamentPlayersTransform.md)
259
285
  - [tournamentInfoItemTransform](functions/tournamentInfoItemTransform.md)
260
286
  - [TournamentItemsTransform](functions/TournamentItemsTransform.md)
261
287
  - [TournamentInstanceStatusName](functions/TournamentInstanceStatusName.md)
@@ -5,97 +5,221 @@
5
5
 
6
6
  > **getAvatarsList**(): `Promise`\<[`TAvatarDefinition`](../interfaces/TAvatarDefinition.md)[]\>
7
7
 
8
- Returns the list of avatars available in the catalog for the current user.
9
- The response includes both free avatars and earned/purchased ones.
10
- Avatars with `hide_until_achieved = true` and `is_given = false` should be hidden from the user.
11
- The result is cached for 30 seconds.
8
+ Returns the avatar catalog available to the current user — every pre-defined
9
+ avatar configured for the label, with per-user unlock flags (`is_given`, `is_in_use`)
10
+ applied server-side.
12
11
 
13
- **Example**:
14
- ```
15
- _smartico.api.getAvatarsList().then((result) => {
16
- console.log(result);
17
- });
18
- ```
19
-
20
- **Visitor mode: not supported**
12
+ The returned `avatar_url` is the absolute CDN URL (the SDK prefixes relative paths
13
+ with the configured avatar domain). AI-customized variants are NOT returned here —
14
+ those live in [getAvatarsCustomized](#getavatarscustomized).
21
15
 
22
16
  #### Returns
23
17
 
24
18
  `Promise`\<[`TAvatarDefinition`](../interfaces/TAvatarDefinition.md)[]\>
25
19
 
20
+ Array of [TAvatarDefinition](../interfaces/TAvatarDefinition.md) — empty array if the feature is disabled
21
+ on the label.
22
+
23
+ #### Remarks
24
+
25
+ **Preconditions**
26
+ - User must be authenticated. Visitor mode is not supported.
27
+ - No other prerequisite calls.
28
+
29
+ **Visibility filter** (consumer-applied)
30
+ Avatars with `hide_until_achieved === true && is_given === false` should be filtered
31
+ out of the grid — they represent surprise unlocks that should remain hidden until
32
+ the user earns them. The default Smartico UI drops these before rendering.
33
+
34
+ **Lock state** (consumer-applied)
35
+ Lock condition: `!is_given && avatar_source_type_id !== 0`. Free avatars
36
+ (`avatar_source_type_id === 0`) are always selectable; non-free avatars are locked
37
+ until `is_given` flips to true (operator grants via campaign, mission reward, store
38
+ purchase, etc.).
39
+
40
+ **Sort order**
41
+ Server does NOT pre-sort. Caller must sort by `priority` ascending (lower = first).
42
+
43
+ **Refresh**
44
+ - The SDK caches results for 30 seconds.
45
+ - [setAvatar](#setavatar) clears this cache on completion; the next call re-fetches.
46
+ - No push subscription — there is no `onUpdate` callback for avatar methods.
47
+ - When `is_given` flips server-side (e.g. the user earns a new avatar), the change
48
+ surfaces only on the next call after the 30-second cache window expires.
49
+
50
+ **Visitor mode**: not supported.
51
+
52
+ **UI guidance**: see [UI Guide — `getAvatarsList`](../_media/UIGuide_getAvatarsList.md).
53
+
54
+ #### Example
55
+
56
+ ```ts
57
+ const avatars = await window._smartico.api.getAvatarsList();
58
+
59
+ // Apply the standard visibility filter and sort.
60
+ const visible = avatars
61
+ .filter((a) => !a.hide_until_achieved || a.is_given)
62
+ .sort((a, b) => a.priority - b.priority);
63
+
64
+ console.log('[smartico] visible avatars:', visible.length, '— render as a grid');
65
+
66
+ const active = visible.find((a) => a.is_in_use);
67
+ if (active) {
68
+ console.log('[smartico] currently in use — overlay a checkmark on this card:', active.avatar_real_id);
69
+ }
70
+ ```
71
+
26
72
  ***
27
73
 
28
74
  ### getAvatarsCustomized()
29
75
 
30
76
  > **getAvatarsCustomized**(): `Promise`\<[`TAvatarCustomized`](../interfaces/TAvatarCustomized.md)[]\>
31
77
 
32
- Returns the list of AI-customized avatars for the current user.
33
- Each entry represents a previously generated AI customization for a specific base avatar.
34
- The result is cached for 30 seconds.
35
-
36
- **Example**:
37
- ```
38
- _smartico.api.getAvatarsCustomized().then((result) => {
39
- console.log(result);
40
- });
41
- ```
78
+ Returns the user's previously generated AI-customized avatar variants.
42
79
 
43
- **Visitor mode: not supported**
80
+ Each entry is one AI-generated image derived from a base avatar in the catalog
81
+ (the base is identified by `avatar_real_id` and was originally a
82
+ [TAvatarDefinition](../interfaces/TAvatarDefinition.md) from [getAvatarsList](#getavatarslist)). These variants are stored
83
+ server-side under the user record and persist across sessions.
44
84
 
45
85
  #### Returns
46
86
 
47
87
  `Promise`\<[`TAvatarCustomized`](../interfaces/TAvatarCustomized.md)[]\>
48
88
 
89
+ Array of [TAvatarCustomized](../interfaces/TAvatarCustomized.md) — empty if the user has never run AI
90
+ customization, or if the feature is disabled on the label.
91
+
92
+ #### Remarks
93
+
94
+ **Preconditions**
95
+ - User must be authenticated. Visitor mode is not supported.
96
+ - Has meaning only after at least one successful AI customization run (see below).
97
+ New users get an empty array.
98
+
99
+ **Where customized avatars come from**
100
+ AI customization is **not** a WebSocket method on this SDK. It is a separate HTTP
101
+ POST to the operator-configured `avatar-customize` endpoint that takes a base avatar
102
+ plus a style prompt from [getAvatarPrompts](#getavatarprompts) and returns a generated CDN URL.
103
+ Once that POST resolves successfully, the new variant is persisted and surfaces in
104
+ the next `getAvatarsCustomized()` call. The variant URL can then be passed to
105
+ [setAvatar](#setavatar) to activate it.
106
+
107
+ **Relation to `getAvatarsList`**
108
+ AI variants do NOT appear in [getAvatarsList](#getavatarslist). Catalog and variants are two
109
+ separate collections — combine them client-side if the UI needs a unified view per
110
+ base avatar.
111
+
112
+ **Sort order**
113
+ Server does NOT pre-sort. Caller typically sorts by `dt_created` descending to show
114
+ the newest variant first.
115
+
116
+ **Refresh**
117
+ - The SDK caches results for 30 seconds.
118
+ - [setAvatar](#setavatar) clears this cache on completion.
119
+ - After a successful AI customization POST, the consumer should re-call to surface
120
+ the new variant — the customization endpoint is outside the SDK so the SDK cannot
121
+ auto-invalidate.
122
+ - No push subscription.
123
+
124
+ **Visitor mode**: not supported.
125
+
126
+ **UI guidance**: see [UI Guide — `getAvatarsCustomized`](../_media/UIGuide_getAvatarsCustomized.md).
127
+
128
+ #### Example
129
+
130
+ ```ts
131
+ const variants = await window._smartico.api.getAvatarsCustomized();
132
+
133
+ // Group by the base avatar so the UI can show "this base has 3 AI variants".
134
+ const byBase = new Map<number, typeof variants>();
135
+ for (const v of variants) {
136
+ const list = byBase.get(v.avatar_real_id) ?? [];
137
+ list.push(v);
138
+ byBase.set(v.avatar_real_id, list);
139
+ }
140
+
141
+ // Newest-first within each base.
142
+ for (const list of byBase.values()) {
143
+ list.sort((a, b) => b.dt_created.localeCompare(a.dt_created));
144
+ }
145
+
146
+ console.log('[smartico] AI variants by base avatar — render as a carousel under each base');
147
+ ```
148
+
49
149
  ***
50
150
 
51
151
  ### getAvatarPrompts()
52
152
 
53
153
  > **getAvatarPrompts**(): `Promise`\<[`TAvatarPrompt`](../interfaces/TAvatarPrompt.md)[]\>
54
154
 
55
- Returns the list of AI customization prompts (styles) available for avatar customization.
56
- Each prompt represents a visual style that can be applied to a base avatar.
57
- The result is cached for 30 seconds.
58
-
59
- **Example**:
60
- ```
61
- _smartico.api.getAvatarPrompts().then((result) => {
62
- console.log(result);
63
- });
64
- ```
155
+ Returns the catalog of AI style prompts available for avatar customization.
65
156
 
66
- **Visitor mode: not supported**
157
+ Each entry is a "style" the user can apply to a base avatar (e.g. "Cartoon",
158
+ "Watercolor", "Cyberpunk"). Prompts carry a cost expressed in points, gems, or
159
+ diamonds — applying a prompt deducts the cost server-side as part of the AI
160
+ generation request.
67
161
 
68
162
  #### Returns
69
163
 
70
164
  `Promise`\<[`TAvatarPrompt`](../interfaces/TAvatarPrompt.md)[]\>
71
165
 
166
+ Array of [TAvatarPrompt](../interfaces/TAvatarPrompt.md) — empty if the AI customization feature is
167
+ disabled on the label.
168
+
169
+ #### Remarks
170
+
171
+ **Preconditions**
172
+ - User must be authenticated. Visitor mode is not supported.
173
+ - No other prerequisite calls. The customization UI typically calls this on demand
174
+ when the user opens the style picker, not on app boot.
175
+
176
+ **Cost handling**
177
+ Each prompt declares `cost_currency_type_id` (0 = points, 1 = gems, 2 = diamonds)
178
+ and `cost_value` (amount). The deduction happens server-side inside the
179
+ `avatar-customize` HTTP POST (the AI generation request, which is NOT part of this
180
+ SDK). The client should compare `cost_value` against the live balance from
181
+ [getUserProfile](WSAPIUser.md#getuserprofile) to disable prompts the user cannot afford, but the server is
182
+ the source of truth and will reject under-funded requests authoritatively.
183
+
184
+ **Refresh**
185
+ - The SDK caches results for 30 seconds.
186
+ - Not invalidated by [setAvatar](#setavatar) (prompts are catalog metadata, independent
187
+ of the user's active avatar).
188
+ - No push subscription.
189
+
190
+ **Visitor mode**: not supported.
191
+
192
+ **UI guidance**: see [UI Guide — `getAvatarPrompts`](../_media/UIGuide_getAvatarPrompts.md).
193
+
194
+ #### Example
195
+
196
+ ```ts
197
+ const [prompts, profile] = await Promise.all([
198
+ window._smartico.api.getAvatarPrompts(),
199
+ window._smartico.api.getUserProfile(),
200
+ ]);
201
+
202
+ for (const p of prompts) {
203
+ // The consumer reads the matching balance from profile based on
204
+ // p.cost_currency_type_id (0=points, 1=gems, 2=diamonds).
205
+ console.log('[smartico] prompt', p.name, '— cost', p.cost_value, 'currency_type', p.cost_currency_type_id);
206
+ }
207
+ ```
208
+
72
209
  ***
73
210
 
74
211
  ### setAvatar()
75
212
 
76
213
  > **setAvatar**(`props`): `Promise`\<[`TSetAvatarResult`](../interfaces/TSetAvatarResult.md)\>
77
214
 
78
- Sets the specified avatar as the active avatar for the current user.
79
- Pass `avatar_url` (the `TAvatarDefinition.url` path or a CDN URL for AI-customized avatars)
80
- and `avatar_real_id` from the avatar catalog.
81
- After a successful call, the avatar list cache is cleared so the next `getAvatarsList()` call reflects `is_in_use`.
215
+ Activates the specified avatar for the current user. The chosen image becomes the
216
+ profile avatar — any subsequent [getUserProfile](WSAPIUser.md#getuserprofile) call will reflect the new
217
+ `avatar_url`.
82
218
 
83
- **Example**:
84
- ```
85
- _smartico.api.getAvatarsList().then((avatars) => {
86
- const avatar = avatars.find((a) => !a.hide_until_achieved || a.is_given);
87
- if (avatar) {
88
- _smartico.api.setAvatar({
89
- avatar_url: avatar.url,
90
- avatar_real_id: avatar.avatar_real_id,
91
- }).then((result) => {
92
- console.log(result);
93
- });
94
- }
95
- });
96
- ```
97
-
98
- **Visitor mode: not supported**
219
+ Pass `avatar_url` (a [TAvatarDefinition.url](../interfaces/TAvatarDefinition.md#url) from the catalog or a
220
+ [TAvatarCustomized.url](../interfaces/TAvatarCustomized.md#url) from the AI-variant list) plus `avatar_real_id` of the
221
+ base avatar. The server validates ownership before applying — locked avatars are
222
+ rejected.
99
223
 
100
224
  #### Parameters
101
225
 
@@ -105,12 +229,116 @@ _smartico.api.getAvatarsList().then((avatars) => {
105
229
 
106
230
  `string`
107
231
 
232
+ Absolute CDN URL of the avatar image. Read from
233
+ [TAvatarDefinition.url](../interfaces/TAvatarDefinition.md#url) for catalog avatars or
234
+ [TAvatarCustomized.url](../interfaces/TAvatarCustomized.md#url) for AI variants.
235
+
108
236
  ###### avatar_real_id
109
237
 
110
238
  `number`
111
239
 
240
+ Numeric ID of the base avatar from
241
+ [TAvatarDefinition.avatar\_real\_id](../interfaces/TAvatarDefinition.md#avatar_real_id). For AI
242
+ variants, this is the `avatar_real_id` of the base
243
+ they were derived from.
244
+
112
245
  #### Returns
113
246
 
114
247
  `Promise`\<[`TSetAvatarResult`](../interfaces/TSetAvatarResult.md)\>
115
248
 
249
+ [TSetAvatarResult](../interfaces/TSetAvatarResult.md) — check `err_code === 0` for success.
250
+
251
+ #### Remarks
252
+
253
+ **Preconditions**
254
+ - User must be authenticated. Visitor mode is not supported.
255
+ - `avatar_url` must be non-empty and `avatar_real_id` must be truthy — the SDK
256
+ throws synchronously otherwise (the request never reaches the server).
257
+ - The avatar must exist in the catalog from [getAvatarsList](#getavatarslist) (or be an AI
258
+ variant of a base avatar the user already owns). Free avatars
259
+ (`avatar_source_type_id === 0`) and the user's currently active avatar bypass the
260
+ ownership check; all others require `is_given === true`.
261
+
262
+ **Error codes** (in `err_code`)
263
+ - `0` — success; cache is cleared and the profile avatar updates immediately.
264
+ - `1` — avatar not found in the catalog. The `avatar_real_id` doesn't exist for
265
+ this label.
266
+ - `2` — avatar inactive (deactivated by the operator).
267
+ - `3` — outside the avatar's active time window
268
+ (`active_from_date` / `active_till_date`).
269
+ - `4` — user does not own this avatar (it isn't in their `is_given` set and isn't
270
+ a free / default avatar).
271
+ - other non-zero — generic server error; surface `err_message` if present.
272
+
273
+ The default Smartico UI shows a hardcoded "Failed to apply avatar" toast on any
274
+ non-zero `err_code` and does not surface `err_message`. Custom UIs SHOULD branch
275
+ on the code and prefer `err_message` when present (it is the localized server
276
+ string).
277
+
278
+ **Refresh after success**
279
+ - The SDK clears both the `getAvatarsList` and `getAvatarsCustomized` caches —
280
+ the next call to either returns fresh data with the new `is_in_use` flag set on
281
+ the chosen avatar.
282
+ - The server persists the new avatar URL on the user record; [getUserProfile](WSAPIUser.md#getuserprofile)
283
+ reflects it on the next read in this session.
284
+ - **No push to other open sessions.** A second device / tab the user is logged in
285
+ on will not see the new avatar until it next calls [getUserProfile](WSAPIUser.md#getuserprofile) or
286
+ re-identifies. Plan UI accordingly.
287
+
288
+ **Idempotency**: safe to retry. Re-applying the same `avatar_real_id` returns
289
+ `err_code: 0` and produces no double side effects (no double-deduction — this
290
+ method does not charge any currency — and no duplicate log entries).
291
+
292
+ **Side effects**: updates the user's stored `avatar_id` / `avatar_real_id`. Does
293
+ NOT cost points, gems, or diamonds — the cost lives on the separate AI
294
+ customization HTTP flow ([getAvatarPrompts](#getavatarprompts)). Does NOT write a user-visible
295
+ entry to [getActivityLog](#getactivitylog).
296
+
297
+ **UI guidance**: see [UI Guide — `setAvatar`](../_media/UIGuide_setAvatar.md).
298
+
299
+ **Visitor mode**: not supported.
300
+
301
+ #### Example
302
+
303
+ ```ts
304
+ const avatars = await window._smartico.api.getAvatarsList();
305
+ const target = avatars.find((a) => a.avatar_real_id === 7);
306
+
307
+ if (!target) {
308
+ console.error('[smartico] avatar 7 not in catalog — hide the picker entry');
309
+ return;
310
+ }
311
+
312
+ const isLocked = !target.is_given && target.avatar_source_type_id !== 0;
313
+ if (isLocked) {
314
+ console.log('[smartico] avatar is locked — show "earn this first" prompt instead of calling setAvatar');
315
+ return;
316
+ }
317
+
318
+ const r = await window._smartico.api.setAvatar({
319
+ avatar_url: target.avatar_url,
320
+ avatar_real_id: target.avatar_real_id,
321
+ });
322
+
323
+ switch (r.err_code) {
324
+ case 0:
325
+ console.log('[smartico] avatar applied — close picker, refresh header avatar');
326
+ break;
327
+ case 1:
328
+ console.error('[smartico] avatar not in catalog — refresh catalog and show error');
329
+ break;
330
+ case 2:
331
+ console.error('[smartico] avatar inactive — operator disabled it; hide from picker');
332
+ break;
333
+ case 3:
334
+ console.error('[smartico] outside time window — show "available on X" message');
335
+ break;
336
+ case 4:
337
+ console.error('[smartico] not owned — show unlock requirements');
338
+ break;
339
+ default:
340
+ console.error('[smartico] avatar apply failed — show generic error toast:', r.err_message);
341
+ }
342
+ ```
343
+
116
344
  ***