@smartico/public-api 0.0.384 → 0.0.386

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.
@@ -1,22 +1,32 @@
1
+ /**
2
+ * Error codes returned in `errCode` by the `joinClan` method (also carried
3
+ * on `TClanJoinResult`). These are terse value definitions for lookup; the
4
+ * full per-code narrative and UI handling lives in the `joinClan` method
5
+ * TSDoc, which owns the error table.
6
+ */
1
7
  export declare enum JoinClanErrorCode {
2
- /** No error, join completed */
8
+ /** Success — join completed; entry fee (if any) deducted. */
3
9
  JOIN_CLAN_OK = 0,
4
- /** Invalid parameters */
10
+ /** Request was malformed (missing or invalid parameters). */
5
11
  JOIN_CLAN_INVALID_PARAMETERS = 1000,
6
- /** clan_id doesn't exist for this label */
12
+ /** Clan doesn't exist for this label. Archived clans are also reported as `1001`. */
7
13
  JOIN_CLAN_NOT_FOUND = 1001,
8
- /** members_count >= capacity_limit */
14
+ /** Clan is full — member capacity reached. */
9
15
  JOIN_CLAN_FULL = 1002,
10
- /** Not enough Points / Gems / Diamonds for entry fee */
16
+ /** Insufficient balance for the entry fee (points / gems / diamonds). */
11
17
  JOIN_CLAN_INSUFFICIENT_FUNDS = 1003,
12
- /** User doesn't satisfy entry_conditions / entry_segment_id */
18
+ /** User doesn't meet the clan's entry segment or conditions. */
13
19
  JOIN_CLAN_SEGMENT_MISMATCH = 1004,
14
- /** User is not in a clan */
20
+ /**
21
+ * User is not in a clan. Note: a `registerInTournament` response code
22
+ * that shares this enum — never returned by `joinClan`.
23
+ */
15
24
  JOIN_CLAN_USER_IS_NOT_IN_CLAN = 1005,
16
- /** User is within the CLAN_COOLDOWN_DAYS window */
25
+ /** User is within the clan-switch cooldown window (switch only). */
17
26
  JOIN_CLAN_COOLDOWN_ACTIVE = 1006,
18
- /** clan_status_id != 1 (clan is archived) */
19
- JOIN_CLAN_ARCHIVED = 1007,
20
- /** Clan joined after tournament start */
27
+ /**
28
+ * Clan joined after tournament start. Note: a `registerInTournament`
29
+ * response code that shares this enum — never returned by `joinClan`.
30
+ */
21
31
  JOIN_CLAN_JOINED_AFTER_TOURNAMENT_START = 1011
22
32
  }
@@ -1,14 +1,44 @@
1
+ /**
2
+ * Error codes returned in `err_code` by the `registerInTournament` method.
3
+ *
4
+ * These are terse value definitions for lookup. The full per-code narrative —
5
+ * when each fires and how the consumer's UI should react — lives in the
6
+ * `registerInTournament` method TSDoc, which owns the error table.
7
+ *
8
+ * Note the numbering break: the gems / diamonds codes are 6-digit
9
+ * (`300010` / `300011`) while the rest of the tournament block is 5-digit;
10
+ * they were appended after the original `30001`–`30009` range was occupied.
11
+ * Branch on the exact numeric value, not on digit count.
12
+ */
1
13
  export declare enum TournamentRegistrationError {
14
+ /** Success — registration persisted; buy-in (if any) deducted. */
2
15
  NO_ERROR = 0,
16
+ /** Clan-based tournament and the user does not belong to a clan yet. */
3
17
  TOURNAMENT_USER_CANNOT_JOIN_WITHOUT_CLAN = 1010,
18
+ /** Instance id is invalid or the tournament was deleted. */
4
19
  TOURNAMENT_INSTANCE_NOT_FOUND = 30001,
20
+ /** Insufficient points balance for a points-priced buy-in. */
5
21
  TOURNAMENT_REGISTRATION_NOT_ENOUGH_POINTS = 30002,
22
+ /** Tournament is no longer in a registerable state (finished, cancelled, finalizing, or not yet open). */
6
23
  TOURNAMENT_INSTANCE_NOT_IN_STATE = 30003,
24
+ /** User is already registered; treat as an idempotent success. */
7
25
  TOURNAMENT_ALREADY_REGISTERED = 30004,
26
+ /** User does not satisfy the tournament's segment / entry conditions. */
8
27
  TOURNAMENT_USER_DONT_MATCH_CONDITIONS = 30005,
28
+ /** User is not registered; anomalous on a register call (usually a server-side race). */
9
29
  TOURNAMENT_USER_NOT_REGISTERED = 30006,
30
+ /** Registration status transition is not allowed (e.g. re-registering a finished tournament). */
10
31
  TOURNAMENT_CANT_CHANGE_REGISTRATION_STATUS = 30007,
32
+ /** Tournament filled up — maximum registrations reached. */
11
33
  TOURNAMENT_MAX_REGISTRATIONS_REACHED = 30008,
12
- TOURNAMENT_REGISTRATION_NOT_ENOUGH_GEMS = 30010,
13
- TOURNAMENT_REGISTRATION_NOT_ENOUGH_DIAMONDS = 30011
34
+ /**
35
+ * The user's wallet currency could not be resolved. Emitted server-side
36
+ * during tournament score processing, NOT during registration — it is
37
+ * never returned by `registerInTournament`. Included for completeness.
38
+ */
39
+ TOURNAMENT_INVALID_USER_CURRENCY = 30009,
40
+ /** Insufficient gems balance for a gems-priced buy-in. */
41
+ TOURNAMENT_REGISTRATION_NOT_ENOUGH_GEMS = 300010,
42
+ /** Insufficient diamonds balance for a diamonds-priced buy-in. */
43
+ TOURNAMENT_REGISTRATION_NOT_ENOUGH_DIAMONDS = 300011
14
44
  }
@@ -280,12 +280,10 @@ export declare class WSAPIClans extends WSAPITournaments {
280
280
  * tournament requires the user to be in a clan first.
281
281
  * - `1006` (`JOIN_CLAN_COOLDOWN_ACTIVE`) — user is inside the
282
282
  * switch-cooldown window from a previous clan join (default
283
- * 7 days, configurable per label). Surface the
283
+ * 7 days, configurable per label). Only reachable when the user is
284
+ * already in a *different* clan (this call is then a clan switch);
285
+ * a first-time join never returns `1006`. Surface the
284
286
  * `TClans.cooldown_until` expiry in the disabled CTA.
285
- * - `1007` (`JOIN_CLAN_ARCHIVED`) — defined on the public enum but
286
- * the server does NOT emit this code in practice (archived clans
287
- * are reported as `1001`). Handle it as a synonym for `1001`
288
- * defensively, but do not rely on it.
289
287
  * - `1011` (`JOIN_CLAN_JOINED_AFTER_TOURNAMENT_START`) — this
290
288
  * method does NOT return `1011` directly. The code fires on
291
289
  * {@link registerInTournament} responses when the user joined
@@ -48,15 +48,8 @@ export declare class WSAPILeaderBoard extends WSAPIGamePick {
48
48
  * the array is the prize for place 1, the second for place 2, and
49
49
  * so on. The array length is the number of paid places.
50
50
  *
51
- * **Cache TTL — single shared key (known limitation)**
52
- * The SDK caches the response for 30 seconds under a SINGLE shared
53
- * key — calling `getLeaderBoard(DAILY)` followed by
54
- * `getLeaderBoard(WEEKLY)` within the same 30 s window returns the
55
- * cached DAILY result for the WEEKLY call. Same applies to
56
- * switching `getPreviousPeriod`. To force a fresh fetch when
57
- * switching periods or current/previous, call
58
- * `_smartico.api.clearCaches()` before the second call, or simply
59
- * wait out the TTL.
51
+ * **Cache TTL**
52
+ * The SDK caches each response for 30 seconds.
60
53
  *
61
54
  * **Period boundaries**
62
55
  * The server finalizes each period on a server-configurable
@@ -126,8 +119,7 @@ export declare class WSAPILeaderBoard extends WSAPIGamePick {
126
119
  * }
127
120
  * }
128
121
  *
129
- * // Switch to previous period view — but bust the cache first to avoid the shared-key collision.
130
- * await window._smartico.api.clearCaches();
122
+ * // Switch to previous period view — cached separately from the current period.
131
123
  * const prev = await window._smartico.api.getLeaderBoard(LeaderBoardPeriodType.WEEKLY, true);
132
124
  * console.log('[smartico] previous-week standings — render with greyed-out "ended" treatment:', prev?.users.length, 'finalists');
133
125
  *
@@ -177,8 +177,14 @@ export declare class WSAPIMissions extends WSAPIGeneral {
177
177
  * **Idempotency / Side effects**: fetch-only; safe to call repeatedly.
178
178
  * The cache layer deduplicates concurrent calls within the TTL window.
179
179
  *
180
+ * **Visitor mode**: not supported. Badges are an authenticated-only
181
+ * feature; calling this on the visitor-mode handle (`_smartico.vapi`)
182
+ * throws synchronously rather than silently returning an empty list.
183
+ *
180
184
  * **UI guidance**: see [UI Guide — `getBadges`](../../docs/ui/missions/UIGuide_getBadges.md).
181
185
  *
186
+ * @throws `Error("getBadges is not available in visitor mode")` when
187
+ * called from a visitor-mode session.
182
188
  * @returns Promise resolving to `TMissionOrBadge[]`. Every item has
183
189
  * `type === 'badge'`. Cached for 30 s under the `Badges` key.
184
190
  *
@@ -334,12 +334,25 @@ export declare class WSAPIUser extends WSAPIBase {
334
334
  * `ach_points_ever` and {@link getLevels} would also work, but
335
335
  * `progress` saves the math.
336
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.
337
+ * **Cache TTL & freshness**
338
+ * The response is cached for 30 seconds, but the SDK automatically
339
+ * drops that cache whenever a user-properties update arrives — the
340
+ * same live channel that backs {@link getUserProfile}. The practical
341
+ * effect depends on the label's leveling logic:
342
+ * - **Points-based or operator-manual leveling**: a points or level
343
+ * change flows through the user-properties channel, so the cache is
344
+ * busted at that moment and the next `getCurrentLevel()` call
345
+ * returns up-to-date data without waiting out the TTL.
346
+ * - **Counter-based leveling** (level driven by sliding-window
347
+ * counters such as deposit or wagering totals over a recent window —
348
+ * see {@link getUserLevelExtraCounters}): ordinary progress changes
349
+ * are recomputed by a periodic server job and do NOT emit a
350
+ * user-properties update, so they become visible on this method only
351
+ * after the 30 s TTL expires (or after `_smartico.api.clearCaches()`).
352
+ *
353
+ * Avoid calling `clearCaches()` on the points/manual path — it's
354
+ * unnecessary there (the cache is already refreshed on the property
355
+ * update) and forces a slower extra round-trip.
343
356
  *
344
357
  * **Leveling logic**
345
358
  * The semantics of how a user advances depends on the label's
@@ -367,10 +380,10 @@ export declare class WSAPIUser extends WSAPIBase {
367
380
  * console.log('[smartico] render level badge — name:', level.name,
368
381
  * 'progress:', Math.round(level.progress), '%');
369
382
  *
370
- * // Detect level-up via getUserProfile's push channel.
383
+ * // Detect level-up via getUserProfile's push channel. No clearCaches()
384
+ * // needed — the SDK already drops the level cache on this update.
371
385
  * window._smartico.on('props_change', async (changed) => {
372
386
  * if ('ach_level_current_id' in changed) {
373
- * await window._smartico.api.clearCaches(); // bust the 30 s cache
374
387
  * const fresh = await window._smartico.api.getCurrentLevel();
375
388
  * console.log('[smartico] user levelled up — animate badge to new level:', fresh.name);
376
389
  * }
@@ -403,14 +416,12 @@ export declare class WSAPIUser extends WSAPIBase {
403
416
  * `levelsCounter2Name`.
404
417
  *
405
418
  * **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.
419
+ * Sliding-window counters are recomputed by a periodic server-side
420
+ * job. Its rebuild cadence is operator-configured per brand —
421
+ * commonly daily, though it can be set more frequent — so level
422
+ * transitions driven by counter changes surface with a latency tied
423
+ * to that rebuild schedule after the underlying activity (e.g. a
424
+ * deposit), not in real time.
414
425
  *
415
426
  * **Idempotency**: safe. Read-only. Repeated calls within the cache
416
427
  * window return a deep-cloned cached value without a network
package/dist/index.js CHANGED
@@ -911,6 +911,9 @@ var InboxMessagesTransform = function InboxMessagesTransform(items) {
911
911
  };
912
912
 
913
913
  var InboxMessageBodyTransform = function InboxMessageBodyTransform(item) {
914
+ if (!item) {
915
+ return null;
916
+ }
914
917
  var x = {
915
918
  action: item.action,
916
919
  icon: item.image,
@@ -1880,7 +1883,7 @@ TournamentUtils.getPrizeTransformed = function (prize) {
1880
1883
 
1881
1884
  var TournamentItemsTransform = function TournamentItemsTransform(items) {
1882
1885
  return items.filter(function (r) {
1883
- return r.tournamentId >= 1;
1886
+ return r != null && r.tournamentId >= 1;
1884
1887
  }).map(function (r) {
1885
1888
  var x = _extends({
1886
1889
  instance_id: r.tournamentInstanceId,
@@ -2019,20 +2022,50 @@ var tournamentInfoItemTransform = function tournamentInfoItemTransform(t) {
2019
2022
  return response;
2020
2023
  };
2021
2024
 
2025
+ /**
2026
+ * Error codes returned in `err_code` by the `registerInTournament` method.
2027
+ *
2028
+ * These are terse value definitions for lookup. The full per-code narrative —
2029
+ * when each fires and how the consumer's UI should react — lives in the
2030
+ * `registerInTournament` method TSDoc, which owns the error table.
2031
+ *
2032
+ * Note the numbering break: the gems / diamonds codes are 6-digit
2033
+ * (`300010` / `300011`) while the rest of the tournament block is 5-digit;
2034
+ * they were appended after the original `30001`–`30009` range was occupied.
2035
+ * Branch on the exact numeric value, not on digit count.
2036
+ */
2022
2037
  exports.TournamentRegistrationError = void 0;
2023
2038
  (function (TournamentRegistrationError) {
2039
+ /** Success — registration persisted; buy-in (if any) deducted. */
2024
2040
  TournamentRegistrationError[TournamentRegistrationError["NO_ERROR"] = 0] = "NO_ERROR";
2041
+ /** Clan-based tournament and the user does not belong to a clan yet. */
2025
2042
  TournamentRegistrationError[TournamentRegistrationError["TOURNAMENT_USER_CANNOT_JOIN_WITHOUT_CLAN"] = 1010] = "TOURNAMENT_USER_CANNOT_JOIN_WITHOUT_CLAN";
2043
+ /** Instance id is invalid or the tournament was deleted. */
2026
2044
  TournamentRegistrationError[TournamentRegistrationError["TOURNAMENT_INSTANCE_NOT_FOUND"] = 30001] = "TOURNAMENT_INSTANCE_NOT_FOUND";
2045
+ /** Insufficient points balance for a points-priced buy-in. */
2027
2046
  TournamentRegistrationError[TournamentRegistrationError["TOURNAMENT_REGISTRATION_NOT_ENOUGH_POINTS"] = 30002] = "TOURNAMENT_REGISTRATION_NOT_ENOUGH_POINTS";
2047
+ /** Tournament is no longer in a registerable state (finished, cancelled, finalizing, or not yet open). */
2028
2048
  TournamentRegistrationError[TournamentRegistrationError["TOURNAMENT_INSTANCE_NOT_IN_STATE"] = 30003] = "TOURNAMENT_INSTANCE_NOT_IN_STATE";
2049
+ /** User is already registered; treat as an idempotent success. */
2029
2050
  TournamentRegistrationError[TournamentRegistrationError["TOURNAMENT_ALREADY_REGISTERED"] = 30004] = "TOURNAMENT_ALREADY_REGISTERED";
2051
+ /** User does not satisfy the tournament's segment / entry conditions. */
2030
2052
  TournamentRegistrationError[TournamentRegistrationError["TOURNAMENT_USER_DONT_MATCH_CONDITIONS"] = 30005] = "TOURNAMENT_USER_DONT_MATCH_CONDITIONS";
2053
+ /** User is not registered; anomalous on a register call (usually a server-side race). */
2031
2054
  TournamentRegistrationError[TournamentRegistrationError["TOURNAMENT_USER_NOT_REGISTERED"] = 30006] = "TOURNAMENT_USER_NOT_REGISTERED";
2055
+ /** Registration status transition is not allowed (e.g. re-registering a finished tournament). */
2032
2056
  TournamentRegistrationError[TournamentRegistrationError["TOURNAMENT_CANT_CHANGE_REGISTRATION_STATUS"] = 30007] = "TOURNAMENT_CANT_CHANGE_REGISTRATION_STATUS";
2057
+ /** Tournament filled up — maximum registrations reached. */
2033
2058
  TournamentRegistrationError[TournamentRegistrationError["TOURNAMENT_MAX_REGISTRATIONS_REACHED"] = 30008] = "TOURNAMENT_MAX_REGISTRATIONS_REACHED";
2034
- TournamentRegistrationError[TournamentRegistrationError["TOURNAMENT_REGISTRATION_NOT_ENOUGH_GEMS"] = 30010] = "TOURNAMENT_REGISTRATION_NOT_ENOUGH_GEMS";
2035
- TournamentRegistrationError[TournamentRegistrationError["TOURNAMENT_REGISTRATION_NOT_ENOUGH_DIAMONDS"] = 30011] = "TOURNAMENT_REGISTRATION_NOT_ENOUGH_DIAMONDS";
2059
+ /**
2060
+ * The user's wallet currency could not be resolved. Emitted server-side
2061
+ * during tournament score processing, NOT during registration — it is
2062
+ * never returned by `registerInTournament`. Included for completeness.
2063
+ */
2064
+ TournamentRegistrationError[TournamentRegistrationError["TOURNAMENT_INVALID_USER_CURRENCY"] = 30009] = "TOURNAMENT_INVALID_USER_CURRENCY";
2065
+ /** Insufficient gems balance for a gems-priced buy-in. */
2066
+ TournamentRegistrationError[TournamentRegistrationError["TOURNAMENT_REGISTRATION_NOT_ENOUGH_GEMS"] = 300010] = "TOURNAMENT_REGISTRATION_NOT_ENOUGH_GEMS";
2067
+ /** Insufficient diamonds balance for a diamonds-priced buy-in. */
2068
+ TournamentRegistrationError[TournamentRegistrationError["TOURNAMENT_REGISTRATION_NOT_ENOUGH_DIAMONDS"] = 300011] = "TOURNAMENT_REGISTRATION_NOT_ENOUGH_DIAMONDS";
2036
2069
  })(exports.TournamentRegistrationError || (exports.TournamentRegistrationError = {}));
2037
2070
 
2038
2071
  exports.TournamentType = void 0;
@@ -2802,12 +2835,25 @@ var WSAPIUser = /*#__PURE__*/function (_WSAPIBase) {
2802
2835
  * `ach_points_ever` and {@link getLevels} would also work, but
2803
2836
  * `progress` saves the math.
2804
2837
  *
2805
- * **Cache TTL**: the SDK caches the response for 30 seconds. There is
2806
- * no push event that refreshes this cache; a server-side level change
2807
- * (visible immediately on {@link getUserProfile}'s `ach_level_current_id`
2808
- * via the user-properties update channel) becomes visible on this
2809
- * method only after the cache TTL expires, or after
2810
- * `_smartico.api.clearCaches()` is called.
2838
+ * **Cache TTL & freshness**
2839
+ * The response is cached for 30 seconds, but the SDK automatically
2840
+ * drops that cache whenever a user-properties update arrives — the
2841
+ * same live channel that backs {@link getUserProfile}. The practical
2842
+ * effect depends on the label's leveling logic:
2843
+ * - **Points-based or operator-manual leveling**: a points or level
2844
+ * change flows through the user-properties channel, so the cache is
2845
+ * busted at that moment and the next `getCurrentLevel()` call
2846
+ * returns up-to-date data without waiting out the TTL.
2847
+ * - **Counter-based leveling** (level driven by sliding-window
2848
+ * counters such as deposit or wagering totals over a recent window —
2849
+ * see {@link getUserLevelExtraCounters}): ordinary progress changes
2850
+ * are recomputed by a periodic server job and do NOT emit a
2851
+ * user-properties update, so they become visible on this method only
2852
+ * after the 30 s TTL expires (or after `_smartico.api.clearCaches()`).
2853
+ *
2854
+ * Avoid calling `clearCaches()` on the points/manual path — it's
2855
+ * unnecessary there (the cache is already refreshed on the property
2856
+ * update) and forces a slower extra round-trip.
2811
2857
  *
2812
2858
  * **Leveling logic**
2813
2859
  * The semantics of how a user advances depends on the label's
@@ -2835,10 +2881,10 @@ var WSAPIUser = /*#__PURE__*/function (_WSAPIBase) {
2835
2881
  * console.log('[smartico] render level badge — name:', level.name,
2836
2882
  * 'progress:', Math.round(level.progress), '%');
2837
2883
  *
2838
- * // Detect level-up via getUserProfile's push channel.
2884
+ * // Detect level-up via getUserProfile's push channel. No clearCaches()
2885
+ * // needed — the SDK already drops the level cache on this update.
2839
2886
  * window._smartico.on('props_change', async (changed) => {
2840
2887
  * if ('ach_level_current_id' in changed) {
2841
- * await window._smartico.api.clearCaches(); // bust the 30 s cache
2842
2888
  * const fresh = await window._smartico.api.getCurrentLevel();
2843
2889
  * console.log('[smartico] user levelled up — animate badge to new level:', fresh.name);
2844
2890
  * }
@@ -2881,14 +2927,12 @@ var WSAPIUser = /*#__PURE__*/function (_WSAPIBase) {
2881
2927
  * `levelsCounter2Name`.
2882
2928
  *
2883
2929
  * **Refresh cadence**
2884
- * Sliding-window counters are recomputed by a server-side job that
2885
- * runs roughly every 60 seconds against the operator's BigQuery
2886
- * dataset; level transitions driven by counter changes have a
2887
- * latency of up to several minutes after the underlying activity
2888
- * (e.g. a deposit). The SDK caches the response for 30 seconds; no
2889
- * push event refreshes this cache. After a level change visible on
2890
- * {@link getUserProfile}'s `ach_level_current_id`, call
2891
- * `_smartico.api.clearCaches()` to force a fresh fetch.
2930
+ * Sliding-window counters are recomputed by a periodic server-side
2931
+ * job. Its rebuild cadence is operator-configured per brand —
2932
+ * commonly daily, though it can be set more frequent — so level
2933
+ * transitions driven by counter changes surface with a latency tied
2934
+ * to that rebuild schedule after the underlying activity (e.g. a
2935
+ * deposit), not in real time.
2892
2936
  *
2893
2937
  * **Idempotency**: safe. Read-only. Repeated calls within the cache
2894
2938
  * window return a deep-cloned cached value without a network
@@ -3438,8 +3482,14 @@ var WSAPIMissions = /*#__PURE__*/function (_WSAPIGeneral) {
3438
3482
  * **Idempotency / Side effects**: fetch-only; safe to call repeatedly.
3439
3483
  * The cache layer deduplicates concurrent calls within the TTL window.
3440
3484
  *
3485
+ * **Visitor mode**: not supported. Badges are an authenticated-only
3486
+ * feature; calling this on the visitor-mode handle (`_smartico.vapi`)
3487
+ * throws synchronously rather than silently returning an empty list.
3488
+ *
3441
3489
  * **UI guidance**: see [UI Guide — `getBadges`](../../docs/ui/missions/UIGuide_getBadges.md).
3442
3490
  *
3491
+ * @throws `Error("getBadges is not available in visitor mode")` when
3492
+ * called from a visitor-mode session.
3443
3493
  * @returns Promise resolving to `TMissionOrBadge[]`. Every item has
3444
3494
  * `type === 'badge'`. Cached for 30 s under the `Badges` key.
3445
3495
  *
@@ -3484,6 +3534,12 @@ var WSAPIMissions = /*#__PURE__*/function (_WSAPIGeneral) {
3484
3534
  _proto.getBadges = function getBadges() {
3485
3535
  try {
3486
3536
  var _this2 = this;
3537
+ // Badges are an authenticated-only feature. The visitor-mode WSAPI
3538
+ // instance (`_smartico.vapi`) is constructed without a tracker, so the
3539
+ // server would silently return nothing; throw a clear error instead.
3540
+ if (!_this2.api.tracker) {
3541
+ throw new Error('getBadges is not available in visitor mode');
3542
+ }
3487
3543
  return Promise.resolve(OCache.use(onUpdateContextKey.Badges, exports.ECacheContext.WSAPI, function () {
3488
3544
  return _this2.api.badgetsGetItemsT(_this2.userExtId);
3489
3545
  }, CACHE_DATA_SEC));
@@ -5728,12 +5784,10 @@ var WSAPIClans = /*#__PURE__*/function (_WSAPITournaments) {
5728
5784
  * tournament requires the user to be in a clan first.
5729
5785
  * - `1006` (`JOIN_CLAN_COOLDOWN_ACTIVE`) — user is inside the
5730
5786
  * switch-cooldown window from a previous clan join (default
5731
- * 7 days, configurable per label). Surface the
5787
+ * 7 days, configurable per label). Only reachable when the user is
5788
+ * already in a *different* clan (this call is then a clan switch);
5789
+ * a first-time join never returns `1006`. Surface the
5732
5790
  * `TClans.cooldown_until` expiry in the disabled CTA.
5733
- * - `1007` (`JOIN_CLAN_ARCHIVED`) — defined on the public enum but
5734
- * the server does NOT emit this code in practice (archived clans
5735
- * are reported as `1001`). Handle it as a synonym for `1001`
5736
- * defensively, but do not rely on it.
5737
5791
  * - `1011` (`JOIN_CLAN_JOINED_AFTER_TOURNAMENT_START`) — this
5738
5792
  * method does NOT return `1011` directly. The code fires on
5739
5793
  * {@link registerInTournament} responses when the user joined
@@ -5968,6 +6022,9 @@ var WSAPIJackpots = /*#__PURE__*/function (_WSAPIClans) {
5968
6022
  return Promise.resolve(OCache.use(onUpdateContextKey.Jackpots, exports.ECacheContext.WSAPI, function () {
5969
6023
  try {
5970
6024
  return Promise.resolve(_this2.api.jackpotGet(_this2.userExtId, filter)).then(function (_jackpots) {
6025
+ if (!(_jackpots != null && _jackpots.items)) {
6026
+ return [];
6027
+ }
5971
6028
  var _pots = _jackpots.items.map(function (jp) {
5972
6029
  return jp.pot;
5973
6030
  });
@@ -7629,6 +7686,9 @@ var WSAPIMiniGames = /*#__PURE__*/function (_WSAPIRaffles) {
7629
7686
  var index = templates.findIndex(function (t) {
7630
7687
  return t.id === data.saw_template_id;
7631
7688
  });
7689
+ if (index === -1) {
7690
+ return;
7691
+ }
7632
7692
  templates[index].spin_count = data.spin_count;
7633
7693
  _this6.updateEntity(onUpdateContextKey.Saw, templates);
7634
7694
  });
@@ -8760,15 +8820,8 @@ var WSAPILeaderBoard = /*#__PURE__*/function (_WSAPIGamePick) {
8760
8820
  * the array is the prize for place 1, the second for place 2, and
8761
8821
  * so on. The array length is the number of paid places.
8762
8822
  *
8763
- * **Cache TTL — single shared key (known limitation)**
8764
- * The SDK caches the response for 30 seconds under a SINGLE shared
8765
- * key — calling `getLeaderBoard(DAILY)` followed by
8766
- * `getLeaderBoard(WEEKLY)` within the same 30 s window returns the
8767
- * cached DAILY result for the WEEKLY call. Same applies to
8768
- * switching `getPreviousPeriod`. To force a fresh fetch when
8769
- * switching periods or current/previous, call
8770
- * `_smartico.api.clearCaches()` before the second call, or simply
8771
- * wait out the TTL.
8823
+ * **Cache TTL**
8824
+ * The SDK caches each response for 30 seconds.
8772
8825
  *
8773
8826
  * **Period boundaries**
8774
8827
  * The server finalizes each period on a server-configurable
@@ -8838,8 +8891,7 @@ var WSAPILeaderBoard = /*#__PURE__*/function (_WSAPIGamePick) {
8838
8891
  * }
8839
8892
  * }
8840
8893
  *
8841
- * // Switch to previous period view — but bust the cache first to avoid the shared-key collision.
8842
- * await window._smartico.api.clearCaches();
8894
+ * // Switch to previous period view — cached separately from the current period.
8843
8895
  * const prev = await window._smartico.api.getLeaderBoard(LeaderBoardPeriodType.WEEKLY, true);
8844
8896
  * console.log('[smartico] previous-week standings — render with greyed-out "ended" treatment:', prev?.users.length, 'finalists');
8845
8897
  *
@@ -8850,7 +8902,10 @@ var WSAPILeaderBoard = /*#__PURE__*/function (_WSAPIGamePick) {
8850
8902
  _proto.getLeaderBoard = function getLeaderBoard(periodType, getPreviousPeriod) {
8851
8903
  try {
8852
8904
  var _this = this;
8853
- return Promise.resolve(OCache.use(onUpdateContextKey.LeaderBoards, exports.ECacheContext.WSAPI, function () {
8905
+ // Cache per (periodType, current/previous) so switching tabs or
8906
+ // current↔previous within the TTL doesn't return a colliding board.
8907
+ var cacheKey = onUpdateContextKey.LeaderBoards + ":" + periodType + ":" + (getPreviousPeriod ? 1 : 0);
8908
+ return Promise.resolve(OCache.use(cacheKey, exports.ECacheContext.WSAPI, function () {
8854
8909
  return _this.api.leaderboardsGetT(_this.userExtId, periodType, getPreviousPeriod);
8855
8910
  }, CACHE_DATA_SEC));
8856
8911
  } catch (e) {
@@ -9683,6 +9738,7 @@ var WSAPI = /*#__PURE__*/function (_WSAPIInbox) {
9683
9738
  if ((data == null || (_data$props3 = data.props) == null ? void 0 : _data$props3.ach_points_balance) !== undefined || (data == null || (_data$props4 = data.props) == null ? void 0 : _data$props4.ach_gems_balance) !== undefined || (data == null || (_data$props5 = data.props) == null ? void 0 : _data$props5.ach_diamonds_balance) !== undefined) {
9684
9739
  _this.notifyActivityLogUpdate();
9685
9740
  }
9741
+ OCache.clear(exports.ECacheContext.WSAPI, onUpdateContextKey.CurrentLevel);
9686
9742
  });
9687
9743
  on(exports.ClassId.RAF_OPTIN_RESPONSE, function () {
9688
9744
  return _this.updateRaffles();
@@ -12275,31 +12331,37 @@ exports.AvatarCustomizeErrorCode = void 0;
12275
12331
  })(exports.AvatarCustomizeErrorCode || (exports.AvatarCustomizeErrorCode = {}));
12276
12332
  var AvatarCustomizeErrorMessage = (_AvatarCustomizeError = {}, _AvatarCustomizeError[exports.AvatarCustomizeErrorCode.AVATAR_USER_LIMIT] = 'You have exceeded number of custom avatars creation, please try later', _AvatarCustomizeError[exports.AvatarCustomizeErrorCode.AVATAR_LABEL_LIMIT] = 'The custom avatars are not available, please try again later', _AvatarCustomizeError);
12277
12333
 
12278
- /*
12279
- * Possible error codes returned in JOIN_CLAN_RESPONSE.errCode (cid: 575).
12280
- * Clan-protocol-specific numeric codes defined in the handler spec.
12334
+ /**
12335
+ * Error codes returned in `errCode` by the `joinClan` method (also carried
12336
+ * on `TClanJoinResult`). These are terse value definitions for lookup; the
12337
+ * full per-code narrative and UI handling lives in the `joinClan` method
12338
+ * TSDoc, which owns the error table.
12281
12339
  */
12282
12340
  exports.JoinClanErrorCode = void 0;
12283
12341
  (function (JoinClanErrorCode) {
12284
- /** No error, join completed */
12342
+ /** Success — join completed; entry fee (if any) deducted. */
12285
12343
  JoinClanErrorCode[JoinClanErrorCode["JOIN_CLAN_OK"] = 0] = "JOIN_CLAN_OK";
12286
- /** Invalid parameters */
12344
+ /** Request was malformed (missing or invalid parameters). */
12287
12345
  JoinClanErrorCode[JoinClanErrorCode["JOIN_CLAN_INVALID_PARAMETERS"] = 1000] = "JOIN_CLAN_INVALID_PARAMETERS";
12288
- /** clan_id doesn't exist for this label */
12346
+ /** Clan doesn't exist for this label. Archived clans are also reported as `1001`. */
12289
12347
  JoinClanErrorCode[JoinClanErrorCode["JOIN_CLAN_NOT_FOUND"] = 1001] = "JOIN_CLAN_NOT_FOUND";
12290
- /** members_count >= capacity_limit */
12348
+ /** Clan is full — member capacity reached. */
12291
12349
  JoinClanErrorCode[JoinClanErrorCode["JOIN_CLAN_FULL"] = 1002] = "JOIN_CLAN_FULL";
12292
- /** Not enough Points / Gems / Diamonds for entry fee */
12350
+ /** Insufficient balance for the entry fee (points / gems / diamonds). */
12293
12351
  JoinClanErrorCode[JoinClanErrorCode["JOIN_CLAN_INSUFFICIENT_FUNDS"] = 1003] = "JOIN_CLAN_INSUFFICIENT_FUNDS";
12294
- /** User doesn't satisfy entry_conditions / entry_segment_id */
12352
+ /** User doesn't meet the clan's entry segment or conditions. */
12295
12353
  JoinClanErrorCode[JoinClanErrorCode["JOIN_CLAN_SEGMENT_MISMATCH"] = 1004] = "JOIN_CLAN_SEGMENT_MISMATCH";
12296
- /** User is not in a clan */
12354
+ /**
12355
+ * User is not in a clan. Note: a `registerInTournament` response code
12356
+ * that shares this enum — never returned by `joinClan`.
12357
+ */
12297
12358
  JoinClanErrorCode[JoinClanErrorCode["JOIN_CLAN_USER_IS_NOT_IN_CLAN"] = 1005] = "JOIN_CLAN_USER_IS_NOT_IN_CLAN";
12298
- /** User is within the CLAN_COOLDOWN_DAYS window */
12359
+ /** User is within the clan-switch cooldown window (switch only). */
12299
12360
  JoinClanErrorCode[JoinClanErrorCode["JOIN_CLAN_COOLDOWN_ACTIVE"] = 1006] = "JOIN_CLAN_COOLDOWN_ACTIVE";
12300
- /** clan_status_id != 1 (clan is archived) */
12301
- JoinClanErrorCode[JoinClanErrorCode["JOIN_CLAN_ARCHIVED"] = 1007] = "JOIN_CLAN_ARCHIVED";
12302
- /** Clan joined after tournament start */
12361
+ /**
12362
+ * Clan joined after tournament start. Note: a `registerInTournament`
12363
+ * response code that shares this enum — never returned by `joinClan`.
12364
+ */
12303
12365
  JoinClanErrorCode[JoinClanErrorCode["JOIN_CLAN_JOINED_AFTER_TOURNAMENT_START"] = 1011] = "JOIN_CLAN_JOINED_AFTER_TOURNAMENT_START";
12304
12366
  })(exports.JoinClanErrorCode || (exports.JoinClanErrorCode = {}));
12305
12367