@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,533 @@
1
+ import { TActivityLog, TLevel, TLevelCurrent, TSegmentCheckResult, TUserProfile, UserLevelExtraCountersT } from './WSAPITypes';
2
+ import { WSAPIBase } from './WSAPIBase';
3
+ /** @group User */
4
+ export declare class WSAPIUser extends WSAPIBase {
5
+ /**
6
+ * Returns the current user's public profile — the source of truth for
7
+ * balances (points / gems / diamonds), the current level ID, the
8
+ * display username + avatar, language, public tags, and the inbox
9
+ * unread count. **This method is synchronous** (returns `TUserProfile`,
10
+ * not a Promise): the SDK keeps a local snapshot of the user's public
11
+ * properties that is initialised at identify time and kept live by a
12
+ * server-driven update channel — every call returns the latest cached
13
+ * values without a network round-trip.
14
+ *
15
+ * Subscribe to changes by registering a callback on `_smartico.on('props_change', ...)`
16
+ * — the callback fires with the full snapshot at identify and with
17
+ * partial-key updates on every subsequent server push (typically
18
+ * under 1 second after the underlying state change).
19
+ *
20
+ * @remarks
21
+ * **Preconditions**
22
+ * The tracker must be initialised — calling this before the identify
23
+ * round-trip completes throws (`"Tracker is not initialized, cannot
24
+ * getUserProfile"`). Safe ways to wait for readiness:
25
+ * - register `_smartico.on('identify', (errCode, props) => ...)` —
26
+ * fires once after a successful identify with the full props
27
+ * - register `_smartico.on('props_change', () => ...)` — fires first
28
+ * at identify with the full snapshot, then on every push update
29
+ *
30
+ * **What's kept live (push-updated)**
31
+ * Balance fields (`ach_points_balance`, `ach_gems_balance`,
32
+ * `ach_diamonds_balance`, `ach_points_ever`), `ach_level_current_id`,
33
+ * `core_public_tags`, `core_inbox_unread_count`, `core_user_language`,
34
+ * `avatar_url`, `public_username`, and the AI-driven recommended-amount
35
+ * fields all flow over the SDK's user-properties update channel as
36
+ * partial updates — the snapshot is patched in place when any of them
37
+ * change server-side. Re-call `getUserProfile()` (or watch
38
+ * `props_change`) to observe new values.
39
+ *
40
+ * **Reading state from the returned profile**
41
+ * Balances (`ach_points_balance`, `ach_gems_balance`,
42
+ * `ach_diamonds_balance`) are the canonical source for affordability
43
+ * checks across the SDK — compare against `entry_fee_amount` (clans),
44
+ * `registration_cost_points` / `_gems` / `_diamonds` (tournaments), and
45
+ * `price` / `discounted_price` + `purchase_type` (store items).
46
+ * `ach_points_ever` is monotonic — store purchases deduct from
47
+ * `ach_points_balance` but NEVER from `ach_points_ever`, so it remains
48
+ * useful for level-progress math (`required_points` on the next
49
+ * {@link getLevels} entry minus `ach_points_ever`). `ach_level_current_id`
50
+ * is the FK into the level ladder — resolve metadata via
51
+ * {@link getCurrentLevel} (richer, includes progress %) or
52
+ * {@link getLevels} (full ladder lookup table).
53
+ *
54
+ * **Inbox unread count** — `core_inbox_unread_count` on this profile
55
+ * is push-updated in real time (under 1 second). For an inbox badge,
56
+ * prefer this field over `getInboxUnreadCount` (which is cached
57
+ * for 30 s) — same value, fresher signal.
58
+ *
59
+ * **Language**: `core_user_language` reflects the server's stored
60
+ * language. If the consumer just called `_smartico.changeLanguage(...)`,
61
+ * the field may briefly lag the local intent until the server push
62
+ * arrives. Use `_smartico.getPublicProps()` for the
63
+ * client-fallback-applied version if instant accuracy matters.
64
+ *
65
+ * **Idempotency / Side effects**: trivially safe — no network call,
66
+ * no state mutation.
67
+ *
68
+ * **UI guidance**: see [UI Guide — `getUserProfile`](../../docs/ui/user/UIGuide_getUserProfile.md).
69
+ *
70
+ * **Visitor mode**: not supported — throws. Visitor sessions do not
71
+ * have a public-profile snapshot.
72
+ *
73
+ * @returns The current cached `TUserProfile` snapshot. A shallow copy —
74
+ * mutating it does not affect the SDK's internal state.
75
+ * @throws `Error("Tracker is not initialized, cannot getUserProfile")`
76
+ * if called before identify completes or from a visitor session.
77
+ *
78
+ * @example
79
+ * ```ts
80
+ * // Wait for identify before calling.
81
+ * window._smartico.on('identify', (errCode) => {
82
+ * if (errCode !== 0) return;
83
+ * const profile = window._smartico.api.getUserProfile();
84
+ * console.log('[smartico] initial profile loaded — render the user widget:', profile);
85
+ * });
86
+ *
87
+ * // Stay in sync with live updates.
88
+ * window._smartico.on('props_change', (changed) => {
89
+ * // `changed` is the partial keys for this push (full snapshot at identify).
90
+ * const profile = window._smartico.api.getUserProfile();
91
+ * console.log('[smartico] profile updated — re-render any widgets bound to:', Object.keys(changed),
92
+ * '— balances now:', profile.ach_points_balance, profile.ach_gems_balance, profile.ach_diamonds_balance);
93
+ *
94
+ * // React to specific fields.
95
+ * if ('ach_level_current_id' in changed) {
96
+ * console.log('[smartico] level changed — call getCurrentLevel() for richer detail, animate the level badge');
97
+ * }
98
+ * if ('core_inbox_unread_count' in changed) {
99
+ * console.log('[smartico] inbox unread count changed — update the badge to:', profile.core_inbox_unread_count);
100
+ * }
101
+ * });
102
+ *
103
+ * // Affordability gating example — used inside a clan / tournament / store CTA handler.
104
+ * const profile = window._smartico.api.getUserProfile();
105
+ * const item = await window._smartico.api.getStoreItems().then(items => items[0]);
106
+ * const price = item.discounted_price ?? item.price;
107
+ * const balance = {
108
+ * points: profile.ach_points_balance,
109
+ * gems: profile.ach_gems_balance,
110
+ * diamonds: profile.ach_diamonds_balance,
111
+ * }[item.purchase_type];
112
+ * if (balance < price) {
113
+ * console.log('[smartico] insufficient', item.purchase_type, '— disable Buy and show deficit', price - balance);
114
+ * }
115
+ * ```
116
+ */
117
+ getUserProfile(): TUserProfile;
118
+ /**
119
+ * Checks whether the current user matches a single segment, returning
120
+ * `true` / `false` directly. Use this as a decision primitive to gate
121
+ * UI surfaces (e.g. show a "VIP lounge" tab only when the user is in
122
+ * the VIP segment), or to drive segment-specific CTA copy.
123
+ *
124
+ * Every call is a server round-trip — there is no SDK-side cache. For
125
+ * checking multiple segments in one round-trip, use
126
+ * {@link checkSegmentListMatch} instead.
127
+ *
128
+ * @remarks
129
+ * **Refresh model**
130
+ * - **No client cache.** Every call sends a request; the SDK does not
131
+ * memoize results.
132
+ * - **No push event** notifies the consumer when segment membership
133
+ * flips (the user crosses a qualification threshold, or the
134
+ * operator changes the segment definition). Membership changes
135
+ * become visible only on the next `checkSegmentMatch` call.
136
+ * - **Behavioral segments (configured against BigQuery) have batch
137
+ * lag** — even if the user's activity has changed (deposit, wager,
138
+ * etc.), the segment-membership result may not reflect that change
139
+ * until the next batch evaluation run (typically up to several
140
+ * hours).
141
+ *
142
+ * **Rate limit** (important)
143
+ * The server caps `checkSegment*` calls at **10 requests per
144
+ * 60-second window**, with a minimum gap of **~5 seconds between
145
+ * consecutive calls**. Avoid calling on every render — cache the
146
+ * result client-side for the session, or until you have a reason to
147
+ * believe the user's state changed (e.g. after a deposit completes,
148
+ * a level changes via {@link getUserProfile}'s `props_change`, or a
149
+ * specific custom event fires).
150
+ *
151
+ * **`is_matching: false` is ambiguous on the server** — both "the
152
+ * segment doesn't exist for this label" and "the user doesn't
153
+ * qualify" return `false` with no distinguishing signal. Pass IDs
154
+ * you've verified are valid for your label.
155
+ *
156
+ * **Idempotency**: safe. Read-only. No side effects (no analytics
157
+ * events, no DB writes).
158
+ *
159
+ * **Visitor mode**: not supported.
160
+ *
161
+ * @param segment_id The segment ID. Segment IDs are label-scoped;
162
+ * the same numeric ID can refer to different
163
+ * segments under different labels. Use the IDs
164
+ * configured for your label.
165
+ * @returns `true` if the user currently matches the
166
+ * segment, `false` otherwise. `false` also covers
167
+ * the "segment doesn't exist for this label"
168
+ * case — these are not distinguishable.
169
+ *
170
+ * @example
171
+ * ```ts
172
+ * const isVip = await window._smartico.api.checkSegmentMatch(vipSegmentId);
173
+ * if (isVip) {
174
+ * console.log('[smartico] user is in VIP segment — render the VIP-only widget surface');
175
+ * } else {
176
+ * console.log('[smartico] user not in VIP segment (or segment id misconfigured) — hide the VIP surface');
177
+ * }
178
+ *
179
+ * // Cache the result for the session; re-check after material user-state changes.
180
+ * window._smartico.on('props_change', async (changed) => {
181
+ * if ('ach_points_ever' in changed || 'ach_level_current_id' in changed) {
182
+ * const fresh = await window._smartico.api.checkSegmentMatch(vipSegmentId);
183
+ * console.log('[smartico] user state changed — VIP membership now:', fresh);
184
+ * }
185
+ * });
186
+ * ```
187
+ */
188
+ checkSegmentMatch(segment_id: number): Promise<boolean>;
189
+ /**
190
+ * Checks the current user's membership in multiple segments in a
191
+ * single server round-trip — returns a `TSegmentCheckResult[]` with
192
+ * one entry per *unique* segment ID. Use this instead of looping
193
+ * {@link checkSegmentMatch} when you need to evaluate several
194
+ * segments at once (e.g. multi-segment composite gating, A/B-style
195
+ * cohort detection).
196
+ *
197
+ * @remarks
198
+ * **Response order is NOT guaranteed**
199
+ * The server returns results in an unspecified order — different
200
+ * from the input array. Always correlate by the `segment_id` field on
201
+ * each `TSegmentCheckResult` rather than by array position. The
202
+ * returned array length may also be smaller than the input array
203
+ * (duplicate IDs are silently de-duplicated server-side).
204
+ *
205
+ * **Single round-trip**
206
+ * The entire `segment_ids` array is sent in one request. Two segments
207
+ * cost the same as one in terms of network latency and rate-limit
208
+ * consumption (one call = one rate-limit slot, regardless of how many
209
+ * segments).
210
+ *
211
+ * **Shared semantics with `checkSegmentMatch`**
212
+ * Both methods wrap the same underlying server endpoint and share
213
+ * the same caching, refresh, rate-limit, and ambiguity behavior. See
214
+ * {@link checkSegmentMatch} for: no client cache · no push event for
215
+ * membership changes · behavioral segments have batch lag · rate
216
+ * limit (10 requests / 60 s, ~5 s minimum gap between calls) ·
217
+ * `is_matching: false` doesn't distinguish "not in segment" from
218
+ * "segment doesn't exist for this label".
219
+ *
220
+ * **Idempotency**: safe. Read-only. No side effects.
221
+ *
222
+ * **Visitor mode**: not supported.
223
+ *
224
+ * @param segment_ids Array of segment IDs to check. Duplicates are
225
+ * silently de-duplicated server-side. Segment IDs
226
+ * are label-scoped — use the IDs configured for
227
+ * your label.
228
+ * @returns Array of `{ segment_id, is_matching }` results.
229
+ * Order is NOT guaranteed; correlate by
230
+ * `segment_id`. Length may be less than the input
231
+ * when duplicate IDs were sent.
232
+ *
233
+ * @example
234
+ * ```ts
235
+ * const segmentIds = [vipSegmentId, newPlayerSegmentId, freeRollSegmentId];
236
+ * const results = await window._smartico.api.checkSegmentListMatch(segmentIds);
237
+ *
238
+ * // Always correlate by segment_id — the response order is unspecified.
239
+ * const byId = new Map(results.map(r => [r.segment_id, r.is_matching]));
240
+ *
241
+ * if (byId.get(vipSegmentId)) {
242
+ * console.log('[smartico] user is in VIP segment — render VIP surface');
243
+ * }
244
+ * if (byId.get(newPlayerSegmentId) && byId.get(freeRollSegmentId)) {
245
+ * console.log('[smartico] new player AND eligible for free roll — show the welcome promo');
246
+ * }
247
+ *
248
+ * // Cache the result map for the session; refresh on material state changes.
249
+ * ```
250
+ */
251
+ checkSegmentListMatch(segment_ids: number[]): Promise<TSegmentCheckResult[]>;
252
+ /**
253
+ * Returns the full level ladder configured for the current label —
254
+ * one `TLevel` per active level, server-sorted by `required_points`
255
+ * ASC (lowest first; `ordinal_position` is a 1-based index into the
256
+ * returned array). Use this to render a level map / progression
257
+ * screen, or as a lookup table to resolve `ach_level_current_id` from
258
+ * {@link getUserProfile} into a richer level object.
259
+ *
260
+ * @remarks
261
+ * **Server-side filtering**
262
+ * The server returns ALL active levels for the label. There is NO
263
+ * per-user filtering on visibility, level-status, or anything else —
264
+ * the response is identical across users of the same label. Apply
265
+ * `visibility_points` filtering client-side if you want to hide
266
+ * not-yet-reached levels (compare against
267
+ * `getUserProfile().ach_points_ever` and exclude levels where
268
+ * `visibility_points > ach_points_ever`).
269
+ *
270
+ * **Sort order**
271
+ * The returned array is already sorted by `required_points` ASC, and
272
+ * `ordinal_position` is a 1-based index into that same sort order —
273
+ * client-side re-sorting is not required for the default rendering.
274
+ * If your label uses sliding-window leveling logic
275
+ * (see {@link getUserLevelExtraCounters}) and you want to sort by
276
+ * a multi-criteria key (`required_points`, then
277
+ * `required_level_counter_1`, then `required_level_counter_2`), do
278
+ * that client-side.
279
+ *
280
+ * **Cache TTL**: the SDK caches the response for 30 seconds. Cache
281
+ * is fully cleared on login / logout. Operator-driven level edits
282
+ * surface on the next cache miss.
283
+ *
284
+ * **Idempotency / Side effects**: safe. Read-only metadata. Calls
285
+ * within the cache window de-duplicate to the same cached array.
286
+ *
287
+ * **UI guidance**: see [UI Guide — `getLevels`](../../docs/ui/user/UIGuide_getLevels.md).
288
+ *
289
+ * **Visitor mode**: supported. Use `_smartico.vapi(lang).getLevels()`
290
+ * to fetch the ladder for anonymous viewers; the level configuration
291
+ * is label-scoped static data so the response is meaningful even
292
+ * without an authenticated user. Per-user fields (the implicit
293
+ * "current level" via {@link getCurrentLevel}, or the user's progress)
294
+ * are not available in visitor mode.
295
+ *
296
+ * @returns Promise resolving to the ordered `TLevel[]` ladder. Empty
297
+ * if no levels are configured for the label.
298
+ *
299
+ * @example
300
+ * ```ts
301
+ * const [levels, profile] = await Promise.all([
302
+ * window._smartico.api.getLevels(),
303
+ * Promise.resolve(window._smartico.api.getUserProfile()),
304
+ * ]);
305
+ *
306
+ * // Resolve the user's current level by ID.
307
+ * const current = levels.find(l => l.id === profile.ach_level_current_id);
308
+ * console.log('[smartico] render header badge — current level:', current?.name,
309
+ * '(position', current?.ordinal_position, 'of', levels.length, ')');
310
+ *
311
+ * // Filter to levels the user has unlocked enough to see.
312
+ * const visible = levels.filter(l =>
313
+ * l.visibility_points == null || l.visibility_points <= profile.ach_points_ever
314
+ * );
315
+ * console.log('[smartico] render the level map with', visible.length, 'visible tiles');
316
+ *
317
+ * // Visitor-mode equivalent: returns the same ladder; no per-user state.
318
+ * // const visitorLevels = await window._smartico.vapi('EN').getLevels();
319
+ * ```
320
+ */
321
+ getLevels(): Promise<TLevel[]>;
322
+ /**
323
+ * Returns the user's current level — every `TLevel` field plus a
324
+ * computed `progress` percentage toward the next level. Use this to
325
+ * power a level badge with a progress bar.
326
+ *
327
+ * @remarks
328
+ * **How `progress` is computed**
329
+ * The SDK derives `progress` as the *delta-from-current-level-floor*:
330
+ * `(ach_points_ever − current.required_points) / (next.required_points
331
+ * − current.required_points) × 100`, clamped to `[0, 100]`. At the
332
+ * highest level (no next level), `progress` is `100`. Reading the
333
+ * source values directly from {@link getUserProfile}'s
334
+ * `ach_points_ever` and {@link getLevels} would also work, but
335
+ * `progress` saves the math.
336
+ *
337
+ * **Cache TTL**: the SDK caches the response for 30 seconds. There is
338
+ * no push event that refreshes this cache; a server-side level change
339
+ * (visible immediately on {@link getUserProfile}'s `ach_level_current_id`
340
+ * via the user-properties update channel) becomes visible on this
341
+ * method only after the cache TTL expires, or after
342
+ * `_smartico.api.clearCaches()` is called.
343
+ *
344
+ * **Leveling logic**
345
+ * The semantics of how a user advances depends on the label's
346
+ * leveling logic (configured per brand): points-only (the default),
347
+ * sliding-window with extra counters (uses
348
+ * {@link getUserLevelExtraCounters}), or fully-manual operator
349
+ * assignment. The `progress` percentage on this method assumes the
350
+ * points-only model — it's not meaningful for manual-only labels
351
+ * where level changes are operator-driven rather than points-driven.
352
+ *
353
+ * **Idempotency**: safe. Read-only. Repeated calls within the cache
354
+ * window return a deep-cloned cached value without a network
355
+ * round-trip.
356
+ *
357
+ * **Side effects**: none — pure read.
358
+ *
359
+ * **Visitor mode**: not supported.
360
+ *
361
+ * @returns Promise resolving to `TLevelCurrent` — the current level
362
+ * plus `progress: number` (0–100).
363
+ *
364
+ * @example
365
+ * ```ts
366
+ * const level = await window._smartico.api.getCurrentLevel();
367
+ * console.log('[smartico] render level badge — name:', level.name,
368
+ * 'progress:', Math.round(level.progress), '%');
369
+ *
370
+ * // Detect level-up via getUserProfile's push channel.
371
+ * window._smartico.on('props_change', async (changed) => {
372
+ * if ('ach_level_current_id' in changed) {
373
+ * await window._smartico.api.clearCaches(); // bust the 30 s cache
374
+ * const fresh = await window._smartico.api.getCurrentLevel();
375
+ * console.log('[smartico] user levelled up — animate badge to new level:', fresh.name);
376
+ * }
377
+ * });
378
+ * ```
379
+ */
380
+ getCurrentLevel(): Promise<TLevelCurrent>;
381
+ /**
382
+ * Returns the user's current values for the two label-defined "extra
383
+ * counters" used by sliding-window leveling logic. Operators
384
+ * configure what each counter means per label (e.g. `level_counter_1`
385
+ * = total deposits in the last 30 days, `level_counter_2` = total
386
+ * wagering in the last 30 days). Compare against
387
+ * `required_level_counter_1` / `_2` on the next level from
388
+ * {@link getLevels} to know how close the user is to advancing.
389
+ *
390
+ * @remarks
391
+ * **When this matters**
392
+ * Only labels configured for sliding-window leveling populate the
393
+ * counter fields. On the default points-only leveling model, both
394
+ * `level_counter_1` and `level_counter_2` are `undefined`. Detect
395
+ * a points-only label by either counter being `undefined`.
396
+ *
397
+ * **Counter semantics — operator-defined**
398
+ * The SDK exposes raw numeric values; the meaning of each counter
399
+ * (deposit amount, wager amount, lifetime spend, etc.) is fully
400
+ * operator-defined per label. Resolve labels for display via
401
+ * `getTranslations` — the operator's display strings are
402
+ * stored under the translation keys `levelsCounter1Name` and
403
+ * `levelsCounter2Name`.
404
+ *
405
+ * **Refresh cadence**
406
+ * Sliding-window counters are recomputed by a server-side job that
407
+ * runs roughly every 60 seconds against the operator's BigQuery
408
+ * dataset; level transitions driven by counter changes have a
409
+ * latency of up to several minutes after the underlying activity
410
+ * (e.g. a deposit). The SDK caches the response for 30 seconds; no
411
+ * push event refreshes this cache. After a level change visible on
412
+ * {@link getUserProfile}'s `ach_level_current_id`, call
413
+ * `_smartico.api.clearCaches()` to force a fresh fetch.
414
+ *
415
+ * **Idempotency**: safe. Read-only. Repeated calls within the cache
416
+ * window return a deep-cloned cached value without a network
417
+ * round-trip.
418
+ *
419
+ * **Side effects**: none — pure read.
420
+ *
421
+ * **Visitor mode**: not supported.
422
+ *
423
+ * @returns Promise resolving to `UserLevelExtraCountersT`. Both
424
+ * fields are `undefined` on labels not using sliding-window
425
+ * leveling.
426
+ *
427
+ * @example
428
+ * ```ts
429
+ * const [counters, levels, profile] = await Promise.all([
430
+ * window._smartico.api.getUserLevelExtraCounters(),
431
+ * window._smartico.api.getLevels(),
432
+ * Promise.resolve(window._smartico.api.getUserProfile()),
433
+ * ]);
434
+ *
435
+ * // Quick detection: undefined means this label doesn't use sliding-window leveling.
436
+ * if (counters.level_counter_1 === undefined) {
437
+ * console.log('[smartico] points-only label — skip counter UI; show points progress only');
438
+ * return;
439
+ * }
440
+ *
441
+ * // Find the next level and render a 3-bar progress block.
442
+ * const currentIdx = levels.findIndex(l => l.id === profile.ach_level_current_id);
443
+ * const next = levels[currentIdx + 1];
444
+ * if (next) {
445
+ * console.log('[smartico] render points bar:', profile.ach_points_ever, '/', next.required_points);
446
+ * if (next.required_level_counter_1) {
447
+ * console.log('[smartico] render counter 1 bar:', counters.level_counter_1, '/', next.required_level_counter_1);
448
+ * }
449
+ * if (next.required_level_counter_2) {
450
+ * console.log('[smartico] render counter 2 bar:', counters.level_counter_2, '/', next.required_level_counter_2);
451
+ * }
452
+ * }
453
+ * ```
454
+ */
455
+ getUserLevelExtraCounters(): Promise<UserLevelExtraCountersT>;
456
+ /**
457
+ * Returns the user's unified balance-change history — every points, gems, and
458
+ * diamonds transaction within the requested time window, ordered newest-first.
459
+ * Use to power an "Activity" / "History" tab showing wins, claims, purchases,
460
+ * level-up rewards, and operator adjustments.
461
+ *
462
+ * The returned shape is the same regardless of currency type — `type` (see
463
+ * {@link UserBalanceType}) distinguishes points / gems / diamonds and
464
+ * `source_type_id` (see {@link PointChangeSourceType}) names the originating
465
+ * event.
466
+ *
467
+ * @remarks
468
+ * **Preconditions**
469
+ * - User must be authenticated. Visitor mode is not guarded at the SDK level
470
+ * but is not meaningful — activity is per-user.
471
+ *
472
+ * **Pagination — `from` / `to` are offset + ceiling, not timestamps**
473
+ * The SDK derives `offset = from`, `limit = min(to - from, 50)` — the server
474
+ * hard-caps a single response at 50 entries. For infinite scroll, advance
475
+ * `from` by 50 between calls. Both `startTimeSeconds` and `endTimeSeconds`
476
+ * are epoch seconds bounding the window the server scans.
477
+ *
478
+ * **Subscription model (`onUpdate`)**
479
+ * The callback fires when the user's `ach_points_balance`,
480
+ * `ach_gems_balance`, or `ach_diamonds_balance` changes (i.e. whenever a
481
+ * wallet event lands). The pushed payload is a FIXED re-fetch of the
482
+ * **last 10 minutes / first 50 entries** — it does NOT honor the original
483
+ * call's `startTimeSeconds` / `endTimeSeconds` / `from` / `to`. Consumers
484
+ * maintaining a long historical view must re-call `getActivityLog` with
485
+ * their own params after receiving an `onUpdate` notification.
486
+ *
487
+ * **Refresh**
488
+ * - The SDK caches results for 30 seconds.
489
+ * - Push triggers fire only on balance changes; transactions that don't
490
+ * alter a balance (theoretical zero-amount entries) won't refresh.
491
+ *
492
+ * **Visitor mode**: not meaningful (no per-user history available).
493
+ *
494
+ * **UI guidance**: see [UI Guide — `getActivityLog`](../../docs/ui/user/UIGuide_getActivityLog.md).
495
+ *
496
+ * @returns Array of {@link TActivityLog} ordered newest-first.
497
+ *
498
+ * @example
499
+ * ```ts
500
+ * const now = Math.floor(Date.now() / 1000);
501
+ * const start = now - 86400 * 30; // 30 days
502
+ *
503
+ * const log = await window._smartico.api.getActivityLog({
504
+ * startTimeSeconds: start,
505
+ * endTimeSeconds: now,
506
+ * from: 0,
507
+ * to: 50,
508
+ * onUpdate: (refreshed) => {
509
+ * console.log('[smartico] wallet changed — refreshed payload is last 10 min / 50 entries:', refreshed.length, 'rows');
510
+ * // If the consumer is showing a full 30-day view, re-call getActivityLog with the original params here.
511
+ * },
512
+ * });
513
+ *
514
+ * for (const row of log) {
515
+ * const sign = row.amount >= 0 ? '+' : '';
516
+ * console.log('[smartico] activity row — render with', row.type === 0 ? 'points' : row.type === 1 ? 'gems' : 'diamonds', 'icon, color by sign:', sign + row.amount, 'balance after:', row.balance, 'source:', row.source_type_id);
517
+ * }
518
+ * ```
519
+ */
520
+ getActivityLog({ startTimeSeconds, endTimeSeconds, from, to, onUpdate, }: {
521
+ /** Window start in epoch seconds. */
522
+ startTimeSeconds: number;
523
+ /** Window end in epoch seconds. */
524
+ endTimeSeconds: number;
525
+ /** Pagination offset (0-based). */
526
+ from: number;
527
+ /** Pagination ceiling (exclusive); server caps `to - from` at 50. */
528
+ to: number;
529
+ /** Optional push callback; payload is a fixed 10-min / 50-entry refresh on every wallet change (see Subscription model). */
530
+ onUpdate?: (data: TActivityLog[]) => void;
531
+ }): Promise<TActivityLog[]>;
532
+ protected notifyActivityLogUpdate(): Promise<void>;
533
+ }