@smartico/public-api 0.0.325 → 0.0.327

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 (48) hide show
  1. package/dist/Base/ClassId.d.ts +2 -0
  2. package/dist/CustomSections/AchCustomSection.d.ts +2 -1
  3. package/dist/CustomSections/UICustomSection.d.ts +1 -0
  4. package/dist/MiniGames/AttemptPeriodType.d.ts +6 -0
  5. package/dist/MiniGames/SAWPrize.d.ts +2 -0
  6. package/dist/MiniGames/index.d.ts +1 -0
  7. package/dist/PointsHistory/GetPointsHistoryRequest.d.ts +6 -0
  8. package/dist/PointsHistory/GetPointsHistoryResponse.d.ts +7 -0
  9. package/dist/PointsHistory/PointChangeSourceType.d.ts +19 -0
  10. package/dist/PointsHistory/PointsHistoryLog.d.ts +21 -0
  11. package/dist/PointsHistory/UserBalanceType.d.ts +5 -0
  12. package/dist/PointsHistory/index.d.ts +5 -0
  13. package/dist/SmarticoAPI.d.ts +4 -1
  14. package/dist/WSAPI/WSAPI.d.ts +34 -1
  15. package/dist/WSAPI/WSAPITypes.d.ts +30 -2
  16. package/dist/index.d.ts +1 -0
  17. package/dist/index.js +224 -74
  18. package/dist/index.js.map +1 -1
  19. package/dist/index.modern.mjs +128 -3
  20. package/dist/index.modern.mjs.map +1 -1
  21. package/docs/README.md +4 -0
  22. package/docs/classes/WSAPI.md +41 -0
  23. package/docs/enums/AchCustomSectionType.md +6 -0
  24. package/docs/enums/AttemptPeriodType.md +25 -0
  25. package/docs/enums/PointChangeSourceType.md +103 -0
  26. package/docs/enums/UserBalanceType.md +19 -0
  27. package/docs/interfaces/SAWPrize.md +6 -0
  28. package/docs/interfaces/TMiniGamePrize.md +8 -0
  29. package/docs/interfaces/TPointsHistoryLog.md +68 -0
  30. package/docs/interfaces/TUICustomSection.md +8 -0
  31. package/package.json +1 -1
  32. package/src/Base/ClassId.ts +3 -0
  33. package/src/CustomSections/AchCustomSection.ts +1 -0
  34. package/src/CustomSections/UICustomSection.ts +7 -0
  35. package/src/MiniGames/AttemptPeriodType.ts +6 -0
  36. package/src/MiniGames/SAWGetTemplatesResponse.ts +1 -0
  37. package/src/MiniGames/SAWPrize.ts +2 -0
  38. package/src/MiniGames/index.ts +2 -1
  39. package/src/PointsHistory/GetPointsHistoryRequest.ts +8 -0
  40. package/src/PointsHistory/GetPointsHistoryResponse.ts +39 -0
  41. package/src/PointsHistory/PointChangeSourceType.ts +20 -0
  42. package/src/PointsHistory/PointsHistoryLog.ts +24 -0
  43. package/src/PointsHistory/UserBalanceType.ts +6 -0
  44. package/src/PointsHistory/index.ts +6 -0
  45. package/src/SmarticoAPI.ts +29 -0
  46. package/src/WSAPI/WSAPI.ts +64 -2
  47. package/src/WSAPI/WSAPITypes.ts +30 -2
  48. package/src/index.ts +2 -1
@@ -84,6 +84,8 @@ var ClassId;
84
84
  ClassId[ClassId["ACH_SHOP_ITEM_HISTORY_RESPONSE"] = 542] = "ACH_SHOP_ITEM_HISTORY_RESPONSE";
85
85
  ClassId[ClassId["GET_RELATED_ACH_N_TOURNAMENTS_REQUEST"] = 543] = "GET_RELATED_ACH_N_TOURNAMENTS_REQUEST";
86
86
  ClassId[ClassId["GET_RELATED_ACH_N_TOURNAMENTS_RESPONSE"] = 544] = "GET_RELATED_ACH_N_TOURNAMENTS_RESPONSE";
87
+ ClassId[ClassId["GET_POINT_HISTORY_REQUEST"] = 545] = "GET_POINT_HISTORY_REQUEST";
88
+ ClassId[ClassId["GET_POINT_HISTORY_RESPONSE"] = 546] = "GET_POINT_HISTORY_RESPONSE";
87
89
  /*
88
90
  !Important, if adding new messages that are 'acting' on behalf of the client,
89
91
  you need to include them in the CLASS_ID_IGNORE_FOR_SIMULATION
@@ -483,7 +485,8 @@ const SAWTemplatesTransform = items => {
483
485
  prize_modifiers: p.saw_prize_ui_definition.prize_modifiers,
484
486
  allow_split_decimal: p.saw_prize_ui_definition.allow_split_decimal,
485
487
  hide_prize_from_history: p.saw_prize_ui_definition.hide_prize_from_history,
486
- requirements_to_get_prize: p.saw_prize_ui_definition.requirements_to_get_prize
488
+ requirements_to_get_prize: p.saw_prize_ui_definition.requirements_to_get_prize,
489
+ max_give_period_type_id: p.max_give_period_type_id
487
490
  };
488
491
  return y;
489
492
  })
@@ -613,6 +616,14 @@ var SAWExposeUserSpinId;
613
616
  SAWExposeUserSpinId[SAWExposeUserSpinId["SpinId"] = 2] = "SpinId";
614
617
  })(SAWExposeUserSpinId || (SAWExposeUserSpinId = {}));
615
618
 
619
+ var AttemptPeriodType;
620
+ (function (AttemptPeriodType) {
621
+ AttemptPeriodType[AttemptPeriodType["FromLastAttempt"] = 1] = "FromLastAttempt";
622
+ AttemptPeriodType[AttemptPeriodType["CalendarDaysUTC"] = 2] = "CalendarDaysUTC";
623
+ AttemptPeriodType[AttemptPeriodType["CalendarDaysUserTimeZone"] = 3] = "CalendarDaysUserTimeZone";
624
+ AttemptPeriodType[AttemptPeriodType["Lifetime"] = 4] = "Lifetime";
625
+ })(AttemptPeriodType || (AttemptPeriodType = {}));
626
+
616
627
  class NodeCache {
617
628
  constructor() {
618
629
  this.ttlChecker = void 0;
@@ -2092,6 +2103,7 @@ var onUpdateContextKey;
2092
2103
  onUpdateContextKey["JackpotEligibleGames"] = "jackpotEligibleGames";
2093
2104
  onUpdateContextKey["CurrentLevel"] = "currentLevel";
2094
2105
  onUpdateContextKey["InboxUnreadCount"] = "inboxUnreadCount";
2106
+ onUpdateContextKey["PointsHistory"] = "pointsHistory";
2095
2107
  })(onUpdateContextKey || (onUpdateContextKey = {}));
2096
2108
  /** @group General API */
2097
2109
  class WSAPI {
@@ -2143,10 +2155,13 @@ class WSAPI {
2143
2155
  }
2144
2156
  });
2145
2157
  on(ClassId.CLIENT_PUBLIC_PROPERTIES_CHANGED_EVENT, data => {
2146
- var _data$props, _data$props2;
2158
+ var _data$props, _data$props2, _data$props3, _data$props4, _data$props5;
2147
2159
  if ((data == null || (_data$props = data.props) == null ? void 0 : _data$props.core_inbox_unread_count) !== undefined && (data == null || (_data$props2 = data.props) == null ? void 0 : _data$props2.core_inbox_unread_count) !== null) {
2148
2160
  this.updateInboxUnreadCount(data.props.core_inbox_unread_count);
2149
2161
  }
2162
+ if ((data == null || (_data$props3 = data.props) == null ? void 0 : _data$props3.ach_points_balance) !== undefined || (data == null || (_data$props4 = data.props) == null ? void 0 : _data$props4.ach_gems_balance) !== undefined || (data == null || (_data$props5 = data.props) == null ? void 0 : _data$props5.ach_diamonds_balance) !== undefined) {
2163
+ this.notifyPointsHistoryUpdate();
2164
+ }
2150
2165
  });
2151
2166
  }
2152
2167
  }
@@ -2868,6 +2883,43 @@ class WSAPI {
2868
2883
  }) {
2869
2884
  this.api.reportEngagementAction(null, engagement_uid, activityType, action);
2870
2885
  }
2886
+ /**
2887
+ * Returns the points history for a user within a specified time range.
2888
+ * The response includes both points changes and gems/diamonds changes.
2889
+ * Each log entry contains information about the change amount, balance, and source.
2890
+ * The returned list is cached for 30 seconds.
2891
+ * You can pass the onUpdate callback as a parameter, it will be called every time the points history is updated and will provide the updated list of points history logs for the last 10 minutes.
2892
+ *
2893
+ * **Example**:
2894
+ * ```
2895
+ * const startTime = Math.floor(Date.now() / 1000) - 86400 * 30; // 30 days ago
2896
+ * const endTime = Math.floor(Date.now() / 1000); // now
2897
+ *
2898
+ * _smartico.api.getPointsHistory({
2899
+ * startTimeSeconds: startTime,
2900
+ * endTimeSeconds: endTime,
2901
+ * onUpdate: (data) => console.log('Updated:', data)
2902
+ * }).then((result) => {
2903
+ * console.log(result);
2904
+ * });
2905
+ * ```
2906
+ *
2907
+ * **Visitor mode: not supported**
2908
+ *
2909
+ * @param params.startTimeSeconds - Start time in seconds (epoch timestamp)
2910
+ * @param params.endTimeSeconds - End time in seconds (epoch timestamp)
2911
+ * @param params.onUpdate - Optional callback function that will be called when the points history is updated
2912
+ */
2913
+ async getPointsHistory({
2914
+ startTimeSeconds,
2915
+ endTimeSeconds,
2916
+ onUpdate
2917
+ }) {
2918
+ if (onUpdate) {
2919
+ this.onUpdateCallback.set(onUpdateContextKey.PointsHistory, onUpdate);
2920
+ }
2921
+ return await OCache.use(onUpdateContextKey.PointsHistory, ECacheContext.WSAPI, () => this.api.getPointsHistoryT(null, startTimeSeconds, endTimeSeconds), CACHE_DATA_SEC);
2922
+ }
2871
2923
  async updateOnSpin(data) {
2872
2924
  const templates = await OCache.use(onUpdateContextKey.Saw, ECacheContext.WSAPI, () => this.api.sawGetTemplatesT(null), CACHE_DATA_SEC);
2873
2925
  const index = templates.findIndex(t => t.id === data.saw_template_id);
@@ -2909,6 +2961,12 @@ class WSAPI {
2909
2961
  const payload = await this.api.getRafflesT(null);
2910
2962
  this.updateEntity(onUpdateContextKey.Raffles, payload);
2911
2963
  }
2964
+ async notifyPointsHistoryUpdate() {
2965
+ const startSeconds = Date.now() / 1000 - 600;
2966
+ const endSeconds = Date.now() / 1000;
2967
+ const payload = await this.api.getPointsHistoryT(null, startSeconds, endSeconds);
2968
+ this.updateEntity(onUpdateContextKey.PointsHistory, payload);
2969
+ }
2912
2970
  async updateEntity(contextKey, payload) {
2913
2971
  OCache.set(contextKey, payload, ECacheContext.WSAPI);
2914
2972
  const onUpdate = this.onUpdateCallback.get(contextKey);
@@ -3216,6 +3274,7 @@ var AchCustomSectionType;
3216
3274
  AchCustomSectionType[AchCustomSectionType["LOOTBOX_CALENDAR_DAYS"] = 11] = "LOOTBOX_CALENDAR_DAYS";
3217
3275
  AchCustomSectionType[AchCustomSectionType["TREASURE_HUNT"] = 12] = "TREASURE_HUNT";
3218
3276
  AchCustomSectionType[AchCustomSectionType["RAFFLE"] = 13] = "RAFFLE";
3277
+ AchCustomSectionType[AchCustomSectionType["BADGES"] = 14] = "BADGES";
3219
3278
  })(AchCustomSectionType || (AchCustomSectionType = {}));
3220
3279
  var AchCustomLayoutTheme;
3221
3280
  (function (AchCustomLayoutTheme) {
@@ -3275,6 +3334,8 @@ const UICustomSectionTransform = response => {
3275
3334
  ach_tournament_id: r.ach_tournament_id,
3276
3335
  show_raw_data: r.show_raw_data,
3277
3336
  liquid_template: r.liquid_template
3337
+ } : {}, r.section_type_id === AchCustomSectionType.BADGES ? {
3338
+ ach_category_ids: r.ach_category_ids
3278
3339
  } : {});
3279
3340
  items.push(x);
3280
3341
  }
@@ -3308,6 +3369,60 @@ var BonusStatus;
3308
3369
  BonusStatus[BonusStatus["EXPIRED"] = 6] = "EXPIRED";
3309
3370
  })(BonusStatus || (BonusStatus = {}));
3310
3371
 
3372
+ var UserBalanceType;
3373
+ (function (UserBalanceType) {
3374
+ UserBalanceType[UserBalanceType["Points"] = 0] = "Points";
3375
+ UserBalanceType[UserBalanceType["Gems"] = 1] = "Gems";
3376
+ UserBalanceType[UserBalanceType["Diamonds"] = 2] = "Diamonds";
3377
+ })(UserBalanceType || (UserBalanceType = {}));
3378
+
3379
+ const PointsHistoryTransform = items => {
3380
+ if (!items) {
3381
+ return [];
3382
+ }
3383
+ return items.map(item => {
3384
+ const itemTransformed = {
3385
+ create_date: item.create_date,
3386
+ user_ext_id: item.user_ext_id,
3387
+ crm_brand_id: item.crm_brand_id,
3388
+ source_type_id: item.source_type_id
3389
+ };
3390
+ if (item.type === UserBalanceType.Diamonds || item.type === UserBalanceType.Gems) {
3391
+ itemTransformed.type = item.type;
3392
+ itemTransformed.amount = item.amount;
3393
+ itemTransformed.balance = item.balance;
3394
+ }
3395
+ if (item.type === UserBalanceType.Points) {
3396
+ itemTransformed.type = UserBalanceType.Points;
3397
+ itemTransformed.amount = item.points_collected;
3398
+ itemTransformed.balance = item.user_points_balance;
3399
+ itemTransformed.total_ever = item.user_points_ever;
3400
+ }
3401
+ return itemTransformed;
3402
+ });
3403
+ };
3404
+
3405
+ var PointChangeSourceType;
3406
+ (function (PointChangeSourceType) {
3407
+ PointChangeSourceType[PointChangeSourceType["Journey"] = 1] = "Journey";
3408
+ PointChangeSourceType[PointChangeSourceType["AchievementTaskCompletion"] = 2] = "AchievementTaskCompletion";
3409
+ PointChangeSourceType[PointChangeSourceType["AchievementCompletion"] = 3] = "AchievementCompletion";
3410
+ PointChangeSourceType[PointChangeSourceType["LevelsStructureChange"] = 4] = "LevelsStructureChange";
3411
+ PointChangeSourceType[PointChangeSourceType["StorePurchase"] = 5] = "StorePurchase";
3412
+ PointChangeSourceType[PointChangeSourceType["ManualAdjustment"] = 6] = "ManualAdjustment";
3413
+ PointChangeSourceType[PointChangeSourceType["Leaderboard"] = 7] = "Leaderboard";
3414
+ PointChangeSourceType[PointChangeSourceType["Tournament"] = 11] = "Tournament";
3415
+ PointChangeSourceType[PointChangeSourceType["AutomationRule"] = 12] = "AutomationRule";
3416
+ PointChangeSourceType[PointChangeSourceType["TournamentRegistration"] = 13] = "TournamentRegistration";
3417
+ PointChangeSourceType[PointChangeSourceType["TournamentRegistrationCancellation"] = 14] = "TournamentRegistrationCancellation";
3418
+ PointChangeSourceType[PointChangeSourceType["RefundPoints"] = 15] = "RefundPoints";
3419
+ PointChangeSourceType[PointChangeSourceType["PlayMiniGame"] = 16] = "PlayMiniGame";
3420
+ PointChangeSourceType[PointChangeSourceType["WinMiniGame"] = 17] = "WinMiniGame";
3421
+ PointChangeSourceType[PointChangeSourceType["API"] = 18] = "API";
3422
+ PointChangeSourceType[PointChangeSourceType["DynamicFormula"] = 19] = "DynamicFormula";
3423
+ PointChangeSourceType[PointChangeSourceType["Raffle"] = 21] = "Raffle";
3424
+ })(PointChangeSourceType || (PointChangeSourceType = {}));
3425
+
3311
3426
  /**
3312
3427
  * @ignore
3313
3428
  */
@@ -4091,6 +4206,16 @@ class SmarticoAPI {
4091
4206
  const message = this.buildMessage(user_ext_id, ClassId.RAF_CLAIM_PRIZE_REQUEST, props);
4092
4207
  return await this.send(message, ClassId.RAF_CLAIM_PRIZE_RESPONSE);
4093
4208
  }
4209
+ async getPointsHistory(user_ext_id, startTimeSeconds, endTimeSeconds) {
4210
+ const message = this.buildMessage(user_ext_id, ClassId.GET_POINT_HISTORY_REQUEST, {
4211
+ startTimeSeconds,
4212
+ endTimeSeconds
4213
+ });
4214
+ return await this.send(message, ClassId.GET_POINT_HISTORY_RESPONSE);
4215
+ }
4216
+ async getPointsHistoryT(user_ext_id, startTimeSeconds, endTimeSeconds) {
4217
+ return PointsHistoryTransform((await this.getPointsHistory(user_ext_id, startTimeSeconds, endTimeSeconds)).logHistory);
4218
+ }
4094
4219
  }
4095
4220
 
4096
4221
  class CookieStore {
@@ -4556,5 +4681,5 @@ var JackpotType;
4556
4681
  JackpotType[JackpotType["Personal"] = 2] = "Personal";
4557
4682
  })(JackpotType || (JackpotType = {}));
4558
4683
 
4559
- export { AchCategoryTransform, AchCustomLayoutTheme, AchCustomSectionType, AchMissionsTabsOptions, AchOverviewMissionsFilter, AchievementAvailabilityStatus, AchievementStatus, AchievementTaskType, AchievementType, ActivityTypeLimited, AnalyticsInboxSubScreenNameId, AnalyticsInterfaceType, AnalyticsScreenNameId, AnalyticsTournamentsLobbySubScreenNameId, 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, PrizeModifiers, PrizeModifiersKeysNames, PublicLabelSettings, QuizAnswersValueType, QuizMarketPerSport, QuizSportType, SAWAcknowledgeType, SAWAcknowledgeTypeName, SAWAcknowledgeTypeNamed, SAWAskForUsername, SAWBuyInType, SAWBuyInTypeName, SAWBuyInTypeNamed, SAWExposeUserSpinId, SAWGPMarketType, SAWGameDifficultyType, SAWGameDifficultyTypeName, SAWGameLayout, 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, enrichUserAchievementsWithBadgeState, getLeaderBoardTransform, marketsInfo, quizAnswerAwayTeamReplacementText, quizAnswerHomeTeamReplacementText, quizAnswersTrKeys, quizDrawReplacementText, quizEvenReplacementText, quizNoGoalsReplacementText, quizNoReplacementText, quizOddReplacementText, quizOrReplacementText, quizSupportedSports, quizYesReplacementText, tournamentInfoItemTransform };
4684
+ export { AchCategoryTransform, AchCustomLayoutTheme, AchCustomSectionType, AchMissionsTabsOptions, AchOverviewMissionsFilter, AchievementAvailabilityStatus, AchievementStatus, AchievementTaskType, AchievementType, 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, PointsHistoryTransform, PrizeModifiers, PrizeModifiersKeysNames, PublicLabelSettings, QuizAnswersValueType, QuizMarketPerSport, QuizSportType, SAWAcknowledgeType, SAWAcknowledgeTypeName, SAWAcknowledgeTypeNamed, SAWAskForUsername, SAWBuyInType, SAWBuyInTypeName, SAWBuyInTypeNamed, SAWExposeUserSpinId, SAWGPMarketType, SAWGameDifficultyType, SAWGameDifficultyTypeName, SAWGameLayout, 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, enrichUserAchievementsWithBadgeState, getLeaderBoardTransform, marketsInfo, quizAnswerAwayTeamReplacementText, quizAnswerHomeTeamReplacementText, quizAnswersTrKeys, quizDrawReplacementText, quizEvenReplacementText, quizNoGoalsReplacementText, quizNoReplacementText, quizOddReplacementText, quizOrReplacementText, quizSupportedSports, quizYesReplacementText, tournamentInfoItemTransform };
4560
4685
  //# sourceMappingURL=index.modern.mjs.map