@smartico/public-api 0.0.402 → 0.0.404
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/skills/api-tsdoc/SKILL.md +675 -0
- package/.claude/skills/api-tsdoc-final/SKILL.md +266 -0
- package/.claude/skills/api-tsdoc-howto/SKILL.md +143 -0
- package/dist/MiniGames/SAWTemplate.d.ts +4 -0
- package/dist/NodeCache.d.ts +1 -0
- package/dist/OCache.d.ts +7 -0
- package/dist/SmarticoGlobal.d.ts +0 -6
- package/dist/WSAPI/WSAPITypes.d.ts +43 -0
- package/dist/WSAPI/WSAPIUser.d.ts +3 -0
- package/dist/index.js +92 -33
- package/dist/index.js.map +1 -1
- package/dist/index.modern.mjs +60 -10
- package/dist/index.modern.mjs.map +1 -1
- package/docs/api/interfaces/TUserProfile.md +136 -0
- package/docs/capabilities/_responses/buyStoreItem.json +4 -0
- package/docs/capabilities/_responses/claimBonus.json +4 -0
- package/docs/capabilities/_responses/gamePickGetActiveRound.json +95 -0
- package/docs/capabilities/_responses/gamePickGetActiveRounds.json +191 -0
- package/docs/capabilities/_responses/gamePickGetBoard.json +47 -0
- package/docs/capabilities/_responses/gamePickGetGameInfo.json +355 -0
- package/docs/capabilities/_responses/gamePickGetHistory.json +191 -0
- package/docs/capabilities/_responses/gamePickGetUserInfo.json +14 -0
- package/docs/capabilities/_responses/getAchCategories.json +12 -0
- package/docs/capabilities/_responses/getActivityLog.json +1 -0
- package/docs/capabilities/_responses/getAvatarPrompts.json +16 -0
- package/docs/capabilities/_responses/getAvatarsCustomized.json +12 -0
- package/docs/capabilities/_responses/getAvatarsList.json +24 -0
- package/docs/capabilities/_responses/getBadges.json +98 -0
- package/docs/capabilities/_responses/getBonuses.json +18 -0
- package/docs/capabilities/_responses/getClanInfo.json +39 -0
- package/docs/capabilities/_responses/getClans.json +35 -0
- package/docs/capabilities/_responses/getCurrentLevel.json +20 -0
- package/docs/capabilities/_responses/getCustomSections.json +25 -0
- package/docs/capabilities/_responses/getInboxMessageBody.json +7 -0
- package/docs/capabilities/_responses/getInboxMessages.json +18 -0
- package/docs/capabilities/_responses/getInboxUnreadCount.json +1 -0
- package/docs/capabilities/_responses/getJackpotEligibleGames.json +20 -0
- package/docs/capabilities/_responses/getJackpotWinners.json +28 -0
- package/docs/capabilities/_responses/getLeaderBoard.json +45 -0
- package/docs/capabilities/_responses/getLevels.json +40 -0
- package/docs/capabilities/_responses/getMiniGames.json +208 -0
- package/docs/capabilities/_responses/getMiniGamesHistory.json +1 -0
- package/docs/capabilities/_responses/getMissions.json +117 -0
- package/docs/capabilities/_responses/getRaffleDrawRun.json +62 -0
- package/docs/capabilities/_responses/getRaffleDrawRunsHistory.json +34 -0
- package/docs/capabilities/_responses/getRaffles.json +140 -0
- package/docs/capabilities/_responses/getStoreCategories.json +12 -0
- package/docs/capabilities/_responses/getStoreItems.json +47 -0
- package/docs/capabilities/_responses/getStorePurchasedItems.json +49 -0
- package/docs/capabilities/_responses/getTournamentInstanceInfo.json +75 -0
- package/docs/capabilities/_responses/getTournamentsList.json +66 -0
- package/docs/capabilities/_responses/getTranslations.json +25 -0
- package/docs/capabilities/_responses/getUserLevelExtraCounters.json +4 -0
- package/docs/capabilities/_responses/getUserProfile.json +34 -0
- package/docs/capabilities/_responses/jackpotGet.json +113 -0
- package/docs/capabilities/_responses/jackpotOptIn.json +9 -0
- package/docs/capabilities/_responses/jackpotOptOut.json +9 -0
- package/docs/capabilities/_responses/markAllInboxMessagesAsRead.json +4 -0
- package/docs/capabilities/_responses/markInboxMessageAsRead.json +4 -0
- package/docs/capabilities/_responses/markUnmarkInboxMessageAsFavorite.json +4 -0
- package/docs/capabilities/_responses/miniGameWinAcknowledgeRequest.json +10 -0
- package/docs/capabilities/_responses/playMiniGame.json +6 -0
- package/docs/capabilities/_responses/playMiniGameBatch.json +9 -0
- package/docs/capabilities/_responses/registerInTournament.json +4 -0
- package/docs/capabilities/_responses/requestMissionOptIn.json +4 -0
- package/docs/capabilities/_responses/setAvatar.json +4 -0
- package/docs/capabilities/avatarsCustomize.md +115 -0
- package/docs/capabilities/buyStoreItem.md +179 -0
- package/docs/capabilities/checkSegmentListMatch.md +69 -0
- package/docs/capabilities/checkSegmentMatch.md +74 -0
- package/docs/capabilities/claimBonus.md +125 -0
- package/docs/capabilities/claimRafflePrize.md +116 -0
- package/docs/capabilities/deleteAllInboxMessages.md +66 -0
- package/docs/capabilities/deleteInboxMessage.md +60 -0
- package/docs/capabilities/gamePickGetActiveRound.md +248 -0
- package/docs/capabilities/gamePickGetActiveRounds.md +259 -0
- package/docs/capabilities/gamePickGetBoard.md +202 -0
- package/docs/capabilities/gamePickGetGameInfo.md +318 -0
- package/docs/capabilities/gamePickGetHistory.md +244 -0
- package/docs/capabilities/gamePickGetRoundInfoForUser.md +189 -0
- package/docs/capabilities/gamePickGetUserInfo.md +91 -0
- package/docs/capabilities/gamePickSubmitSelection.md +222 -0
- package/docs/capabilities/gamePickSubmitSelectionQuiz.md +198 -0
- package/docs/capabilities/getAchCategories.md +119 -0
- package/docs/capabilities/getActivityLog.md +108 -0
- package/docs/capabilities/getAvatarPrompts.md +81 -0
- package/docs/capabilities/getAvatarsCustomized.md +96 -0
- package/docs/capabilities/getAvatarsList.md +101 -0
- package/docs/capabilities/getBadges.md +237 -0
- package/docs/capabilities/getBonuses.md +159 -0
- package/docs/capabilities/getClanInfo.md +164 -0
- package/docs/capabilities/getClanTournamentPlayers.md +112 -0
- package/docs/capabilities/getClans.md +168 -0
- package/docs/capabilities/getCurrentLevel.md +123 -0
- package/docs/capabilities/getCustomSections.md +96 -0
- package/docs/capabilities/getInboxMessageBody.md +87 -0
- package/docs/capabilities/getInboxMessages.md +146 -0
- package/docs/capabilities/getInboxUnreadCount.md +54 -0
- package/docs/capabilities/getJackpotEligibleGames.md +93 -0
- package/docs/capabilities/getJackpotWinners.md +113 -0
- package/docs/capabilities/getLeaderBoard.md +187 -0
- package/docs/capabilities/getLeaderBoards.md +88 -0
- package/docs/capabilities/getLevels.md +118 -0
- package/docs/capabilities/getMiniGames.md +295 -0
- package/docs/capabilities/getMiniGamesHistory.md +183 -0
- package/docs/capabilities/getMissions.md +253 -0
- package/docs/capabilities/getRaffleDrawRun.md +210 -0
- package/docs/capabilities/getRaffleDrawRunsHistory.md +116 -0
- package/docs/capabilities/getRaffleWonPrizes.md +153 -0
- package/docs/capabilities/getRaffles.md +249 -0
- package/docs/capabilities/getRelatedItemsForGame.md +236 -0
- package/docs/capabilities/getStoreCategories.md +128 -0
- package/docs/capabilities/getStoreItems.md +260 -0
- package/docs/capabilities/getStorePurchasedItems.md +280 -0
- package/docs/capabilities/getTournamentInstanceInfo.md +301 -0
- package/docs/capabilities/getTournamentsList.md +234 -0
- package/docs/capabilities/getTranslations.md +95 -0
- package/docs/capabilities/getUserLevelExtraCounters.md +92 -0
- package/docs/capabilities/getUserProfile.md +184 -0
- package/docs/capabilities/jackpotGet.md +173 -0
- package/docs/capabilities/jackpotOptIn.md +94 -0
- package/docs/capabilities/jackpotOptOut.md +92 -0
- package/docs/capabilities/joinClan.md +169 -0
- package/docs/capabilities/markAllInboxMessagesAsRead.md +72 -0
- package/docs/capabilities/markInboxMessageAsRead.md +69 -0
- package/docs/capabilities/markUnmarkInboxMessageAsFavorite.md +75 -0
- package/docs/capabilities/miniGameWinAcknowledgeRequest.md +98 -0
- package/docs/capabilities/playMiniGame.md +217 -0
- package/docs/capabilities/playMiniGameBatch.md +129 -0
- package/docs/capabilities/registerInTournament.md +187 -0
- package/docs/capabilities/reportClickEvent.md +74 -0
- package/docs/capabilities/reportImpressionEvent.md +67 -0
- package/docs/capabilities/requestMissionClaimReward.md +117 -0
- package/docs/capabilities/requestMissionOptIn.md +98 -0
- package/docs/capabilities/requestRaffleOptin.md +108 -0
- package/docs/capabilities/setAvatar.md +132 -0
- package/docs/capabilities/smarticoCallbacks.md +165 -0
- package/docs/capabilities/smarticoGlobal.md +62 -0
- package/package.json +3 -2
- package/readme-smartico-dev.md +208 -0
- package/scripts/capture-responses-browser.mjs +301 -0
- package/scripts/gen-capabilities.js +368 -0
- package/scripts/run-public-api.mjs +105 -0
- package/src/MiniGames/SAWGetTemplatesResponse.ts +2 -0
- package/src/MiniGames/SAWTemplate.ts +5 -0
- package/src/NodeCache.ts +8 -0
- package/src/OCache.ts +17 -0
- package/src/SmarticoGlobal.ts +0 -7
- package/src/WSAPI/WSAPI.ts +3 -3
- package/src/WSAPI/WSAPIJackpots.ts +4 -1
- package/src/WSAPI/WSAPIMiniGames.ts +1 -1
- package/src/WSAPI/WSAPITypes.ts +44 -0
- package/src/WSAPI/WSAPIUser.ts +30 -5
package/dist/index.modern.mjs
CHANGED
|
@@ -507,6 +507,8 @@ const SAWTemplatesTransform = items => {
|
|
|
507
507
|
activeFromDate: r.activeFromDate,
|
|
508
508
|
activeTillDate: r.activeTillDate,
|
|
509
509
|
next_available_spin_ts: r.next_available_spin_ts,
|
|
510
|
+
earliest_expiration_dt: r.earliest_expiration_dt,
|
|
511
|
+
latest_expiration_dt: r.latest_expiration_dt,
|
|
510
512
|
steps_to_finish_game: r.saw_template_ui_definition.steps_to_finish_game,
|
|
511
513
|
custom_section_id: r.saw_template_ui_definition.custom_section_id,
|
|
512
514
|
saw_template_ui_definition: r.saw_template_ui_definition
|
|
@@ -713,6 +715,13 @@ class NodeCache {
|
|
|
713
715
|
delete this.cache[key];
|
|
714
716
|
}
|
|
715
717
|
}
|
|
718
|
+
removeByPrefix(prefix) {
|
|
719
|
+
for (const key in this.cache) {
|
|
720
|
+
if (this.cache.hasOwnProperty(key) && key.indexOf(prefix) === 0) {
|
|
721
|
+
delete this.cache[key];
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
}
|
|
716
725
|
flushAll() {
|
|
717
726
|
this.cache = {};
|
|
718
727
|
if (this.ttlChecker) {
|
|
@@ -762,6 +771,21 @@ class OCache {
|
|
|
762
771
|
this.cache[cacheContext].remove(key);
|
|
763
772
|
}
|
|
764
773
|
}
|
|
774
|
+
/**
|
|
775
|
+
* Remove every entry whose string key starts with `oKeyBase` — the bare key
|
|
776
|
+
* AND all per-parameter composite variants (`${oKeyBase}:…` / `${oKeyBase}<id>`).
|
|
777
|
+
* Use when a cache is keyed per parameter (paginated, per-template, per-window):
|
|
778
|
+
* an exact-key `clear(oKeyBase)` would miss every variant. `oKeyBase` must be a string.
|
|
779
|
+
*/
|
|
780
|
+
static async clearByPrefix(cacheContext, oKeyBase) {
|
|
781
|
+
// `set`/`get` build keys as `<context>_<JSON.stringify(oKey)>`; JSON.stringify
|
|
782
|
+
// wraps a string in quotes, so dropping the trailing quote yields a prefix that
|
|
783
|
+
// matches both the bare `"base"` key and every `"base…"` composite key.
|
|
784
|
+
const prefix = cacheContext.toString() + '_' + JSON.stringify(oKeyBase).slice(0, -1);
|
|
785
|
+
if (this.cache[cacheContext]) {
|
|
786
|
+
this.cache[cacheContext].removeByPrefix(prefix);
|
|
787
|
+
}
|
|
788
|
+
}
|
|
765
789
|
static async clearContext(cacheContext) {
|
|
766
790
|
if (this.cache[cacheContext]) {
|
|
767
791
|
this.cache[cacheContext].flushAll();
|
|
@@ -2426,6 +2450,12 @@ const raffleClaimPrizeResponseTransform = info => {
|
|
|
2426
2450
|
|
|
2427
2451
|
/** @group User */
|
|
2428
2452
|
class WSAPIUser extends WSAPIBase {
|
|
2453
|
+
constructor(...args) {
|
|
2454
|
+
super(...args);
|
|
2455
|
+
/** @hidden Last window passed to `getActivityLog` with an `onUpdate`, so a push
|
|
2456
|
+
* refresh re-fetches the same window and updates its matching composite cache key. */
|
|
2457
|
+
this.activityLogOnUpdateParams = void 0;
|
|
2458
|
+
}
|
|
2429
2459
|
/**
|
|
2430
2460
|
* Returns the current user's public profile — the source of truth for
|
|
2431
2461
|
* balances (points / gems / diamonds), the current level ID, the
|
|
@@ -2982,16 +3012,33 @@ class WSAPIUser extends WSAPIBase {
|
|
|
2982
3012
|
to,
|
|
2983
3013
|
onUpdate
|
|
2984
3014
|
}) {
|
|
3015
|
+
const cacheKey = `${onUpdateContextKey.ActivityLog}:${startTimeSeconds}:${endTimeSeconds}:${from}:${to}`;
|
|
2985
3016
|
if (typeof onUpdate === 'function') {
|
|
2986
3017
|
this.onUpdateCallback.set(onUpdateContextKey.ActivityLog, onUpdate);
|
|
3018
|
+
// Remember the requested window so a push refresh re-fetches THIS window
|
|
3019
|
+
// and writes the matching composite cache key (see notifyActivityLogUpdate).
|
|
3020
|
+
this.activityLogOnUpdateParams = {
|
|
3021
|
+
startTimeSeconds,
|
|
3022
|
+
endTimeSeconds,
|
|
3023
|
+
from,
|
|
3024
|
+
to
|
|
3025
|
+
};
|
|
2987
3026
|
}
|
|
2988
|
-
return await OCache.use(
|
|
3027
|
+
return await OCache.use(cacheKey, ECacheContext.WSAPI, () => this.api.getActivityLogT(this.userExtId, startTimeSeconds, endTimeSeconds, from, to), CACHE_DATA_SEC);
|
|
2989
3028
|
}
|
|
2990
3029
|
async notifyActivityLogUpdate() {
|
|
2991
|
-
const
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
3030
|
+
const params = this.activityLogOnUpdateParams;
|
|
3031
|
+
// No consumer has subscribed to a specific window yet — nothing to refresh.
|
|
3032
|
+
if (!params) {
|
|
3033
|
+
return;
|
|
3034
|
+
}
|
|
3035
|
+
const payload = await this.api.getActivityLogT(this.userExtId, params.startTimeSeconds, params.endTimeSeconds, params.from, params.to);
|
|
3036
|
+
const cacheKey = `${onUpdateContextKey.ActivityLog}:${params.startTimeSeconds}:${params.endTimeSeconds}:${params.from}:${params.to}`;
|
|
3037
|
+
OCache.set(cacheKey, payload, ECacheContext.WSAPI);
|
|
3038
|
+
const onUpdate = this.onUpdateCallback.get(onUpdateContextKey.ActivityLog);
|
|
3039
|
+
if (typeof onUpdate === 'function') {
|
|
3040
|
+
onUpdate(payload);
|
|
3041
|
+
}
|
|
2995
3042
|
}
|
|
2996
3043
|
}
|
|
2997
3044
|
|
|
@@ -5610,7 +5657,10 @@ class WSAPIJackpots extends WSAPIClans {
|
|
|
5610
5657
|
async jackpotClearCache() {
|
|
5611
5658
|
OCache.clear(ECacheContext.WSAPI, onUpdateContextKey.Jackpots);
|
|
5612
5659
|
OCache.clear(ECacheContext.WSAPI, onUpdateContextKey.Pots);
|
|
5613
|
-
|
|
5660
|
+
// Winners + eligible-games are cached per jp_template_id (composite keys),
|
|
5661
|
+
// so a bare clear misses every variant — clear by prefix.
|
|
5662
|
+
OCache.clearByPrefix(ECacheContext.WSAPI, onUpdateContextKey.JackpotWinners);
|
|
5663
|
+
OCache.clearByPrefix(ECacheContext.WSAPI, onUpdateContextKey.JackpotEligibleGames);
|
|
5614
5664
|
}
|
|
5615
5665
|
/**
|
|
5616
5666
|
* Returns the user-eligible jackpots active for the label, fused with their live
|
|
@@ -6846,7 +6896,7 @@ class WSAPIMiniGames extends WSAPIRaffles {
|
|
|
6846
6896
|
offset,
|
|
6847
6897
|
saw_template_id
|
|
6848
6898
|
}) {
|
|
6849
|
-
return OCache.use(onUpdateContextKey.SAWHistory
|
|
6899
|
+
return OCache.use(`${onUpdateContextKey.SAWHistory}:${saw_template_id != null ? saw_template_id : ''}:${limit != null ? limit : ''}:${offset != null ? offset : ''}`, ECacheContext.WSAPI, () => this.api.getSawWinningHistoryT(this.userExtId, limit, offset, saw_template_id), CACHE_DATA_SEC);
|
|
6850
6900
|
}
|
|
6851
6901
|
/**
|
|
6852
6902
|
* Plays one round of a mini-game template — runs the server's
|
|
@@ -9243,11 +9293,11 @@ class WSAPI extends WSAPIInbox {
|
|
|
9243
9293
|
on(ClassId.SAW_SHOW_SPIN_PUSH, () => this.reloadMiniGameTemplate());
|
|
9244
9294
|
on(ClassId.SAW_AKNOWLEDGE_RESPONSE, () => {
|
|
9245
9295
|
this.reloadMiniGameTemplate();
|
|
9246
|
-
OCache.
|
|
9296
|
+
OCache.clearByPrefix(ECacheContext.WSAPI, onUpdateContextKey.SAWHistory);
|
|
9247
9297
|
});
|
|
9248
9298
|
on(ClassId.SAW_DO_SPIN_RESPONSE, () => {
|
|
9249
9299
|
this.reloadMiniGameTemplate();
|
|
9250
|
-
OCache.
|
|
9300
|
+
OCache.clearByPrefix(ECacheContext.WSAPI, onUpdateContextKey.SAWHistory);
|
|
9251
9301
|
});
|
|
9252
9302
|
on(ClassId.MISSION_OPTIN_RESPONSE, () => this.updateMissions());
|
|
9253
9303
|
on(ClassId.ACHIEVEMENT_CLAIM_PRIZE_RESPONSE, () => this.updateMissions());
|
|
@@ -9266,7 +9316,7 @@ class WSAPI extends WSAPIInbox {
|
|
|
9266
9316
|
on(ClassId.CLAIM_BONUS_RESPONSE, () => this.updateBonuses());
|
|
9267
9317
|
on(ClassId.SAW_DO_SPIN_BATCH_RESPONSE, () => {
|
|
9268
9318
|
this.reloadMiniGameTemplate();
|
|
9269
|
-
OCache.
|
|
9319
|
+
OCache.clearByPrefix(ECacheContext.WSAPI, onUpdateContextKey.SAWHistory);
|
|
9270
9320
|
});
|
|
9271
9321
|
on(ClassId.RAF_CLAIM_PRIZE_RESPONSE, () => this.updateRaffles());
|
|
9272
9322
|
on(ClassId.GET_INBOX_MESSAGES_RESPONSE, res => {
|