@smartico/public-api 0.0.400 → 0.0.402

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 (67) hide show
  1. package/dist/ActivityLog/ActivityLogEntry.d.ts +2 -0
  2. package/dist/Avatars/AvatarCustomized.d.ts +2 -2
  3. package/dist/Core/index.d.ts +1 -0
  4. package/dist/GamePick/GamePickTypes.d.ts +14 -14
  5. package/dist/Level/Level.d.ts +1 -0
  6. package/dist/SmarticoGlobal.d.ts +190 -0
  7. package/dist/WSAPI/WSAPIAvatars.d.ts +1 -1
  8. package/dist/WSAPI/WSAPIGamePick.d.ts +6 -6
  9. package/dist/WSAPI/WSAPIMiniGames.d.ts +55 -42
  10. package/dist/WSAPI/WSAPITypes.d.ts +9 -6
  11. package/dist/index.d.ts +2 -0
  12. package/dist/index.js +73 -57
  13. package/dist/index.js.map +1 -1
  14. package/dist/index.modern.mjs +64 -51
  15. package/dist/index.modern.mjs.map +1 -1
  16. package/docs/api/README.md +20 -0
  17. package/docs/api/classes/WSAPIAvatars.md +2 -9
  18. package/docs/api/classes/WSAPIGamePick.md +48 -48
  19. package/docs/api/classes/WSAPIMiniGames.md +132 -70
  20. package/docs/api/enumerations/GPRoundStatus.md +43 -0
  21. package/docs/api/enumerations/GamePickMarketType.md +19 -0
  22. package/docs/api/enumerations/GamePickResolutionType.md +35 -0
  23. package/docs/api/enumerations/GamePickScoreType.md +19 -0
  24. package/docs/api/enumerations/GamePickSportType.md +375 -0
  25. package/docs/api/enumerations/GameRoundOrderType.md +35 -0
  26. package/docs/api/enumerations/LiquidEntityData.md +6 -0
  27. package/docs/api/interfaces/AvatarCustomized.md +2 -2
  28. package/docs/api/interfaces/GamePickBoardUser.md +75 -0
  29. package/docs/api/interfaces/GamePickEvent.md +123 -0
  30. package/docs/api/interfaces/GamePickEventMeta.md +201 -0
  31. package/docs/api/interfaces/GamePickGameInfo.md +27 -0
  32. package/docs/api/interfaces/GamePickRequestParams.md +39 -0
  33. package/docs/api/interfaces/GamePickRound.md +383 -0
  34. package/docs/api/interfaces/GamePickRoundBase.md +232 -0
  35. package/docs/api/interfaces/GamePickRoundBoard.md +359 -0
  36. package/docs/api/interfaces/GamePickRoundPublicMeta.md +103 -0
  37. package/docs/api/interfaces/GamePickRoundRequestParams.md +63 -0
  38. package/docs/api/interfaces/GamePickUserInfo.md +107 -0
  39. package/docs/api/interfaces/GamesApiResponse.md +33 -0
  40. package/docs/api/interfaces/GemsDiamondsLog.md +2 -0
  41. package/docs/api/interfaces/Level.md +8 -0
  42. package/docs/api/interfaces/PointsLog.md +2 -0
  43. package/docs/api/interfaces/QuizEventMeta.md +61 -0
  44. package/docs/api/interfaces/RafflePrizePublicMeta.md +9 -0
  45. package/docs/api/interfaces/TAvatarCustomized.md +2 -2
  46. package/docs/api/interfaces/TInboxMessage.md +2 -1
  47. package/docs/api/interfaces/TMiniGamePlayResult.md +11 -0
  48. package/docs/api/interfaces/TMissionOrBadge.md +3 -1
  49. package/docs/api/interfaces/TRafflePrize.md +9 -0
  50. package/docs/api/variables/AllRoundsGameBoardID.md +5 -0
  51. package/docs/ui/minigames/UIGuide_playMiniGame.md +6 -5
  52. package/package.json +1 -1
  53. package/src/ActivityLog/ActivityLogEntry.ts +2 -0
  54. package/src/Avatars/AvatarCustomized.ts +2 -2
  55. package/src/Core/index.ts +1 -0
  56. package/src/GamePick/GamePickTypes.ts +14 -14
  57. package/src/Level/Level.ts +1 -0
  58. package/src/Missions/UserAchievement.ts +2 -2
  59. package/src/SmarticoAPI.ts +2 -1
  60. package/src/SmarticoGlobal.ts +209 -0
  61. package/src/Store/StoreItem.ts +1 -1
  62. package/src/WSAPI/WSAPIAvatars.ts +1 -1
  63. package/src/WSAPI/WSAPIGamePick.ts +6 -6
  64. package/src/WSAPI/WSAPIMiniGames.ts +55 -42
  65. package/src/WSAPI/WSAPITypes.ts +9 -6
  66. package/src/index.ts +21 -0
  67. package/tsconfig.json +1 -0
package/dist/index.js CHANGED
@@ -1064,7 +1064,7 @@ var StoreItemTransform = function StoreItemTransform(items) {
1064
1064
  id: r.id,
1065
1065
  name: r.itemPublicMeta.name,
1066
1066
  purchase_type: mapPurchaseType$1(r.itemPublicMeta.purchase_type),
1067
- price: r.itemPublicMeta.price,
1067
+ price: Number(r.itemPublicMeta.price),
1068
1068
  image: r.itemPublicMeta.image_url,
1069
1069
  description: r.itemPublicMeta.description,
1070
1070
  ribbon: r.itemPublicMeta.label_tag === 'custom' ? r.itemPublicMeta.custom_label_tag : r.itemPublicMeta.label_tag,
@@ -7533,63 +7533,76 @@ var WSAPIMiniGames = /*#__PURE__*/function (_WSAPIRaffles) {
7533
7533
  }
7534
7534
  }
7535
7535
  /**
7536
- * Manually acknowledges a mini-game spin — marks the spin as
7537
- * "delivered" so the prize takes effect server-side. Most consumers
7538
- * do NOT need to call this method directly; {@link playMiniGame}
7539
- * and {@link playMiniGameBatch} auto-acknowledge on success. Use
7540
- * this only for recovery scenarios.
7536
+ * Manually acknowledges a mini-game spin — marks the win delivered
7537
+ * server-side. Most consumers do NOT need this: {@link playMiniGame}
7538
+ * acknowledges by default (`acknowledge: true`) and
7539
+ * {@link playMiniGameBatch} acknowledges automatically. Call this
7540
+ * directly only when you took ownership of the acknowledge step or
7541
+ * need to recover a lost one.
7541
7542
  *
7542
7543
  * @remarks
7543
7544
  * **When to call**
7544
- * - **Lost auto-acknowledge** — when the WebSocket dropped between
7545
- * the spin response and the auto-acknowledge fire-and-forget,
7546
- * the spin shows `is_claimed: false` in
7547
- * {@link getMiniGamesHistory}. Pass that row's
7548
- * `client_request_id` here to deliver the prize.
7549
- * - **Explicit-acknowledge UI** — for templates configured with
7550
- * the `ExplicitAcknowledge` acknowledge type (operator
7551
- * decision), the consumer's UI shows a "Claim" CTA after the
7552
- * prize animation. Click handler calls this method with the
7553
- * spin's `client_request_id` rather than auto-acknowledging.
7554
- *
7555
- * **No-op on already-acknowledged spins**
7556
- * The server's acknowledge SQL matches on `acknowledge_date IS
7557
- * NULL` — a duplicate call returns successfully with no effect.
7545
+ * - **Primary — after `playMiniGame(..., { acknowledge: false })`.**
7546
+ * You opted out of the automatic acknowledge to finalise the win
7547
+ * on your own schedule (e.g. on a user "Claim" tap). Pass the
7548
+ * `request_id` from that call's result here when ready. This is
7549
+ * REQUIRED for operator-configured "explicit claim" prizes — they
7550
+ * are not covered by the server-side fallback, so without this
7551
+ * call their prize is never credited.
7552
+ * - **Recovery — a lost acknowledge.** {@link playMiniGameBatch}
7553
+ * acknowledges on a fire-and-forget basis; if one is lost (network
7554
+ * drop) the spin shows `is_claimed: false` in
7555
+ * {@link getMiniGamesHistory}. Pass that row's `client_request_id`
7556
+ * to deliver it.
7557
+ *
7558
+ * The `request_id` on a {@link playMiniGame} result and the
7559
+ * `client_request_id` on a {@link getMiniGamesHistory} row are the
7560
+ * same correlation id — this method accepts either.
7561
+ *
7562
+ * **Idempotency**: safe. Acknowledging a spin that is already
7563
+ * finalised — by you, by the automatic acknowledge, or by the
7564
+ * fallback — is a no-op with no double credit. Acknowledging a
7565
+ * failed spin's id is likewise a no-op.
7558
7566
  *
7559
7567
  * **Server-side fallback**
7560
- * Even without ever calling this method, a server-side job
7561
- * auto-acknowledges stale spins every ~60 seconds — so prizes are
7562
- * eventually delivered. The `is_claimed` flag flips on the next
7563
- * `getMiniGamesHistory` call after the job runs.
7564
- *
7565
- * **Idempotency**: safe. Repeated calls have no effect after the
7566
- * first.
7567
- *
7568
- * **Side effects** (on first successful call for an unacknowledged
7569
- * spin)
7570
- * - Prize value credited per the prize's type (see
7571
- * {@link playMiniGame} "Prize handling").
7572
- * - The spin's `is_claimed` flag flips to `true` on the next
7573
- * {@link getMiniGamesHistory} call.
7568
+ * Even if you never call this, a server-side job finalises ordinary
7569
+ * un-acknowledged spins automatically after a short delay (about 1–3
7570
+ * minutes), flipping `is_claimed` to `true` on the next
7571
+ * {@link getMiniGamesHistory} fetch. "Explicit claim" prizes are the
7572
+ * exception — excluded from the fallback, they require an explicit
7573
+ * call here.
7574
+ *
7575
+ * **Side effects** (first successful call for an un-acknowledged spin)
7576
+ * - For "explicit claim" prizes, the prize value is credited on this
7577
+ * call. For standard prizes the value was already credited at spin
7578
+ * time (see {@link playMiniGame} "Prize handling"); this call only
7579
+ * marks the win delivered.
7580
+ * - The spin's `is_claimed` flips to `true` on the next
7581
+ * {@link getMiniGamesHistory} fetch.
7574
7582
  *
7575
7583
  * **Visitor mode**: not supported.
7576
7584
  *
7577
- * @param request_id The `client_request_id` from a `TSawHistory`
7578
- * row returned by {@link getMiniGamesHistory}.
7585
+ * @param request_id Correlation id of the spin to finalise: the
7586
+ * `request_id` from a {@link playMiniGame} result
7587
+ * (played with `acknowledge: false`), or the
7588
+ * `client_request_id` of a
7589
+ * {@link getMiniGamesHistory} row.
7579
7590
  *
7580
7591
  * @example
7581
7592
  * ```ts
7582
- * const history = await window._smartico.api.getMiniGamesHistory({ limit: 20 });
7583
- * const unacknowledged = history.filter(h => !h.is_claimed);
7593
+ * // Primary — finalise a win you played with acknowledge: false.
7594
+ * const r = await window._smartico.api.playMiniGame(templateId, { acknowledge: false });
7595
+ * if (r.err_code === 0) {
7596
+ * console.log('[smartico] show the prize / Claim CTA; on Claim, finalise the win');
7597
+ * await window._smartico.api.miniGameWinAcknowledgeRequest(r.request_id);
7598
+ * }
7584
7599
  *
7585
- * for (const row of unacknowledged) {
7600
+ * // Recovery — re-acknowledge any spins a batch acknowledge missed.
7601
+ * const history = await window._smartico.api.getMiniGamesHistory({ limit: 20 });
7602
+ * for (const row of history.filter(h => !h.is_claimed)) {
7586
7603
  * console.log('[smartico] re-acknowledging stale spin', row.client_request_id);
7587
7604
  * await window._smartico.api.miniGameWinAcknowledgeRequest(row.client_request_id);
7588
7605
  * }
7589
- *
7590
- * // Re-fetch history to see the updated is_claimed flags.
7591
- * const fresh = await window._smartico.api.getMiniGamesHistory({ limit: 20 });
7592
- * console.log('[smartico] history after recovery —', fresh.filter(h => !h.is_claimed).length, 'still unacknowledged');
7593
7606
  * ```
7594
7607
  */
7595
7608
  ;
@@ -7902,7 +7915,7 @@ var WSAPIAvatars = /*#__PURE__*/function (_WSAPIMiniGames) {
7902
7915
  *
7903
7916
  * // Newest-first within each base.
7904
7917
  * for (const list of byBase.values()) {
7905
- * list.sort((a, b) => b.dt_created.localeCompare(a.dt_created));
7918
+ * list.sort((a, b) => b.dt_created - a.dt_created);
7906
7919
  * }
7907
7920
  *
7908
7921
  * console.log('[smartico] AI variants by base avatar — render as a carousel under each base');
@@ -8561,9 +8574,9 @@ var WSAPIGamePick = /*#__PURE__*/function (_WSAPIAvatars) {
8561
8574
  * **Side effects**
8562
8575
  * - First successful submit deducts the buy-in (Points / Gems / Diamonds /
8563
8576
  * one Spin) per `saw_buyin_type_id`.
8564
- * - Reports a `minigame_matchx_prediction` event to the operator's event log.
8565
- * - Updates the round's participant counter (`users_cnt`) and per-event
8566
- * counters (`num_users`).
8577
+ * - Records the user's participation against the round and its events
8578
+ * server-side and reports a prediction event to the operator's activity
8579
+ * stream.
8567
8580
  * - Score is awarded after the operator resolves the round
8568
8581
  * ({@link GPRoundStatus} = `RoundResolved`).
8569
8582
  *
@@ -8668,9 +8681,9 @@ var WSAPIGamePick = /*#__PURE__*/function (_WSAPIAvatars) {
8668
8681
  * **Idempotency**: identical to {@link gamePickSubmitSelection} — re-submit
8669
8682
  * returns `errCode: 3` and never double-charges the buy-in.
8670
8683
  *
8671
- * **Side effects**: identical to {@link gamePickSubmitSelection}, with the
8672
- * reported event being `minigame_quiz_prediction` instead of
8673
- * `minigame_matchx_prediction`.
8684
+ * **Side effects**: identical to {@link gamePickSubmitSelection} — buy-in
8685
+ * deduction on first submit, participation recorded, score awarded on round
8686
+ * resolution.
8674
8687
  *
8675
8688
  * **Visitor mode**: not supported.
8676
8689
  *
@@ -11668,10 +11681,13 @@ var SmarticoAPI = /*#__PURE__*/function () {
11668
11681
  body: JSON.stringify(params)
11669
11682
  };
11670
11683
  } else if (params) {
11671
- var extraQuery = Object.entries(params).map(function (_ref5) {
11672
- var k = _ref5[0],
11673
- v = _ref5[1];
11674
- return k + "=" + encodeURIComponent(JSON.stringify(v));
11684
+ var extraQuery = Object.entries(params).filter(function (_ref5) {
11685
+ var v = _ref5[1];
11686
+ return v !== null && v !== undefined;
11687
+ }).map(function (_ref6) {
11688
+ var k = _ref6[0],
11689
+ v = _ref6[1];
11690
+ return k + "=" + encodeURIComponent(typeof v === 'object' ? JSON.stringify(v) : v);
11675
11691
  }).join('&');
11676
11692
  url += "&" + extraQuery;
11677
11693
  }
@@ -11692,9 +11708,9 @@ var SmarticoAPI = /*#__PURE__*/function () {
11692
11708
  return Promise.reject(e);
11693
11709
  }
11694
11710
  };
11695
- _proto.sendAvatarApi = function sendAvatarApi(_ref6) {
11696
- var method = _ref6.method,
11697
- body = _ref6.body;
11711
+ _proto.sendAvatarApi = function sendAvatarApi(_ref7) {
11712
+ var method = _ref7.method,
11713
+ body = _ref7.body;
11698
11714
  try {
11699
11715
  var _this75 = this;
11700
11716
  if (!_this75.tracker) {