@smartico/public-api 0.0.403 → 0.0.405

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 (148) hide show
  1. package/.claude/skills/api-tsdoc/SKILL.md +675 -0
  2. package/.claude/skills/api-tsdoc-final/SKILL.md +266 -0
  3. package/.claude/skills/api-tsdoc-howto/SKILL.md +143 -0
  4. package/dist/MiniGames/SAWTemplate.d.ts +4 -0
  5. package/dist/MiniGames/SAWTemplateUI.d.ts +6 -2
  6. package/dist/SmarticoGlobal.d.ts +0 -6
  7. package/dist/WSAPI/WSAPITypes.d.ts +43 -0
  8. package/dist/index.js +2 -0
  9. package/dist/index.js.map +1 -1
  10. package/dist/index.modern.mjs +2 -0
  11. package/dist/index.modern.mjs.map +1 -1
  12. package/docs/api/interfaces/SAWTemplate.md +16 -0
  13. package/docs/api/interfaces/TMiniGameTemplate.md +21 -0
  14. package/docs/api/interfaces/TUserProfile.md +136 -0
  15. package/docs/capabilities/_responses/buyStoreItem.json +4 -0
  16. package/docs/capabilities/_responses/claimBonus.json +4 -0
  17. package/docs/capabilities/_responses/gamePickGetActiveRound.json +95 -0
  18. package/docs/capabilities/_responses/gamePickGetActiveRounds.json +191 -0
  19. package/docs/capabilities/_responses/gamePickGetBoard.json +47 -0
  20. package/docs/capabilities/_responses/gamePickGetGameInfo.json +355 -0
  21. package/docs/capabilities/_responses/gamePickGetHistory.json +191 -0
  22. package/docs/capabilities/_responses/gamePickGetUserInfo.json +14 -0
  23. package/docs/capabilities/_responses/getAchCategories.json +12 -0
  24. package/docs/capabilities/_responses/getActivityLog.json +1 -0
  25. package/docs/capabilities/_responses/getAvatarPrompts.json +16 -0
  26. package/docs/capabilities/_responses/getAvatarsCustomized.json +12 -0
  27. package/docs/capabilities/_responses/getAvatarsList.json +24 -0
  28. package/docs/capabilities/_responses/getBadges.json +98 -0
  29. package/docs/capabilities/_responses/getBonuses.json +18 -0
  30. package/docs/capabilities/_responses/getClanInfo.json +39 -0
  31. package/docs/capabilities/_responses/getClans.json +35 -0
  32. package/docs/capabilities/_responses/getCurrentLevel.json +20 -0
  33. package/docs/capabilities/_responses/getCustomSections.json +25 -0
  34. package/docs/capabilities/_responses/getInboxMessageBody.json +7 -0
  35. package/docs/capabilities/_responses/getInboxMessages.json +18 -0
  36. package/docs/capabilities/_responses/getInboxUnreadCount.json +1 -0
  37. package/docs/capabilities/_responses/getJackpotEligibleGames.json +20 -0
  38. package/docs/capabilities/_responses/getJackpotWinners.json +28 -0
  39. package/docs/capabilities/_responses/getLeaderBoard.json +45 -0
  40. package/docs/capabilities/_responses/getLevels.json +40 -0
  41. package/docs/capabilities/_responses/getMiniGames.json +208 -0
  42. package/docs/capabilities/_responses/getMiniGamesHistory.json +1 -0
  43. package/docs/capabilities/_responses/getMissions.json +117 -0
  44. package/docs/capabilities/_responses/getRaffleDrawRun.json +62 -0
  45. package/docs/capabilities/_responses/getRaffleDrawRunsHistory.json +34 -0
  46. package/docs/capabilities/_responses/getRaffles.json +140 -0
  47. package/docs/capabilities/_responses/getStoreCategories.json +12 -0
  48. package/docs/capabilities/_responses/getStoreItems.json +47 -0
  49. package/docs/capabilities/_responses/getStorePurchasedItems.json +49 -0
  50. package/docs/capabilities/_responses/getTournamentInstanceInfo.json +75 -0
  51. package/docs/capabilities/_responses/getTournamentsList.json +66 -0
  52. package/docs/capabilities/_responses/getTranslations.json +25 -0
  53. package/docs/capabilities/_responses/getUserLevelExtraCounters.json +4 -0
  54. package/docs/capabilities/_responses/getUserProfile.json +34 -0
  55. package/docs/capabilities/_responses/jackpotGet.json +113 -0
  56. package/docs/capabilities/_responses/jackpotOptIn.json +9 -0
  57. package/docs/capabilities/_responses/jackpotOptOut.json +9 -0
  58. package/docs/capabilities/_responses/markAllInboxMessagesAsRead.json +4 -0
  59. package/docs/capabilities/_responses/markInboxMessageAsRead.json +4 -0
  60. package/docs/capabilities/_responses/markUnmarkInboxMessageAsFavorite.json +4 -0
  61. package/docs/capabilities/_responses/miniGameWinAcknowledgeRequest.json +10 -0
  62. package/docs/capabilities/_responses/playMiniGame.json +6 -0
  63. package/docs/capabilities/_responses/playMiniGameBatch.json +9 -0
  64. package/docs/capabilities/_responses/registerInTournament.json +4 -0
  65. package/docs/capabilities/_responses/requestMissionOptIn.json +4 -0
  66. package/docs/capabilities/_responses/setAvatar.json +4 -0
  67. package/docs/capabilities/avatarsCustomize.md +115 -0
  68. package/docs/capabilities/buyStoreItem.md +179 -0
  69. package/docs/capabilities/checkSegmentListMatch.md +69 -0
  70. package/docs/capabilities/checkSegmentMatch.md +74 -0
  71. package/docs/capabilities/claimBonus.md +125 -0
  72. package/docs/capabilities/claimRafflePrize.md +116 -0
  73. package/docs/capabilities/deleteAllInboxMessages.md +66 -0
  74. package/docs/capabilities/deleteInboxMessage.md +60 -0
  75. package/docs/capabilities/gamePickGetActiveRound.md +248 -0
  76. package/docs/capabilities/gamePickGetActiveRounds.md +259 -0
  77. package/docs/capabilities/gamePickGetBoard.md +202 -0
  78. package/docs/capabilities/gamePickGetGameInfo.md +318 -0
  79. package/docs/capabilities/gamePickGetHistory.md +244 -0
  80. package/docs/capabilities/gamePickGetRoundInfoForUser.md +189 -0
  81. package/docs/capabilities/gamePickGetUserInfo.md +91 -0
  82. package/docs/capabilities/gamePickSubmitSelection.md +222 -0
  83. package/docs/capabilities/gamePickSubmitSelectionQuiz.md +198 -0
  84. package/docs/capabilities/getAchCategories.md +119 -0
  85. package/docs/capabilities/getActivityLog.md +108 -0
  86. package/docs/capabilities/getAvatarPrompts.md +81 -0
  87. package/docs/capabilities/getAvatarsCustomized.md +96 -0
  88. package/docs/capabilities/getAvatarsList.md +101 -0
  89. package/docs/capabilities/getBadges.md +237 -0
  90. package/docs/capabilities/getBonuses.md +159 -0
  91. package/docs/capabilities/getClanInfo.md +164 -0
  92. package/docs/capabilities/getClanTournamentPlayers.md +112 -0
  93. package/docs/capabilities/getClans.md +168 -0
  94. package/docs/capabilities/getCurrentLevel.md +123 -0
  95. package/docs/capabilities/getCustomSections.md +96 -0
  96. package/docs/capabilities/getInboxMessageBody.md +87 -0
  97. package/docs/capabilities/getInboxMessages.md +146 -0
  98. package/docs/capabilities/getInboxUnreadCount.md +54 -0
  99. package/docs/capabilities/getJackpotEligibleGames.md +93 -0
  100. package/docs/capabilities/getJackpotWinners.md +113 -0
  101. package/docs/capabilities/getLeaderBoard.md +187 -0
  102. package/docs/capabilities/getLeaderBoards.md +88 -0
  103. package/docs/capabilities/getLevels.md +118 -0
  104. package/docs/capabilities/getMiniGames.md +295 -0
  105. package/docs/capabilities/getMiniGamesHistory.md +183 -0
  106. package/docs/capabilities/getMissions.md +253 -0
  107. package/docs/capabilities/getRaffleDrawRun.md +210 -0
  108. package/docs/capabilities/getRaffleDrawRunsHistory.md +116 -0
  109. package/docs/capabilities/getRaffleWonPrizes.md +153 -0
  110. package/docs/capabilities/getRaffles.md +249 -0
  111. package/docs/capabilities/getRelatedItemsForGame.md +236 -0
  112. package/docs/capabilities/getStoreCategories.md +128 -0
  113. package/docs/capabilities/getStoreItems.md +260 -0
  114. package/docs/capabilities/getStorePurchasedItems.md +280 -0
  115. package/docs/capabilities/getTournamentInstanceInfo.md +301 -0
  116. package/docs/capabilities/getTournamentsList.md +234 -0
  117. package/docs/capabilities/getTranslations.md +95 -0
  118. package/docs/capabilities/getUserLevelExtraCounters.md +92 -0
  119. package/docs/capabilities/getUserProfile.md +184 -0
  120. package/docs/capabilities/jackpotGet.md +173 -0
  121. package/docs/capabilities/jackpotOptIn.md +94 -0
  122. package/docs/capabilities/jackpotOptOut.md +92 -0
  123. package/docs/capabilities/joinClan.md +169 -0
  124. package/docs/capabilities/markAllInboxMessagesAsRead.md +72 -0
  125. package/docs/capabilities/markInboxMessageAsRead.md +69 -0
  126. package/docs/capabilities/markUnmarkInboxMessageAsFavorite.md +75 -0
  127. package/docs/capabilities/miniGameWinAcknowledgeRequest.md +98 -0
  128. package/docs/capabilities/playMiniGame.md +217 -0
  129. package/docs/capabilities/playMiniGameBatch.md +129 -0
  130. package/docs/capabilities/registerInTournament.md +187 -0
  131. package/docs/capabilities/reportClickEvent.md +74 -0
  132. package/docs/capabilities/reportImpressionEvent.md +67 -0
  133. package/docs/capabilities/requestMissionClaimReward.md +117 -0
  134. package/docs/capabilities/requestMissionOptIn.md +98 -0
  135. package/docs/capabilities/requestRaffleOptin.md +108 -0
  136. package/docs/capabilities/setAvatar.md +132 -0
  137. package/docs/capabilities/smarticoCallbacks.md +165 -0
  138. package/docs/capabilities/smarticoGlobal.md +62 -0
  139. package/package.json +3 -2
  140. package/readme-smartico-dev.md +208 -0
  141. package/scripts/capture-responses-browser.mjs +301 -0
  142. package/scripts/gen-capabilities.js +368 -0
  143. package/scripts/run-public-api.mjs +105 -0
  144. package/src/MiniGames/SAWGetTemplatesResponse.ts +2 -0
  145. package/src/MiniGames/SAWTemplate.ts +5 -0
  146. package/src/MiniGames/SAWTemplateUI.ts +6 -2
  147. package/src/SmarticoGlobal.ts +0 -7
  148. package/src/WSAPI/WSAPITypes.ts +44 -0
@@ -0,0 +1,198 @@
1
+ # gamePickSubmitSelectionQuiz — API (GamePickRound)
2
+
3
+ > Submits all quiz answers for a round in one shot.
4
+ > Import: `import { GamePickRound } from '@smartico/public-api'`
5
+ > Search terms: gamePickSubmitSelectionQuiz, gamepick, GamePickRound, GPRoundStatus, GamePickScoreType, GameRoundOrderType, GamePickRoundPublicMeta, GamePickEvent, SAWGPMarketType, GamePickEventMeta, QuizAnswersValueType, GamePickResolutionType
6
+
7
+ ## Signature
8
+ ```ts
9
+ _smartico.api.gamePickSubmitSelectionQuiz(props: GamePickRequestParams & { round: Partial<GamePickRound> }): Promise<GamesApiResponse<GamePickRound>>
10
+ ```
11
+
12
+ ## Parameters
13
+ - `props.saw_template_id` — ID of the Quiz game template.
14
+ - `props.round` — Round object with `round_id` + `events[]` carrying the user's answer selections.
15
+
16
+ ## Returns — `Promise<GamesApiResponse<GamePickRound>>`
17
+ Wrapped in `GamesApiResponse`: `errCode` (number — `0` = success), `errMessage?` (string), `data?` — the payload:
18
+
19
+ `GamePickRound`:
20
+ - `round_id` (number) — Unique round identifier
21
+ - `round_row_id` (number) — Sequential row ID used for ordering rounds
22
+ - `round_name` (string) — Localized display name of the round
23
+ - `round_description` (string) — Localized description of the round
24
+ - `final_screen_cta_button_title` (string) — Label for the CTA button on the final/results screen
25
+ - `final_screen_message` (string) — Message displayed on the final/results screen
26
+ - `final_screen_image_desktop` (string) — URL of the final screen image (desktop)
27
+ - `final_screen_image_mobile` (string) — URL of the final screen image (mobile)
28
+ - `promo_image` (string) — URL of the promotional image for the round
29
+ - `promo_text` (string) — Promotional text displayed with the round
30
+ - `open_date` (number) — Timestamp (ms) when the round opens for participation
31
+ - `last_bet_date` (number) — Timestamp (ms) of the last moment bets are accepted
32
+ - `resolution_date` (number) — Timestamp (ms) when the round is expected to be resolved
33
+ - `score_full_win` (number) — Points awarded for a fully correct prediction
34
+ - `score_part_win` (number) — Points awarded for a partially correct prediction
35
+ - `score_lost` (number) — Points awarded (or deducted) for an incorrect prediction
36
+ - `is_active_now` (boolean) — Whether the round is currently active for participation
37
+ - `is_resolved` (boolean) — Whether the round has been fully resolved and scored
38
+ - `round_status_id` (GPRoundStatus) — Current lifecycle status of the round
39
+ - `events_total` (number) — Total number of events in the round
40
+ - `events_resolved` (number) — Number of events that have been resolved
41
+ - `score_type_id` (GamePickScoreType) — Scoring method used for this round
42
+ - `order_events` (GameRoundOrderType) — How events are ordered for display
43
+ - `board_users_count` (number) — Maximum number of users shown on the leaderboard
44
+ - `hide_users_predictions` (boolean) — Whether other users' predictions are hidden until resolution
45
+ - `public_meta` (GamePickRoundPublicMeta) — Public metadata including translations and display settings from the BackOffice
46
+ - `round_name` (string) — Localized round name
47
+ - `round_description` (string) — Localized round description
48
+ - `promo_image` (string) — URL of the promotional image for the round
49
+ - `promo_text` (string) — Promotional text displayed with the round
50
+ - `hide_resolved_round` (boolean) — Whether to hide the round from the UI after it has been resolved
51
+ - `final_screen_image_desktop` (string) — URL of the final screen image for desktop
52
+ - `final_screen_image_mobile` (string) — URL of the final screen image for mobile
53
+ - `final_screen_message` (string) — Message displayed on the final/results screen
54
+ - `final_screen_cta_button_title` (string) — Label for the CTA button on the final screen
55
+ - `final_screen_cta_dp` (string) — Deep link triggered by the CTA button on the final screen
56
+ - `allow_edit_answers` (boolean) — Whether users can edit their answers after initial submission (within betting window)
57
+ - `_translations` ({
58
+ [key: string]: {
59
+ round_name: string;
60
+ round_description: string;
61
+ promo_image: string;
62
+ promo_text: string;
63
+ final_screen_image_desktop: string;
64
+ final_screen_image_mobile: string;
65
+ final_screen_message: string;
66
+ final_screen_cta_button_title: string;
67
+ };
68
+ }) — Per-language overrides for round display content
69
+ - `next_round_open_date` (number) — Timestamp (ms) when the next round opens, if available
70
+ - `show_users_preference` (boolean) — Whether to show aggregated user preference percentages for each outcome
71
+ - `events` (GamePickEvent[]) — List of events (matches/questions) in this round
72
+ - `gp_event_id` (number) — Unique identifier of the event
73
+ - `event_resolution_date` (string) — ISO 8601 date-time string when the event was resolved; null until resolved.
74
+ - `match_date` (string) — ISO 8601 date-time string of the match/event start time.
75
+ - `market_type_id` (SAWGPMarketType) — Market type defining the prediction format (e.g. two-team score, quiz question, custom)
76
+ - `event_meta` (GamePickEventMeta) — Event metadata containing team names, images, sport type, and question details
77
+ - `answers` ({
78
+ /** Answer identifier value sent on submission */
79
+ value: string;
80
+ /** Localized display text of the answer */
81
+ text: string;
82
+ /** Per-language overrides for the answer text */
83
+ _translations: {
84
+ [key: string]: {
85
+ text: string;
86
+ };
87
+ };
88
+ }[]) — List of possible answer options for the quiz question
89
+ - `question_image` (string) — URL of an image associated with the question
90
+ - `result` (QuizAnswersValueType) — Correct answer value after resolution
91
+ - `custom_question` (string) — Custom question text displayed to the user
92
+ - `event_name` (string) — Display name of the event/match
93
+ - `team1_name` (string) — Name of the first team (home)
94
+ - `team1_image` (string) — URL of the first team's logo image
95
+ - `team2_name` (string) — Name of the second team (away)
96
+ - `team2_image` (string) — URL of the second team's logo image
97
+ - `team1_result` (number) — Actual result score for team 1 after resolution
98
+ - `team2_result` (number) — Actual result score for team 2 after resolution
99
+ - `sport_type_id` (number) — Betradar sport type ID for the event
100
+ - `is_canceled` (boolean) — Whether the event has been canceled
101
+ - `auto_resolve_enabled` (boolean) — Whether auto-resolution from live data feed is enabled
102
+ - `auto_resolve_date` (string) — ISO date string for when auto-resolution is expected
103
+ - `team1_auto_result` (number) — Auto-resolved score for team 1 from live data feed
104
+ - `team2_auto_result` (number) — Auto-resolved score for team 2 from live data feed
105
+ - `auto_result` (string) — Auto-resolved answer value from live data feed (for quiz events)
106
+ - `_translations` ({
107
+ [key: string]: {
108
+ team1_name: string;
109
+ team2_name: string;
110
+ event_name: string;
111
+ custom_question: string;
112
+ };
113
+ }) — Per-language overrides for team names, event name, and custom question
114
+ - `user_placed_bet` (boolean) — Whether the current user has submitted a prediction for this event
115
+ - `team1_user_selection` (number | { from: number; to: number }) — User's predicted score for team 1 (MatchX only). Can be a number or a range object
116
+ - `team2_user_selection` (number | { from: number; to: number }) — User's predicted score for team 2 (MatchX only). Can be a number or a range object
117
+ - `user_selection` (QuizAnswersValueType) — User's selected answer (Quiz only). Value depends on market type (e.g. '1', '2', 'x', 'yes', 'no')
118
+ - `resolution_type_id` (GamePickResolutionType) — How the user's prediction was scored after resolution
119
+ - `resolution_score` (number) — Points awarded for this event based on prediction accuracy
120
+ - `is_open_for_bets` (boolean) — Whether this event is still accepting predictions
121
+ - `odds_details` ({ odd_value: { [key: string]: number } }) — Betting odds details for the event outcomes
122
+ - `question_image` (string) — URL of a question-specific image (quiz events)
123
+ - `user_score` (number) — Current user's total score in this round
124
+ - `user_placed_bet` (boolean) — Whether the current user has submitted any predictions in this round
125
+ - `has_open_for_bet_events` (boolean) — Whether there are events still open for betting
126
+ - `has_not_submitted_changes` (boolean) — Whether the user has unsaved changes to their predictions
127
+
128
+ ## Behavioral contract
129
+ **Preconditions**
130
+ - User must be authenticated. Visitor mode not supported.
131
+ - `saw_template_id` and `props.round.round_id` are mandatory — SDK throws if
132
+ either is missing.
133
+ - Each event must include `gp_event_id` and `user_selection`. Missing
134
+ events default to "no change".
135
+
136
+
137
+
138
+ **Idempotency**: identical to `gamePickSubmitSelection` — re-submit
139
+ returns `errCode: 3` and never double-charges the buy-in.
140
+
141
+ **Side effects**: identical to `gamePickSubmitSelection` — buy-in
142
+ deduction on first submit, participation recorded, score awarded on round
143
+ resolution.
144
+
145
+ **Visitor mode**: not supported.
146
+
147
+ **UI guidance**: see [UI Guide — `gamePickSubmitSelectionQuiz`](../../docs/ui/gamepick/UIGuide_gamePickSubmitSelectionQuiz.md).
148
+
149
+ ## Example
150
+ ```ts
151
+ const ar = await window._smartico.api.gamePickGetActiveRound({
152
+ saw_template_id: 1183,
153
+ round_id: 37974,
154
+ });
155
+ if (ar.errCode !== 0 || !ar.data) {
156
+ console.error('[smartico] could not fetch round to submit answers — show error');
157
+ return;
158
+ }
159
+
160
+ const round = ar.data;
161
+ round.events = round.events.map(e => ({
162
+ gp_event_id: e.gp_event_id,
163
+ user_selection: 'x',
164
+ }));
165
+
166
+ const r = await window._smartico.api.gamePickSubmitSelectionQuiz({
167
+ saw_template_id: 1183,
168
+ round,
169
+ });
170
+
171
+ if (r.errCode === 0) {
172
+ console.log('[smartico] quiz answers saved — show confirmation');
173
+ } else if (r.errCode === 3) {
174
+ console.log('[smartico] nothing changed — silent no-op');
175
+ } else {
176
+ console.error('[smartico] quiz submit failed:', r.errMessage);
177
+ }
178
+ ```
179
+
180
+ ## Errors
181
+ **Error codes** (in `errCode`)
182
+ - `0` — success.
183
+ - `3` (`NoBetsUpdatedOnSubmit`) — no changes, OR every event past
184
+ `last_bet_date`. Buy-in NOT consumed; current round returned in `data`.
185
+ - `4` — round / event not found.
186
+ - `100002` — template not found.
187
+ - `100000` — auth hash invalid.
188
+ - `100004` — generic server error.
189
+
190
+ Buy-in failures use the same `SAWSpinErrorCode` pass-through values
191
+ as `gamePickSubmitSelection` — see that method's TSDoc for the
192
+ `40001` / `40003` / `40004` / `40007` / `40009` / `40011` / `40012`
193
+ semantics.
194
+
195
+ ## Related
196
+ - `gamePickSubmitSelection`
197
+ - `SAWSpinErrorCode`
198
+ - `GamesApiResponse`
@@ -0,0 +1,119 @@
1
+ # getAchCategories — API (TAchCategory)
2
+
3
+ > Returns the list of active mission/badge categories configured for the current label.
4
+ > Import: `import { TAchCategory } from '@smartico/public-api'`
5
+ > Search terms: getAchCategories, missions, TAchCategory, id, name, order
6
+
7
+ ## Signature
8
+ ```ts
9
+ _smartico.api.getAchCategories(): Promise<TAchCategory[]>
10
+ ```
11
+
12
+ ## Parameters
13
+ _None._
14
+
15
+ ## Returns — `Promise<TAchCategory[]>`
16
+ Array of `TAchCategory`. Each item:
17
+ - `id` (number) — Stable numeric ID of the category. Used as the key when joining to `TMissionOrBadge.category_ids: number[]`.
18
+ - `name` (string) — Display name of the category, pre-translated server-side. Never null.
19
+ - `order` (number) — Relative display position (lower = appears first). Default 1 when the operator did not configure an explicit order.
20
+
21
+ ## Behavioral contract
22
+ **What categories are**
23
+ - Operator-defined groupings, configured per-label by the brand operator.
24
+ Only active categories are returned; inactive/deleted ones are filtered out.
25
+ - Each `TAchCategory` exposes `{ id, name, order }`. `name` is the display label;
26
+ `order` is the relative position (lower = appears first).
27
+ - The same array covers BOTH missions and badges — categories are not filtered by
28
+ entity type on the server.
29
+
30
+ **Localization / translation**
31
+ - `name` is **pre-translated server-side** to the authenticated user's stored language.
32
+ In visitor mode, the language passed to `_smartico.vapi(lang)` drives the
33
+ translation. Consumers never need to translate `name` themselves.
34
+ - Fallback if no translation exists for the user's language: the brand's EN value
35
+ is returned. The field is never null.
36
+
37
+ **Sort order**
38
+ The server does NOT pre-sort. Sort client-side before rendering:
39
+ `categories.sort((a, b) => a.order - b.order)`.
40
+
41
+ **How missions/badges join to categories**
42
+ Each `TMissionOrBadge` exposes `category_ids: number[]` (zero-or-more,
43
+ many-to-many). A single mission/badge can belong to multiple categories
44
+ simultaneously, or to none. To render a "category → items" view:
45
+ `missions.filter(m => m.category_ids.includes(cat.id))`.
46
+
47
+ **Uncategorized items**
48
+ Items with `category_ids: []` are NOT represented by a synthetic "Other" entry.
49
+ If your UI needs one, generate it client-side by checking
50
+ `item.category_ids.length === 0`.
51
+
52
+ **Empty categories**
53
+ A category may be returned even if zero missions/badges reference it. Filter
54
+ out empty categories on the consumer side if you don't want to render section
55
+ headers for them.
56
+
57
+ **Refresh cadence / cache**
58
+ - The SDK caches the response for 30 seconds. Subsequent calls within that
59
+ window return the cached array without a network round-trip.
60
+ - The cache is NOT invalidated by mission/badge push events — operator-driven
61
+ category changes propagate at the next 30 s cache miss.
62
+ - Cache is fully cleared on login / logout.
63
+ - In **visitor mode** additional server-side caching applies on top of the
64
+ SDK cache; worst-case staleness for an edited/added category is on the order
65
+ of a few minutes for anonymous viewers.
66
+
67
+ **Idempotency**: safe. Read-only metadata fetch. Cache de-duplicates concurrent calls.
68
+
69
+ **Side effects**: none — pure metadata read.
70
+
71
+ **UI guidance**: see [UI Guide — `getAchCategories`](../../docs/ui/missions/UIGuide_getAchCategories.md).
72
+
73
+ ## Example
74
+ ```ts
75
+ const categories = await window._smartico.api.getAchCategories();
76
+
77
+ if (categories.length === 0) {
78
+ console.log('[smartico] no categories configured — render missions/badges as a flat list without section headers');
79
+ } else {
80
+ const sorted = [...categories].sort((a, b) => a.order - b.order);
81
+ console.log('[smartico] categories loaded — render one tab/section per entry in this order:', sorted.map(c => c.name));
82
+
83
+ // Join to missions: render each category as a section
84
+ const missions = await window._smartico.api.getMissions();
85
+ for (const cat of sorted) {
86
+ const items = missions.filter(m => m.category_ids.includes(cat.id));
87
+ if (items.length === 0) {
88
+ console.log('[smartico] category has no missions — skip rendering its section header:', cat.name);
89
+ continue;
90
+ }
91
+ console.log(`[smartico] render section "${cat.name}" with ${items.length} mission(s)`);
92
+ }
93
+
94
+ // Uncategorized items: surface in a caller-provided "Other" bucket if needed
95
+ const uncategorized = missions.filter(m => m.category_ids.length === 0);
96
+ if (uncategorized.length > 0) {
97
+ console.log('[smartico] uncategorized missions exist — render a caller-provided "Other" section; server does NOT return id:-1:', uncategorized.length);
98
+ }
99
+ }
100
+
101
+ // Visitor mode — same shape, language driven by vapi(lang) argument
102
+ const visitorCats = await window._smartico.vapi('DE').getAchCategories();
103
+ console.log('[smartico] visitor-mode categories (names translated to DE):', visitorCats);
104
+ ```
105
+
106
+ ### Example response (REAL shape)
107
+ > Where this real payload differs from the typed Returns above (TS interface vs raw wire), the REAL shape is the runtime truth.
108
+ ```json
109
+ [
110
+ {
111
+ "id": 27,
112
+ "name": "Lucky Badges",
113
+ "order": 3
114
+ }
115
+ ]
116
+ ```
117
+
118
+ ## Errors
119
+ See this method's TSDoc / the mutation pages for `err_code` handling.
@@ -0,0 +1,108 @@
1
+ # getActivityLog — API (TActivityLog)
2
+
3
+ > Returns the user's unified balance-change history — every points, gems, and diamonds transaction within the requested time window, ordered newest-first.
4
+ > Import: `import { TActivityLog } from '@smartico/public-api'`
5
+ > Search terms: getActivityLog, user, TActivityLog, UserBalanceType, PointChangeSourceType, onUpdate, subscription
6
+
7
+ ## Signature
8
+ ```ts
9
+ _smartico.api.getActivityLog({
10
+ startTimeSeconds,
11
+ endTimeSeconds,
12
+ from,
13
+ to,
14
+ onUpdate,
15
+ }: {
16
+ /** Window start in epoch seconds. */
17
+ startTimeSeconds: number;
18
+ /** Window end in epoch seconds. */
19
+ endTimeSeconds: number;
20
+ /** Pagination offset (0-based). */
21
+ from: number;
22
+ /** Pagination ceiling (exclusive); server caps `to - from` at 50. */
23
+ to: number;
24
+ /** Optional push callback; payload is a fixed 10-min / 50-entry refresh on every wallet change (see Subscription model). */
25
+ onUpdate?: (data: TActivityLog[]) => void;
26
+ }): Promise<TActivityLog[]>
27
+ ```
28
+
29
+ ## Parameters
30
+ _None._
31
+
32
+ ## Returns — `Promise<TActivityLog[]>`
33
+ Array of `TActivityLog`. Each item:
34
+ - `create_date` (number) — Date when the change was created (epoch timestamp in seconds)
35
+ - `user_ext_id` (string) — External user ID
36
+ - `crm_brand_id` (number) — CRM brand ID
37
+ - `type` (UserBalanceType) — Type of balance: Points = 0, Gems = 1, Diamonds = 2
38
+ - `amount` (number) — Amount changed (positive or negative)
39
+ - `balance` (number) — Current balance after this change
40
+ - `total_ever` (number) — Total ever collected (only relevant for type points)
41
+ - `source_type_id` (PointChangeSourceType) — Source type ID indicating what triggered this change
42
+
43
+ ## Behavioral contract
44
+ **Preconditions**
45
+ - User must be authenticated. Visitor mode is not guarded at the SDK level
46
+ but is not meaningful — activity is per-user.
47
+
48
+ **Pagination — `from` / `to` are offset + ceiling, not timestamps**
49
+ The SDK derives `offset = from`, `limit = min(to - from, 50)` — the server
50
+ hard-caps a single response at 50 entries. For infinite scroll, advance
51
+ `from` by 50 between calls. Both `startTimeSeconds` and `endTimeSeconds`
52
+ are epoch seconds bounding the window the server scans.
53
+
54
+ **Subscription model (`onUpdate`)**
55
+ The callback fires when the user's `ach_points_balance`,
56
+ `ach_gems_balance`, or `ach_diamonds_balance` changes (i.e. whenever a
57
+ wallet event lands). The pushed payload is a FIXED re-fetch of the
58
+ **last 10 minutes / first 50 entries** — it does NOT honor the original
59
+ call's `startTimeSeconds` / `endTimeSeconds` / `from` / `to`. Consumers
60
+ maintaining a long historical view must re-call `getActivityLog` with
61
+ their own params after receiving an `onUpdate` notification.
62
+
63
+ **Refresh**
64
+ - The SDK caches results for 30 seconds.
65
+ - Push triggers fire only on balance changes; transactions that don't
66
+ alter a balance (theoretical zero-amount entries) won't refresh.
67
+
68
+ **Visitor mode**: not meaningful (no per-user history available).
69
+
70
+ **UI guidance**: see [UI Guide — `getActivityLog`](../../docs/ui/user/UIGuide_getActivityLog.md).
71
+
72
+ ## Example
73
+ ```ts
74
+ const now = Math.floor(Date.now() / 1000);
75
+ const start = now - 86400 * 30; // 30 days
76
+
77
+ const log = await window._smartico.api.getActivityLog({
78
+ startTimeSeconds: start,
79
+ endTimeSeconds: now,
80
+ from: 0,
81
+ to: 50,
82
+ onUpdate: (refreshed) => {
83
+ console.log('[smartico] wallet changed — refreshed payload is last 10 min / 50 entries:', refreshed.length, 'rows');
84
+ // If the consumer is showing a full 30-day view, re-call getActivityLog with the original params here.
85
+ },
86
+ });
87
+
88
+ for (const row of log) {
89
+ const sign = row.amount >= 0 ? '+' : '';
90
+ console.log('[smartico] activity row — render with', row.type === 0 ? 'points' : row.type === 1 ? 'gems' : 'diamonds', 'icon, color by sign:', sign + row.amount, 'balance after:', row.balance, 'source:', row.source_type_id);
91
+ }
92
+ ```
93
+
94
+ ### Example response (REAL shape)
95
+ > Where this real payload differs from the typed Returns above (TS interface vs raw wire), the REAL shape is the runtime truth.
96
+ ```json
97
+ [
98
+ null
99
+ ]
100
+ ```
101
+
102
+ ## Errors
103
+ See this method's TSDoc / the mutation pages for `err_code` handling.
104
+
105
+ ## Related
106
+ - `UserBalanceType`
107
+ - `PointChangeSourceType`
108
+ - `TActivityLog`
@@ -0,0 +1,81 @@
1
+ # getAvatarPrompts — API (TAvatarPrompt)
2
+
3
+ > Returns the catalog of AI style prompts available for avatar customization.
4
+ > Import: `import { TAvatarPrompt } from '@smartico/public-api'`
5
+ > Search terms: getAvatarPrompts, avatars, TAvatarPrompt, prompt_id, name, icon_url, cost_currency_type_id, cost_value
6
+
7
+ ## Signature
8
+ ```ts
9
+ _smartico.api.getAvatarPrompts(): Promise<TAvatarPrompt[]>
10
+ ```
11
+
12
+ ## Parameters
13
+ _None._
14
+
15
+ ## Returns — `Promise<TAvatarPrompt[]>`
16
+ Array of `TAvatarPrompt`. Each item:
17
+ - `prompt_id` (number) — Stable numeric identifier of the prompt.
18
+ - `name` (string) — Display name of the style, e.g. "Cartoon", "Watercolor".
19
+ - `icon_url` (string) — Absolute CDN URL of the prompt's preview icon.
20
+ - `cost_currency_type_id` (number) — Currency used to pay for the customization. `0` = points, `1` = gems, `2` = diamonds, `3` = free. A `cost_value` of `0` is also free.
21
+ - `cost_value` (number) — Cost amount in the currency named by `cost_currency_type_id`. `0` = free.
22
+
23
+ ## Behavioral contract
24
+ **Preconditions**
25
+ - User must be authenticated. Visitor mode is not supported.
26
+ - No other prerequisite calls. The customization UI typically calls this on demand
27
+ when the user opens the style picker, not on app boot.
28
+
29
+ **Cost handling**
30
+ Each prompt declares `cost_currency_type_id` (0 = points, 1 = gems, 2 = diamonds)
31
+ and `cost_value` (amount). The deduction happens server-side inside the
32
+ `avatar-customize` HTTP POST (the AI generation request, which is NOT part of this
33
+ SDK). The client should compare `cost_value` against the live balance from
34
+ `getUserProfile` to disable prompts the user cannot afford, but the server is
35
+ the source of truth and will reject under-funded requests authoritatively.
36
+
37
+ **Refresh**
38
+ - The SDK caches results for 30 seconds.
39
+ - Not invalidated by `setAvatar` (prompts are catalog metadata, independent
40
+ of the user's active avatar).
41
+ - No push subscription.
42
+
43
+ **Visitor mode**: not supported.
44
+
45
+ **UI guidance**: see [UI Guide — `getAvatarPrompts`](../../docs/ui/avatars/UIGuide_getAvatarPrompts.md).
46
+
47
+ ## Example
48
+ ```ts
49
+ const [prompts, profile] = await Promise.all([
50
+ window._smartico.api.getAvatarPrompts(),
51
+ window._smartico.api.getUserProfile(),
52
+ ]);
53
+
54
+ for (const p of prompts) {
55
+ // The consumer reads the matching balance from profile based on
56
+ // p.cost_currency_type_id (0=points, 1=gems, 2=diamonds).
57
+ console.log('[smartico] prompt', p.name, '— cost', p.cost_value, 'currency_type', p.cost_currency_type_id);
58
+ }
59
+ ```
60
+
61
+ ### Example response (REAL shape)
62
+ > Where this real payload differs from the typed Returns above (TS interface vs raw wire), the REAL shape is the runtime truth.
63
+ ```json
64
+ [
65
+ {
66
+ "prompt_id": 1,
67
+ "name": "Crown",
68
+ "icon_url": "https://cdn.example/00000000-0000-0000-0000-000000000000/entity-image-1776958855960-1.webp",
69
+ "cost_currency_type_id": 0,
70
+ "cost_value": 1
71
+ }
72
+ ]
73
+ ```
74
+
75
+ ## Errors
76
+ See this method's TSDoc / the mutation pages for `err_code` handling.
77
+
78
+ ## Related
79
+ - `getUserProfile`
80
+ - `setAvatar`
81
+ - `TAvatarPrompt`
@@ -0,0 +1,96 @@
1
+ # getAvatarsCustomized — API (TAvatarCustomized)
2
+
3
+ > Returns the user's previously generated AI-customized avatar variants.
4
+ > Import: `import { TAvatarCustomized } from '@smartico/public-api'`
5
+ > Search terms: getAvatarsCustomized, avatars, TAvatarCustomized, avatar_real_id, url, dt_created
6
+
7
+ ## Signature
8
+ ```ts
9
+ _smartico.api.getAvatarsCustomized(): Promise<TAvatarCustomized[]>
10
+ ```
11
+
12
+ ## Parameters
13
+ _None._
14
+
15
+ ## Returns — `Promise<TAvatarCustomized[]>`
16
+ Array of `TAvatarCustomized`. Each item:
17
+ - `avatar_real_id` (number) — `avatar_real_id` of the base avatar this variant was generated from.
18
+ - `url` (string) — Absolute CDN URL of the AI-generated image. Can be passed as `avatar_url` to `setAvatar()`.
19
+ - `dt_created` (number) — Unix-ms timestamp of when the variant was generated.
20
+
21
+ ## Behavioral contract
22
+ **Preconditions**
23
+ - User must be authenticated. Visitor mode is not supported.
24
+ - Has meaning only after at least one successful AI customization run (see below).
25
+ New users get an empty array.
26
+
27
+ **Where customized avatars come from**
28
+ AI customization is **not** a WebSocket method on this SDK. It is a separate HTTP
29
+ POST to the operator-configured `avatar-customize` endpoint that takes a base avatar
30
+ plus a style prompt from `getAvatarPrompts` and returns a generated CDN URL.
31
+ Once that POST resolves successfully, the new variant is persisted and surfaces in
32
+ the next `getAvatarsCustomized()` call. The variant URL can then be passed to
33
+ `setAvatar` to activate it.
34
+
35
+ **Relation to `getAvatarsList`**
36
+ AI variants do NOT appear in `getAvatarsList`. Catalog and variants are two
37
+ separate collections — combine them client-side if the UI needs a unified view per
38
+ base avatar.
39
+
40
+ **Sort order**
41
+ Server does NOT pre-sort. Caller typically sorts by `dt_created` descending to show
42
+ the newest variant first.
43
+
44
+ **Refresh**
45
+ - The SDK caches results for 30 seconds.
46
+ - `setAvatar` clears this cache on completion.
47
+ - After a successful AI customization POST, the consumer should re-call to surface
48
+ the new variant — the customization endpoint is outside the SDK so the SDK cannot
49
+ auto-invalidate.
50
+ - No push subscription.
51
+
52
+ **Visitor mode**: not supported.
53
+
54
+ **UI guidance**: see [UI Guide — `getAvatarsCustomized`](../../docs/ui/avatars/UIGuide_getAvatarsCustomized.md).
55
+
56
+ ## Example
57
+ ```ts
58
+ const variants = await window._smartico.api.getAvatarsCustomized();
59
+
60
+ // Group by the base avatar so the UI can show "this base has 3 AI variants".
61
+ const byBase = new Map<number, typeof variants>();
62
+ for (const v of variants) {
63
+ const list = byBase.get(v.avatar_real_id) ?? [];
64
+ list.push(v);
65
+ byBase.set(v.avatar_real_id, list);
66
+ }
67
+
68
+ // Newest-first within each base.
69
+ for (const list of byBase.values()) {
70
+ list.sort((a, b) => b.dt_created - a.dt_created);
71
+ }
72
+
73
+ console.log('[smartico] AI variants by base avatar — render as a carousel under each base');
74
+ ```
75
+
76
+ ### Example response (REAL shape)
77
+ > Where this real payload differs from the typed Returns above (TS interface vs raw wire), the REAL shape is the runtime truth.
78
+ ```json
79
+ [
80
+ {
81
+ "avatar_real_id": 12,
82
+ "url": "https://cdn.example/avatars/12/00000000-0000-0000-0000-000000000000.png",
83
+ "dt_created": 1782248067048
84
+ }
85
+ ]
86
+ ```
87
+
88
+ ## Errors
89
+ See this method's TSDoc / the mutation pages for `err_code` handling.
90
+
91
+ ## Related
92
+ - `TAvatarDefinition`
93
+ - `getAvatarsList`
94
+ - `getAvatarPrompts`
95
+ - `setAvatar`
96
+ - `TAvatarCustomized`