@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
@@ -535,6 +535,7 @@ const SAWTemplatesTransform = items => {
535
535
  sectors: p.saw_prize_ui_definition.sectors,
536
536
  acknowledge_type: SAWAcknowledgeTypeNamed(p.saw_prize_ui_definition.acknowledge_type),
537
537
  aknowledge_message: p.saw_prize_ui_definition.aknowledge_message,
538
+ aknowledge_message_lose: p.saw_prize_ui_definition.aknowledge_message_lose,
538
539
  acknowledge_dp: p.saw_prize_ui_definition.acknowledge_dp,
539
540
  acknowledge_action_title: p.saw_prize_ui_definition.acknowledge_action_title,
540
541
  acknowledge_dp_additional: p.saw_prize_ui_definition.acknowledge_dp_additional,
@@ -5990,7 +5991,7 @@ class WSAPIJackpots extends WSAPIClans {
5990
5991
  *
5991
5992
  * @remarks
5992
5993
  * **Preconditions**
5993
- * - User must be authenticated. Visitor mode not supported.
5994
+ * - No authentication required — works in both identified and visitor mode.
5994
5995
  * - `jp_template_id` is mandatory.
5995
5996
  *
5996
5997
  * **`onUpdate` caveat**
@@ -6008,7 +6009,12 @@ class WSAPIJackpots extends WSAPIClans {
6008
6009
  * Non-zero `errCode` on control-group users or generic server errors.
6009
6010
  * Branch on `errCode === 0` and surface `errMsg` on failure.
6010
6011
  *
6011
- * **Visitor mode**: not supported.
6012
+ * **Visitor mode**: supported via
6013
+ * `_smartico.vapi(lang).getJackpotEligibleGames(...)`. The eligible-games
6014
+ * list is template-level (which games contribute to the pot) and carries no
6015
+ * per-user fields, so a visitor session receives the same list an identified
6016
+ * user would. The `lang` passed to `_smartico.vapi(lang)` drives the
6017
+ * translation of game names.
6012
6018
  *
6013
6019
  * **UI guidance**: see [UI Guide — `getJackpotEligibleGames`](../../docs/ui/jackpots/UIGuide_getJackpotEligibleGames.md).
6014
6020
  *
@@ -6026,6 +6032,10 @@ class WSAPIJackpots extends WSAPIClans {
6026
6032
  *
6027
6033
  * const r = await window._smartico.api.getJackpotEligibleGames({ jp_template_id: 42 });
6028
6034
  * console.log('[smartico] render', r.eligible_games.length, 'eligible game tiles');
6035
+ *
6036
+ * // Visitor mode — same shape, language driven by the vapi(lang) argument
6037
+ * const visitor = await window._smartico.vapi('EN').getJackpotEligibleGames({ jp_template_id: 42 });
6038
+ * console.log('[smartico] visitor eligible games:', visitor.eligible_games.length);
6029
6039
  * ```
6030
6040
  */
6031
6041
  async getJackpotEligibleGames({
@@ -6768,6 +6778,27 @@ class WSAPIMiniGames extends WSAPIRaffles {
6768
6778
  * games server (not this SDK); the SAW spin is fired
6769
6779
  * server-internally to deduct the buy-in.
6770
6780
  *
6781
+ * **Per-prize statistics (`expose_game_stat_on_api`)**
6782
+ * Each template's `prizes` array always carries the definition
6783
+ * fields — name, icon, `prize_type`, `prize_value`, acknowledge
6784
+ * configuration. The stock-statistics fields are gated by an
6785
+ * operator template setting, surfaced as
6786
+ * `expose_game_stat_on_api`:
6787
+ * - Populated when enabled: `pool` (remaining stock),
6788
+ * `wins_count` (total wins across all players), `weekdays`
6789
+ * (ISO 1–7 days the prize can be won), `active_from_ts` /
6790
+ * `active_till_ts` (prize availability window).
6791
+ * - Omitted when disabled (the default) — this keeps the live
6792
+ * prize economy (stock levels, win rates, schedules) hidden
6793
+ * from players.
6794
+ * - Exception: `pool` is always populated for `MatchX` / `Quiz`
6795
+ * templates, whose game flow needs the remaining stock.
6796
+ * - `pool_initial` is populated regardless of the setting.
6797
+ * When enabled, the values are also kept current — the server
6798
+ * refreshes the prize rows on each fetch and drops its template
6799
+ * caches after every play, so `pool` / `wins_count` are safe to
6800
+ * drive an "X prizes left" scarcity UI.
6801
+ *
6771
6802
  * **Cache TTL**: the SDK caches the response for 30 seconds. Cache
6772
6803
  * is fully cleared on login / logout.
6773
6804
  *
@@ -6981,14 +7012,19 @@ class WSAPIMiniGames extends WSAPIRaffles {
6981
7012
  * it later by calling {@link miniGameWinAcknowledgeRequest} with the
6982
7013
  * `request_id` returned on this result.
6983
7014
  *
6984
- * What `acknowledge: false` does and does NOT defer:
6985
- * - For STANDARD prizes the value is credited at spin time
6986
- * regardless, so opting out does NOT delay the balance change —
6987
- * it only defers the "delivered" bookkeeping and the `is_claimed`
6988
- * flag flipping in {@link getMiniGamesHistory}.
6989
- * - For operator-configured "explicit claim" prizes the credit IS
6990
- * deferred until the spin is acknowledged, so those require an
6991
- * explicit acknowledge to finalise.
7015
+ * What `acknowledge: false` defers:
7016
+ * - For STANDARD prizes the value is credited when the spin is
7017
+ * finalised — by your later acknowledge or, failing that, by the
7018
+ * server-side fallback below — so opting out delays the balance
7019
+ * change by at most that fallback window. The `is_claimed` flag in
7020
+ * {@link getMiniGamesHistory} flips on the same finalisation.
7021
+ * - For operator-configured "explicit claim" prizes the credit is
7022
+ * deferred until your explicit acknowledge — the fallback does not
7023
+ * cover them.
7024
+ *
7025
+ * While the spin is un-finalised it can also be finalised as LOST —
7026
+ * prize discarded back to the pool — via
7027
+ * {@link miniGameWinAcknowledgeRequest} with `{ lose: true }`.
6992
7028
  *
6993
7029
  * A server-side fallback auto-acknowledges ordinary un-acknowledged
6994
7030
  * spins after a short delay (about 1–3 minutes), so an ordinary
@@ -7019,8 +7055,10 @@ class WSAPIMiniGames extends WSAPIRaffles {
7019
7055
  * time the call resolves. Balance updates flow via the
7020
7056
  * user-properties channel (observe via {@link getUserProfile}).
7021
7057
  * - Prize value credited per the prize's type (see "Prize handling"
7022
- * above). Standard prizes are credited at spin time; "explicit
7023
- * claim" prizes are credited when the spin is acknowledged.
7058
+ * above) when the spin is finalised — with the default
7059
+ * auto-acknowledge that happens before the call resolves;
7060
+ * "explicit claim" prizes are credited only by an explicit
7061
+ * acknowledge.
7024
7062
  * - The play is recorded server-side for analytics / reporting.
7025
7063
  *
7026
7064
  * **UI guidance**: see [UI Guide — `playMiniGame`](../../docs/ui/minigames/UIGuide_playMiniGame.md).
@@ -7085,18 +7123,24 @@ class WSAPIMiniGames extends WSAPIRaffles {
7085
7123
  *
7086
7124
  * @example
7087
7125
  * Manual finalisation (`acknowledge: false`) — e.g. an explicit
7088
- * "Claim" CTA, or finalising on your own schedule:
7126
+ * "Claim" CTA, a decline/forfeit flow, or finalising on your own
7127
+ * schedule:
7089
7128
  * ```ts
7090
7129
  * const r = await window._smartico.api.playMiniGame(game.id, { acknowledge: false });
7091
7130
  * if (r.err_code === 0) {
7092
- * // Spin resolved but not yet acknowledged. For standard prizes the
7093
- * // balance already changed server-side; "explicit claim" prizes
7094
- * // are credited only by the acknowledge below.
7131
+ * // Spin resolved but not yet finalised — the prize is not credited
7132
+ * // yet. Your acknowledge below credits it (for standard prizes the
7133
+ * // server-side fallback would eventually do the same).
7095
7134
  * console.log('[smartico] prize won — show the result / Claim CTA, then finalise');
7096
7135
  *
7097
7136
  * // On the user's Claim click, finalise with the request_id from the result.
7098
7137
  * await window._smartico.api.miniGameWinAcknowledgeRequest(r.request_id);
7099
7138
  * console.log('[smartico] win finalised — refresh getUserProfile / getMiniGames to reflect it');
7139
+ *
7140
+ * // Or, if the game flow ends in the player declining / losing the
7141
+ * // drawn prize, finalise the spin as lost instead — the prize is
7142
+ * // not credited and returns to the prize pool:
7143
+ * // await window._smartico.api.miniGameWinAcknowledgeRequest(r.request_id, { lose: true });
7100
7144
  * }
7101
7145
  * ```
7102
7146
  */
@@ -7121,9 +7165,10 @@ class WSAPIMiniGames extends WSAPIRaffles {
7121
7165
  }
7122
7166
  /**
7123
7167
  * Manually acknowledges a mini-game spin — marks the win delivered
7124
- * server-side. Most consumers do NOT need this: {@link playMiniGame}
7125
- * acknowledges by default (`acknowledge: true`) and
7126
- * {@link playMiniGameBatch} acknowledges automatically. Call this
7168
+ * server-side, or (with `lose: true`) finalises it as lost and
7169
+ * returns the prize to the pool. Most consumers do NOT need this:
7170
+ * {@link playMiniGame} acknowledges by default (`acknowledge: true`)
7171
+ * and {@link playMiniGameBatch} acknowledges automatically. Call this
7127
7172
  * directly only when you took ownership of the acknowledge step or
7128
7173
  * need to recover a lost one.
7129
7174
  *
@@ -7146,6 +7191,27 @@ class WSAPIMiniGames extends WSAPIRaffles {
7146
7191
  * `client_request_id` on a {@link getMiniGamesHistory} row are the
7147
7192
  * same correlation id — this method accepts either.
7148
7193
  *
7194
+ * **Finalising as lost (`lose: true`)**
7195
+ * Pass `{ lose: true }` to finalise the spin as LOST instead of won:
7196
+ * the prize is NOT credited and is returned to the game's prize pool
7197
+ * (available again for other players), and the spin fires the
7198
+ * mini-game "lose" engagement event instead of the win one. On the
7199
+ * next {@link getMiniGamesHistory} fetch the row shows `is_claimed:
7200
+ * true` with no prize attached. Use this for game mechanics where the
7201
+ * player can decline or forfeit the drawn prize — e.g. a
7202
+ * gamble/discard step, or a client-driven game where the user's final
7203
+ * action decides whether the pre-drawn prize is actually won (the
7204
+ * default Smartico UI does this for the Voyager game: failing the
7205
+ * star-collection run finalises the spin as lost). When configured,
7206
+ * the prize's `aknowledge_message_lose` is the operator's result copy
7207
+ * for this case — show it instead of `aknowledge_message`. It only
7208
+ * works on a spin that is not yet finalised, so it requires playing
7209
+ * with `acknowledge: false` and calling promptly — once the automatic
7210
+ * acknowledge or the server-side fallback (below) has finalised the
7211
+ * spin, `lose: true` is a no-op and the prize stays credited.
7212
+ * ("Explicit claim" prizes are exempt from the fallback, so for them
7213
+ * there is no time pressure.)
7214
+ *
7149
7215
  * **Idempotency**: safe. Acknowledging a spin that is already
7150
7216
  * finalised — by you, by the automatic acknowledge, or by the
7151
7217
  * fallback — is a no-op with no double credit. Acknowledging a
@@ -7160,13 +7226,16 @@ class WSAPIMiniGames extends WSAPIRaffles {
7160
7226
  * call here.
7161
7227
  *
7162
7228
  * **Side effects** (first successful call for an un-acknowledged spin)
7163
- * - For "explicit claim" prizes, the prize value is credited on this
7164
- * call. For standard prizes the value was already credited at spin
7165
- * time (see {@link playMiniGame} "Prize handling"); this call only
7166
- * marks the win delivered.
7167
- * - The spin's `is_claimed` flips to `true` on the next
7229
+ * - Default (win): the prize value is credited on this call — this is
7230
+ * the finalisation step that credits standard and "explicit claim"
7231
+ * prizes alike (see {@link playMiniGame} "Prize handling").
7232
+ * - With `lose: true`: no credit; the prize returns to the prize pool
7233
+ * and the "lose" engagement event fires.
7234
+ * - Either way the spin's `is_claimed` flips to `true` on the next
7168
7235
  * {@link getMiniGamesHistory} fetch.
7169
7236
  *
7237
+ * **UI guidance**: see [UI Guide — `miniGameWinAcknowledgeRequest`](../../docs/ui/minigames/UIGuide_miniGameWinAcknowledgeRequest.md).
7238
+ *
7170
7239
  * **Visitor mode**: not supported.
7171
7240
  *
7172
7241
  * @param request_id Correlation id of the spin to finalise: the
@@ -7174,6 +7243,10 @@ class WSAPIMiniGames extends WSAPIRaffles {
7174
7243
  * (played with `acknowledge: false`), or the
7175
7244
  * `client_request_id` of a
7176
7245
  * {@link getMiniGamesHistory} row.
7246
+ * @param options.lose Optional. When `true`, finalises the spin as
7247
+ * lost — the prize is not credited and returns
7248
+ * to the prize pool (see "Finalising as lost").
7249
+ * Omit (or pass `false`) to deliver the win.
7177
7250
  *
7178
7251
  * @example
7179
7252
  * ```ts
@@ -7184,6 +7257,10 @@ class WSAPIMiniGames extends WSAPIRaffles {
7184
7257
  * await window._smartico.api.miniGameWinAcknowledgeRequest(r.request_id);
7185
7258
  * }
7186
7259
  *
7260
+ * // Decline / forfeit — finalise the same spin as lost instead:
7261
+ * // the prize is not credited and goes back to the prize pool.
7262
+ * await window._smartico.api.miniGameWinAcknowledgeRequest(r.request_id, { lose: true });
7263
+ *
7187
7264
  * // Recovery — re-acknowledge any spins a batch acknowledge missed.
7188
7265
  * const history = await window._smartico.api.getMiniGamesHistory({ limit: 20 });
7189
7266
  * for (const row of history.filter(h => !h.is_claimed)) {
@@ -7192,8 +7269,10 @@ class WSAPIMiniGames extends WSAPIRaffles {
7192
7269
  * }
7193
7270
  * ```
7194
7271
  */
7195
- async miniGameWinAcknowledgeRequest(request_id) {
7196
- return this.api.doAcknowledgeRequest(this.userExtId, request_id);
7272
+ async miniGameWinAcknowledgeRequest(request_id, {
7273
+ lose
7274
+ } = {}) {
7275
+ return this.api.doAcknowledgeRequest(this.userExtId, request_id, lose);
7197
7276
  }
7198
7277
  /**
7199
7278
  * Plays a mini-game template `spin_count` times in one round-trip.
@@ -9925,6 +10004,7 @@ class SmarticoAPI {
9925
10004
  t.prizes.forEach(p => {
9926
10005
  p.saw_prize_ui_definition.name = IntUtils.replaceAll(p.saw_prize_ui_definition.name, '{{jackpot}}', jackpotValue);
9927
10006
  p.saw_prize_ui_definition.aknowledge_message = IntUtils.replaceAll(p.saw_prize_ui_definition.aknowledge_message, '{{jackpot}}', jackpotValue);
10007
+ p.saw_prize_ui_definition.aknowledge_message_lose = IntUtils.replaceAll(p.saw_prize_ui_definition.aknowledge_message_lose, '{{jackpot}}', jackpotValue);
9928
10008
  });
9929
10009
  }
9930
10010
  });
@@ -9934,9 +10014,10 @@ class SmarticoAPI {
9934
10014
  async sawGetTemplatesT(user_ext_id) {
9935
10015
  return SAWTemplatesTransform((await this.sawGetTemplates(user_ext_id)).templates);
9936
10016
  }
9937
- async doAcknowledgeRequest(user_ext_id, request_id) {
10017
+ async doAcknowledgeRequest(user_ext_id, request_id, lose) {
9938
10018
  const message = this.buildMessage(user_ext_id, ClassId.SAW_AKNOWLEDGE_REQUEST, {
9939
- request_id
10019
+ request_id,
10020
+ lose
9940
10021
  });
9941
10022
  return await this.send(message, ClassId.SAW_AKNOWLEDGE_RESPONSE);
9942
10023
  }