@smartico/public-api 0.0.397 → 0.0.399

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.
@@ -9,4 +9,5 @@ export interface Level {
9
9
  required_level_counter_1: number;
10
10
  required_level_counter_2: number;
11
11
  general_level_progress: number;
12
+ ordinal_position?: number;
12
13
  }
@@ -177,10 +177,12 @@ export declare class WSAPIMiniGames extends WSAPIRaffles {
177
177
  /**
178
178
  * Plays one round of a mini-game template — runs the server's
179
179
  * randomised prize selection, deducts the buy-in cost (if any),
180
- * and returns the won `prize_id`. After the play resolves, the SDK
181
- * automatically fires a server-side acknowledgement on a
182
- * fire-and-forget basis, marking the spin as "delivered" so the
183
- * prize takes effect.
180
+ * credits the won prize, and returns the won `prize_id`. By default
181
+ * (`acknowledge: true`) the SDK then sends a server-side
182
+ * acknowledgement and AWAITS it before resolving, so the win is
183
+ * marked delivered by the time the promise settles. Pass
184
+ * `acknowledge: false` to skip that step and finalise the win
185
+ * yourself later (see the `acknowledge` parameter).
184
186
  *
185
187
  * Works for all `SAWGameType` values EXCEPT:
186
188
  * - `PrizeDrop` — prizes arrive server-pushed; do NOT call
@@ -244,17 +246,36 @@ export declare class WSAPIMiniGames extends WSAPIRaffles {
244
246
  * corresponding domain methods.
245
247
  * - `'manual'` — operator delivers offline.
246
248
  *
247
- * **Auto-acknowledge**
248
- * The SDK calls the server's acknowledge endpoint immediately
249
- * after the spin response, on a fire-and-forget basis (not
250
- * awaited). This marks the spin as "delivered" so prize effects
251
- * take hold. If the auto-acknowledge fails (network drop), the
252
- * spin appears as `is_claimed: false` in
253
- * {@link getMiniGamesHistory}; the consumer can recover it by
254
- * passing the `client_request_id` to
255
- * {@link miniGameWinAcknowledgeRequest}. A server-side fallback
256
- * job auto-acknowledges stale spins every ~60 seconds, so prizes
257
- * are eventually delivered even without consumer action.
249
+ * **Acknowledge** (the `acknowledge` parameter, default `true`)
250
+ * Every spin is finalised by a follow-up acknowledge step that
251
+ * marks the win delivered. By default the SDK sends that
252
+ * acknowledge and AWAITS it, so `playMiniGame` resolves only after
253
+ * the win is finalised server-side. Keep the default unless you
254
+ * have a specific reason not to.
255
+ *
256
+ * Pass `acknowledge: false` to skip that automatic step.
257
+ * `playMiniGame` then resolves as soon as the spin result is known,
258
+ * without waiting for the win to be marked delivered. You finalise
259
+ * it later by calling {@link miniGameWinAcknowledgeRequest}. The
260
+ * result does NOT carry the spin's request id — obtain it as the
261
+ * `client_request_id` of the matching {@link getMiniGamesHistory}
262
+ * row (the spin appears there with `is_claimed: false`).
263
+ *
264
+ * What `acknowledge: false` does and does NOT defer:
265
+ * - For STANDARD prizes the value is credited at spin time
266
+ * regardless, so opting out does NOT delay the balance change —
267
+ * it only defers the "delivered" bookkeeping and the `is_claimed`
268
+ * flag flipping in {@link getMiniGamesHistory}.
269
+ * - For operator-configured "explicit claim" prizes the credit IS
270
+ * deferred until the spin is acknowledged, so those require an
271
+ * explicit acknowledge to finalise.
272
+ *
273
+ * A server-side fallback auto-acknowledges ordinary un-acknowledged
274
+ * spins after a short delay (about 1–3 minutes), so an ordinary
275
+ * prize is never lost even without consumer action. "Explicit
276
+ * claim" prizes are excluded from that fallback — if you use
277
+ * `acknowledge: false` for one, you MUST acknowledge it explicitly
278
+ * or its prize is never credited.
258
279
  *
259
280
  * **Idempotency**: NOT idempotent. A double-click sends two
260
281
  * spins and deducts the buy-in twice. The SDK does NOT guard
@@ -273,25 +294,33 @@ export declare class WSAPIMiniGames extends WSAPIRaffles {
273
294
  * refreshed array.
274
295
  *
275
296
  * **Side effects** (on `err_code === 0`)
276
- * - Buy-in deducted from the user's balance (points / gems /
277
- * diamonds / spin tickets — depending on `saw_buyin_type`).
278
- * Balance updates flow via the user-properties channel
279
- * (subscribe to {@link getUserProfile} `props_change` to
280
- * observe).
281
- * - Prize value credited per the prize's type (see "Prize
282
- * handling" above).
283
- * - A `minigame_attempt` analytics event fires server-side with
284
- * the result status.
297
+ * - Buy-in deducted at spin time (points / gems / diamonds / spin
298
+ * tickets — depending on `saw_buyin_type`), already applied by the
299
+ * time the call resolves. Balance updates flow via the
300
+ * user-properties channel (observe via {@link getUserProfile}).
301
+ * - Prize value credited per the prize's type (see "Prize handling"
302
+ * above). Standard prizes are credited at spin time; "explicit
303
+ * claim" prizes are credited when the spin is acknowledged.
304
+ * - The play is recorded server-side for analytics / reporting.
285
305
  *
286
306
  * **UI guidance**: see [UI Guide — `playMiniGame`](../../docs/ui/minigames/UIGuide_playMiniGame.md).
287
307
  *
288
308
  * **Visitor mode**: not supported. Visitor sessions trying to
289
309
  * spin receive `SAW_VISITOR_STOP_SPIN_REQUEST (-40001)`.
290
310
  *
291
- * @param template_id The mini-game template ID (from
292
- * `TMiniGameTemplate.id`).
293
- * @param params Optional. Pass an `onUpdate` callback to
294
- * subscribe to subsequent template refreshes.
311
+ * @param template_id The mini-game template ID (from
312
+ * `TMiniGameTemplate.id`).
313
+ * @param params Optional options bag.
314
+ * @param params.onUpdate Pass a callback to subscribe to
315
+ * subsequent template refreshes (same
316
+ * channel as {@link getMiniGames}).
317
+ * @param params.acknowledge Whether the SDK automatically sends and
318
+ * awaits the win acknowledge after the
319
+ * spin. Defaults to `true` (recommended).
320
+ * Set `false` to finalise the win yourself
321
+ * via {@link miniGameWinAcknowledgeRequest}
322
+ * — see "Acknowledge" above for the
323
+ * request-id caveat.
295
324
  * @returns `{ err_code, err_message, prize_id }` — success when
296
325
  * `err_code === 0`. `prize_id` is always populated; look
297
326
  * it up in `template.prizes` to interpret the prize.
@@ -333,9 +362,30 @@ export declare class WSAPIMiniGames extends WSAPIRaffles {
333
362
  * console.error('[smartico] play failed — show generic error with this message:', r.err_message);
334
363
  * }
335
364
  * ```
365
+ *
366
+ * @example
367
+ * Manual finalisation (`acknowledge: false`) — e.g. an explicit
368
+ * "Claim" CTA, or finalising on your own schedule:
369
+ * ```ts
370
+ * const r = await window._smartico.api.playMiniGame(game.id, { acknowledge: false });
371
+ * if (r.err_code === 0) {
372
+ * // Spin resolved but not yet acknowledged. For standard prizes the
373
+ * // balance already changed server-side; "explicit claim" prizes
374
+ * // are credited only by the acknowledge below.
375
+ * console.log('[smartico] prize won — show the result / Claim CTA, then finalise');
376
+ *
377
+ * // The result has no request id — read it from history as client_request_id.
378
+ * const [row] = await window._smartico.api.getMiniGamesHistory({ saw_template_id: game.id, limit: 1 });
379
+ * if (row && !row.is_claimed) {
380
+ * await window._smartico.api.miniGameWinAcknowledgeRequest(row.client_request_id);
381
+ * console.log('[smartico] win finalised — refresh getUserProfile / getMiniGames to reflect it');
382
+ * }
383
+ * }
384
+ * ```
336
385
  */
337
- playMiniGame(template_id: number, { onUpdate }?: {
386
+ playMiniGame(template_id: number, { onUpdate, acknowledge }?: {
338
387
  onUpdate?: (data: TMiniGameTemplate[]) => void;
388
+ acknowledge?: boolean;
339
389
  }): Promise<TMiniGamePlayResult>;
340
390
  /**
341
391
  * Manually acknowledges a mini-game spin — marks the spin as
package/dist/index.js CHANGED
@@ -7299,10 +7299,12 @@ var WSAPIMiniGames = /*#__PURE__*/function (_WSAPIRaffles) {
7299
7299
  /**
7300
7300
  * Plays one round of a mini-game template — runs the server's
7301
7301
  * randomised prize selection, deducts the buy-in cost (if any),
7302
- * and returns the won `prize_id`. After the play resolves, the SDK
7303
- * automatically fires a server-side acknowledgement on a
7304
- * fire-and-forget basis, marking the spin as "delivered" so the
7305
- * prize takes effect.
7302
+ * credits the won prize, and returns the won `prize_id`. By default
7303
+ * (`acknowledge: true`) the SDK then sends a server-side
7304
+ * acknowledgement and AWAITS it before resolving, so the win is
7305
+ * marked delivered by the time the promise settles. Pass
7306
+ * `acknowledge: false` to skip that step and finalise the win
7307
+ * yourself later (see the `acknowledge` parameter).
7306
7308
  *
7307
7309
  * Works for all `SAWGameType` values EXCEPT:
7308
7310
  * - `PrizeDrop` — prizes arrive server-pushed; do NOT call
@@ -7366,17 +7368,36 @@ var WSAPIMiniGames = /*#__PURE__*/function (_WSAPIRaffles) {
7366
7368
  * corresponding domain methods.
7367
7369
  * - `'manual'` — operator delivers offline.
7368
7370
  *
7369
- * **Auto-acknowledge**
7370
- * The SDK calls the server's acknowledge endpoint immediately
7371
- * after the spin response, on a fire-and-forget basis (not
7372
- * awaited). This marks the spin as "delivered" so prize effects
7373
- * take hold. If the auto-acknowledge fails (network drop), the
7374
- * spin appears as `is_claimed: false` in
7375
- * {@link getMiniGamesHistory}; the consumer can recover it by
7376
- * passing the `client_request_id` to
7377
- * {@link miniGameWinAcknowledgeRequest}. A server-side fallback
7378
- * job auto-acknowledges stale spins every ~60 seconds, so prizes
7379
- * are eventually delivered even without consumer action.
7371
+ * **Acknowledge** (the `acknowledge` parameter, default `true`)
7372
+ * Every spin is finalised by a follow-up acknowledge step that
7373
+ * marks the win delivered. By default the SDK sends that
7374
+ * acknowledge and AWAITS it, so `playMiniGame` resolves only after
7375
+ * the win is finalised server-side. Keep the default unless you
7376
+ * have a specific reason not to.
7377
+ *
7378
+ * Pass `acknowledge: false` to skip that automatic step.
7379
+ * `playMiniGame` then resolves as soon as the spin result is known,
7380
+ * without waiting for the win to be marked delivered. You finalise
7381
+ * it later by calling {@link miniGameWinAcknowledgeRequest}. The
7382
+ * result does NOT carry the spin's request id — obtain it as the
7383
+ * `client_request_id` of the matching {@link getMiniGamesHistory}
7384
+ * row (the spin appears there with `is_claimed: false`).
7385
+ *
7386
+ * What `acknowledge: false` does and does NOT defer:
7387
+ * - For STANDARD prizes the value is credited at spin time
7388
+ * regardless, so opting out does NOT delay the balance change —
7389
+ * it only defers the "delivered" bookkeeping and the `is_claimed`
7390
+ * flag flipping in {@link getMiniGamesHistory}.
7391
+ * - For operator-configured "explicit claim" prizes the credit IS
7392
+ * deferred until the spin is acknowledged, so those require an
7393
+ * explicit acknowledge to finalise.
7394
+ *
7395
+ * A server-side fallback auto-acknowledges ordinary un-acknowledged
7396
+ * spins after a short delay (about 1–3 minutes), so an ordinary
7397
+ * prize is never lost even without consumer action. "Explicit
7398
+ * claim" prizes are excluded from that fallback — if you use
7399
+ * `acknowledge: false` for one, you MUST acknowledge it explicitly
7400
+ * or its prize is never credited.
7380
7401
  *
7381
7402
  * **Idempotency**: NOT idempotent. A double-click sends two
7382
7403
  * spins and deducts the buy-in twice. The SDK does NOT guard
@@ -7395,25 +7416,33 @@ var WSAPIMiniGames = /*#__PURE__*/function (_WSAPIRaffles) {
7395
7416
  * refreshed array.
7396
7417
  *
7397
7418
  * **Side effects** (on `err_code === 0`)
7398
- * - Buy-in deducted from the user's balance (points / gems /
7399
- * diamonds / spin tickets — depending on `saw_buyin_type`).
7400
- * Balance updates flow via the user-properties channel
7401
- * (subscribe to {@link getUserProfile} `props_change` to
7402
- * observe).
7403
- * - Prize value credited per the prize's type (see "Prize
7404
- * handling" above).
7405
- * - A `minigame_attempt` analytics event fires server-side with
7406
- * the result status.
7419
+ * - Buy-in deducted at spin time (points / gems / diamonds / spin
7420
+ * tickets — depending on `saw_buyin_type`), already applied by the
7421
+ * time the call resolves. Balance updates flow via the
7422
+ * user-properties channel (observe via {@link getUserProfile}).
7423
+ * - Prize value credited per the prize's type (see "Prize handling"
7424
+ * above). Standard prizes are credited at spin time; "explicit
7425
+ * claim" prizes are credited when the spin is acknowledged.
7426
+ * - The play is recorded server-side for analytics / reporting.
7407
7427
  *
7408
7428
  * **UI guidance**: see [UI Guide — `playMiniGame`](../../docs/ui/minigames/UIGuide_playMiniGame.md).
7409
7429
  *
7410
7430
  * **Visitor mode**: not supported. Visitor sessions trying to
7411
7431
  * spin receive `SAW_VISITOR_STOP_SPIN_REQUEST (-40001)`.
7412
7432
  *
7413
- * @param template_id The mini-game template ID (from
7414
- * `TMiniGameTemplate.id`).
7415
- * @param params Optional. Pass an `onUpdate` callback to
7416
- * subscribe to subsequent template refreshes.
7433
+ * @param template_id The mini-game template ID (from
7434
+ * `TMiniGameTemplate.id`).
7435
+ * @param params Optional options bag.
7436
+ * @param params.onUpdate Pass a callback to subscribe to
7437
+ * subsequent template refreshes (same
7438
+ * channel as {@link getMiniGames}).
7439
+ * @param params.acknowledge Whether the SDK automatically sends and
7440
+ * awaits the win acknowledge after the
7441
+ * spin. Defaults to `true` (recommended).
7442
+ * Set `false` to finalise the win yourself
7443
+ * via {@link miniGameWinAcknowledgeRequest}
7444
+ * — see "Acknowledge" above for the
7445
+ * request-id caveat.
7417
7446
  * @returns `{ err_code, err_message, prize_id }` — success when
7418
7447
  * `err_code === 0`. `prize_id` is always populated; look
7419
7448
  * it up in `template.prizes` to interpret the prize.
@@ -7455,23 +7484,53 @@ var WSAPIMiniGames = /*#__PURE__*/function (_WSAPIRaffles) {
7455
7484
  * console.error('[smartico] play failed — show generic error with this message:', r.err_message);
7456
7485
  * }
7457
7486
  * ```
7487
+ *
7488
+ * @example
7489
+ * Manual finalisation (`acknowledge: false`) — e.g. an explicit
7490
+ * "Claim" CTA, or finalising on your own schedule:
7491
+ * ```ts
7492
+ * const r = await window._smartico.api.playMiniGame(game.id, { acknowledge: false });
7493
+ * if (r.err_code === 0) {
7494
+ * // Spin resolved but not yet acknowledged. For standard prizes the
7495
+ * // balance already changed server-side; "explicit claim" prizes
7496
+ * // are credited only by the acknowledge below.
7497
+ * console.log('[smartico] prize won — show the result / Claim CTA, then finalise');
7498
+ *
7499
+ * // The result has no request id — read it from history as client_request_id.
7500
+ * const [row] = await window._smartico.api.getMiniGamesHistory({ saw_template_id: game.id, limit: 1 });
7501
+ * if (row && !row.is_claimed) {
7502
+ * await window._smartico.api.miniGameWinAcknowledgeRequest(row.client_request_id);
7503
+ * console.log('[smartico] win finalised — refresh getUserProfile / getMiniGames to reflect it');
7504
+ * }
7505
+ * }
7506
+ * ```
7458
7507
  */
7459
7508
  ;
7460
- _proto.playMiniGame = function playMiniGame(template_id, _temp2) {
7461
- var _ref3 = _temp2 === void 0 ? {} : _temp2,
7462
- onUpdate = _ref3.onUpdate;
7509
+ _proto.playMiniGame = function playMiniGame(template_id, _temp4) {
7510
+ var _ref3 = _temp4 === void 0 ? {} : _temp4,
7511
+ onUpdate = _ref3.onUpdate,
7512
+ _ref3$acknowledge = _ref3.acknowledge,
7513
+ acknowledge = _ref3$acknowledge === void 0 ? true : _ref3$acknowledge;
7463
7514
  try {
7464
7515
  var _this3 = this;
7465
7516
  if (typeof onUpdate === 'function') {
7466
7517
  _this3.onUpdateCallback.set(onUpdateContextKey.Saw, onUpdate);
7467
7518
  }
7468
7519
  return Promise.resolve(_this3.api.sawSpinRequest(_this3.userExtId, template_id)).then(function (r) {
7469
- var o = {
7470
- err_code: r.errCode,
7471
- err_message: r.errMsg,
7472
- prize_id: r.saw_prize_id
7473
- };
7474
- return o;
7520
+ function _temp3() {
7521
+ var o = {
7522
+ err_code: r.errCode,
7523
+ err_message: r.errMsg,
7524
+ prize_id: r.saw_prize_id
7525
+ };
7526
+ return o;
7527
+ }
7528
+ var _temp2 = function () {
7529
+ if (acknowledge) {
7530
+ return Promise.resolve(_this3.api.doAcknowledgeRequest(_this3.userExtId, r.request_id)).then(function () {});
7531
+ }
7532
+ }();
7533
+ return _temp2 && _temp2.then ? _temp2.then(_temp3) : _temp3(_temp2);
7475
7534
  });
7476
7535
  } catch (e) {
7477
7536
  return Promise.reject(e);
@@ -7651,8 +7710,8 @@ var WSAPIMiniGames = /*#__PURE__*/function (_WSAPIRaffles) {
7651
7710
  * ```
7652
7711
  */
7653
7712
  ;
7654
- _proto.playMiniGameBatch = function playMiniGameBatch(template_id, spin_count, _temp3) {
7655
- var _ref4 = _temp3 === void 0 ? {} : _temp3,
7713
+ _proto.playMiniGameBatch = function playMiniGameBatch(template_id, spin_count, _temp5) {
7714
+ var _ref4 = _temp5 === void 0 ? {} : _temp5,
7656
7715
  onUpdate = _ref4.onUpdate;
7657
7716
  try {
7658
7717
  var _this5 = this;