@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.
Files changed (54) hide show
  1. package/README.md +1 -1
  2. package/dist/Avatars/AvatarCustomizeErrorCode.d.ts +7 -1
  3. package/dist/Avatars/AvatarCustomizeResponse.d.ts +16 -0
  4. package/dist/Avatars/index.d.ts +1 -0
  5. package/dist/Clans/JoinClanErrorCode.d.ts +21 -11
  6. package/dist/Missions/UserAchievementTask.d.ts +4 -0
  7. package/dist/SmarticoAPI.d.ts +11 -0
  8. package/dist/Tournaments/TournamentRegistrationError.d.ts +32 -2
  9. package/dist/WSAPI/WSAPIAvatars.d.ts +103 -0
  10. package/dist/WSAPI/WSAPIClans.d.ts +3 -5
  11. package/dist/WSAPI/WSAPILeaderBoard.d.ts +3 -11
  12. package/dist/WSAPI/WSAPIMissions.d.ts +6 -0
  13. package/dist/WSAPI/WSAPITypes.d.ts +6 -2
  14. package/dist/WSAPI/WSAPIUser.d.ts +27 -16
  15. package/dist/index.js +362 -127
  16. package/dist/index.js.map +1 -1
  17. package/dist/index.modern.mjs +270 -55
  18. package/dist/index.modern.mjs.map +1 -1
  19. package/docs/SmarticoObject.md +15 -0
  20. package/docs/api/README.md +2 -0
  21. package/docs/api/classes/WSAPIAvatars.md +135 -0
  22. package/docs/api/classes/WSAPIClans.md +3 -5
  23. package/docs/api/classes/WSAPILeaderBoard.md +3 -11
  24. package/docs/api/classes/WSAPIMissions.md +9 -0
  25. package/docs/api/classes/WSAPIUser.md +27 -16
  26. package/docs/api/documents/SmarticoObject.md +15 -0
  27. package/docs/api/enumerations/AvatarCustomizeErrorCode.md +21 -0
  28. package/docs/api/enumerations/JoinClanErrorCode.md +16 -17
  29. package/docs/api/enumerations/TournamentRegistrationError.md +47 -2
  30. package/docs/api/interfaces/AvatarCustomizeResponse.md +31 -0
  31. package/docs/api/interfaces/TAvatarPrompt.md +2 -2
  32. package/docs/api/interfaces/TMissionOrBadgeTask.md +16 -0
  33. package/docs/api/interfaces/UserAchievementTask.md +16 -0
  34. package/docs/native/PROTOCOL.md +3 -1
  35. package/docs/ui/avatars/UIGuide_avatarsCustomize.md +69 -0
  36. package/docs/ui/clans/UIGuide_joinClan.md +1 -2
  37. package/docs/ui/leaderboard/UIGuide_getLeaderBoard.md +15 -14
  38. package/package.json +1 -1
  39. package/src/Avatars/AvatarCustomizeErrorCode.ts +7 -5
  40. package/src/Avatars/AvatarCustomizeResponse.ts +17 -0
  41. package/src/Avatars/index.ts +1 -0
  42. package/src/Clans/JoinClanErrorCode.ts +20 -14
  43. package/src/Missions/UserAchievement.ts +2 -0
  44. package/src/Missions/UserAchievementTask.ts +4 -0
  45. package/src/SmarticoAPI.ts +53 -0
  46. package/src/Tournaments/TournamentRegistrationError.ts +32 -4
  47. package/src/WSAPI/WSAPI.ts +3 -1
  48. package/src/WSAPI/WSAPIAvatars.ts +121 -0
  49. package/src/WSAPI/WSAPIClans.ts +3 -5
  50. package/src/WSAPI/WSAPILeaderBoard.ts +7 -12
  51. package/src/WSAPI/WSAPIMissions.ts +12 -0
  52. package/src/WSAPI/WSAPITypes.ts +6 -2
  53. package/src/WSAPI/WSAPIUser.ts +27 -16
  54. 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
 
@@ -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
 
@@ -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**: the SDK caches the response for 30 seconds. There is
375
- * no push event that refreshes this cache; a server-side level change
376
- * (visible immediately on {@link getUserProfile}'s `ach_level_current_id`
377
- * via the user-properties update channel) becomes visible on this
378
- * method only after the cache TTL expires, or after
379
- * `_smartico.api.clearCaches()` is called.
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 job that
447
- * runs roughly every 60 seconds against the operator's BigQuery
448
- * dataset; level transitions driven by counter changes have a
449
- * latency of up to several minutes after the underlying activity
450
- * (e.g. a deposit). The SDK caches the response for 30 seconds; no
451
- * push event refreshes this cache. After a level change visible on
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"],