@mtgame/core 2.0.8 → 2.0.10

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 (38) hide show
  1. package/api/media-api.d.ts +2 -1
  2. package/api/public-team-api.d.ts +2 -0
  3. package/api/tournament-api.d.ts +2 -0
  4. package/api/volleyball-game-api.d.ts +1 -0
  5. package/esm2020/api/media-api.mjs +5 -1
  6. package/esm2020/api/public-team-api.mjs +8 -1
  7. package/esm2020/api/tournament-api.mjs +1 -1
  8. package/esm2020/api/volleyball-game-api.mjs +7 -1
  9. package/esm2020/localization/waterpolo-game-log-types.mjs +3 -3
  10. package/esm2020/models/basketball-game-log.mjs +1 -1
  11. package/esm2020/models/game.mjs +1 -1
  12. package/esm2020/models/hockey-game-statistic.mjs +1 -1
  13. package/esm2020/models/hockey-statistic.mjs +1 -1
  14. package/esm2020/models/league-player.mjs +3 -2
  15. package/esm2020/models/league.mjs +5 -1
  16. package/esm2020/models/rugby-game-statistic.mjs +28 -1
  17. package/esm2020/models/tournament-team-user.mjs +1 -1
  18. package/esm2020/models/tournament.mjs +1 -1
  19. package/esm2020/models/user.mjs +1 -1
  20. package/esm2020/models/waterpolo-game-statistic.mjs +3 -4
  21. package/esm2020/services/centrifugo.service.mjs +24 -6
  22. package/esm2020/utils/data.mjs +6 -3
  23. package/fesm2015/mtgame-core.mjs +85 -12
  24. package/fesm2015/mtgame-core.mjs.map +1 -1
  25. package/fesm2020/mtgame-core.mjs +79 -12
  26. package/fesm2020/mtgame-core.mjs.map +1 -1
  27. package/models/basketball-game-log.d.ts +1 -0
  28. package/models/game.d.ts +1 -1
  29. package/models/hockey-game-statistic.d.ts +9 -0
  30. package/models/hockey-statistic.d.ts +9 -0
  31. package/models/league-player.d.ts +2 -1
  32. package/models/league.d.ts +2 -0
  33. package/models/rugby-game-statistic.d.ts +6 -6
  34. package/models/tournament-team-user.d.ts +3 -0
  35. package/models/tournament.d.ts +1 -0
  36. package/models/user.d.ts +2 -0
  37. package/package.json +4 -4
  38. package/services/centrifugo.service.d.ts +2 -1
@@ -4,11 +4,11 @@ import { map, filter, take, takeUntil, distinctUntilChanged, delay, switchMap }
4
4
  import { __decorate } from 'tslib';
5
5
  import * as i1 from '@angular/common/http';
6
6
  import { HttpParams } from '@angular/common/http';
7
- import { BehaviorSubject, Subject, ReplaySubject, of } from 'rxjs';
7
+ import { BehaviorSubject, Observable, Subject, ReplaySubject, of } from 'rxjs';
8
8
  import { Centrifuge } from 'centrifuge';
9
+ import { isPlatformBrowser } from '@angular/common';
9
10
  import { UAParser } from 'ua-parser-js';
10
11
  import * as FingerPrint from '@fingerprintjs/fingerprintjs';
11
- import { isPlatformBrowser } from '@angular/common';
12
12
  import { captureException } from '@sentry/angular';
13
13
  import { FormGroup } from '@angular/forms';
14
14
 
@@ -561,6 +561,10 @@ let League = class League extends BaseModel {
561
561
  get tiktokLink() {
562
562
  return this.socialLinks.find(link => link.indexOf('tiktok.com/') > -1);
563
563
  }
564
+ checkRuDomain() {
565
+ const domainSplit = this.domain.split('.');
566
+ return domainSplit[(domainSplit.length - 1)] === 'ru';
567
+ }
564
568
  };
565
569
  League = __decorate([
566
570
  Model({
@@ -1362,6 +1366,7 @@ LeaguePlayer = __decorate([
1362
1366
  user: nestedModel(User),
1363
1367
  qualification: enumField(Qualification),
1364
1368
  fieldValues: listField(nestedModel(LeaguePlayerFieldValue)),
1369
+ gender: enumField(UserGender),
1365
1370
  }
1366
1371
  })
1367
1372
  ], LeaguePlayer);
@@ -1708,8 +1713,11 @@ function updateItemInArray(data, item, force = false, checkFunction) {
1708
1713
  !force && item.updatedAt && oldItem.updatedAt && oldItem.updatedAt > item.updatedAt) {
1709
1714
  return data;
1710
1715
  }
1711
- data[index] = item;
1712
- return data;
1716
+ return [
1717
+ ...data.slice(0, index),
1718
+ item,
1719
+ ...data.slice(index + 1),
1720
+ ];
1713
1721
  }
1714
1722
  function updateItemsInArray(data, items, force = false, checkFunction) {
1715
1723
  items.forEach(item => {
@@ -3857,6 +3865,10 @@ class MediaApi {
3857
3865
  if (filters.teamId) {
3858
3866
  params = params.set('team_id', filters.teamId.toString());
3859
3867
  }
3868
+ if (filters.statuses) {
3869
+ const statuses = filters.statuses.map(i => GameStatuses[i]);
3870
+ params = params.set('statuses', statuses.join(','));
3871
+ }
3860
3872
  return this.httpClient.get(`${this.configService.get('apiUrl')}/api/v1/league/${leagueId}/media/`, { params, observe: 'response' })
3861
3873
  .pipe(map(response => ({
3862
3874
  total: +response.headers.get('X-Page-Count'),
@@ -4340,6 +4352,33 @@ let RugbyGameStatistic = class RugbyGameStatistic extends GameStatisticBase {
4340
4352
  get gameMinutes() {
4341
4353
  return Math.floor(this.gameTime / 60);
4342
4354
  }
4355
+ get conversionKicks() {
4356
+ return (this.conversionGoals || 0) + (this.conversionMisses || 0);
4357
+ }
4358
+ get conversionGoalsPercent() {
4359
+ if (!this.conversionKicks) {
4360
+ return 0;
4361
+ }
4362
+ return Math.floor(1000 * this.conversionGoals / this.conversionKicks) / 10;
4363
+ }
4364
+ get penaltyKicksOnGoal() {
4365
+ return (this.penaltyGoals || 0) + (this.penaltyMisses || 0);
4366
+ }
4367
+ get penaltyGoalsPercent() {
4368
+ if (!this.penaltyKicksOnGoal) {
4369
+ return 0;
4370
+ }
4371
+ return Math.floor(1000 * this.penaltyGoals / this.penaltyKicksOnGoal) / 10;
4372
+ }
4373
+ get dropGoalKicks() {
4374
+ return (this.dropGoals || 0) + (this.dropGoalMisses || 0);
4375
+ }
4376
+ get dropGoalsPercent() {
4377
+ if (!this.dropGoalKicks) {
4378
+ return 0;
4379
+ }
4380
+ return Math.floor(1000 * this.dropGoals / this.dropGoalKicks) / 10;
4381
+ }
4343
4382
  get totalGoals() {
4344
4383
  return (this.conversionGoals || 0) + (this.dropGoals || 0) + (this.penaltyGoals || 0);
4345
4384
  }
@@ -5588,6 +5627,12 @@ class VolleyballGameApi extends GameBaseApi {
5588
5627
  responseType: 'blob'
5589
5628
  }).toPromise();
5590
5629
  }
5630
+ async downloadProtocolAdvanced(gameId, format) {
5631
+ return this.httpClient.get(`${this.configService.get('apiUrl')}/api/v1/tournament_volleyball_game/${gameId}/game_protocol_advanced/`, {
5632
+ params: new HttpParams().set('file_type', format),
5633
+ responseType: 'blob'
5634
+ }).toPromise();
5635
+ }
5591
5636
  async downloadProtocol(gameId, format) {
5592
5637
  return this.httpClient.get(`${this.configService.get('apiUrl')}/api/v1/tournament_volleyball_game/${gameId}/game_protocol/`, {
5593
5638
  params: new HttpParams().set('file_type', format),
@@ -5918,7 +5963,7 @@ let WaterpoloGameStatistic = class WaterpoloGameStatistic extends GameStatisticB
5918
5963
  return this.ppShots + this.evShots + this.shShots;
5919
5964
  }
5920
5965
  get totalShots() {
5921
- return this.shots + (this.shootoutAttempts || 0);
5966
+ return this.shots + this.shootoutShots;
5922
5967
  }
5923
5968
  get faceOffs() {
5924
5969
  return (this.faceOffWins || 0) + (this.faceOffLosses || 0);
@@ -5967,8 +6012,7 @@ let WaterpoloGameStatistic = class WaterpoloGameStatistic extends GameStatisticB
5967
6012
  this.freeKickShotsBlocked + this.cornerShotsBlocked;
5968
6013
  }
5969
6014
  get totalFouls() {
5970
- return (this.fouls || 0) + (this.penaltyFouls || 0) + (this.attackFouls || 0) + (this.personalFouls || 0) +
5971
- (this.minorPenalties || 0) + (this.majorPenalties || 0) + (this.matchPenalties || 0);
6015
+ return (this.fouls || 0) + (this.personalFouls || 0);
5972
6016
  }
5973
6017
  get totalPenalties() {
5974
6018
  return (this.minorPenalties || 0) + (this.majorPenalties || 0) + (this.matchPenalties || 0);
@@ -6269,6 +6313,12 @@ class PublicTeamApi {
6269
6313
  const params = new HttpParams().set('league_id', leagueId.toString());
6270
6314
  return this.httpClient.get(`${this.configService.get('apiUrl')}/api/v1/public_team/${teamId}/tournament_teams/`, { params }).pipe(map(result => result.map(item => new TournamentTeam(item)))).toPromise();
6271
6315
  }
6316
+ async getUsers(teamId) {
6317
+ return this.httpClient
6318
+ .get(`${this.configService.get('apiUrl')}/api/v1/public_team/${teamId}/users/`)
6319
+ .pipe(map(data => data.map(item => new TeamUser(item))))
6320
+ .toPromise();
6321
+ }
6272
6322
  }
6273
6323
  PublicTeamApi.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: PublicTeamApi, deps: [{ token: i1.HttpClient }, { token: ConfigService }], target: i0.ɵɵFactoryTarget.Injectable });
6274
6324
  PublicTeamApi.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: PublicTeamApi, providedIn: 'root' });
@@ -6476,8 +6526,8 @@ const WaterpoloGameLogTypeLocalization = {
6476
6526
  [WaterpoloGameLogTypes.assist]: 'Голевая передача',
6477
6527
  [WaterpoloGameLogTypes.block_shot]: 'Блокировка броска',
6478
6528
  [WaterpoloGameLogTypes.minor_penalty]: 'Удаление на 20 сек.',
6479
- [WaterpoloGameLogTypes.major_penalty]: 'Удаление + 4 мин. штраф',
6480
- [WaterpoloGameLogTypes.match_penalty]: 'Удаление до конца матча',
6529
+ [WaterpoloGameLogTypes.major_penalty]: 'Удаление + 20 сек. штраф',
6530
+ [WaterpoloGameLogTypes.match_penalty]: 'Удаление + 4 мин. штраф',
6481
6531
  [WaterpoloGameLogTypes.foul]: 'Фол',
6482
6532
  [WaterpoloGameLogTypes.penalty_foul]: 'Фол пенальти',
6483
6533
  [WaterpoloGameLogTypes.attack_foul]: 'Фол в нападении',
@@ -6845,9 +6895,10 @@ TournamentJoin1x1Data = __decorate([
6845
6895
  ], TournamentJoin1x1Data);
6846
6896
 
6847
6897
  class CentrifugoService {
6848
- constructor(httpClient, configService) {
6898
+ constructor(httpClient, configService, platformId) {
6849
6899
  this.httpClient = httpClient;
6850
6900
  this.configService = configService;
6901
+ this.platformId = platformId;
6851
6902
  this.channels$ = {};
6852
6903
  this.subscriptions = {};
6853
6904
  this.connectedSubject = new BehaviorSubject(false);
@@ -6856,6 +6907,11 @@ class CentrifugoService {
6856
6907
  return this.connectedSubject;
6857
6908
  }
6858
6909
  listen(channel) {
6910
+ if (!isPlatformBrowser(this.platformId)) {
6911
+ return new Observable(observer => {
6912
+ observer.error('Centrifugo is not available in ssr mode');
6913
+ });
6914
+ }
6859
6915
  if (channel in this.channels$) {
6860
6916
  return this.channels$[channel];
6861
6917
  }
@@ -6876,6 +6932,11 @@ class CentrifugoService {
6876
6932
  }
6877
6933
  }
6878
6934
  connect() {
6935
+ if (!isPlatformBrowser(this.platformId)) {
6936
+ return new Observable(observer => {
6937
+ observer.error('Centrifugo is not available in ssr mode');
6938
+ });
6939
+ }
6879
6940
  if (!this.initializeEngineSubject) {
6880
6941
  this.initializeEngineSubject = new ReplaySubject(1);
6881
6942
  this.httpClient.get(`${this.configService.get('apiUrl')}/api/v1/centrifugo_v2/`)
@@ -6899,6 +6960,9 @@ class CentrifugoService {
6899
6960
  return this.initializeEngineSubject.pipe(filter(item => Boolean(item)), take(1));
6900
6961
  }
6901
6962
  async publish(channel, message) {
6963
+ if (!isPlatformBrowser(this.platformId)) {
6964
+ throw new Error('Centrifugo is not available in ssr mode');
6965
+ }
6902
6966
  const connected = await this.connect().pipe(filter(item => Boolean(item)), take(1)).toPromise();
6903
6967
  if (!connected) {
6904
6968
  throw new Error('Centrifuge connection error');
@@ -6937,12 +7001,15 @@ class CentrifugoService {
6937
7001
  this.channels$[channel].next(message);
6938
7002
  }
6939
7003
  }
6940
- CentrifugoService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: CentrifugoService, deps: [{ token: i1.HttpClient }, { token: ConfigService }], target: i0.ɵɵFactoryTarget.Injectable });
7004
+ CentrifugoService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: CentrifugoService, deps: [{ token: i1.HttpClient }, { token: ConfigService }, { token: PLATFORM_ID }], target: i0.ɵɵFactoryTarget.Injectable });
6941
7005
  CentrifugoService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: CentrifugoService, providedIn: 'root' });
6942
7006
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: CentrifugoService, decorators: [{
6943
7007
  type: Injectable,
6944
7008
  args: [{ providedIn: 'root' }]
6945
- }], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: ConfigService }]; } });
7009
+ }], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: ConfigService }, { type: undefined, decorators: [{
7010
+ type: Inject,
7011
+ args: [PLATFORM_ID]
7012
+ }] }]; } });
6946
7013
 
6947
7014
  class BaseController {
6948
7015
  constructor() {