@smartico/public-api 0.0.361 → 0.0.363

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.
@@ -2218,6 +2218,9 @@ var onUpdateContextKey;
2218
2218
  onUpdateContextKey["CurrentLevel"] = "currentLevel";
2219
2219
  onUpdateContextKey["InboxUnreadCount"] = "inboxUnreadCount";
2220
2220
  onUpdateContextKey["ActivityLog"] = "activityLog";
2221
+ onUpdateContextKey["AvatarsList"] = "avatarsList";
2222
+ onUpdateContextKey["AvatarsCustomized"] = "avatarsCustomized";
2223
+ onUpdateContextKey["AvatarPrompts"] = "avatarPrompts";
2221
2224
  })(onUpdateContextKey || (onUpdateContextKey = {}));
2222
2225
  /** @group General API */
2223
2226
  class WSAPI {
@@ -3401,6 +3404,97 @@ class WSAPI {
3401
3404
  }
3402
3405
  return this.api.gpGetRoundInfoForUser(props.saw_template_id, props.round_id, props.int_user_id);
3403
3406
  }
3407
+ /**
3408
+ * Returns the list of avatars available in the catalog for the current user.
3409
+ * The response includes both free avatars and earned/purchased ones.
3410
+ * Avatars with `hide_until_achieved = true` and `is_given = false` should be hidden from the user.
3411
+ * The result is cached for 30 seconds.
3412
+ *
3413
+ * **Example**:
3414
+ * ```
3415
+ * _smartico.api.getAvatarsList().then((result) => {
3416
+ * console.log(result);
3417
+ * });
3418
+ * ```
3419
+ *
3420
+ * **Visitor mode: not supported**
3421
+ */
3422
+ async getAvatarsList() {
3423
+ return OCache.use(onUpdateContextKey.AvatarsList, ECacheContext.WSAPI, () => this.api.avatarsGetListT(this.userExtId), CACHE_DATA_SEC);
3424
+ }
3425
+ /**
3426
+ * Returns the list of AI-customized avatars for the current user.
3427
+ * Each entry represents a previously generated AI customization for a specific base avatar.
3428
+ * The result is cached for 30 seconds.
3429
+ *
3430
+ * **Example**:
3431
+ * ```
3432
+ * _smartico.api.getAvatarsCustomized().then((result) => {
3433
+ * console.log(result);
3434
+ * });
3435
+ * ```
3436
+ *
3437
+ * **Visitor mode: not supported**
3438
+ */
3439
+ async getAvatarsCustomized() {
3440
+ return OCache.use(onUpdateContextKey.AvatarsCustomized, ECacheContext.WSAPI, () => this.api.avatarsGetCustomizedT(this.userExtId), CACHE_DATA_SEC);
3441
+ }
3442
+ /**
3443
+ * Returns the list of AI customization prompts (styles) available for avatar customization.
3444
+ * Each prompt represents a visual style that can be applied to a base avatar.
3445
+ * The result is cached for 30 seconds.
3446
+ *
3447
+ * **Example**:
3448
+ * ```
3449
+ * _smartico.api.getAvatarPrompts().then((result) => {
3450
+ * console.log(result);
3451
+ * });
3452
+ * ```
3453
+ *
3454
+ * **Visitor mode: not supported**
3455
+ */
3456
+ async getAvatarPrompts() {
3457
+ return OCache.use(onUpdateContextKey.AvatarPrompts, ECacheContext.WSAPI, () => this.api.avatarsGetPromptsT(this.userExtId), CACHE_DATA_SEC);
3458
+ }
3459
+ /**
3460
+ * Sets the specified avatar as the active avatar for the current user.
3461
+ * Pass `avatar_url` (the `TAvatarDefinition.url` path or a CDN URL for AI-customized avatars)
3462
+ * and `avatar_real_id` from the avatar catalog.
3463
+ * After a successful call, the avatar list cache is cleared so the next `getAvatarsList()` call reflects `is_in_use`.
3464
+ *
3465
+ * **Example**:
3466
+ * ```
3467
+ * _smartico.api.getAvatarsList().then((avatars) => {
3468
+ * const avatar = avatars.find((a) => !a.hide_until_achieved || a.is_given);
3469
+ * if (avatar) {
3470
+ * _smartico.api.setAvatar({
3471
+ * avatar_url: avatar.url,
3472
+ * avatar_real_id: avatar.avatar_real_id,
3473
+ * }).then((result) => {
3474
+ * console.log(result);
3475
+ * });
3476
+ * }
3477
+ * });
3478
+ * ```
3479
+ *
3480
+ * **Visitor mode: not supported**
3481
+ */
3482
+ async setAvatar(props) {
3483
+ var _r$errCode;
3484
+ if (!props.avatar_url) {
3485
+ throw new Error('avatar_url is required');
3486
+ }
3487
+ if (!props.avatar_real_id) {
3488
+ throw new Error('avatar_real_id is required');
3489
+ }
3490
+ const r = await this.api.avatarSetAvatar(this.userExtId, props.avatar_url, props.avatar_real_id);
3491
+ OCache.clear(ECacheContext.WSAPI, onUpdateContextKey.AvatarsList);
3492
+ OCache.clear(ECacheContext.WSAPI, onUpdateContextKey.AvatarsCustomized);
3493
+ return {
3494
+ err_code: (_r$errCode = r.errCode) != null ? _r$errCode : 0,
3495
+ err_message: r.errMsg
3496
+ };
3497
+ }
3404
3498
  async updateOnSpin(data) {
3405
3499
  const templates = await OCache.use(onUpdateContextKey.Saw, ECacheContext.WSAPI, () => this.api.sawGetTemplatesT(this.userExtId), CACHE_DATA_SEC);
3406
3500
  const index = templates.findIndex(t => t.id === data.saw_template_id);
@@ -3938,6 +4032,41 @@ var PointChangeSourceType;
3938
4032
  PointChangeSourceType[PointChangeSourceType["Avatars"] = 22] = "Avatars";
3939
4033
  })(PointChangeSourceType || (PointChangeSourceType = {}));
3940
4034
 
4035
+ const avatarDefinitionTransform = (items, avatarDomain) => {
4036
+ return items.map(item => ({
4037
+ avatar_real_id: item.avatar_real_id,
4038
+ is_default: item.is_default,
4039
+ hide_until_achieved: item.hide_until_achieved,
4040
+ priority: item.priority,
4041
+ description: item.public_meta.description,
4042
+ url: item.public_meta.url,
4043
+ avatar_url: item.public_meta.url && !item.public_meta.url.startsWith('http') ? `${avatarDomain}${item.public_meta.url}` : item.public_meta.url,
4044
+ avatar_source_type_id: item.avatar_source_type_id,
4045
+ active_from_date: item.active_from_date,
4046
+ active_till_date: item.active_till_date,
4047
+ is_given: item.is_given,
4048
+ is_in_use: item.is_in_use
4049
+ }));
4050
+ };
4051
+
4052
+ const avatarCustomizedTransform = (items, avatarDomain) => {
4053
+ return items.map(item => ({
4054
+ avatar_real_id: item.avatar_real_id,
4055
+ url: item.url && !item.url.startsWith('http') ? `${avatarDomain}${item.url}` : item.url,
4056
+ dt_created: item.dt_created
4057
+ }));
4058
+ };
4059
+
4060
+ const avatarPromptTransform = (items, avatarDomain) => {
4061
+ return items.map(item => ({
4062
+ prompt_id: item.prompt_id,
4063
+ name: item.public_meta.name,
4064
+ icon_url: item.public_meta.icon_url && !item.public_meta.icon_url.startsWith('http') ? `${avatarDomain}${item.public_meta.icon_url}` : item.public_meta.icon_url,
4065
+ cost_currency_type_id: item.cost_currency_type_id,
4066
+ cost_value: item.cost_value
4067
+ }));
4068
+ };
4069
+
3941
4070
  /**
3942
4071
  * @ignore
3943
4072
  */
@@ -4844,6 +4973,37 @@ class SmarticoAPI {
4844
4973
  params
4845
4974
  });
4846
4975
  }
4976
+ async avatarsGetList(user_ext_id) {
4977
+ const message = this.buildMessage(user_ext_id, ClassId.GET_AVATARS_LIST_REQUEST);
4978
+ return await this.send(message, ClassId.GET_AVATARS_LIST_RESPONSE);
4979
+ }
4980
+ async avatarsGetCustomized(user_ext_id) {
4981
+ const message = this.buildMessage(user_ext_id, ClassId.GET_AVATARS_CUSTOMIZED_REQUEST);
4982
+ return await this.send(message, ClassId.GET_AVATARS_CUSTOMIZED_RESPONSE);
4983
+ }
4984
+ async avatarsGetPrompts(user_ext_id) {
4985
+ const message = this.buildMessage(user_ext_id, ClassId.GET_AVATAR_PROMPTS_REQUEST);
4986
+ return await this.send(message, ClassId.GET_AVATAR_PROMPTS_RESPONSE);
4987
+ }
4988
+ async avatarSetAvatar(user_ext_id, avatar_id, avatar_real_id) {
4989
+ const message = this.buildMessage(user_ext_id, ClassId.CLIENT_SET_AVATAR_REQUEST, {
4990
+ avatar_id,
4991
+ avatar_real_id
4992
+ });
4993
+ return await this.send(message, ClassId.CLIENT_SET_AVATAR_RESPONSE);
4994
+ }
4995
+ async avatarsGetListT(user_ext_id) {
4996
+ var _await$this$avatarsGe;
4997
+ return avatarDefinitionTransform((_await$this$avatarsGe = (await this.avatarsGetList(user_ext_id)).avatars) != null ? _await$this$avatarsGe : [], this.avatarDomain);
4998
+ }
4999
+ async avatarsGetCustomizedT(user_ext_id) {
5000
+ var _await$this$avatarsGe2;
5001
+ return avatarCustomizedTransform((_await$this$avatarsGe2 = (await this.avatarsGetCustomized(user_ext_id)).avatars) != null ? _await$this$avatarsGe2 : [], this.avatarDomain);
5002
+ }
5003
+ async avatarsGetPromptsT(user_ext_id) {
5004
+ var _await$this$avatarsGe3;
5005
+ return avatarPromptTransform((_await$this$avatarsGe3 = (await this.avatarsGetPrompts(user_ext_id)).prompts) != null ? _await$this$avatarsGe3 : [], this.avatarDomain);
5006
+ }
4847
5007
  getWSCalls() {
4848
5008
  return new WSAPI(this);
4849
5009
  }
@@ -5366,5 +5526,15 @@ var JackpotType;
5366
5526
  JackpotType[JackpotType["Personal"] = 2] = "Personal";
5367
5527
  })(JackpotType || (JackpotType = {}));
5368
5528
 
5369
- export { AchCategoryTransform, AchCustomLayoutTheme, AchCustomSectionType, AchMissionsTabsOptions, AchOverviewMissionsFilter, AchievementAvailabilityStatus, AchievementStatus, AchievementTaskType, AchievementType, ActivityLogTransform, ActivityTypeLimited, AnalyticsInboxSubScreenNameId, AnalyticsInterfaceType, AnalyticsScreenNameId, AnalyticsTournamentsLobbySubScreenNameId, AttemptPeriodType, BadgesTimeLimitStates, BonusItemsTransform, BonusStatus, BuyStoreItemErrorCode, ClassId, CookieStore, CoreUtils, ECacheContext, GetJackpotEligibleGamesResponseTransform, GetJackpotWinnersResponseTransform, GetLevelMapResponseTransform, InboxCategories, InboxMessageBodyTransform, InboxMessageType, InboxMessagesTransform, InboxReadStatus, JackPotTemparature, JackpotContributionType, JackpotType, 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, drawRunHistoryTransform, drawRunTransform, drawTransform, enrichUserAchievementsWithBadgeState, getLeaderBoardTransform, marketsInfo, prizeTransform, quizAnswerAwayTeamReplacementText, quizAnswerHomeTeamReplacementText, quizAnswersTrKeys, quizDrawReplacementText, quizEvenReplacementText, quizNoGoalsReplacementText, quizNoReplacementText, quizOddReplacementText, quizOrReplacementText, quizSupportedSports, quizYesReplacementText, raffleClaimPrizeResponseTransform, raffleTransform, ticketsTransform, tournamentInfoItemTransform, winnersTransform };
5529
+ var AvatarCustomizeErrorCode;
5530
+ (function (AvatarCustomizeErrorCode) {
5531
+ AvatarCustomizeErrorCode[AvatarCustomizeErrorCode["AVATAR_USER_LIMIT"] = 12001] = "AVATAR_USER_LIMIT";
5532
+ AvatarCustomizeErrorCode[AvatarCustomizeErrorCode["AVATAR_LABEL_LIMIT"] = 12002] = "AVATAR_LABEL_LIMIT";
5533
+ })(AvatarCustomizeErrorCode || (AvatarCustomizeErrorCode = {}));
5534
+ const AvatarCustomizeErrorMessage = {
5535
+ [AvatarCustomizeErrorCode.AVATAR_USER_LIMIT]: 'You have exceeded number of custom avatars creation, please try later',
5536
+ [AvatarCustomizeErrorCode.AVATAR_LABEL_LIMIT]: 'The custom avatars are not available, please try again later'
5537
+ };
5538
+
5539
+ export { AchCategoryTransform, AchCustomLayoutTheme, AchCustomSectionType, AchMissionsTabsOptions, AchOverviewMissionsFilter, AchievementAvailabilityStatus, AchievementStatus, AchievementTaskType, AchievementType, ActivityLogTransform, ActivityTypeLimited, AnalyticsInboxSubScreenNameId, AnalyticsInterfaceType, AnalyticsScreenNameId, AnalyticsTournamentsLobbySubScreenNameId, AttemptPeriodType, AvatarCustomizeErrorCode, AvatarCustomizeErrorMessage, BadgesTimeLimitStates, BonusItemsTransform, BonusStatus, BuyStoreItemErrorCode, ClassId, CookieStore, CoreUtils, ECacheContext, GetJackpotEligibleGamesResponseTransform, GetJackpotWinnersResponseTransform, GetLevelMapResponseTransform, InboxCategories, InboxMessageBodyTransform, InboxMessageType, InboxMessagesTransform, InboxReadStatus, JackPotTemparature, JackpotContributionType, JackpotType, 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, drawRunHistoryTransform, drawRunTransform, drawTransform, enrichUserAchievementsWithBadgeState, getLeaderBoardTransform, marketsInfo, prizeTransform, quizAnswerAwayTeamReplacementText, quizAnswerHomeTeamReplacementText, quizAnswersTrKeys, quizDrawReplacementText, quizEvenReplacementText, quizNoGoalsReplacementText, quizNoReplacementText, quizOddReplacementText, quizOrReplacementText, quizSupportedSports, quizYesReplacementText, raffleClaimPrizeResponseTransform, raffleTransform, ticketsTransform, tournamentInfoItemTransform, winnersTransform };
5370
5540
  //# sourceMappingURL=index.modern.mjs.map