@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.
- package/dist/Level/Level.d.ts +1 -0
- package/dist/WSAPI/WSAPIMiniGames.d.ts +72 -28
- package/dist/WSAPI/WSAPITypes.d.ts +5 -0
- package/dist/index.js +74 -29
- package/dist/index.js.map +1 -1
- package/dist/index.modern.mjs +74 -29
- package/dist/index.modern.mjs.map +1 -1
- package/docs/ui/minigames/UIGuide_playMiniGame.md +13 -8
- package/package.json +1 -1
- package/src/Level/Level.ts +1 -0
- package/src/WSAPI/WSAPIMiniGames.ts +73 -28
- package/src/WSAPI/WSAPITypes.ts +5 -0
|
@@ -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 (
|
|
8
|
-
don't need to handle acknowledge
|
|
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`,
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
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
package/src/Level/Level.ts
CHANGED
|
@@ -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`.
|
|
212
|
-
*
|
|
213
|
-
*
|
|
214
|
-
*
|
|
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
|
-
* **
|
|
279
|
-
*
|
|
280
|
-
*
|
|
281
|
-
*
|
|
282
|
-
*
|
|
283
|
-
*
|
|
284
|
-
*
|
|
285
|
-
*
|
|
286
|
-
*
|
|
287
|
-
*
|
|
288
|
-
*
|
|
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
|
|
308
|
-
*
|
|
309
|
-
* Balance updates flow via the
|
|
310
|
-
* (
|
|
311
|
-
*
|
|
312
|
-
*
|
|
313
|
-
*
|
|
314
|
-
* -
|
|
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
|
|
323
|
-
*
|
|
324
|
-
* @param params
|
|
325
|
-
*
|
|
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;
|
package/src/WSAPI/WSAPITypes.ts
CHANGED
|
@@ -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
|
/**
|