@smartico/public-api 0.0.398 → 0.0.400

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.
@@ -6851,10 +6851,12 @@ class WSAPIMiniGames extends WSAPIRaffles {
6851
6851
  /**
6852
6852
  * Plays one round of a mini-game template — runs the server's
6853
6853
  * randomised prize selection, deducts the buy-in cost (if any),
6854
- * and returns the won `prize_id`. After the play resolves, the SDK
6855
- * automatically fires a server-side acknowledgement on a
6856
- * fire-and-forget basis, marking the spin as "delivered" so the
6857
- * prize takes effect.
6854
+ * credits the won prize, and returns the won `prize_id`. By default
6855
+ * (`acknowledge: true`) the SDK then sends a server-side
6856
+ * acknowledgement and AWAITS it before resolving, so the win is
6857
+ * marked delivered by the time the promise settles. Pass
6858
+ * `acknowledge: false` to skip that step and finalise the win
6859
+ * yourself later (see the `acknowledge` parameter).
6858
6860
  *
6859
6861
  * Works for all `SAWGameType` values EXCEPT:
6860
6862
  * - `PrizeDrop` — prizes arrive server-pushed; do NOT call
@@ -6918,17 +6920,34 @@ class WSAPIMiniGames extends WSAPIRaffles {
6918
6920
  * corresponding domain methods.
6919
6921
  * - `'manual'` — operator delivers offline.
6920
6922
  *
6921
- * **Auto-acknowledge**
6922
- * The SDK calls the server's acknowledge endpoint immediately
6923
- * after the spin response, on a fire-and-forget basis (not
6924
- * awaited). This marks the spin as "delivered" so prize effects
6925
- * take hold. If the auto-acknowledge fails (network drop), the
6926
- * spin appears as `is_claimed: false` in
6927
- * {@link getMiniGamesHistory}; the consumer can recover it by
6928
- * passing the `client_request_id` to
6929
- * {@link miniGameWinAcknowledgeRequest}. A server-side fallback
6930
- * job auto-acknowledges stale spins every ~60 seconds, so prizes
6931
- * are eventually delivered even without consumer action.
6923
+ * **Acknowledge** (the `acknowledge` parameter, default `true`)
6924
+ * Every spin is finalised by a follow-up acknowledge step that
6925
+ * marks the win delivered. By default the SDK sends that
6926
+ * acknowledge and AWAITS it, so `playMiniGame` resolves only after
6927
+ * the win is finalised server-side. Keep the default unless you
6928
+ * have a specific reason not to.
6929
+ *
6930
+ * Pass `acknowledge: false` to skip that automatic step.
6931
+ * `playMiniGame` then resolves as soon as the spin result is known,
6932
+ * without waiting for the win to be marked delivered. You finalise
6933
+ * it later by calling {@link miniGameWinAcknowledgeRequest} with the
6934
+ * `request_id` returned on this result.
6935
+ *
6936
+ * What `acknowledge: false` does and does NOT defer:
6937
+ * - For STANDARD prizes the value is credited at spin time
6938
+ * regardless, so opting out does NOT delay the balance change —
6939
+ * it only defers the "delivered" bookkeeping and the `is_claimed`
6940
+ * flag flipping in {@link getMiniGamesHistory}.
6941
+ * - For operator-configured "explicit claim" prizes the credit IS
6942
+ * deferred until the spin is acknowledged, so those require an
6943
+ * explicit acknowledge to finalise.
6944
+ *
6945
+ * A server-side fallback auto-acknowledges ordinary un-acknowledged
6946
+ * spins after a short delay (about 1–3 minutes), so an ordinary
6947
+ * prize is never lost even without consumer action. "Explicit
6948
+ * claim" prizes are excluded from that fallback — if you use
6949
+ * `acknowledge: false` for one, you MUST acknowledge it explicitly
6950
+ * or its prize is never credited.
6932
6951
  *
6933
6952
  * **Idempotency**: NOT idempotent. A double-click sends two
6934
6953
  * spins and deducts the buy-in twice. The SDK does NOT guard
@@ -6947,25 +6966,33 @@ class WSAPIMiniGames extends WSAPIRaffles {
6947
6966
  * refreshed array.
6948
6967
  *
6949
6968
  * **Side effects** (on `err_code === 0`)
6950
- * - Buy-in deducted from the user's balance (points / gems /
6951
- * diamonds / spin tickets — depending on `saw_buyin_type`).
6952
- * Balance updates flow via the user-properties channel
6953
- * (subscribe to {@link getUserProfile} `props_change` to
6954
- * observe).
6955
- * - Prize value credited per the prize's type (see "Prize
6956
- * handling" above).
6957
- * - A `minigame_attempt` analytics event fires server-side with
6958
- * the result status.
6969
+ * - Buy-in deducted at spin time (points / gems / diamonds / spin
6970
+ * tickets — depending on `saw_buyin_type`), already applied by the
6971
+ * time the call resolves. Balance updates flow via the
6972
+ * user-properties channel (observe via {@link getUserProfile}).
6973
+ * - Prize value credited per the prize's type (see "Prize handling"
6974
+ * above). Standard prizes are credited at spin time; "explicit
6975
+ * claim" prizes are credited when the spin is acknowledged.
6976
+ * - The play is recorded server-side for analytics / reporting.
6959
6977
  *
6960
6978
  * **UI guidance**: see [UI Guide — `playMiniGame`](../../docs/ui/minigames/UIGuide_playMiniGame.md).
6961
6979
  *
6962
6980
  * **Visitor mode**: not supported. Visitor sessions trying to
6963
6981
  * spin receive `SAW_VISITOR_STOP_SPIN_REQUEST (-40001)`.
6964
6982
  *
6965
- * @param template_id The mini-game template ID (from
6966
- * `TMiniGameTemplate.id`).
6967
- * @param params Optional. Pass an `onUpdate` callback to
6968
- * subscribe to subsequent template refreshes.
6983
+ * @param template_id The mini-game template ID (from
6984
+ * `TMiniGameTemplate.id`).
6985
+ * @param params Optional options bag.
6986
+ * @param params.onUpdate Pass a callback to subscribe to
6987
+ * subsequent template refreshes (same
6988
+ * channel as {@link getMiniGames}).
6989
+ * @param params.acknowledge Whether the SDK automatically sends and
6990
+ * awaits the win acknowledge after the
6991
+ * spin. Defaults to `true` (recommended).
6992
+ * Set `false` to finalise the win yourself
6993
+ * via {@link miniGameWinAcknowledgeRequest}
6994
+ * — see "Acknowledge" above for the
6995
+ * request-id caveat.
6969
6996
  * @returns `{ err_code, err_message, prize_id }` — success when
6970
6997
  * `err_code === 0`. `prize_id` is always populated; look
6971
6998
  * it up in `template.prizes` to interpret the prize.
@@ -7007,6 +7034,23 @@ class WSAPIMiniGames extends WSAPIRaffles {
7007
7034
  * console.error('[smartico] play failed — show generic error with this message:', r.err_message);
7008
7035
  * }
7009
7036
  * ```
7037
+ *
7038
+ * @example
7039
+ * Manual finalisation (`acknowledge: false`) — e.g. an explicit
7040
+ * "Claim" CTA, or finalising on your own schedule:
7041
+ * ```ts
7042
+ * const r = await window._smartico.api.playMiniGame(game.id, { acknowledge: false });
7043
+ * if (r.err_code === 0) {
7044
+ * // Spin resolved but not yet acknowledged. For standard prizes the
7045
+ * // balance already changed server-side; "explicit claim" prizes
7046
+ * // are credited only by the acknowledge below.
7047
+ * console.log('[smartico] prize won — show the result / Claim CTA, then finalise');
7048
+ *
7049
+ * // On the user's Claim click, finalise with the request_id from the result.
7050
+ * await window._smartico.api.miniGameWinAcknowledgeRequest(r.request_id);
7051
+ * console.log('[smartico] win finalised — refresh getUserProfile / getMiniGames to reflect it');
7052
+ * }
7053
+ * ```
7010
7054
  */
7011
7055
  async playMiniGame(template_id, {
7012
7056
  onUpdate,
@@ -7022,7 +7066,8 @@ class WSAPIMiniGames extends WSAPIRaffles {
7022
7066
  const o = {
7023
7067
  err_code: r.errCode,
7024
7068
  err_message: r.errMsg,
7025
- prize_id: r.saw_prize_id
7069
+ prize_id: r.saw_prize_id,
7070
+ request_id: r.request_id
7026
7071
  };
7027
7072
  return o;
7028
7073
  }