@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.
- package/.nvmrc +1 -1
- package/CLAUDE.md +103 -0
- package/README.md +53 -2
- package/dist/Base/ClassId.d.ts +2 -0
- package/dist/Jackpots/JackpotDetails.d.ts +14 -15
- package/dist/Jackpots/JackpotPot.d.ts +10 -6
- package/dist/Raffle/GetRaffleWonPrizesRequest.d.ts +9 -0
- package/dist/Raffle/GetRaffleWonPrizesResponse.d.ts +52 -0
- package/dist/Raffle/index.d.ts +2 -0
- package/dist/SmarticoAPI.d.ts +6 -1
- package/dist/SmarticoLib/index.d.ts +5 -1
- package/dist/Store/BuyStoreItemErrorCode.d.ts +9 -1
- package/dist/Tournaments/TournamentRegistrationError.d.ts +3 -1
- package/dist/WSAPI/WSAPI.d.ts +13 -1235
- package/dist/WSAPI/WSAPIAvatars.d.ts +296 -0
- package/dist/WSAPI/WSAPIBase.d.ts +71 -0
- package/dist/WSAPI/WSAPIBonuses.d.ts +240 -0
- package/dist/WSAPI/WSAPIClans.d.ts +388 -0
- package/dist/WSAPI/WSAPIGamePick.d.ts +593 -0
- package/dist/WSAPI/WSAPIGeneral.d.ts +172 -0
- package/dist/WSAPI/WSAPIInbox.d.ts +615 -0
- package/dist/WSAPI/WSAPIJackpots.d.ts +344 -0
- package/dist/WSAPI/WSAPILeaderBoard.d.ts +139 -0
- package/dist/WSAPI/WSAPIMiniGames.d.ts +510 -0
- package/dist/WSAPI/WSAPIMissions.d.ts +517 -0
- package/dist/WSAPI/WSAPIRaffles.d.ts +643 -0
- package/dist/WSAPI/WSAPIStore.d.ts +656 -0
- package/dist/WSAPI/WSAPITournaments.d.ts +501 -0
- package/dist/WSAPI/WSAPITypes.d.ts +376 -205
- package/dist/WSAPI/WSAPIUser.d.ts +533 -0
- package/dist/index.js +6745 -1661
- package/dist/index.js.map +1 -1
- package/dist/index.modern.mjs +6324 -1342
- package/dist/index.modern.mjs.map +1 -1
- package/docs/Callbacks.md +162 -0
- package/docs/SmarticoObject.md +445 -0
- package/docs/Transforms.md +99 -0
- package/docs/api/README.md +82 -2
- package/docs/api/classes/WSAPIAvatars.md +344 -0
- package/docs/api/classes/WSAPIBonuses.md +271 -0
- package/docs/api/classes/WSAPIClans.md +436 -0
- package/docs/api/classes/WSAPIGamePick.md +710 -0
- package/docs/api/classes/WSAPIGeneral.md +212 -0
- package/docs/api/classes/WSAPIInbox.md +801 -0
- package/docs/api/classes/WSAPIJackpots.md +439 -0
- package/docs/api/classes/WSAPILeaderBoard.md +157 -0
- package/docs/api/classes/WSAPIMiniGames.md +612 -0
- package/docs/api/classes/WSAPIMissions.md +590 -0
- package/docs/api/classes/WSAPIRaffles.md +773 -0
- package/docs/api/classes/WSAPIStore.md +719 -0
- package/docs/api/classes/WSAPITournaments.md +571 -0
- package/docs/api/classes/WSAPIUser.md +637 -0
- package/docs/api/documents/Callbacks.md +162 -0
- package/docs/api/documents/SmarticoObject.md +445 -0
- package/docs/api/documents/Transforms.md +99 -0
- package/docs/api/enumerations/AchievementClaimPeriodTypeId.md +13 -0
- package/docs/api/enumerations/BonusStatus-1.md +11 -6
- package/docs/api/enumerations/BuyStoreItemErrorCode.md +32 -0
- package/docs/api/enumerations/JoinClanErrorCode.md +81 -0
- package/docs/api/enumerations/TournamentRegistrationError.md +12 -0
- package/docs/api/functions/clanTournamentPlayersTransform.md +13 -0
- package/docs/api/interfaces/AvatarCustomized.md +25 -0
- package/docs/api/interfaces/AvatarDefinition.md +94 -0
- package/docs/api/interfaces/AvatarPrompt.md +45 -0
- package/docs/api/interfaces/BonusMetaMap-1.md +4 -1
- package/docs/api/interfaces/BonusTemplateMetaMap-1.md +9 -4
- package/docs/api/interfaces/Clan.md +4 -0
- package/docs/api/interfaces/ClanInfo.md +109 -0
- package/docs/api/interfaces/ClanMember.md +53 -0
- package/docs/api/interfaces/ClanPrizePublicMeta.md +41 -0
- package/docs/api/interfaces/ClanPrizeStructureEntry.md +7 -1
- package/docs/api/interfaces/ClanPublicMeta.md +4 -0
- package/docs/api/interfaces/ClanTournamentPlayerRaw.md +67 -0
- package/docs/api/interfaces/GemsDiamondsLog.md +43 -0
- package/docs/api/interfaces/GetClanInfoResponse.md +61 -0
- package/docs/api/interfaces/GetClanTournamentPlayersResponse.md +81 -0
- package/docs/api/interfaces/GetRaffleWonPrizesRequest.md +59 -0
- package/docs/api/interfaces/GetRaffleWonPrizesResponse.md +95 -0
- package/docs/api/interfaces/InboxMarkMessageAction.md +10 -2
- package/docs/api/interfaces/JackpotDetails.md +14 -15
- package/docs/api/interfaces/JackpotPot.md +9 -6
- package/docs/api/interfaces/LeaderBoardDetailsT.md +14 -8
- package/docs/api/interfaces/LeaderBoardUserT.md +8 -5
- package/docs/api/interfaces/LeaderBoardsRewardsT.md +7 -0
- package/docs/api/interfaces/PointsLog.md +43 -0
- package/docs/api/interfaces/RaffleWonPrize.md +59 -0
- package/docs/api/interfaces/RaffleWonPrizePublicMeta.md +27 -0
- package/docs/api/interfaces/RaffleWonPrizeUser.md +43 -0
- package/docs/api/interfaces/SAWTemplateUI.md +10 -0
- package/docs/api/interfaces/TAchCategory.md +14 -4
- package/docs/api/interfaces/TAvatarCustomized.md +4 -4
- package/docs/api/interfaces/TAvatarDefinition.md +13 -14
- package/docs/api/interfaces/TAvatarPrompt.md +6 -6
- package/docs/api/interfaces/TBonus.md +16 -8
- package/docs/api/interfaces/TBuyStoreItemResult.md +4 -11
- package/docs/api/interfaces/TClaimBonusResult.md +5 -5
- package/docs/api/interfaces/TClan.md +8 -4
- package/docs/api/interfaces/TClanInfo.md +47 -0
- package/docs/api/interfaces/TClanJoinResult.md +11 -1
- package/docs/api/interfaces/TClanTournamentPlayer.md +55 -0
- package/docs/api/interfaces/TClanTournamentPlayersResult.md +27 -0
- package/docs/api/interfaces/TClans.md +3 -1
- package/docs/api/interfaces/TGetTranslations.md +4 -0
- package/docs/api/interfaces/TInboxMessage.md +14 -6
- package/docs/api/interfaces/TInboxMessageBody.md +18 -12
- package/docs/api/interfaces/TLevel.md +17 -20
- package/docs/api/interfaces/TLevelCurrent.md +19 -18
- package/docs/api/interfaces/TMiniGamePlayBatchResult.md +14 -6
- package/docs/api/interfaces/TMiniGamePlayResult.md +9 -4
- package/docs/api/interfaces/TMissionClaimRewardResult.md +6 -3
- package/docs/api/interfaces/TMissionOptInResult.md +6 -3
- package/docs/api/interfaces/TMissionOrBadge.md +5 -4
- package/docs/api/interfaces/TRaffleOptinResponse.md +4 -2
- package/docs/api/interfaces/TSegmentCheckResult.md +10 -0
- package/docs/api/interfaces/TSetAvatarResult.md +3 -3
- package/docs/api/interfaces/TStoreItem.md +11 -1
- package/docs/api/interfaces/TTournament.md +1 -1
- package/docs/api/interfaces/TTournamentDetailed.md +9 -1
- package/docs/api/interfaces/TTournamentRegistrationResult.md +4 -2
- package/docs/api/interfaces/TUICustomSection.md +23 -19
- package/docs/api/interfaces/TUserProfile.md +18 -16
- package/docs/api/interfaces/TransformedRaffleClaimPrizeResponse.md +6 -2
- package/docs/api/interfaces/UserAchievement.md +1 -1
- package/docs/api/interfaces/UserLevelExtraCountersT.md +9 -2
- package/docs/api/type-aliases/ActivityLogEntry.md +3 -0
- package/docs/native/ADDING_METHODS.md +7 -2
- package/docs/native/PROTOCOL.md +337 -0
- package/docs/ui/avatars/UIGuide_getAvatarPrompts.md +100 -0
- package/docs/ui/avatars/UIGuide_getAvatarsCustomized.md +90 -0
- package/docs/ui/avatars/UIGuide_getAvatarsList.md +105 -0
- package/docs/ui/avatars/UIGuide_setAvatar.md +118 -0
- package/docs/ui/bonuses/UIGuide_claimBonus.md +144 -0
- package/docs/ui/bonuses/UIGuide_getBonuses.md +176 -0
- package/docs/ui/clans/UIGuide_getClanInfo.md +153 -0
- package/docs/ui/clans/UIGuide_getClans.md +172 -0
- package/docs/ui/clans/UIGuide_joinClan.md +196 -0
- package/docs/ui/gamepick/UIGuide_gamePickGetActiveRound.md +99 -0
- package/docs/ui/gamepick/UIGuide_gamePickGetActiveRounds.md +76 -0
- package/docs/ui/gamepick/UIGuide_gamePickGetBoard.md +81 -0
- package/docs/ui/gamepick/UIGuide_gamePickGetGameInfo.md +78 -0
- package/docs/ui/gamepick/UIGuide_gamePickGetHistory.md +55 -0
- package/docs/ui/gamepick/UIGuide_gamePickGetRoundInfoForUser.md +71 -0
- package/docs/ui/gamepick/UIGuide_gamePickGetUserInfo.md +64 -0
- package/docs/ui/gamepick/UIGuide_gamePickSubmitSelection.md +103 -0
- package/docs/ui/gamepick/UIGuide_gamePickSubmitSelectionQuiz.md +67 -0
- package/docs/ui/general/UIGuide_getCustomSections.md +137 -0
- package/docs/ui/general/UIGuide_getRelatedItemsForGame.md +140 -0
- package/docs/ui/inbox/UIGuide_deleteInboxMessage.md +135 -0
- package/docs/ui/inbox/UIGuide_getInboxMessageBody.md +133 -0
- package/docs/ui/inbox/UIGuide_getInboxMessages.md +186 -0
- package/docs/ui/inbox/UIGuide_markInboxMessageAsRead.md +122 -0
- package/docs/ui/inbox/UIGuide_markUnmarkInboxMessageAsFavorite.md +84 -0
- package/docs/ui/jackpots/UIGuide_getJackpotEligibleGames.md +73 -0
- package/docs/ui/jackpots/UIGuide_getJackpotWinners.md +83 -0
- package/docs/ui/jackpots/UIGuide_jackpotGet.md +138 -0
- package/docs/ui/jackpots/UIGuide_jackpotOptIn.md +85 -0
- package/docs/ui/jackpots/UIGuide_jackpotOptOut.md +65 -0
- package/docs/ui/leaderboard/UIGuide_getLeaderBoard.md +166 -0
- package/docs/ui/minigames/UIGuide_getMiniGames.md +153 -0
- package/docs/ui/minigames/UIGuide_getMiniGamesHistory.md +90 -0
- package/docs/ui/minigames/UIGuide_playMiniGame.md +150 -0
- package/docs/ui/minigames/UIGuide_playMiniGameBatch.md +128 -0
- package/docs/ui/missions/UIGuide_getAchCategories.md +17 -0
- package/docs/ui/missions/UIGuide_getBadges.md +237 -0
- package/docs/ui/missions/UIGuide_getMissions.md +268 -0
- package/docs/ui/missions/UIGuide_requestMissionClaimReward.md +21 -0
- package/docs/ui/missions/UIGuide_requestMissionOptIn.md +16 -0
- package/docs/ui/raffles/UIGuide_claimRafflePrize.md +99 -0
- package/docs/ui/raffles/UIGuide_getRaffleDrawRun.md +117 -0
- package/docs/ui/raffles/UIGuide_getRaffleDrawRunsHistory.md +92 -0
- package/docs/ui/raffles/UIGuide_getRaffleWonPrizes.md +120 -0
- package/docs/ui/raffles/UIGuide_getRaffles.md +175 -0
- package/docs/ui/raffles/UIGuide_requestRaffleOptin.md +114 -0
- package/docs/ui/store/UIGuide_buyStoreItem.md +133 -0
- package/docs/ui/store/UIGuide_getStoreCategories.md +19 -0
- package/docs/ui/store/UIGuide_getStoreItems.md +264 -0
- package/docs/ui/store/UIGuide_getStorePurchasedItems.md +122 -0
- package/docs/ui/tournaments/UIGuide_getClanTournamentPlayers.md +140 -0
- package/docs/ui/tournaments/UIGuide_getTournamentInstanceInfo.md +265 -0
- package/docs/ui/tournaments/UIGuide_getTournamentsList.md +236 -0
- package/docs/ui/tournaments/UIGuide_registerInTournament.md +156 -0
- package/docs/ui/user/UIGuide_getActivityLog.md +130 -0
- package/docs/ui/user/UIGuide_getLevels.md +167 -0
- package/docs/ui/user/UIGuide_getUserProfile.md +213 -0
- package/package.json +3 -3
- package/scripts/postdoc-cleanup.js +195 -0
- package/src/Base/ClassId.ts +2 -0
- package/src/Jackpots/JackpotDetails.ts +14 -15
- package/src/Jackpots/JackpotPot.ts +10 -6
- package/src/Missions/MissionsUtils.ts +5 -2
- package/src/Raffle/GetRaffleWonPrizesRequest.ts +12 -0
- package/src/Raffle/GetRaffleWonPrizesResponse.ts +56 -0
- package/src/Raffle/index.ts +3 -1
- package/src/SmarticoAPI.ts +14 -1
- package/src/SmarticoLib/index.ts +4 -0
- package/src/Store/BuyStoreItemErrorCode.ts +8 -0
- package/src/Store/StoreItem.ts +1 -0
- package/src/Store/StoreItemPurchased.ts +1 -0
- package/src/Store/StoreItemType.ts +1 -1
- package/src/Tournaments/TournamentRegistrationError.ts +4 -0
- package/src/WSAPI/WSAPI.ts +27 -2007
- package/src/WSAPI/WSAPIAvatars.ts +345 -0
- package/src/WSAPI/WSAPIBase.ts +93 -0
- package/src/WSAPI/WSAPIBonuses.ts +268 -0
- package/src/WSAPI/WSAPIClans.ts +417 -0
- package/src/WSAPI/WSAPIGamePick.ts +667 -0
- package/src/WSAPI/WSAPIGeneral.ts +199 -0
- package/src/WSAPI/WSAPIInbox.ts +711 -0
- package/src/WSAPI/WSAPIJackpots.ts +448 -0
- package/src/WSAPI/WSAPILeaderBoard.ts +154 -0
- package/src/WSAPI/WSAPIMiniGames.ts +597 -0
- package/src/WSAPI/WSAPIMissions.ts +572 -0
- package/src/WSAPI/WSAPIRaffles.ts +703 -0
- package/src/WSAPI/WSAPIStore.ts +732 -0
- package/src/WSAPI/WSAPITournaments.ts +541 -0
- package/src/WSAPI/WSAPITypes.ts +376 -207
- package/src/WSAPI/WSAPIUser.ts +606 -0
- package/tsconfig.json +26 -2
- package/docs/api/classes/WSAPI.md +0 -1927
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
# UI Guide — `getActivityLog`
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
- Returns the user's unified balance-change history — every points / gems /
|
|
5
|
+
diamonds transaction in the requested window, newest-first.
|
|
6
|
+
- Power an "Activity" / "History" tab showing wins, claims, purchases,
|
|
7
|
+
level-up rewards, and operator adjustments.
|
|
8
|
+
- 30 s SDK cache + push refresh on every wallet change (with a caveat —
|
|
9
|
+
see below).
|
|
10
|
+
|
|
11
|
+
## List view organization
|
|
12
|
+
|
|
13
|
+
Single flat list, server-sorted newest-first by `create_date`. The default
|
|
14
|
+
Smartico UI groups rows visually by calendar day (e.g. "Today", "Yesterday",
|
|
15
|
+
"24 May").
|
|
16
|
+
|
|
17
|
+
### Time-period filter chips
|
|
18
|
+
|
|
19
|
+
The default Smartico UI exposes these filters on top:
|
|
20
|
+
|
|
21
|
+
| Chip | `startTimeSeconds` | `endTimeSeconds` |
|
|
22
|
+
|---|---|---|
|
|
23
|
+
| Today | today 00:00 local | now + 60 s |
|
|
24
|
+
| This week | Monday 00:00 local | now + 60 s |
|
|
25
|
+
| Previous week | Prev Monday 00:00 | Prev Sunday 23:59:59 |
|
|
26
|
+
| Last 24 h (default) | now − 86400 | now + 60 s |
|
|
27
|
+
|
|
28
|
+
Custom UIs can pick any window; the server scans the full range.
|
|
29
|
+
|
|
30
|
+
## Item card / row
|
|
31
|
+
|
|
32
|
+
Fields rendered per row:
|
|
33
|
+
|
|
34
|
+
| Field | Source | Notes |
|
|
35
|
+
|---|---|---|
|
|
36
|
+
| Currency icon | `type` (`UserBalanceType`) | points / gems / diamonds icon |
|
|
37
|
+
| Amount | `amount` | Prepend `+` if positive; color green when `>= 0`, red when negative |
|
|
38
|
+
| Balance after | `balance` | Right-aligned column |
|
|
39
|
+
| Source label | `source_type_id` (`PointChangeSourceType`) | See mapping table below |
|
|
40
|
+
| Timestamp | `create_date` (epoch s × 1000) | Relative ("2h ago") or HH:MM |
|
|
41
|
+
|
|
42
|
+
## Source label mapping
|
|
43
|
+
|
|
44
|
+
For consistency with the default Smartico UI, group source IDs into these
|
|
45
|
+
display buckets:
|
|
46
|
+
|
|
47
|
+
| `PointChangeSourceType` | Display label |
|
|
48
|
+
|---|---|
|
|
49
|
+
| `Journey` (1), `ManualAdjustment` (6), `AutomationRule` (12), `API` (18) | "Marketing" |
|
|
50
|
+
| `AchievementTaskCompletion` (2) | "Mission Task" |
|
|
51
|
+
| `AchievementCompletion` (3) | "Mission" |
|
|
52
|
+
| `LevelsStructureChange` (4) | "Level" |
|
|
53
|
+
| `StorePurchase` (5) | "Store" |
|
|
54
|
+
| `Leaderboard` (7) | "Leaderboard" |
|
|
55
|
+
| `Tournament` (11), `TournamentRegistration` (13), `TournamentRegistrationCancellation` (14) | "Tournament" |
|
|
56
|
+
| `RefundPoints` (15) | "Refund" |
|
|
57
|
+
| `PlayMiniGame` (16), `WinMiniGame` (17) | "Mini-Game" |
|
|
58
|
+
| `DynamicFormula` (19) | "Formula" |
|
|
59
|
+
| `Raffle` (21) | "Raffle" |
|
|
60
|
+
| `Avatars` (22) | "Avatar" |
|
|
61
|
+
| *(any unknown)* | "Other" |
|
|
62
|
+
|
|
63
|
+
## Pagination
|
|
64
|
+
|
|
65
|
+
`from` and `to` are offset + ceiling, NOT timestamps:
|
|
66
|
+
|
|
67
|
+
- `offset = from`
|
|
68
|
+
- `limit = min(to - from, 50)` — server hard-caps at 50 rows per request.
|
|
69
|
+
|
|
70
|
+
For infinite scroll, advance `from` by 50 each page. Detect end of list when
|
|
71
|
+
the returned array length is less than the requested page size.
|
|
72
|
+
|
|
73
|
+
## Subscription model — `onUpdate` caveat
|
|
74
|
+
|
|
75
|
+
The `onUpdate` callback fires whenever the user's points / gems / diamonds
|
|
76
|
+
balance changes. **The pushed payload is a FIXED re-fetch** of:
|
|
77
|
+
|
|
78
|
+
- `startTimeSeconds = now - 600` (last 10 minutes)
|
|
79
|
+
- `endTimeSeconds = now`
|
|
80
|
+
- `from = 0`, `to = 50`
|
|
81
|
+
|
|
82
|
+
It does NOT use the original call's parameters. Consumers maintaining a long
|
|
83
|
+
historical view (e.g. 30 days) should treat `onUpdate` as a "new transactions
|
|
84
|
+
arrived" hint and re-call `getActivityLog` with their own params:
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
const log = await window._smartico.api.getActivityLog({
|
|
88
|
+
startTimeSeconds: thirtyDaysAgo,
|
|
89
|
+
endTimeSeconds: now,
|
|
90
|
+
from: 0, to: 50,
|
|
91
|
+
onUpdate: async (refreshed) => {
|
|
92
|
+
console.log('[smartico] wallet changed — refreshed last-10-min payload arrived');
|
|
93
|
+
// To keep the 30-day view current, re-fetch with the original params:
|
|
94
|
+
const fresh = await window._smartico.api.getActivityLog({
|
|
95
|
+
startTimeSeconds: thirtyDaysAgo,
|
|
96
|
+
endTimeSeconds: Math.floor(Date.now() / 1000),
|
|
97
|
+
from: 0, to: 50,
|
|
98
|
+
});
|
|
99
|
+
console.log('[smartico] re-rendered full 30-day list with', fresh.length, 'rows');
|
|
100
|
+
},
|
|
101
|
+
});
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Empty / loading / error states
|
|
105
|
+
|
|
106
|
+
- **Empty**: "No activity in this period" — common for new users or
|
|
107
|
+
narrow time windows.
|
|
108
|
+
- **Loading (cold fetch)**: skeleton list (5 placeholder rows).
|
|
109
|
+
- **Error**: keep prior list if any; non-blocking banner.
|
|
110
|
+
|
|
111
|
+
## Refresh
|
|
112
|
+
|
|
113
|
+
- 30 s SDK cache absorbs rapid tab switches.
|
|
114
|
+
- Push triggers fire on every wallet change; the SDK handles invalidation
|
|
115
|
+
internally.
|
|
116
|
+
- For the user's CURRENT balance (not the activity log), read
|
|
117
|
+
[`getUserProfile`](../../api/classes/WSAPIUser.md#getuserprofile) — the
|
|
118
|
+
activity log is for historical detail, not for the current balance widget.
|
|
119
|
+
|
|
120
|
+
## Mobile vs desktop
|
|
121
|
+
|
|
122
|
+
- **Desktop**: row shows activity icon · source label · amount · balance · time.
|
|
123
|
+
- **Mobile**: row stacks activity + source label on the left, amount + balance
|
|
124
|
+
on the right.
|
|
125
|
+
|
|
126
|
+
## Performance
|
|
127
|
+
|
|
128
|
+
- 30 s cache + push invalidation makes repeated tab opens cheap.
|
|
129
|
+
- 50-row page limit — paginate via `from` for full history.
|
|
130
|
+
- Don't poll — the `onUpdate` callback handles change detection.
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
# UI Guide — `getLevels`
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
- Returns the full level ladder for the label — one `TLevel` per
|
|
6
|
+
active level, server-sorted by `required_points` ASC.
|
|
7
|
+
- Use as a lookup table to resolve `ach_level_current_id` from
|
|
8
|
+
`[getUserProfile](../../api/classes/WSAPIUser.md#getuserprofile)`
|
|
9
|
+
into a richer level object, or as the source for a level map UI.
|
|
10
|
+
- Loading indicator: skip on cache hit (30 s); show a brief shimmer
|
|
11
|
+
on cold fetch (typically 100–300 ms).
|
|
12
|
+
|
|
13
|
+
## List view organization
|
|
14
|
+
|
|
15
|
+
The default Smartico UI renders levels as a **vertical grid** —
|
|
16
|
+
2-column on mobile (`grid-boxes-2 levels`), responsive on desktop
|
|
17
|
+
(`grid-boxes-levels`). No horizontal-scroll layout, no tabs.
|
|
18
|
+
|
|
19
|
+
Items are already sorted by `required_points` ASC; `ordinal_position`
|
|
20
|
+
is a 1-based index matching that sort. Render in the returned array
|
|
21
|
+
order — no client-side sort needed unless your label uses
|
|
22
|
+
sliding-window leveling (then sort secondary on
|
|
23
|
+
`required_level_counter_1`, then `required_level_counter_2`).
|
|
24
|
+
|
|
25
|
+
## Client-side filtering by `visibility_points`
|
|
26
|
+
|
|
27
|
+
The server returns ALL active levels; the default Smartico UI hides
|
|
28
|
+
levels the user hasn't reached the visibility threshold for:
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
const visible = levels.filter(l =>
|
|
32
|
+
l.visibility_points == null || l.visibility_points <= profile.ach_points_ever
|
|
33
|
+
);
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Hidden levels are absent from the render entirely — no "?" tile, no
|
|
37
|
+
silhouette. If your product surface wants a teaser for upcoming
|
|
38
|
+
levels, render the hidden ones with a custom CSS treatment instead
|
|
39
|
+
of filtering them out.
|
|
40
|
+
|
|
41
|
+
## Level tile
|
|
42
|
+
|
|
43
|
+
Fields rendered per tile:
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
| Field | Use |
|
|
47
|
+
| ------------------ | ---------------------------------------------------------------------------------------------------- |
|
|
48
|
+
| `image` | Tile icon (square, 256×256 px source). |
|
|
49
|
+
| `name` | Tile heading. |
|
|
50
|
+
| `description` | Optional sub-text under the heading; the default UI shows this in the detail modal, not on the tile. |
|
|
51
|
+
| `required_points` | Threshold display: `"{N} pts to reach"` or progress bar. |
|
|
52
|
+
| `ordinal_position` | Tile order; matches array order. |
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
**Locked vs unlocked treatment** — apply a `disabled` class to tiles
|
|
56
|
+
where the user hasn't met the threshold:
|
|
57
|
+
|
|
58
|
+
- Points-only leveling (most labels): `disabled = ach_points_ever < required_points`
|
|
59
|
+
- Sliding-window leveling: also check
|
|
60
|
+
`level_counter_1 < required_level_counter_1` (and `_2`) from
|
|
61
|
+
`[getUserLevelExtraCounters](../../api/classes/WSAPIUser.md#getuserlevelextracounters)`.
|
|
62
|
+
- Manual-only leveling: `disabled` unless the level matches the
|
|
63
|
+
user's current `ach_level_current_id`.
|
|
64
|
+
|
|
65
|
+
The default Smartico UI uses CSS-only treatment for locked tiles —
|
|
66
|
+
no padlock icon, no greyscale by default. Brands can add those via
|
|
67
|
+
custom CSS / Liquid skin overrides.
|
|
68
|
+
|
|
69
|
+
## Detail view (per-level modal)
|
|
70
|
+
|
|
71
|
+
When the user taps a tile, open a modal showing:
|
|
72
|
+
|
|
73
|
+
- Hero image (`image`)
|
|
74
|
+
- Title (`name`), description (`description`)
|
|
75
|
+
- Progress block: for the user's current level, three stacked
|
|
76
|
+
progress bars (points / counter 1 / counter 2) — see "Sliding-window
|
|
77
|
+
leveling" below. For other levels, just the requirement display.
|
|
78
|
+
- Custom fields rendered from `custom_data` (operator-defined).
|
|
79
|
+
|
|
80
|
+
`custom_data` is typed as `string` but at runtime is `any` — the SDK
|
|
81
|
+
auto-parses JSON-looking strings. Always guard with
|
|
82
|
+
`typeof custom_data === 'object'` before property access; treat
|
|
83
|
+
non-object values as raw strings.
|
|
84
|
+
|
|
85
|
+
## Sliding-window leveling (advanced)
|
|
86
|
+
|
|
87
|
+
If your label uses sliding-window leveling (the "Logic 2" model), the
|
|
88
|
+
`required_level_counter_1` and `required_level_counter_2` fields are
|
|
89
|
+
populated. Render alongside the points threshold:
|
|
90
|
+
|
|
91
|
+
```
|
|
92
|
+
Points: {ach_points_ever} / {required_points}
|
|
93
|
+
Counter 1: {level_counter_1} / {required_level_counter_1} ← from getUserLevelExtraCounters
|
|
94
|
+
Counter 2: {level_counter_2} / {required_level_counter_2}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
The operator names the counters via translation keys
|
|
98
|
+
(`levelsCounter1Name`, `levelsCounter2Name`) — typical values are
|
|
99
|
+
"Total Deposits", "Total Wagering", etc. The SDK does not expose the
|
|
100
|
+
operator's chosen labels; resolve them via
|
|
101
|
+
`[getTranslations](../../api/classes/WSAPIGeneral.md#gettranslations)`.
|
|
102
|
+
|
|
103
|
+
On points-only labels, both `required_level_counter_*` fields are
|
|
104
|
+
`null` — skip rendering the counter rows.
|
|
105
|
+
|
|
106
|
+
## Progress to next level
|
|
107
|
+
|
|
108
|
+
Two formulas are in use; pick whichever fits your design:
|
|
109
|
+
|
|
110
|
+
- **From-zero (default Smartico UI uses this)**:
|
|
111
|
+
`ach_points_ever / next_level.required_points × 100`. Shows
|
|
112
|
+
"absolute" progress; never decreases as the user gains points.
|
|
113
|
+
- **From-current-level-floor (SDK uses this in
|
|
114
|
+
`[getCurrentLevel](../../api/classes/WSAPIUser.md#getcurrentlevel)`)**:
|
|
115
|
+
`(ach_points_ever − current.required_points) / (next.required_points − current.required_points) × 100`. Resets to 0 when the user levels
|
|
116
|
+
up; better for "how far through this level" UX.
|
|
117
|
+
|
|
118
|
+
Both bound at 100; at the max level the bar shows full.
|
|
119
|
+
|
|
120
|
+
## Image / asset specs
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
| Field | Aspect | Notes |
|
|
124
|
+
| ------- | ------------------------------------------ | ------------------------------------------------------------------------------------------------------ |
|
|
125
|
+
| `image` | 1:1 (square), 256×256 px documented source | Render in a square tile container; fallback: text-only tile with the level name if `image` is missing. |
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
## Empty / loading / error states
|
|
129
|
+
|
|
130
|
+
- **Loading (cold fetch)**: render a skeleton grid (3–6 placeholder
|
|
131
|
+
tiles) sized to the eventual layout.
|
|
132
|
+
- **Loading (cache hit)**: do not render a loading state — the
|
|
133
|
+
promise resolves within a microtask.
|
|
134
|
+
- **Empty result**: `[]` means no levels are configured for the
|
|
135
|
+
label. Hide the level UI entirely (or render a neutral
|
|
136
|
+
"no levels configured" placeholder).
|
|
137
|
+
- **Error**: keep the prior list visible if any; show a small
|
|
138
|
+
non-blocking error banner; retry on next user-driven action.
|
|
139
|
+
|
|
140
|
+
## Animations / transitions
|
|
141
|
+
|
|
142
|
+
- **Tile entry**: stagger fade-in (~30 ms per tile) on first render.
|
|
143
|
+
- **Level-up celebration**: when `ach_level_current_id` flips on a
|
|
144
|
+
push (detect via `[getUserProfile](../../api/classes/WSAPIUser.md#getuserprofile)`'s
|
|
145
|
+
`props_change`), animate the newly-reached tile (scale-up,
|
|
146
|
+
shine sweep). The default Smartico UI does this on the header
|
|
147
|
+
badge, not on the level-map tiles.
|
|
148
|
+
|
|
149
|
+
## Mobile vs desktop
|
|
150
|
+
|
|
151
|
+
- **Grid columns**: desktop responsive (3–5 columns depending on
|
|
152
|
+
viewport); mobile 2 columns.
|
|
153
|
+
- **Detail view**: desktop opens as a centered modal with backdrop
|
|
154
|
+
dim; mobile opens as a full-screen sheet.
|
|
155
|
+
- **Counter rows in detail**: identical on both — three stacked
|
|
156
|
+
progress bars on Logic 2 labels.
|
|
157
|
+
|
|
158
|
+
## Performance
|
|
159
|
+
|
|
160
|
+
- The 30 s cache deduplicates rapid refetches; a poll loop hitting
|
|
161
|
+
`getLevels()` every 5 s effectively translates to one network
|
|
162
|
+
round-trip per 30 s.
|
|
163
|
+
- `getLevels` is suitable to call once at app boot and cache the
|
|
164
|
+
array in your own state (re-fetch only when the user's level
|
|
165
|
+
changes per `props_change`, since the operator-driven ladder
|
|
166
|
+
rarely changes mid-session).
|
|
167
|
+
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
# UI Guide — `getUserProfile`
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
- The synchronous source of truth for the current user's public
|
|
5
|
+
properties — balances, level, username, avatar, tags, language,
|
|
6
|
+
inbox count.
|
|
7
|
+
- The SDK keeps a local snapshot updated by a server push channel.
|
|
8
|
+
Every call returns the latest cached values; no network round-trip.
|
|
9
|
+
- Drive long-lived widgets (header user-bar, balance display, inbox
|
|
10
|
+
badge, level badge) by **subscribing to `props_change` events** and
|
|
11
|
+
re-reading via `getUserProfile()` on each fire. Don't poll.
|
|
12
|
+
|
|
13
|
+
## Subscription pattern
|
|
14
|
+
|
|
15
|
+
The default Smartico UI registers a single `props_change` listener
|
|
16
|
+
at boot and re-renders the affected widgets from the current
|
|
17
|
+
`getUserProfile()` snapshot. The callback's argument carries only
|
|
18
|
+
the changed keys, so you can branch on which subset of widgets to
|
|
19
|
+
update:
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
window._smartico.on('props_change', (changed) => {
|
|
23
|
+
const profile = window._smartico.api.getUserProfile();
|
|
24
|
+
|
|
25
|
+
if ('ach_points_balance' in changed
|
|
26
|
+
|| 'ach_gems_balance' in changed
|
|
27
|
+
|| 'ach_diamonds_balance' in changed) {
|
|
28
|
+
console.log('[smartico] balance changed — re-render the currency strip:',
|
|
29
|
+
profile.ach_points_balance, profile.ach_gems_balance, profile.ach_diamonds_balance);
|
|
30
|
+
}
|
|
31
|
+
if ('ach_level_current_id' in changed) {
|
|
32
|
+
console.log('[smartico] level changed — call getCurrentLevel() and animate the badge');
|
|
33
|
+
}
|
|
34
|
+
if ('core_inbox_unread_count' in changed) {
|
|
35
|
+
console.log('[smartico] inbox count changed — update the inbox badge to:',
|
|
36
|
+
profile.core_inbox_unread_count);
|
|
37
|
+
}
|
|
38
|
+
if ('core_public_tags' in changed) {
|
|
39
|
+
console.log('[smartico] tags changed — re-evaluate any tag-gated UI:',
|
|
40
|
+
profile.core_public_tags);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
For one-time reads (e.g. inside a click handler), call
|
|
46
|
+
`getUserProfile()` directly — no subscription needed.
|
|
47
|
+
|
|
48
|
+
## Balance widget
|
|
49
|
+
|
|
50
|
+
The default Smartico UI renders a horizontal strip of currency
|
|
51
|
+
counters in the header / menu bar. Render rules:
|
|
52
|
+
|
|
53
|
+
| Field | Rendered | Format |
|
|
54
|
+
|---|---|---|
|
|
55
|
+
| `ach_points_balance` | Always | Locale-aware integer (e.g. `"1,234"`); show even when zero. |
|
|
56
|
+
| `ach_gems_balance` | Only if the operator has enabled gems for this label | Same locale format. |
|
|
57
|
+
| `ach_diamonds_balance` | Only if the operator has enabled diamonds for this label | Same locale format. |
|
|
58
|
+
|
|
59
|
+
Gems and diamonds are conditionally rendered per label
|
|
60
|
+
configuration — not just based on whether the value is non-zero. For
|
|
61
|
+
labels that don't use these currencies, hide the counters entirely
|
|
62
|
+
rather than showing `0`. (The SDK doesn't expose label settings; ask
|
|
63
|
+
the operator or detect by other context.)
|
|
64
|
+
|
|
65
|
+
Pair the counter with an icon for each currency (points icon, gem
|
|
66
|
+
icon, diamond icon). Use brand assets — none ship with the SDK.
|
|
67
|
+
|
|
68
|
+
## Affordability checks
|
|
69
|
+
|
|
70
|
+
`getUserProfile()` is the source for paid-mutation gating across
|
|
71
|
+
the SDK. Same pattern for each domain:
|
|
72
|
+
|
|
73
|
+
| Method | Read balance for | Compare against |
|
|
74
|
+
|---|---|---|
|
|
75
|
+
| [`buyStoreItem`](../../api/classes/WSAPIStore.md#buystoreitem) | `item.purchase_type` (`'points'` / `'gems'` / `'diamonds'`) | `item.discounted_price ?? item.price` |
|
|
76
|
+
| [`joinClan`](../../api/classes/WSAPIClans.md#joinclan) | `clan.entry_fee_currency_type_id` (`0`/`1`/`2`/`3`) | `clan.entry_fee_amount` |
|
|
77
|
+
| [`registerInTournament`](../../api/classes/WSAPITournaments.md#registerintournament) | Whichever of `registration_cost_points` / `_gems` / `_diamonds` is set | The same field |
|
|
78
|
+
|
|
79
|
+
Disable the CTA when the user's balance is below the cost; show the
|
|
80
|
+
deficit in the disabled state's text.
|
|
81
|
+
|
|
82
|
+
## Level badge
|
|
83
|
+
|
|
84
|
+
Render the level badge using `ach_level_current_id` as a lookup key
|
|
85
|
+
into the level ladder fetched separately:
|
|
86
|
+
|
|
87
|
+
1. Call [`getLevels`](../../api/classes/WSAPIUser.md#getlevels) once
|
|
88
|
+
at app boot to cache the full ladder.
|
|
89
|
+
2. On `ach_level_current_id` change (via `props_change`), look up the
|
|
90
|
+
level by ID and render its `name` + `image`.
|
|
91
|
+
3. For the richer "progress to next level" UI, call
|
|
92
|
+
[`getCurrentLevel`](../../api/classes/WSAPIUser.md#getcurrentlevel)
|
|
93
|
+
— it adds a computed `progress` percentage.
|
|
94
|
+
|
|
95
|
+
`ach_level_current_id` may briefly be `0` (or undefined) for new
|
|
96
|
+
users with no points yet. Handle that as "no level" — render a
|
|
97
|
+
default badge (e.g. "Newcomer" or hide the badge).
|
|
98
|
+
|
|
99
|
+
## Avatar widget
|
|
100
|
+
|
|
101
|
+
`avatar_url` is a CDN URL resolved by the SDK from the server's
|
|
102
|
+
`avatar_id` field. To render:
|
|
103
|
+
|
|
104
|
+
- Place inside a square container (1:1 aspect ratio).
|
|
105
|
+
- The default Smartico UI proxies the URL through a CDN resizer
|
|
106
|
+
(`resize/128/128/webp/...`) for size-appropriate fetches and
|
|
107
|
+
WebP-where-supported. Brands that don't use that resizer can
|
|
108
|
+
load `avatar_url` directly.
|
|
109
|
+
- **No built-in placeholder**: when `avatar_url` is missing, the
|
|
110
|
+
default Smartico UI renders an empty container (no fallback
|
|
111
|
+
image). Provide your own placeholder asset / initial-letter
|
|
112
|
+
fallback if the empty state matters.
|
|
113
|
+
|
|
114
|
+
## Username widget
|
|
115
|
+
|
|
116
|
+
`public_username` is the user's display name. Fallback chain:
|
|
117
|
+
|
|
118
|
+
- `public_username` if set
|
|
119
|
+
- `'...'` (three dots) or a localized "Anonymous" string if not set
|
|
120
|
+
|
|
121
|
+
The default Smartico UI uses `'...'`. There's no automatic fallback
|
|
122
|
+
to `user_ext_id` — that field is internal and should never be
|
|
123
|
+
displayed.
|
|
124
|
+
|
|
125
|
+
## Inbox badge
|
|
126
|
+
|
|
127
|
+
`core_inbox_unread_count` is the authoritative source for inbox
|
|
128
|
+
unread badge rendering — it's push-updated in real time (under 1
|
|
129
|
+
second), unlike
|
|
130
|
+
[`getInboxUnreadCount()`](../../api/classes/WSAPIInbox.md#getinboxunreadcount)
|
|
131
|
+
which caches for 30 s.
|
|
132
|
+
|
|
133
|
+
Render rules:
|
|
134
|
+
|
|
135
|
+
- `0` (or undefined) → badge hidden entirely
|
|
136
|
+
- `1`–`N` → render the raw integer (e.g. `"5"`, `"42"`)
|
|
137
|
+
- No truncation to `"99+"` in the default Smartico UI; brands that
|
|
138
|
+
want a cap should apply it themselves.
|
|
139
|
+
|
|
140
|
+
## Public tags
|
|
141
|
+
|
|
142
|
+
`core_public_tags` is an array of operator-defined uppercase strings
|
|
143
|
+
(e.g. `['VIP', 'NEWSLETTER_OPT_IN']`). Use them to gate UI
|
|
144
|
+
visibility — show a "VIP rewards" link only when `'VIP'` is in the
|
|
145
|
+
array.
|
|
146
|
+
|
|
147
|
+
To modify tags, use `_smartico.updatePublicTags(operation, tags)` —
|
|
148
|
+
the change round-trips through the server and arrives back as a
|
|
149
|
+
`props_change` push (usually within ~1 second).
|
|
150
|
+
|
|
151
|
+
## Language
|
|
152
|
+
|
|
153
|
+
`core_user_language` is the server-stored language code (e.g.
|
|
154
|
+
`"en"`, `"de"`). The SDK uses this for:
|
|
155
|
+
|
|
156
|
+
- Pre-translated content fields on missions, bonuses, clans, etc.
|
|
157
|
+
- The `lang_code` parameter that
|
|
158
|
+
[`getTranslations`](../../api/classes/WSAPIGeneral.md#gettranslations)
|
|
159
|
+
is typically called with.
|
|
160
|
+
|
|
161
|
+
When the user just changed language client-side, this field may
|
|
162
|
+
briefly lag the local intent until the server push arrives. If your
|
|
163
|
+
UI needs instant accuracy (e.g. switching the in-page language
|
|
164
|
+
without a refresh), use `_smartico.getPublicProps()` which applies
|
|
165
|
+
the client-side fallback.
|
|
166
|
+
|
|
167
|
+
## AI-recommended amounts
|
|
168
|
+
|
|
169
|
+
`core_recommended_deposit_amount` and
|
|
170
|
+
`core_recommended_casino_bet_amount` are AI-computed for the user.
|
|
171
|
+
The default Smartico UI doesn't render them — they're exposed for
|
|
172
|
+
custom integrations (e.g. operator-specific deposit prompts,
|
|
173
|
+
personalized bet suggestions).
|
|
174
|
+
|
|
175
|
+
Guard against `undefined` — these are absent for users with no
|
|
176
|
+
current recommendation.
|
|
177
|
+
|
|
178
|
+
## Empty / loading / error states
|
|
179
|
+
|
|
180
|
+
- **Pre-identify**: `getUserProfile()` throws
|
|
181
|
+
`"Tracker is not initialized, cannot getUserProfile"`. Render
|
|
182
|
+
widgets as skeleton/placeholder until the `identify` event fires
|
|
183
|
+
(or until the first `props_change` callback).
|
|
184
|
+
- **Visitor mode**: not supported; will throw. Render a "Log in to
|
|
185
|
+
see your profile" CTA instead of a balance widget for anonymous
|
|
186
|
+
sessions.
|
|
187
|
+
- **Stale data**: real-time push usually keeps the snapshot under 1
|
|
188
|
+
second behind server state. There's no explicit "stale" state —
|
|
189
|
+
trust the snapshot.
|
|
190
|
+
|
|
191
|
+
## Animations / transitions
|
|
192
|
+
|
|
193
|
+
- **Balance changes**: when `ach_points_balance` / `_gems` /
|
|
194
|
+
`_diamonds` change, animate the count-up/down between the prior
|
|
195
|
+
and new value (200–600 ms). Detect by diffing the prior snapshot
|
|
196
|
+
inside `props_change`.
|
|
197
|
+
- **Level-up**: when `ach_level_current_id` increases, play a
|
|
198
|
+
celebration animation on the badge (sparkle, scale-up, color
|
|
199
|
+
flash). Detect by diffing the prior `ach_level_current_id`.
|
|
200
|
+
- **Inbox badge appearing**: when `core_inbox_unread_count` flips
|
|
201
|
+
from `0` to `>0`, animate the badge fade-in.
|
|
202
|
+
|
|
203
|
+
## Performance
|
|
204
|
+
|
|
205
|
+
- `getUserProfile()` is effectively free (synchronous, in-memory
|
|
206
|
+
copy). Call it as often as you need.
|
|
207
|
+
- Avoid re-rendering every widget on every `props_change` push —
|
|
208
|
+
branch on the changed keys and re-render only the affected
|
|
209
|
+
surfaces.
|
|
210
|
+
- `getUserProfile()` returns a shallow copy on each call; for
|
|
211
|
+
performance-critical paths (e.g. animations), prefer memoizing
|
|
212
|
+
the result inside `props_change` rather than calling on every
|
|
213
|
+
frame.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smartico/public-api",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.381",
|
|
4
4
|
"description": "Smartico public API",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"bump-ach": "cd ../tracker/ach && npm install @smartico/public-api@latest --legacy-peer-deps",
|
|
25
25
|
"bump-bo-server": "cd ../bo_server/server && source ~/.nvm/nvm.sh && nvm use v13.13.0 && npm install @smartico/public-api@latest",
|
|
26
26
|
"bump-bo-client": "cd ../bo_server/client && source ~/.nvm/nvm.sh && nvm use v13.13.0 && npm install @smartico/public-api@latest",
|
|
27
|
-
"doc": "typedoc"
|
|
27
|
+
"doc": "typedoc && node scripts/postdoc-cleanup.js"
|
|
28
28
|
},
|
|
29
29
|
"author": "",
|
|
30
30
|
"license": "ISC",
|
|
@@ -40,6 +40,6 @@
|
|
|
40
40
|
"typedoc-plugin-markdown": "^4.11.0",
|
|
41
41
|
"typedoc-plugin-merge-modules": "^7.0.0",
|
|
42
42
|
"typescript": "~5.1.0",
|
|
43
|
-
"@types/node": "^
|
|
43
|
+
"@types/node": "^22.9.0"
|
|
44
44
|
}
|
|
45
45
|
}
|