@smartico/public-api 0.0.386 → 0.0.388

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 (44) hide show
  1. package/README.md +2 -2
  2. package/dist/Avatars/AvatarCustomizeErrorCode.d.ts +7 -1
  3. package/dist/Avatars/AvatarCustomizeResponse.d.ts +16 -0
  4. package/dist/Avatars/index.d.ts +1 -0
  5. package/dist/CustomSections/AchCustomSection.d.ts +2 -1
  6. package/dist/Missions/UserAchievementTask.d.ts +4 -0
  7. package/dist/SmarticoAPI.d.ts +15 -2
  8. package/dist/WSAPI/WSAPIAvatars.d.ts +103 -0
  9. package/dist/WSAPI/WSAPILeaderBoard.d.ts +76 -10
  10. package/dist/WSAPI/WSAPITypes.d.ts +22 -5
  11. package/dist/index.js +441 -149
  12. package/dist/index.js.map +1 -1
  13. package/dist/index.modern.mjs +280 -29
  14. package/dist/index.modern.mjs.map +1 -1
  15. package/docs/SmarticoObject.md +15 -0
  16. package/docs/api/README.md +2 -0
  17. package/docs/api/classes/WSAPIAvatars.md +135 -0
  18. package/docs/api/classes/WSAPIClans.md +3 -5
  19. package/docs/api/classes/WSAPILeaderBoard.md +86 -10
  20. package/docs/api/documents/SmarticoObject.md +15 -0
  21. package/docs/api/enumerations/AvatarCustomizeErrorCode.md +21 -0
  22. package/docs/api/enumerations/JoinClanErrorCode.md +16 -17
  23. package/docs/api/interfaces/AvatarCustomizeResponse.md +31 -0
  24. package/docs/api/interfaces/LeaderBoardDetailsT.md +19 -0
  25. package/docs/api/interfaces/LeaderBoardUserT.md +14 -2
  26. package/docs/api/interfaces/TAvatarPrompt.md +2 -2
  27. package/docs/api/interfaces/TMissionOrBadgeTask.md +16 -0
  28. package/docs/api/interfaces/UserAchievementTask.md +16 -0
  29. package/docs/native/PROTOCOL.md +37 -7
  30. package/docs/ui/avatars/UIGuide_avatarsCustomize.md +69 -0
  31. package/docs/ui/leaderboard/UIGuide_getLeaderBoard.md +15 -0
  32. package/package.json +1 -1
  33. package/src/Avatars/AvatarCustomizeErrorCode.ts +7 -5
  34. package/src/Avatars/AvatarCustomizeResponse.ts +17 -0
  35. package/src/Avatars/index.ts +1 -0
  36. package/src/CustomSections/AchCustomSection.ts +1 -0
  37. package/src/Leaderboard/LeaderBoards.ts +9 -12
  38. package/src/Missions/UserAchievement.ts +2 -0
  39. package/src/Missions/UserAchievementTask.ts +4 -0
  40. package/src/SmarticoAPI.ts +84 -3
  41. package/src/WSAPI/WSAPIAvatars.ts +121 -0
  42. package/src/WSAPI/WSAPILeaderBoard.ts +91 -14
  43. package/src/WSAPI/WSAPITypes.ts +22 -5
  44. package/tsconfig.json +3 -1
@@ -1616,6 +1616,8 @@ const UserAchievementTransform = items => {
1616
1616
  id: t.task_id,
1617
1617
  name: (_t$task_public_meta = t.task_public_meta) == null ? void 0 : _t$task_public_meta.name,
1618
1618
  points_reward: t.points_reward,
1619
+ gems_reward: t.gems_reward,
1620
+ diamonds_reward: t.diamonds_reward,
1619
1621
  is_completed: t.isCompleted,
1620
1622
  progress: t.userProgress,
1621
1623
  execution_count_expected: t.executionCount,
@@ -2080,33 +2082,33 @@ const pointsRewardTransform = reward_points => {
2080
2082
  };
2081
2083
  const getLeaderBoardPlayerTransformed = (user, isMe) => {
2082
2084
  if (user) {
2083
- const x = {
2085
+ return {
2084
2086
  public_username: (user == null ? void 0 : user.public_username) || user.user_alt_name,
2085
2087
  avatar_url: user.avatar_url,
2088
+ level_id: user.level_id,
2086
2089
  position: user.position_in_board,
2087
2090
  points: user.points_accumulated,
2088
- is_me: user.is_me
2091
+ // The `me` entry is the current user by definition, so force `true`
2092
+ // there; list rows carry the server-provided flag.
2093
+ is_me: isMe ? true : user.is_me
2089
2094
  };
2090
- if (isMe) {
2091
- delete x.is_me;
2092
- }
2093
- return x;
2094
2095
  }
2095
2096
  return null;
2096
2097
  };
2097
2098
  const getLeaderBoardTransform = board => {
2098
2099
  if (board) {
2099
- const x = {
2100
+ return {
2100
2101
  board_id: board.board_id,
2101
2102
  name: board.board_public_meta.name,
2102
2103
  description: board.board_public_meta.description,
2103
2104
  rules: board.board_public_meta.rules,
2104
2105
  period_type_id: board.period_type_id,
2106
+ version_id: board.versiod_id,
2107
+ create_date: board.create_date,
2105
2108
  rewards: pointsRewardTransform(board.reward_points),
2106
- users: board.positions.map(p => getLeaderBoardPlayerTransformed(p)),
2109
+ users: (board.positions || []).map(p => getLeaderBoardPlayerTransformed(p)),
2107
2110
  me: getLeaderBoardPlayerTransformed(board.userPosition, true)
2108
2111
  };
2109
- return x;
2110
2112
  }
2111
2113
  return null;
2112
2114
  };
@@ -7531,6 +7533,116 @@ class WSAPIAvatars extends WSAPIMiniGames {
7531
7533
  err_message: r.errMsg
7532
7534
  };
7533
7535
  }
7536
+ /**
7537
+ * Generates an AI-customized variant of a base avatar by applying an
7538
+ * operator-defined style prompt, returning the CDN URL of the result.
7539
+ * This is a paid, generate-only step: it does NOT change the user's
7540
+ * active avatar — pass the returned `cdn_url` to {@link setAvatar} to
7541
+ * activate it.
7542
+ *
7543
+ * @remarks
7544
+ * **Preconditions**
7545
+ * - Authenticated session required; not available in visitor mode (throws).
7546
+ * - All five fields are mandatory — the SDK throws synchronously
7547
+ * (`Error("<field> is required")`) if any is missing or zero.
7548
+ * - `prompt_id` must be one of the prompts from {@link getAvatarPrompts};
7549
+ * `avatar_url` / `avatar_real_id` identify the base avatar to style.
7550
+ *
7551
+ * **Cost**
7552
+ * Each generation costs the currency the operator configured on the
7553
+ * chosen prompt (points, gems, or diamonds — some prompts are free; read
7554
+ * `cost_currency_type_id` / `cost_value` from the {@link getAvatarPrompts}
7555
+ * entry to gate the UI before calling). The cost is charged only on
7556
+ * success; if the user can't afford it the call fails with `errCode -1`
7557
+ * and nothing is generated or charged.
7558
+ *
7559
+ * **Latency**
7560
+ * Generation runs server-side AI image synthesis and is synchronous from
7561
+ * the caller's side — expect several seconds (roughly 5–20 s) before the
7562
+ * promise resolves. There is no SDK cache and no push/subscription; show
7563
+ * a loading state for the full duration and disable the trigger to
7564
+ * prevent duplicate submissions.
7565
+ *
7566
+ * **Result & error codes**
7567
+ * On success the result has `cdn_url` set; on failure it has `errCode` /
7568
+ * `errMessage` set and no `cdn_url`. Branch on `errCode` — the generic
7569
+ * message is fixed text, not cause-specific:
7570
+ * - `12001` (`AvatarCustomizeErrorCode.AVATAR_USER_LIMIT`) — the user hit
7571
+ * their monthly per-user generation cap. Nothing is generated or charged.
7572
+ * - `12002` (`AvatarCustomizeErrorCode.AVATAR_LABEL_LIMIT`) — the brand's
7573
+ * shared monthly pool is exhausted. Nothing is generated or charged;
7574
+ * surface a "try again later" message.
7575
+ * - `-1` — generic failure: insufficient balance, an unavailable prompt,
7576
+ * or a generation error. Nothing is charged. Allow the user to retry.
7577
+ *
7578
+ * Both monthly caps are operator-configured and reset at the start of
7579
+ * each calendar month.
7580
+ *
7581
+ * **Side effects (on success)**
7582
+ * The generated variant is persisted to the user's customization history
7583
+ * and counts toward the monthly caps **whether or not** it is later
7584
+ * activated — generation is not reversible. The SDK clears the
7585
+ * {@link getAvatarsCustomized} cache so the next call surfaces the new
7586
+ * variant. The user's active avatar is unchanged until you call
7587
+ * {@link setAvatar} with the returned `cdn_url`.
7588
+ *
7589
+ * **Idempotency**: not idempotent — each successful call generates (and
7590
+ * charges for) a new variant. Guard the call site against double-clicks.
7591
+ *
7592
+ * **UI guidance**: see [UI Guide — `avatarsCustomize`](../../docs/ui/avatars/UIGuide_avatarsCustomize.md).
7593
+ *
7594
+ * **Visitor mode**: not supported (throws).
7595
+ *
7596
+ * @param props.label_id Numeric Smartico label (brand) ID the user belongs to.
7597
+ * @param props.user_id Numeric Smartico user ID.
7598
+ * @param props.prompt_id Style-prompt ID (`prompt_id`) from {@link getAvatarPrompts}.
7599
+ * @param props.avatar_url CDN URL of the base avatar to customize.
7600
+ * @param props.avatar_real_id `avatar_real_id` of the base avatar.
7601
+ * @returns {@link AvatarCustomizeResponse} — `cdn_url` set on success;
7602
+ * `errCode` / `errMessage` set on failure.
7603
+ *
7604
+ * @example
7605
+ * ```ts
7606
+ * // label_id / user_id identify the Smartico user being customized.
7607
+ * const prompts = await window._smartico.api.getAvatarPrompts();
7608
+ * const prompt = prompts[0];
7609
+ *
7610
+ * console.log('[smartico] generating avatar — show a spinner for ~5-20s and disable the Generate button');
7611
+ * const result = await window._smartico.api.avatarsCustomize({
7612
+ * label_id,
7613
+ * user_id,
7614
+ * prompt_id: prompt.prompt_id,
7615
+ * avatar_url: baseAvatar.avatar_url,
7616
+ * avatar_real_id: baseAvatar.avatar_real_id,
7617
+ * });
7618
+ *
7619
+ * if (result.cdn_url) {
7620
+ * console.log('[smartico] generation succeeded — preview this URL, then call setAvatar to apply it:', result.cdn_url);
7621
+ * // await window._smartico.api.setAvatar({ avatar_url: result.cdn_url, avatar_real_id: baseAvatar.avatar_real_id });
7622
+ * } else if (result.errCode === 12001) {
7623
+ * console.error('[smartico] user monthly limit reached — show "you have used all your custom avatars this month"');
7624
+ * } else if (result.errCode === 12002) {
7625
+ * console.error('[smartico] brand monthly pool exhausted — show "custom avatars are unavailable right now, try later"');
7626
+ * } else {
7627
+ * console.error('[smartico] generation failed (e.g. not enough balance) — let the user retry:', result.errMessage);
7628
+ * }
7629
+ * ```
7630
+ */
7631
+ async avatarsCustomize(props) {
7632
+ const required = ['label_id', 'user_id', 'prompt_id', 'avatar_url', 'avatar_real_id'];
7633
+ for (const field of required) {
7634
+ if (!props[field]) {
7635
+ throw new Error(`${field} is required`);
7636
+ }
7637
+ }
7638
+ const r = await this.api.avatarsCustomize(props);
7639
+ // On success a new variant is persisted server-side — drop the cached
7640
+ // list so the next getAvatarsCustomized() surfaces it.
7641
+ if (r.cdn_url) {
7642
+ OCache.clear(ECacheContext.WSAPI, onUpdateContextKey.AvatarsCustomized);
7643
+ }
7644
+ return r;
7645
+ }
7534
7646
  }
7535
7647
 
7536
7648
  /** @group GamePick */
@@ -8195,7 +8307,9 @@ class WSAPILeaderBoard extends WSAPIGamePick {
8195
8307
  *
8196
8308
  * The leaderboard for each period type is configured separately by
8197
8309
  * the operator. A label may have any combination of DAILY, WEEKLY,
8198
- * and MONTHLY boards configured (or none).
8310
+ * and MONTHLY boards configured (or none). To discover which boards
8311
+ * exist before loading any standings, call {@link getLeaderBoards}
8312
+ * (metadata only) and drive the tab selector from its `period_type_id`s.
8199
8313
  *
8200
8314
  * @remarks
8201
8315
  * **Return value note** — the runtime may return `undefined` if no
@@ -8207,10 +8321,13 @@ class WSAPILeaderBoard extends WSAPIGamePick {
8207
8321
  * Pass a `periodType` from {@link LeaderBoardPeriodType}
8208
8322
  * (`DAILY = 1`, `WEEKLY = 2`, `MONTHLY = 3`). Pass
8209
8323
  * `getPreviousPeriod: true` to fetch the most-recently-ended
8210
- * period's snapshot (yesterday's results, last week's results,
8211
- * last month's results) instead of the current live period. The
8212
- * SDK only exposes one period back — older snapshots are not
8213
- * reachable through this method.
8324
+ * period's snapshot (yesterday's / last week's / last month's
8325
+ * results) instead of the current live period. To reach older
8326
+ * snapshots, pass a number instead of a boolean: `1` = previous
8327
+ * period, `2` = the one before that, and so on (`0` / `false` =
8328
+ * current). Use the snapshot's `create_date` / `version_id` to label
8329
+ * which historical run a previous-period board is. How far back
8330
+ * snapshots are retained is operator-configured.
8214
8331
  *
8215
8332
  * **Top-20 cap**
8216
8333
  * The server hard-caps `users[]` at 20 entries, ordered by
@@ -8264,10 +8381,11 @@ class WSAPILeaderBoard extends WSAPIGamePick {
8264
8381
  * Selects which pre-configured board to
8265
8382
  * fetch; the board itself is bound to one
8266
8383
  * period by the operator.
8267
- * @param getPreviousPeriod When `true`, returns the most recent
8268
- * finalized snapshot for that period type
8269
- * (e.g. last week's results). Defaults to
8270
- * `false` (current in-progress period).
8384
+ * @param getPreviousPeriod Which period to fetch. `false` (default)
8385
+ * = current in-progress period; `true` =
8386
+ * the most recent finalized snapshot; a
8387
+ * number `n` = the n-th previous snapshot
8388
+ * (`1` = previous, `2` = the one before, …).
8271
8389
  * @returns Promise resolving to `LeaderBoardDetailsT`.
8272
8390
  * **At runtime, may resolve to `undefined`**
8273
8391
  * when no board is configured for the
@@ -8311,10 +8429,75 @@ class WSAPILeaderBoard extends WSAPIGamePick {
8311
8429
  * ```
8312
8430
  */
8313
8431
  async getLeaderBoard(periodType, getPreviousPeriod) {
8314
- // Cache per (periodType, current/previous) so switching tabs or
8315
- // current↔previous within the TTL doesn't return a colliding board.
8316
- const cacheKey = `${onUpdateContextKey.LeaderBoards}:${periodType}:${getPreviousPeriod ? 1 : 0}`;
8317
- return OCache.use(cacheKey, ECacheContext.WSAPI, () => this.api.leaderboardsGetT(this.userExtId, periodType, getPreviousPeriod), CACHE_DATA_SEC);
8432
+ // Resolve the snapshot offset: false/omitted → 0 (current), true → 1
8433
+ // (previous), or an explicit number for older snapshots.
8434
+ const offset = typeof getPreviousPeriod === 'number' ? getPreviousPeriod : getPreviousPeriod ? 1 : 0;
8435
+ // Cache per (periodType, offset) so switching tabs or period within the
8436
+ // TTL doesn't return a colliding board.
8437
+ const cacheKey = `${onUpdateContextKey.LeaderBoards}:${periodType}:${offset}`;
8438
+ return OCache.use(cacheKey, ECacheContext.WSAPI, () => this.api.leaderboardsGetT(this.userExtId, periodType, offset), CACHE_DATA_SEC);
8439
+ }
8440
+ /**
8441
+ * Returns the list of leaderboards the operator has configured for this
8442
+ * label — **metadata only, without participants**. Use it to discover
8443
+ * which boards exist (and their period types) so you can render the
8444
+ * board/tab selector, then load a specific board's standings on demand
8445
+ * with {@link getLeaderBoard}.
8446
+ *
8447
+ * This is the lightweight discovery counterpart to {@link getLeaderBoard}:
8448
+ * it issues one round-trip that returns every board's identity, name,
8449
+ * description, rules, `period_type_id`, and prize table, but **not** the
8450
+ * ranked players. Fetching the full standings for one board (the top-20
8451
+ * `users[]` and the caller's own `me` entry) is what {@link getLeaderBoard}
8452
+ * does per period.
8453
+ *
8454
+ * @remarks
8455
+ * **Returned shape**
8456
+ * An array of `LeaderBoardDetailsT`, one per configured board, ordered by
8457
+ * `period_type_id` ascending (DAILY, WEEKLY, MONTHLY, …). On every entry
8458
+ * `users` is an empty array and `me` is `undefined` — this call never
8459
+ * carries participant data. Read `period_type_id` from each entry and pass
8460
+ * it to {@link getLeaderBoard} to load that board's standings.
8461
+ *
8462
+ * **Empty result**
8463
+ * Resolves to an empty array when the label has no leaderboards configured
8464
+ * — treat that as "hide the leaderboard surface".
8465
+ *
8466
+ * **Cache TTL**
8467
+ * Cached for 30 seconds under a dedicated key (independent of
8468
+ * {@link getLeaderBoard}'s per-period cache). Repeated calls within the
8469
+ * window return the cached list without a round-trip.
8470
+ *
8471
+ * **Refresh model**: one-shot fetch — no subscription, no push. Board
8472
+ * configuration changes surface on the next cache miss.
8473
+ *
8474
+ * **Idempotency / Side effects**: safe. Read-only.
8475
+ *
8476
+ * **Visitor mode**: supported. Returns the brand's public board list.
8477
+ *
8478
+ * @returns Promise resolving to the array of configured boards
8479
+ * (metadata only). Empty array when none are configured.
8480
+ *
8481
+ * @example
8482
+ * ```ts
8483
+ * const boards = await window._smartico.api.getLeaderBoards();
8484
+ *
8485
+ * if (boards.length === 0) {
8486
+ * console.log('[smartico] no leaderboards configured — hide the leaderboard surface');
8487
+ * return;
8488
+ * }
8489
+ *
8490
+ * // Render one tab per board from the lightweight list (no players yet).
8491
+ * console.log('[smartico] render leaderboard tabs:', boards.map(b => b.name));
8492
+ *
8493
+ * // When the user opens a tab, load that board's standings on demand.
8494
+ * const first = boards[0];
8495
+ * const full = await window._smartico.api.getLeaderBoard(first.period_type_id);
8496
+ * console.log('[smartico] loaded standings for', first.name, '—', full?.users.length ?? 0, 'players');
8497
+ * ```
8498
+ */
8499
+ async getLeaderBoards() {
8500
+ return OCache.use(`${onUpdateContextKey.LeaderBoards}:list`, ECacheContext.WSAPI, () => this.api.leaderboardsGetListT(this.userExtId), CACHE_DATA_SEC);
8318
8501
  }
8319
8502
  }
8320
8503
 
@@ -9097,6 +9280,7 @@ var LiquidEntityData;
9097
9280
  LiquidEntityData[LiquidEntityData["Tournament"] = 10] = "Tournament";
9098
9281
  LiquidEntityData[LiquidEntityData["Raffles"] = 11] = "Raffles";
9099
9282
  LiquidEntityData[LiquidEntityData["SingleRaffle"] = 12] = "SingleRaffle";
9283
+ LiquidEntityData[LiquidEntityData["Clans"] = 13] = "Clans";
9100
9284
  })(LiquidEntityData || (LiquidEntityData = {}));
9101
9285
 
9102
9286
  const UICustomSectionTransform = response => {
@@ -9297,7 +9481,7 @@ const AVATAR_DOMAIN = 'https://img{ENV_ID}.smr.vc';
9297
9481
  const DEFAULT_LANG_EN = 'EN';
9298
9482
  class SmarticoAPI {
9299
9483
  constructor(label_api_key, brand_api_key, messageSender, options = {}) {
9300
- var _options$tracker;
9484
+ var _options$tracker, _options$tracker2;
9301
9485
  this.label_api_key = void 0;
9302
9486
  this.brand_api_key = void 0;
9303
9487
  this.messageSender = void 0;
@@ -9308,6 +9492,7 @@ class SmarticoAPI {
9308
9492
  this.gamesApiUrl = void 0;
9309
9493
  this.baseRgApiParams = void 0;
9310
9494
  this.avatarDomain = void 0;
9495
+ this.avatarOriginDomain = void 0;
9311
9496
  this.envId = void 0;
9312
9497
  this.logger = void 0;
9313
9498
  this.logCIDs = void 0;
@@ -9335,6 +9520,7 @@ class SmarticoAPI {
9335
9520
  };
9336
9521
  }
9337
9522
  this.avatarDomain = SmarticoAPI.getAvatarUrl(label_api_key || ((_options$tracker = options.tracker) == null ? void 0 : _options$tracker.label_api_key));
9523
+ this.avatarOriginDomain = SmarticoAPI.getAvatarOriginUrl(label_api_key || ((_options$tracker2 = options.tracker) == null ? void 0 : _options$tracker2.label_api_key));
9338
9524
  this.label_api_key = SmarticoAPI.getCleanLabelApiKey(label_api_key);
9339
9525
  }
9340
9526
  static getEnvDnsSuffix(label_api_key) {
@@ -9391,6 +9577,9 @@ class SmarticoAPI {
9391
9577
  const avatarUrl = AVATAR_DOMAIN.replace('{ENV_ID}', SmarticoAPI.getEnvDnsSuffix(label_api_key));
9392
9578
  return SmarticoAPI.replaceSmrDomainsWithCloudfront(avatarUrl);
9393
9579
  }
9580
+ static getAvatarOriginUrl(label_api_key) {
9581
+ return AVATAR_DOMAIN.replace('{ENV_ID}', SmarticoAPI.getEnvDnsSuffix(label_api_key));
9582
+ }
9394
9583
  async send(message, expectCID, force_language) {
9395
9584
  if (this.logCIDs.includes(message.cid)) {
9396
9585
  this.logger.info('REQ', message);
@@ -9950,9 +10139,12 @@ class SmarticoAPI {
9950
10139
  }
9951
10140
  async leaderboardGet(user_ext_id, period_type_id, prevPeriod = false, force_language) {
9952
10141
  var _response$map$boardKe, _response$map$boardKe2;
10142
+ // boolean keeps back-compat (false → current, true → previous);
10143
+ // a number selects an arbitrary snapshot offset (1 = previous, 2 = the one before, …).
10144
+ const snapshot_offset = typeof prevPeriod === 'number' ? prevPeriod : prevPeriod ? 1 : 0;
9953
10145
  const message = this.buildMessage(user_ext_id, ClassId.GET_LEADERS_BOARD_REQUEST, {
9954
10146
  period_type_id,
9955
- snapshot_offset: prevPeriod ? 1 : 0,
10147
+ snapshot_offset,
9956
10148
  include_users: true
9957
10149
  });
9958
10150
  const response = await this.send(message, ClassId.GET_LEADERS_BOARD_RESPONSE, force_language);
@@ -9973,6 +10165,20 @@ class SmarticoAPI {
9973
10165
  async leaderboardsGetT(user_ext_id, period_type_id = LeaderBoardPeriodType.DAILY, prevPeriod = false) {
9974
10166
  return getLeaderBoardTransform(await this.leaderboardGet(user_ext_id, period_type_id, prevPeriod));
9975
10167
  }
10168
+ async leaderboardsGetList(user_ext_id, force_language) {
10169
+ const message = this.buildMessage(user_ext_id, ClassId.GET_LEADERS_BOARD_REQUEST, {
10170
+ // No period_type_id → the server returns every configured board.
10171
+ // include_users: false → board metadata only (no positions / userPosition).
10172
+ snapshot_offset: 0,
10173
+ include_users: false
10174
+ });
10175
+ const response = await this.send(message, ClassId.GET_LEADERS_BOARD_RESPONSE, force_language);
10176
+ // map is keyed by period_type_id; integer-like keys iterate in ascending order.
10177
+ return Object.values(response.map || {});
10178
+ }
10179
+ async leaderboardsGetListT(user_ext_id) {
10180
+ return (await this.leaderboardsGetList(user_ext_id)).map(getLeaderBoardTransform);
10181
+ }
9976
10182
  async levelsGet(user_ext_id, force_language) {
9977
10183
  const message = this.buildMessage(user_ext_id, ClassId.GET_LEVEL_MAP_REQUEST);
9978
10184
  return await this.send(message, ClassId.GET_LEVEL_MAP_RESPONSE, force_language);
@@ -10145,6 +10351,33 @@ class SmarticoAPI {
10145
10351
  throw new Error(`Failed to call games API: ${method}. ${e.message}`);
10146
10352
  }
10147
10353
  }
10354
+ async sendAvatarApi({
10355
+ method,
10356
+ body
10357
+ }) {
10358
+ if (!this.tracker) {
10359
+ throw new Error(`Avatar APIs are not available in the visitor mode`);
10360
+ }
10361
+ const url = `${this.avatarOriginDomain}/${method}`;
10362
+ try {
10363
+ const response = await fetch(url, {
10364
+ method: 'POST',
10365
+ headers: {
10366
+ 'Accept': 'application/json',
10367
+ 'Content-Type': 'application/json'
10368
+ },
10369
+ body: JSON.stringify(body)
10370
+ });
10371
+ const data = await response.json();
10372
+ return SmarticoAPI.replaceSmrDomainsWithCloudfront(data);
10373
+ } catch (e) {
10374
+ this.logger.error(`Failed to call avatar API: ${method}`, {
10375
+ url,
10376
+ error: e.message
10377
+ });
10378
+ throw new Error(`Failed to call avatar API: ${method}. ${e.message}`);
10379
+ }
10380
+ }
10148
10381
  async gpGetActiveRounds(saw_template_id) {
10149
10382
  const params = {
10150
10383
  ext_game_id: saw_template_id
@@ -10252,6 +10485,21 @@ class SmarticoAPI {
10252
10485
  });
10253
10486
  return await this.send(message, ClassId.CLIENT_SET_AVATAR_RESPONSE);
10254
10487
  }
10488
+ async avatarsCustomize(params) {
10489
+ var _this$tracker, _this$tracker2;
10490
+ return this.sendAvatarApi({
10491
+ method: 'avatar-customize',
10492
+ body: {
10493
+ label_id: params.label_id,
10494
+ user_id: params.user_id,
10495
+ user_ext_id: (_this$tracker = this.tracker) == null ? void 0 : _this$tracker.getExtUserId(),
10496
+ brand_key: this.brand_api_key || ((_this$tracker2 = this.tracker) == null || (_this$tracker2 = _this$tracker2.params) == null ? void 0 : _this$tracker2.brand_key),
10497
+ prompt_id: params.prompt_id,
10498
+ avatar_url: params.avatar_url,
10499
+ avatar_real_id: params.avatar_real_id
10500
+ }
10501
+ });
10502
+ }
10255
10503
  async avatarsGetListT(user_ext_id) {
10256
10504
  var _await$this$avatarsGe;
10257
10505
  return avatarDefinitionTransform((_await$this$avatarsGe = (await this.avatarsGetList(user_ext_id)).avatars) != null ? _await$this$avatarsGe : [], this.avatarDomain);
@@ -10925,15 +11173,18 @@ var JackpotType;
10925
11173
  JackpotType[JackpotType["Personal"] = 2] = "Personal";
10926
11174
  })(JackpotType || (JackpotType = {}));
10927
11175
 
11176
+ /**
11177
+ * Limit error codes returned in `errCode` by the `avatarsCustomize` method.
11178
+ * See the `avatarsCustomize` TSDoc for the full table (including the generic
11179
+ * `-1` failure, which has no named member here).
11180
+ */
10928
11181
  var AvatarCustomizeErrorCode;
10929
11182
  (function (AvatarCustomizeErrorCode) {
11183
+ /** The user has reached the operator-configured per-user monthly cap on custom-avatar generations. */
10930
11184
  AvatarCustomizeErrorCode[AvatarCustomizeErrorCode["AVATAR_USER_LIMIT"] = 12001] = "AVATAR_USER_LIMIT";
11185
+ /** The brand's operator-configured shared monthly pool of custom-avatar generations is exhausted. */
10931
11186
  AvatarCustomizeErrorCode[AvatarCustomizeErrorCode["AVATAR_LABEL_LIMIT"] = 12002] = "AVATAR_LABEL_LIMIT";
10932
11187
  })(AvatarCustomizeErrorCode || (AvatarCustomizeErrorCode = {}));
10933
- const AvatarCustomizeErrorMessage = {
10934
- [AvatarCustomizeErrorCode.AVATAR_USER_LIMIT]: 'You have exceeded number of custom avatars creation, please try later',
10935
- [AvatarCustomizeErrorCode.AVATAR_LABEL_LIMIT]: 'The custom avatars are not available, please try again later'
10936
- };
10937
11188
 
10938
11189
  /**
10939
11190
  * Error codes returned in `errCode` by the `joinClan` method (also carried
@@ -10969,5 +11220,5 @@ var JoinClanErrorCode;
10969
11220
  JoinClanErrorCode[JoinClanErrorCode["JOIN_CLAN_JOINED_AFTER_TOURNAMENT_START"] = 1011] = "JOIN_CLAN_JOINED_AFTER_TOURNAMENT_START";
10970
11221
  })(JoinClanErrorCode || (JoinClanErrorCode = {}));
10971
11222
 
10972
- export { AchCategoryTransform, AchCustomLayoutTheme, AchCustomSectionType, AchMissionsTabsOptions, AchOverviewMissionsFilter, AchievementAvailabilityStatus, AchievementClaimPeriodTypeId, AchievementStatus, AchievementTaskType, AchievementType, ActivityLogTransform, ActivityTypeLimited, AllRoundsGameBoardID, AnalyticsInboxSubScreenNameId, AnalyticsInterfaceType, AnalyticsScreenNameId, AnalyticsTournamentsLobbySubScreenNameId, AttemptPeriodType, AvatarCustomizeErrorCode, AvatarCustomizeErrorMessage, BadgesTimeLimitStates, BonusItemsTransform, BonusStatus, BuyStoreItemErrorCode, ClassId, CookieStore, CoreUtils, ECacheContext, GPRoundStatus, GamePickMarketType, GamePickResolutionType, GamePickScoreType, GamePickSportType, GameRoundOrderType, GetJackpotEligibleGamesResponseTransform, GetJackpotWinnersResponseTransform, GetLevelMapResponseTransform, InboxCategories, InboxMessageBodyTransform, InboxMessageType, InboxMessagesTransform, InboxReadStatus, JackPotTemparature, JackpotContributionType, JackpotType, JoinClanErrorCode, LeaderBoardPeriodType, LiquidEntityData, MiniGamePrizeTypeName, MiniGamePrizeTypeNamed, MissionCategory, MissionUtils, OCache, OpenLinksType, PointChangeSourceType, PrizeModifiers, PrizeModifiersKeysNames, PublicLabelSettings, QuizAnswersValueType, QuizMarketPerSport, QuizSportType, RaffleDrawInstanceState, RaffleDrawTypeExecution, RaffleTicketCapVisualization, SAWAcknowledgeType, SAWAcknowledgeTypeName, SAWAcknowledgeTypeNamed, SAWAskForUsername, SAWBuyInType, SAWBuyInTypeName, SAWBuyInTypeNamed, SAWExposeUserSpinId, SAWExposeUserSpinIdName, SAWExposeUserSpinIdNamed, SAWGPMarketType, SAWGameDifficultyType, SAWGameDifficultyTypeName, SAWGameLayout, SAWGameLayoutName, SAWGameLayoutNamed, SAWGameType, SAWGameTypeName, SAWGameTypeNamed, SAWHistoryTransform, SAWPrizeType, SAWSpinErrorCode, SAWTemplatesTransform, SAWUtils, SAWWheelLayout, SAWWinSoundFiles, SAWWinSoundType, SawGameDifficultyTypeNamed, ScheduledMissionType, SmarticoAPI, StoreCategoryTransform, StoreItemPurchaseType, StoreItemPurchasedTransform, StoreItemTransform, StoreItemType, StoreItemTypeName, StoreItemTypeNamed, TournamentInstanceStatus, TournamentInstanceStatusName, TournamentItemsTransform, TournamentRegistrationError, TournamentRegistrationStatus, TournamentRegistrationStatusName, TournamentRegistrationStatusNamed, TournamentRegistrationType, TournamentRegistrationTypeGetName, TournamentType, TournamentUtils, TranslationArea, UICustomSectionTransform, UserAchievementTransform, UserBalanceType, WSAPI, avatarCustomizedTransform, avatarDefinitionTransform, avatarPromptTransform, clanTournamentPlayersTransform, drawRunHistoryTransform, drawRunTransform, drawTransform, enrichUserAchievementsWithBadgeState, getLeaderBoardTransform, marketsInfo, prizeTransform, quizAnswerAwayTeamReplacementText, quizAnswerHomeTeamReplacementText, quizAnswersTrKeys, quizDrawReplacementText, quizEvenReplacementText, quizNoGoalsReplacementText, quizNoReplacementText, quizOddReplacementText, quizOrReplacementText, quizSupportedSports, quizYesReplacementText, raffleClaimPrizeResponseTransform, raffleTransform, ticketsTransform, tournamentInfoItemTransform, winnersTransform };
11223
+ export { AchCategoryTransform, AchCustomLayoutTheme, AchCustomSectionType, AchMissionsTabsOptions, AchOverviewMissionsFilter, AchievementAvailabilityStatus, AchievementClaimPeriodTypeId, AchievementStatus, AchievementTaskType, AchievementType, ActivityLogTransform, ActivityTypeLimited, AllRoundsGameBoardID, AnalyticsInboxSubScreenNameId, AnalyticsInterfaceType, AnalyticsScreenNameId, AnalyticsTournamentsLobbySubScreenNameId, AttemptPeriodType, AvatarCustomizeErrorCode, BadgesTimeLimitStates, BonusItemsTransform, BonusStatus, BuyStoreItemErrorCode, ClassId, CookieStore, CoreUtils, ECacheContext, GPRoundStatus, GamePickMarketType, GamePickResolutionType, GamePickScoreType, GamePickSportType, GameRoundOrderType, GetJackpotEligibleGamesResponseTransform, GetJackpotWinnersResponseTransform, GetLevelMapResponseTransform, InboxCategories, InboxMessageBodyTransform, InboxMessageType, InboxMessagesTransform, InboxReadStatus, JackPotTemparature, JackpotContributionType, JackpotType, JoinClanErrorCode, LeaderBoardPeriodType, LiquidEntityData, MiniGamePrizeTypeName, MiniGamePrizeTypeNamed, MissionCategory, MissionUtils, OCache, OpenLinksType, PointChangeSourceType, PrizeModifiers, PrizeModifiersKeysNames, PublicLabelSettings, QuizAnswersValueType, QuizMarketPerSport, QuizSportType, RaffleDrawInstanceState, RaffleDrawTypeExecution, RaffleTicketCapVisualization, SAWAcknowledgeType, SAWAcknowledgeTypeName, SAWAcknowledgeTypeNamed, SAWAskForUsername, SAWBuyInType, SAWBuyInTypeName, SAWBuyInTypeNamed, SAWExposeUserSpinId, SAWExposeUserSpinIdName, SAWExposeUserSpinIdNamed, SAWGPMarketType, SAWGameDifficultyType, SAWGameDifficultyTypeName, SAWGameLayout, SAWGameLayoutName, SAWGameLayoutNamed, SAWGameType, SAWGameTypeName, SAWGameTypeNamed, SAWHistoryTransform, SAWPrizeType, SAWSpinErrorCode, SAWTemplatesTransform, SAWUtils, SAWWheelLayout, SAWWinSoundFiles, SAWWinSoundType, SawGameDifficultyTypeNamed, ScheduledMissionType, SmarticoAPI, StoreCategoryTransform, StoreItemPurchaseType, StoreItemPurchasedTransform, StoreItemTransform, StoreItemType, StoreItemTypeName, StoreItemTypeNamed, TournamentInstanceStatus, TournamentInstanceStatusName, TournamentItemsTransform, TournamentRegistrationError, TournamentRegistrationStatus, TournamentRegistrationStatusName, TournamentRegistrationStatusNamed, TournamentRegistrationType, TournamentRegistrationTypeGetName, TournamentType, TournamentUtils, TranslationArea, UICustomSectionTransform, UserAchievementTransform, UserBalanceType, WSAPI, avatarCustomizedTransform, avatarDefinitionTransform, avatarPromptTransform, clanTournamentPlayersTransform, drawRunHistoryTransform, drawRunTransform, drawTransform, enrichUserAchievementsWithBadgeState, getLeaderBoardTransform, marketsInfo, prizeTransform, quizAnswerAwayTeamReplacementText, quizAnswerHomeTeamReplacementText, quizAnswersTrKeys, quizDrawReplacementText, quizEvenReplacementText, quizNoGoalsReplacementText, quizNoReplacementText, quizOddReplacementText, quizOrReplacementText, quizSupportedSports, quizYesReplacementText, raffleClaimPrizeResponseTransform, raffleTransform, ticketsTransform, tournamentInfoItemTransform, winnersTransform };
10973
11224
  //# sourceMappingURL=index.modern.mjs.map