@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 { Injectable, Optional, Inject, PLATFORM_ID } from '@angular/core';
4
4
  import { map, filter, take, takeUntil, distinctUntilChanged, delay, switchMap } from 'rxjs/operators';
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({
@@ -1359,6 +1363,7 @@ LeaguePlayer = __decorate([
1359
1363
  user: nestedModel(User),
1360
1364
  qualification: enumField(Qualification),
1361
1365
  fieldValues: listField(nestedModel(LeaguePlayerFieldValue)),
1366
+ gender: enumField(UserGender),
1362
1367
  }
1363
1368
  })
1364
1369
  ], LeaguePlayer);
@@ -1705,8 +1710,11 @@ function updateItemInArray(data, item, force = false, checkFunction) {
1705
1710
  !force && item.updatedAt && oldItem.updatedAt && oldItem.updatedAt > item.updatedAt) {
1706
1711
  return data;
1707
1712
  }
1708
- data[index] = item;
1709
- return data;
1713
+ return [
1714
+ ...data.slice(0, index),
1715
+ item,
1716
+ ...data.slice(index + 1),
1717
+ ];
1710
1718
  }
1711
1719
  function updateItemsInArray(data, items, force = false, checkFunction) {
1712
1720
  items.forEach(item => {
@@ -4037,6 +4045,10 @@ class MediaApi {
4037
4045
  if (filters.teamId) {
4038
4046
  params = params.set('team_id', filters.teamId.toString());
4039
4047
  }
4048
+ if (filters.statuses) {
4049
+ const statuses = filters.statuses.map(i => GameStatuses[i]);
4050
+ params = params.set('statuses', statuses.join(','));
4051
+ }
4040
4052
  return this.httpClient.get(`${this.configService.get('apiUrl')}/api/v1/league/${leagueId}/media/`, { params, observe: 'response' })
4041
4053
  .pipe(map(response => ({
4042
4054
  total: +response.headers.get('X-Page-Count'),
@@ -4547,6 +4559,33 @@ let RugbyGameStatistic = class RugbyGameStatistic extends GameStatisticBase {
4547
4559
  get gameMinutes() {
4548
4560
  return Math.floor(this.gameTime / 60);
4549
4561
  }
4562
+ get conversionKicks() {
4563
+ return (this.conversionGoals || 0) + (this.conversionMisses || 0);
4564
+ }
4565
+ get conversionGoalsPercent() {
4566
+ if (!this.conversionKicks) {
4567
+ return 0;
4568
+ }
4569
+ return Math.floor(1000 * this.conversionGoals / this.conversionKicks) / 10;
4570
+ }
4571
+ get penaltyKicksOnGoal() {
4572
+ return (this.penaltyGoals || 0) + (this.penaltyMisses || 0);
4573
+ }
4574
+ get penaltyGoalsPercent() {
4575
+ if (!this.penaltyKicksOnGoal) {
4576
+ return 0;
4577
+ }
4578
+ return Math.floor(1000 * this.penaltyGoals / this.penaltyKicksOnGoal) / 10;
4579
+ }
4580
+ get dropGoalKicks() {
4581
+ return (this.dropGoals || 0) + (this.dropGoalMisses || 0);
4582
+ }
4583
+ get dropGoalsPercent() {
4584
+ if (!this.dropGoalKicks) {
4585
+ return 0;
4586
+ }
4587
+ return Math.floor(1000 * this.dropGoals / this.dropGoalKicks) / 10;
4588
+ }
4550
4589
  get totalGoals() {
4551
4590
  return (this.conversionGoals || 0) + (this.dropGoals || 0) + (this.penaltyGoals || 0);
4552
4591
  }
@@ -6020,6 +6059,14 @@ class VolleyballGameApi extends GameBaseApi {
6020
6059
  }).toPromise();
6021
6060
  });
6022
6061
  }
6062
+ downloadProtocolAdvanced(gameId, format) {
6063
+ return __awaiter(this, void 0, void 0, function* () {
6064
+ return this.httpClient.get(`${this.configService.get('apiUrl')}/api/v1/tournament_volleyball_game/${gameId}/game_protocol_advanced/`, {
6065
+ params: new HttpParams().set('file_type', format),
6066
+ responseType: 'blob'
6067
+ }).toPromise();
6068
+ });
6069
+ }
6023
6070
  downloadProtocol(gameId, format) {
6024
6071
  return __awaiter(this, void 0, void 0, function* () {
6025
6072
  return this.httpClient.get(`${this.configService.get('apiUrl')}/api/v1/tournament_volleyball_game/${gameId}/game_protocol/`, {
@@ -6352,7 +6399,7 @@ let WaterpoloGameStatistic = class WaterpoloGameStatistic extends GameStatisticB
6352
6399
  return this.ppShots + this.evShots + this.shShots;
6353
6400
  }
6354
6401
  get totalShots() {
6355
- return this.shots + (this.shootoutAttempts || 0);
6402
+ return this.shots + this.shootoutShots;
6356
6403
  }
6357
6404
  get faceOffs() {
6358
6405
  return (this.faceOffWins || 0) + (this.faceOffLosses || 0);
@@ -6401,8 +6448,7 @@ let WaterpoloGameStatistic = class WaterpoloGameStatistic extends GameStatisticB
6401
6448
  this.freeKickShotsBlocked + this.cornerShotsBlocked;
6402
6449
  }
6403
6450
  get totalFouls() {
6404
- return (this.fouls || 0) + (this.penaltyFouls || 0) + (this.attackFouls || 0) + (this.personalFouls || 0) +
6405
- (this.minorPenalties || 0) + (this.majorPenalties || 0) + (this.matchPenalties || 0);
6451
+ return (this.fouls || 0) + (this.personalFouls || 0);
6406
6452
  }
6407
6453
  get totalPenalties() {
6408
6454
  return (this.minorPenalties || 0) + (this.majorPenalties || 0) + (this.matchPenalties || 0);
@@ -6715,6 +6761,14 @@ class PublicTeamApi {
6715
6761
  const params = new HttpParams().set('league_id', leagueId.toString());
6716
6762
  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();
6717
6763
  }
6764
+ getUsers(teamId) {
6765
+ return __awaiter(this, void 0, void 0, function* () {
6766
+ return this.httpClient
6767
+ .get(`${this.configService.get('apiUrl')}/api/v1/public_team/${teamId}/users/`)
6768
+ .pipe(map(data => data.map(item => new TeamUser(item))))
6769
+ .toPromise();
6770
+ });
6771
+ }
6718
6772
  }
6719
6773
  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 });
6720
6774
  PublicTeamApi.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: PublicTeamApi, providedIn: 'root' });
@@ -6922,8 +6976,8 @@ const WaterpoloGameLogTypeLocalization = {
6922
6976
  [WaterpoloGameLogTypes.assist]: 'Голевая передача',
6923
6977
  [WaterpoloGameLogTypes.block_shot]: 'Блокировка броска',
6924
6978
  [WaterpoloGameLogTypes.minor_penalty]: 'Удаление на 20 сек.',
6925
- [WaterpoloGameLogTypes.major_penalty]: 'Удаление + 4 мин. штраф',
6926
- [WaterpoloGameLogTypes.match_penalty]: 'Удаление до конца матча',
6979
+ [WaterpoloGameLogTypes.major_penalty]: 'Удаление + 20 сек. штраф',
6980
+ [WaterpoloGameLogTypes.match_penalty]: 'Удаление + 4 мин. штраф',
6927
6981
  [WaterpoloGameLogTypes.foul]: 'Фол',
6928
6982
  [WaterpoloGameLogTypes.penalty_foul]: 'Фол пенальти',
6929
6983
  [WaterpoloGameLogTypes.attack_foul]: 'Фол в нападении',
@@ -7291,9 +7345,10 @@ TournamentJoin1x1Data = __decorate([
7291
7345
  ], TournamentJoin1x1Data);
7292
7346
 
7293
7347
  class CentrifugoService {
7294
- constructor(httpClient, configService) {
7348
+ constructor(httpClient, configService, platformId) {
7295
7349
  this.httpClient = httpClient;
7296
7350
  this.configService = configService;
7351
+ this.platformId = platformId;
7297
7352
  this.channels$ = {};
7298
7353
  this.subscriptions = {};
7299
7354
  this.connectedSubject = new BehaviorSubject(false);
@@ -7302,6 +7357,11 @@ class CentrifugoService {
7302
7357
  return this.connectedSubject;
7303
7358
  }
7304
7359
  listen(channel) {
7360
+ if (!isPlatformBrowser(this.platformId)) {
7361
+ return new Observable(observer => {
7362
+ observer.error('Centrifugo is not available in ssr mode');
7363
+ });
7364
+ }
7305
7365
  if (channel in this.channels$) {
7306
7366
  return this.channels$[channel];
7307
7367
  }
@@ -7322,6 +7382,11 @@ class CentrifugoService {
7322
7382
  }
7323
7383
  }
7324
7384
  connect() {
7385
+ if (!isPlatformBrowser(this.platformId)) {
7386
+ return new Observable(observer => {
7387
+ observer.error('Centrifugo is not available in ssr mode');
7388
+ });
7389
+ }
7325
7390
  if (!this.initializeEngineSubject) {
7326
7391
  this.initializeEngineSubject = new ReplaySubject(1);
7327
7392
  this.httpClient.get(`${this.configService.get('apiUrl')}/api/v1/centrifugo_v2/`)
@@ -7346,6 +7411,9 @@ class CentrifugoService {
7346
7411
  }
7347
7412
  publish(channel, message) {
7348
7413
  return __awaiter(this, void 0, void 0, function* () {
7414
+ if (!isPlatformBrowser(this.platformId)) {
7415
+ throw new Error('Centrifugo is not available in ssr mode');
7416
+ }
7349
7417
  const connected = yield this.connect().pipe(filter(item => Boolean(item)), take(1)).toPromise();
7350
7418
  if (!connected) {
7351
7419
  throw new Error('Centrifuge connection error');
@@ -7385,12 +7453,17 @@ class CentrifugoService {
7385
7453
  this.channels$[channel].next(message);
7386
7454
  }
7387
7455
  }
7388
- 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 });
7456
+ 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 });
7389
7457
  CentrifugoService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: CentrifugoService, providedIn: 'root' });
7390
7458
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: CentrifugoService, decorators: [{
7391
7459
  type: Injectable,
7392
7460
  args: [{ providedIn: 'root' }]
7393
- }], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: ConfigService }]; } });
7461
+ }], ctorParameters: function () {
7462
+ return [{ type: i1.HttpClient }, { type: ConfigService }, { type: undefined, decorators: [{
7463
+ type: Inject,
7464
+ args: [PLATFORM_ID]
7465
+ }] }];
7466
+ } });
7394
7467
 
7395
7468
  class BaseController {
7396
7469
  constructor() {