@smartico/public-api 0.0.425 → 0.0.427
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/Core/PublicLabelSettings.d.ts +2 -0
- package/dist/Missions/BadgesTimeLimitStates.d.ts +6 -1
- package/dist/Raffle/RaffleDraw.d.ts +10 -4
- package/dist/SmarticoAPI.d.ts +3 -1
- package/dist/SmarticoGlobal.d.ts +2 -0
- package/dist/WSAPI/WSAPILeaderBoard.d.ts +49 -1
- package/dist/WSAPI/WSAPIMissions.d.ts +5 -1
- package/dist/WSAPI/WSAPIRaffles.d.ts +6 -2
- package/dist/WSAPI/WSAPITournaments.d.ts +14 -5
- package/dist/WSAPI/WSAPITypes.d.ts +30 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +136 -16
- package/dist/index.js.map +1 -1
- package/dist/index.modern.mjs +135 -16
- package/dist/index.modern.mjs.map +1 -1
- package/docs/SmarticoObject.md +9 -4
- package/docs/ui/leaderboard/UIGuide_getLeaderBoard.md +18 -3
- package/docs/ui/missions/UIGuide_getBadges.md +6 -0
- package/docs/ui/raffles/UIGuide_getRaffles.md +18 -1
- package/docs/ui/tournaments/UIGuide_getTournamentsList.md +12 -6
- package/package.json +1 -1
- package/src/Core/PublicLabelSettings.ts +2 -0
- package/src/Missions/BadgesTimeLimitStates.ts +5 -0
- package/src/Missions/MissionsUtils.ts +2 -2
- package/src/Raffle/GetRafflesResponse.ts +2 -0
- package/src/Raffle/RaffleDraw.ts +10 -4
- package/src/SmarticoAPI.ts +44 -0
- package/src/SmarticoGlobal.ts +2 -0
- package/src/Tournaments/Tournament.ts +1 -0
- package/src/WSAPI/WSAPILeaderBoard.ts +52 -0
- package/src/WSAPI/WSAPIMissions.ts +5 -1
- package/src/WSAPI/WSAPIRaffles.ts +6 -2
- package/src/WSAPI/WSAPITournaments.ts +14 -5
- package/src/WSAPI/WSAPITypes.ts +31 -0
- package/src/index.ts +1 -1
package/dist/index.modern.mjs
CHANGED
|
@@ -886,6 +886,8 @@ var PublicLabelSettings;
|
|
|
886
886
|
PublicLabelSettings["GAMIFICATION_UI_WIDGET"] = "GAMIFICATION_UI_WIDGET";
|
|
887
887
|
PublicLabelSettings["GAMIFICATION_UI_MINI_GAME"] = "GAMIFICATION_UI_MINI_GAME";
|
|
888
888
|
PublicLabelSettings["GAMIFICATION_UI_SETTINGS"] = "GAMIFICATION_UI_SETTINGS";
|
|
889
|
+
PublicLabelSettings["GAMIFICATION_UI_SETTINGS_V2"] = "GAMIFICATION_UI_SETTINGS_V2";
|
|
890
|
+
PublicLabelSettings["GAMIFICATION_UI_SETTINGS_TEST_V2"] = "GAMIFICATION_UI_SETTINGS_TEST_V2";
|
|
889
891
|
PublicLabelSettings["GAMIFICATION_UI_MAIN_TEST"] = "GAMIFICATION_UI_MAIN_TEST";
|
|
890
892
|
PublicLabelSettings["GAMIFICATION_UI_WIDGET_TEST"] = "GAMIFICATION_UI_WIDGET_TEST";
|
|
891
893
|
PublicLabelSettings["GAMIFICATION_UI_SETTINGS_TEST"] = "GAMIFICATION_UI_SETTINGS_TEST";
|
|
@@ -1288,6 +1290,11 @@ var BadgesTimeLimitStates;
|
|
|
1288
1290
|
BadgesTimeLimitStates[BadgesTimeLimitStates["AfterEndDateNotStarted"] = 4] = "AfterEndDateNotStarted";
|
|
1289
1291
|
/** After End Date (player has some progress, but not completed) */
|
|
1290
1292
|
BadgesTimeLimitStates[BadgesTimeLimitStates["AfterEndDateWithProgress"] = 5] = "AfterEndDateWithProgress";
|
|
1293
|
+
/**
|
|
1294
|
+
* After Start Date, player has some progress, and the badge has no End Date.
|
|
1295
|
+
* The badge is still earnable — do not render it as expired.
|
|
1296
|
+
*/
|
|
1297
|
+
BadgesTimeLimitStates[BadgesTimeLimitStates["AfterStartDateWithProgress"] = 6] = "AfterStartDateWithProgress";
|
|
1291
1298
|
})(BadgesTimeLimitStates || (BadgesTimeLimitStates = {}));
|
|
1292
1299
|
|
|
1293
1300
|
var _MissionUtils;
|
|
@@ -1554,8 +1561,7 @@ MissionUtils.determineBadgeState = badge => {
|
|
|
1554
1561
|
if (progress === 0) {
|
|
1555
1562
|
return BadgesTimeLimitStates.AfterStartDateNoProgress;
|
|
1556
1563
|
}
|
|
1557
|
-
|
|
1558
|
-
// (but if needed we can add one)
|
|
1564
|
+
return BadgesTimeLimitStates.AfterStartDateWithProgress;
|
|
1559
1565
|
}
|
|
1560
1566
|
// 3. AFTER START, BEFORE END DATE
|
|
1561
1567
|
if (now < active_till_ts) {
|
|
@@ -1930,6 +1936,7 @@ const TournamentItemsTransform = items => {
|
|
|
1930
1936
|
prize_pool_short: r.publicMeta.prize_pool_short,
|
|
1931
1937
|
custom_price_text: r.publicMeta.custom_price_text,
|
|
1932
1938
|
custom_section_id: r.publicMeta.custom_section_id,
|
|
1939
|
+
only_in_custom_section: r.publicMeta.only_in_custom_section,
|
|
1933
1940
|
custom_data: IntUtils.JsonOrText(r.publicMeta.custom_data),
|
|
1934
1941
|
is_featured: r.publicMeta.featured,
|
|
1935
1942
|
ribbon: r.publicMeta.label_tag === 'custom' ? r.publicMeta.custom_label_tag : r.publicMeta.label_tag,
|
|
@@ -2287,6 +2294,7 @@ const prizeTransform = items => {
|
|
|
2287
2294
|
description: item.public_meta.description,
|
|
2288
2295
|
image_url: item.public_meta.image_url,
|
|
2289
2296
|
custom_data: item.public_meta.custom_data,
|
|
2297
|
+
hide_chance_to_win: item.public_meta.hide_chance_to_win,
|
|
2290
2298
|
prizes_per_run: item.prizes_per_run,
|
|
2291
2299
|
prizes_per_run_actual: item.prizes_per_run_actual,
|
|
2292
2300
|
chances_to_win_perc: item.chances_to_win_perc,
|
|
@@ -2345,6 +2353,7 @@ const raffleTransform = items => {
|
|
|
2345
2353
|
custom_section_id: item.public_meta.custom_section_id,
|
|
2346
2354
|
image_url: item.public_meta.image_url,
|
|
2347
2355
|
image_url_mobile: item.public_meta.image_url_mobile,
|
|
2356
|
+
hint_text: item.public_meta.hint_text,
|
|
2348
2357
|
custom_data: item.public_meta.custom_data,
|
|
2349
2358
|
start_date: item.start_date_ts,
|
|
2350
2359
|
end_date: item.end_date_ts,
|
|
@@ -2408,19 +2417,25 @@ var RaffleDrawInstanceState;
|
|
|
2408
2417
|
RaffleDrawInstanceState[RaffleDrawInstanceState["WinnerSelection"] = 2] = "WinnerSelection";
|
|
2409
2418
|
/** Draw is executed and the winners are selected */
|
|
2410
2419
|
RaffleDrawInstanceState[RaffleDrawInstanceState["Executed"] = 3] = "Executed";
|
|
2420
|
+
/**
|
|
2421
|
+
* Draw was cancelled and will never be executed.
|
|
2422
|
+
* Treat it as a terminal state: stop any polling of the draw run
|
|
2423
|
+
* and do not show the winner-selection progress UI.
|
|
2424
|
+
*/
|
|
2425
|
+
RaffleDrawInstanceState[RaffleDrawInstanceState["Cancelled"] = 4] = "Cancelled";
|
|
2411
2426
|
})(RaffleDrawInstanceState || (RaffleDrawInstanceState = {}));
|
|
2412
2427
|
var RaffleDrawTypeExecution;
|
|
2413
2428
|
(function (RaffleDrawTypeExecution) {
|
|
2414
2429
|
/** Draw is executed only once */
|
|
2415
|
-
RaffleDrawTypeExecution[RaffleDrawTypeExecution["ExecDate"] =
|
|
2430
|
+
RaffleDrawTypeExecution[RaffleDrawTypeExecution["ExecDate"] = 1] = "ExecDate";
|
|
2416
2431
|
/** Draw is executed on a recurring basis */
|
|
2417
|
-
RaffleDrawTypeExecution[RaffleDrawTypeExecution["Recurring"] =
|
|
2432
|
+
RaffleDrawTypeExecution[RaffleDrawTypeExecution["Recurring"] = 2] = "Recurring";
|
|
2418
2433
|
/**
|
|
2419
2434
|
* Draw is executed once and is marked as grand.
|
|
2420
2435
|
* This means it is a special or significant draw,
|
|
2421
2436
|
* often with larger prizes or more importance.
|
|
2422
2437
|
*/
|
|
2423
|
-
RaffleDrawTypeExecution[RaffleDrawTypeExecution["Grand"] =
|
|
2438
|
+
RaffleDrawTypeExecution[RaffleDrawTypeExecution["Grand"] = 3] = "Grand";
|
|
2424
2439
|
})(RaffleDrawTypeExecution || (RaffleDrawTypeExecution = {}));
|
|
2425
2440
|
|
|
2426
2441
|
/** @hidden */
|
|
@@ -3442,7 +3457,11 @@ class WSAPIMissions extends WSAPIGeneral {
|
|
|
3442
3457
|
* as undefined / default. Time windows are absolute calendar timestamps
|
|
3443
3458
|
* (`active_from_ts` / `active_till_ts`), not opt-in-relative durations —
|
|
3444
3459
|
* drive availability chips from the SDK-computed `badgeTimeLimitState`
|
|
3445
|
-
* (enum {@link BadgesTimeLimitStates}), not `time_limit_ms`.
|
|
3460
|
+
* (enum {@link BadgesTimeLimitStates}), not `time_limit_ms`. A badge
|
|
3461
|
+
* with no `active_till_ts` is open-ended and never reaches the
|
|
3462
|
+
* "after end date" states — it reports `AfterStartDateNoProgress`
|
|
3463
|
+
* or `AfterStartDateWithProgress` — so it must never be rendered as
|
|
3464
|
+
* expired. Locking for
|
|
3446
3465
|
* badges is purely time-based: `is_locked` is `true` only when
|
|
3447
3466
|
* `badgeTimeLimitState === BadgesTimeLimitStates.BeforeStartDate` (the
|
|
3448
3467
|
* time window hasn't started yet). The primary navigation field is
|
|
@@ -4820,6 +4839,12 @@ class WSAPITournaments extends WSAPIStore {
|
|
|
4820
4839
|
* tournaments not yet published. SDK consumers receive only items
|
|
4821
4840
|
* the user is eligible to see; no client-side gating is required.
|
|
4822
4841
|
*
|
|
4842
|
+
* Client-side filtering you may still want: tournaments with
|
|
4843
|
+
* `only_in_custom_section: true` are intended for their custom-section
|
|
4844
|
+
* view only and should be hidden from the main lobby list — including
|
|
4845
|
+
* from any per-tab counters rendered next to the tab labels, otherwise
|
|
4846
|
+
* the counts disagree with the number of cards the user can see.
|
|
4847
|
+
*
|
|
4823
4848
|
* **Reading state from the returned item**
|
|
4824
4849
|
* Drive list bucketing and CTA labels from the SDK-computed booleans
|
|
4825
4850
|
* (`is_active`, `is_can_register`, `is_cancelled`, `is_finished`,
|
|
@@ -4884,19 +4909,22 @@ class WSAPITournaments extends WSAPIStore {
|
|
|
4884
4909
|
* },
|
|
4885
4910
|
* });
|
|
4886
4911
|
*
|
|
4912
|
+
* // Main lobby list — custom-section-only tournaments belong to that section's own view.
|
|
4913
|
+
* const lobby = tournaments.filter(t => !t.only_in_custom_section);
|
|
4914
|
+
*
|
|
4887
4915
|
* // Bucket items by lifecycle state for a tabbed UI.
|
|
4888
|
-
* const live =
|
|
4889
|
-
* const upcoming =
|
|
4916
|
+
* const live = lobby.filter(t => t.is_in_progress);
|
|
4917
|
+
* const upcoming = lobby
|
|
4890
4918
|
* .filter(t => t.is_upcoming && !t.is_user_registered)
|
|
4891
4919
|
* .sort((a, b) => a.start_time - b.start_time);
|
|
4892
|
-
* const mine =
|
|
4893
|
-
* const finished =
|
|
4920
|
+
* const mine = lobby.filter(t => t.is_user_registered);
|
|
4921
|
+
* const finished = lobby.filter(t => t.is_finished);
|
|
4894
4922
|
*
|
|
4895
4923
|
* console.log('[smartico] render lobby tabs with these counts: live=', live.length,
|
|
4896
4924
|
* 'upcoming=', upcoming.length, 'mine=', mine.length, 'finished=', finished.length);
|
|
4897
4925
|
*
|
|
4898
4926
|
* // Featured tournament: pin to position 0 of the Overview/Top tabs.
|
|
4899
|
-
* const featured =
|
|
4927
|
+
* const featured = lobby.find(t => t.is_featured && !t.is_cancelled);
|
|
4900
4928
|
* if (featured) {
|
|
4901
4929
|
* console.log('[smartico] featured tournament — pin to position 0 of the Overview tab:', featured.name);
|
|
4902
4930
|
* }
|
|
@@ -6154,8 +6182,12 @@ class WSAPIRaffles extends WSAPIJackpots {
|
|
|
6154
6182
|
* sold-out message).
|
|
6155
6183
|
* - Within each draw, `current_state`
|
|
6156
6184
|
* ({@link RaffleDrawInstanceState}) buckets the draw into Open
|
|
6157
|
-
* (accepting tickets), WinnerSelection (currently drawing),
|
|
6158
|
-
* Executed (winners selected).
|
|
6185
|
+
* (accepting tickets), WinnerSelection (currently drawing),
|
|
6186
|
+
* Executed (winners selected), or Cancelled (will never run).
|
|
6187
|
+
* Treat every state other than Open and WinnerSelection as
|
|
6188
|
+
* terminal — stop polling the draw run and clear any
|
|
6189
|
+
* "drawing in progress" indicator, otherwise a cancelled draw
|
|
6190
|
+
* leaves the UI spinning forever.
|
|
6159
6191
|
* - `execution_type` ({@link RaffleDrawTypeExecution}) distinguishes
|
|
6160
6192
|
* one-shot (`ExecDate`), repeating (`Recurring`), or special
|
|
6161
6193
|
* one-shot (`Grand`) draws. Recurring draws share a stable
|
|
@@ -8739,6 +8771,56 @@ class WSAPILeaderBoard extends WSAPIGamePick {
|
|
|
8739
8771
|
async getLeaderBoards() {
|
|
8740
8772
|
return OCache.use(`${onUpdateContextKey.LeaderBoards}:list`, ECacheContext.WSAPI, () => this.api.leaderboardsGetListT(this.userExtId), CACHE_DATA_SEC);
|
|
8741
8773
|
}
|
|
8774
|
+
/**
|
|
8775
|
+
* Returns the operator's privacy configuration for leaderboard rendering.
|
|
8776
|
+
* Apply it to every leaderboard row you draw — the standings returned by
|
|
8777
|
+
* {@link getLeaderBoard} always carry `avatar_url`, `level_id` and
|
|
8778
|
+
* `points`, so honouring these flags is the consumer's responsibility.
|
|
8779
|
+
* Ignoring them surfaces data the operator asked to keep private.
|
|
8780
|
+
*
|
|
8781
|
+
* @remarks
|
|
8782
|
+
* **Flags** — each is `true` when the corresponding data must be hidden:
|
|
8783
|
+
* - `hide_avatars` — draw rows without the player avatar.
|
|
8784
|
+
* - `hide_levels` — draw rows without the player's level name.
|
|
8785
|
+
* - `hide_other_points` — hide `points` for every row except the current
|
|
8786
|
+
* user's. The current user always sees their own points.
|
|
8787
|
+
*
|
|
8788
|
+
* **Defaults on an unconfigured label** — `hide_avatars` and
|
|
8789
|
+
* `hide_levels` default to `false` (show), while `hide_other_points`
|
|
8790
|
+
* defaults to `true` (hide) unless the operator explicitly turned it off.
|
|
8791
|
+
* The asymmetry is intentional: it matches the default Smartico UI, so a
|
|
8792
|
+
* consumer rendering its own leaderboard next to the built-in one agrees
|
|
8793
|
+
* with it rather than exposing points the built-in surface hides.
|
|
8794
|
+
*
|
|
8795
|
+
* **Synchronous** — the settings arrive with the session handshake, so
|
|
8796
|
+
* this returns immediately and never issues a round-trip. Call it on
|
|
8797
|
+
* every render rather than caching the result yourself.
|
|
8798
|
+
*
|
|
8799
|
+
* **Idempotency / Side effects**: safe. Read-only.
|
|
8800
|
+
*
|
|
8801
|
+
* **Visitor mode**: supported. Returns the same label-level configuration.
|
|
8802
|
+
*
|
|
8803
|
+
* @returns The resolved leaderboard privacy flags. Never `null`.
|
|
8804
|
+
*
|
|
8805
|
+
* @example
|
|
8806
|
+
* ```ts
|
|
8807
|
+
* import { LeaderBoardPeriodType } from '@smartico/public-api';
|
|
8808
|
+
*
|
|
8809
|
+
* const settings = window._smartico.api.getLeaderBoardSettings();
|
|
8810
|
+
* const board = await window._smartico.api.getLeaderBoard(LeaderBoardPeriodType.WEEKLY);
|
|
8811
|
+
*
|
|
8812
|
+
* for (const row of board?.users ?? []) {
|
|
8813
|
+
* const showPoints = row.is_me || !settings.hide_other_points;
|
|
8814
|
+
*
|
|
8815
|
+
* console.log('[smartico] render row', row.position, row.public_username,
|
|
8816
|
+
* settings.hide_avatars ? '(no avatar)' : row.avatar_url,
|
|
8817
|
+
* showPoints ? row.points : '(points hidden)');
|
|
8818
|
+
* }
|
|
8819
|
+
* ```
|
|
8820
|
+
*/
|
|
8821
|
+
getLeaderBoardSettings() {
|
|
8822
|
+
return this.api.leaderboardsGetSettings();
|
|
8823
|
+
}
|
|
8742
8824
|
}
|
|
8743
8825
|
|
|
8744
8826
|
/** @group Inbox */
|
|
@@ -10470,6 +10552,43 @@ class SmarticoAPI {
|
|
|
10470
10552
|
async leaderboardsGetListT(user_ext_id) {
|
|
10471
10553
|
return (await this.leaderboardsGetList(user_ext_id)).map(getLeaderBoardTransform);
|
|
10472
10554
|
}
|
|
10555
|
+
leaderboardsGetSettings() {
|
|
10556
|
+
// Defaults match the default Smartico UI when the operator has not
|
|
10557
|
+
// configured the gamification UI settings: avatars and levels are
|
|
10558
|
+
// shown, other players' points are not.
|
|
10559
|
+
const settings = this.getGamificationUISettings();
|
|
10560
|
+
return {
|
|
10561
|
+
hide_avatars: (settings == null ? void 0 : settings.hide_avatars_leaderboards) === true,
|
|
10562
|
+
hide_levels: (settings == null ? void 0 : settings.leaderboard_hide_levels) === true,
|
|
10563
|
+
// Deliberately asymmetric: points stay hidden unless the operator
|
|
10564
|
+
// explicitly opted in by setting the flag to false. This mirrors the
|
|
10565
|
+
// default Smartico UI, so a consumer rendering both surfaces agrees
|
|
10566
|
+
// with it on an unconfigured label.
|
|
10567
|
+
hide_other_points: (settings == null ? void 0 : settings.leaderboard_hide_other_points) !== false
|
|
10568
|
+
};
|
|
10569
|
+
}
|
|
10570
|
+
getGamificationUISettings() {
|
|
10571
|
+
var _this$tracker$userPub;
|
|
10572
|
+
if (!this.tracker) {
|
|
10573
|
+
return null;
|
|
10574
|
+
}
|
|
10575
|
+
const parse = raw => {
|
|
10576
|
+
if (typeof raw !== 'string' || raw.length === 0) {
|
|
10577
|
+
return null;
|
|
10578
|
+
}
|
|
10579
|
+
try {
|
|
10580
|
+
const parsed = JSON.parse(raw);
|
|
10581
|
+
return parsed && Object.keys(parsed).length ? parsed : null;
|
|
10582
|
+
} catch (e) {
|
|
10583
|
+
return null;
|
|
10584
|
+
}
|
|
10585
|
+
};
|
|
10586
|
+
// Test accounts read the operator's test variant when one is configured;
|
|
10587
|
+
// everyone else reads the live settings.
|
|
10588
|
+
const isTestAccount = ((_this$tracker$userPub = this.tracker.userPublicProps) == null ? void 0 : _this$tracker$userPub.core_is_test_account) === true;
|
|
10589
|
+
const testSettings = isTestAccount ? parse(this.tracker.getLabelSetting(PublicLabelSettings.GAMIFICATION_UI_SETTINGS_TEST_V2)) : null;
|
|
10590
|
+
return testSettings || parse(this.tracker.getLabelSetting(PublicLabelSettings.GAMIFICATION_UI_SETTINGS_V2));
|
|
10591
|
+
}
|
|
10473
10592
|
async levelsGet(user_ext_id, force_language) {
|
|
10474
10593
|
const message = this.buildMessage(user_ext_id, ClassId.GET_LEVEL_MAP_REQUEST);
|
|
10475
10594
|
return await this.send(message, ClassId.GET_LEVEL_MAP_RESPONSE, force_language);
|
|
@@ -10592,11 +10711,11 @@ class SmarticoAPI {
|
|
|
10592
10711
|
return await this.send(message, ClassId.MARK_INBOX_DELETED_RESPONSE);
|
|
10593
10712
|
}
|
|
10594
10713
|
buildGamesApiParams() {
|
|
10595
|
-
var _this$tracker$
|
|
10714
|
+
var _this$tracker$userPub2, _this$tracker$userPub3;
|
|
10596
10715
|
const params = Object.assign({}, this.baseRgApiParams, {
|
|
10597
|
-
ext_user_id: (_this$tracker$
|
|
10716
|
+
ext_user_id: (_this$tracker$userPub2 = this.tracker.userPublicProps) == null ? void 0 : _this$tracker$userPub2.user_id,
|
|
10598
10717
|
smartico_ext_user_id: this.tracker.getExtUserId(),
|
|
10599
|
-
lang: (_this$tracker$
|
|
10718
|
+
lang: (_this$tracker$userPub3 = this.tracker.userPublicProps) == null ? void 0 : _this$tracker$userPub3.core_user_language
|
|
10600
10719
|
});
|
|
10601
10720
|
return params;
|
|
10602
10721
|
}
|