@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
@@ -28,23 +28,81 @@ export class WSAPIJackpots extends WSAPIClans {
28
28
  OCache.clear(ECacheContext.WSAPI, onUpdateContextKey.JackpotWinners);
29
29
  }
30
30
 
31
- /** Returns list of Jackpots that are active in the system and matching to the filter definition.
32
- * If filter is not provided, all active jackpots will be returned.
33
- * Filter can be used to get jackpots related to specific game or specific jackpot template.
34
- * You can call this method every second in order to get up to date information about current value of the jackpot(s) and present them to the end-users
31
+ /**
32
+ * Returns the user-eligible jackpots active for the label, fused with their live
33
+ * pot values. Each entry carries the static template (name, description, opt-in
34
+ * state, eligible games, currency) plus a freshly-fetched `pot` snapshot.
35
35
  *
36
- * **Example**:
37
- * ```
38
- * _smartico.api.jackpotGet({ related_game_id: 'wooko-slot' }).then((result) => {
39
- * console.log(result);
40
- * });
41
- * ```
36
+ * Designed to be polled at high frequency (every 1 second is fine) — the SDK
37
+ * splits the response into a 30-second template cache and a 1-second pot-value
38
+ * cache so consumers can render a live-counting pot amount without hammering
39
+ * the server for the static template data.
42
40
  *
43
- * **Example in the Visitor mode**:
44
- * ```
45
- * _smartico.vapi('EN').jackpotGet({ related_game_id: 'wooko-slot' }).then((result) => {
46
- * console.log(result);
47
- * });
41
+ * @remarks
42
+ * **Preconditions**
43
+ * - No prerequisite calls.
44
+ * - Visitor mode supported via `_smartico.vapi(lang).jackpotGet(...)`.
45
+ *
46
+ * **Server-side eligibility filtering**
47
+ * Jackpots are filtered server-side by the user's segments before being
48
+ * returned. Templates the user is ineligible for never appear in this
49
+ * response — there is no "locked" state to render. An empty result for a
50
+ * known-good user typically means none of the configured templates match
51
+ * the user's segments / level / brand.
52
+ *
53
+ * **Filter behavior**
54
+ * Passing `related_game_id` returns only jackpots linked to that game (from
55
+ * the operator's games catalog). Passing `jp_template_id` returns just that
56
+ * single template. With no filter, all active templates the user is
57
+ * eligible for are returned. Changing the filter between calls flushes both
58
+ * the template cache and the pot cache.
59
+ *
60
+ * **Two-tier cache**
61
+ * - Template definitions: 30 s cache. Re-fetched on filter change or when
62
+ * opt-in / opt-out / a jackpot-win push lands.
63
+ * - Pot values: 1 s cache. Re-fetched on every call past the 1-second
64
+ * window so a 1 Hz poll renders a smoothly counting pot.
65
+ *
66
+ * **`jp_public_meta.custom_data`**
67
+ * Server returns this as a JSON-encoded string; the SDK parses it inline so
68
+ * consumers always receive either a parsed object or the raw string.
69
+ *
70
+ * **Personal vs MultiUser jackpots** (see {@link JackpotType})
71
+ * - `MultiUser` (1) — shared pot; `registration_count` reflects real opted-in
72
+ * user count; temperature transitions fire push events.
73
+ * - `Personal` (2) — independent per-user pot; `registration_count` is
74
+ * always 1; temperature push events are suppressed.
75
+ *
76
+ * **Refresh**
77
+ * - `jp_status_id`, segment changes, and operator template edits surface
78
+ * after the 30 s template cache TTL.
79
+ * - Opt-in / opt-out / jackpot-win push events all clear the template and
80
+ * pot caches — the next call re-fetches.
81
+ *
82
+ * **Visitor mode**: supported.
83
+ *
84
+ * **UI guidance**: see [UI Guide — `jackpotGet`](../../docs/ui/jackpots/UIGuide_jackpotGet.md).
85
+ *
86
+ * @param filter Optional filter narrowing the result set.
87
+ * @param filter.related_game_id Limit to jackpots linked to this game ID
88
+ * (from the operator's games catalog).
89
+ * @param filter.jp_template_id Limit to a single template.
90
+ * @returns Array of {@link JackpotDetails} — empty if the user is eligible
91
+ * for no active jackpots.
92
+ *
93
+ * @example
94
+ * ```ts
95
+ * // Poll every second for live pot counter
96
+ * setInterval(async () => {
97
+ * const jackpots = await window._smartico.api.jackpotGet();
98
+ * for (const jp of jackpots) {
99
+ * console.log('[smartico] update pot widget for', jp.jp_public_meta.name, '— amount:', jp.pot.current_pot_amount_user_currency, jp.user_currency, '— temperature:', jp.pot.current_pot_temperature);
100
+ * }
101
+ * }, 1000);
102
+ *
103
+ * // Filtered fetch for a specific game tile
104
+ * const linked = await window._smartico.api.jackpotGet({ related_game_id: 'gold-slot2' });
105
+ * console.log('[smartico] linked jackpots for game:', linked.length);
48
106
  * ```
49
107
  */
50
108
  public async jackpotGet(filter?: { related_game_id?: string; jp_template_id?: number }): Promise<JackpotDetails[]> {
@@ -97,18 +155,68 @@ export class WSAPIJackpots extends WSAPIClans {
97
155
  }
98
156
 
99
157
  /**
100
- * Opt-in currently logged in user to the jackpot with the specified jp_template_id.
101
- * You may call jackpotGet method after doing optin to see that user is opted in to the jackpot.
158
+ * Opts the authenticated user into a jackpot. From this point on, the user
159
+ * contributes to the pot (per the template's `contribution_type` and
160
+ * `contribution_value`) and is eligible to win when the pot explodes.
102
161
  *
103
- * **Example**:
104
- * ```
105
- * _smartico.api.jackpotOptIn({ jp_template_id: 123 }).then((result) => {
106
- * console.log('Opted in to the jackpot');
107
- * });
108
- * ```
162
+ * On success the SDK clears the jackpot caches — the next
163
+ * {@link jackpotGet} call returns the updated `is_opted_in: true` and an
164
+ * incremented `registration_count`.
165
+ *
166
+ * @remarks
167
+ * **Preconditions**
168
+ * - User must be authenticated. Visitor mode not supported.
169
+ * - `jp_template_id` is mandatory — the SDK throws synchronously if missing.
170
+ * - The jackpot must currently be active and the user must be in its
171
+ * eligibility segment. Ineligible jackpots are filtered out of
172
+ * {@link jackpotGet} entirely, so a card the user sees is opt-in-able.
173
+ *
174
+ * **Error handling**
175
+ * The server returns a non-zero `errCode` with a human-readable `errMsg`
176
+ * for any failure. Common causes:
177
+ * - User is in a control group.
178
+ * - Jackpot template is not active (status changed since the user opened
179
+ * the card).
180
+ * - User is already opted in (the SDK has no client-side guard against a
181
+ * double-tap; the server enforces).
182
+ * - DB race / generic server error.
183
+ *
184
+ * The SDK does NOT enumerate distinct numeric codes for each cause — branch
185
+ * on `errCode === 0` for success and surface `errMsg` as-is for failures.
186
+ *
187
+ * **Idempotency / re-opt-in semantics**
188
+ * - **Already opted in** → returns non-zero `errCode` ("User already opted in").
189
+ * - **Previously opted in then opted out** → succeeds silently; the server
190
+ * re-activates the registration. This is not an error path — a user can
191
+ * freely cycle opt-in / opt-out.
192
+ *
193
+ * **Refresh after success**
194
+ * - The SDK clears the template, pot, and winners caches.
195
+ * - The next {@link jackpotGet} call returns `is_opted_in: true` for this
196
+ * template.
197
+ *
198
+ * **Side effects**
199
+ * Fires a `JACKPOT_OPT_IN` engagement event (visible to operator-side
200
+ * automation rules). Does NOT immediately move points / gems — contributions
201
+ * happen per-bet via the user's gameplay, not on opt-in.
202
+ *
203
+ * **Visitor mode**: not supported.
109
204
  *
110
- * **Visitor mode: not supported**
205
+ * **UI guidance**: see [UI Guide — `jackpotOptIn`](../../docs/ui/jackpots/UIGuide_jackpotOptIn.md).
111
206
  *
207
+ * @param filter.jp_template_id ID of the jackpot template to join.
208
+ * @returns {@link JackpotsOptinResponse} — `errCode === 0` on success.
209
+ *
210
+ * @example
211
+ * ```ts
212
+ * const r = await window._smartico.api.jackpotOptIn({ jp_template_id: 42 });
213
+ *
214
+ * if (r.errCode === 0) {
215
+ * console.log('[smartico] opted in — refresh jackpot card to show opt-out CTA');
216
+ * } else {
217
+ * console.error('[smartico] opt-in failed — show this message in an error toast:', r.errMsg);
218
+ * }
219
+ * ```
112
220
  */
113
221
  public async jackpotOptIn(filter: { jp_template_id: number }): Promise<JackpotsOptinResponse> {
114
222
  if (!filter.jp_template_id) {
@@ -121,18 +229,63 @@ export class WSAPIJackpots extends WSAPIClans {
121
229
  }
122
230
 
123
231
  /**
124
- * Opt-out currently logged in user from the jackpot with the specified jp_template_id.
125
- * You may call jackpotGet method after doing optout to see that user is not opted in to the jackpot.
232
+ * Opts the authenticated user out of a jackpot. From this point on the user
233
+ * no longer contributes to the pot and is not eligible to win.
126
234
  *
127
- * **Example**:
128
- * ```
129
- * _smartico.api.jackpotOptOut({ jp_template_id: 123 }).then((result) => {
130
- * console.log('Opted out from the jackpot');
131
- * });
132
- * ```
235
+ * The user can re-join later via {@link jackpotOptIn} — opt-out is not
236
+ * permanent.
237
+ *
238
+ * @remarks
239
+ * **Preconditions**
240
+ * - User must be authenticated. Visitor mode not supported.
241
+ * - `jp_template_id` is mandatory — the SDK throws synchronously if missing.
242
+ *
243
+ * **Error handling**
244
+ * The server returns a non-zero `errCode` with a human-readable `errMsg` for
245
+ * any failure. Common causes:
246
+ * - User has never opted in OR is already opted out — server returns
247
+ * non-zero `errCode` for the "already opted out" case. Calling opt-out
248
+ * on a jackpot the user has never registered for typically returns
249
+ * success (the server finds no registration row to update).
250
+ * - DB race / generic server error.
251
+ *
252
+ * Unlike {@link jackpotOptIn}, opt-out does NOT check the template's status
253
+ * — the user can opt out of a jackpot that has been deactivated by the
254
+ * operator.
133
255
  *
134
- * **Visitor mode: not supported**
256
+ * **Idempotency**
257
+ * - First opt-out → success.
258
+ * - Second opt-out → non-zero `errCode` ("Already opted out").
259
+ * - Opt-out of a never-joined jackpot → typically succeeds silently
260
+ * (no registration row to act on).
135
261
  *
262
+ * **Refresh after success**
263
+ * - The SDK clears the template, pot, and winners caches.
264
+ * - The next {@link jackpotGet} call returns `is_opted_in: false` for this
265
+ * template and a decremented `registration_count`.
266
+ *
267
+ * **Side effects**
268
+ * Fires a `JACKPOT_OPT_OUT` engagement event for operator-side automation
269
+ * rules. The user's existing contributions to the current pot remain in
270
+ * place — opt-out stops future contributions but does not refund past ones.
271
+ *
272
+ * **Visitor mode**: not supported.
273
+ *
274
+ * **UI guidance**: see [UI Guide — `jackpotOptOut`](../../docs/ui/jackpots/UIGuide_jackpotOptOut.md).
275
+ *
276
+ * @param filter.jp_template_id ID of the jackpot template to leave.
277
+ * @returns {@link JackpotsOptoutResponse} — `errCode === 0` on success.
278
+ *
279
+ * @example
280
+ * ```ts
281
+ * const r = await window._smartico.api.jackpotOptOut({ jp_template_id: 42 });
282
+ *
283
+ * if (r.errCode === 0) {
284
+ * console.log('[smartico] opted out — refresh jackpot card to show join CTA');
285
+ * } else {
286
+ * console.error('[smartico] opt-out failed — show this message in an error toast:', r.errMsg);
287
+ * }
288
+ * ```
136
289
  */
137
290
  public async jackpotOptOut(filter: { jp_template_id: number }): Promise<JackpotsOptoutResponse> {
138
291
  if (!filter.jp_template_id) {
@@ -145,34 +298,75 @@ export class WSAPIJackpots extends WSAPIClans {
145
298
  }
146
299
 
147
300
  /**
148
- * Returns jackpot winners for the given `jp_template_id` (paginated on the server).
149
- * Default page size on the wire is 20; use `limit`, `offset`, and repeated calls to load more.
150
- * The full protocol response also includes `has_more`; this method returns only the `winners` array.
301
+ * Returns past winners of a specific jackpot template, paginated. Use to
302
+ * power a "Recent winners" panel inside the jackpot detail modal.
151
303
  *
152
- * **Example**:
153
- * ```
154
- * _smartico.api.getJackpotWinners({
155
- * jp_template_id: 123,
156
- * }).then((result) => {
157
- * console.log(result);
158
- * });
159
- * ```
304
+ * **Important**: respect the `expose_winners_over_api` flag on the jackpot's
305
+ * {@link JackpotDetails} before calling this method. The server-side handler
306
+ * does NOT enforce that flag — it is a UI-only gate. Custom UIs that ignore
307
+ * the flag will display winners the operator intended to keep private.
308
+ *
309
+ * @remarks
310
+ * **Preconditions**
311
+ * - User must be authenticated. Visitor mode not supported.
312
+ * - `jp_template_id` is mandatory — the SDK throws synchronously if missing.
313
+ * - The consumer SHOULD check
314
+ * {@link JackpotDetails.expose_winners_over_api} before calling, since
315
+ * the server does not enforce it.
316
+ *
317
+ * **Pagination**
318
+ * Server default page size is 20. Pass `limit` and `offset` to paginate
319
+ * (e.g. infinite-scroll). The wire response carries a `has_more` flag, but
320
+ * this SDK method returns only the `winners` array — detect end-of-list by
321
+ * a returned array shorter than `limit`.
322
+ *
323
+ * **Currency caveat**
324
+ * Winner amounts in the response (`winner.winning_amount_jp_currency`) are
325
+ * in the jackpot's NATIVE currency, NOT the user's wallet currency. If a
326
+ * user-currency display is needed, the consumer must convert client-side.
327
+ *
328
+ * **Refresh**
329
+ * - The SDK caches per `jp_template_id` for 30 seconds.
330
+ * - Caches clear on jackpot-win push events and on opt-in / opt-out.
331
+ *
332
+ * **Error handling**
333
+ * Non-zero `errCode` on control-group users or generic server errors. The
334
+ * SDK does NOT enumerate distinct codes — branch on `errCode === 0` and
335
+ * surface `errMsg` on failure.
336
+ *
337
+ * **Visitor mode**: not supported.
338
+ *
339
+ * **UI guidance**: see [UI Guide — `getJackpotWinners`](../../docs/ui/jackpots/UIGuide_getJackpotWinners.md).
340
+ *
341
+ * @returns Array of {@link JackpotWinnerHistory} entries newest-first.
160
342
  *
161
- * **Visitor mode: not supported**
343
+ * @example
344
+ * ```ts
345
+ * const [jp] = await window._smartico.api.jackpotGet({ jp_template_id: 42 });
162
346
  *
163
- * @param params - Jackpot winners parameters
164
- * @param params.jp_template_id - Jackpot template id (required; throws if missing)
165
- * @param params.limit - Page size (server default 20 when omitted)
166
- * @param params.offset - Offset into the winner list
347
+ * if (!jp || !jp.expose_winners_over_api) {
348
+ * console.log('[smartico] winners hidden by operator config — hide the winners tab');
349
+ * return;
350
+ * }
351
+ *
352
+ * const winners = await window._smartico.api.getJackpotWinners({
353
+ * jp_template_id: 42,
354
+ * limit: 20,
355
+ * offset: 0,
356
+ * });
357
+ * console.log('[smartico] render', winners.length, 'recent winner rows (amounts in', jp.jp_currency + ')');
358
+ * ```
167
359
  */
168
-
169
360
  public async getJackpotWinners({
170
361
  limit,
171
362
  offset,
172
363
  jp_template_id,
173
364
  }: {
365
+ /** Page size (default 20). */
174
366
  limit?: number;
367
+ /** Pagination offset (default 0). */
175
368
  offset?: number;
369
+ /** Jackpot template ID (required). */
176
370
  jp_template_id?: number;
177
371
  }): Promise<JackpotWinnerHistory[]> {
178
372
  return OCache.use(
@@ -184,20 +378,62 @@ export class WSAPIJackpots extends WSAPIClans {
184
378
  }
185
379
 
186
380
  /**
187
- * Returns the eligible games for the jackpot with the specified jp_template_id.
381
+ * Returns the casino games eligible to contribute to a specific jackpot —
382
+ * the catalog the user must play to grow the pot. Use to power an
383
+ * "Eligible games" carousel inside the jackpot detail modal.
188
384
  *
189
- * **Example**:
190
- * ```
191
- * _smartico.api.getJackpotEligibleGames({ jp_template_id: 123 }).then((result) => {
192
- * console.log(result);
193
- * });
385
+ * **Shortcut**: when the jackpot's
386
+ * {@link JackpotDetails.ach_related_game_allow_all} flag is `true`, every
387
+ * game in the operator catalog contributes — there's no point calling this
388
+ * method (the result would be the full catalog). The default Smartico UI
389
+ * hides the Eligible Games tab entirely in that case.
390
+ *
391
+ * @remarks
392
+ * **Preconditions**
393
+ * - User must be authenticated. Visitor mode not supported.
394
+ * - `jp_template_id` is mandatory.
395
+ *
396
+ * **`onUpdate` caveat**
397
+ * The `onUpdate` callback is accepted to match the SDK's subscription
398
+ * contract but is NOT auto-invoked by any current server push. It will only
399
+ * fire if a consumer (or a future SDK version) explicitly pushes an update.
400
+ * Treat it as a no-op for now.
401
+ *
402
+ * **Refresh**
403
+ * - The SDK caches per `jp_template_id` for 30 seconds.
404
+ * - Cache does NOT clear on opt-in / opt-out / jackpot-win — eligible-game
405
+ * lists rarely change during a session. Wait for the 30 s TTL.
406
+ *
407
+ * **Error handling**
408
+ * Non-zero `errCode` on control-group users or generic server errors.
409
+ * Branch on `errCode === 0` and surface `errMsg` on failure.
410
+ *
411
+ * **Visitor mode**: not supported.
412
+ *
413
+ * **UI guidance**: see [UI Guide — `getJackpotEligibleGames`](../../docs/ui/jackpots/UIGuide_getJackpotEligibleGames.md).
414
+ *
415
+ * @returns {@link TGetJackpotEligibleGamesResponse} —
416
+ * `{ eligible_games: JackpotEligibleGame[] }`.
417
+ *
418
+ * @example
419
+ * ```ts
420
+ * const [jp] = await window._smartico.api.jackpotGet({ jp_template_id: 42 });
421
+ *
422
+ * if (jp?.ach_related_game_allow_all) {
423
+ * console.log('[smartico] all games eligible — hide the eligible-games tab');
424
+ * return;
425
+ * }
426
+ *
427
+ * const r = await window._smartico.api.getJackpotEligibleGames({ jp_template_id: 42 });
428
+ * console.log('[smartico] render', r.eligible_games.length, 'eligible game tiles');
194
429
  * ```
195
- *
196
- * **Visitor mode: not supported**
197
- *
198
430
  */
199
-
200
- public async getJackpotEligibleGames({ jp_template_id, onUpdate } : { jp_template_id: number, onUpdate?: () => void }): Promise<TGetJackpotEligibleGamesResponse> {
431
+ public async getJackpotEligibleGames({ jp_template_id, onUpdate } : {
432
+ /** Jackpot template ID (required). */
433
+ jp_template_id: number,
434
+ /** Optional callback; not auto-invoked today. */
435
+ onUpdate?: () => void,
436
+ }): Promise<TGetJackpotEligibleGamesResponse> {
201
437
  if (onUpdate) {
202
438
  this.onUpdateCallback.set(onUpdateContextKey.JackpotEligibleGames, onUpdate);
203
439
  }
@@ -12,21 +12,135 @@ import { WSAPIGamePick } from './WSAPIGamePick';
12
12
  /** @group LeaderBoard */
13
13
  export class WSAPILeaderBoard extends WSAPIGamePick {
14
14
  /**
15
- * Returns the leaderboard for the current type (default is Daily). If getPreviousPeriod is passed as true, a leaderboard for the previous period for the current type will be returned.
16
- * For example, if the type is Weekly and getPreviousPeriod is true, a leaderboard for the previous week will be returned.
15
+ * Returns the operator-configured standalone leaderboard for the
16
+ * given period type — top-20 ranked entries, the current user's
17
+ * own entry (when authenticated), and the configured prize table.
18
+ * Use this to power a leaderboard page with daily / weekly /
19
+ * monthly tabs.
17
20
  *
18
- * **Example**:
19
- * ```
20
- * _smartico.api.getLeaderBoard(1).then((result) => {
21
- * console.log(result);
22
- * });
23
- * ```
21
+ * The leaderboard for each period type is configured separately by
22
+ * the operator. A label may have any combination of DAILY, WEEKLY,
23
+ * and MONTHLY boards configured (or none).
24
24
  *
25
- * **Example in the Visitor mode**:
26
- * ```
27
- * _smartico.vapi('EN').getLeaderBoard(1).then((result) => {
28
- * console.log(result);
29
- * });
25
+ * @remarks
26
+ * **Return value note** — the runtime may return `undefined` if no
27
+ * board is configured for the requested `periodType`, despite the
28
+ * static return type being `Promise<LeaderBoardDetailsT>`. Defend
29
+ * against that case in consumer code.
30
+ *
31
+ * **Preconditions**
32
+ * Pass a `periodType` from {@link LeaderBoardPeriodType}
33
+ * (`DAILY = 1`, `WEEKLY = 2`, `MONTHLY = 3`). Pass
34
+ * `getPreviousPeriod: true` to fetch the most-recently-ended
35
+ * period's snapshot (yesterday's results, last week's results,
36
+ * last month's results) instead of the current live period. The
37
+ * SDK only exposes one period back — older snapshots are not
38
+ * reachable through this method.
39
+ *
40
+ * **Top-20 cap**
41
+ * The server hard-caps `users[]` at 20 entries, ordered by
42
+ * `position` ASC. Position values are server-computed (DENSE_RANK
43
+ * over all participants); the truncation at 20 is for transport
44
+ * size only — `position` may exceed 20 elsewhere.
45
+ *
46
+ * **The `me` field**
47
+ * Always populated for authenticated users (even when they have
48
+ * zero points in the period). `me.position === -1` is the signal
49
+ * that the user is active but ranked outside the top 20 (or has no
50
+ * activity yet). `me` is `undefined` for visitor-mode sessions.
51
+ *
52
+ * **Rewards are points only**
53
+ * `rewards[].points` are gamification points credited to the user's
54
+ * balance when the period finalizes. The leaderboard never awards
55
+ * gems, diamonds, store items, or bonuses. The first element of
56
+ * the array is the prize for place 1, the second for place 2, and
57
+ * so on. The array length is the number of paid places.
58
+ *
59
+ * **Cache TTL — single shared key (known limitation)**
60
+ * The SDK caches the response for 30 seconds under a SINGLE shared
61
+ * key — calling `getLeaderBoard(DAILY)` followed by
62
+ * `getLeaderBoard(WEEKLY)` within the same 30 s window returns the
63
+ * cached DAILY result for the WEEKLY call. Same applies to
64
+ * switching `getPreviousPeriod`. To force a fresh fetch when
65
+ * switching periods or current/previous, call
66
+ * `_smartico.api.clearCaches()` before the second call, or simply
67
+ * wait out the TTL.
68
+ *
69
+ * **Period boundaries**
70
+ * The server finalizes each period on a server-configurable
71
+ * schedule: DAILY at midnight + operator-defined offset; WEEKLY
72
+ * at the start of Monday; MONTHLY on the 1st of each month. At
73
+ * finalization, the server distributes the configured `rewards[]`
74
+ * points to the top placeholders and resets the live board. After
75
+ * finalization, `getLeaderBoard(periodType, false)` returns the
76
+ * NEW (empty) period's board; call with
77
+ * `getPreviousPeriod: true` to see the just-ended standings.
78
+ *
79
+ * **Refresh model**
80
+ * - One-shot fetch (no subscription).
81
+ * - No push event refreshes the cache; finalization at the period
82
+ * boundary is NOT pushed to the client.
83
+ * - Poll manually if the consumer needs near-live state during an
84
+ * in-progress period.
85
+ *
86
+ * **Idempotency / Side effects**: safe. Read-only.
87
+ *
88
+ * **UI guidance**: see [UI Guide — `getLeaderBoard`](../../docs/ui/leaderboard/UIGuide_getLeaderBoard.md).
89
+ *
90
+ * **Visitor mode**: supported. The same shape is returned, scoped
91
+ * to the brand's public leaderboard. `me` is `undefined` for
92
+ * visitors.
93
+ *
94
+ * @param periodType The board's period type
95
+ * ({@link LeaderBoardPeriodType}).
96
+ * Selects which pre-configured board to
97
+ * fetch; the board itself is bound to one
98
+ * period by the operator.
99
+ * @param getPreviousPeriod When `true`, returns the most recent
100
+ * finalized snapshot for that period type
101
+ * (e.g. last week's results). Defaults to
102
+ * `false` (current in-progress period).
103
+ * @returns Promise resolving to `LeaderBoardDetailsT`.
104
+ * **At runtime, may resolve to `undefined`**
105
+ * when no board is configured for the
106
+ * requested period type — guard against it.
107
+ *
108
+ * @example
109
+ * ```ts
110
+ * import { LeaderBoardPeriodType } from '@smartico/public-api';
111
+ *
112
+ * const board = await window._smartico.api.getLeaderBoard(LeaderBoardPeriodType.WEEKLY);
113
+ *
114
+ * if (!board) {
115
+ * console.log('[smartico] no weekly board configured for this label — hide the leaderboard surface');
116
+ * return;
117
+ * }
118
+ *
119
+ * console.log('[smartico] render leaderboard tab —', board.name, '—', board.users.length, 'ranked entries (top 20 max)');
120
+ *
121
+ * // Render prize table.
122
+ * for (const reward of board.rewards) {
123
+ * console.log('[smartico] prize row — place', reward.place, '→', reward.points, 'points');
124
+ * }
125
+ *
126
+ * // "Me" panel — sticky row showing the current user's rank.
127
+ * if (board.me) {
128
+ * if (board.me.position === -1) {
129
+ * console.log('[smartico] user is unranked — show "You are unranked, earn points to enter the leaderboard"');
130
+ * } else if (board.me.position > 20) {
131
+ * console.log('[smartico] user is ranked', board.me.position, 'but outside the visible top-20 — show sticky "me" row with', board.me.points, 'points');
132
+ * } else {
133
+ * console.log('[smartico] user is in the top 20 at position', board.me.position, '— highlight their row in the main list');
134
+ * }
135
+ * }
136
+ *
137
+ * // Switch to previous period view — but bust the cache first to avoid the shared-key collision.
138
+ * await window._smartico.api.clearCaches();
139
+ * const prev = await window._smartico.api.getLeaderBoard(LeaderBoardPeriodType.WEEKLY, true);
140
+ * console.log('[smartico] previous-week standings — render with greyed-out "ended" treatment:', prev?.users.length, 'finalists');
141
+ *
142
+ * // Visitor-mode equivalent — me is always undefined.
143
+ * // const visitorBoard = await window._smartico.vapi('EN').getLeaderBoard(LeaderBoardPeriodType.DAILY);
30
144
  * ```
31
145
  */
32
146
  public async getLeaderBoard(periodType: LeaderBoardPeriodType, getPreviousPeriod?: boolean): Promise<LeaderBoardDetailsT> {