@smartico/public-api 0.0.103 → 0.0.105

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/README.md CHANGED
@@ -43,6 +43,8 @@ See the [API documentation](docs/classes/WSAPI.md) for all available methods and
43
43
 
44
44
  ## Backend usage (NodeJS context)
45
45
 
46
+ Note: access to the API is not provided by default and is topic for a separate agreement with Smartico
47
+
46
48
  ### Installation
47
49
 
48
50
  ```bash
@@ -5,7 +5,6 @@ export interface SAWTemplateUI {
5
5
  description?: string;
6
6
  over_limit_message?: string;
7
7
  no_attempts_message?: string;
8
- no_points_message?: string;
9
8
  thumbnail?: string;
10
9
  sectors_count: number;
11
10
  priority: number;
@@ -4,6 +4,7 @@ import { TournamentRegistrationStatus } from "./TournamentRegistrationStatus";
4
4
  import { TournamentType } from "./TournamentType";
5
5
  import { TournamentPublicMeta } from "./TournamentPublicMeta";
6
6
  import { TTournament } from "../WSAPI/WSAPITypes";
7
+ import { TournamentPlayer, TournamentPrize } from ".";
7
8
  import { AchRelatedGame } from "../Base/AchRelatedGame";
8
9
  export interface Tournament {
9
10
  /** ID of tournament template */
@@ -46,6 +47,12 @@ export interface Tournament {
46
47
  playersMaxCount?: number;
47
48
  /** Tournament duration in millisecnnds */
48
49
  durationMs?: number;
50
+ /** prizes structure */
51
+ prizeStructure?: {
52
+ prizes: TournamentPrize[];
53
+ };
54
+ /** Information about current user */
55
+ tournamentPlayer?: TournamentPlayer;
49
56
  /** List of casino games (or other types of entities) related to the tournament */
50
57
  related_games?: AchRelatedGame[];
51
58
  }
@@ -1,4 +1,6 @@
1
1
  import { Tournament } from "./Tournament";
2
+ import { TournamentPlayer } from "./TournamentPlayer";
3
+ import { TournamentPrize } from "./TournamentPrize";
2
4
  export declare class TournamentUtils {
3
5
  static isCanRegister: (tournament: Tournament) => boolean;
4
6
  static isInProgress: (tournament: Tournament) => boolean;
@@ -6,4 +8,20 @@ export declare class TournamentUtils {
6
8
  static isFinished: (tournament: Tournament) => boolean;
7
9
  static isCancelled: (tournament: Tournament) => boolean;
8
10
  static isUpcoming: (tournament: Tournament) => boolean;
11
+ static getPlayerTransformed: (player: TournamentPlayer, isMe?: boolean) => {
12
+ public_username: string;
13
+ avatar_url: string;
14
+ position: number;
15
+ scores: number;
16
+ is_me: boolean;
17
+ };
18
+ static getPrizeTransformed: (prize: TournamentPrize) => {
19
+ type: any;
20
+ name: string;
21
+ description: string;
22
+ image_url: string;
23
+ place_from: number;
24
+ place_to: number;
25
+ points: number;
26
+ };
9
27
  }
@@ -58,10 +58,8 @@ export interface TMiniGameTemplate {
58
58
  next_available_spin_ts: number;
59
59
  /** The message that should be shown to the user when he cannot play the game, server rejected attempt with error code SAWSpinErrorCode.SAW_FAILED_MAX_SPINS_REACHED */
60
60
  over_limit_message: string;
61
- /** The message that should be shown to the user when he cannot play the game because he doesn't have spin attempts. */
61
+ /** The message that should be shown to the user when he cannot play the game because he doesn't have spin attempts or points. */
62
62
  no_attempts_message: string;
63
- /** The message that should be shown to the user when he cannot play the game because he doesn't have points. */
64
- no_points_message: string;
65
63
  /** Current jackpont amount, if jackpot is enabled. */
66
64
  jackpot_current: number;
67
65
  /** The amount that will be added to the jackpot every time when somebody plays the game. Note that the contribution amount is abstract, means that no money or points are deducted from the user balance. */
@@ -171,6 +169,35 @@ export interface TTournament {
171
169
  is_featured: boolean;
172
170
  /** The ribbon of the tournament item. Can be 'sale', 'hot', 'new', 'vip' or URL to the image in case of custom ribbon */
173
171
  ribbon: TRibbon;
172
+ /** A number is used to order the tournaments, representing their priority in the list */
173
+ priority: number;
174
+ /** Info about current player in tournament */
175
+ me?: {
176
+ /** The username of the participant */
177
+ public_username: string;
178
+ /** The URL to the avatar of the participant */
179
+ avatar_url: string;
180
+ /** The position of the participant in the tournament */
181
+ position: number;
182
+ /** The scores of the participant in the tournament */
183
+ scores: number;
184
+ };
185
+ /** Prize structure */
186
+ prizes?: {
187
+ /** The name of the prize */
188
+ name: string;
189
+ /** The description of the prize */
190
+ description: string;
191
+ /** The image of the prize */
192
+ image_url: string;
193
+ /** from-to range of the places to which this prize */
194
+ place_from: number;
195
+ place_to: number;
196
+ /** type of the prize: TANGIBLE, POINTS_ADD, POINTS_DEDUCT, POINTS_RESET, MINI_GAME_ATTEMPT, BONUS */
197
+ type: string;
198
+ /** if the prize is points related, indicates amount of points */
199
+ points?: number;
200
+ }[];
174
201
  /** The time when tournament is going to start, epoch with milliseconds */
175
202
  start_time: number;
176
203
  /** The time when tournament is going to finish, epoch with milliseconds */
package/dist/index.js CHANGED
@@ -284,7 +284,6 @@ var SAWTemplatesTransform = function SAWTemplatesTransform(items) {
284
284
  thumbnail: (_r$saw_skin_ui_defini = r.saw_skin_ui_definition) != null && _r$saw_skin_ui_defini.skin_folder ? ((_r$saw_skin_ui_defini2 = r.saw_skin_ui_definition) == null ? void 0 : _r$saw_skin_ui_defini2.skin_folder) + '/ico.png' : "https://libs.smartico.ai/gf/images/saw/" + r.saw_skin_key + "/ico.png",
285
285
  over_limit_message: r.saw_template_ui_definition.over_limit_message,
286
286
  no_attempts_message: r.saw_template_ui_definition.no_attempts_message,
287
- no_points_message: r.saw_template_ui_definition.no_points_message,
288
287
  jackpot_symbol: r.saw_template_ui_definition.jackpot_symbol,
289
288
  saw_game_type: SAWGameTypeNamed(r.saw_game_type_id),
290
289
  saw_buyin_type: SAWBuyInTypeNamed(r.saw_buyin_type_id),
@@ -723,6 +722,7 @@ var TournamentItemsTransform = function TournamentItemsTransform(items) {
723
722
  custom_data: IntUtils.JsonOrText(r.publicMeta.custom_data),
724
723
  is_featured: r.publicMeta.featured,
725
724
  ribbon: r.publicMeta.label_tag,
725
+ priority: r.publicMeta.position,
726
726
  start_time: r.startTimeTs,
727
727
  end_time: r.endTimeTs,
728
728
  registration_count: r.registrationCount,
@@ -740,57 +740,18 @@ var TournamentItemsTransform = function TournamentItemsTransform(items) {
740
740
  is_in_progress: TournamentUtils.isInProgress(r),
741
741
  is_upcoming: TournamentUtils.isUpcoming(r)
742
742
  };
743
+ if (r.prizeStructure) {
744
+ x.prizes = r.prizeStructure.prizes.map(function (p) {
745
+ return TournamentUtils.getPrizeTransformed(p);
746
+ });
747
+ }
748
+ if (r.tournamentPlayer) {
749
+ x.me = TournamentUtils.getPlayerTransformed(r.tournamentPlayer, true);
750
+ }
743
751
  return x;
744
752
  });
745
753
  };
746
754
 
747
- var tournamentPrizeTypeToPrizeName = function tournamentPrizeTypeToPrizeName(type) {
748
- var _ActivityTypeLimited$;
749
- return (_ActivityTypeLimited$ = {}, _ActivityTypeLimited$[exports.ActivityTypeLimited.DoNothing] = 'TANGIBLE', _ActivityTypeLimited$[exports.ActivityTypeLimited.Points] = 'POINTS_ADD', _ActivityTypeLimited$[exports.ActivityTypeLimited.DeductPoints] = 'POINTS_DEDUCT', _ActivityTypeLimited$[exports.ActivityTypeLimited.ResetPoints] = 'POINTS_RESET', _ActivityTypeLimited$[exports.ActivityTypeLimited.MiniGameAttempt] = "MINI_GAME_ATTEMPT", _ActivityTypeLimited$[exports.ActivityTypeLimited.Bonus] = 'BONUS', _ActivityTypeLimited$)[type];
750
- };
751
- var tournamentInfoItemTransform = function tournamentInfoItemTransform(t) {
752
- var response = _extends({}, TournamentItemsTransform([t.tournamentInfo.tournamentLobbyInfo])[0], {
753
- related_games: (t.tournamentInfo.tournamentLobbyInfo.related_games || []).map(function (g) {
754
- return {
755
- ext_game_id: g.ext_game_id,
756
- game_public_meta: {
757
- name: g.game_public_meta.name,
758
- link: g.game_public_meta.link,
759
- image: g.game_public_meta.image,
760
- enabled: g.game_public_meta.enabled,
761
- game_categories: g.game_public_meta.game_categories,
762
- game_provider: g.game_public_meta.game_provider
763
- }
764
- };
765
- }),
766
- players: t.tournamentInfo.players.map(function (p) {
767
- return {
768
- public_username: p.userAltName,
769
- avatar_url: p.avatar_url,
770
- position: p.position,
771
- scores: p.scores,
772
- is_me: p.isMe
773
- };
774
- })
775
- });
776
- if (t.prizeStructure) {
777
- response.prizes = t.prizeStructure.prizes.map(function (p) {
778
- return _extends({}, p, {
779
- type: tournamentPrizeTypeToPrizeName(p.type)
780
- });
781
- });
782
- }
783
- if (t.userPosition) {
784
- response.me = {
785
- public_username: t.userPosition.userAltName,
786
- avatar_url: t.userPosition.avatar_url,
787
- position: t.userPosition.position,
788
- scores: t.userPosition.scores
789
- };
790
- }
791
- return response;
792
- };
793
-
794
755
  exports.TournamentInstanceStatus = void 0;
795
756
  (function (TournamentInstanceStatus) {
796
757
  TournamentInstanceStatus[TournamentInstanceStatus["PUBLISHED"] = 1] = "PUBLISHED";
@@ -806,26 +767,10 @@ var TournamentInstanceStatusName = function TournamentInstanceStatusName(s) {
806
767
  return (_TournamentInstanceSt = {}, _TournamentInstanceSt[exports.TournamentInstanceStatus.PUBLISHED] = "PUBLISHED", _TournamentInstanceSt[exports.TournamentInstanceStatus.REGISTER] = "REGISTER", _TournamentInstanceSt[exports.TournamentInstanceStatus.STARTED] = "STARTED", _TournamentInstanceSt[exports.TournamentInstanceStatus.FINISHED] = "FINISHED", _TournamentInstanceSt[exports.TournamentInstanceStatus.CANCELLED] = "CANCELLED", _TournamentInstanceSt[exports.TournamentInstanceStatus.FAILED] = "FAILED", _TournamentInstanceSt[exports.TournamentInstanceStatus.FINALIZING] = "FINALIZING", _TournamentInstanceSt)[s];
807
768
  };
808
769
 
809
- exports.TournamentRegistrationError = void 0;
810
- (function (TournamentRegistrationError) {
811
- TournamentRegistrationError[TournamentRegistrationError["NO_ERROR"] = 0] = "NO_ERROR";
812
- TournamentRegistrationError[TournamentRegistrationError["TOURNAMENT_INSTANCE_NOT_FOUND"] = 30001] = "TOURNAMENT_INSTANCE_NOT_FOUND";
813
- TournamentRegistrationError[TournamentRegistrationError["TOURNAMENT_REGISTRATION_NOT_ENOUGH_POINTS"] = 30002] = "TOURNAMENT_REGISTRATION_NOT_ENOUGH_POINTS";
814
- TournamentRegistrationError[TournamentRegistrationError["TOURNAMENT_INSTANCE_NOT_IN_STATE"] = 30003] = "TOURNAMENT_INSTANCE_NOT_IN_STATE";
815
- TournamentRegistrationError[TournamentRegistrationError["TOURNAMENT_ALREADY_REGISTERED"] = 30004] = "TOURNAMENT_ALREADY_REGISTERED";
816
- TournamentRegistrationError[TournamentRegistrationError["TOURNAMENT_USER_DONT_MATCH_CONDITIONS"] = 30005] = "TOURNAMENT_USER_DONT_MATCH_CONDITIONS";
817
- TournamentRegistrationError[TournamentRegistrationError["TOURNAMENT_USER_NOT_REGISTERED"] = 30006] = "TOURNAMENT_USER_NOT_REGISTERED";
818
- TournamentRegistrationError[TournamentRegistrationError["TOURNAMENT_CANT_CHANGE_REGISTRATION_STATUS"] = 30007] = "TOURNAMENT_CANT_CHANGE_REGISTRATION_STATUS";
819
- TournamentRegistrationError[TournamentRegistrationError["TOURNAMENT_MAX_REGISTRATIONS_REACHED"] = 30008] = "TOURNAMENT_MAX_REGISTRATIONS_REACHED";
820
- })(exports.TournamentRegistrationError || (exports.TournamentRegistrationError = {}));
821
-
822
- exports.TournamentType = void 0;
823
- (function (TournamentType) {
824
- TournamentType[TournamentType["SCHEDULED"] = 1] = "SCHEDULED";
825
- TournamentType[TournamentType["SNG"] = 2] = "SNG";
826
- TournamentType[TournamentType["TEST"] = 3] = "TEST";
827
- })(exports.TournamentType || (exports.TournamentType = {}));
828
-
770
+ var tournamentPrizeTypeToPrizeName = function tournamentPrizeTypeToPrizeName(type) {
771
+ var _ActivityTypeLimited$;
772
+ return (_ActivityTypeLimited$ = {}, _ActivityTypeLimited$[exports.ActivityTypeLimited.DoNothing] = 'TANGIBLE', _ActivityTypeLimited$[exports.ActivityTypeLimited.Points] = 'POINTS_ADD', _ActivityTypeLimited$[exports.ActivityTypeLimited.DeductPoints] = 'POINTS_DEDUCT', _ActivityTypeLimited$[exports.ActivityTypeLimited.ResetPoints] = 'POINTS_RESET', _ActivityTypeLimited$[exports.ActivityTypeLimited.MiniGameAttempt] = "MINI_GAME_ATTEMPT", _ActivityTypeLimited$[exports.ActivityTypeLimited.Bonus] = 'BONUS', _ActivityTypeLimited$)[type];
773
+ };
829
774
  var TournamentUtils = function TournamentUtils() {};
830
775
  TournamentUtils.isCanRegister = function (tournament) {
831
776
  if (tournament) {
@@ -866,6 +811,75 @@ TournamentUtils.isUpcoming = function (tournament) {
866
811
  }
867
812
  return false;
868
813
  };
814
+ TournamentUtils.getPlayerTransformed = function (player, isMe) {
815
+ if (player) {
816
+ var playerTransformed = {
817
+ public_username: player.userAltName,
818
+ avatar_url: player.avatar_url,
819
+ position: player.position,
820
+ scores: player.scores,
821
+ is_me: player.isMe
822
+ };
823
+ if (isMe) {
824
+ delete playerTransformed.is_me;
825
+ }
826
+ return playerTransformed;
827
+ }
828
+ return null;
829
+ };
830
+ TournamentUtils.getPrizeTransformed = function (prize) {
831
+ if (prize) {
832
+ return _extends({}, prize, {
833
+ type: tournamentPrizeTypeToPrizeName(prize.type)
834
+ });
835
+ }
836
+ return null;
837
+ };
838
+
839
+ var tournamentInfoItemTransform = function tournamentInfoItemTransform(t) {
840
+ var response = _extends({}, TournamentItemsTransform([t.tournamentInfo.tournamentLobbyInfo])[0], {
841
+ related_games: (t.tournamentInfo.tournamentLobbyInfo.related_games || []).map(function (g) {
842
+ return {
843
+ ext_game_id: g.ext_game_id,
844
+ game_public_meta: {
845
+ name: g.game_public_meta.name,
846
+ link: g.game_public_meta.link,
847
+ image: g.game_public_meta.image,
848
+ enabled: g.game_public_meta.enabled,
849
+ game_categories: g.game_public_meta.game_categories,
850
+ game_provider: g.game_public_meta.game_provider
851
+ }
852
+ };
853
+ }),
854
+ players: t.tournamentInfo.players.map(function (p) {
855
+ return TournamentUtils.getPlayerTransformed(p);
856
+ })
857
+ });
858
+ if (t.userPosition) {
859
+ response.me = TournamentUtils.getPlayerTransformed(t.userPosition, true);
860
+ }
861
+ return response;
862
+ };
863
+
864
+ exports.TournamentRegistrationError = void 0;
865
+ (function (TournamentRegistrationError) {
866
+ TournamentRegistrationError[TournamentRegistrationError["NO_ERROR"] = 0] = "NO_ERROR";
867
+ TournamentRegistrationError[TournamentRegistrationError["TOURNAMENT_INSTANCE_NOT_FOUND"] = 30001] = "TOURNAMENT_INSTANCE_NOT_FOUND";
868
+ TournamentRegistrationError[TournamentRegistrationError["TOURNAMENT_REGISTRATION_NOT_ENOUGH_POINTS"] = 30002] = "TOURNAMENT_REGISTRATION_NOT_ENOUGH_POINTS";
869
+ TournamentRegistrationError[TournamentRegistrationError["TOURNAMENT_INSTANCE_NOT_IN_STATE"] = 30003] = "TOURNAMENT_INSTANCE_NOT_IN_STATE";
870
+ TournamentRegistrationError[TournamentRegistrationError["TOURNAMENT_ALREADY_REGISTERED"] = 30004] = "TOURNAMENT_ALREADY_REGISTERED";
871
+ TournamentRegistrationError[TournamentRegistrationError["TOURNAMENT_USER_DONT_MATCH_CONDITIONS"] = 30005] = "TOURNAMENT_USER_DONT_MATCH_CONDITIONS";
872
+ TournamentRegistrationError[TournamentRegistrationError["TOURNAMENT_USER_NOT_REGISTERED"] = 30006] = "TOURNAMENT_USER_NOT_REGISTERED";
873
+ TournamentRegistrationError[TournamentRegistrationError["TOURNAMENT_CANT_CHANGE_REGISTRATION_STATUS"] = 30007] = "TOURNAMENT_CANT_CHANGE_REGISTRATION_STATUS";
874
+ TournamentRegistrationError[TournamentRegistrationError["TOURNAMENT_MAX_REGISTRATIONS_REACHED"] = 30008] = "TOURNAMENT_MAX_REGISTRATIONS_REACHED";
875
+ })(exports.TournamentRegistrationError || (exports.TournamentRegistrationError = {}));
876
+
877
+ exports.TournamentType = void 0;
878
+ (function (TournamentType) {
879
+ TournamentType[TournamentType["SCHEDULED"] = 1] = "SCHEDULED";
880
+ TournamentType[TournamentType["SNG"] = 2] = "SNG";
881
+ TournamentType[TournamentType["TEST"] = 3] = "TEST";
882
+ })(exports.TournamentType || (exports.TournamentType = {}));
869
883
 
870
884
  var GetLevelMapResponseTransform = function GetLevelMapResponseTransform(levels) {
871
885
  return levels == null ? void 0 : levels.levels.map(function (l) {