@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.
@@ -496,6 +496,14 @@ const sawPrizeValue = p => {
496
496
  }
497
497
  return n > 0 ? n : p.prize_value;
498
498
  };
499
+ const GEMS_DIAMONDS_TYPES = ['gems', 'diamonds', 'gems-and-diamonds'];
500
+ /** Which currency a gems-and-diamonds prize gives (`_gems_diamonds_type`: 0 gems, 1 diamonds, 2 both). */
501
+ const sawGemsDiamondsType = p => {
502
+ var _GEMS_DIAMONDS_TYPES$;
503
+ if (p.prize_type_id !== SAWPrizeType.GEMS_AND_DIAMONDS) return undefined;
504
+ const d = p.prize_details_json;
505
+ return (_GEMS_DIAMONDS_TYPES$ = GEMS_DIAMONDS_TYPES[d == null ? void 0 : d._gems_diamonds_type]) != null ? _GEMS_DIAMONDS_TYPES$ : d != null && d.gems && d != null && d.diamonds ? 'gems-and-diamonds' : d != null && d.diamonds ? 'diamonds' : 'gems';
506
+ };
499
507
  const SAWTemplatesTransform = items => {
500
508
  return items.map(r => {
501
509
  var _r$saw_skin_ui_defini;
@@ -550,6 +558,7 @@ const SAWTemplatesTransform = items => {
550
558
  name: p.saw_prize_ui_definition.name,
551
559
  prize_type: MiniGamePrizeTypeNamed(p.prize_type_id),
552
560
  prize_value: sawPrizeValue(p),
561
+ gems_diamonds_type: sawGemsDiamondsType(p),
553
562
  font_size: p.saw_prize_ui_definition.font_size,
554
563
  font_size_mobile: p.saw_prize_ui_definition.font_size_mobile,
555
564
  icon: p.saw_prize_ui_definition.icon,
@@ -1246,8 +1255,8 @@ var AchievementAvailabilityStatus;
1246
1255
  AchievementAvailabilityStatus[AchievementAvailabilityStatus["AvailableInactive"] = 1] = "AvailableInactive";
1247
1256
  /** Mission without date/time restrictions or with passed active from date, opt-in is required, user is opted-in or mission is unlocked*/
1248
1257
  AchievementAvailabilityStatus[AchievementAvailabilityStatus["AvailableActive"] = 2] = "AvailableActive";
1249
- /** Mission with active from date defined, date is in future.
1250
- * Field: active_from_ts
1258
+ /** 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.
1259
+ * Field: activity_period_next_start_ts when set (the time the mission opens next), otherwise active_from_ts
1251
1260
  */
1252
1261
  AchievementAvailabilityStatus[AchievementAvailabilityStatus["UnavailableWithActiveFrom"] = 3] = "UnavailableWithActiveFrom";
1253
1262
  /** Mission with active till date defined, date is in future, and no opt-in required and mission is unlocked.
@@ -1345,6 +1354,10 @@ MissionUtils.getAvailabilityStatus = mission => {
1345
1354
  if (!mission) {
1346
1355
  return null;
1347
1356
  }
1357
+ // a mission available only on some weekdays / days of the month, currently outside them
1358
+ if (mission.activity_period_next_start_ts && _MissionUtils.getMs(mission.activity_period_next_start_ts) > Date.now()) {
1359
+ return AchievementAvailabilityStatus.UnavailableWithActiveFrom;
1360
+ }
1348
1361
  const activeFrom = mission.active_from_ts ? _MissionUtils.getMs(mission.active_from_ts) : null;
1349
1362
  const activeTill = mission.active_till_ts ? _MissionUtils.getMs(mission.active_till_ts) : null;
1350
1363
  const startDate = mission.start_date_ts ? _MissionUtils.getMs(mission.start_date_ts) : null;
@@ -1639,6 +1652,7 @@ const UserAchievementTransform = items => {
1639
1652
  time_limit_ms: r.time_limit_ms,
1640
1653
  active_from_ts: r.active_from_ts,
1641
1654
  active_till_ts: r.active_till_ts,
1655
+ activity_period_next_start_ts: r.activity_period_next_start_ts,
1642
1656
  dt_start: r.start_date_ts,
1643
1657
  reward: r.ach_public_meta.reward,
1644
1658
  progress: r.progress,
@@ -3314,6 +3328,10 @@ class WSAPIMissions extends WSAPIGeneral {
3314
3328
  * - `RECURRING` missions between cycles, until the next cycle starts.
3315
3329
  * - `RECURRING_QUANTITY` missions outside their `active_from_ts` /
3316
3330
  * `active_till_ts` window.
3331
+ * - Missions available only on some weekdays or days of the month, while
3332
+ * outside those days — unless the mission is configured to be shown
3333
+ * before it opens (then it arrives with `activity_period_next_start_ts`),
3334
+ * and always once it will not open again. Completed missions stay.
3317
3335
  *
3318
3336
  * Client-side filtering you may still want: missions with
3319
3337
  * `only_in_custom_section: true` are intended for their custom-section
@@ -3332,7 +3350,9 @@ class WSAPIMissions extends WSAPIGeneral {
3332
3350
  * missions) at least one cycle done / the cap reached — see the recurring
3333
3351
  * caveats below. Sort by `complete_date_ts` DESC.
3334
3352
  * 3. **Locked** — `is_locked === true`, OR not yet started
3335
- * (`active_from_ts > Date.now()`). Sort by `position` ASC.
3353
+ * (`active_from_ts > Date.now()`), OR outside its active days
3354
+ * (`activity_period_next_start_ts > Date.now()` — show an "opens in"
3355
+ * countdown to it, and refetch when it elapses). Sort by `position` ASC.
3336
3356
  * 4. **In-progress** — `is_opted_in === true`, OR (no opt-in required and
3337
3357
  * `progress > 0`). Sort by `position` ASC.
3338
3358
  * 5. **Available** — everything else (opt-in required but not yet joined, or
@@ -3657,8 +3677,9 @@ class WSAPIMissions extends WSAPIGeneral {
3657
3677
  * means local mission state was stale (e.g. user opted in from another
3658
3678
  * session/tab).
3659
3679
  * - `40013` — mission not opt-in-able: missing `requires_optin`, in
3660
- * DRAFT/ARCHIVED state, or outside its `active_from_ts` /
3661
- * `active_till_ts` window.
3680
+ * DRAFT/ARCHIVED state, outside its `active_from_ts` /
3681
+ * `active_till_ts` window, or outside its active weekdays / days of the
3682
+ * month (`activity_period_next_start_ts` is set).
3662
3683
  * - `40014` — mission is locked; user has unlock-tasks remaining.
3663
3684
  * Surface the mission's `unlock_mission_description` to guide them.
3664
3685
  * - other non-zero — generic server error. Surface `err_message` if any.