@smartico/public-api 0.0.399 → 0.0.401

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/Core/index.d.ts +1 -0
  2. package/dist/GamePick/GamePickTypes.d.ts +8 -8
  3. package/dist/Level/Level.d.ts +1 -0
  4. package/dist/SmarticoGlobal.d.ts +190 -0
  5. package/dist/WSAPI/WSAPIGamePick.d.ts +6 -6
  6. package/dist/WSAPI/WSAPIMiniGames.d.ts +60 -52
  7. package/dist/WSAPI/WSAPITypes.d.ts +5 -0
  8. package/dist/index.d.ts +1 -0
  9. package/dist/index.js +78 -66
  10. package/dist/index.js.map +1 -1
  11. package/dist/index.modern.mjs +69 -60
  12. package/dist/index.modern.mjs.map +1 -1
  13. package/docs/api/README.md +20 -0
  14. package/docs/api/classes/WSAPIAvatars.md +1 -8
  15. package/docs/api/classes/WSAPIGamePick.md +48 -48
  16. package/docs/api/classes/WSAPIMiniGames.md +132 -70
  17. package/docs/api/enumerations/GPRoundStatus.md +43 -0
  18. package/docs/api/enumerations/GamePickMarketType.md +19 -0
  19. package/docs/api/enumerations/GamePickResolutionType.md +35 -0
  20. package/docs/api/enumerations/GamePickScoreType.md +19 -0
  21. package/docs/api/enumerations/GamePickSportType.md +375 -0
  22. package/docs/api/enumerations/GameRoundOrderType.md +35 -0
  23. package/docs/api/enumerations/LiquidEntityData.md +6 -0
  24. package/docs/api/interfaces/GamePickBoardUser.md +75 -0
  25. package/docs/api/interfaces/GamePickEvent.md +123 -0
  26. package/docs/api/interfaces/GamePickEventMeta.md +201 -0
  27. package/docs/api/interfaces/GamePickGameInfo.md +27 -0
  28. package/docs/api/interfaces/GamePickRequestParams.md +39 -0
  29. package/docs/api/interfaces/GamePickRound.md +383 -0
  30. package/docs/api/interfaces/GamePickRoundBase.md +232 -0
  31. package/docs/api/interfaces/GamePickRoundBoard.md +359 -0
  32. package/docs/api/interfaces/GamePickRoundPublicMeta.md +103 -0
  33. package/docs/api/interfaces/GamePickRoundRequestParams.md +63 -0
  34. package/docs/api/interfaces/GamePickUserInfo.md +107 -0
  35. package/docs/api/interfaces/GamesApiResponse.md +33 -0
  36. package/docs/api/interfaces/Level.md +8 -0
  37. package/docs/api/interfaces/QuizEventMeta.md +61 -0
  38. package/docs/api/interfaces/RafflePrizePublicMeta.md +9 -0
  39. package/docs/api/interfaces/TMiniGamePlayResult.md +11 -0
  40. package/docs/api/interfaces/TRafflePrize.md +9 -0
  41. package/docs/api/variables/AllRoundsGameBoardID.md +5 -0
  42. package/docs/ui/minigames/UIGuide_playMiniGame.md +6 -5
  43. package/package.json +1 -1
  44. package/src/Core/index.ts +1 -0
  45. package/src/GamePick/GamePickTypes.ts +8 -8
  46. package/src/Level/Level.ts +1 -0
  47. package/src/SmarticoAPI.ts +2 -1
  48. package/src/SmarticoGlobal.ts +209 -0
  49. package/src/WSAPI/WSAPIGamePick.ts +6 -6
  50. package/src/WSAPI/WSAPIMiniGames.ts +61 -52
  51. package/src/WSAPI/WSAPITypes.ts +5 -0
  52. package/src/index.ts +1 -0
  53. package/tsconfig.json +1 -0
@@ -287,10 +287,8 @@ export class WSAPIMiniGames extends WSAPIRaffles {
287
287
  * Pass `acknowledge: false` to skip that automatic step.
288
288
  * `playMiniGame` then resolves as soon as the spin result is known,
289
289
  * without waiting for the win to be marked delivered. You finalise
290
- * it later by calling {@link miniGameWinAcknowledgeRequest}. The
291
- * result does NOT carry the spin's request id — obtain it as the
292
- * `client_request_id` of the matching {@link getMiniGamesHistory}
293
- * row (the spin appears there with `is_claimed: false`).
290
+ * it later by calling {@link miniGameWinAcknowledgeRequest} with the
291
+ * `request_id` returned on this result.
294
292
  *
295
293
  * What `acknowledge: false` does and does NOT defer:
296
294
  * - For STANDARD prizes the value is credited at spin time
@@ -405,12 +403,9 @@ export class WSAPIMiniGames extends WSAPIRaffles {
405
403
  * // are credited only by the acknowledge below.
406
404
  * console.log('[smartico] prize won — show the result / Claim CTA, then finalise');
407
405
  *
408
- * // The result has no request id — read it from history as client_request_id.
409
- * const [row] = await window._smartico.api.getMiniGamesHistory({ saw_template_id: game.id, limit: 1 });
410
- * if (row && !row.is_claimed) {
411
- * await window._smartico.api.miniGameWinAcknowledgeRequest(row.client_request_id);
412
- * console.log('[smartico] win finalised — refresh getUserProfile / getMiniGames to reflect it');
413
- * }
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');
414
409
  * }
415
410
  * ```
416
411
  */
@@ -430,69 +425,83 @@ export class WSAPIMiniGames extends WSAPIRaffles {
430
425
  err_code: r.errCode,
431
426
  err_message: r.errMsg,
432
427
  prize_id: r.saw_prize_id,
428
+ request_id: r.request_id,
433
429
  };
434
430
 
435
431
  return o;
436
432
  }
437
433
 
438
434
  /**
439
- * Manually acknowledges a mini-game spin — marks the spin as
440
- * "delivered" so the prize takes effect server-side. Most consumers
441
- * do NOT need to call this method directly; {@link playMiniGame}
442
- * and {@link playMiniGameBatch} auto-acknowledge on success. Use
443
- * this only for recovery scenarios.
435
+ * Manually acknowledges a mini-game spin — marks the win delivered
436
+ * server-side. Most consumers do NOT need this: {@link playMiniGame}
437
+ * acknowledges by default (`acknowledge: true`) and
438
+ * {@link playMiniGameBatch} acknowledges automatically. Call this
439
+ * directly only when you took ownership of the acknowledge step or
440
+ * need to recover a lost one.
444
441
  *
445
442
  * @remarks
446
443
  * **When to call**
447
- * - **Lost auto-acknowledge** — when the WebSocket dropped between
448
- * the spin response and the auto-acknowledge fire-and-forget,
449
- * the spin shows `is_claimed: false` in
450
- * {@link getMiniGamesHistory}. Pass that row's
451
- * `client_request_id` here to deliver the prize.
452
- * - **Explicit-acknowledge UI** — for templates configured with
453
- * the `ExplicitAcknowledge` acknowledge type (operator
454
- * decision), the consumer's UI shows a "Claim" CTA after the
455
- * prize animation. Click handler calls this method with the
456
- * spin's `client_request_id` rather than auto-acknowledging.
457
- *
458
- * **No-op on already-acknowledged spins**
459
- * The server's acknowledge SQL matches on `acknowledge_date IS
460
- * NULL` — a duplicate call returns successfully with no effect.
444
+ * - **Primary — after `playMiniGame(..., { acknowledge: false })`.**
445
+ * You opted out of the automatic acknowledge to finalise the win
446
+ * on your own schedule (e.g. on a user "Claim" tap). Pass the
447
+ * `request_id` from that call's result here when ready. This is
448
+ * REQUIRED for operator-configured "explicit claim" prizes — they
449
+ * are not covered by the server-side fallback, so without this
450
+ * call their prize is never credited.
451
+ * - **Recovery — a lost acknowledge.** {@link playMiniGameBatch}
452
+ * acknowledges on a fire-and-forget basis; if one is lost (network
453
+ * drop) the spin shows `is_claimed: false` in
454
+ * {@link getMiniGamesHistory}. Pass that row's `client_request_id`
455
+ * to deliver it.
456
+ *
457
+ * The `request_id` on a {@link playMiniGame} result and the
458
+ * `client_request_id` on a {@link getMiniGamesHistory} row are the
459
+ * same correlation id — this method accepts either.
460
+ *
461
+ * **Idempotency**: safe. Acknowledging a spin that is already
462
+ * finalised — by you, by the automatic acknowledge, or by the
463
+ * fallback — is a no-op with no double credit. Acknowledging a
464
+ * failed spin's id is likewise a no-op.
461
465
  *
462
466
  * **Server-side fallback**
463
- * Even without ever calling this method, a server-side job
464
- * auto-acknowledges stale spins every ~60 seconds — so prizes are
465
- * eventually delivered. The `is_claimed` flag flips on the next
466
- * `getMiniGamesHistory` call after the job runs.
467
- *
468
- * **Idempotency**: safe. Repeated calls have no effect after the
469
- * first.
470
- *
471
- * **Side effects** (on first successful call for an unacknowledged
472
- * spin)
473
- * - Prize value credited per the prize's type (see
474
- * {@link playMiniGame} "Prize handling").
475
- * - The spin's `is_claimed` flag flips to `true` on the next
476
- * {@link getMiniGamesHistory} call.
467
+ * Even if you never call this, a server-side job finalises ordinary
468
+ * un-acknowledged spins automatically after a short delay (about 1–3
469
+ * minutes), flipping `is_claimed` to `true` on the next
470
+ * {@link getMiniGamesHistory} fetch. "Explicit claim" prizes are the
471
+ * exception — excluded from the fallback, they require an explicit
472
+ * call here.
473
+ *
474
+ * **Side effects** (first successful call for an un-acknowledged spin)
475
+ * - For "explicit claim" prizes, the prize value is credited on this
476
+ * call. For standard prizes the value was already credited at spin
477
+ * time (see {@link playMiniGame} "Prize handling"); this call only
478
+ * marks the win delivered.
479
+ * - The spin's `is_claimed` flips to `true` on the next
480
+ * {@link getMiniGamesHistory} fetch.
477
481
  *
478
482
  * **Visitor mode**: not supported.
479
483
  *
480
- * @param request_id The `client_request_id` from a `TSawHistory`
481
- * row returned by {@link getMiniGamesHistory}.
484
+ * @param request_id Correlation id of the spin to finalise: the
485
+ * `request_id` from a {@link playMiniGame} result
486
+ * (played with `acknowledge: false`), or the
487
+ * `client_request_id` of a
488
+ * {@link getMiniGamesHistory} row.
482
489
  *
483
490
  * @example
484
491
  * ```ts
485
- * const history = await window._smartico.api.getMiniGamesHistory({ limit: 20 });
486
- * const unacknowledged = history.filter(h => !h.is_claimed);
492
+ * // Primary — finalise a win you played with acknowledge: false.
493
+ * const r = await window._smartico.api.playMiniGame(templateId, { acknowledge: false });
494
+ * if (r.err_code === 0) {
495
+ * console.log('[smartico] show the prize / Claim CTA; on Claim, finalise the win');
496
+ * await window._smartico.api.miniGameWinAcknowledgeRequest(r.request_id);
497
+ * }
487
498
  *
488
- * for (const row of unacknowledged) {
499
+ * // Recovery — re-acknowledge any spins a batch acknowledge missed.
500
+ * const history = await window._smartico.api.getMiniGamesHistory({ limit: 20 });
501
+ * for (const row of history.filter(h => !h.is_claimed)) {
489
502
  * console.log('[smartico] re-acknowledging stale spin', row.client_request_id);
490
503
  * await window._smartico.api.miniGameWinAcknowledgeRequest(row.client_request_id);
491
504
  * }
492
- *
493
- * // Re-fetch history to see the updated is_claimed flags.
494
- * const fresh = await window._smartico.api.getMiniGamesHistory({ limit: 20 });
495
- * console.log('[smartico] history after recovery —', fresh.filter(h => !h.is_claimed).length, 'still unacknowledged');
496
505
  * ```
497
506
  */
498
507
  public async miniGameWinAcknowledgeRequest(request_id: string) {
@@ -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
+ * `miniGameWinAcknowledgeRequest` to finalise the win when
107
+ * playing with `acknowledge: false` — no need to look it up via
108
+ * `getMiniGamesHistory`. */
109
+ request_id: string;
105
110
  }
106
111
 
107
112
  /**
package/src/index.ts CHANGED
@@ -2,6 +2,7 @@ export * from './Base/ClassId';
2
2
  export * from './ILogger';
3
3
  export * from './SmarticoAPI';
4
4
  export * from './WSAPI/WSAPI';
5
+ export * from './SmarticoGlobal';
5
6
  export * from './CookieStore';
6
7
 
7
8
  export * from './Analytics';
package/tsconfig.json CHANGED
@@ -30,6 +30,7 @@
30
30
  "src/WSAPI/WSAPILeaderBoard.ts",
31
31
  "src/WSAPI/WSAPIInbox.ts",
32
32
  "src/WSAPI/WSAPITypes.ts",
33
+ "src/GamePick/GamePickTypes.ts",
33
34
  "src/Tournaments/TournamentRegistrationStatus.ts",
34
35
  "src/Tournaments/TournamentRegistrationType.ts",
35
36
  "src/Tournaments/TournamentRegistrationError.ts",