@smartico/public-api 0.0.385 → 0.0.387
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/README.md +1 -1
- package/dist/Avatars/AvatarCustomizeErrorCode.d.ts +7 -1
- package/dist/Avatars/AvatarCustomizeResponse.d.ts +16 -0
- package/dist/Avatars/index.d.ts +1 -0
- package/dist/Clans/JoinClanErrorCode.d.ts +21 -11
- package/dist/Missions/UserAchievementTask.d.ts +4 -0
- package/dist/SmarticoAPI.d.ts +11 -0
- package/dist/Tournaments/TournamentRegistrationError.d.ts +32 -2
- package/dist/WSAPI/WSAPIAvatars.d.ts +103 -0
- 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/WSAPITypes.d.ts +6 -2
- package/dist/WSAPI/WSAPIUser.d.ts +27 -16
- package/dist/index.js +362 -127
- package/dist/index.js.map +1 -1
- package/dist/index.modern.mjs +270 -55
- package/dist/index.modern.mjs.map +1 -1
- package/docs/SmarticoObject.md +15 -0
- package/docs/api/README.md +2 -0
- package/docs/api/classes/WSAPIAvatars.md +135 -0
- package/docs/api/classes/WSAPIClans.md +3 -5
- 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/documents/SmarticoObject.md +15 -0
- package/docs/api/enumerations/AvatarCustomizeErrorCode.md +21 -0
- package/docs/api/enumerations/JoinClanErrorCode.md +16 -17
- package/docs/api/enumerations/TournamentRegistrationError.md +47 -2
- package/docs/api/interfaces/AvatarCustomizeResponse.md +31 -0
- package/docs/api/interfaces/TAvatarPrompt.md +2 -2
- package/docs/api/interfaces/TMissionOrBadgeTask.md +16 -0
- package/docs/api/interfaces/UserAchievementTask.md +16 -0
- package/docs/native/PROTOCOL.md +3 -1
- package/docs/ui/avatars/UIGuide_avatarsCustomize.md +69 -0
- 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/Avatars/AvatarCustomizeErrorCode.ts +7 -5
- package/src/Avatars/AvatarCustomizeResponse.ts +17 -0
- package/src/Avatars/index.ts +1 -0
- package/src/Clans/JoinClanErrorCode.ts +20 -14
- package/src/Missions/UserAchievement.ts +2 -0
- package/src/Missions/UserAchievementTask.ts +4 -0
- package/src/SmarticoAPI.ts +53 -0
- package/src/Tournaments/TournamentRegistrationError.ts +32 -4
- package/src/WSAPI/WSAPI.ts +3 -1
- package/src/WSAPI/WSAPIAvatars.ts +121 -0
- package/src/WSAPI/WSAPIClans.ts +3 -5
- package/src/WSAPI/WSAPILeaderBoard.ts +7 -12
- package/src/WSAPI/WSAPIMissions.ts +12 -0
- package/src/WSAPI/WSAPITypes.ts +6 -2
- package/src/WSAPI/WSAPIUser.ts +27 -16
- package/tsconfig.json +3 -1
|
@@ -198,8 +198,14 @@ export class WSAPIMissions extends WSAPIGeneral {
|
|
|
198
198
|
* **Idempotency / Side effects**: fetch-only; safe to call repeatedly.
|
|
199
199
|
* The cache layer deduplicates concurrent calls within the TTL window.
|
|
200
200
|
*
|
|
201
|
+
* **Visitor mode**: not supported. Badges are an authenticated-only
|
|
202
|
+
* feature; calling this on the visitor-mode handle (`_smartico.vapi`)
|
|
203
|
+
* throws synchronously rather than silently returning an empty list.
|
|
204
|
+
*
|
|
201
205
|
* **UI guidance**: see [UI Guide — `getBadges`](../../docs/ui/missions/UIGuide_getBadges.md).
|
|
202
206
|
*
|
|
207
|
+
* @throws `Error("getBadges is not available in visitor mode")` when
|
|
208
|
+
* called from a visitor-mode session.
|
|
203
209
|
* @returns Promise resolving to `TMissionOrBadge[]`. Every item has
|
|
204
210
|
* `type === 'badge'`. Cached for 30 s under the `Badges` key.
|
|
205
211
|
*
|
|
@@ -241,6 +247,12 @@ export class WSAPIMissions extends WSAPIGeneral {
|
|
|
241
247
|
* ```
|
|
242
248
|
*/
|
|
243
249
|
public async getBadges(): Promise<TMissionOrBadge[]> {
|
|
250
|
+
// Badges are an authenticated-only feature. The visitor-mode WSAPI
|
|
251
|
+
// instance (`_smartico.vapi`) is constructed without a tracker, so the
|
|
252
|
+
// server would silently return nothing; throw a clear error instead.
|
|
253
|
+
if (!this.api.tracker) {
|
|
254
|
+
throw new Error('getBadges is not available in visitor mode');
|
|
255
|
+
}
|
|
244
256
|
return OCache.use(onUpdateContextKey.Badges, ECacheContext.WSAPI, () => this.api.badgetsGetItemsT(this.userExtId), CACHE_DATA_SEC);
|
|
245
257
|
}
|
|
246
258
|
|
package/src/WSAPI/WSAPITypes.ts
CHANGED
|
@@ -953,6 +953,10 @@ export interface TMissionOrBadgeTask {
|
|
|
953
953
|
progress: number;
|
|
954
954
|
/** Reward for completing the task in points */
|
|
955
955
|
points_reward: number;
|
|
956
|
+
/** Reward for completing the task in gems */
|
|
957
|
+
gems_reward?: number;
|
|
958
|
+
/** Reward for completing the task in diamonds */
|
|
959
|
+
diamonds_reward?: number;
|
|
956
960
|
/** This is the total number of times the user needs to execute to complete task. e.g. he needs to bet 100 times. Here will be 100 */
|
|
957
961
|
execution_count_expected?: number;
|
|
958
962
|
/** This is the number of times the user has executed 'activity' of the task. e.g. he bet 5 times out of 100. Here will be 5 */
|
|
@@ -1780,9 +1784,9 @@ export interface TAvatarPrompt {
|
|
|
1780
1784
|
name: string;
|
|
1781
1785
|
/** Absolute CDN URL of the prompt's preview icon. */
|
|
1782
1786
|
icon_url: string;
|
|
1783
|
-
/** Currency used to pay for the customization. `0` = points, `1` = gems, `2` = diamonds. */
|
|
1787
|
+
/** Currency used to pay for the customization. `0` = points, `1` = gems, `2` = diamonds, `3` = free. A `cost_value` of `0` is also free. */
|
|
1784
1788
|
cost_currency_type_id: number;
|
|
1785
|
-
/** Cost amount in the currency named by `cost_currency_type_id`. */
|
|
1789
|
+
/** Cost amount in the currency named by `cost_currency_type_id`. `0` = free. */
|
|
1786
1790
|
cost_value: number;
|
|
1787
1791
|
}
|
|
1788
1792
|
|
package/src/WSAPI/WSAPIUser.ts
CHANGED
|
@@ -371,12 +371,25 @@ export class WSAPIUser extends WSAPIBase {
|
|
|
371
371
|
* `ach_points_ever` and {@link getLevels} would also work, but
|
|
372
372
|
* `progress` saves the math.
|
|
373
373
|
*
|
|
374
|
-
* **Cache TTL
|
|
375
|
-
*
|
|
376
|
-
*
|
|
377
|
-
*
|
|
378
|
-
*
|
|
379
|
-
*
|
|
374
|
+
* **Cache TTL & freshness**
|
|
375
|
+
* The response is cached for 30 seconds, but the SDK automatically
|
|
376
|
+
* drops that cache whenever a user-properties update arrives — the
|
|
377
|
+
* same live channel that backs {@link getUserProfile}. The practical
|
|
378
|
+
* effect depends on the label's leveling logic:
|
|
379
|
+
* - **Points-based or operator-manual leveling**: a points or level
|
|
380
|
+
* change flows through the user-properties channel, so the cache is
|
|
381
|
+
* busted at that moment and the next `getCurrentLevel()` call
|
|
382
|
+
* returns up-to-date data without waiting out the TTL.
|
|
383
|
+
* - **Counter-based leveling** (level driven by sliding-window
|
|
384
|
+
* counters such as deposit or wagering totals over a recent window —
|
|
385
|
+
* see {@link getUserLevelExtraCounters}): ordinary progress changes
|
|
386
|
+
* are recomputed by a periodic server job and do NOT emit a
|
|
387
|
+
* user-properties update, so they become visible on this method only
|
|
388
|
+
* after the 30 s TTL expires (or after `_smartico.api.clearCaches()`).
|
|
389
|
+
*
|
|
390
|
+
* Avoid calling `clearCaches()` on the points/manual path — it's
|
|
391
|
+
* unnecessary there (the cache is already refreshed on the property
|
|
392
|
+
* update) and forces a slower extra round-trip.
|
|
380
393
|
*
|
|
381
394
|
* **Leveling logic**
|
|
382
395
|
* The semantics of how a user advances depends on the label's
|
|
@@ -404,10 +417,10 @@ export class WSAPIUser extends WSAPIBase {
|
|
|
404
417
|
* console.log('[smartico] render level badge — name:', level.name,
|
|
405
418
|
* 'progress:', Math.round(level.progress), '%');
|
|
406
419
|
*
|
|
407
|
-
* // Detect level-up via getUserProfile's push channel.
|
|
420
|
+
* // Detect level-up via getUserProfile's push channel. No clearCaches()
|
|
421
|
+
* // needed — the SDK already drops the level cache on this update.
|
|
408
422
|
* window._smartico.on('props_change', async (changed) => {
|
|
409
423
|
* if ('ach_level_current_id' in changed) {
|
|
410
|
-
* await window._smartico.api.clearCaches(); // bust the 30 s cache
|
|
411
424
|
* const fresh = await window._smartico.api.getCurrentLevel();
|
|
412
425
|
* console.log('[smartico] user levelled up — animate badge to new level:', fresh.name);
|
|
413
426
|
* }
|
|
@@ -443,14 +456,12 @@ export class WSAPIUser extends WSAPIBase {
|
|
|
443
456
|
* `levelsCounter2Name`.
|
|
444
457
|
*
|
|
445
458
|
* **Refresh cadence**
|
|
446
|
-
* Sliding-window counters are recomputed by a server-side
|
|
447
|
-
*
|
|
448
|
-
*
|
|
449
|
-
*
|
|
450
|
-
*
|
|
451
|
-
*
|
|
452
|
-
* {@link getUserProfile}'s `ach_level_current_id`, call
|
|
453
|
-
* `_smartico.api.clearCaches()` to force a fresh fetch.
|
|
459
|
+
* Sliding-window counters are recomputed by a periodic server-side
|
|
460
|
+
* job. Its rebuild cadence is operator-configured per brand —
|
|
461
|
+
* commonly daily, though it can be set more frequent — so level
|
|
462
|
+
* transitions driven by counter changes surface with a latency tied
|
|
463
|
+
* to that rebuild schedule after the underlying activity (e.g. a
|
|
464
|
+
* deposit), not in real time.
|
|
454
465
|
*
|
|
455
466
|
* **Idempotency**: safe. Read-only. Repeated calls within the cache
|
|
456
467
|
* window return a deep-cloned cached value without a network
|
package/tsconfig.json
CHANGED
|
@@ -90,7 +90,9 @@
|
|
|
90
90
|
"src/Tournaments/GetClanTournamentPlayersResponse.ts",
|
|
91
91
|
"src/Avatars/AvatarDefinition.ts",
|
|
92
92
|
"src/Avatars/AvatarCustomized.ts",
|
|
93
|
-
"src/Avatars/AvatarPrompt.ts"
|
|
93
|
+
"src/Avatars/AvatarPrompt.ts",
|
|
94
|
+
"src/Avatars/AvatarCustomizeResponse.ts",
|
|
95
|
+
"src/Avatars/AvatarCustomizeErrorCode.ts"
|
|
94
96
|
],
|
|
95
97
|
"out": "docs/api",
|
|
96
98
|
"projectDocuments": ["docs/SmarticoObject.md", "docs/Callbacks.md", "docs/Transforms.md"],
|