@smartico/public-api 0.0.409 → 0.0.410
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/MiniGames/SAWDoAknowledgeRequest.d.ts +2 -0
- package/dist/MiniGames/SAWPrize.d.ts +9 -0
- package/dist/MiniGames/SAWTemplate.d.ts +1 -0
- package/dist/SmarticoAPI.d.ts +1 -1
- package/dist/SmarticoLib/index.d.ts +1 -1
- package/dist/WSAPI/WSAPIJackpots.d.ts +11 -2
- package/dist/WSAPI/WSAPIMiniGames.d.ts +86 -23
- package/dist/WSAPI/WSAPITypes.d.ts +12 -12
- package/dist/index.js +104 -31
- package/dist/index.js.map +1 -1
- package/dist/index.modern.mjs +101 -28
- package/dist/index.modern.mjs.map +1 -1
- package/docs/api/classes/WSAPIJackpots.md +11 -2
- package/docs/api/classes/WSAPIMiniGames.md +86 -23
- package/docs/api/interfaces/SAWDoAknowledgeRequest.md +8 -0
- package/docs/api/interfaces/SAWPrize.md +18 -0
- package/docs/api/interfaces/SAWTemplate.md +2 -0
- package/docs/api/interfaces/TMiniGamePrize.md +25 -9
- package/docs/api/interfaces/TMiniGameTemplate.md +3 -3
- package/docs/capabilities/getJackpotEligibleGames.md +11 -2
- package/docs/capabilities/getMiniGames.md +35 -12
- package/docs/capabilities/miniGameWinAcknowledgeRequest.md +30 -7
- package/docs/capabilities/playMiniGame.md +27 -14
- package/docs/native/PROTOCOL.md +3 -0
- package/docs/ui/jackpots/UIGuide_getJackpotEligibleGames.md +8 -0
- package/docs/ui/minigames/UIGuide_getMiniGames.md +24 -0
- package/docs/ui/minigames/UIGuide_getMiniGamesHistory.md +1 -1
- package/docs/ui/minigames/UIGuide_playMiniGame.md +28 -1
- package/package.json +1 -1
- package/src/MiniGames/SAWDoAknowledgeRequest.ts +2 -0
- package/src/MiniGames/SAWPrize.ts +9 -0
- package/src/MiniGames/SAWTemplate.ts +1 -0
- package/src/SmarticoAPI.ts +2 -1
- package/src/SmarticoLib/index.ts +1 -1
- package/src/WSAPI/WSAPIJackpots.ts +11 -2
- package/src/WSAPI/WSAPIMiniGames.ts +85 -24
- package/src/WSAPI/WSAPITypes.ts +12 -12
package/dist/index.modern.mjs
CHANGED
|
@@ -5990,7 +5990,7 @@ class WSAPIJackpots extends WSAPIClans {
|
|
|
5990
5990
|
*
|
|
5991
5991
|
* @remarks
|
|
5992
5992
|
* **Preconditions**
|
|
5993
|
-
* -
|
|
5993
|
+
* - No authentication required — works in both identified and visitor mode.
|
|
5994
5994
|
* - `jp_template_id` is mandatory.
|
|
5995
5995
|
*
|
|
5996
5996
|
* **`onUpdate` caveat**
|
|
@@ -6008,7 +6008,12 @@ class WSAPIJackpots extends WSAPIClans {
|
|
|
6008
6008
|
* Non-zero `errCode` on control-group users or generic server errors.
|
|
6009
6009
|
* Branch on `errCode === 0` and surface `errMsg` on failure.
|
|
6010
6010
|
*
|
|
6011
|
-
* **Visitor mode**:
|
|
6011
|
+
* **Visitor mode**: supported via
|
|
6012
|
+
* `_smartico.vapi(lang).getJackpotEligibleGames(...)`. The eligible-games
|
|
6013
|
+
* list is template-level (which games contribute to the pot) and carries no
|
|
6014
|
+
* per-user fields, so a visitor session receives the same list an identified
|
|
6015
|
+
* user would. The `lang` passed to `_smartico.vapi(lang)` drives the
|
|
6016
|
+
* translation of game names.
|
|
6012
6017
|
*
|
|
6013
6018
|
* **UI guidance**: see [UI Guide — `getJackpotEligibleGames`](../../docs/ui/jackpots/UIGuide_getJackpotEligibleGames.md).
|
|
6014
6019
|
*
|
|
@@ -6026,6 +6031,10 @@ class WSAPIJackpots extends WSAPIClans {
|
|
|
6026
6031
|
*
|
|
6027
6032
|
* const r = await window._smartico.api.getJackpotEligibleGames({ jp_template_id: 42 });
|
|
6028
6033
|
* console.log('[smartico] render', r.eligible_games.length, 'eligible game tiles');
|
|
6034
|
+
*
|
|
6035
|
+
* // Visitor mode — same shape, language driven by the vapi(lang) argument
|
|
6036
|
+
* const visitor = await window._smartico.vapi('EN').getJackpotEligibleGames({ jp_template_id: 42 });
|
|
6037
|
+
* console.log('[smartico] visitor eligible games:', visitor.eligible_games.length);
|
|
6029
6038
|
* ```
|
|
6030
6039
|
*/
|
|
6031
6040
|
async getJackpotEligibleGames({
|
|
@@ -6768,6 +6777,27 @@ class WSAPIMiniGames extends WSAPIRaffles {
|
|
|
6768
6777
|
* games server (not this SDK); the SAW spin is fired
|
|
6769
6778
|
* server-internally to deduct the buy-in.
|
|
6770
6779
|
*
|
|
6780
|
+
* **Per-prize statistics (`expose_game_stat_on_api`)**
|
|
6781
|
+
* Each template's `prizes` array always carries the definition
|
|
6782
|
+
* fields — name, icon, `prize_type`, `prize_value`, acknowledge
|
|
6783
|
+
* configuration. The stock-statistics fields are gated by an
|
|
6784
|
+
* operator template setting, surfaced as
|
|
6785
|
+
* `expose_game_stat_on_api`:
|
|
6786
|
+
* - Populated when enabled: `pool` (remaining stock),
|
|
6787
|
+
* `wins_count` (total wins across all players), `weekdays`
|
|
6788
|
+
* (ISO 1–7 days the prize can be won), `active_from_ts` /
|
|
6789
|
+
* `active_till_ts` (prize availability window).
|
|
6790
|
+
* - Omitted when disabled (the default) — this keeps the live
|
|
6791
|
+
* prize economy (stock levels, win rates, schedules) hidden
|
|
6792
|
+
* from players.
|
|
6793
|
+
* - Exception: `pool` is always populated for `MatchX` / `Quiz`
|
|
6794
|
+
* templates, whose game flow needs the remaining stock.
|
|
6795
|
+
* - `pool_initial` is populated regardless of the setting.
|
|
6796
|
+
* When enabled, the values are also kept current — the server
|
|
6797
|
+
* refreshes the prize rows on each fetch and drops its template
|
|
6798
|
+
* caches after every play, so `pool` / `wins_count` are safe to
|
|
6799
|
+
* drive an "X prizes left" scarcity UI.
|
|
6800
|
+
*
|
|
6771
6801
|
* **Cache TTL**: the SDK caches the response for 30 seconds. Cache
|
|
6772
6802
|
* is fully cleared on login / logout.
|
|
6773
6803
|
*
|
|
@@ -6981,14 +7011,19 @@ class WSAPIMiniGames extends WSAPIRaffles {
|
|
|
6981
7011
|
* it later by calling {@link miniGameWinAcknowledgeRequest} with the
|
|
6982
7012
|
* `request_id` returned on this result.
|
|
6983
7013
|
*
|
|
6984
|
-
* What `acknowledge: false`
|
|
6985
|
-
* - For STANDARD prizes the value is credited
|
|
6986
|
-
*
|
|
6987
|
-
*
|
|
6988
|
-
*
|
|
6989
|
-
*
|
|
6990
|
-
*
|
|
6991
|
-
* explicit acknowledge
|
|
7014
|
+
* What `acknowledge: false` defers:
|
|
7015
|
+
* - For STANDARD prizes the value is credited when the spin is
|
|
7016
|
+
* finalised — by your later acknowledge or, failing that, by the
|
|
7017
|
+
* server-side fallback below — so opting out delays the balance
|
|
7018
|
+
* change by at most that fallback window. The `is_claimed` flag in
|
|
7019
|
+
* {@link getMiniGamesHistory} flips on the same finalisation.
|
|
7020
|
+
* - For operator-configured "explicit claim" prizes the credit is
|
|
7021
|
+
* deferred until your explicit acknowledge — the fallback does not
|
|
7022
|
+
* cover them.
|
|
7023
|
+
*
|
|
7024
|
+
* While the spin is un-finalised it can also be finalised as LOST —
|
|
7025
|
+
* prize discarded back to the pool — via
|
|
7026
|
+
* {@link miniGameWinAcknowledgeRequest} with `{ lose: true }`.
|
|
6992
7027
|
*
|
|
6993
7028
|
* A server-side fallback auto-acknowledges ordinary un-acknowledged
|
|
6994
7029
|
* spins after a short delay (about 1–3 minutes), so an ordinary
|
|
@@ -7019,8 +7054,10 @@ class WSAPIMiniGames extends WSAPIRaffles {
|
|
|
7019
7054
|
* time the call resolves. Balance updates flow via the
|
|
7020
7055
|
* user-properties channel (observe via {@link getUserProfile}).
|
|
7021
7056
|
* - Prize value credited per the prize's type (see "Prize handling"
|
|
7022
|
-
* above)
|
|
7023
|
-
*
|
|
7057
|
+
* above) when the spin is finalised — with the default
|
|
7058
|
+
* auto-acknowledge that happens before the call resolves;
|
|
7059
|
+
* "explicit claim" prizes are credited only by an explicit
|
|
7060
|
+
* acknowledge.
|
|
7024
7061
|
* - The play is recorded server-side for analytics / reporting.
|
|
7025
7062
|
*
|
|
7026
7063
|
* **UI guidance**: see [UI Guide — `playMiniGame`](../../docs/ui/minigames/UIGuide_playMiniGame.md).
|
|
@@ -7085,18 +7122,24 @@ class WSAPIMiniGames extends WSAPIRaffles {
|
|
|
7085
7122
|
*
|
|
7086
7123
|
* @example
|
|
7087
7124
|
* Manual finalisation (`acknowledge: false`) — e.g. an explicit
|
|
7088
|
-
* "Claim" CTA, or finalising on your own
|
|
7125
|
+
* "Claim" CTA, a decline/forfeit flow, or finalising on your own
|
|
7126
|
+
* schedule:
|
|
7089
7127
|
* ```ts
|
|
7090
7128
|
* const r = await window._smartico.api.playMiniGame(game.id, { acknowledge: false });
|
|
7091
7129
|
* if (r.err_code === 0) {
|
|
7092
|
-
* // Spin resolved but not yet
|
|
7093
|
-
* //
|
|
7094
|
-
* //
|
|
7130
|
+
* // Spin resolved but not yet finalised — the prize is not credited
|
|
7131
|
+
* // yet. Your acknowledge below credits it (for standard prizes the
|
|
7132
|
+
* // server-side fallback would eventually do the same).
|
|
7095
7133
|
* console.log('[smartico] prize won — show the result / Claim CTA, then finalise');
|
|
7096
7134
|
*
|
|
7097
7135
|
* // On the user's Claim click, finalise with the request_id from the result.
|
|
7098
7136
|
* await window._smartico.api.miniGameWinAcknowledgeRequest(r.request_id);
|
|
7099
7137
|
* console.log('[smartico] win finalised — refresh getUserProfile / getMiniGames to reflect it');
|
|
7138
|
+
*
|
|
7139
|
+
* // Or, if the game flow ends in the player declining / losing the
|
|
7140
|
+
* // drawn prize, finalise the spin as lost instead — the prize is
|
|
7141
|
+
* // not credited and returns to the prize pool:
|
|
7142
|
+
* // await window._smartico.api.miniGameWinAcknowledgeRequest(r.request_id, { lose: true });
|
|
7100
7143
|
* }
|
|
7101
7144
|
* ```
|
|
7102
7145
|
*/
|
|
@@ -7121,9 +7164,10 @@ class WSAPIMiniGames extends WSAPIRaffles {
|
|
|
7121
7164
|
}
|
|
7122
7165
|
/**
|
|
7123
7166
|
* Manually acknowledges a mini-game spin — marks the win delivered
|
|
7124
|
-
* server-side
|
|
7125
|
-
*
|
|
7126
|
-
* {@link
|
|
7167
|
+
* server-side, or (with `lose: true`) finalises it as lost and
|
|
7168
|
+
* returns the prize to the pool. Most consumers do NOT need this:
|
|
7169
|
+
* {@link playMiniGame} acknowledges by default (`acknowledge: true`)
|
|
7170
|
+
* and {@link playMiniGameBatch} acknowledges automatically. Call this
|
|
7127
7171
|
* directly only when you took ownership of the acknowledge step or
|
|
7128
7172
|
* need to recover a lost one.
|
|
7129
7173
|
*
|
|
@@ -7146,6 +7190,23 @@ class WSAPIMiniGames extends WSAPIRaffles {
|
|
|
7146
7190
|
* `client_request_id` on a {@link getMiniGamesHistory} row are the
|
|
7147
7191
|
* same correlation id — this method accepts either.
|
|
7148
7192
|
*
|
|
7193
|
+
* **Finalising as lost (`lose: true`)**
|
|
7194
|
+
* Pass `{ lose: true }` to finalise the spin as LOST instead of won:
|
|
7195
|
+
* the prize is NOT credited and is returned to the game's prize pool
|
|
7196
|
+
* (available again for other players), and the spin fires the
|
|
7197
|
+
* mini-game "lose" engagement event instead of the win one. On the
|
|
7198
|
+
* next {@link getMiniGamesHistory} fetch the row shows `is_claimed:
|
|
7199
|
+
* true` with no prize attached. Use this for game mechanics where the
|
|
7200
|
+
* player can decline or forfeit the drawn prize — e.g. a
|
|
7201
|
+
* gamble/discard step, or a client-driven game where the user's final
|
|
7202
|
+
* action decides whether the pre-drawn prize is actually won. It only
|
|
7203
|
+
* works on a spin that is not yet finalised, so it requires playing
|
|
7204
|
+
* with `acknowledge: false` and calling promptly — once the automatic
|
|
7205
|
+
* acknowledge or the server-side fallback (below) has finalised the
|
|
7206
|
+
* spin, `lose: true` is a no-op and the prize stays credited.
|
|
7207
|
+
* ("Explicit claim" prizes are exempt from the fallback, so for them
|
|
7208
|
+
* there is no time pressure.)
|
|
7209
|
+
*
|
|
7149
7210
|
* **Idempotency**: safe. Acknowledging a spin that is already
|
|
7150
7211
|
* finalised — by you, by the automatic acknowledge, or by the
|
|
7151
7212
|
* fallback — is a no-op with no double credit. Acknowledging a
|
|
@@ -7160,11 +7221,12 @@ class WSAPIMiniGames extends WSAPIRaffles {
|
|
|
7160
7221
|
* call here.
|
|
7161
7222
|
*
|
|
7162
7223
|
* **Side effects** (first successful call for an un-acknowledged spin)
|
|
7163
|
-
* -
|
|
7164
|
-
*
|
|
7165
|
-
*
|
|
7166
|
-
*
|
|
7167
|
-
*
|
|
7224
|
+
* - Default (win): the prize value is credited on this call — this is
|
|
7225
|
+
* the finalisation step that credits standard and "explicit claim"
|
|
7226
|
+
* prizes alike (see {@link playMiniGame} "Prize handling").
|
|
7227
|
+
* - With `lose: true`: no credit; the prize returns to the prize pool
|
|
7228
|
+
* and the "lose" engagement event fires.
|
|
7229
|
+
* - Either way the spin's `is_claimed` flips to `true` on the next
|
|
7168
7230
|
* {@link getMiniGamesHistory} fetch.
|
|
7169
7231
|
*
|
|
7170
7232
|
* **Visitor mode**: not supported.
|
|
@@ -7174,6 +7236,10 @@ class WSAPIMiniGames extends WSAPIRaffles {
|
|
|
7174
7236
|
* (played with `acknowledge: false`), or the
|
|
7175
7237
|
* `client_request_id` of a
|
|
7176
7238
|
* {@link getMiniGamesHistory} row.
|
|
7239
|
+
* @param options.lose Optional. When `true`, finalises the spin as
|
|
7240
|
+
* lost — the prize is not credited and returns
|
|
7241
|
+
* to the prize pool (see "Finalising as lost").
|
|
7242
|
+
* Omit (or pass `false`) to deliver the win.
|
|
7177
7243
|
*
|
|
7178
7244
|
* @example
|
|
7179
7245
|
* ```ts
|
|
@@ -7184,6 +7250,10 @@ class WSAPIMiniGames extends WSAPIRaffles {
|
|
|
7184
7250
|
* await window._smartico.api.miniGameWinAcknowledgeRequest(r.request_id);
|
|
7185
7251
|
* }
|
|
7186
7252
|
*
|
|
7253
|
+
* // Decline / forfeit — finalise the same spin as lost instead:
|
|
7254
|
+
* // the prize is not credited and goes back to the prize pool.
|
|
7255
|
+
* await window._smartico.api.miniGameWinAcknowledgeRequest(r.request_id, { lose: true });
|
|
7256
|
+
*
|
|
7187
7257
|
* // Recovery — re-acknowledge any spins a batch acknowledge missed.
|
|
7188
7258
|
* const history = await window._smartico.api.getMiniGamesHistory({ limit: 20 });
|
|
7189
7259
|
* for (const row of history.filter(h => !h.is_claimed)) {
|
|
@@ -7192,8 +7262,10 @@ class WSAPIMiniGames extends WSAPIRaffles {
|
|
|
7192
7262
|
* }
|
|
7193
7263
|
* ```
|
|
7194
7264
|
*/
|
|
7195
|
-
async miniGameWinAcknowledgeRequest(request_id
|
|
7196
|
-
|
|
7265
|
+
async miniGameWinAcknowledgeRequest(request_id, {
|
|
7266
|
+
lose
|
|
7267
|
+
} = {}) {
|
|
7268
|
+
return this.api.doAcknowledgeRequest(this.userExtId, request_id, lose);
|
|
7197
7269
|
}
|
|
7198
7270
|
/**
|
|
7199
7271
|
* Plays a mini-game template `spin_count` times in one round-trip.
|
|
@@ -9934,9 +10006,10 @@ class SmarticoAPI {
|
|
|
9934
10006
|
async sawGetTemplatesT(user_ext_id) {
|
|
9935
10007
|
return SAWTemplatesTransform((await this.sawGetTemplates(user_ext_id)).templates);
|
|
9936
10008
|
}
|
|
9937
|
-
async doAcknowledgeRequest(user_ext_id, request_id) {
|
|
10009
|
+
async doAcknowledgeRequest(user_ext_id, request_id, lose) {
|
|
9938
10010
|
const message = this.buildMessage(user_ext_id, ClassId.SAW_AKNOWLEDGE_REQUEST, {
|
|
9939
|
-
request_id
|
|
10011
|
+
request_id,
|
|
10012
|
+
lose
|
|
9940
10013
|
});
|
|
9941
10014
|
return await this.send(message, ClassId.SAW_AKNOWLEDGE_RESPONSE);
|
|
9942
10015
|
}
|