@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,296 @@
1
+ import { TAvatarDefinition, TAvatarCustomized, TAvatarPrompt, TSetAvatarResult } from './WSAPITypes';
2
+ import { WSAPIMiniGames } from './WSAPIMiniGames';
3
+ /** @group Avatars */
4
+ export declare class WSAPIAvatars extends WSAPIMiniGames {
5
+ /**
6
+ * Returns the avatar catalog available to the current user — every pre-defined
7
+ * avatar configured for the label, with per-user unlock flags (`is_given`, `is_in_use`)
8
+ * applied server-side.
9
+ *
10
+ * The returned `avatar_url` is the absolute CDN URL (the SDK prefixes relative paths
11
+ * with the configured avatar domain). AI-customized variants are NOT returned here —
12
+ * those live in {@link getAvatarsCustomized}.
13
+ *
14
+ * @remarks
15
+ * **Preconditions**
16
+ * - User must be authenticated. Visitor mode is not supported.
17
+ * - No other prerequisite calls.
18
+ *
19
+ * **Visibility filter** (consumer-applied)
20
+ * Avatars with `hide_until_achieved === true && is_given === false` should be filtered
21
+ * out of the grid — they represent surprise unlocks that should remain hidden until
22
+ * the user earns them. The default Smartico UI drops these before rendering.
23
+ *
24
+ * **Lock state** (consumer-applied)
25
+ * Lock condition: `!is_given && avatar_source_type_id !== 0`. Free avatars
26
+ * (`avatar_source_type_id === 0`) are always selectable; non-free avatars are locked
27
+ * until `is_given` flips to true (operator grants via campaign, mission reward, store
28
+ * purchase, etc.).
29
+ *
30
+ * **Sort order**
31
+ * Server does NOT pre-sort. Caller must sort by `priority` ascending (lower = first).
32
+ *
33
+ * **Refresh**
34
+ * - The SDK caches results for 30 seconds.
35
+ * - {@link setAvatar} clears this cache on completion; the next call re-fetches.
36
+ * - No push subscription — there is no `onUpdate` callback for avatar methods.
37
+ * - When `is_given` flips server-side (e.g. the user earns a new avatar), the change
38
+ * surfaces only on the next call after the 30-second cache window expires.
39
+ *
40
+ * **Visitor mode**: not supported.
41
+ *
42
+ * **UI guidance**: see [UI Guide — `getAvatarsList`](../../docs/ui/avatars/UIGuide_getAvatarsList.md).
43
+ *
44
+ * @returns Array of {@link TAvatarDefinition} — empty array if the feature is disabled
45
+ * on the label.
46
+ *
47
+ * @example
48
+ * ```ts
49
+ * const avatars = await window._smartico.api.getAvatarsList();
50
+ *
51
+ * // Apply the standard visibility filter and sort.
52
+ * const visible = avatars
53
+ * .filter((a) => !a.hide_until_achieved || a.is_given)
54
+ * .sort((a, b) => a.priority - b.priority);
55
+ *
56
+ * console.log('[smartico] visible avatars:', visible.length, '— render as a grid');
57
+ *
58
+ * const active = visible.find((a) => a.is_in_use);
59
+ * if (active) {
60
+ * console.log('[smartico] currently in use — overlay a checkmark on this card:', active.avatar_real_id);
61
+ * }
62
+ * ```
63
+ */
64
+ getAvatarsList(): Promise<TAvatarDefinition[]>;
65
+ /**
66
+ * Returns the user's previously generated AI-customized avatar variants.
67
+ *
68
+ * Each entry is one AI-generated image derived from a base avatar in the catalog
69
+ * (the base is identified by `avatar_real_id` and was originally a
70
+ * {@link TAvatarDefinition} from {@link getAvatarsList}). These variants are stored
71
+ * server-side under the user record and persist across sessions.
72
+ *
73
+ * @remarks
74
+ * **Preconditions**
75
+ * - User must be authenticated. Visitor mode is not supported.
76
+ * - Has meaning only after at least one successful AI customization run (see below).
77
+ * New users get an empty array.
78
+ *
79
+ * **Where customized avatars come from**
80
+ * AI customization is **not** a WebSocket method on this SDK. It is a separate HTTP
81
+ * POST to the operator-configured `avatar-customize` endpoint that takes a base avatar
82
+ * plus a style prompt from {@link getAvatarPrompts} and returns a generated CDN URL.
83
+ * Once that POST resolves successfully, the new variant is persisted and surfaces in
84
+ * the next `getAvatarsCustomized()` call. The variant URL can then be passed to
85
+ * {@link setAvatar} to activate it.
86
+ *
87
+ * **Relation to `getAvatarsList`**
88
+ * AI variants do NOT appear in {@link getAvatarsList}. Catalog and variants are two
89
+ * separate collections — combine them client-side if the UI needs a unified view per
90
+ * base avatar.
91
+ *
92
+ * **Sort order**
93
+ * Server does NOT pre-sort. Caller typically sorts by `dt_created` descending to show
94
+ * the newest variant first.
95
+ *
96
+ * **Refresh**
97
+ * - The SDK caches results for 30 seconds.
98
+ * - {@link setAvatar} clears this cache on completion.
99
+ * - After a successful AI customization POST, the consumer should re-call to surface
100
+ * the new variant — the customization endpoint is outside the SDK so the SDK cannot
101
+ * auto-invalidate.
102
+ * - No push subscription.
103
+ *
104
+ * **Visitor mode**: not supported.
105
+ *
106
+ * **UI guidance**: see [UI Guide — `getAvatarsCustomized`](../../docs/ui/avatars/UIGuide_getAvatarsCustomized.md).
107
+ *
108
+ * @returns Array of {@link TAvatarCustomized} — empty if the user has never run AI
109
+ * customization, or if the feature is disabled on the label.
110
+ *
111
+ * @example
112
+ * ```ts
113
+ * const variants = await window._smartico.api.getAvatarsCustomized();
114
+ *
115
+ * // Group by the base avatar so the UI can show "this base has 3 AI variants".
116
+ * const byBase = new Map<number, typeof variants>();
117
+ * for (const v of variants) {
118
+ * const list = byBase.get(v.avatar_real_id) ?? [];
119
+ * list.push(v);
120
+ * byBase.set(v.avatar_real_id, list);
121
+ * }
122
+ *
123
+ * // Newest-first within each base.
124
+ * for (const list of byBase.values()) {
125
+ * list.sort((a, b) => b.dt_created.localeCompare(a.dt_created));
126
+ * }
127
+ *
128
+ * console.log('[smartico] AI variants by base avatar — render as a carousel under each base');
129
+ * ```
130
+ */
131
+ getAvatarsCustomized(): Promise<TAvatarCustomized[]>;
132
+ /**
133
+ * Returns the catalog of AI style prompts available for avatar customization.
134
+ *
135
+ * Each entry is a "style" the user can apply to a base avatar (e.g. "Cartoon",
136
+ * "Watercolor", "Cyberpunk"). Prompts carry a cost expressed in points, gems, or
137
+ * diamonds — applying a prompt deducts the cost server-side as part of the AI
138
+ * generation request.
139
+ *
140
+ * @remarks
141
+ * **Preconditions**
142
+ * - User must be authenticated. Visitor mode is not supported.
143
+ * - No other prerequisite calls. The customization UI typically calls this on demand
144
+ * when the user opens the style picker, not on app boot.
145
+ *
146
+ * **Cost handling**
147
+ * Each prompt declares `cost_currency_type_id` (0 = points, 1 = gems, 2 = diamonds)
148
+ * and `cost_value` (amount). The deduction happens server-side inside the
149
+ * `avatar-customize` HTTP POST (the AI generation request, which is NOT part of this
150
+ * SDK). The client should compare `cost_value` against the live balance from
151
+ * {@link getUserProfile} to disable prompts the user cannot afford, but the server is
152
+ * the source of truth and will reject under-funded requests authoritatively.
153
+ *
154
+ * **Refresh**
155
+ * - The SDK caches results for 30 seconds.
156
+ * - Not invalidated by {@link setAvatar} (prompts are catalog metadata, independent
157
+ * of the user's active avatar).
158
+ * - No push subscription.
159
+ *
160
+ * **Visitor mode**: not supported.
161
+ *
162
+ * **UI guidance**: see [UI Guide — `getAvatarPrompts`](../../docs/ui/avatars/UIGuide_getAvatarPrompts.md).
163
+ *
164
+ * @returns Array of {@link TAvatarPrompt} — empty if the AI customization feature is
165
+ * disabled on the label.
166
+ *
167
+ * @example
168
+ * ```ts
169
+ * const [prompts, profile] = await Promise.all([
170
+ * window._smartico.api.getAvatarPrompts(),
171
+ * window._smartico.api.getUserProfile(),
172
+ * ]);
173
+ *
174
+ * for (const p of prompts) {
175
+ * // The consumer reads the matching balance from profile based on
176
+ * // p.cost_currency_type_id (0=points, 1=gems, 2=diamonds).
177
+ * console.log('[smartico] prompt', p.name, '— cost', p.cost_value, 'currency_type', p.cost_currency_type_id);
178
+ * }
179
+ * ```
180
+ */
181
+ getAvatarPrompts(): Promise<TAvatarPrompt[]>;
182
+ /**
183
+ * Activates the specified avatar for the current user. The chosen image becomes the
184
+ * profile avatar — any subsequent {@link getUserProfile} call will reflect the new
185
+ * `avatar_url`.
186
+ *
187
+ * Pass `avatar_url` (a {@link TAvatarDefinition.url} from the catalog or a
188
+ * {@link TAvatarCustomized.url} from the AI-variant list) plus `avatar_real_id` of the
189
+ * base avatar. The server validates ownership before applying — locked avatars are
190
+ * rejected.
191
+ *
192
+ * @remarks
193
+ * **Preconditions**
194
+ * - User must be authenticated. Visitor mode is not supported.
195
+ * - `avatar_url` must be non-empty and `avatar_real_id` must be truthy — the SDK
196
+ * throws synchronously otherwise (the request never reaches the server).
197
+ * - The avatar must exist in the catalog from {@link getAvatarsList} (or be an AI
198
+ * variant of a base avatar the user already owns). Free avatars
199
+ * (`avatar_source_type_id === 0`) and the user's currently active avatar bypass the
200
+ * ownership check; all others require `is_given === true`.
201
+ *
202
+ * **Error codes** (in `err_code`)
203
+ * - `0` — success; cache is cleared and the profile avatar updates immediately.
204
+ * - `1` — avatar not found in the catalog. The `avatar_real_id` doesn't exist for
205
+ * this label.
206
+ * - `2` — avatar inactive (deactivated by the operator).
207
+ * - `3` — outside the avatar's active time window
208
+ * (`active_from_date` / `active_till_date`).
209
+ * - `4` — user does not own this avatar (it isn't in their `is_given` set and isn't
210
+ * a free / default avatar).
211
+ * - other non-zero — generic server error; surface `err_message` if present.
212
+ *
213
+ * The default Smartico UI shows a hardcoded "Failed to apply avatar" toast on any
214
+ * non-zero `err_code` and does not surface `err_message`. Custom UIs SHOULD branch
215
+ * on the code and prefer `err_message` when present (it is the localized server
216
+ * string).
217
+ *
218
+ * **Refresh after success**
219
+ * - The SDK clears both the `getAvatarsList` and `getAvatarsCustomized` caches —
220
+ * the next call to either returns fresh data with the new `is_in_use` flag set on
221
+ * the chosen avatar.
222
+ * - The server persists the new avatar URL on the user record; {@link getUserProfile}
223
+ * reflects it on the next read in this session.
224
+ * - **No push to other open sessions.** A second device / tab the user is logged in
225
+ * on will not see the new avatar until it next calls {@link getUserProfile} or
226
+ * re-identifies. Plan UI accordingly.
227
+ *
228
+ * **Idempotency**: safe to retry. Re-applying the same `avatar_real_id` returns
229
+ * `err_code: 0` and produces no double side effects (no double-deduction — this
230
+ * method does not charge any currency — and no duplicate log entries).
231
+ *
232
+ * **Side effects**: updates the user's stored `avatar_id` / `avatar_real_id`. Does
233
+ * NOT cost points, gems, or diamonds — the cost lives on the separate AI
234
+ * customization HTTP flow ({@link getAvatarPrompts}). Does NOT write a user-visible
235
+ * entry to {@link getActivityLog}.
236
+ *
237
+ * **UI guidance**: see [UI Guide — `setAvatar`](../../docs/ui/avatars/UIGuide_setAvatar.md).
238
+ *
239
+ * **Visitor mode**: not supported.
240
+ *
241
+ * @param props.avatar_url Absolute CDN URL of the avatar image. Read from
242
+ * {@link TAvatarDefinition.url} for catalog avatars or
243
+ * {@link TAvatarCustomized.url} for AI variants.
244
+ * @param props.avatar_real_id Numeric ID of the base avatar from
245
+ * {@link TAvatarDefinition.avatar_real_id}. For AI
246
+ * variants, this is the `avatar_real_id` of the base
247
+ * they were derived from.
248
+ * @returns {@link TSetAvatarResult} — check `err_code === 0` for success.
249
+ *
250
+ * @example
251
+ * ```ts
252
+ * const avatars = await window._smartico.api.getAvatarsList();
253
+ * const target = avatars.find((a) => a.avatar_real_id === 7);
254
+ *
255
+ * if (!target) {
256
+ * console.error('[smartico] avatar 7 not in catalog — hide the picker entry');
257
+ * return;
258
+ * }
259
+ *
260
+ * const isLocked = !target.is_given && target.avatar_source_type_id !== 0;
261
+ * if (isLocked) {
262
+ * console.log('[smartico] avatar is locked — show "earn this first" prompt instead of calling setAvatar');
263
+ * return;
264
+ * }
265
+ *
266
+ * const r = await window._smartico.api.setAvatar({
267
+ * avatar_url: target.avatar_url,
268
+ * avatar_real_id: target.avatar_real_id,
269
+ * });
270
+ *
271
+ * switch (r.err_code) {
272
+ * case 0:
273
+ * console.log('[smartico] avatar applied — close picker, refresh header avatar');
274
+ * break;
275
+ * case 1:
276
+ * console.error('[smartico] avatar not in catalog — refresh catalog and show error');
277
+ * break;
278
+ * case 2:
279
+ * console.error('[smartico] avatar inactive — operator disabled it; hide from picker');
280
+ * break;
281
+ * case 3:
282
+ * console.error('[smartico] outside time window — show "available on X" message');
283
+ * break;
284
+ * case 4:
285
+ * console.error('[smartico] not owned — show unlock requirements');
286
+ * break;
287
+ * default:
288
+ * console.error('[smartico] avatar apply failed — show generic error toast:', r.err_message);
289
+ * }
290
+ * ```
291
+ */
292
+ setAvatar(props: {
293
+ avatar_url: string;
294
+ avatar_real_id: number;
295
+ }): Promise<TSetAvatarResult>;
296
+ }
@@ -0,0 +1,71 @@
1
+ import { SmarticoAPI } from '../SmarticoAPI';
2
+ /** @hidden */
3
+ export declare const CACHE_DATA_SEC = 30;
4
+ /** @hidden */
5
+ export declare const JACKPOT_TEMPLATE_CACHE_SEC = 30;
6
+ /** @hidden */
7
+ export declare const JACKPOT_POT_CACHE_SEC = 1;
8
+ /** @hidden */
9
+ export declare const JACKPOT_WINNERS_CACHE_SEC = 30;
10
+ /** @hidden */
11
+ export declare const JACKPOT_ELIGIBLE_GAMES_CACHE_SEC = 30;
12
+ /** @hidden */
13
+ export declare enum onUpdateContextKey {
14
+ Saw = "saw",
15
+ Missions = "missions",
16
+ TournamentList = "tournamentList",
17
+ InboxMessages = "inboxMessages",
18
+ Badges = "badges",
19
+ Levels = "levels",
20
+ StoreItems = "storeItems",
21
+ StoreCategories = "storeCategories",
22
+ AchCategories = "achCategories",
23
+ LeaderBoards = "leaderBoards",
24
+ LevelExtraCounters = "levelExtraCounters",
25
+ Segments = "segments",
26
+ StoreHistory = "storeHistory",
27
+ Jackpots = "jackpots",
28
+ Pots = "Pots",
29
+ CustomSections = "customSections",
30
+ Bonuses = "bonuses",
31
+ Clans = "clans",
32
+ SAWHistory = "sawHistory",
33
+ JackpotWinners = "jackpotWinners",
34
+ Raffles = "raffles",
35
+ JackpotEligibleGames = "jackpotEligibleGames",
36
+ CurrentLevel = "currentLevel",
37
+ InboxUnreadCount = "inboxUnreadCount",
38
+ ActivityLog = "activityLog",
39
+ AvatarsList = "avatarsList",
40
+ AvatarsCustomized = "avatarsCustomized",
41
+ AvatarPrompts = "avatarPrompts"
42
+ }
43
+ /**
44
+ * Abstract base of the SDK's public surface. Holds the shared state
45
+ * (`api`, `userExtId`, `onUpdateCallback` map) and the generic cache /
46
+ * subscription helper (`updateEntity`). Domain-specific methods live on
47
+ * subclasses; the terminator `WSAPI` class composes the whole chain.
48
+ *
49
+ * **Consumers should not instantiate this directly** — the SDK constructs
50
+ * the concrete `WSAPI` via `_smartico.api`.
51
+ *
52
+ * @hidden
53
+ */
54
+ export declare abstract class WSAPIBase {
55
+ protected api: SmarticoAPI;
56
+ /** @hidden */
57
+ protected onUpdateCallback: Map<onUpdateContextKey, (data: any) => void>;
58
+ /** @hidden */
59
+ protected userExtId: string;
60
+ /** @private */
61
+ constructor(api: SmarticoAPI, userExtId?: string);
62
+ /** @private */
63
+ clearCaches(): void;
64
+ /**
65
+ * Generic cache-update + subscription-notify helper. Used by domain
66
+ * classes' `update*` methods to refresh a context and fire any
67
+ * registered `onUpdate` callback.
68
+ * @hidden
69
+ */
70
+ protected updateEntity(contextKey: onUpdateContextKey, payload: any): Promise<void>;
71
+ }
@@ -0,0 +1,240 @@
1
+ import { TBonus, TClaimBonusResult } from './WSAPITypes';
2
+ import { WSAPIMissions } from './WSAPIMissions';
3
+ /** @group Bonuses */
4
+ export declare class WSAPIBonuses extends WSAPIMissions {
5
+ /**
6
+ * Returns the bonuses awarded to the current user — both pending
7
+ * (player-claim required) and already-redeemed. Each bonus carries
8
+ * a `bonus_status_id` ({@link BonusStatus}) describing its lifecycle
9
+ * stage and an `is_redeemable` flag that signals whether the
10
+ * consumer must trigger a manual {@link claimBonus} call.
11
+ *
12
+ * Bonuses originate from many sources (CRM rules, mission/tournament
13
+ * rewards, store redemptions, mini-game prizes, manual operator
14
+ * awards) and all surface through this single list. The consumer
15
+ * cannot distinguish the source server-side without operator
16
+ * coordination.
17
+ *
18
+ * @remarks
19
+ * **Subscription model (`onUpdate`)**
20
+ * The callback receives the FULL refreshed bonuses list (never a
21
+ * diff/patch). Each subsequent call to `getBonuses({ onUpdate })`
22
+ * REPLACES the prior callback. Pass `onUpdate: undefined` (or omit
23
+ * it) to keep the prior callback in place; the callback is never
24
+ * auto-cleared.
25
+ *
26
+ * **Update triggers** — the callback fires after every
27
+ * {@link claimBonus} call resolves on this connection (success OR
28
+ * failure). This is the ONLY trigger.
29
+ *
30
+ * Does NOT fire when: a new bonus is awarded server-side
31
+ * (CRM rule, mission completion, store purchase, etc.), a bonus
32
+ * expires, or an operator manually issues / cancels a bonus. Those
33
+ * changes surface only on the next cache miss (after the 30 s TTL).
34
+ * Re-call `getBonuses()` manually if your UI needs near-live state
35
+ * for server-driven awards.
36
+ *
37
+ * **Reading state from the returned bonus**
38
+ * Drive UI bucketing from `bonus_status_id` (enum {@link BonusStatus}):
39
+ *
40
+ * - `COUPON_ISSUED` (2) — actionable; player must claim. Pair with
41
+ * `is_redeemable === true` to gate the Claim button.
42
+ * - `REDEEM_FAILED` (4) — also actionable; the previous claim
43
+ * attempt failed but the bonus is still valid. Surface a retry CTA
44
+ * — the default Smartico UI treats this identically to
45
+ * `COUPON_ISSUED` from the player's perspective.
46
+ * - `REDEEMED` (3) — historical; show in a "claimed" tab.
47
+ * - `New` (1), `COUPON_ISSUE_FAILED` (5), `EXPIRED` (6) — these
48
+ * should not normally reach the client and are typically filtered
49
+ * out by operator-side widget configuration; if they do appear,
50
+ * they have no player-actionable state.
51
+ *
52
+ * `is_redeemable` is the authoritative gate for showing the Claim
53
+ * button — it's `true` only when the bonus is in a claimable status
54
+ * AND the operator's integration uses a coupon model (where the
55
+ * player must explicitly trigger delivery). Auto-redeemed bonuses
56
+ * arrive already in `REDEEMED` state with `is_redeemable: false`.
57
+ *
58
+ * **Field hierarchy — display amount**
59
+ * Bonuses carry both template-level (`label_bonus_template_meta_map.description`)
60
+ * and instance-level (`bonus_meta_map.uiAmount`) display strings.
61
+ * Prefer `bonus_meta_map.uiAmount` when present — it's the dynamic
62
+ * amount computed at issuance time (e.g. from a dynamic-bonus
63
+ * formula). Fall back to `label_bonus_template_meta_map.description`
64
+ * (which can include HTML; sanitize before injecting).
65
+ *
66
+ * **Date format**
67
+ * `create_date` and `redeem_date` are ISO 8601 UTC strings WITHOUT
68
+ * a timezone suffix (`"YYYY-MM-DDTHH:MM:SS"`). Parse as UTC and
69
+ * display in the user's local timezone. `redeem_date` is absent
70
+ * until the bonus reaches `REDEEMED` status.
71
+ *
72
+ * **Cache TTL**: the SDK caches the response for 30 seconds. Cache
73
+ * is fully cleared on login / logout.
74
+ *
75
+ * **Idempotency / Side effects**: safe. Read-only.
76
+ *
77
+ * **UI guidance**: see [UI Guide — `getBonuses`](../../docs/ui/bonuses/UIGuide_getBonuses.md).
78
+ *
79
+ * **Visitor mode**: not supported.
80
+ *
81
+ * @param params Optional. Omit to fetch without subscribing.
82
+ * @param params.onUpdate Callback invoked with the full refreshed
83
+ * bonuses list after every
84
+ * {@link claimBonus} resolves. Each call
85
+ * to `getBonuses` overwrites the prior
86
+ * callback.
87
+ * @returns Promise resolving to the bonuses list.
88
+ * Empty array if no bonuses are visible.
89
+ *
90
+ * @example
91
+ * ```ts
92
+ * const bonuses = await window._smartico.api.getBonuses({
93
+ * onUpdate: (refreshed) => {
94
+ * console.log('[smartico] bonuses refreshed (after claimBonus) — re-render the bonuses UI from this array:', refreshed);
95
+ * },
96
+ * });
97
+ *
98
+ * // Bucket into pending vs redeemed tabs. The default Smartico UI groups
99
+ * // COUPON_ISSUED + REDEEM_FAILED into the same "Pending" tab.
100
+ * const pending = bonuses.filter(b =>
101
+ * b.bonus_status_id === 2 || b.bonus_status_id === 4 // COUPON_ISSUED or REDEEM_FAILED
102
+ * );
103
+ * const redeemed = bonuses.filter(b => b.bonus_status_id === 3); // REDEEMED
104
+ *
105
+ * console.log('[smartico] render bonus tabs: pending=', pending.length, 'redeemed=', redeemed.length);
106
+ *
107
+ * // Render each pending bonus card; show Claim button only when redeemable.
108
+ * for (const b of pending) {
109
+ * const amount = b.bonus_meta_map?.uiAmount || b.label_bonus_template_meta_map?.description;
110
+ * if (b.is_redeemable) {
111
+ * console.log('[smartico] render Claim button for bonus', b.bonus_id, '— amount:', amount);
112
+ * } else {
113
+ * console.log('[smartico] render bonus as informational (no Claim button) — amount:', amount);
114
+ * }
115
+ * }
116
+ *
117
+ * // Server-awarded bonuses (e.g. from a CRM campaign) do NOT push;
118
+ * // poll if you need near-live awareness.
119
+ * setInterval(async () => {
120
+ * const fresh = await window._smartico.api.getBonuses();
121
+ * const newCount = fresh.filter(b => b.bonus_status_id === 2 || b.bonus_status_id === 4).length;
122
+ * console.log('[smartico] poll tick — pending bonuses now:', newCount);
123
+ * }, 30_000);
124
+ * ```
125
+ */
126
+ getBonuses({ onUpdate }?: {
127
+ onUpdate?: (data: TBonus[]) => void;
128
+ }): Promise<TBonus[]>;
129
+ /**
130
+ * Triggers manual redemption of a coupon-model bonus the user has
131
+ * been awarded. For bonuses with `is_redeemable === true` returned
132
+ * by {@link getBonuses}, this is the call that asks the operator's
133
+ * integration to actually credit the bonus to the player's account.
134
+ * Bonuses on integrations that auto-redeem arrive already in
135
+ * `REDEEMED` state and do not require this call.
136
+ *
137
+ * Use this for `bonus_status_id` of `COUPON_ISSUED` (2) as the
138
+ * first-time claim, and for `REDEEM_FAILED` (4) as a retry after a
139
+ * prior unsuccessful attempt.
140
+ *
141
+ * @remarks
142
+ * **Preconditions**
143
+ * Read the candidate bonus from {@link getBonuses} and gate the
144
+ * call on `is_redeemable === true`. The SDK forwards the request
145
+ * unconditionally — calling on a non-claimable bonus returns
146
+ * `err_code = -1`.
147
+ *
148
+ * **Error codes** (in `err_code`)
149
+ *
150
+ * The SDK currently types `err_code` as {@link SAWSpinErrorCode} for
151
+ * historical reasons, but the values returned by this method come
152
+ * from the server's general error space and are NOT mini-game codes.
153
+ * Branch on the numeric values:
154
+ *
155
+ * - `0` — success; the bonus has been redeemed and the operator's
156
+ * integration has credited the player's account.
157
+ * - `-1` — bonus not claimable: not found, already claimed by
158
+ * another session, or its status is no longer `COUPON_ISSUED` /
159
+ * `REDEEM_FAILED`. Treat as idempotent — refresh
160
+ * {@link getBonuses} and reconcile.
161
+ * - `1` — generic server error. Transient; allow retry after a brief
162
+ * delay.
163
+ * - `9999` — uncaught server exception. Treat as a transient failure;
164
+ * surface a generic error and allow retry.
165
+ * - other non-zero — generic server error. Surface `err_message` if
166
+ * any.
167
+ *
168
+ * **`success` field is unreliable**: the wire response does not
169
+ * carry a `success` boolean — the field on `TClaimBonusResult` will
170
+ * be `undefined` in practice. Always branch on `err_code === 0`
171
+ * for the success check.
172
+ *
173
+ * **Refresh after success (and after failure)**
174
+ * The SDK automatically refreshes the bonuses cache on every
175
+ * response (success OR failure) and fires any `onUpdate` callback
176
+ * registered via {@link getBonuses}'s `onUpdate`. After
177
+ * `err_code === 0`, the redeemed bonus shifts from
178
+ * `COUPON_ISSUED` / `REDEEM_FAILED` to `REDEEMED` on the refreshed
179
+ * array, with `redeem_date` populated. After a failure, the bonus
180
+ * typically lands in `REDEEM_FAILED` and remains claimable for a
181
+ * retry.
182
+ *
183
+ * **Idempotency**: NOT idempotent at the SDK level. A second call
184
+ * returns `err_code = -1` once the first has succeeded — treat that
185
+ * as success in the UI rather than as a real error. Guard the call
186
+ * site against double-clicks (set a local "claiming" flag on click,
187
+ * clear it on response).
188
+ *
189
+ * **Side effects** (on `err_code === 0`)
190
+ * - Bonus status transitions to `REDEEMED`; `redeem_date` is set.
191
+ * - The operator's integration credits the player's account
192
+ * externally. The SDK does not observe that credit directly —
193
+ * balance updates flow over the user-properties channel from the
194
+ * operator's side, not from this response.
195
+ * - Server-side analytics events fire downstream (not directly
196
+ * observable from the SDK).
197
+ *
198
+ * **UI guidance**: see [UI Guide — `claimBonus`](../../docs/ui/bonuses/UIGuide_claimBonus.md).
199
+ *
200
+ * **Visitor mode**: not supported.
201
+ *
202
+ * @param bonus_id The `bonus_id` from a `TBonus` returned by
203
+ * {@link getBonuses}.
204
+ * @returns `{ err_code, err_message, success? }`; success when
205
+ * `err_code === 0` (or `err_code === -1` when treated as
206
+ * idempotent no-op). The `success` field is unreliable —
207
+ * ignore it.
208
+ *
209
+ * @example
210
+ * ```ts
211
+ * const bonuses = await window._smartico.api.getBonuses({
212
+ * onUpdate: (refreshed) => console.log('[smartico] bonuses refreshed — re-render from this array', refreshed),
213
+ * });
214
+ * const bonus = bonuses.find(b => b.bonus_id === bonusId);
215
+ *
216
+ * if (!bonus) {
217
+ * console.log('[smartico] bonus no longer visible — refresh list and hide CTA');
218
+ * return;
219
+ * }
220
+ * if (!bonus.is_redeemable) {
221
+ * console.log('[smartico] bonus is not claimable (auto-redeemed or already finalised) — keep CTA hidden');
222
+ * return;
223
+ * }
224
+ *
225
+ * console.log('[smartico] claim starting — set in-flight flag, show loading dots on the Claim button, keep the modal open');
226
+ * const r = await window._smartico.api.claimBonus(bonus.bonus_id);
227
+ * console.log('[smartico] claim response received — clear in-flight flag');
228
+ *
229
+ * if (r.err_code === 0 || r.err_code === -1) {
230
+ * console.log('[smartico] claim succeeded (or was already done) — show a success toast; the getBonuses onUpdate above will fire with the refreshed list');
231
+ * } else if (r.err_code === 9999) {
232
+ * console.error('[smartico] uncaught server exception — show a generic error toast and allow retry');
233
+ * } else {
234
+ * console.error('[smartico] claim failed — surface this error message to the user; the bonus will move to REDEEM_FAILED state and remain claimable for a retry:', r.err_message);
235
+ * }
236
+ * ```
237
+ */
238
+ claimBonus(bonus_id: number): Promise<TClaimBonusResult>;
239
+ protected updateBonuses(): Promise<void>;
240
+ }