@smartico/public-api 0.0.402 → 0.0.404

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 (153) 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/NodeCache.d.ts +1 -0
  6. package/dist/OCache.d.ts +7 -0
  7. package/dist/SmarticoGlobal.d.ts +0 -6
  8. package/dist/WSAPI/WSAPITypes.d.ts +43 -0
  9. package/dist/WSAPI/WSAPIUser.d.ts +3 -0
  10. package/dist/index.js +92 -33
  11. package/dist/index.js.map +1 -1
  12. package/dist/index.modern.mjs +60 -10
  13. package/dist/index.modern.mjs.map +1 -1
  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/NodeCache.ts +8 -0
  147. package/src/OCache.ts +17 -0
  148. package/src/SmarticoGlobal.ts +0 -7
  149. package/src/WSAPI/WSAPI.ts +3 -3
  150. package/src/WSAPI/WSAPIJackpots.ts +4 -1
  151. package/src/WSAPI/WSAPIMiniGames.ts +1 -1
  152. package/src/WSAPI/WSAPITypes.ts +44 -0
  153. package/src/WSAPI/WSAPIUser.ts +30 -5
@@ -0,0 +1,253 @@
1
+ # getMissions — API (TMissionOrBadge)
2
+
3
+ > Returns all missions visible to the current user, scoped server-side to what the user is qualified to see.
4
+ > Import: `import { TMissionOrBadge } from '@smartico/public-api'`
5
+ > Search terms: getMissions, missions, getUserMissions, achievements, TMissionOrBadge, TMissionOrBadgeTask, AchRelatedGame, TRibbon, AchievementAvailabilityStatus, AchievementClaimPeriodTypeId, BadgesTimeLimitStates, onUpdate, subscription, id, name, image, is_completed, is_locked, is_requires_optin, is_opted_in, time_limit_ms
6
+
7
+ ## Signature
8
+ ```ts
9
+ _smartico.api.getMissions({ onUpdate }: { onUpdate?: (data: TMissionOrBadge[]) => void } = {}): Promise<TMissionOrBadge[]>
10
+ ```
11
+
12
+ ## Parameters
13
+ - `params` — Optional. Omit to fetch without subscribing.
14
+ - `params.onUpdate` — Callback invoked with the full refreshed mission array on every server-pushed update (after opt-in / claim-reward calls, or when the server pushes an asynchronous mission-state change). Each call to `getMissions` overwrites the prior callback. Never fires in visitor mode.
15
+
16
+ ## Returns — `Promise<TMissionOrBadge[]>`
17
+ Array of `TMissionOrBadge`. Each item:
18
+ - `id` (number) — ID of the mission or badge
19
+ - `type` ('mission' | 'badge') — Type of entity. Can be 'mission' or 'badge'
20
+ - `name` (string) — Name of the mission or badge, translated to the user language
21
+ - `sub_header` (string) — Sub-header of the mission, translated to the user language
22
+ - `description` (string) — Description of the mission or badge, translated to the user language
23
+ - `reward` (string) — Description of the mission reward if defined
24
+ - `image` (string) — URL of the image of the mission or badge, 256x256px
25
+ - `is_completed` (boolean) — Indicator if the mission is completed or badge is granted
26
+ - `is_locked` (boolean) — Indicator if the mission is locked. Means that it's visible to the user, but he cannot progress in it until it's unlocked. Mission may optionally contain the explanation of what should be done to unlock it in the unlock_mission_description property
27
+ - `unlock_mission_description` (string) — Optional explaination of what should be done to unlock the mission
28
+ - `is_requires_optin` (boolean) — Indicator if the mission requires opt-in. Means that user should explicitly opt-in to the mission in order to start progressing in it
29
+ - `is_opted_in` (boolean) — Indicator if the user opted-in to the mission
30
+ - `time_limit_ms` (number) — The amount of time in milliseconds that user has to complete the mission
31
+ - `active_from_ts` (number) — Holds time from which mission will become available, for the missions that are targeted to be available from specific date/time
32
+ - `active_till_ts` (number) — Holds time till mission will become unavailable, for the missions that are targeted to be available from specific date/time
33
+ - `dt_start` (number) — The date when the mission was started, relevant for the time limited missions, also indicating opt-it date for mission that requires opt-in and unlock date for Locked mission.
34
+ - `progress` (number) — The progress of the mission in percents calculated as the aggregated relative percentage of all tasks
35
+ - `cta_action` (string) — The action that should be performed when user clicks on the mission or badge Can be URL or deep link, e.g. 'dp:deposit'. The most safe to execute CTA is to pass it to _smartico.dp(cta_action); The 'dp' function will handle the CTA and will execute it in the most safe way
36
+ - `cta_text` (string) — The text of the CTA button, e.g. 'Make a deposit'
37
+ - `custom_section_id` (number) — The ID of the custom section where the mission or badge is assigned. Resolve to section metadata via `_smartico.api.getCustomSections()`.
38
+ - `only_in_custom_section` (boolean) — The indicator if the mission or badge is visible only in the custom section and should be hidden from the main overview of missions/badges
39
+ - `custom_data` (any) — The custom data of the mission or badge defined by operator. Can be a JSON object, string or number
40
+ - `tasks` (TMissionOrBadgeTask[]) — The list of tasks of the mission or badge
41
+ - `id` (number) — ID of the task
42
+ - `name` (string) — Name of the task, translated to the user language
43
+ - `is_completed` (boolean) — Indicator if the task is completed
44
+ - `progress` (number) — The progress of the task in percents
45
+ - `points_reward` (number) — Reward for completing the task in points
46
+ - `gems_reward` (number) — Reward for completing the task in gems
47
+ - `diamonds_reward` (number) — Reward for completing the task in diamonds
48
+ - `execution_count_expected` (number) — 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
49
+ - `execution_count_actual` (number) — 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
50
+ - `related_games` (AchRelatedGame[]) — List of casino games (or other types of entities) related to the mission or badge
51
+ - `ext_game_id` (string) — The ID of the related game
52
+ - `game_public_meta` ({
53
+ /** The name of the game */
54
+ name: string;
55
+ /** The URL to the game */
56
+ link: string;
57
+ /** The URL to the image of the game, 1:1 aspect ratio */
58
+ image: string;
59
+ /** The indicator if the game is enabled */
60
+ enabled: boolean;
61
+ /** The list of categories of the game */
62
+ game_categories: string[];
63
+ /** The name of the game provider */
64
+ game_provider: string;
65
+ /** The URL to the mobile game */
66
+ mobile_spec_link: string;
67
+ /** The priority of the game */
68
+ priority?: number;
69
+ }) — Game public meta information
70
+ - `category_ids` (number[]) — The list of IDs of the categories where the badge item is assigned, information about categories can be retrieved with getAchCategories method
71
+ - `hint_text` (string) — The T&C text for the missions
72
+ - `position` (number) — Priority (or position) of the mission in the UI. Low value indicates higher position in the UI
73
+ - `ribbon` (TRibbon) — The ribbon of the mission/badge item. Can be 'sale', 'hot', 'new', 'vip' or URL to the image in case of custom ribbon, 250x300px
74
+ - `ach_completed_id` (number) — Stable identifier of this specific mission completion. Undefined for badges and for missions that have not yet completed.
75
+ - `requires_prize_claim` (boolean) — Flag from achievement if the mission prize will be given only after user claims it
76
+ - `prize_claimed_date_ts` (number) — The date/timestamp indicating when the prize was claimed by the user
77
+ - `complete_date` (string) — Date-time the mission/badge was completed, as a `"dd/MM/yyyy HH:mm:ss"` string (server local — NOT ISO-8601, so `new Date(complete_date)` will not parse it). Prefer the epoch-ms `complete_date_ts` for date math.
78
+ - `complete_date_ts` (number) — Time of mission/badge being completed, this property shows the epoch time in UTC
79
+ - `completed_today` (boolean) — Flag for mission/badge indicating that mission/badge completed today
80
+ - `completed_this_week` (boolean) — Flag for mission/badge indicating that mission/badge completed this week
81
+ - `completed_this_month` (boolean) — Flag for mission/badge indicating that mission/badge completed this month
82
+ - `custom_section_type_id` (number) — ID of specific Custom Section type
83
+ - `max_completion_count` (number) — Max number of times the user can complete a mission in case if mission type is Recurring upon completion. NULL equals infinite.
84
+ - `completion_count` (number) — Current completion count for Recurring upon completion missions
85
+ - `next_recurrence_date_ts` (number) — The date/timestamp for recurring missions, which indicating the time remaining until the next recurrence of the mission. Note that if a mission has an "Active till" date defined, this field is not relevant after that date.
86
+ - `availability_status` (AchievementAvailabilityStatus) — Availability status of the mission depends on the defined time limits
87
+ - `claim_button_title` (string) — Title for the claim reward button
88
+ - `claim_button_action` (string) — Action for the claim reward button
89
+ - `prize_claim_expiration_date` (number) — The date/timestamp indicating when the mission claim will expire
90
+ - `prize_claim_period_type_id` (AchievementClaimPeriodTypeId) — The type of the prize claim period (Relative or Exact time and date)
91
+ - `badgeTimeLimitState` (BadgesTimeLimitStates) — Badge time limit state for badges with time restrictions
92
+ - `hide_locked_mission` (boolean) — Flag from achievement if the mission should be hidden when it is locked, until it's unlocked
93
+
94
+ ## Behavioral contract
95
+ **Subscription model (`onUpdate`)**
96
+ The callback receives the FULL refreshed mission array (never a
97
+ diff/patch). Each subsequent call to `getMissions({ onUpdate })`
98
+ REPLACES the prior callback — only one active subscriber at a time.
99
+ Pass `onUpdate: undefined` (or omit it) to keep the prior callback in
100
+ place; the callback is never auto-cleared.
101
+
102
+ **Update triggers** — the callback fires when:
103
+ 1. **Mutation responses**: `requestMissionOptIn(...)` or
104
+ `requestMissionClaimReward(...)` resolves (any `err_code`).
105
+ 2. **Asynchronous server pushes**: a user activity (deposit, bet,
106
+ login, etc.) advances task progress on a task configured to push
107
+ updates, or completes a mission.
108
+ 3. **Visibility changes**: the user's level changes, or other
109
+ gamification visibility tags change.
110
+
111
+ Operator-side BO mission-config edits do NOT push to connected
112
+ clients — those changes surface only on the next cache miss (after
113
+ the 30 s TTL) or alongside the next trigger from (1)–(3).
114
+
115
+ **What's in the returned list / what's filtered server-side**
116
+ The response is pre-filtered by the server. Missions EXCLUDED before
117
+ reaching the SDK:
118
+ - Missions in `DRAFT` or `ARCHIVED` status (see `AchievementStatus`).
119
+ - Missions where the user fails visibility conditions. Exception:
120
+ completed missions may remain visible after the user no longer
121
+ qualifies (configurable per-brand).
122
+ - `FEATURED_MANUALLY` missions that are still locked — they appear
123
+ only after the user unlocks them.
124
+ - Locked missions configured to hide while locked — UNLESS the
125
+ mission is configured to expose immediately on unlock (then the
126
+ locked mission is included as a teaser).
127
+ - `RECURRING` missions between cycles, until the next cycle starts.
128
+ - `RECURRING_QUANTITY` missions outside their `active_from_ts` /
129
+ `active_till_ts` window.
130
+
131
+ Client-side filtering you may still want: missions with
132
+ `only_in_custom_section: true` are intended for their custom-section
133
+ view only and should be hidden from the main mission list.
134
+
135
+ **Reading state from the returned mission**
136
+ Drive availability chips ("missed", "coming soon", "needs opt-in",
137
+ "in progress", "expired") from `availability_status` (enum
138
+ `AchievementAvailabilityStatus`) — it's the canonical derived
139
+ state and reflects all server-side timing/visibility rules in one
140
+ field. For time-limited and recurring missions, `dt_start` doubles
141
+ as the opt-in timestamp (for opt-in missions) or unlock timestamp
142
+ (for previously-locked missions); the expiration of a time-limited
143
+ mission is `dt_start + time_limit_ms`. `next_recurrence_date_ts`
144
+ is populated for `RECURRING` / `RECURRING_QUANTITY` missions but
145
+ is no longer meaningful once the mission's `active_till_ts` has
146
+ passed.
147
+
148
+ **Refresh after a mutation**
149
+ After `requestMissionOptIn(...)` or `requestMissionClaimReward(...)`
150
+ resolves, the SDK auto-refreshes the mission cache; the `onUpdate`
151
+ callback fires with the new array shortly after. `is_opted_in`,
152
+ `progress`, and `is_completed` flip on the refreshed mission — do
153
+ NOT mutate them optimistically while the round-trip is pending.
154
+ Render any pending state from your own loading flag.
155
+
156
+ **UI guidance**: see [UI Guide — `getMissions`](../../docs/ui/missions/UIGuide_getMissions.md).
157
+
158
+ ## Example
159
+ ```ts
160
+ // 1. Initial fetch + subscribe to live updates
161
+ const missions = await window._smartico.api.getMissions({
162
+ onUpdate: (refreshed) => {
163
+ console.log('[smartico] mission list refreshed — re-render the entire mission list UI from this array, do not merge with prior state:', refreshed);
164
+
165
+ // 2. onUpdate fires for: opt-in/claim responses, task-progress
166
+ // pushes that complete a mission or move a "pushToClient" task,
167
+ // and user-level changes. Treat each call as authoritative.
168
+ const claimable = refreshed.filter(m =>
169
+ m.is_completed && m.requires_prize_claim && !m.prize_claimed_date_ts,
170
+ );
171
+ if (claimable.length > 0) {
172
+ console.log('[smartico] there are unclaimed mission prizes — surface a "Claim" CTA on each of these missions:', claimable.map(m => m.id));
173
+ }
174
+ },
175
+ });
176
+
177
+ // 3. Filter/render from the returned list. The server already excludes
178
+ // DRAFT/ARCHIVED missions and ones the user can't see. You may need
179
+ // client-side filters for view-specific concerns (custom sections,
180
+ // completed/missed tabs).
181
+ const generalView = missions
182
+ .filter(m => !m.only_in_custom_section)
183
+ .sort((a, b) => (a.position ?? 0) - (b.position ?? 0));
184
+
185
+ console.log('[smartico] initial mission list ready — render', generalView.length, 'missions sorted by position');
186
+
187
+ // 4. Visitor-mode equivalent: onUpdate is accepted but never fires.
188
+ // Re-poll if you need fresh data.
189
+ // const visitorMissions = await window._smartico.vapi('EN').getMissions();
190
+ // console.log('[smartico] visitor missions are the brand proxy user\'s — per-user fields are not meaningful');
191
+ ```
192
+
193
+ ### Example response (REAL shape)
194
+ > Where this real payload differs from the typed Returns above (TS interface vs raw wire), the REAL shape is the runtime truth.
195
+ ```json
196
+ [
197
+ {
198
+ "id": 4015,
199
+ "name": "Looking good!",
200
+ "image": "https://cdn.example/be339e036eea69ecef4246-Mission4.png",
201
+ "is_completed": true,
202
+ "is_locked": false,
203
+ "is_requires_optin": false,
204
+ "is_opted_in": true,
205
+ "time_limit_ms": null,
206
+ "active_from_ts": null,
207
+ "active_till_ts": null,
208
+ "dt_start": 1780586690767,
209
+ "reward": "10 pt",
210
+ "progress": 100,
211
+ "type": "mission",
212
+ "cta_action": "dp:gf_change_avatar",
213
+ "cta_text": "Pick an avatar",
214
+ "only_in_custom_section": false,
215
+ "custom_data": {},
216
+ "position": 1,
217
+ "tasks": [
218
+ {
219
+ "id": 9107,
220
+ "name": "Change your avatar",
221
+ "points_reward": 10,
222
+ "gems_reward": null,
223
+ "diamonds_reward": null,
224
+ "is_completed": true,
225
+ "progress": 100,
226
+ "execution_count_expected": 1,
227
+ "execution_count_actual": 1
228
+ }
229
+ ],
230
+ "related_games": [],
231
+ "category_ids": [],
232
+ "ach_completed_id": 3407657653,
233
+ "requires_prize_claim": false,
234
+ "prize_claimed_date_ts": null,
235
+ "complete_date": "08/06/2026 14:52:48",
236
+ "complete_date_ts": 1780930368099,
237
+ "completed_today": false,
238
+ "completed_this_week": false,
239
+ "completed_this_month": true,
240
+ "availability_status": 2,
241
+ "hide_locked_mission": true,
242
+ "prize_claim_expiration_date": null,
243
+ "prize_claim_period_type_id": null
244
+ }
245
+ ]
246
+ ```
247
+
248
+ ## Errors
249
+ See this method's TSDoc / the mutation pages for `err_code` handling.
250
+
251
+ ## Related
252
+ - `AchievementStatus`
253
+ - `AchievementAvailabilityStatus`
@@ -0,0 +1,210 @@
1
+ # getRaffleDrawRun — API (TRaffleDraw)
2
+
3
+ > Returns the full detail of a single raffle draw run — same shape as the embedded `TRaffleDraw` in `getRaffles`, but populated with paginated `prizes[].winners[]` rows including usernames and avatars.
4
+ > Import: `import { TRaffleDraw } from '@smartico/public-api'`
5
+ > Search terms: getRaffleDrawRun, raffles, TRaffleDraw, TRafflePrize, TRafflePrizeWinner, RaffleDrawInstanceState, RaffleDrawTypeExecution, TRaffleTicket, id, name, description, image_url, image_url_mobile, icon_url, background_image_url, background_image_url_mobile
6
+
7
+ ## Signature
8
+ ```ts
9
+ _smartico.api.getRaffleDrawRun(props: { raffle_id: number; run_id: number; winners_from?: number; winners_to?: number }): Promise<TRaffleDraw>
10
+ ```
11
+
12
+ ## Parameters
13
+ - `props.raffle_id` — The parent raffle's `id` (from `TRaffle.id`).
14
+ - `props.run_id` — The draw run instance ID (from `TRaffleDraw.run_id`, not `TRaffleDraw.id`).
15
+ - `props.winners_from` — First winner index to return (0-based). Defaults to `0`.
16
+ - `props.winners_to` — Last winner index (exclusive). Defaults to `20`. Server caps the window at 50 rows per call.
17
+
18
+ ## Returns — `Promise<TRaffleDraw>`
19
+ `TRaffleDraw`:
20
+ - `id` (number) — Id of the Draw definition, for the repetative draws (e.g. daily), this number will be the same for all draws that are repeating daily (internal name: schedule_id)
21
+ - `name` (string) — Name of the draw, e.g. 'Daily draw'
22
+ - `description` (string) — Description of the draw
23
+ - `image_url` (string) — URL of the image that represents the draw, 365x175px
24
+ - `image_url_mobile` (string) — URL of the moible image that represents the draw, 300x145px
25
+ - `icon_url` (string) — URL of the icon that represents the draw
26
+ - `background_image_url` (string) — URL of the background image that will be used in the draw list item
27
+ - `background_image_url_mobile` (string) — URL of the moible background image that will be used in the draw list item
28
+ - `is_grand` (boolean) — Show if the draw is grand and is marked as special
29
+ - `prizes` (TRafflePrize[]) — Information about prizes in the draw
30
+ - `id` (string) — The unique identifier for the prize definition
31
+ - `name` (string) — Name of the prize
32
+ - `description` (string) — Description of the prize
33
+ - `image_url` (string) — URL of the image that represents the prize, 256x256px
34
+ - `custom_data` (string) — Custom data field set in the backoffice prize setup. Can be used to build custom UI for gamification.
35
+ - `prizes_per_run` (number) — The number of prizes available per run of the draw. E.g. if the draw is run daily, this is the number of prizes available each day, for example 3 iPhones.
36
+ - `prizes_per_run_actual` (number) — The actual number of prizes for the current instance. This value is taking into account follwing values: - min_required_total_tickets, - add_one_prize_per_each_x_tickets - stock_items_per_draw - total_tickets_count (from Draw instance) - cap_prizes_per_run For example: - prizes_per_run = 1 - min_required_total_tickets = 1000 - add_one_prize_per_each_x_tickets = 1000 - stock_items_per_draw = 5 - total_tickets_count = 7000 - cap_prizes_per_run = 6 prizes_per_run_actual will be 5, because 7000 tickets are collected, so 7 iPhones are available, but the cap is 6 and the stock is 5.
37
+ - `chances_to_win_perc` (number) — The chances to win the prize by current player. Calculated as the ratio of the number of tickets collected by the current player to the total number of tickets collected by all players and multiplied by number of actual prizes of this kind.
38
+ - `min_required_total_tickets` (number) — The minimum number of total tickets collected during draw period required to unlock the prize. If the number of tickets collected is less than this value, the prize is not available. Under total tickets we understand the number of tickets collected by all users. The 'draw period' is the time between the ticket_start_date value of the draw and the current time.
39
+ - `add_one_prize_per_each_x_tickets` (number) — One additional prize will be awarded for each X tickets. E.g. if the prize is 1 iPhone and the value is set to 1000, then for every 1000 tickets collected, an additional iPhone is awarded. If min_required_total_tickets is set to 1000, then next iPhone is awarded when 2000 tickets are collected, and so on. If min_required_total_tickets is not set, then the next iPhone will be awarded when 1000 tickets are collected.
40
+ - `requires_claim` (boolean) — Indicates whether the prize requires a claim action from the user.
41
+ - `min_required_tickets_for_user` (number) — The minimum number of tickets a user must have to be eligible for the prize. For example iPhone prize may require 10 tickets to be collected, only users with 10 or more tickets will be eligible for the prize. More tickets are better, as they increase the chances of winning.
42
+ - `cap_prizes_per_run` (number) — The maximum number of prizes that can be given withing one instance/run of draw. For example the prize is iPhone and add_one_prize_per_each_x_tickets is set to 1000, cap_prizes_per_run is set to 3, and the total number of tickets collected is 7000. In this case, the prizes_per_run_actual will be limitted by 3
43
+ - `priority` (number) — The priority of the prize. The low number means higher priority (e.g. 1 is higher priority than 2). If there are multiple prizes available, the prize with the highest priority (lowest number) will be awarded first.
44
+ - `stock_items_per_draw` (number) — Optional field that indicates total remaining number of the prize for all draws of the type. For example, the Daily draw has 1 iPhone daily, and the total number of iPhones is 10. the stock_items_per_draw will be decreasing by 1 each day (assuming there is enough tickets and it is won every day), and when it reaches 0, the prize is not available anymore.
45
+ - `should_claim` (boolean) — Shows if the prize has been claimed
46
+ - `winners` (TRafflePrizeWinner[])
47
+ - `id` (number) — Id of the winner definition, for the repetative winners (e.g. same winner won two prizes), this number will be the same for all winner that are repeating (internal name: schedule_id)
48
+ - `username` (string) — Winner user name
49
+ - `avatar_url` (string) — URL of the image of user avatar
50
+ - `ticket` (TRaffleTicket) — Ticket information (number string and integer)
51
+ - `ticekt_id` (number) — Int presentation of the ticket
52
+ - `ticket_id_string` (string) — String presentation of the ticket
53
+ - `raf_won_id` (number) — Unique ID of winning
54
+ - `claimed_date` (number) — Date when the prize was claimed
55
+ - `current_state` (RaffleDrawInstanceState) — State of current instance of Draw
56
+ - `run_id` (number) — Field indicates the ID of the latest instance/run of draw
57
+ - `execution_type` (RaffleDrawTypeExecution) — Type of the draw execution, indicating how and when the draw is executed. - ExecDate: Draw is executed only once at a specific date and time. - Recurring: Draw is executed on a recurring basis (e.g., daily, weekly). - Grand: Draw is executed once and is marked as grand, often with larger prizes or more importance.
58
+ - `execution_ts` (number) — Date/time of the draw execution
59
+ - `previous_run_ts` (number) — Date of the previously executed draw (if there is such)
60
+ - `previous_run_id` (number) — Unique ID of the previusly executed draw (if there is such)
61
+ - `ticket_start_ts` (number) — Date/time starting from which the tickets will participate in the upcoming draw This value need to be taken into account with next_execute_ts field value, for example Next draw is at 10:00, ticket_start_date is 9:00, so all tickets that are collected after 9:00 will participate in the draw at 10:00 (internally this value is calculated as next_execute_ts - ticket_start_date)
62
+ - `allow_multi_prize_per_ticket` (boolean) — Field is indicating if same ticket can win multiple prizes in the same draw For example there are 3 types of prizes in the draw - iPhone, iPad, MacBook If this field is true, then one ticket can win all 3 prizes (depending on the chances of course), if false, then one ticket can win only one prize. The distribution of the prizes is start from top (assuming on top are the most valuable prizes) to bottom (less valuable prizes) If specific prize has multiple values, e.g. we have 3 iPhones, then the same ticket can win only one prize of a kind, but can win multiple prizes of different kind (if allow_multi_prize_per_ticket is true)
63
+ - `total_tickets_count` (number) — The number of tickets that are already given to all users for this instance of draw. In other words tickets that are collected between ticket_start_date and current time (or till current_execution_ts is the instance is executed).
64
+ - `my_tickets_count` (number) — The number of tickets collected by current user for this instance of draw.
65
+ - `my_last_tickets` (TRaffleTicket[])
66
+ - `ticekt_id` (number) — Int presentation of the ticket
67
+ - `ticket_id_string` (string) — String presentation of the ticket
68
+ - `user_opted_in` (boolean) — If true, the user has opted-in to the raffle.
69
+ - `requires_optin` (boolean) — If true, the user needs to opt-in to the raffle before they can participate.
70
+ - `is_active` (boolean) — If true, the draw is active and can be participated in.
71
+ - `winners_limit` (number) — The number of winners to return
72
+ - `winners_offset` (number) — The offset of the winners to return
73
+ - `winners_total` (number) — The total number of winners
74
+
75
+ ## Behavioral contract
76
+ **Preconditions**
77
+ Pass `raffle_id` (the parent raffle's `id`) and `run_id` (the
78
+ specific run instance — `TRaffleDraw.run_id` from
79
+ `getRaffles`'s embedded draws). Note that
80
+ `TRaffleDraw.id` is the *schedule_id* (stable across runs of a
81
+ recurring draw) — that's NOT what this method takes; it takes the
82
+ per-instance `run_id`.
83
+
84
+ **Refresh model**
85
+ - **No subscription.** One-shot promise.
86
+ - **No client cache.** Every call sends a network request.
87
+ - **No push event** refreshes the response. Live winner-list
88
+ updates require a fresh call.
89
+ - The default Smartico UI polls this method on a variable cadence
90
+ while a draw is in flight: every 3 s during `WinnerSelection`,
91
+ every 10 s when the countdown is under 5 minutes, every 30 s
92
+ otherwise.
93
+
94
+ **Winner pagination**
95
+ `winners_from` / `winners_to` define a half-open range of winner
96
+ indices. The default window is `0–20` (20 winners). The server
97
+ caps the window at 50 rows per call — passing a larger range
98
+ silently truncates. For "load more" pagination, advance
99
+ `winners_from` by the prior page size and pass the same
100
+ `winners_to` offset. `winners_total` on the returned
101
+ `TRaffleDraw` is the authoritative total count for pagination.
102
+
103
+ The current user's own winning rows (if any) are server-sorted
104
+ to the top of the result.
105
+
106
+ **Throws**
107
+ Both `raffle_id` and `run_id` are required — the SDK throws
108
+ synchronously when either is missing or falsy.
109
+
110
+ **Idempotency / Side effects**: safe. Read-only.
111
+
112
+ **UI guidance**: see [UI Guide — `getRaffleDrawRun`](../../docs/ui/raffles/UIGuide_getRaffleDrawRun.md).
113
+
114
+ **Visitor mode**: supported.
115
+
116
+ ## Example
117
+ ```ts
118
+ const raffles = await window._smartico.api.getRaffles();
119
+ const raffle = raffles[0];
120
+ const draw = raffle.draws.find(d => d.current_state === 3); // Executed
121
+
122
+ if (!draw) {
123
+ console.log('[smartico] no executed draw — skip detail view');
124
+ return;
125
+ }
126
+
127
+ // First page of winners.
128
+ const detail = await window._smartico.api.getRaffleDrawRun({
129
+ raffle_id: raffle.id,
130
+ run_id: draw.run_id, // NOTE: run_id, NOT draw.id
131
+ winners_from: 0,
132
+ winners_to: 20,
133
+ });
134
+
135
+ for (const prize of detail.prizes) {
136
+ console.log('[smartico] prize', prize.name, '— winners on this page:', prize.winners.length);
137
+ const myWin = prize.winners.find(w => w.username === currentUsername); // or another match
138
+ if (myWin) {
139
+ console.log('[smartico] current user won this prize — surface a Claim CTA if not yet claimed');
140
+ }
141
+ }
142
+
143
+ // Load more — pagination via winners_from / winners_to.
144
+ if ((detail.winners_total ?? 0) > 20) {
145
+ const next = await window._smartico.api.getRaffleDrawRun({
146
+ raffle_id: raffle.id,
147
+ run_id: draw.run_id,
148
+ winners_from: 20,
149
+ winners_to: 40,
150
+ });
151
+ console.log('[smartico] page 2 loaded — append', next.prizes.flatMap(p => p.winners).length, 'winners');
152
+ }
153
+ ```
154
+
155
+ ### Example response (REAL shape)
156
+ > Where this real payload differs from the typed Returns above (TS interface vs raw wire), the REAL shape is the runtime truth.
157
+ ```json
158
+ {
159
+ "id": 322,
160
+ "name": "Daily draw",
161
+ "description": "🎟️🔥Hot Daily Raffle Alert!🔥🎟️ Spin your way to amazing prizes every single day! Don't miss out!",
162
+ "image_url": "https://cdn.example/0e61ee7d31eea85ea1e2e5-DailyDraw-Promoimage.png",
163
+ "image_url_mobile": "https://cdn.example/7da52af5814e089897b470-DailyDraw-Promoimagemobile.png",
164
+ "icon_url": "https://cdn.example/c681faad98ec20cf94c6cf-DailyDraw-Drawicon.png",
165
+ "background_image_url": "https://cdn.example/e17b7d69c350b47ae0878f-DrawBackground.png",
166
+ "background_image_url_mobile": "https://cdn.example/9ec0cc0bcf58d038ab59f9-DrawBackgroundMobilecopy.png",
167
+ "is_grand": false,
168
+ "prizes": [
169
+ {
170
+ "id": 1244,
171
+ "name": "16\" Lenovo laptop",
172
+ "image_url": "https://cdn.example/6b4690ea0429208b244f7c-DailyDraw-516inchLaptopLenovoPrizeimage.png",
173
+ "prizes_per_run": 1,
174
+ "prizes_per_run_actual": 1,
175
+ "chances_to_win_perc": 0,
176
+ "min_required_total_tickets": 100,
177
+ "cap_prizes_per_run": 3,
178
+ "priority": 1,
179
+ "stock_items_per_draw": 9991,
180
+ "should_claim": false,
181
+ "winners": [],
182
+ "requires_claim": false,
183
+ "min_required_tickets_for_user": 10
184
+ }
185
+ ],
186
+ "current_state": 1,
187
+ "run_id": 775459,
188
+ "execution_type": 2,
189
+ "execution_ts": 1782378000000,
190
+ "previous_run_ts": 1782291600000,
191
+ "previous_run_id": 771353,
192
+ "ticket_start_ts": 1782291600000,
193
+ "allow_multi_prize_per_ticket": false,
194
+ "total_tickets_count": 93,
195
+ "my_tickets_count": 0,
196
+ "my_last_tickets": [],
197
+ "user_opted_in": true,
198
+ "requires_optin": false,
199
+ "is_active": true,
200
+ "winners_limit": 20,
201
+ "winners_offset": 0,
202
+ "winners_total": 0
203
+ }
204
+ ```
205
+
206
+ ## Errors
207
+ See this method's TSDoc / the mutation pages for `err_code` handling.
208
+
209
+ ## Related
210
+ - `getRaffles`
@@ -0,0 +1,116 @@
1
+ # getRaffleDrawRunsHistory — API (TRaffleDrawRun)
2
+
3
+ > Returns the history of past-executed draw runs for a raffle — optionally scoped to a single recurring draw schedule.
4
+ > Import: `import { TRaffleDrawRun } from '@smartico/public-api'`
5
+ > Search terms: getRaffleDrawRunsHistory, raffles, TRaffleDrawRun, id, run_id, name, description, image_url, image_url_mobile, icon_url, background_image_url
6
+
7
+ ## Signature
8
+ ```ts
9
+ _smartico.api.getRaffleDrawRunsHistory(props: { raffle_id: number; draw_id?: number }): Promise<TRaffleDrawRun[]>
10
+ ```
11
+
12
+ ## Parameters
13
+ - `props.raffle_id` — The parent raffle's `id` (from `TRaffle.id`). Required.
14
+ - `props.draw_id` — Optional — the draw's schedule_id (`TRaffleDraw.id`). When set, scopes the history to that one draw's runs. When omitted, includes all draws of the raffle.
15
+
16
+ ## Returns — `Promise<TRaffleDrawRun[]>`
17
+ Array of `TRaffleDrawRun`. Each item:
18
+ - `id` (number) — Id of the Draw definition, for the repetative draws (e.g. daily), this number will be the same for all draws that are repeating daily (internal name: schedule_id)
19
+ - `run_id` (number) — Field indicates the ID of the latest instance/run of draw
20
+ - `name` (string) — Name of the draw, e.g. 'Daily draw'
21
+ - `description` (string) — Description of the draw
22
+ - `image_url` (string) — URL of the image that represents the draw
23
+ - `image_url_mobile` (string) — URL of the moible image that represents the draw
24
+ - `icon_url` (string) — URL of the icon that represents the draw
25
+ - `background_image_url` (string) — URL of the background image that will be used in the draw list item
26
+ - `background_image_url_mobile` (string) — URL of the moible background image that will be used in the draw list item
27
+ - `is_grand` (boolean) — Show if the draw is grand and is marked as special
28
+ - `execution_ts` (number) — Date/time of the draw execution
29
+ - `actual_execution_ts` (number) — Actual Date/time of the draw execution
30
+ - `ticket_start_ts` (number) — Date/time starting from which the tickets will participate in the upcoming draw This value need to be taken into account with next_execute_ts field value, for example Next draw is at 10:00, ticket_start_date is 9:00, so all tickets that are collected after 9:00 will participate in the draw at 10:00 (internally this value is calculated as next_execute_ts - ticket_start_date)
31
+ - `is_winner` (boolean) — Shows if user has won a prize in a current run
32
+ - `has_unclaimed_prize` (boolean) — Shows if user has unclaimed prize
33
+
34
+ ## Behavioral contract
35
+ **Preconditions**
36
+ `raffle_id` is required. `draw_id` is optional — when omitted,
37
+ the response includes history for ALL draws of the raffle; when
38
+ supplied, it scopes to that one draw's recurring history. The
39
+ `draw_id` to pass is `TRaffleDraw.id` (the schedule_id, stable
40
+ across runs), not `run_id`.
41
+
42
+ **Server-side filtering**
43
+ Draws configured by the operator to hide their history are
44
+ excluded from the response automatically. Cancelled runs are
45
+ also excluded.
46
+
47
+ **Sort order**
48
+ Server returns rows by scheduled `execution_ts` descending
49
+ (newest first). No client-side sort required.
50
+
51
+ **Refresh model**
52
+ - **No subscription.** One-shot promise.
53
+ - **No client cache.** Every call hits the server.
54
+ - **No push event** refreshes the response. Re-call manually to
55
+ pick up newly-executed runs or `has_unclaimed_prize` flips
56
+ after a `claimRafflePrize` call.
57
+
58
+ **Idempotency / Side effects**: safe. Read-only.
59
+
60
+ **UI guidance**: see [UI Guide — `getRaffleDrawRunsHistory`](../../docs/ui/raffles/UIGuide_getRaffleDrawRunsHistory.md).
61
+
62
+ **Visitor mode**: supported. The same shape is returned with
63
+ `is_winner` and `has_unclaimed_prize` always `false` for visitors.
64
+
65
+ ## Example
66
+ ```ts
67
+ const raffles = await window._smartico.api.getRaffles();
68
+ const raffle = raffles[0];
69
+
70
+ // History across all draws of the raffle.
71
+ const allHistory = await window._smartico.api.getRaffleDrawRunsHistory({
72
+ raffle_id: raffle.id,
73
+ });
74
+
75
+ // Highlight rows where the user has an unclaimed prize.
76
+ const unclaimed = allHistory.filter(r => r.has_unclaimed_prize);
77
+ if (unclaimed.length > 0) {
78
+ console.log('[smartico] surface a "Claim" CTA on these', unclaimed.length, 'history rows:', unclaimed.map(r => r.run_id));
79
+ }
80
+
81
+ // Scoped history of one recurring draw (use draw.id, the schedule_id).
82
+ const oneDrawHistory = await window._smartico.api.getRaffleDrawRunsHistory({
83
+ raffle_id: raffle.id,
84
+ draw_id: raffle.draws[0].id, // schedule_id (stable across recurring runs)
85
+ });
86
+ console.log('[smartico] render history rows for the daily draw — newest first:', oneDrawHistory.length, 'rows');
87
+ ```
88
+
89
+ ### Example response (REAL shape)
90
+ > Where this real payload differs from the typed Returns above (TS interface vs raw wire), the REAL shape is the runtime truth.
91
+ ```json
92
+ [
93
+ {
94
+ "id": 323,
95
+ "run_id": 688934,
96
+ "name": "Hourly draw",
97
+ "description": "💰 Every hour, the luck could be yours! 🍀 Participate in our hourly draw for a chance to WIN BIG! 💸 Don't miss out!",
98
+ "image_url": "https://cdn.example/5bcd2fd9bf96f3709d96b5-HourlyDraw-Promoimage.png",
99
+ "image_url_mobile": "https://cdn.example/5bcd2fd9bf96f3709d96b5-HourlyDraw-Promoimage.png",
100
+ "icon_url": "https://cdn.example/c20dcc73645e365a387dc2-HourlyDraw-Drawicon.png",
101
+ "background_image_url": "https://cdn.example/867db7f6791f0a45039608-DrawBackground.png",
102
+ "background_image_url_mobile": "https://cdn.example/d31a8d4708a17723d57b4b-DrawBackgroundMobilecopy.png",
103
+ "is_grand": false,
104
+ "execution_ts": 1780876800000,
105
+ "ticket_start_ts": 1780873200000,
106
+ "is_winner": false,
107
+ "has_unclaimed_prize": false
108
+ }
109
+ ]
110
+ ```
111
+
112
+ ## Errors
113
+ See this method's TSDoc / the mutation pages for `err_code` handling.
114
+
115
+ ## Related
116
+ - `claimRafflePrize`