@smartico/public-api 0.0.379 → 0.0.381

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 (219) hide show
  1. package/.nvmrc +1 -1
  2. package/CLAUDE.md +103 -0
  3. package/README.md +53 -2
  4. package/dist/Base/ClassId.d.ts +2 -0
  5. package/dist/Jackpots/JackpotDetails.d.ts +14 -15
  6. package/dist/Jackpots/JackpotPot.d.ts +10 -6
  7. package/dist/Raffle/GetRaffleWonPrizesRequest.d.ts +9 -0
  8. package/dist/Raffle/GetRaffleWonPrizesResponse.d.ts +52 -0
  9. package/dist/Raffle/index.d.ts +2 -0
  10. package/dist/SmarticoAPI.d.ts +6 -1
  11. package/dist/SmarticoLib/index.d.ts +5 -1
  12. package/dist/Store/BuyStoreItemErrorCode.d.ts +9 -1
  13. package/dist/Tournaments/TournamentRegistrationError.d.ts +3 -1
  14. package/dist/WSAPI/WSAPI.d.ts +13 -1235
  15. package/dist/WSAPI/WSAPIAvatars.d.ts +296 -0
  16. package/dist/WSAPI/WSAPIBase.d.ts +71 -0
  17. package/dist/WSAPI/WSAPIBonuses.d.ts +240 -0
  18. package/dist/WSAPI/WSAPIClans.d.ts +388 -0
  19. package/dist/WSAPI/WSAPIGamePick.d.ts +593 -0
  20. package/dist/WSAPI/WSAPIGeneral.d.ts +172 -0
  21. package/dist/WSAPI/WSAPIInbox.d.ts +615 -0
  22. package/dist/WSAPI/WSAPIJackpots.d.ts +344 -0
  23. package/dist/WSAPI/WSAPILeaderBoard.d.ts +139 -0
  24. package/dist/WSAPI/WSAPIMiniGames.d.ts +510 -0
  25. package/dist/WSAPI/WSAPIMissions.d.ts +517 -0
  26. package/dist/WSAPI/WSAPIRaffles.d.ts +643 -0
  27. package/dist/WSAPI/WSAPIStore.d.ts +656 -0
  28. package/dist/WSAPI/WSAPITournaments.d.ts +501 -0
  29. package/dist/WSAPI/WSAPITypes.d.ts +376 -205
  30. package/dist/WSAPI/WSAPIUser.d.ts +533 -0
  31. package/dist/index.js +6745 -1661
  32. package/dist/index.js.map +1 -1
  33. package/dist/index.modern.mjs +6324 -1342
  34. package/dist/index.modern.mjs.map +1 -1
  35. package/docs/Callbacks.md +162 -0
  36. package/docs/SmarticoObject.md +445 -0
  37. package/docs/Transforms.md +99 -0
  38. package/docs/api/README.md +82 -2
  39. package/docs/api/classes/WSAPIAvatars.md +344 -0
  40. package/docs/api/classes/WSAPIBonuses.md +271 -0
  41. package/docs/api/classes/WSAPIClans.md +436 -0
  42. package/docs/api/classes/WSAPIGamePick.md +710 -0
  43. package/docs/api/classes/WSAPIGeneral.md +212 -0
  44. package/docs/api/classes/WSAPIInbox.md +801 -0
  45. package/docs/api/classes/WSAPIJackpots.md +439 -0
  46. package/docs/api/classes/WSAPILeaderBoard.md +157 -0
  47. package/docs/api/classes/WSAPIMiniGames.md +612 -0
  48. package/docs/api/classes/WSAPIMissions.md +590 -0
  49. package/docs/api/classes/WSAPIRaffles.md +773 -0
  50. package/docs/api/classes/WSAPIStore.md +719 -0
  51. package/docs/api/classes/WSAPITournaments.md +571 -0
  52. package/docs/api/classes/WSAPIUser.md +637 -0
  53. package/docs/api/documents/Callbacks.md +162 -0
  54. package/docs/api/documents/SmarticoObject.md +445 -0
  55. package/docs/api/documents/Transforms.md +99 -0
  56. package/docs/api/enumerations/AchievementClaimPeriodTypeId.md +13 -0
  57. package/docs/api/enumerations/BonusStatus-1.md +11 -6
  58. package/docs/api/enumerations/BuyStoreItemErrorCode.md +32 -0
  59. package/docs/api/enumerations/JoinClanErrorCode.md +81 -0
  60. package/docs/api/enumerations/TournamentRegistrationError.md +12 -0
  61. package/docs/api/functions/clanTournamentPlayersTransform.md +13 -0
  62. package/docs/api/interfaces/AvatarCustomized.md +25 -0
  63. package/docs/api/interfaces/AvatarDefinition.md +94 -0
  64. package/docs/api/interfaces/AvatarPrompt.md +45 -0
  65. package/docs/api/interfaces/BonusMetaMap-1.md +4 -1
  66. package/docs/api/interfaces/BonusTemplateMetaMap-1.md +9 -4
  67. package/docs/api/interfaces/Clan.md +4 -0
  68. package/docs/api/interfaces/ClanInfo.md +109 -0
  69. package/docs/api/interfaces/ClanMember.md +53 -0
  70. package/docs/api/interfaces/ClanPrizePublicMeta.md +41 -0
  71. package/docs/api/interfaces/ClanPrizeStructureEntry.md +7 -1
  72. package/docs/api/interfaces/ClanPublicMeta.md +4 -0
  73. package/docs/api/interfaces/ClanTournamentPlayerRaw.md +67 -0
  74. package/docs/api/interfaces/GemsDiamondsLog.md +43 -0
  75. package/docs/api/interfaces/GetClanInfoResponse.md +61 -0
  76. package/docs/api/interfaces/GetClanTournamentPlayersResponse.md +81 -0
  77. package/docs/api/interfaces/GetRaffleWonPrizesRequest.md +59 -0
  78. package/docs/api/interfaces/GetRaffleWonPrizesResponse.md +95 -0
  79. package/docs/api/interfaces/InboxMarkMessageAction.md +10 -2
  80. package/docs/api/interfaces/JackpotDetails.md +14 -15
  81. package/docs/api/interfaces/JackpotPot.md +9 -6
  82. package/docs/api/interfaces/LeaderBoardDetailsT.md +14 -8
  83. package/docs/api/interfaces/LeaderBoardUserT.md +8 -5
  84. package/docs/api/interfaces/LeaderBoardsRewardsT.md +7 -0
  85. package/docs/api/interfaces/PointsLog.md +43 -0
  86. package/docs/api/interfaces/RaffleWonPrize.md +59 -0
  87. package/docs/api/interfaces/RaffleWonPrizePublicMeta.md +27 -0
  88. package/docs/api/interfaces/RaffleWonPrizeUser.md +43 -0
  89. package/docs/api/interfaces/SAWTemplateUI.md +10 -0
  90. package/docs/api/interfaces/TAchCategory.md +14 -4
  91. package/docs/api/interfaces/TAvatarCustomized.md +4 -4
  92. package/docs/api/interfaces/TAvatarDefinition.md +13 -14
  93. package/docs/api/interfaces/TAvatarPrompt.md +6 -6
  94. package/docs/api/interfaces/TBonus.md +16 -8
  95. package/docs/api/interfaces/TBuyStoreItemResult.md +4 -11
  96. package/docs/api/interfaces/TClaimBonusResult.md +5 -5
  97. package/docs/api/interfaces/TClan.md +8 -4
  98. package/docs/api/interfaces/TClanInfo.md +47 -0
  99. package/docs/api/interfaces/TClanJoinResult.md +11 -1
  100. package/docs/api/interfaces/TClanTournamentPlayer.md +55 -0
  101. package/docs/api/interfaces/TClanTournamentPlayersResult.md +27 -0
  102. package/docs/api/interfaces/TClans.md +3 -1
  103. package/docs/api/interfaces/TGetTranslations.md +4 -0
  104. package/docs/api/interfaces/TInboxMessage.md +14 -6
  105. package/docs/api/interfaces/TInboxMessageBody.md +18 -12
  106. package/docs/api/interfaces/TLevel.md +17 -20
  107. package/docs/api/interfaces/TLevelCurrent.md +19 -18
  108. package/docs/api/interfaces/TMiniGamePlayBatchResult.md +14 -6
  109. package/docs/api/interfaces/TMiniGamePlayResult.md +9 -4
  110. package/docs/api/interfaces/TMissionClaimRewardResult.md +6 -3
  111. package/docs/api/interfaces/TMissionOptInResult.md +6 -3
  112. package/docs/api/interfaces/TMissionOrBadge.md +5 -4
  113. package/docs/api/interfaces/TRaffleOptinResponse.md +4 -2
  114. package/docs/api/interfaces/TSegmentCheckResult.md +10 -0
  115. package/docs/api/interfaces/TSetAvatarResult.md +3 -3
  116. package/docs/api/interfaces/TStoreItem.md +11 -1
  117. package/docs/api/interfaces/TTournament.md +1 -1
  118. package/docs/api/interfaces/TTournamentDetailed.md +9 -1
  119. package/docs/api/interfaces/TTournamentRegistrationResult.md +4 -2
  120. package/docs/api/interfaces/TUICustomSection.md +23 -19
  121. package/docs/api/interfaces/TUserProfile.md +18 -16
  122. package/docs/api/interfaces/TransformedRaffleClaimPrizeResponse.md +6 -2
  123. package/docs/api/interfaces/UserAchievement.md +1 -1
  124. package/docs/api/interfaces/UserLevelExtraCountersT.md +9 -2
  125. package/docs/api/type-aliases/ActivityLogEntry.md +3 -0
  126. package/docs/native/ADDING_METHODS.md +7 -2
  127. package/docs/native/PROTOCOL.md +337 -0
  128. package/docs/ui/avatars/UIGuide_getAvatarPrompts.md +100 -0
  129. package/docs/ui/avatars/UIGuide_getAvatarsCustomized.md +90 -0
  130. package/docs/ui/avatars/UIGuide_getAvatarsList.md +105 -0
  131. package/docs/ui/avatars/UIGuide_setAvatar.md +118 -0
  132. package/docs/ui/bonuses/UIGuide_claimBonus.md +144 -0
  133. package/docs/ui/bonuses/UIGuide_getBonuses.md +176 -0
  134. package/docs/ui/clans/UIGuide_getClanInfo.md +153 -0
  135. package/docs/ui/clans/UIGuide_getClans.md +172 -0
  136. package/docs/ui/clans/UIGuide_joinClan.md +196 -0
  137. package/docs/ui/gamepick/UIGuide_gamePickGetActiveRound.md +99 -0
  138. package/docs/ui/gamepick/UIGuide_gamePickGetActiveRounds.md +76 -0
  139. package/docs/ui/gamepick/UIGuide_gamePickGetBoard.md +81 -0
  140. package/docs/ui/gamepick/UIGuide_gamePickGetGameInfo.md +78 -0
  141. package/docs/ui/gamepick/UIGuide_gamePickGetHistory.md +55 -0
  142. package/docs/ui/gamepick/UIGuide_gamePickGetRoundInfoForUser.md +71 -0
  143. package/docs/ui/gamepick/UIGuide_gamePickGetUserInfo.md +64 -0
  144. package/docs/ui/gamepick/UIGuide_gamePickSubmitSelection.md +103 -0
  145. package/docs/ui/gamepick/UIGuide_gamePickSubmitSelectionQuiz.md +67 -0
  146. package/docs/ui/general/UIGuide_getCustomSections.md +137 -0
  147. package/docs/ui/general/UIGuide_getRelatedItemsForGame.md +140 -0
  148. package/docs/ui/inbox/UIGuide_deleteInboxMessage.md +135 -0
  149. package/docs/ui/inbox/UIGuide_getInboxMessageBody.md +133 -0
  150. package/docs/ui/inbox/UIGuide_getInboxMessages.md +186 -0
  151. package/docs/ui/inbox/UIGuide_markInboxMessageAsRead.md +122 -0
  152. package/docs/ui/inbox/UIGuide_markUnmarkInboxMessageAsFavorite.md +84 -0
  153. package/docs/ui/jackpots/UIGuide_getJackpotEligibleGames.md +73 -0
  154. package/docs/ui/jackpots/UIGuide_getJackpotWinners.md +83 -0
  155. package/docs/ui/jackpots/UIGuide_jackpotGet.md +138 -0
  156. package/docs/ui/jackpots/UIGuide_jackpotOptIn.md +85 -0
  157. package/docs/ui/jackpots/UIGuide_jackpotOptOut.md +65 -0
  158. package/docs/ui/leaderboard/UIGuide_getLeaderBoard.md +166 -0
  159. package/docs/ui/minigames/UIGuide_getMiniGames.md +153 -0
  160. package/docs/ui/minigames/UIGuide_getMiniGamesHistory.md +90 -0
  161. package/docs/ui/minigames/UIGuide_playMiniGame.md +150 -0
  162. package/docs/ui/minigames/UIGuide_playMiniGameBatch.md +128 -0
  163. package/docs/ui/missions/UIGuide_getAchCategories.md +17 -0
  164. package/docs/ui/missions/UIGuide_getBadges.md +237 -0
  165. package/docs/ui/missions/UIGuide_getMissions.md +268 -0
  166. package/docs/ui/missions/UIGuide_requestMissionClaimReward.md +21 -0
  167. package/docs/ui/missions/UIGuide_requestMissionOptIn.md +16 -0
  168. package/docs/ui/raffles/UIGuide_claimRafflePrize.md +99 -0
  169. package/docs/ui/raffles/UIGuide_getRaffleDrawRun.md +117 -0
  170. package/docs/ui/raffles/UIGuide_getRaffleDrawRunsHistory.md +92 -0
  171. package/docs/ui/raffles/UIGuide_getRaffleWonPrizes.md +120 -0
  172. package/docs/ui/raffles/UIGuide_getRaffles.md +175 -0
  173. package/docs/ui/raffles/UIGuide_requestRaffleOptin.md +114 -0
  174. package/docs/ui/store/UIGuide_buyStoreItem.md +133 -0
  175. package/docs/ui/store/UIGuide_getStoreCategories.md +19 -0
  176. package/docs/ui/store/UIGuide_getStoreItems.md +264 -0
  177. package/docs/ui/store/UIGuide_getStorePurchasedItems.md +122 -0
  178. package/docs/ui/tournaments/UIGuide_getClanTournamentPlayers.md +140 -0
  179. package/docs/ui/tournaments/UIGuide_getTournamentInstanceInfo.md +265 -0
  180. package/docs/ui/tournaments/UIGuide_getTournamentsList.md +236 -0
  181. package/docs/ui/tournaments/UIGuide_registerInTournament.md +156 -0
  182. package/docs/ui/user/UIGuide_getActivityLog.md +130 -0
  183. package/docs/ui/user/UIGuide_getLevels.md +167 -0
  184. package/docs/ui/user/UIGuide_getUserProfile.md +213 -0
  185. package/package.json +3 -3
  186. package/scripts/postdoc-cleanup.js +195 -0
  187. package/src/Base/ClassId.ts +2 -0
  188. package/src/Jackpots/JackpotDetails.ts +14 -15
  189. package/src/Jackpots/JackpotPot.ts +10 -6
  190. package/src/Missions/MissionsUtils.ts +5 -2
  191. package/src/Raffle/GetRaffleWonPrizesRequest.ts +12 -0
  192. package/src/Raffle/GetRaffleWonPrizesResponse.ts +56 -0
  193. package/src/Raffle/index.ts +3 -1
  194. package/src/SmarticoAPI.ts +14 -1
  195. package/src/SmarticoLib/index.ts +4 -0
  196. package/src/Store/BuyStoreItemErrorCode.ts +8 -0
  197. package/src/Store/StoreItem.ts +1 -0
  198. package/src/Store/StoreItemPurchased.ts +1 -0
  199. package/src/Store/StoreItemType.ts +1 -1
  200. package/src/Tournaments/TournamentRegistrationError.ts +4 -0
  201. package/src/WSAPI/WSAPI.ts +27 -2007
  202. package/src/WSAPI/WSAPIAvatars.ts +345 -0
  203. package/src/WSAPI/WSAPIBase.ts +93 -0
  204. package/src/WSAPI/WSAPIBonuses.ts +268 -0
  205. package/src/WSAPI/WSAPIClans.ts +417 -0
  206. package/src/WSAPI/WSAPIGamePick.ts +667 -0
  207. package/src/WSAPI/WSAPIGeneral.ts +199 -0
  208. package/src/WSAPI/WSAPIInbox.ts +711 -0
  209. package/src/WSAPI/WSAPIJackpots.ts +448 -0
  210. package/src/WSAPI/WSAPILeaderBoard.ts +154 -0
  211. package/src/WSAPI/WSAPIMiniGames.ts +597 -0
  212. package/src/WSAPI/WSAPIMissions.ts +572 -0
  213. package/src/WSAPI/WSAPIRaffles.ts +703 -0
  214. package/src/WSAPI/WSAPIStore.ts +732 -0
  215. package/src/WSAPI/WSAPITournaments.ts +541 -0
  216. package/src/WSAPI/WSAPITypes.ts +376 -207
  217. package/src/WSAPI/WSAPIUser.ts +606 -0
  218. package/tsconfig.json +26 -2
  219. package/docs/api/classes/WSAPI.md +0 -1927
@@ -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)
@@ -40,6 +47,7 @@
40
47
  - [SAWWheelLayout](enumerations/SAWWheelLayout.md)
41
48
  - [SAWWinSoundType](enumerations/SAWWinSoundType.md)
42
49
  - [AchievementAvailabilityStatus](enumerations/AchievementAvailabilityStatus.md)
50
+ - [AchievementClaimPeriodTypeId](enumerations/AchievementClaimPeriodTypeId.md)
43
51
  - [AchievementStatus](enumerations/AchievementStatus.md)
44
52
  - [AchievementTaskType](enumerations/AchievementTaskType.md)
45
53
  - [AchievementType](enumerations/AchievementType.md)
@@ -74,12 +82,20 @@
74
82
 
75
83
  ## Interfaces
76
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)
77
90
  - [AchRelatedGame](interfaces/AchRelatedGame.md)
78
91
  - [Bonus](interfaces/Bonus.md)
79
92
  - [BonusMetaMap](interfaces/BonusMetaMap.md)
80
93
  - [BonusTemplateMetaMap](interfaces/BonusTemplateMetaMap.md)
81
94
  - [ClanPublicMeta](interfaces/ClanPublicMeta.md)
82
95
  - [Clan](interfaces/Clan.md)
96
+ - [ClanMember](interfaces/ClanMember.md)
97
+ - [ClanInfo](interfaces/ClanInfo.md)
98
+ - [GetClanInfoResponse](interfaces/GetClanInfoResponse.md)
83
99
  - [GetCustomSectionsResponse](interfaces/GetCustomSectionsResponse.md)
84
100
  - [UICustomSection](interfaces/UICustomSection.md)
85
101
  - [InboxMessageBody](interfaces/InboxMessageBody.md)
@@ -138,6 +154,11 @@
138
154
  - [GetDrawRunResponse](interfaces/GetDrawRunResponse.md)
139
155
  - [GetRaffleDrawRunsHistoryRequest](interfaces/GetRaffleDrawRunsHistoryRequest.md)
140
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)
141
162
  - [GetRafflesRequest](interfaces/GetRafflesRequest.md)
142
163
  - [GetRafflesResponse](interfaces/GetRafflesResponse.md)
143
164
  - [RafflePublicMeta](interfaces/RafflePublicMeta.md)
@@ -157,9 +178,14 @@
157
178
  - [StoreCategoryPublicMeta](interfaces/StoreCategoryPublicMeta.md)
158
179
  - [StoreItem](interfaces/StoreItem.md)
159
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)
160
185
  - [GetTournamentInfoResponse](interfaces/GetTournamentInfoResponse.md)
161
186
  - [Tournament](interfaces/Tournament.md)
162
187
  - [ClanLeaderboardEntry](interfaces/ClanLeaderboardEntry.md)
188
+ - [ClanPrizePublicMeta](interfaces/ClanPrizePublicMeta.md)
163
189
  - [ClanPrizeTier](interfaces/ClanPrizeTier.md)
164
190
  - [ClanPrizeStructureEntry](interfaces/ClanPrizeStructureEntry.md)
165
191
  - [TournamentPlayer](interfaces/TournamentPlayer.md)
@@ -233,6 +259,7 @@
233
259
 
234
260
  ## Type Aliases
235
261
 
262
+ - [ActivityLogEntry](type-aliases/ActivityLogEntry.md)
236
263
  - [TournamentRegistrationTypeName](type-aliases/TournamentRegistrationTypeName.md)
237
264
 
238
265
  ## Variables
@@ -254,10 +281,63 @@
254
281
  - [StoreCategoryTransform](functions/StoreCategoryTransform.md)
255
282
  - [StoreItemTransform](functions/StoreItemTransform.md)
256
283
  - [StoreItemTypeNamed](functions/StoreItemTypeNamed.md)
284
+ - [clanTournamentPlayersTransform](functions/clanTournamentPlayersTransform.md)
257
285
  - [tournamentInfoItemTransform](functions/tournamentInfoItemTransform.md)
258
286
  - [TournamentItemsTransform](functions/TournamentItemsTransform.md)
259
287
  - [TournamentInstanceStatusName](functions/TournamentInstanceStatusName.md)
260
288
 
261
- ## General API
289
+ ## Avatars
290
+
291
+ - [WSAPIAvatars](classes/WSAPIAvatars.md)
292
+
293
+ ## Bonuses
294
+
295
+ - [WSAPIBonuses](classes/WSAPIBonuses.md)
296
+
297
+ ## Clans
298
+
299
+ - [WSAPIClans](classes/WSAPIClans.md)
300
+
301
+ ## GamePick
302
+
303
+ - [WSAPIGamePick](classes/WSAPIGamePick.md)
304
+
305
+ ## General
306
+
307
+ - [WSAPIGeneral](classes/WSAPIGeneral.md)
308
+
309
+ ## Inbox
310
+
311
+ - [WSAPIInbox](classes/WSAPIInbox.md)
312
+
313
+ ## Jackpots
314
+
315
+ - [WSAPIJackpots](classes/WSAPIJackpots.md)
316
+
317
+ ## LeaderBoard
318
+
319
+ - [WSAPILeaderBoard](classes/WSAPILeaderBoard.md)
320
+
321
+ ## MiniGames
322
+
323
+ - [WSAPIMiniGames](classes/WSAPIMiniGames.md)
324
+
325
+ ## Missions
326
+
327
+ - [WSAPIMissions](classes/WSAPIMissions.md)
328
+
329
+ ## Raffles
330
+
331
+ - [WSAPIRaffles](classes/WSAPIRaffles.md)
332
+
333
+ ## Store
334
+
335
+ - [WSAPIStore](classes/WSAPIStore.md)
336
+
337
+ ## Tournaments
338
+
339
+ - [WSAPITournaments](classes/WSAPITournaments.md)
340
+
341
+ ## User
262
342
 
263
- - [WSAPI](classes/WSAPI.md)
343
+ - [WSAPIUser](classes/WSAPIUser.md)
@@ -0,0 +1,344 @@
1
+ # Class: WSAPIAvatars
2
+ ## Methods
3
+
4
+ ### getAvatarsList()
5
+
6
+ > **getAvatarsList**(): `Promise`\<[`TAvatarDefinition`](../interfaces/TAvatarDefinition.md)[]\>
7
+
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.
11
+
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).
15
+
16
+ #### Returns
17
+
18
+ `Promise`\<[`TAvatarDefinition`](../interfaces/TAvatarDefinition.md)[]\>
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
+
72
+ ***
73
+
74
+ ### getAvatarsCustomized()
75
+
76
+ > **getAvatarsCustomized**(): `Promise`\<[`TAvatarCustomized`](../interfaces/TAvatarCustomized.md)[]\>
77
+
78
+ Returns the user's previously generated AI-customized avatar variants.
79
+
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.
84
+
85
+ #### Returns
86
+
87
+ `Promise`\<[`TAvatarCustomized`](../interfaces/TAvatarCustomized.md)[]\>
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
+
149
+ ***
150
+
151
+ ### getAvatarPrompts()
152
+
153
+ > **getAvatarPrompts**(): `Promise`\<[`TAvatarPrompt`](../interfaces/TAvatarPrompt.md)[]\>
154
+
155
+ Returns the catalog of AI style prompts available for avatar customization.
156
+
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.
161
+
162
+ #### Returns
163
+
164
+ `Promise`\<[`TAvatarPrompt`](../interfaces/TAvatarPrompt.md)[]\>
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
+
209
+ ***
210
+
211
+ ### setAvatar()
212
+
213
+ > **setAvatar**(`props`): `Promise`\<[`TSetAvatarResult`](../interfaces/TSetAvatarResult.md)\>
214
+
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`.
218
+
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.
223
+
224
+ #### Parameters
225
+
226
+ ##### props
227
+
228
+ ###### avatar_url
229
+
230
+ `string`
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
+
236
+ ###### avatar_real_id
237
+
238
+ `number`
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
+
245
+ #### Returns
246
+
247
+ `Promise`\<[`TSetAvatarResult`](../interfaces/TSetAvatarResult.md)\>
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
+
344
+ ***