@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.
@@ -4,8 +4,10 @@
4
4
  - Action-focused mutation. User clicks "Play" / "Spin" on a mini-
5
5
  game card; the server runs the prize selection and returns the
6
6
  won prize.
7
- - Auto-acknowledges on success (fire-and-forget) — most consumers
8
- don't need to handle acknowledge manually.
7
+ - Auto-acknowledges on success by default (`acknowledge: true`, the
8
+ SDK awaits it) — most consumers don't need to handle acknowledge
9
+ manually. Pass `acknowledge: false` to finalise the win yourself
10
+ (see "Prize reveal modals").
9
11
  - The SDK does NOT prevent double-clicks at the public API level;
10
12
  guard the call site.
11
13
 
@@ -80,12 +82,15 @@ UI behavior per `err_code`:
80
82
  | `FullMessage` (3) | Full-screen modal; user dismisses; auto-acknowledge fires. |
81
83
  | `ExplicitAcknowledge` (4) | Modal with explicit "Claim" CTA; acknowledge sends only on tap. Use this for high-value or lootbox-style rewards. |
82
84
 
83
- For `ExplicitAcknowledge`, suppress the SDK's auto-acknowledge by
84
- NOT using this method's `playMiniGame` directly — call the
85
- acknowledge via [`miniGameWinAcknowledgeRequest`](../../api/classes/WSAPIMiniGames.md#minigamewinacknowledgerequest)
86
- when the user taps Claim. (The SDK still auto-fires the
87
- acknowledge from `playMiniGame`, but the visual gate is still
88
- meaningful.)
85
+ For `ExplicitAcknowledge`, gate the acknowledge on the user's Claim
86
+ tap: call `playMiniGame(template_id, { acknowledge: false })` so the
87
+ SDK does NOT auto-finalise, then call
88
+ [`miniGameWinAcknowledgeRequest`](../../api/classes/WSAPIMiniGames.md#minigamewinacknowledgerequest)
89
+ when the user taps Claim. Pass the spin's `client_request_id`, read
90
+ from the matching [`getMiniGamesHistory`](../../api/classes/WSAPIMiniGames.md#getminigameshistory)
91
+ row (it appears with `is_claimed: false`). Note: "explicit claim"
92
+ prizes are NOT covered by the server-side auto-acknowledge fallback,
93
+ so for these you MUST acknowledge or the prize is never credited.
89
94
 
90
95
  Modal contents per prize:
91
96
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smartico/public-api",
3
- "version": "0.0.398",
3
+ "version": "0.0.400",
4
4
  "description": "Smartico public API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -10,4 +10,5 @@ export interface Level {
10
10
  required_level_counter_1: number;
11
11
  required_level_counter_2: number;
12
12
  general_level_progress: number;
13
+ ordinal_position?: number;
13
14
  }
@@ -208,10 +208,12 @@ export class WSAPIMiniGames extends WSAPIRaffles {
208
208
  /**
209
209
  * Plays one round of a mini-game template — runs the server's
210
210
  * randomised prize selection, deducts the buy-in cost (if any),
211
- * and returns the won `prize_id`. After the play resolves, the SDK
212
- * automatically fires a server-side acknowledgement on a
213
- * fire-and-forget basis, marking the spin as "delivered" so the
214
- * prize takes effect.
211
+ * credits the won prize, and returns the won `prize_id`. By default
212
+ * (`acknowledge: true`) the SDK then sends a server-side
213
+ * acknowledgement and AWAITS it before resolving, so the win is
214
+ * marked delivered by the time the promise settles. Pass
215
+ * `acknowledge: false` to skip that step and finalise the win
216
+ * yourself later (see the `acknowledge` parameter).
215
217
  *
216
218
  * Works for all `SAWGameType` values EXCEPT:
217
219
  * - `PrizeDrop` — prizes arrive server-pushed; do NOT call
@@ -275,17 +277,34 @@ export class WSAPIMiniGames extends WSAPIRaffles {
275
277
  * corresponding domain methods.
276
278
  * - `'manual'` — operator delivers offline.
277
279
  *
278
- * **Auto-acknowledge**
279
- * The SDK calls the server's acknowledge endpoint immediately
280
- * after the spin response, on a fire-and-forget basis (not
281
- * awaited). This marks the spin as "delivered" so prize effects
282
- * take hold. If the auto-acknowledge fails (network drop), the
283
- * spin appears as `is_claimed: false` in
284
- * {@link getMiniGamesHistory}; the consumer can recover it by
285
- * passing the `client_request_id` to
286
- * {@link miniGameWinAcknowledgeRequest}. A server-side fallback
287
- * job auto-acknowledges stale spins every ~60 seconds, so prizes
288
- * are eventually delivered even without consumer action.
280
+ * **Acknowledge** (the `acknowledge` parameter, default `true`)
281
+ * Every spin is finalised by a follow-up acknowledge step that
282
+ * marks the win delivered. By default the SDK sends that
283
+ * acknowledge and AWAITS it, so `playMiniGame` resolves only after
284
+ * the win is finalised server-side. Keep the default unless you
285
+ * have a specific reason not to.
286
+ *
287
+ * Pass `acknowledge: false` to skip that automatic step.
288
+ * `playMiniGame` then resolves as soon as the spin result is known,
289
+ * without waiting for the win to be marked delivered. You finalise
290
+ * it later by calling {@link miniGameWinAcknowledgeRequest} with the
291
+ * `request_id` returned on this result.
292
+ *
293
+ * What `acknowledge: false` does and does NOT defer:
294
+ * - For STANDARD prizes the value is credited at spin time
295
+ * regardless, so opting out does NOT delay the balance change —
296
+ * it only defers the "delivered" bookkeeping and the `is_claimed`
297
+ * flag flipping in {@link getMiniGamesHistory}.
298
+ * - For operator-configured "explicit claim" prizes the credit IS
299
+ * deferred until the spin is acknowledged, so those require an
300
+ * explicit acknowledge to finalise.
301
+ *
302
+ * A server-side fallback auto-acknowledges ordinary un-acknowledged
303
+ * spins after a short delay (about 1–3 minutes), so an ordinary
304
+ * prize is never lost even without consumer action. "Explicit
305
+ * claim" prizes are excluded from that fallback — if you use
306
+ * `acknowledge: false` for one, you MUST acknowledge it explicitly
307
+ * or its prize is never credited.
289
308
  *
290
309
  * **Idempotency**: NOT idempotent. A double-click sends two
291
310
  * spins and deducts the buy-in twice. The SDK does NOT guard
@@ -304,25 +323,33 @@ export class WSAPIMiniGames extends WSAPIRaffles {
304
323
  * refreshed array.
305
324
  *
306
325
  * **Side effects** (on `err_code === 0`)
307
- * - Buy-in deducted from the user's balance (points / gems /
308
- * diamonds / spin tickets — depending on `saw_buyin_type`).
309
- * Balance updates flow via the user-properties channel
310
- * (subscribe to {@link getUserProfile} `props_change` to
311
- * observe).
312
- * - Prize value credited per the prize's type (see "Prize
313
- * handling" above).
314
- * - A `minigame_attempt` analytics event fires server-side with
315
- * the result status.
326
+ * - Buy-in deducted at spin time (points / gems / diamonds / spin
327
+ * tickets — depending on `saw_buyin_type`), already applied by the
328
+ * time the call resolves. Balance updates flow via the
329
+ * user-properties channel (observe via {@link getUserProfile}).
330
+ * - Prize value credited per the prize's type (see "Prize handling"
331
+ * above). Standard prizes are credited at spin time; "explicit
332
+ * claim" prizes are credited when the spin is acknowledged.
333
+ * - The play is recorded server-side for analytics / reporting.
316
334
  *
317
335
  * **UI guidance**: see [UI Guide — `playMiniGame`](../../docs/ui/minigames/UIGuide_playMiniGame.md).
318
336
  *
319
337
  * **Visitor mode**: not supported. Visitor sessions trying to
320
338
  * spin receive `SAW_VISITOR_STOP_SPIN_REQUEST (-40001)`.
321
339
  *
322
- * @param template_id The mini-game template ID (from
323
- * `TMiniGameTemplate.id`).
324
- * @param params Optional. Pass an `onUpdate` callback to
325
- * subscribe to subsequent template refreshes.
340
+ * @param template_id The mini-game template ID (from
341
+ * `TMiniGameTemplate.id`).
342
+ * @param params Optional options bag.
343
+ * @param params.onUpdate Pass a callback to subscribe to
344
+ * subsequent template refreshes (same
345
+ * channel as {@link getMiniGames}).
346
+ * @param params.acknowledge Whether the SDK automatically sends and
347
+ * awaits the win acknowledge after the
348
+ * spin. Defaults to `true` (recommended).
349
+ * Set `false` to finalise the win yourself
350
+ * via {@link miniGameWinAcknowledgeRequest}
351
+ * — see "Acknowledge" above for the
352
+ * request-id caveat.
326
353
  * @returns `{ err_code, err_message, prize_id }` — success when
327
354
  * `err_code === 0`. `prize_id` is always populated; look
328
355
  * it up in `template.prizes` to interpret the prize.
@@ -364,6 +391,23 @@ export class WSAPIMiniGames extends WSAPIRaffles {
364
391
  * console.error('[smartico] play failed — show generic error with this message:', r.err_message);
365
392
  * }
366
393
  * ```
394
+ *
395
+ * @example
396
+ * Manual finalisation (`acknowledge: false`) — e.g. an explicit
397
+ * "Claim" CTA, or finalising on your own schedule:
398
+ * ```ts
399
+ * const r = await window._smartico.api.playMiniGame(game.id, { acknowledge: false });
400
+ * if (r.err_code === 0) {
401
+ * // Spin resolved but not yet acknowledged. For standard prizes the
402
+ * // balance already changed server-side; "explicit claim" prizes
403
+ * // are credited only by the acknowledge below.
404
+ * console.log('[smartico] prize won — show the result / Claim CTA, then finalise');
405
+ *
406
+ * // On the user's Claim click, finalise with the request_id from the result.
407
+ * await window._smartico.api.miniGameWinAcknowledgeRequest(r.request_id);
408
+ * console.log('[smartico] win finalised — refresh getUserProfile / getMiniGames to reflect it');
409
+ * }
410
+ * ```
367
411
  */
368
412
  public async playMiniGame(
369
413
  template_id: number,
@@ -381,6 +425,7 @@ export class WSAPIMiniGames extends WSAPIRaffles {
381
425
  err_code: r.errCode,
382
426
  err_message: r.errMsg,
383
427
  prize_id: r.saw_prize_id,
428
+ request_id: r.request_id,
384
429
  };
385
430
 
386
431
  return o;
@@ -102,6 +102,11 @@ export interface TMiniGamePlayResult {
102
102
  * (including `prize_type === 'no-prize'` for a configured loss
103
103
  * slot). Always populated, even when `err_code !== 0`. */
104
104
  prize_id: number;
105
+ /** Correlation id of this spin. Pass it to
106
+ * {@link miniGameWinAcknowledgeRequest} to finalise the win when
107
+ * playing with `acknowledge: false` — no need to look it up via
108
+ * {@link getMiniGamesHistory}. */
109
+ request_id: string;
105
110
  }
106
111
 
107
112
  /**