@smartico/public-api 0.0.380 → 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/CLAUDE.md +103 -0
- package/README.md +32 -10
- 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/WSAPI/WSAPIAvatars.d.ts +267 -49
- package/dist/WSAPI/WSAPIBonuses.d.ts +224 -10
- package/dist/WSAPI/WSAPIGamePick.d.ts +538 -253
- package/dist/WSAPI/WSAPIGeneral.d.ts +156 -14
- package/dist/WSAPI/WSAPIInbox.d.ts +547 -58
- package/dist/WSAPI/WSAPIJackpots.d.ts +292 -57
- package/dist/WSAPI/WSAPILeaderBoard.d.ts +127 -13
- package/dist/WSAPI/WSAPIMiniGames.d.ts +465 -49
- package/dist/WSAPI/WSAPIRaffles.d.ts +576 -52
- package/dist/WSAPI/WSAPITournaments.d.ts +3 -3
- package/dist/WSAPI/WSAPITypes.d.ts +243 -132
- package/dist/WSAPI/WSAPIUser.d.ts +193 -43
- package/dist/index.js +3409 -615
- package/dist/index.js.map +1 -1
- package/dist/index.modern.mjs +3391 -608
- 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 +26 -0
- package/docs/api/classes/WSAPIAvatars.md +282 -54
- package/docs/api/classes/WSAPIBonuses.md +233 -12
- package/docs/api/classes/WSAPIClans.md +380 -10
- package/docs/api/classes/WSAPIGamePick.md +555 -26
- package/docs/api/classes/WSAPIGeneral.md +165 -16
- package/docs/api/classes/WSAPIInbox.md +588 -64
- package/docs/api/classes/WSAPIJackpots.md +320 -66
- package/docs/api/classes/WSAPILeaderBoard.md +133 -15
- package/docs/api/classes/WSAPIMiniGames.md +501 -64
- package/docs/api/classes/WSAPIMissions.md +58 -79
- package/docs/api/classes/WSAPIRaffles.md +647 -69
- package/docs/api/classes/WSAPIStore.md +83 -108
- package/docs/api/classes/WSAPITournaments.md +495 -28
- package/docs/api/classes/WSAPIUser.md +520 -83
- 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/BonusStatus-1.md +11 -6
- 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/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/TAchCategory.md +2 -7
- 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 -29
- 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 +1 -9
- package/docs/api/interfaces/TMissionOptInResult.md +1 -5
- package/docs/api/interfaces/TMissionOrBadge.md +4 -7
- 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 +3 -13
- package/docs/api/interfaces/TTournament.md +1 -1
- package/docs/api/interfaces/TTournamentDetailed.md +1 -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/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/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/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/user/UIGuide_getActivityLog.md +130 -0
- package/docs/ui/user/UIGuide_getLevels.md +47 -42
- package/package.json +1 -1
- package/src/Base/ClassId.ts +2 -0
- package/src/Jackpots/JackpotDetails.ts +14 -15
- package/src/Jackpots/JackpotPot.ts +10 -6
- 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/WSAPI/WSAPIAvatars.ts +267 -49
- package/src/WSAPI/WSAPIBonuses.ts +224 -10
- package/src/WSAPI/WSAPIGamePick.ts +538 -253
- package/src/WSAPI/WSAPIGeneral.ts +156 -14
- package/src/WSAPI/WSAPIInbox.ts +545 -56
- package/src/WSAPI/WSAPIJackpots.ts +297 -61
- package/src/WSAPI/WSAPILeaderBoard.ts +127 -13
- package/src/WSAPI/WSAPIMiniGames.ts +465 -49
- package/src/WSAPI/WSAPIRaffles.ts +592 -64
- package/src/WSAPI/WSAPITournaments.ts +3 -3
- package/src/WSAPI/WSAPITypes.ts +243 -132
- package/src/WSAPI/WSAPIUser.ts +193 -43
- package/tsconfig.json +9 -1
package/src/WSAPI/WSAPIUser.ts
CHANGED
|
@@ -67,7 +67,7 @@ export class WSAPIUser extends WSAPIBase {
|
|
|
67
67
|
*
|
|
68
68
|
* **Inbox unread count** — `core_inbox_unread_count` on this profile
|
|
69
69
|
* is push-updated in real time (under 1 second). For an inbox badge,
|
|
70
|
-
* prefer this field over
|
|
70
|
+
* prefer this field over `getInboxUnreadCount` (which is cached
|
|
71
71
|
* for 30 s) — same value, fresher signal.
|
|
72
72
|
*
|
|
73
73
|
* **Language**: `core_user_language` reflects the server's stored
|
|
@@ -138,15 +138,75 @@ export class WSAPIUser extends WSAPIBase {
|
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
-
/**
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
*
|
|
141
|
+
/**
|
|
142
|
+
* Checks whether the current user matches a single segment, returning
|
|
143
|
+
* `true` / `false` directly. Use this as a decision primitive to gate
|
|
144
|
+
* UI surfaces (e.g. show a "VIP lounge" tab only when the user is in
|
|
145
|
+
* the VIP segment), or to drive segment-specific CTA copy.
|
|
146
|
+
*
|
|
147
|
+
* Every call is a server round-trip — there is no SDK-side cache. For
|
|
148
|
+
* checking multiple segments in one round-trip, use
|
|
149
|
+
* {@link checkSegmentListMatch} instead.
|
|
150
|
+
*
|
|
151
|
+
* @remarks
|
|
152
|
+
* **Refresh model**
|
|
153
|
+
* - **No client cache.** Every call sends a request; the SDK does not
|
|
154
|
+
* memoize results.
|
|
155
|
+
* - **No push event** notifies the consumer when segment membership
|
|
156
|
+
* flips (the user crosses a qualification threshold, or the
|
|
157
|
+
* operator changes the segment definition). Membership changes
|
|
158
|
+
* become visible only on the next `checkSegmentMatch` call.
|
|
159
|
+
* - **Behavioral segments (configured against BigQuery) have batch
|
|
160
|
+
* lag** — even if the user's activity has changed (deposit, wager,
|
|
161
|
+
* etc.), the segment-membership result may not reflect that change
|
|
162
|
+
* until the next batch evaluation run (typically up to several
|
|
163
|
+
* hours).
|
|
164
|
+
*
|
|
165
|
+
* **Rate limit** (important)
|
|
166
|
+
* The server caps `checkSegment*` calls at **10 requests per
|
|
167
|
+
* 60-second window**, with a minimum gap of **~5 seconds between
|
|
168
|
+
* consecutive calls**. Avoid calling on every render — cache the
|
|
169
|
+
* result client-side for the session, or until you have a reason to
|
|
170
|
+
* believe the user's state changed (e.g. after a deposit completes,
|
|
171
|
+
* a level changes via {@link getUserProfile}'s `props_change`, or a
|
|
172
|
+
* specific custom event fires).
|
|
173
|
+
*
|
|
174
|
+
* **`is_matching: false` is ambiguous on the server** — both "the
|
|
175
|
+
* segment doesn't exist for this label" and "the user doesn't
|
|
176
|
+
* qualify" return `false` with no distinguishing signal. Pass IDs
|
|
177
|
+
* you've verified are valid for your label.
|
|
178
|
+
*
|
|
179
|
+
* **Idempotency**: safe. Read-only. No side effects (no analytics
|
|
180
|
+
* events, no DB writes).
|
|
181
|
+
*
|
|
182
|
+
* **Visitor mode**: not supported.
|
|
183
|
+
*
|
|
184
|
+
* @param segment_id The segment ID. Segment IDs are label-scoped;
|
|
185
|
+
* the same numeric ID can refer to different
|
|
186
|
+
* segments under different labels. Use the IDs
|
|
187
|
+
* configured for your label.
|
|
188
|
+
* @returns `true` if the user currently matches the
|
|
189
|
+
* segment, `false` otherwise. `false` also covers
|
|
190
|
+
* the "segment doesn't exist for this label"
|
|
191
|
+
* case — these are not distinguishable.
|
|
192
|
+
*
|
|
193
|
+
* @example
|
|
194
|
+
* ```ts
|
|
195
|
+
* const isVip = await window._smartico.api.checkSegmentMatch(vipSegmentId);
|
|
196
|
+
* if (isVip) {
|
|
197
|
+
* console.log('[smartico] user is in VIP segment — render the VIP-only widget surface');
|
|
198
|
+
* } else {
|
|
199
|
+
* console.log('[smartico] user not in VIP segment (or segment id misconfigured) — hide the VIP surface');
|
|
200
|
+
* }
|
|
201
|
+
*
|
|
202
|
+
* // Cache the result for the session; re-check after material user-state changes.
|
|
203
|
+
* window._smartico.on('props_change', async (changed) => {
|
|
204
|
+
* if ('ach_points_ever' in changed || 'ach_level_current_id' in changed) {
|
|
205
|
+
* const fresh = await window._smartico.api.checkSegmentMatch(vipSegmentId);
|
|
206
|
+
* console.log('[smartico] user state changed — VIP membership now:', fresh);
|
|
207
|
+
* }
|
|
146
208
|
* });
|
|
147
209
|
* ```
|
|
148
|
-
*
|
|
149
|
-
* **Visitor mode: not supported**
|
|
150
210
|
*/
|
|
151
211
|
public async checkSegmentMatch(segment_id: number): Promise<boolean> {
|
|
152
212
|
const r = await this.api.coreCheckSegments(this.userExtId, [segment_id]);
|
|
@@ -157,14 +217,67 @@ export class WSAPIUser extends WSAPIBase {
|
|
|
157
217
|
}
|
|
158
218
|
}
|
|
159
219
|
|
|
160
|
-
/**
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
220
|
+
/**
|
|
221
|
+
* Checks the current user's membership in multiple segments in a
|
|
222
|
+
* single server round-trip — returns a `TSegmentCheckResult[]` with
|
|
223
|
+
* one entry per *unique* segment ID. Use this instead of looping
|
|
224
|
+
* {@link checkSegmentMatch} when you need to evaluate several
|
|
225
|
+
* segments at once (e.g. multi-segment composite gating, A/B-style
|
|
226
|
+
* cohort detection).
|
|
227
|
+
*
|
|
228
|
+
* @remarks
|
|
229
|
+
* **Response order is NOT guaranteed**
|
|
230
|
+
* The server returns results in an unspecified order — different
|
|
231
|
+
* from the input array. Always correlate by the `segment_id` field on
|
|
232
|
+
* each `TSegmentCheckResult` rather than by array position. The
|
|
233
|
+
* returned array length may also be smaller than the input array
|
|
234
|
+
* (duplicate IDs are silently de-duplicated server-side).
|
|
235
|
+
*
|
|
236
|
+
* **Single round-trip**
|
|
237
|
+
* The entire `segment_ids` array is sent in one request. Two segments
|
|
238
|
+
* cost the same as one in terms of network latency and rate-limit
|
|
239
|
+
* consumption (one call = one rate-limit slot, regardless of how many
|
|
240
|
+
* segments).
|
|
241
|
+
*
|
|
242
|
+
* **Shared semantics with `checkSegmentMatch`**
|
|
243
|
+
* Both methods wrap the same underlying server endpoint and share
|
|
244
|
+
* the same caching, refresh, rate-limit, and ambiguity behavior. See
|
|
245
|
+
* {@link checkSegmentMatch} for: no client cache · no push event for
|
|
246
|
+
* membership changes · behavioral segments have batch lag · rate
|
|
247
|
+
* limit (10 requests / 60 s, ~5 s minimum gap between calls) ·
|
|
248
|
+
* `is_matching: false` doesn't distinguish "not in segment" from
|
|
249
|
+
* "segment doesn't exist for this label".
|
|
250
|
+
*
|
|
251
|
+
* **Idempotency**: safe. Read-only. No side effects.
|
|
252
|
+
*
|
|
253
|
+
* **Visitor mode**: not supported.
|
|
254
|
+
*
|
|
255
|
+
* @param segment_ids Array of segment IDs to check. Duplicates are
|
|
256
|
+
* silently de-duplicated server-side. Segment IDs
|
|
257
|
+
* are label-scoped — use the IDs configured for
|
|
258
|
+
* your label.
|
|
259
|
+
* @returns Array of `{ segment_id, is_matching }` results.
|
|
260
|
+
* Order is NOT guaranteed; correlate by
|
|
261
|
+
* `segment_id`. Length may be less than the input
|
|
262
|
+
* when duplicate IDs were sent.
|
|
263
|
+
*
|
|
264
|
+
* @example
|
|
265
|
+
* ```ts
|
|
266
|
+
* const segmentIds = [vipSegmentId, newPlayerSegmentId, freeRollSegmentId];
|
|
267
|
+
* const results = await window._smartico.api.checkSegmentListMatch(segmentIds);
|
|
268
|
+
*
|
|
269
|
+
* // Always correlate by segment_id — the response order is unspecified.
|
|
270
|
+
* const byId = new Map(results.map(r => [r.segment_id, r.is_matching]));
|
|
271
|
+
*
|
|
272
|
+
* if (byId.get(vipSegmentId)) {
|
|
273
|
+
* console.log('[smartico] user is in VIP segment — render VIP surface');
|
|
274
|
+
* }
|
|
275
|
+
* if (byId.get(newPlayerSegmentId) && byId.get(freeRollSegmentId)) {
|
|
276
|
+
* console.log('[smartico] new player AND eligible for free roll — show the welcome promo');
|
|
277
|
+
* }
|
|
278
|
+
*
|
|
279
|
+
* // Cache the result map for the session; refresh on material state changes.
|
|
166
280
|
* ```
|
|
167
|
-
* **Visitor mode: not supported**
|
|
168
281
|
*/
|
|
169
282
|
public async checkSegmentListMatch(segment_ids: number[]): Promise<TSegmentCheckResult[]> {
|
|
170
283
|
return await this.api.coreCheckSegments(this.userExtId, Array.isArray(segment_ids) ? segment_ids : [segment_ids]);
|
|
@@ -325,7 +438,7 @@ export class WSAPIUser extends WSAPIBase {
|
|
|
325
438
|
* The SDK exposes raw numeric values; the meaning of each counter
|
|
326
439
|
* (deposit amount, wager amount, lifetime spend, etc.) is fully
|
|
327
440
|
* operator-defined per label. Resolve labels for display via
|
|
328
|
-
*
|
|
441
|
+
* `getTranslations` — the operator's display strings are
|
|
329
442
|
* stored under the translation keys `levelsCounter1Name` and
|
|
330
443
|
* `levelsCounter2Name`.
|
|
331
444
|
*
|
|
@@ -389,36 +502,68 @@ export class WSAPIUser extends WSAPIBase {
|
|
|
389
502
|
}
|
|
390
503
|
|
|
391
504
|
/**
|
|
392
|
-
* Returns the
|
|
393
|
-
*
|
|
394
|
-
*
|
|
395
|
-
*
|
|
396
|
-
* You can pass the onUpdate callback as a parameter, it will be called every time the activity log is updated and will provide the updated list of activity logs for the last 10 minutes.
|
|
505
|
+
* Returns the user's unified balance-change history — every points, gems, and
|
|
506
|
+
* diamonds transaction within the requested time window, ordered newest-first.
|
|
507
|
+
* Use to power an "Activity" / "History" tab showing wins, claims, purchases,
|
|
508
|
+
* level-up rewards, and operator adjustments.
|
|
397
509
|
*
|
|
398
|
-
*
|
|
399
|
-
*
|
|
400
|
-
*
|
|
401
|
-
*
|
|
402
|
-
*
|
|
403
|
-
*
|
|
404
|
-
*
|
|
405
|
-
*
|
|
406
|
-
*
|
|
407
|
-
*
|
|
408
|
-
*
|
|
409
|
-
*
|
|
410
|
-
*
|
|
411
|
-
*
|
|
412
|
-
*
|
|
510
|
+
* The returned shape is the same regardless of currency type — `type` (see
|
|
511
|
+
* {@link UserBalanceType}) distinguishes points / gems / diamonds and
|
|
512
|
+
* `source_type_id` (see {@link PointChangeSourceType}) names the originating
|
|
513
|
+
* event.
|
|
514
|
+
*
|
|
515
|
+
* @remarks
|
|
516
|
+
* **Preconditions**
|
|
517
|
+
* - User must be authenticated. Visitor mode is not guarded at the SDK level
|
|
518
|
+
* but is not meaningful — activity is per-user.
|
|
519
|
+
*
|
|
520
|
+
* **Pagination — `from` / `to` are offset + ceiling, not timestamps**
|
|
521
|
+
* The SDK derives `offset = from`, `limit = min(to - from, 50)` — the server
|
|
522
|
+
* hard-caps a single response at 50 entries. For infinite scroll, advance
|
|
523
|
+
* `from` by 50 between calls. Both `startTimeSeconds` and `endTimeSeconds`
|
|
524
|
+
* are epoch seconds bounding the window the server scans.
|
|
525
|
+
*
|
|
526
|
+
* **Subscription model (`onUpdate`)**
|
|
527
|
+
* The callback fires when the user's `ach_points_balance`,
|
|
528
|
+
* `ach_gems_balance`, or `ach_diamonds_balance` changes (i.e. whenever a
|
|
529
|
+
* wallet event lands). The pushed payload is a FIXED re-fetch of the
|
|
530
|
+
* **last 10 minutes / first 50 entries** — it does NOT honor the original
|
|
531
|
+
* call's `startTimeSeconds` / `endTimeSeconds` / `from` / `to`. Consumers
|
|
532
|
+
* maintaining a long historical view must re-call `getActivityLog` with
|
|
533
|
+
* their own params after receiving an `onUpdate` notification.
|
|
534
|
+
*
|
|
535
|
+
* **Refresh**
|
|
536
|
+
* - The SDK caches results for 30 seconds.
|
|
537
|
+
* - Push triggers fire only on balance changes; transactions that don't
|
|
538
|
+
* alter a balance (theoretical zero-amount entries) won't refresh.
|
|
539
|
+
*
|
|
540
|
+
* **Visitor mode**: not meaningful (no per-user history available).
|
|
541
|
+
*
|
|
542
|
+
* **UI guidance**: see [UI Guide — `getActivityLog`](../../docs/ui/user/UIGuide_getActivityLog.md).
|
|
413
543
|
*
|
|
414
|
-
*
|
|
544
|
+
* @returns Array of {@link TActivityLog} ordered newest-first.
|
|
415
545
|
*
|
|
416
|
-
* @
|
|
417
|
-
*
|
|
418
|
-
*
|
|
419
|
-
*
|
|
420
|
-
*
|
|
421
|
-
*
|
|
546
|
+
* @example
|
|
547
|
+
* ```ts
|
|
548
|
+
* const now = Math.floor(Date.now() / 1000);
|
|
549
|
+
* const start = now - 86400 * 30; // 30 days
|
|
550
|
+
*
|
|
551
|
+
* const log = await window._smartico.api.getActivityLog({
|
|
552
|
+
* startTimeSeconds: start,
|
|
553
|
+
* endTimeSeconds: now,
|
|
554
|
+
* from: 0,
|
|
555
|
+
* to: 50,
|
|
556
|
+
* onUpdate: (refreshed) => {
|
|
557
|
+
* console.log('[smartico] wallet changed — refreshed payload is last 10 min / 50 entries:', refreshed.length, 'rows');
|
|
558
|
+
* // If the consumer is showing a full 30-day view, re-call getActivityLog with the original params here.
|
|
559
|
+
* },
|
|
560
|
+
* });
|
|
561
|
+
*
|
|
562
|
+
* for (const row of log) {
|
|
563
|
+
* const sign = row.amount >= 0 ? '+' : '';
|
|
564
|
+
* 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);
|
|
565
|
+
* }
|
|
566
|
+
* ```
|
|
422
567
|
*/
|
|
423
568
|
public async getActivityLog({
|
|
424
569
|
startTimeSeconds,
|
|
@@ -427,10 +572,15 @@ export class WSAPIUser extends WSAPIBase {
|
|
|
427
572
|
to,
|
|
428
573
|
onUpdate,
|
|
429
574
|
}: {
|
|
575
|
+
/** Window start in epoch seconds. */
|
|
430
576
|
startTimeSeconds: number;
|
|
577
|
+
/** Window end in epoch seconds. */
|
|
431
578
|
endTimeSeconds: number;
|
|
579
|
+
/** Pagination offset (0-based). */
|
|
432
580
|
from: number;
|
|
581
|
+
/** Pagination ceiling (exclusive); server caps `to - from` at 50. */
|
|
433
582
|
to: number;
|
|
583
|
+
/** Optional push callback; payload is a fixed 10-min / 50-entry refresh on every wallet change (see Subscription model). */
|
|
434
584
|
onUpdate?: (data: TActivityLog[]) => void;
|
|
435
585
|
}): Promise<TActivityLog[]> {
|
|
436
586
|
|
package/tsconfig.json
CHANGED
|
@@ -60,6 +60,7 @@
|
|
|
60
60
|
"src/Leaderboard/LeaderBoardPeriodType.ts",
|
|
61
61
|
"src/Base/AchRelatedGame.ts",
|
|
62
62
|
"src/Core/ActivityTypeLimited.ts",
|
|
63
|
+
"src/ActivityLog/ActivityLogEntry.ts",
|
|
63
64
|
"src/Jackpots/index.ts",
|
|
64
65
|
"src/Raffle/index.ts",
|
|
65
66
|
"src/Missions/AchievementAvailabilityStatus.ts",
|
|
@@ -83,9 +84,16 @@
|
|
|
83
84
|
"src/Inbox/InboxMessageType.ts",
|
|
84
85
|
"src/Inbox/OpenLinksType.ts",
|
|
85
86
|
"src/Inbox/InboxReadStatus.ts",
|
|
86
|
-
"src/Clans/Clan.ts"
|
|
87
|
+
"src/Clans/Clan.ts",
|
|
88
|
+
"src/Clans/GetClanInfoResponse.ts",
|
|
89
|
+
"src/Clans/JoinClanErrorCode.ts",
|
|
90
|
+
"src/Tournaments/GetClanTournamentPlayersResponse.ts",
|
|
91
|
+
"src/Avatars/AvatarDefinition.ts",
|
|
92
|
+
"src/Avatars/AvatarCustomized.ts",
|
|
93
|
+
"src/Avatars/AvatarPrompt.ts"
|
|
87
94
|
],
|
|
88
95
|
"out": "docs/api",
|
|
96
|
+
"projectDocuments": ["docs/SmarticoObject.md", "docs/Callbacks.md", "docs/Transforms.md"],
|
|
89
97
|
"plugin": ["typedoc-plugin-markdown", "typedoc-plugin-merge-modules"],
|
|
90
98
|
"entryFileName": "README.md",
|
|
91
99
|
"disableSources": true,
|