@smartico/public-api 0.0.437 → 0.0.439
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Missions/AchievementAvailabilityStatus.d.ts +2 -2
- package/dist/Missions/UserAchievement.d.ts +1 -0
- package/dist/WSAPI/WSAPIMissions.d.ts +10 -3
- package/dist/WSAPI/WSAPITypes.d.ts +4 -0
- package/dist/index.js +26 -5
- package/dist/index.js.map +1 -1
- package/dist/index.modern.mjs +26 -5
- package/dist/index.modern.mjs.map +1 -1
- package/docs/ui/missions/UIGuide_getMissions.md +7 -1
- package/package.json +1 -1
- package/src/MiniGames/SAWGetTemplatesResponse.ts +10 -0
- package/src/Missions/AchievementAvailabilityStatus.ts +2 -2
- package/src/Missions/MissionsUtils.ts +5 -0
- package/src/Missions/UserAchievement.ts +2 -0
- package/src/WSAPI/WSAPIMissions.ts +10 -3
- package/src/WSAPI/WSAPITypes.ts +5 -0
|
@@ -31,7 +31,9 @@ note below):
|
|
|
31
31
|
recurring), so only compare against it when it is set.
|
|
32
32
|
Sort: `complete_date_ts` DESC (most recent first).
|
|
33
33
|
3. **Locked** — `is_locked === true`, OR not yet available
|
|
34
|
-
(`active_from_ts > Date.now()`)
|
|
34
|
+
(`active_from_ts > Date.now()`), OR outside its active weekdays /
|
|
35
|
+
days of the month (`activity_period_next_start_ts > Date.now()`).
|
|
36
|
+
Sort: `position` ASC.
|
|
35
37
|
4. **In progress** — `is_opted_in === true`, OR (no opt-in required and
|
|
36
38
|
`progress > 0`). Sort: `position` ASC.
|
|
37
39
|
5. **Available** — everything else: opt-in required but not yet joined, or
|
|
@@ -108,6 +110,8 @@ Top-to-bottom structure (omit sections whose source field is empty):
|
|
|
108
110
|
7. Lock icon overlay on the image when `is_locked === true`.
|
|
109
111
|
8. Time-remaining block — "Available again in" countdown for
|
|
110
112
|
recurring waiting; "Starts on" for `active_from_ts > now`;
|
|
113
|
+
"Opens in" countdown to `activity_period_next_start_ts` while it is
|
|
114
|
+
in the future (refetch with `getMissions` when it elapses);
|
|
111
115
|
"Expired on" for missed; countdown for in-window.
|
|
112
116
|
9. Full `description` (HTML).
|
|
113
117
|
10. Action button — see the decision matrix below.
|
|
@@ -152,6 +156,8 @@ Apply in priority order; **first match wins**:
|
|
|
152
156
|
5. `is_requires_optin && !is_opted_in` (and not locked) →
|
|
153
157
|
**"Opt In" button**. Disable when:
|
|
154
158
|
- `active_from_ts > Date.now()` (not yet started),
|
|
159
|
+
- `activity_period_next_start_ts > Date.now()` (outside its active
|
|
160
|
+
days — the server refuses the opt-in with `40013`),
|
|
155
161
|
- the mission falls in the Missed bucket,
|
|
156
162
|
- `active_till_ts && active_till_ts < Date.now()` (expired).
|
|
157
163
|
While the opt-in request is in flight, show a loading indicator
|
package/package.json
CHANGED
|
@@ -31,6 +31,15 @@ const sawPrizeValue = (p: SAWPrize): number => {
|
|
|
31
31
|
return n > 0 ? n : p.prize_value;
|
|
32
32
|
};
|
|
33
33
|
|
|
34
|
+
const GEMS_DIAMONDS_TYPES: TMiniGamePrize['gems_diamonds_type'][] = ['gems', 'diamonds', 'gems-and-diamonds'];
|
|
35
|
+
|
|
36
|
+
/** Which currency a gems-and-diamonds prize gives (`_gems_diamonds_type`: 0 gems, 1 diamonds, 2 both). */
|
|
37
|
+
const sawGemsDiamondsType = (p: SAWPrize): TMiniGamePrize['gems_diamonds_type'] => {
|
|
38
|
+
if (p.prize_type_id !== SAWPrizeType.GEMS_AND_DIAMONDS) return undefined;
|
|
39
|
+
const d = p.prize_details_json;
|
|
40
|
+
return GEMS_DIAMONDS_TYPES[d?._gems_diamonds_type] ?? (d?.gems && d?.diamonds ? 'gems-and-diamonds' : d?.diamonds ? 'diamonds' : 'gems');
|
|
41
|
+
};
|
|
42
|
+
|
|
34
43
|
export const SAWTemplatesTransform = (items: SAWTemplate[]): TMiniGameTemplate[] => {
|
|
35
44
|
return items.map((r) => {
|
|
36
45
|
const x: TMiniGameTemplate = {
|
|
@@ -85,6 +94,7 @@ export const SAWTemplatesTransform = (items: SAWTemplate[]): TMiniGameTemplate[]
|
|
|
85
94
|
name: p.saw_prize_ui_definition.name,
|
|
86
95
|
prize_type: MiniGamePrizeTypeNamed(p.prize_type_id),
|
|
87
96
|
prize_value: sawPrizeValue(p),
|
|
97
|
+
gems_diamonds_type: sawGemsDiamondsType(p),
|
|
88
98
|
font_size: p.saw_prize_ui_definition.font_size,
|
|
89
99
|
font_size_mobile: p.saw_prize_ui_definition.font_size_mobile,
|
|
90
100
|
icon: p.saw_prize_ui_definition.icon,
|
|
@@ -14,8 +14,8 @@ export enum AchievementAvailabilityStatus {
|
|
|
14
14
|
/** Mission without date/time restrictions or with passed active from date, opt-in is required, user is opted-in or mission is unlocked*/
|
|
15
15
|
AvailableActive = 2,
|
|
16
16
|
|
|
17
|
-
/** Mission with active from date defined, date is in future.
|
|
18
|
-
* Field: active_from_ts
|
|
17
|
+
/** Mission with active from date defined, date is in future, or a mission available only on some weekdays / days of the month that is outside its active days.
|
|
18
|
+
* Field: activity_period_next_start_ts when set (the time the mission opens next), otherwise active_from_ts
|
|
19
19
|
*/
|
|
20
20
|
UnavailableWithActiveFrom = 3,
|
|
21
21
|
|
|
@@ -56,6 +56,11 @@ export class MissionUtils {
|
|
|
56
56
|
return null;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
// a mission available only on some weekdays / days of the month, currently outside them
|
|
60
|
+
if (mission.activity_period_next_start_ts && MissionUtils.getMs(mission.activity_period_next_start_ts) > Date.now()) {
|
|
61
|
+
return AchievementAvailabilityStatus.UnavailableWithActiveFrom;
|
|
62
|
+
}
|
|
63
|
+
|
|
59
64
|
const activeFrom = mission.active_from_ts ? MissionUtils.getMs(mission.active_from_ts) : null
|
|
60
65
|
const activeTill = mission.active_till_ts ? MissionUtils.getMs(mission.active_till_ts) : null;
|
|
61
66
|
const startDate = mission.start_date_ts ? MissionUtils.getMs(mission.start_date_ts) : null;
|
|
@@ -35,6 +35,7 @@ export interface UserAchievement {
|
|
|
35
35
|
related_games?: AchRelatedGame[];
|
|
36
36
|
active_from_ts?: number; // indicates when 'scheduled' mission is active from,
|
|
37
37
|
active_till_ts?: number; // indicates when 'scheduled' mission is active till,
|
|
38
|
+
activity_period_next_start_ts?: number; // when a mission limited to some weekdays / days of the month opens next; set only while it is outside its active days
|
|
38
39
|
ach_categories?: number[];
|
|
39
40
|
recurring_quantity?: number; // max completion count for Recurring upon completion
|
|
40
41
|
completed_count?: number; // completion count for Recurring upon completion
|
|
@@ -102,6 +103,7 @@ export const UserAchievementTransform = (items: UserAchievement[]): TMissionOrBa
|
|
|
102
103
|
time_limit_ms: r.time_limit_ms,
|
|
103
104
|
active_from_ts: r.active_from_ts,
|
|
104
105
|
active_till_ts: r.active_till_ts,
|
|
106
|
+
activity_period_next_start_ts: r.activity_period_next_start_ts,
|
|
105
107
|
dt_start: r.start_date_ts,
|
|
106
108
|
reward: r.ach_public_meta.reward,
|
|
107
109
|
progress: r.progress,
|
|
@@ -61,6 +61,10 @@ export class WSAPIMissions extends WSAPIGeneral {
|
|
|
61
61
|
* - `RECURRING` missions between cycles, until the next cycle starts.
|
|
62
62
|
* - `RECURRING_QUANTITY` missions outside their `active_from_ts` /
|
|
63
63
|
* `active_till_ts` window.
|
|
64
|
+
* - Missions available only on some weekdays or days of the month, while
|
|
65
|
+
* outside those days — unless the mission is configured to be shown
|
|
66
|
+
* before it opens (then it arrives with `activity_period_next_start_ts`),
|
|
67
|
+
* and always once it will not open again. Completed missions stay.
|
|
64
68
|
*
|
|
65
69
|
* Client-side filtering you may still want: missions with
|
|
66
70
|
* `only_in_custom_section: true` are intended for their custom-section
|
|
@@ -79,7 +83,9 @@ export class WSAPIMissions extends WSAPIGeneral {
|
|
|
79
83
|
* missions) at least one cycle done / the cap reached — see the recurring
|
|
80
84
|
* caveats below. Sort by `complete_date_ts` DESC.
|
|
81
85
|
* 3. **Locked** — `is_locked === true`, OR not yet started
|
|
82
|
-
* (`active_from_ts > Date.now()`)
|
|
86
|
+
* (`active_from_ts > Date.now()`), OR outside its active days
|
|
87
|
+
* (`activity_period_next_start_ts > Date.now()` — show an "opens in"
|
|
88
|
+
* countdown to it, and refetch when it elapses). Sort by `position` ASC.
|
|
83
89
|
* 4. **In-progress** — `is_opted_in === true`, OR (no opt-in required and
|
|
84
90
|
* `progress > 0`). Sort by `position` ASC.
|
|
85
91
|
* 5. **Available** — everything else (opt-in required but not yet joined, or
|
|
@@ -416,8 +422,9 @@ export class WSAPIMissions extends WSAPIGeneral {
|
|
|
416
422
|
* means local mission state was stale (e.g. user opted in from another
|
|
417
423
|
* session/tab).
|
|
418
424
|
* - `40013` — mission not opt-in-able: missing `requires_optin`, in
|
|
419
|
-
* DRAFT/ARCHIVED state,
|
|
420
|
-
* `active_till_ts` window
|
|
425
|
+
* DRAFT/ARCHIVED state, outside its `active_from_ts` /
|
|
426
|
+
* `active_till_ts` window, or outside its active weekdays / days of the
|
|
427
|
+
* month (`activity_period_next_start_ts` is set).
|
|
421
428
|
* - `40014` — mission is locked; user has unlock-tasks remaining.
|
|
422
429
|
* Surface the mission's `unlock_mission_description` to guide them.
|
|
423
430
|
* - other non-zero — generic server error. Surface `err_message` if any.
|
package/src/WSAPI/WSAPITypes.ts
CHANGED
|
@@ -33,6 +33,8 @@ export interface TMiniGamePrize {
|
|
|
33
33
|
* For example for prize '100 points' the prize_value will be 100, for '100 free spins' 100, for '50 Diamonds' 50.
|
|
34
34
|
*/
|
|
35
35
|
prize_value?: number;
|
|
36
|
+
/** For 'gems-and-diamonds' prizes — which currency the prize gives: 'gems', 'diamonds', or 'gems-and-diamonds' (both; `prize_value` is then their sum). Absent for other types */
|
|
37
|
+
gems_diamonds_type?: 'gems' | 'diamonds' | 'gems-and-diamonds';
|
|
36
38
|
/** Custom font size in px for rendering the prize name on the game surface (e.g. a wheel sector), desktop */
|
|
37
39
|
font_size?: number;
|
|
38
40
|
/** Custom font size in px for the prize name, mobile; falls back to `font_size` when absent */
|
|
@@ -885,6 +887,9 @@ export interface TMissionOrBadge {
|
|
|
885
887
|
/** Holds time till mission will become unavailable, for the missions that are targeted to be available from specific date/time */
|
|
886
888
|
active_till_ts: number;
|
|
887
889
|
|
|
890
|
+
/** Time (epoch ms) when a mission that is available only on some weekdays or days of the month opens next. Set only while the mission is outside its active days and is shown before it opens; absent when it is open now or has no such limit */
|
|
891
|
+
activity_period_next_start_ts?: number;
|
|
892
|
+
|
|
888
893
|
/** 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. */
|
|
889
894
|
dt_start: number;
|
|
890
895
|
/** The progress of the mission in percents calculated as the aggregated relative percentage of all tasks */
|