@smartico/public-api 0.0.408 → 0.0.410

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 (53) hide show
  1. package/dist/GamePick/GamePickTypes.d.ts +6 -1
  2. package/dist/MiniGames/SAWDoAknowledgeRequest.d.ts +2 -0
  3. package/dist/MiniGames/SAWPrize.d.ts +9 -0
  4. package/dist/MiniGames/SAWTemplate.d.ts +1 -0
  5. package/dist/SmarticoAPI.d.ts +1 -1
  6. package/dist/SmarticoLib/index.d.ts +1 -1
  7. package/dist/Tournaments/GetClanTournamentPlayersResponse.d.ts +2 -16
  8. package/dist/WSAPI/WSAPIJackpots.d.ts +11 -2
  9. package/dist/WSAPI/WSAPIMiniGames.d.ts +86 -23
  10. package/dist/WSAPI/WSAPITypes.d.ts +16 -12
  11. package/dist/index.js +109 -31
  12. package/dist/index.js.map +1 -1
  13. package/dist/index.modern.mjs +106 -28
  14. package/dist/index.modern.mjs.map +1 -1
  15. package/docs/api/README.md +0 -2
  16. package/docs/api/classes/WSAPIJackpots.md +11 -2
  17. package/docs/api/classes/WSAPIMiniGames.md +86 -23
  18. package/docs/api/functions/clanTournamentPlayersTransform.md +2 -2
  19. package/docs/api/interfaces/GamePickEvent.md +6 -1
  20. package/docs/api/interfaces/SAWDoAknowledgeRequest.md +8 -0
  21. package/docs/api/interfaces/SAWPrize.md +18 -0
  22. package/docs/api/interfaces/SAWTemplate.md +2 -0
  23. package/docs/api/interfaces/TMiniGamePrize.md +25 -9
  24. package/docs/api/interfaces/TMiniGameTemplate.md +3 -3
  25. package/docs/capabilities/gamePickGetActiveRound.md +1 -1
  26. package/docs/capabilities/gamePickGetActiveRounds.md +1 -1
  27. package/docs/capabilities/gamePickGetHistory.md +1 -1
  28. package/docs/capabilities/gamePickGetRoundInfoForUser.md +1 -1
  29. package/docs/capabilities/gamePickSubmitSelection.md +1 -1
  30. package/docs/capabilities/gamePickSubmitSelectionQuiz.md +1 -1
  31. package/docs/capabilities/getJackpotEligibleGames.md +11 -2
  32. package/docs/capabilities/getMiniGames.md +35 -12
  33. package/docs/capabilities/miniGameWinAcknowledgeRequest.md +30 -7
  34. package/docs/capabilities/playMiniGame.md +27 -14
  35. package/docs/native/PROTOCOL.md +3 -0
  36. package/docs/ui/jackpots/UIGuide_getJackpotEligibleGames.md +8 -0
  37. package/docs/ui/minigames/UIGuide_getMiniGames.md +24 -0
  38. package/docs/ui/minigames/UIGuide_getMiniGamesHistory.md +1 -1
  39. package/docs/ui/minigames/UIGuide_playMiniGame.md +28 -1
  40. package/package.json +2 -2
  41. package/src/GamePick/GamePickTypes.ts +6 -1
  42. package/src/MiniGames/SAWDoAknowledgeRequest.ts +2 -0
  43. package/src/MiniGames/SAWGetTemplatesResponse.ts +2 -0
  44. package/src/MiniGames/SAWPrize.ts +9 -0
  45. package/src/MiniGames/SAWTemplate.ts +1 -0
  46. package/src/SmarticoAPI.ts +2 -1
  47. package/src/SmarticoLib/index.ts +1 -1
  48. package/src/Tournaments/GetClanTournamentPlayersResponse.ts +5 -18
  49. package/src/WSAPI/WSAPIJackpots.ts +11 -2
  50. package/src/WSAPI/WSAPIMiniGames.ts +85 -24
  51. package/src/WSAPI/WSAPITypes.ts +16 -12
  52. package/docs/api/interfaces/TClanTournamentPlayer.md +0 -55
  53. package/docs/api/interfaces/TClanTournamentPlayersResult.md +0 -13
@@ -539,6 +539,8 @@ const SAWTemplatesTransform = items => {
539
539
  acknowledge_action_title: p.saw_prize_ui_definition.acknowledge_action_title,
540
540
  acknowledge_dp_additional: p.saw_prize_ui_definition.acknowledge_dp_additional,
541
541
  acknowledge_action_title_additional: p.saw_prize_ui_definition.acknowledge_action_title_additional,
542
+ second_btn: p.saw_prize_ui_definition.second_btn,
543
+ second_btn_action_title: p.saw_prize_ui_definition.second_btn_action_title,
542
544
  out_of_stock_message: p.saw_prize_ui_definition.out_of_stock_message,
543
545
  pool: p.pool,
544
546
  pool_initial: p.pool_initial,
@@ -1728,6 +1730,9 @@ var AchievementClaimPeriodTypeId;
1728
1730
  AchievementClaimPeriodTypeId[AchievementClaimPeriodTypeId["ExactPeriod"] = 1] = "ExactPeriod";
1729
1731
  })(AchievementClaimPeriodTypeId || (AchievementClaimPeriodTypeId = {}));
1730
1732
 
1733
+ // Consumer-facing types live in WSAPITypes.ts (`TClanTournamentPlayers`) — the
1734
+ // single source documented + emitted to docs. This transform maps the raw wire
1735
+ // shape onto it; do not re-declare a parallel result/player type here.
1731
1736
  const clanTournamentPlayersTransform = response => {
1732
1737
  return {
1733
1738
  tournament_instance_id: response.tournament_instance_id,
@@ -5985,7 +5990,7 @@ class WSAPIJackpots extends WSAPIClans {
5985
5990
  *
5986
5991
  * @remarks
5987
5992
  * **Preconditions**
5988
- * - User must be authenticated. Visitor mode not supported.
5993
+ * - No authentication required — works in both identified and visitor mode.
5989
5994
  * - `jp_template_id` is mandatory.
5990
5995
  *
5991
5996
  * **`onUpdate` caveat**
@@ -6003,7 +6008,12 @@ class WSAPIJackpots extends WSAPIClans {
6003
6008
  * Non-zero `errCode` on control-group users or generic server errors.
6004
6009
  * Branch on `errCode === 0` and surface `errMsg` on failure.
6005
6010
  *
6006
- * **Visitor mode**: not supported.
6011
+ * **Visitor mode**: supported via
6012
+ * `_smartico.vapi(lang).getJackpotEligibleGames(...)`. The eligible-games
6013
+ * list is template-level (which games contribute to the pot) and carries no
6014
+ * per-user fields, so a visitor session receives the same list an identified
6015
+ * user would. The `lang` passed to `_smartico.vapi(lang)` drives the
6016
+ * translation of game names.
6007
6017
  *
6008
6018
  * **UI guidance**: see [UI Guide — `getJackpotEligibleGames`](../../docs/ui/jackpots/UIGuide_getJackpotEligibleGames.md).
6009
6019
  *
@@ -6021,6 +6031,10 @@ class WSAPIJackpots extends WSAPIClans {
6021
6031
  *
6022
6032
  * const r = await window._smartico.api.getJackpotEligibleGames({ jp_template_id: 42 });
6023
6033
  * console.log('[smartico] render', r.eligible_games.length, 'eligible game tiles');
6034
+ *
6035
+ * // Visitor mode — same shape, language driven by the vapi(lang) argument
6036
+ * const visitor = await window._smartico.vapi('EN').getJackpotEligibleGames({ jp_template_id: 42 });
6037
+ * console.log('[smartico] visitor eligible games:', visitor.eligible_games.length);
6024
6038
  * ```
6025
6039
  */
6026
6040
  async getJackpotEligibleGames({
@@ -6763,6 +6777,27 @@ class WSAPIMiniGames extends WSAPIRaffles {
6763
6777
  * games server (not this SDK); the SAW spin is fired
6764
6778
  * server-internally to deduct the buy-in.
6765
6779
  *
6780
+ * **Per-prize statistics (`expose_game_stat_on_api`)**
6781
+ * Each template's `prizes` array always carries the definition
6782
+ * fields — name, icon, `prize_type`, `prize_value`, acknowledge
6783
+ * configuration. The stock-statistics fields are gated by an
6784
+ * operator template setting, surfaced as
6785
+ * `expose_game_stat_on_api`:
6786
+ * - Populated when enabled: `pool` (remaining stock),
6787
+ * `wins_count` (total wins across all players), `weekdays`
6788
+ * (ISO 1–7 days the prize can be won), `active_from_ts` /
6789
+ * `active_till_ts` (prize availability window).
6790
+ * - Omitted when disabled (the default) — this keeps the live
6791
+ * prize economy (stock levels, win rates, schedules) hidden
6792
+ * from players.
6793
+ * - Exception: `pool` is always populated for `MatchX` / `Quiz`
6794
+ * templates, whose game flow needs the remaining stock.
6795
+ * - `pool_initial` is populated regardless of the setting.
6796
+ * When enabled, the values are also kept current — the server
6797
+ * refreshes the prize rows on each fetch and drops its template
6798
+ * caches after every play, so `pool` / `wins_count` are safe to
6799
+ * drive an "X prizes left" scarcity UI.
6800
+ *
6766
6801
  * **Cache TTL**: the SDK caches the response for 30 seconds. Cache
6767
6802
  * is fully cleared on login / logout.
6768
6803
  *
@@ -6976,14 +7011,19 @@ class WSAPIMiniGames extends WSAPIRaffles {
6976
7011
  * it later by calling {@link miniGameWinAcknowledgeRequest} with the
6977
7012
  * `request_id` returned on this result.
6978
7013
  *
6979
- * What `acknowledge: false` does and does NOT defer:
6980
- * - For STANDARD prizes the value is credited at spin time
6981
- * regardless, so opting out does NOT delay the balance change —
6982
- * it only defers the "delivered" bookkeeping and the `is_claimed`
6983
- * flag flipping in {@link getMiniGamesHistory}.
6984
- * - For operator-configured "explicit claim" prizes the credit IS
6985
- * deferred until the spin is acknowledged, so those require an
6986
- * explicit acknowledge to finalise.
7014
+ * What `acknowledge: false` defers:
7015
+ * - For STANDARD prizes the value is credited when the spin is
7016
+ * finalised — by your later acknowledge or, failing that, by the
7017
+ * server-side fallback below — so opting out delays the balance
7018
+ * change by at most that fallback window. The `is_claimed` flag in
7019
+ * {@link getMiniGamesHistory} flips on the same finalisation.
7020
+ * - For operator-configured "explicit claim" prizes the credit is
7021
+ * deferred until your explicit acknowledge — the fallback does not
7022
+ * cover them.
7023
+ *
7024
+ * While the spin is un-finalised it can also be finalised as LOST —
7025
+ * prize discarded back to the pool — via
7026
+ * {@link miniGameWinAcknowledgeRequest} with `{ lose: true }`.
6987
7027
  *
6988
7028
  * A server-side fallback auto-acknowledges ordinary un-acknowledged
6989
7029
  * spins after a short delay (about 1–3 minutes), so an ordinary
@@ -7014,8 +7054,10 @@ class WSAPIMiniGames extends WSAPIRaffles {
7014
7054
  * time the call resolves. Balance updates flow via the
7015
7055
  * user-properties channel (observe via {@link getUserProfile}).
7016
7056
  * - Prize value credited per the prize's type (see "Prize handling"
7017
- * above). Standard prizes are credited at spin time; "explicit
7018
- * claim" prizes are credited when the spin is acknowledged.
7057
+ * above) when the spin is finalised — with the default
7058
+ * auto-acknowledge that happens before the call resolves;
7059
+ * "explicit claim" prizes are credited only by an explicit
7060
+ * acknowledge.
7019
7061
  * - The play is recorded server-side for analytics / reporting.
7020
7062
  *
7021
7063
  * **UI guidance**: see [UI Guide — `playMiniGame`](../../docs/ui/minigames/UIGuide_playMiniGame.md).
@@ -7080,18 +7122,24 @@ class WSAPIMiniGames extends WSAPIRaffles {
7080
7122
  *
7081
7123
  * @example
7082
7124
  * Manual finalisation (`acknowledge: false`) — e.g. an explicit
7083
- * "Claim" CTA, or finalising on your own schedule:
7125
+ * "Claim" CTA, a decline/forfeit flow, or finalising on your own
7126
+ * schedule:
7084
7127
  * ```ts
7085
7128
  * const r = await window._smartico.api.playMiniGame(game.id, { acknowledge: false });
7086
7129
  * if (r.err_code === 0) {
7087
- * // Spin resolved but not yet acknowledged. For standard prizes the
7088
- * // balance already changed server-side; "explicit claim" prizes
7089
- * // are credited only by the acknowledge below.
7130
+ * // Spin resolved but not yet finalised — the prize is not credited
7131
+ * // yet. Your acknowledge below credits it (for standard prizes the
7132
+ * // server-side fallback would eventually do the same).
7090
7133
  * console.log('[smartico] prize won — show the result / Claim CTA, then finalise');
7091
7134
  *
7092
7135
  * // On the user's Claim click, finalise with the request_id from the result.
7093
7136
  * await window._smartico.api.miniGameWinAcknowledgeRequest(r.request_id);
7094
7137
  * console.log('[smartico] win finalised — refresh getUserProfile / getMiniGames to reflect it');
7138
+ *
7139
+ * // Or, if the game flow ends in the player declining / losing the
7140
+ * // drawn prize, finalise the spin as lost instead — the prize is
7141
+ * // not credited and returns to the prize pool:
7142
+ * // await window._smartico.api.miniGameWinAcknowledgeRequest(r.request_id, { lose: true });
7095
7143
  * }
7096
7144
  * ```
7097
7145
  */
@@ -7116,9 +7164,10 @@ class WSAPIMiniGames extends WSAPIRaffles {
7116
7164
  }
7117
7165
  /**
7118
7166
  * Manually acknowledges a mini-game spin — marks the win delivered
7119
- * server-side. Most consumers do NOT need this: {@link playMiniGame}
7120
- * acknowledges by default (`acknowledge: true`) and
7121
- * {@link playMiniGameBatch} acknowledges automatically. Call this
7167
+ * server-side, or (with `lose: true`) finalises it as lost and
7168
+ * returns the prize to the pool. Most consumers do NOT need this:
7169
+ * {@link playMiniGame} acknowledges by default (`acknowledge: true`)
7170
+ * and {@link playMiniGameBatch} acknowledges automatically. Call this
7122
7171
  * directly only when you took ownership of the acknowledge step or
7123
7172
  * need to recover a lost one.
7124
7173
  *
@@ -7141,6 +7190,23 @@ class WSAPIMiniGames extends WSAPIRaffles {
7141
7190
  * `client_request_id` on a {@link getMiniGamesHistory} row are the
7142
7191
  * same correlation id — this method accepts either.
7143
7192
  *
7193
+ * **Finalising as lost (`lose: true`)**
7194
+ * Pass `{ lose: true }` to finalise the spin as LOST instead of won:
7195
+ * the prize is NOT credited and is returned to the game's prize pool
7196
+ * (available again for other players), and the spin fires the
7197
+ * mini-game "lose" engagement event instead of the win one. On the
7198
+ * next {@link getMiniGamesHistory} fetch the row shows `is_claimed:
7199
+ * true` with no prize attached. Use this for game mechanics where the
7200
+ * player can decline or forfeit the drawn prize — e.g. a
7201
+ * gamble/discard step, or a client-driven game where the user's final
7202
+ * action decides whether the pre-drawn prize is actually won. It only
7203
+ * works on a spin that is not yet finalised, so it requires playing
7204
+ * with `acknowledge: false` and calling promptly — once the automatic
7205
+ * acknowledge or the server-side fallback (below) has finalised the
7206
+ * spin, `lose: true` is a no-op and the prize stays credited.
7207
+ * ("Explicit claim" prizes are exempt from the fallback, so for them
7208
+ * there is no time pressure.)
7209
+ *
7144
7210
  * **Idempotency**: safe. Acknowledging a spin that is already
7145
7211
  * finalised — by you, by the automatic acknowledge, or by the
7146
7212
  * fallback — is a no-op with no double credit. Acknowledging a
@@ -7155,11 +7221,12 @@ class WSAPIMiniGames extends WSAPIRaffles {
7155
7221
  * call here.
7156
7222
  *
7157
7223
  * **Side effects** (first successful call for an un-acknowledged spin)
7158
- * - For "explicit claim" prizes, the prize value is credited on this
7159
- * call. For standard prizes the value was already credited at spin
7160
- * time (see {@link playMiniGame} "Prize handling"); this call only
7161
- * marks the win delivered.
7162
- * - The spin's `is_claimed` flips to `true` on the next
7224
+ * - Default (win): the prize value is credited on this call — this is
7225
+ * the finalisation step that credits standard and "explicit claim"
7226
+ * prizes alike (see {@link playMiniGame} "Prize handling").
7227
+ * - With `lose: true`: no credit; the prize returns to the prize pool
7228
+ * and the "lose" engagement event fires.
7229
+ * - Either way the spin's `is_claimed` flips to `true` on the next
7163
7230
  * {@link getMiniGamesHistory} fetch.
7164
7231
  *
7165
7232
  * **Visitor mode**: not supported.
@@ -7169,6 +7236,10 @@ class WSAPIMiniGames extends WSAPIRaffles {
7169
7236
  * (played with `acknowledge: false`), or the
7170
7237
  * `client_request_id` of a
7171
7238
  * {@link getMiniGamesHistory} row.
7239
+ * @param options.lose Optional. When `true`, finalises the spin as
7240
+ * lost — the prize is not credited and returns
7241
+ * to the prize pool (see "Finalising as lost").
7242
+ * Omit (or pass `false`) to deliver the win.
7172
7243
  *
7173
7244
  * @example
7174
7245
  * ```ts
@@ -7179,6 +7250,10 @@ class WSAPIMiniGames extends WSAPIRaffles {
7179
7250
  * await window._smartico.api.miniGameWinAcknowledgeRequest(r.request_id);
7180
7251
  * }
7181
7252
  *
7253
+ * // Decline / forfeit — finalise the same spin as lost instead:
7254
+ * // the prize is not credited and goes back to the prize pool.
7255
+ * await window._smartico.api.miniGameWinAcknowledgeRequest(r.request_id, { lose: true });
7256
+ *
7182
7257
  * // Recovery — re-acknowledge any spins a batch acknowledge missed.
7183
7258
  * const history = await window._smartico.api.getMiniGamesHistory({ limit: 20 });
7184
7259
  * for (const row of history.filter(h => !h.is_claimed)) {
@@ -7187,8 +7262,10 @@ class WSAPIMiniGames extends WSAPIRaffles {
7187
7262
  * }
7188
7263
  * ```
7189
7264
  */
7190
- async miniGameWinAcknowledgeRequest(request_id) {
7191
- return this.api.doAcknowledgeRequest(this.userExtId, request_id);
7265
+ async miniGameWinAcknowledgeRequest(request_id, {
7266
+ lose
7267
+ } = {}) {
7268
+ return this.api.doAcknowledgeRequest(this.userExtId, request_id, lose);
7192
7269
  }
7193
7270
  /**
7194
7271
  * Plays a mini-game template `spin_count` times in one round-trip.
@@ -9929,9 +10006,10 @@ class SmarticoAPI {
9929
10006
  async sawGetTemplatesT(user_ext_id) {
9930
10007
  return SAWTemplatesTransform((await this.sawGetTemplates(user_ext_id)).templates);
9931
10008
  }
9932
- async doAcknowledgeRequest(user_ext_id, request_id) {
10009
+ async doAcknowledgeRequest(user_ext_id, request_id, lose) {
9933
10010
  const message = this.buildMessage(user_ext_id, ClassId.SAW_AKNOWLEDGE_REQUEST, {
9934
- request_id
10011
+ request_id,
10012
+ lose
9935
10013
  });
9936
10014
  return await this.send(message, ClassId.SAW_AKNOWLEDGE_RESPONSE);
9937
10015
  }