@smartico/public-api 0.0.104 → 0.0.106

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,9 @@ 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 server-to-server API is not provided by default and is a topic for a separate agreement with Smartico.
47
+ We recommend using a front-end API approach in most cases.
48
+
46
49
  ### Installation
47
50
 
48
51
  ```bash
@@ -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
  }
@@ -169,6 +169,35 @@ export interface TTournament {
169
169
  is_featured: boolean;
170
170
  /** The ribbon of the tournament item. Can be 'sale', 'hot', 'new', 'vip' or URL to the image in case of custom ribbon */
171
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
+ }[];
172
201
  /** The time when tournament is going to start, epoch with milliseconds */
173
202
  start_time: number;
174
203
  /** The time when tournament is going to finish, epoch with milliseconds */
package/dist/index.js CHANGED
@@ -722,6 +722,7 @@ var TournamentItemsTransform = function TournamentItemsTransform(items) {
722
722
  custom_data: IntUtils.JsonOrText(r.publicMeta.custom_data),
723
723
  is_featured: r.publicMeta.featured,
724
724
  ribbon: r.publicMeta.label_tag,
725
+ priority: r.publicMeta.position,
725
726
  start_time: r.startTimeTs,
726
727
  end_time: r.endTimeTs,
727
728
  registration_count: r.registrationCount,
@@ -739,57 +740,18 @@ var TournamentItemsTransform = function TournamentItemsTransform(items) {
739
740
  is_in_progress: TournamentUtils.isInProgress(r),
740
741
  is_upcoming: TournamentUtils.isUpcoming(r)
741
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
+ }
742
751
  return x;
743
752
  });
744
753
  };
745
754
 
746
- var tournamentPrizeTypeToPrizeName = function tournamentPrizeTypeToPrizeName(type) {
747
- var _ActivityTypeLimited$;
748
- 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];
749
- };
750
- var tournamentInfoItemTransform = function tournamentInfoItemTransform(t) {
751
- var response = _extends({}, TournamentItemsTransform([t.tournamentInfo.tournamentLobbyInfo])[0], {
752
- related_games: (t.tournamentInfo.tournamentLobbyInfo.related_games || []).map(function (g) {
753
- return {
754
- ext_game_id: g.ext_game_id,
755
- game_public_meta: {
756
- name: g.game_public_meta.name,
757
- link: g.game_public_meta.link,
758
- image: g.game_public_meta.image,
759
- enabled: g.game_public_meta.enabled,
760
- game_categories: g.game_public_meta.game_categories,
761
- game_provider: g.game_public_meta.game_provider
762
- }
763
- };
764
- }),
765
- players: t.tournamentInfo.players.map(function (p) {
766
- return {
767
- public_username: p.userAltName,
768
- avatar_url: p.avatar_url,
769
- position: p.position,
770
- scores: p.scores,
771
- is_me: p.isMe
772
- };
773
- })
774
- });
775
- if (t.prizeStructure) {
776
- response.prizes = t.prizeStructure.prizes.map(function (p) {
777
- return _extends({}, p, {
778
- type: tournamentPrizeTypeToPrizeName(p.type)
779
- });
780
- });
781
- }
782
- if (t.userPosition) {
783
- response.me = {
784
- public_username: t.userPosition.userAltName,
785
- avatar_url: t.userPosition.avatar_url,
786
- position: t.userPosition.position,
787
- scores: t.userPosition.scores
788
- };
789
- }
790
- return response;
791
- };
792
-
793
755
  exports.TournamentInstanceStatus = void 0;
794
756
  (function (TournamentInstanceStatus) {
795
757
  TournamentInstanceStatus[TournamentInstanceStatus["PUBLISHED"] = 1] = "PUBLISHED";
@@ -805,26 +767,10 @@ var TournamentInstanceStatusName = function TournamentInstanceStatusName(s) {
805
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];
806
768
  };
807
769
 
808
- exports.TournamentRegistrationError = void 0;
809
- (function (TournamentRegistrationError) {
810
- TournamentRegistrationError[TournamentRegistrationError["NO_ERROR"] = 0] = "NO_ERROR";
811
- TournamentRegistrationError[TournamentRegistrationError["TOURNAMENT_INSTANCE_NOT_FOUND"] = 30001] = "TOURNAMENT_INSTANCE_NOT_FOUND";
812
- TournamentRegistrationError[TournamentRegistrationError["TOURNAMENT_REGISTRATION_NOT_ENOUGH_POINTS"] = 30002] = "TOURNAMENT_REGISTRATION_NOT_ENOUGH_POINTS";
813
- TournamentRegistrationError[TournamentRegistrationError["TOURNAMENT_INSTANCE_NOT_IN_STATE"] = 30003] = "TOURNAMENT_INSTANCE_NOT_IN_STATE";
814
- TournamentRegistrationError[TournamentRegistrationError["TOURNAMENT_ALREADY_REGISTERED"] = 30004] = "TOURNAMENT_ALREADY_REGISTERED";
815
- TournamentRegistrationError[TournamentRegistrationError["TOURNAMENT_USER_DONT_MATCH_CONDITIONS"] = 30005] = "TOURNAMENT_USER_DONT_MATCH_CONDITIONS";
816
- TournamentRegistrationError[TournamentRegistrationError["TOURNAMENT_USER_NOT_REGISTERED"] = 30006] = "TOURNAMENT_USER_NOT_REGISTERED";
817
- TournamentRegistrationError[TournamentRegistrationError["TOURNAMENT_CANT_CHANGE_REGISTRATION_STATUS"] = 30007] = "TOURNAMENT_CANT_CHANGE_REGISTRATION_STATUS";
818
- TournamentRegistrationError[TournamentRegistrationError["TOURNAMENT_MAX_REGISTRATIONS_REACHED"] = 30008] = "TOURNAMENT_MAX_REGISTRATIONS_REACHED";
819
- })(exports.TournamentRegistrationError || (exports.TournamentRegistrationError = {}));
820
-
821
- exports.TournamentType = void 0;
822
- (function (TournamentType) {
823
- TournamentType[TournamentType["SCHEDULED"] = 1] = "SCHEDULED";
824
- TournamentType[TournamentType["SNG"] = 2] = "SNG";
825
- TournamentType[TournamentType["TEST"] = 3] = "TEST";
826
- })(exports.TournamentType || (exports.TournamentType = {}));
827
-
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
+ };
828
774
  var TournamentUtils = function TournamentUtils() {};
829
775
  TournamentUtils.isCanRegister = function (tournament) {
830
776
  if (tournament) {
@@ -865,6 +811,80 @@ TournamentUtils.isUpcoming = function (tournament) {
865
811
  }
866
812
  return false;
867
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.prizeStructure) {
859
+ response.prizes = t.prizeStructure.prizes.map(function (p) {
860
+ return TournamentUtils.getPrizeTransformed(p);
861
+ });
862
+ }
863
+ if (t.userPosition) {
864
+ response.me = TournamentUtils.getPlayerTransformed(t.userPosition, true);
865
+ }
866
+ return response;
867
+ };
868
+
869
+ exports.TournamentRegistrationError = void 0;
870
+ (function (TournamentRegistrationError) {
871
+ TournamentRegistrationError[TournamentRegistrationError["NO_ERROR"] = 0] = "NO_ERROR";
872
+ TournamentRegistrationError[TournamentRegistrationError["TOURNAMENT_INSTANCE_NOT_FOUND"] = 30001] = "TOURNAMENT_INSTANCE_NOT_FOUND";
873
+ TournamentRegistrationError[TournamentRegistrationError["TOURNAMENT_REGISTRATION_NOT_ENOUGH_POINTS"] = 30002] = "TOURNAMENT_REGISTRATION_NOT_ENOUGH_POINTS";
874
+ TournamentRegistrationError[TournamentRegistrationError["TOURNAMENT_INSTANCE_NOT_IN_STATE"] = 30003] = "TOURNAMENT_INSTANCE_NOT_IN_STATE";
875
+ TournamentRegistrationError[TournamentRegistrationError["TOURNAMENT_ALREADY_REGISTERED"] = 30004] = "TOURNAMENT_ALREADY_REGISTERED";
876
+ TournamentRegistrationError[TournamentRegistrationError["TOURNAMENT_USER_DONT_MATCH_CONDITIONS"] = 30005] = "TOURNAMENT_USER_DONT_MATCH_CONDITIONS";
877
+ TournamentRegistrationError[TournamentRegistrationError["TOURNAMENT_USER_NOT_REGISTERED"] = 30006] = "TOURNAMENT_USER_NOT_REGISTERED";
878
+ TournamentRegistrationError[TournamentRegistrationError["TOURNAMENT_CANT_CHANGE_REGISTRATION_STATUS"] = 30007] = "TOURNAMENT_CANT_CHANGE_REGISTRATION_STATUS";
879
+ TournamentRegistrationError[TournamentRegistrationError["TOURNAMENT_MAX_REGISTRATIONS_REACHED"] = 30008] = "TOURNAMENT_MAX_REGISTRATIONS_REACHED";
880
+ })(exports.TournamentRegistrationError || (exports.TournamentRegistrationError = {}));
881
+
882
+ exports.TournamentType = void 0;
883
+ (function (TournamentType) {
884
+ TournamentType[TournamentType["SCHEDULED"] = 1] = "SCHEDULED";
885
+ TournamentType[TournamentType["SNG"] = 2] = "SNG";
886
+ TournamentType[TournamentType["TEST"] = 3] = "TEST";
887
+ })(exports.TournamentType || (exports.TournamentType = {}));
868
888
 
869
889
  var GetLevelMapResponseTransform = function GetLevelMapResponseTransform(levels) {
870
890
  return levels == null ? void 0 : levels.levels.map(function (l) {