@smartico/public-api 0.0.385 → 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
@@ -2022,20 +2022,50 @@ var tournamentInfoItemTransform = function tournamentInfoItemTransform(t) {
2022
2022
  return response;
2023
2023
  };
2024
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
+ */
2025
2037
  exports.TournamentRegistrationError = void 0;
2026
2038
  (function (TournamentRegistrationError) {
2039
+ /** Success — registration persisted; buy-in (if any) deducted. */
2027
2040
  TournamentRegistrationError[TournamentRegistrationError["NO_ERROR"] = 0] = "NO_ERROR";
2041
+ /** Clan-based tournament and the user does not belong to a clan yet. */
2028
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. */
2029
2044
  TournamentRegistrationError[TournamentRegistrationError["TOURNAMENT_INSTANCE_NOT_FOUND"] = 30001] = "TOURNAMENT_INSTANCE_NOT_FOUND";
2045
+ /** Insufficient points balance for a points-priced buy-in. */
2030
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). */
2031
2048
  TournamentRegistrationError[TournamentRegistrationError["TOURNAMENT_INSTANCE_NOT_IN_STATE"] = 30003] = "TOURNAMENT_INSTANCE_NOT_IN_STATE";
2049
+ /** User is already registered; treat as an idempotent success. */
2032
2050
  TournamentRegistrationError[TournamentRegistrationError["TOURNAMENT_ALREADY_REGISTERED"] = 30004] = "TOURNAMENT_ALREADY_REGISTERED";
2051
+ /** User does not satisfy the tournament's segment / entry conditions. */
2033
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). */
2034
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). */
2035
2056
  TournamentRegistrationError[TournamentRegistrationError["TOURNAMENT_CANT_CHANGE_REGISTRATION_STATUS"] = 30007] = "TOURNAMENT_CANT_CHANGE_REGISTRATION_STATUS";
2057
+ /** Tournament filled up — maximum registrations reached. */
2036
2058
  TournamentRegistrationError[TournamentRegistrationError["TOURNAMENT_MAX_REGISTRATIONS_REACHED"] = 30008] = "TOURNAMENT_MAX_REGISTRATIONS_REACHED";
2037
- TournamentRegistrationError[TournamentRegistrationError["TOURNAMENT_REGISTRATION_NOT_ENOUGH_GEMS"] = 30010] = "TOURNAMENT_REGISTRATION_NOT_ENOUGH_GEMS";
2038
- 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";
2039
2069
  })(exports.TournamentRegistrationError || (exports.TournamentRegistrationError = {}));
2040
2070
 
2041
2071
  exports.TournamentType = void 0;
@@ -2805,12 +2835,25 @@ var WSAPIUser = /*#__PURE__*/function (_WSAPIBase) {
2805
2835
  * `ach_points_ever` and {@link getLevels} would also work, but
2806
2836
  * `progress` saves the math.
2807
2837
  *
2808
- * **Cache TTL**: the SDK caches the response for 30 seconds. There is
2809
- * no push event that refreshes this cache; a server-side level change
2810
- * (visible immediately on {@link getUserProfile}'s `ach_level_current_id`
2811
- * via the user-properties update channel) becomes visible on this
2812
- * method only after the cache TTL expires, or after
2813
- * `_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.
2814
2857
  *
2815
2858
  * **Leveling logic**
2816
2859
  * The semantics of how a user advances depends on the label's
@@ -2838,10 +2881,10 @@ var WSAPIUser = /*#__PURE__*/function (_WSAPIBase) {
2838
2881
  * console.log('[smartico] render level badge — name:', level.name,
2839
2882
  * 'progress:', Math.round(level.progress), '%');
2840
2883
  *
2841
- * // 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.
2842
2886
  * window._smartico.on('props_change', async (changed) => {
2843
2887
  * if ('ach_level_current_id' in changed) {
2844
- * await window._smartico.api.clearCaches(); // bust the 30 s cache
2845
2888
  * const fresh = await window._smartico.api.getCurrentLevel();
2846
2889
  * console.log('[smartico] user levelled up — animate badge to new level:', fresh.name);
2847
2890
  * }
@@ -2884,14 +2927,12 @@ var WSAPIUser = /*#__PURE__*/function (_WSAPIBase) {
2884
2927
  * `levelsCounter2Name`.
2885
2928
  *
2886
2929
  * **Refresh cadence**
2887
- * Sliding-window counters are recomputed by a server-side job that
2888
- * runs roughly every 60 seconds against the operator's BigQuery
2889
- * dataset; level transitions driven by counter changes have a
2890
- * latency of up to several minutes after the underlying activity
2891
- * (e.g. a deposit). The SDK caches the response for 30 seconds; no
2892
- * push event refreshes this cache. After a level change visible on
2893
- * {@link getUserProfile}'s `ach_level_current_id`, call
2894
- * `_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.
2895
2936
  *
2896
2937
  * **Idempotency**: safe. Read-only. Repeated calls within the cache
2897
2938
  * window return a deep-cloned cached value without a network
@@ -3441,8 +3482,14 @@ var WSAPIMissions = /*#__PURE__*/function (_WSAPIGeneral) {
3441
3482
  * **Idempotency / Side effects**: fetch-only; safe to call repeatedly.
3442
3483
  * The cache layer deduplicates concurrent calls within the TTL window.
3443
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
+ *
3444
3489
  * **UI guidance**: see [UI Guide — `getBadges`](../../docs/ui/missions/UIGuide_getBadges.md).
3445
3490
  *
3491
+ * @throws `Error("getBadges is not available in visitor mode")` when
3492
+ * called from a visitor-mode session.
3446
3493
  * @returns Promise resolving to `TMissionOrBadge[]`. Every item has
3447
3494
  * `type === 'badge'`. Cached for 30 s under the `Badges` key.
3448
3495
  *
@@ -3487,6 +3534,12 @@ var WSAPIMissions = /*#__PURE__*/function (_WSAPIGeneral) {
3487
3534
  _proto.getBadges = function getBadges() {
3488
3535
  try {
3489
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
+ }
3490
3543
  return Promise.resolve(OCache.use(onUpdateContextKey.Badges, exports.ECacheContext.WSAPI, function () {
3491
3544
  return _this2.api.badgetsGetItemsT(_this2.userExtId);
3492
3545
  }, CACHE_DATA_SEC));
@@ -5731,12 +5784,10 @@ var WSAPIClans = /*#__PURE__*/function (_WSAPITournaments) {
5731
5784
  * tournament requires the user to be in a clan first.
5732
5785
  * - `1006` (`JOIN_CLAN_COOLDOWN_ACTIVE`) — user is inside the
5733
5786
  * switch-cooldown window from a previous clan join (default
5734
- * 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
5735
5790
  * `TClans.cooldown_until` expiry in the disabled CTA.
5736
- * - `1007` (`JOIN_CLAN_ARCHIVED`) — defined on the public enum but
5737
- * the server does NOT emit this code in practice (archived clans
5738
- * are reported as `1001`). Handle it as a synonym for `1001`
5739
- * defensively, but do not rely on it.
5740
5791
  * - `1011` (`JOIN_CLAN_JOINED_AFTER_TOURNAMENT_START`) — this
5741
5792
  * method does NOT return `1011` directly. The code fires on
5742
5793
  * {@link registerInTournament} responses when the user joined
@@ -8769,15 +8820,8 @@ var WSAPILeaderBoard = /*#__PURE__*/function (_WSAPIGamePick) {
8769
8820
  * the array is the prize for place 1, the second for place 2, and
8770
8821
  * so on. The array length is the number of paid places.
8771
8822
  *
8772
- * **Cache TTL — single shared key (known limitation)**
8773
- * The SDK caches the response for 30 seconds under a SINGLE shared
8774
- * key — calling `getLeaderBoard(DAILY)` followed by
8775
- * `getLeaderBoard(WEEKLY)` within the same 30 s window returns the
8776
- * cached DAILY result for the WEEKLY call. Same applies to
8777
- * switching `getPreviousPeriod`. To force a fresh fetch when
8778
- * switching periods or current/previous, call
8779
- * `_smartico.api.clearCaches()` before the second call, or simply
8780
- * wait out the TTL.
8823
+ * **Cache TTL**
8824
+ * The SDK caches each response for 30 seconds.
8781
8825
  *
8782
8826
  * **Period boundaries**
8783
8827
  * The server finalizes each period on a server-configurable
@@ -8847,8 +8891,7 @@ var WSAPILeaderBoard = /*#__PURE__*/function (_WSAPIGamePick) {
8847
8891
  * }
8848
8892
  * }
8849
8893
  *
8850
- * // Switch to previous period view — but bust the cache first to avoid the shared-key collision.
8851
- * await window._smartico.api.clearCaches();
8894
+ * // Switch to previous period view — cached separately from the current period.
8852
8895
  * const prev = await window._smartico.api.getLeaderBoard(LeaderBoardPeriodType.WEEKLY, true);
8853
8896
  * console.log('[smartico] previous-week standings — render with greyed-out "ended" treatment:', prev?.users.length, 'finalists');
8854
8897
  *
@@ -8859,7 +8902,10 @@ var WSAPILeaderBoard = /*#__PURE__*/function (_WSAPIGamePick) {
8859
8902
  _proto.getLeaderBoard = function getLeaderBoard(periodType, getPreviousPeriod) {
8860
8903
  try {
8861
8904
  var _this = this;
8862
- 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 () {
8863
8909
  return _this.api.leaderboardsGetT(_this.userExtId, periodType, getPreviousPeriod);
8864
8910
  }, CACHE_DATA_SEC));
8865
8911
  } catch (e) {
@@ -9692,6 +9738,7 @@ var WSAPI = /*#__PURE__*/function (_WSAPIInbox) {
9692
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) {
9693
9739
  _this.notifyActivityLogUpdate();
9694
9740
  }
9741
+ OCache.clear(exports.ECacheContext.WSAPI, onUpdateContextKey.CurrentLevel);
9695
9742
  });
9696
9743
  on(exports.ClassId.RAF_OPTIN_RESPONSE, function () {
9697
9744
  return _this.updateRaffles();
@@ -12284,31 +12331,37 @@ exports.AvatarCustomizeErrorCode = void 0;
12284
12331
  })(exports.AvatarCustomizeErrorCode || (exports.AvatarCustomizeErrorCode = {}));
12285
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);
12286
12333
 
12287
- /*
12288
- * Possible error codes returned in JOIN_CLAN_RESPONSE.errCode (cid: 575).
12289
- * 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.
12290
12339
  */
12291
12340
  exports.JoinClanErrorCode = void 0;
12292
12341
  (function (JoinClanErrorCode) {
12293
- /** No error, join completed */
12342
+ /** Success — join completed; entry fee (if any) deducted. */
12294
12343
  JoinClanErrorCode[JoinClanErrorCode["JOIN_CLAN_OK"] = 0] = "JOIN_CLAN_OK";
12295
- /** Invalid parameters */
12344
+ /** Request was malformed (missing or invalid parameters). */
12296
12345
  JoinClanErrorCode[JoinClanErrorCode["JOIN_CLAN_INVALID_PARAMETERS"] = 1000] = "JOIN_CLAN_INVALID_PARAMETERS";
12297
- /** clan_id doesn't exist for this label */
12346
+ /** Clan doesn't exist for this label. Archived clans are also reported as `1001`. */
12298
12347
  JoinClanErrorCode[JoinClanErrorCode["JOIN_CLAN_NOT_FOUND"] = 1001] = "JOIN_CLAN_NOT_FOUND";
12299
- /** members_count >= capacity_limit */
12348
+ /** Clan is full — member capacity reached. */
12300
12349
  JoinClanErrorCode[JoinClanErrorCode["JOIN_CLAN_FULL"] = 1002] = "JOIN_CLAN_FULL";
12301
- /** Not enough Points / Gems / Diamonds for entry fee */
12350
+ /** Insufficient balance for the entry fee (points / gems / diamonds). */
12302
12351
  JoinClanErrorCode[JoinClanErrorCode["JOIN_CLAN_INSUFFICIENT_FUNDS"] = 1003] = "JOIN_CLAN_INSUFFICIENT_FUNDS";
12303
- /** User doesn't satisfy entry_conditions / entry_segment_id */
12352
+ /** User doesn't meet the clan's entry segment or conditions. */
12304
12353
  JoinClanErrorCode[JoinClanErrorCode["JOIN_CLAN_SEGMENT_MISMATCH"] = 1004] = "JOIN_CLAN_SEGMENT_MISMATCH";
12305
- /** 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
+ */
12306
12358
  JoinClanErrorCode[JoinClanErrorCode["JOIN_CLAN_USER_IS_NOT_IN_CLAN"] = 1005] = "JOIN_CLAN_USER_IS_NOT_IN_CLAN";
12307
- /** User is within the CLAN_COOLDOWN_DAYS window */
12359
+ /** User is within the clan-switch cooldown window (switch only). */
12308
12360
  JoinClanErrorCode[JoinClanErrorCode["JOIN_CLAN_COOLDOWN_ACTIVE"] = 1006] = "JOIN_CLAN_COOLDOWN_ACTIVE";
12309
- /** clan_status_id != 1 (clan is archived) */
12310
- JoinClanErrorCode[JoinClanErrorCode["JOIN_CLAN_ARCHIVED"] = 1007] = "JOIN_CLAN_ARCHIVED";
12311
- /** 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
+ */
12312
12365
  JoinClanErrorCode[JoinClanErrorCode["JOIN_CLAN_JOINED_AFTER_TOURNAMENT_START"] = 1011] = "JOIN_CLAN_JOINED_AFTER_TOURNAMENT_START";
12313
12366
  })(exports.JoinClanErrorCode || (exports.JoinClanErrorCode = {}));
12314
12367