@smartico/public-api 0.0.409 → 0.0.411

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 (43) hide show
  1. package/README.md +1 -1
  2. package/dist/MiniGames/SAWDoAknowledgeRequest.d.ts +2 -0
  3. package/dist/MiniGames/SAWPrize.d.ts +18 -0
  4. package/dist/MiniGames/SAWPrizeUI.d.ts +1 -0
  5. package/dist/MiniGames/SAWTemplate.d.ts +24 -0
  6. package/dist/SmarticoAPI.d.ts +1 -1
  7. package/dist/SmarticoLib/index.d.ts +1 -1
  8. package/dist/WSAPI/WSAPIJackpots.d.ts +11 -2
  9. package/dist/WSAPI/WSAPIMiniGames.d.ts +92 -23
  10. package/dist/WSAPI/WSAPITypes.d.ts +45 -44
  11. package/dist/index.js +112 -31
  12. package/dist/index.js.map +1 -1
  13. package/dist/index.modern.mjs +109 -28
  14. package/dist/index.modern.mjs.map +1 -1
  15. package/docs/api/classes/WSAPIJackpots.md +11 -2
  16. package/docs/api/classes/WSAPIMiniGames.md +92 -23
  17. package/docs/api/interfaces/SAWDoAknowledgeRequest.md +8 -0
  18. package/docs/api/interfaces/SAWPrize.md +36 -0
  19. package/docs/api/interfaces/SAWPrizeUI.md +2 -0
  20. package/docs/api/interfaces/SAWTemplate.md +48 -0
  21. package/docs/api/interfaces/TMiniGamePrize.md +51 -27
  22. package/docs/api/interfaces/TMiniGameTemplate.md +15 -16
  23. package/docs/capabilities/getJackpotEligibleGames.md +11 -2
  24. package/docs/capabilities/getMiniGames.md +63 -39
  25. package/docs/capabilities/miniGameWinAcknowledgeRequest.md +36 -7
  26. package/docs/capabilities/playMiniGame.md +27 -14
  27. package/docs/native/PROTOCOL.md +7 -0
  28. package/docs/ui/jackpots/UIGuide_getJackpotEligibleGames.md +8 -0
  29. package/docs/ui/minigames/UIGuide_getMiniGames.md +46 -0
  30. package/docs/ui/minigames/UIGuide_getMiniGamesHistory.md +1 -1
  31. package/docs/ui/minigames/UIGuide_miniGameWinAcknowledgeRequest.md +90 -0
  32. package/docs/ui/minigames/UIGuide_playMiniGame.md +38 -2
  33. package/package.json +1 -1
  34. package/src/MiniGames/SAWDoAknowledgeRequest.ts +2 -0
  35. package/src/MiniGames/SAWGetTemplatesResponse.ts +1 -0
  36. package/src/MiniGames/SAWPrize.ts +18 -0
  37. package/src/MiniGames/SAWPrizeUI.ts +2 -1
  38. package/src/MiniGames/SAWTemplate.ts +27 -4
  39. package/src/SmarticoAPI.ts +7 -1
  40. package/src/SmarticoLib/index.ts +1 -1
  41. package/src/WSAPI/WSAPIJackpots.ts +11 -2
  42. package/src/WSAPI/WSAPIMiniGames.ts +91 -24
  43. package/src/WSAPI/WSAPITypes.ts +47 -46
package/dist/index.js CHANGED
@@ -538,6 +538,7 @@ var SAWTemplatesTransform = function SAWTemplatesTransform(items) {
538
538
  sectors: p.saw_prize_ui_definition.sectors,
539
539
  acknowledge_type: SAWAcknowledgeTypeNamed(p.saw_prize_ui_definition.acknowledge_type),
540
540
  aknowledge_message: p.saw_prize_ui_definition.aknowledge_message,
541
+ aknowledge_message_lose: p.saw_prize_ui_definition.aknowledge_message_lose,
541
542
  acknowledge_dp: p.saw_prize_ui_definition.acknowledge_dp,
542
543
  acknowledge_action_title: p.saw_prize_ui_definition.acknowledge_action_title,
543
544
  acknowledge_dp_additional: p.saw_prize_ui_definition.acknowledge_dp_additional,
@@ -6369,7 +6370,7 @@ var WSAPIJackpots = /*#__PURE__*/function (_WSAPIClans) {
6369
6370
  *
6370
6371
  * @remarks
6371
6372
  * **Preconditions**
6372
- * - User must be authenticated. Visitor mode not supported.
6373
+ * - No authentication required — works in both identified and visitor mode.
6373
6374
  * - `jp_template_id` is mandatory.
6374
6375
  *
6375
6376
  * **`onUpdate` caveat**
@@ -6387,7 +6388,12 @@ var WSAPIJackpots = /*#__PURE__*/function (_WSAPIClans) {
6387
6388
  * Non-zero `errCode` on control-group users or generic server errors.
6388
6389
  * Branch on `errCode === 0` and surface `errMsg` on failure.
6389
6390
  *
6390
- * **Visitor mode**: not supported.
6391
+ * **Visitor mode**: supported via
6392
+ * `_smartico.vapi(lang).getJackpotEligibleGames(...)`. The eligible-games
6393
+ * list is template-level (which games contribute to the pot) and carries no
6394
+ * per-user fields, so a visitor session receives the same list an identified
6395
+ * user would. The `lang` passed to `_smartico.vapi(lang)` drives the
6396
+ * translation of game names.
6391
6397
  *
6392
6398
  * **UI guidance**: see [UI Guide — `getJackpotEligibleGames`](../../docs/ui/jackpots/UIGuide_getJackpotEligibleGames.md).
6393
6399
  *
@@ -6405,6 +6411,10 @@ var WSAPIJackpots = /*#__PURE__*/function (_WSAPIClans) {
6405
6411
  *
6406
6412
  * const r = await window._smartico.api.getJackpotEligibleGames({ jp_template_id: 42 });
6407
6413
  * console.log('[smartico] render', r.eligible_games.length, 'eligible game tiles');
6414
+ *
6415
+ * // Visitor mode — same shape, language driven by the vapi(lang) argument
6416
+ * const visitor = await window._smartico.vapi('EN').getJackpotEligibleGames({ jp_template_id: 42 });
6417
+ * console.log('[smartico] visitor eligible games:', visitor.eligible_games.length);
6408
6418
  * ```
6409
6419
  */
6410
6420
  ;
@@ -7211,6 +7221,27 @@ var WSAPIMiniGames = /*#__PURE__*/function (_WSAPIRaffles) {
7211
7221
  * games server (not this SDK); the SAW spin is fired
7212
7222
  * server-internally to deduct the buy-in.
7213
7223
  *
7224
+ * **Per-prize statistics (`expose_game_stat_on_api`)**
7225
+ * Each template's `prizes` array always carries the definition
7226
+ * fields — name, icon, `prize_type`, `prize_value`, acknowledge
7227
+ * configuration. The stock-statistics fields are gated by an
7228
+ * operator template setting, surfaced as
7229
+ * `expose_game_stat_on_api`:
7230
+ * - Populated when enabled: `pool` (remaining stock),
7231
+ * `wins_count` (total wins across all players), `weekdays`
7232
+ * (ISO 1–7 days the prize can be won), `active_from_ts` /
7233
+ * `active_till_ts` (prize availability window).
7234
+ * - Omitted when disabled (the default) — this keeps the live
7235
+ * prize economy (stock levels, win rates, schedules) hidden
7236
+ * from players.
7237
+ * - Exception: `pool` is always populated for `MatchX` / `Quiz`
7238
+ * templates, whose game flow needs the remaining stock.
7239
+ * - `pool_initial` is populated regardless of the setting.
7240
+ * When enabled, the values are also kept current — the server
7241
+ * refreshes the prize rows on each fetch and drops its template
7242
+ * caches after every play, so `pool` / `wins_count` are safe to
7243
+ * drive an "X prizes left" scarcity UI.
7244
+ *
7214
7245
  * **Cache TTL**: the SDK caches the response for 30 seconds. Cache
7215
7246
  * is fully cleared on login / logout.
7216
7247
  *
@@ -7438,14 +7469,19 @@ var WSAPIMiniGames = /*#__PURE__*/function (_WSAPIRaffles) {
7438
7469
  * it later by calling {@link miniGameWinAcknowledgeRequest} with the
7439
7470
  * `request_id` returned on this result.
7440
7471
  *
7441
- * What `acknowledge: false` does and does NOT defer:
7442
- * - For STANDARD prizes the value is credited at spin time
7443
- * regardless, so opting out does NOT delay the balance change —
7444
- * it only defers the "delivered" bookkeeping and the `is_claimed`
7445
- * flag flipping in {@link getMiniGamesHistory}.
7446
- * - For operator-configured "explicit claim" prizes the credit IS
7447
- * deferred until the spin is acknowledged, so those require an
7448
- * explicit acknowledge to finalise.
7472
+ * What `acknowledge: false` defers:
7473
+ * - For STANDARD prizes the value is credited when the spin is
7474
+ * finalised — by your later acknowledge or, failing that, by the
7475
+ * server-side fallback below — so opting out delays the balance
7476
+ * change by at most that fallback window. The `is_claimed` flag in
7477
+ * {@link getMiniGamesHistory} flips on the same finalisation.
7478
+ * - For operator-configured "explicit claim" prizes the credit is
7479
+ * deferred until your explicit acknowledge — the fallback does not
7480
+ * cover them.
7481
+ *
7482
+ * While the spin is un-finalised it can also be finalised as LOST —
7483
+ * prize discarded back to the pool — via
7484
+ * {@link miniGameWinAcknowledgeRequest} with `{ lose: true }`.
7449
7485
  *
7450
7486
  * A server-side fallback auto-acknowledges ordinary un-acknowledged
7451
7487
  * spins after a short delay (about 1–3 minutes), so an ordinary
@@ -7476,8 +7512,10 @@ var WSAPIMiniGames = /*#__PURE__*/function (_WSAPIRaffles) {
7476
7512
  * time the call resolves. Balance updates flow via the
7477
7513
  * user-properties channel (observe via {@link getUserProfile}).
7478
7514
  * - Prize value credited per the prize's type (see "Prize handling"
7479
- * above). Standard prizes are credited at spin time; "explicit
7480
- * claim" prizes are credited when the spin is acknowledged.
7515
+ * above) when the spin is finalised — with the default
7516
+ * auto-acknowledge that happens before the call resolves;
7517
+ * "explicit claim" prizes are credited only by an explicit
7518
+ * acknowledge.
7481
7519
  * - The play is recorded server-side for analytics / reporting.
7482
7520
  *
7483
7521
  * **UI guidance**: see [UI Guide — `playMiniGame`](../../docs/ui/minigames/UIGuide_playMiniGame.md).
@@ -7542,18 +7580,24 @@ var WSAPIMiniGames = /*#__PURE__*/function (_WSAPIRaffles) {
7542
7580
  *
7543
7581
  * @example
7544
7582
  * Manual finalisation (`acknowledge: false`) — e.g. an explicit
7545
- * "Claim" CTA, or finalising on your own schedule:
7583
+ * "Claim" CTA, a decline/forfeit flow, or finalising on your own
7584
+ * schedule:
7546
7585
  * ```ts
7547
7586
  * const r = await window._smartico.api.playMiniGame(game.id, { acknowledge: false });
7548
7587
  * if (r.err_code === 0) {
7549
- * // Spin resolved but not yet acknowledged. For standard prizes the
7550
- * // balance already changed server-side; "explicit claim" prizes
7551
- * // are credited only by the acknowledge below.
7588
+ * // Spin resolved but not yet finalised — the prize is not credited
7589
+ * // yet. Your acknowledge below credits it (for standard prizes the
7590
+ * // server-side fallback would eventually do the same).
7552
7591
  * console.log('[smartico] prize won — show the result / Claim CTA, then finalise');
7553
7592
  *
7554
7593
  * // On the user's Claim click, finalise with the request_id from the result.
7555
7594
  * await window._smartico.api.miniGameWinAcknowledgeRequest(r.request_id);
7556
7595
  * console.log('[smartico] win finalised — refresh getUserProfile / getMiniGames to reflect it');
7596
+ *
7597
+ * // Or, if the game flow ends in the player declining / losing the
7598
+ * // drawn prize, finalise the spin as lost instead — the prize is
7599
+ * // not credited and returns to the prize pool:
7600
+ * // await window._smartico.api.miniGameWinAcknowledgeRequest(r.request_id, { lose: true });
7557
7601
  * }
7558
7602
  * ```
7559
7603
  */
@@ -7591,9 +7635,10 @@ var WSAPIMiniGames = /*#__PURE__*/function (_WSAPIRaffles) {
7591
7635
  }
7592
7636
  /**
7593
7637
  * Manually acknowledges a mini-game spin — marks the win delivered
7594
- * server-side. Most consumers do NOT need this: {@link playMiniGame}
7595
- * acknowledges by default (`acknowledge: true`) and
7596
- * {@link playMiniGameBatch} acknowledges automatically. Call this
7638
+ * server-side, or (with `lose: true`) finalises it as lost and
7639
+ * returns the prize to the pool. Most consumers do NOT need this:
7640
+ * {@link playMiniGame} acknowledges by default (`acknowledge: true`)
7641
+ * and {@link playMiniGameBatch} acknowledges automatically. Call this
7597
7642
  * directly only when you took ownership of the acknowledge step or
7598
7643
  * need to recover a lost one.
7599
7644
  *
@@ -7616,6 +7661,27 @@ var WSAPIMiniGames = /*#__PURE__*/function (_WSAPIRaffles) {
7616
7661
  * `client_request_id` on a {@link getMiniGamesHistory} row are the
7617
7662
  * same correlation id — this method accepts either.
7618
7663
  *
7664
+ * **Finalising as lost (`lose: true`)**
7665
+ * Pass `{ lose: true }` to finalise the spin as LOST instead of won:
7666
+ * the prize is NOT credited and is returned to the game's prize pool
7667
+ * (available again for other players), and the spin fires the
7668
+ * mini-game "lose" engagement event instead of the win one. On the
7669
+ * next {@link getMiniGamesHistory} fetch the row shows `is_claimed:
7670
+ * true` with no prize attached. Use this for game mechanics where the
7671
+ * player can decline or forfeit the drawn prize — e.g. a
7672
+ * gamble/discard step, or a client-driven game where the user's final
7673
+ * action decides whether the pre-drawn prize is actually won (the
7674
+ * default Smartico UI does this for the Voyager game: failing the
7675
+ * star-collection run finalises the spin as lost). When configured,
7676
+ * the prize's `aknowledge_message_lose` is the operator's result copy
7677
+ * for this case — show it instead of `aknowledge_message`. It only
7678
+ * works on a spin that is not yet finalised, so it requires playing
7679
+ * with `acknowledge: false` and calling promptly — once the automatic
7680
+ * acknowledge or the server-side fallback (below) has finalised the
7681
+ * spin, `lose: true` is a no-op and the prize stays credited.
7682
+ * ("Explicit claim" prizes are exempt from the fallback, so for them
7683
+ * there is no time pressure.)
7684
+ *
7619
7685
  * **Idempotency**: safe. Acknowledging a spin that is already
7620
7686
  * finalised — by you, by the automatic acknowledge, or by the
7621
7687
  * fallback — is a no-op with no double credit. Acknowledging a
@@ -7630,13 +7696,16 @@ var WSAPIMiniGames = /*#__PURE__*/function (_WSAPIRaffles) {
7630
7696
  * call here.
7631
7697
  *
7632
7698
  * **Side effects** (first successful call for an un-acknowledged spin)
7633
- * - For "explicit claim" prizes, the prize value is credited on this
7634
- * call. For standard prizes the value was already credited at spin
7635
- * time (see {@link playMiniGame} "Prize handling"); this call only
7636
- * marks the win delivered.
7637
- * - The spin's `is_claimed` flips to `true` on the next
7699
+ * - Default (win): the prize value is credited on this call — this is
7700
+ * the finalisation step that credits standard and "explicit claim"
7701
+ * prizes alike (see {@link playMiniGame} "Prize handling").
7702
+ * - With `lose: true`: no credit; the prize returns to the prize pool
7703
+ * and the "lose" engagement event fires.
7704
+ * - Either way the spin's `is_claimed` flips to `true` on the next
7638
7705
  * {@link getMiniGamesHistory} fetch.
7639
7706
  *
7707
+ * **UI guidance**: see [UI Guide — `miniGameWinAcknowledgeRequest`](../../docs/ui/minigames/UIGuide_miniGameWinAcknowledgeRequest.md).
7708
+ *
7640
7709
  * **Visitor mode**: not supported.
7641
7710
  *
7642
7711
  * @param request_id Correlation id of the spin to finalise: the
@@ -7644,6 +7713,10 @@ var WSAPIMiniGames = /*#__PURE__*/function (_WSAPIRaffles) {
7644
7713
  * (played with `acknowledge: false`), or the
7645
7714
  * `client_request_id` of a
7646
7715
  * {@link getMiniGamesHistory} row.
7716
+ * @param options.lose Optional. When `true`, finalises the spin as
7717
+ * lost — the prize is not credited and returns
7718
+ * to the prize pool (see "Finalising as lost").
7719
+ * Omit (or pass `false`) to deliver the win.
7647
7720
  *
7648
7721
  * @example
7649
7722
  * ```ts
@@ -7654,6 +7727,10 @@ var WSAPIMiniGames = /*#__PURE__*/function (_WSAPIRaffles) {
7654
7727
  * await window._smartico.api.miniGameWinAcknowledgeRequest(r.request_id);
7655
7728
  * }
7656
7729
  *
7730
+ * // Decline / forfeit — finalise the same spin as lost instead:
7731
+ * // the prize is not credited and goes back to the prize pool.
7732
+ * await window._smartico.api.miniGameWinAcknowledgeRequest(r.request_id, { lose: true });
7733
+ *
7657
7734
  * // Recovery — re-acknowledge any spins a batch acknowledge missed.
7658
7735
  * const history = await window._smartico.api.getMiniGamesHistory({ limit: 20 });
7659
7736
  * for (const row of history.filter(h => !h.is_claimed)) {
@@ -7663,10 +7740,12 @@ var WSAPIMiniGames = /*#__PURE__*/function (_WSAPIRaffles) {
7663
7740
  * ```
7664
7741
  */
7665
7742
  ;
7666
- _proto.miniGameWinAcknowledgeRequest = function miniGameWinAcknowledgeRequest(request_id) {
7743
+ _proto.miniGameWinAcknowledgeRequest = function miniGameWinAcknowledgeRequest(request_id, _temp5) {
7744
+ var _ref4 = _temp5 === void 0 ? {} : _temp5,
7745
+ lose = _ref4.lose;
7667
7746
  try {
7668
7747
  var _this4 = this;
7669
- return Promise.resolve(_this4.api.doAcknowledgeRequest(_this4.userExtId, request_id));
7748
+ return Promise.resolve(_this4.api.doAcknowledgeRequest(_this4.userExtId, request_id, lose));
7670
7749
  } catch (e) {
7671
7750
  return Promise.reject(e);
7672
7751
  }
@@ -7776,9 +7855,9 @@ var WSAPIMiniGames = /*#__PURE__*/function (_WSAPIRaffles) {
7776
7855
  * ```
7777
7856
  */
7778
7857
  ;
7779
- _proto.playMiniGameBatch = function playMiniGameBatch(template_id, spin_count, _temp5) {
7780
- var _ref4 = _temp5 === void 0 ? {} : _temp5,
7781
- onUpdate = _ref4.onUpdate;
7858
+ _proto.playMiniGameBatch = function playMiniGameBatch(template_id, spin_count, _temp6) {
7859
+ var _ref5 = _temp6 === void 0 ? {} : _temp6,
7860
+ onUpdate = _ref5.onUpdate;
7782
7861
  try {
7783
7862
  var _this5 = this;
7784
7863
  if (typeof onUpdate === 'function') {
@@ -10813,6 +10892,7 @@ var SmarticoAPI = /*#__PURE__*/function () {
10813
10892
  t.prizes.forEach(function (p) {
10814
10893
  p.saw_prize_ui_definition.name = IntUtils.replaceAll(p.saw_prize_ui_definition.name, '{{jackpot}}', jackpotValue);
10815
10894
  p.saw_prize_ui_definition.aknowledge_message = IntUtils.replaceAll(p.saw_prize_ui_definition.aknowledge_message, '{{jackpot}}', jackpotValue);
10895
+ p.saw_prize_ui_definition.aknowledge_message_lose = IntUtils.replaceAll(p.saw_prize_ui_definition.aknowledge_message_lose, '{{jackpot}}', jackpotValue);
10816
10896
  });
10817
10897
  }
10818
10898
  });
@@ -10833,11 +10913,12 @@ var SmarticoAPI = /*#__PURE__*/function () {
10833
10913
  return Promise.reject(e);
10834
10914
  }
10835
10915
  };
10836
- _proto.doAcknowledgeRequest = function doAcknowledgeRequest(user_ext_id, request_id) {
10916
+ _proto.doAcknowledgeRequest = function doAcknowledgeRequest(user_ext_id, request_id, lose) {
10837
10917
  try {
10838
10918
  var _this16 = this;
10839
10919
  var message = _this16.buildMessage(user_ext_id, exports.ClassId.SAW_AKNOWLEDGE_REQUEST, {
10840
- request_id: request_id
10920
+ request_id: request_id,
10921
+ lose: lose
10841
10922
  });
10842
10923
  return Promise.resolve(_this16.send(message, exports.ClassId.SAW_AKNOWLEDGE_RESPONSE));
10843
10924
  } catch (e) {