@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.
- package/dist/Clans/JoinClanErrorCode.d.ts +21 -11
- package/dist/Tournaments/TournamentRegistrationError.d.ts +32 -2
- package/dist/WSAPI/WSAPIClans.d.ts +3 -5
- package/dist/WSAPI/WSAPILeaderBoard.d.ts +3 -11
- package/dist/WSAPI/WSAPIMissions.d.ts +6 -0
- package/dist/WSAPI/WSAPIUser.d.ts +27 -16
- package/dist/index.js +102 -49
- package/dist/index.js.map +1 -1
- package/dist/index.modern.mjs +102 -49
- package/dist/index.modern.mjs.map +1 -1
- package/docs/api/classes/WSAPILeaderBoard.md +3 -11
- package/docs/api/classes/WSAPIMissions.md +9 -0
- package/docs/api/classes/WSAPIUser.md +27 -16
- package/docs/api/enumerations/TournamentRegistrationError.md +47 -2
- package/docs/ui/clans/UIGuide_joinClan.md +1 -2
- package/docs/ui/leaderboard/UIGuide_getLeaderBoard.md +15 -14
- package/package.json +1 -1
- package/src/Clans/JoinClanErrorCode.ts +20 -14
- package/src/Tournaments/TournamentRegistrationError.ts +32 -4
- package/src/WSAPI/WSAPI.ts +3 -1
- package/src/WSAPI/WSAPIClans.ts +3 -5
- package/src/WSAPI/WSAPILeaderBoard.ts +7 -12
- package/src/WSAPI/WSAPIMissions.ts +12 -0
- package/src/WSAPI/WSAPIUser.ts +27 -16
|
@@ -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
|
-
/**
|
|
8
|
+
/** Success — join completed; entry fee (if any) deducted. */
|
|
3
9
|
JOIN_CLAN_OK = 0,
|
|
4
|
-
/**
|
|
10
|
+
/** Request was malformed (missing or invalid parameters). */
|
|
5
11
|
JOIN_CLAN_INVALID_PARAMETERS = 1000,
|
|
6
|
-
/**
|
|
12
|
+
/** Clan doesn't exist for this label. Archived clans are also reported as `1001`. */
|
|
7
13
|
JOIN_CLAN_NOT_FOUND = 1001,
|
|
8
|
-
/**
|
|
14
|
+
/** Clan is full — member capacity reached. */
|
|
9
15
|
JOIN_CLAN_FULL = 1002,
|
|
10
|
-
/**
|
|
16
|
+
/** Insufficient balance for the entry fee (points / gems / diamonds). */
|
|
11
17
|
JOIN_CLAN_INSUFFICIENT_FUNDS = 1003,
|
|
12
|
-
/** User doesn't
|
|
18
|
+
/** User doesn't meet the clan's entry segment or conditions. */
|
|
13
19
|
JOIN_CLAN_SEGMENT_MISMATCH = 1004,
|
|
14
|
-
/**
|
|
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
|
|
25
|
+
/** User is within the clan-switch cooldown window (switch only). */
|
|
17
26
|
JOIN_CLAN_COOLDOWN_ACTIVE = 1006,
|
|
18
|
-
/**
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
|
|
13
|
-
|
|
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).
|
|
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
|
|
52
|
-
* The SDK caches
|
|
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 —
|
|
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
|
|
338
|
-
*
|
|
339
|
-
*
|
|
340
|
-
*
|
|
341
|
-
*
|
|
342
|
-
*
|
|
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
|
|
407
|
-
*
|
|
408
|
-
*
|
|
409
|
-
*
|
|
410
|
-
*
|
|
411
|
-
*
|
|
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
|
-
|
|
2038
|
-
|
|
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
|
|
2809
|
-
*
|
|
2810
|
-
*
|
|
2811
|
-
*
|
|
2812
|
-
*
|
|
2813
|
-
*
|
|
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
|
|
2888
|
-
*
|
|
2889
|
-
*
|
|
2890
|
-
*
|
|
2891
|
-
*
|
|
2892
|
-
*
|
|
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).
|
|
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
|
|
8773
|
-
* The SDK caches
|
|
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 —
|
|
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
|
-
|
|
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
|
-
*
|
|
12289
|
-
*
|
|
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
|
-
/**
|
|
12342
|
+
/** Success — join completed; entry fee (if any) deducted. */
|
|
12294
12343
|
JoinClanErrorCode[JoinClanErrorCode["JOIN_CLAN_OK"] = 0] = "JOIN_CLAN_OK";
|
|
12295
|
-
/**
|
|
12344
|
+
/** Request was malformed (missing or invalid parameters). */
|
|
12296
12345
|
JoinClanErrorCode[JoinClanErrorCode["JOIN_CLAN_INVALID_PARAMETERS"] = 1000] = "JOIN_CLAN_INVALID_PARAMETERS";
|
|
12297
|
-
/**
|
|
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
|
-
/**
|
|
12348
|
+
/** Clan is full — member capacity reached. */
|
|
12300
12349
|
JoinClanErrorCode[JoinClanErrorCode["JOIN_CLAN_FULL"] = 1002] = "JOIN_CLAN_FULL";
|
|
12301
|
-
/**
|
|
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
|
|
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
|
-
/**
|
|
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
|
|
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
|
-
/**
|
|
12310
|
-
|
|
12311
|
-
|
|
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
|
|