volleyballsimtypes 0.0.18 → 0.0.20
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/dist/cjs/src/data/init-models.js +2 -0
- package/dist/cjs/src/data/models/season.d.ts +5 -0
- package/dist/cjs/src/data/models/season.js +8 -0
- package/dist/cjs/src/data/models/team.d.ts +11 -0
- package/dist/cjs/src/data/transformers/coach.d.ts +1 -1
- package/dist/cjs/src/data/transformers/match-set-stats.d.ts +2 -2
- package/dist/cjs/src/data/transformers/match-set-stats.js +2 -2
- package/dist/cjs/src/data/transformers/match-set.d.ts +2 -2
- package/dist/cjs/src/data/transformers/match-set.js +2 -2
- package/dist/cjs/src/data/transformers/match.d.ts +2 -2
- package/dist/cjs/src/data/transformers/match.js +2 -2
- package/dist/cjs/src/data/transformers/player.d.ts +2 -2
- package/dist/cjs/src/data/transformers/player.js +2 -2
- package/dist/cjs/src/data/transformers/rally.d.ts +2 -2
- package/dist/cjs/src/data/transformers/rally.js +3 -3
- package/dist/cjs/src/data/transformers/season.d.ts +2 -2
- package/dist/cjs/src/data/transformers/season.js +6 -3
- package/dist/cjs/src/data/transformers/substitution.d.ts +2 -2
- package/dist/cjs/src/data/transformers/substitution.js +2 -2
- package/dist/cjs/src/routing/league.d.ts +1 -0
- package/dist/cjs/src/service/league/season.d.ts +3 -2
- package/dist/cjs/src/service/league/season.js +2 -6
- package/dist/esm/src/data/init-models.js +2 -0
- package/dist/esm/src/data/models/season.d.ts +5 -0
- package/dist/esm/src/data/models/season.js +8 -0
- package/dist/esm/src/data/models/team.d.ts +11 -0
- package/dist/esm/src/data/transformers/coach.d.ts +1 -1
- package/dist/esm/src/data/transformers/match-set-stats.d.ts +2 -2
- package/dist/esm/src/data/transformers/match-set-stats.js +2 -2
- package/dist/esm/src/data/transformers/match-set.d.ts +2 -2
- package/dist/esm/src/data/transformers/match-set.js +2 -2
- package/dist/esm/src/data/transformers/match.d.ts +2 -2
- package/dist/esm/src/data/transformers/match.js +2 -2
- package/dist/esm/src/data/transformers/player.d.ts +2 -2
- package/dist/esm/src/data/transformers/player.js +2 -2
- package/dist/esm/src/data/transformers/rally.d.ts +2 -2
- package/dist/esm/src/data/transformers/rally.js +3 -3
- package/dist/esm/src/data/transformers/season.d.ts +2 -2
- package/dist/esm/src/data/transformers/season.js +6 -3
- package/dist/esm/src/data/transformers/substitution.d.ts +2 -2
- package/dist/esm/src/data/transformers/substitution.js +2 -2
- package/dist/esm/src/routing/league.d.ts +1 -0
- package/dist/esm/src/service/league/season.d.ts +3 -2
- package/dist/esm/src/service/league/season.js +2 -6
- package/package.json +1 -1
|
@@ -155,6 +155,8 @@ function initModels(sequelize) {
|
|
|
155
155
|
Season.hasMany(Match, { as: 'Matches', foreignKey: 'season_id' });
|
|
156
156
|
Team.belongsTo(League, { as: 'league', foreignKey: 'league_id' });
|
|
157
157
|
League.hasMany(League, { as: 'Teams', foreignKey: 'league_id' });
|
|
158
|
+
Season.belongsTo(Team, { as: 'champion', foreignKey: 'champion' });
|
|
159
|
+
Team.hasMany(Season, { as: 'titles', foreignKey: 'champion' });
|
|
158
160
|
return {
|
|
159
161
|
Block,
|
|
160
162
|
Coach,
|
|
@@ -11,6 +11,7 @@ export interface SeasonAttributes {
|
|
|
11
11
|
seasonTeams?: TeamAttributes[];
|
|
12
12
|
Matches?: MatchAttributes[];
|
|
13
13
|
league?: LeagueAttributes;
|
|
14
|
+
champion?: string;
|
|
14
15
|
}
|
|
15
16
|
export type SeasonPk = 'season_id';
|
|
16
17
|
export type SeasonId = SeasonModel[SeasonPk];
|
|
@@ -56,5 +57,9 @@ export declare class SeasonModel extends Model<SeasonAttributes, SeasonCreationA
|
|
|
56
57
|
hasTeam_id_Team: Sequelize.BelongsToManyHasAssociationMixin<TeamModel, TeamId>;
|
|
57
58
|
hasseasonTeams: Sequelize.BelongsToManyHasAssociationsMixin<TeamModel, TeamId>;
|
|
58
59
|
countseasonTeams: Sequelize.BelongsToManyCountAssociationsMixin;
|
|
60
|
+
Champion: TeamModel;
|
|
61
|
+
getChampion: Sequelize.BelongsToGetAssociationMixin<TeamModel>;
|
|
62
|
+
setChampion: Sequelize.BelongsToSetAssociationMixin<TeamModel, TeamId>;
|
|
63
|
+
createChampion: Sequelize.BelongsToCreateAssociationMixin<TeamModel>;
|
|
59
64
|
static initModel(sequelize: Sequelize.Sequelize): typeof SeasonModel;
|
|
60
65
|
}
|
|
@@ -21,6 +21,14 @@ class SeasonModel extends sequelize_1.Model {
|
|
|
21
21
|
model: 'League',
|
|
22
22
|
key: 'league_id'
|
|
23
23
|
}
|
|
24
|
+
},
|
|
25
|
+
champion: {
|
|
26
|
+
type: sequelize_1.DataTypes.UUID,
|
|
27
|
+
allowNull: true,
|
|
28
|
+
references: {
|
|
29
|
+
model: 'Team',
|
|
30
|
+
key: 'team_id'
|
|
31
|
+
}
|
|
24
32
|
}
|
|
25
33
|
}, {
|
|
26
34
|
sequelize,
|
|
@@ -118,5 +118,16 @@ export declare class TeamModel extends Model<TeamAttributes, TeamCreationAttribu
|
|
|
118
118
|
hasSeasonTeam: Sequelize.HasManyHasAssociationMixin<SeasonTeamsModel, SeasonTeamsId>;
|
|
119
119
|
hasSeasonTeams: Sequelize.HasManyHasAssociationsMixin<SeasonTeamsModel, SeasonTeamsId>;
|
|
120
120
|
countSeasonTeams: Sequelize.HasManyCountAssociationsMixin;
|
|
121
|
+
titles: SeasonModel[];
|
|
122
|
+
getTitles: Sequelize.HasManyGetAssociationsMixin<SeasonModel>;
|
|
123
|
+
setTitles: Sequelize.HasManySetAssociationsMixin<SeasonModel, SeasonId>;
|
|
124
|
+
addTitle: Sequelize.HasManyAddAssociationMixin<SeasonModel, SeasonId>;
|
|
125
|
+
addTitles: Sequelize.HasManyAddAssociationsMixin<SeasonModel, SeasonId>;
|
|
126
|
+
createTitle: Sequelize.HasManyCreateAssociationMixin<SeasonModel>;
|
|
127
|
+
removeTitle: Sequelize.HasManyRemoveAssociationMixin<SeasonModel, SeasonId>;
|
|
128
|
+
removeTitles: Sequelize.HasManyRemoveAssociationsMixin<SeasonModel, SeasonId>;
|
|
129
|
+
hasTitle: Sequelize.HasManyHasAssociationMixin<SeasonModel, SeasonId>;
|
|
130
|
+
hasTitles: Sequelize.HasManyHasAssociationsMixin<SeasonModel, SeasonId>;
|
|
131
|
+
countTitles: Sequelize.HasManyCountAssociationsMixin;
|
|
121
132
|
static initModel(sequelize: Sequelize.Sequelize): typeof TeamModel;
|
|
122
133
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CoachAttributes, CoachModel } from '../models';
|
|
2
2
|
import { Coach } from '../../service';
|
|
3
|
-
import { APICoach } from '../../routing
|
|
3
|
+
import { APICoach } from '../../routing';
|
|
4
4
|
declare function transformToAttributes(coach: Coach): CoachAttributes;
|
|
5
5
|
declare function transformToObject(model: CoachModel): Coach;
|
|
6
6
|
declare function transformToAPIObject(model: CoachModel): APICoach;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MatchSetStatsAttributes, MatchSetStatsModel } from '../models';
|
|
2
|
-
import {
|
|
2
|
+
import { SetStatistics } from '../../service';
|
|
3
3
|
import { APISetStatistics } from '../../routing';
|
|
4
|
-
declare function transformToAttributes(stats: SetStatistics,
|
|
4
|
+
declare function transformToAttributes(stats: SetStatistics, setId: string): MatchSetStatsAttributes;
|
|
5
5
|
declare function transformToObject(model: MatchSetStatsModel): SetStatistics;
|
|
6
6
|
declare function transformToAPIObject(model: MatchSetStatsModel, order: number): APISetStatistics;
|
|
7
7
|
export { transformToObject as transformToMatchSetStats, transformToAPIObject as transformToAPIMatchSetStats, transformToAttributes as transformFromMatchSetStats };
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.transformFromMatchSetStats = exports.transformToAPIMatchSetStats = exports.transformToMatchSetStats = void 0;
|
|
4
4
|
const player_1 = require("./player");
|
|
5
|
-
function transformToAttributes(stats,
|
|
5
|
+
function transformToAttributes(stats, setId) {
|
|
6
6
|
return {
|
|
7
7
|
player_id: stats.player.id,
|
|
8
|
-
match_set_id:
|
|
8
|
+
match_set_id: setId,
|
|
9
9
|
aces: stats.ace,
|
|
10
10
|
assists: stats.assists,
|
|
11
11
|
attempts: stats.attempts,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MatchSetAttributes, MatchSetModel } from '../models';
|
|
2
|
-
import {
|
|
2
|
+
import { MatchSet } from '../../service';
|
|
3
3
|
import { APIMatchSet } from '../../routing';
|
|
4
|
-
declare function transformToAttributes(set: MatchSet,
|
|
4
|
+
declare function transformToAttributes(set: MatchSet, matchId: string): MatchSetAttributes;
|
|
5
5
|
declare function transformToObject(model: MatchSetModel): MatchSet;
|
|
6
6
|
declare function transformToAPIObject(model: MatchSetModel): APIMatchSet;
|
|
7
7
|
export { transformToObject as transformToMatchSet, transformToAPIObject as transformToAPIMatchSet, transformToAttributes as transformFromMatchSet };
|
|
@@ -5,10 +5,10 @@ const service_1 = require("../../service");
|
|
|
5
5
|
const player_1 = require("./player");
|
|
6
6
|
const rally_1 = require("./rally");
|
|
7
7
|
const match_set_stats_1 = require("./match-set-stats");
|
|
8
|
-
function transformToAttributes(set,
|
|
8
|
+
function transformToAttributes(set, matchId) {
|
|
9
9
|
return {
|
|
10
10
|
match_set_id: set.id,
|
|
11
|
-
match_id:
|
|
11
|
+
match_id: matchId,
|
|
12
12
|
order: set.order,
|
|
13
13
|
away_libero: set.awayLibero?.id,
|
|
14
14
|
home_libero: set.homeLibero?.id,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MatchAttributes, MatchModel } from '../models';
|
|
2
|
-
import { Match
|
|
2
|
+
import { Match } from '../../service';
|
|
3
3
|
import { APIMatch } from '../../routing';
|
|
4
|
-
declare function transformToAttributes(match: Match,
|
|
4
|
+
declare function transformToAttributes(match: Match, seasonId: string): MatchAttributes;
|
|
5
5
|
declare function transformToObject(model: MatchModel): Match;
|
|
6
6
|
declare function transformToAPIObject(model: MatchModel): APIMatch;
|
|
7
7
|
export { transformToObject as transformToMatch, transformToAPIObject as transformToAPIMatch, transformToAttributes as transformFromMatch };
|
|
@@ -4,10 +4,10 @@ exports.transformFromMatch = exports.transformToAPIMatch = exports.transformToMa
|
|
|
4
4
|
const service_1 = require("../../service");
|
|
5
5
|
const team_1 = require("./team");
|
|
6
6
|
const match_set_1 = require("./match-set");
|
|
7
|
-
function transformToAttributes(match,
|
|
7
|
+
function transformToAttributes(match, seasonId) {
|
|
8
8
|
return {
|
|
9
9
|
match_id: match.id,
|
|
10
|
-
season_id:
|
|
10
|
+
season_id: seasonId,
|
|
11
11
|
away_team: match.awayTeam.id,
|
|
12
12
|
home_team: match.homeTeam.id,
|
|
13
13
|
scheduled_date: match.scheduledDate.toISOString(),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PlayerAttributes, PlayerModel } from '../models';
|
|
2
|
-
import { Player
|
|
2
|
+
import { Player } from '../../service';
|
|
3
3
|
import { APIPlayer } from '../../routing';
|
|
4
|
-
declare function transformToAttributes(player: Player,
|
|
4
|
+
declare function transformToAttributes(player: Player, teamId: string): PlayerAttributes;
|
|
5
5
|
declare function transformToObject(model: PlayerModel): Player;
|
|
6
6
|
declare function transformToAPIObject(model: PlayerModel): APIPlayer;
|
|
7
7
|
export { transformToObject as transformToPlayer, transformToAPIObject as transformToAPIPlayer, transformToAttributes as transformFromPlayer };
|
|
@@ -7,10 +7,10 @@ const role_1 = require("./role");
|
|
|
7
7
|
const performance_stats_1 = require("./performance-stats");
|
|
8
8
|
const country_1 = require("./country");
|
|
9
9
|
const match_set_stats_1 = require("./match-set-stats");
|
|
10
|
-
function transformToAttributes(player,
|
|
10
|
+
function transformToAttributes(player, teamId) {
|
|
11
11
|
return {
|
|
12
12
|
player_id: player.id,
|
|
13
|
-
team_id:
|
|
13
|
+
team_id: teamId,
|
|
14
14
|
country_id: player.country.id,
|
|
15
15
|
jersey_number: player.jerseyNumber,
|
|
16
16
|
first_name: player.name.first,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { RallyAttributes, RallyModel } from '../models';
|
|
2
|
-
import {
|
|
2
|
+
import { Rally } from '../../service';
|
|
3
3
|
import { APIRally } from '../../routing';
|
|
4
|
-
declare function transformToAttributes(rally: Rally,
|
|
4
|
+
declare function transformToAttributes(rally: Rally, setId: string): RallyAttributes;
|
|
5
5
|
declare function transformToObject(model: RallyModel): Rally;
|
|
6
6
|
declare function transformToAPIObject(model: RallyModel): APIRally;
|
|
7
7
|
export { transformToObject as transformToRally, transformToAPIObject as transformToAPIRally, transformToAttributes as transformFromRally };
|
|
@@ -12,7 +12,7 @@ const set_1 = require("./set");
|
|
|
12
12
|
const spike_1 = require("./spike");
|
|
13
13
|
const block_1 = require("./block");
|
|
14
14
|
const score_1 = require("./score");
|
|
15
|
-
function transformToAttributes(rally,
|
|
15
|
+
function transformToAttributes(rally, setId) {
|
|
16
16
|
const rallyPositions = [
|
|
17
17
|
...rally.awayPlayerPosition.map(pp => (0, rally_position_1.transformFromPlayerPosition)(pp, 'Away', rally)),
|
|
18
18
|
...rally.homePlayerPosition.map(pp => (0, rally_position_1.transformFromPlayerPosition)(pp, 'Home', rally))
|
|
@@ -30,14 +30,14 @@ function transformToAttributes(rally, set) {
|
|
|
30
30
|
}
|
|
31
31
|
return {
|
|
32
32
|
rally_id: rally.id,
|
|
33
|
-
match_set_id:
|
|
33
|
+
match_set_id: setId,
|
|
34
34
|
order: rally.order,
|
|
35
35
|
serving_team: rally.servingTeam.id,
|
|
36
36
|
RallyPositions: rallyPositions,
|
|
37
37
|
LiberoReplacements: rally.events.filter(event => event.eventType === service_1.EventType.LIBERO_REPLACEMENT)
|
|
38
38
|
.map(event => (0, libero_replacement_1.transformFromLiberoReplacement)(event, rally)),
|
|
39
39
|
Substitutions: rally.events.filter(event => event.eventType === service_1.EventType.SUBSTITUTION)
|
|
40
|
-
.map(event => (0, substitution_1.transformFromSubstitution)(event, rally)),
|
|
40
|
+
.map(event => (0, substitution_1.transformFromSubstitution)(event, rally.id)),
|
|
41
41
|
Serves: rally.events.filter(event => event.eventType === service_1.EventType.SERVE)
|
|
42
42
|
.map(event => (0, serve_1.transformFromServe)(event, rally)),
|
|
43
43
|
Receptions: rally.events.filter(event => event.eventType === service_1.EventType.RECEPTION)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SeasonAttributes, SeasonModel } from '../models';
|
|
2
|
-
import {
|
|
2
|
+
import { Season } from '../../service';
|
|
3
3
|
import { APISeason } from '../../routing';
|
|
4
|
-
declare function transformToAttributes(season: Season,
|
|
4
|
+
declare function transformToAttributes(season: Season, leagueId: string): SeasonAttributes;
|
|
5
5
|
declare function transformToObject(model: SeasonModel): Season;
|
|
6
6
|
declare function transformToAPIObject(model: SeasonModel): APISeason;
|
|
7
7
|
export { transformToObject as transformToSeason, transformToAPIObject as transformToAPISeason, transformToAttributes as transformFromSeason };
|
|
@@ -5,11 +5,12 @@ const team_1 = require("./team");
|
|
|
5
5
|
const service_1 = require("../../service");
|
|
6
6
|
const match_1 = require("./match");
|
|
7
7
|
const league_1 = require("./league");
|
|
8
|
-
function transformToAttributes(season,
|
|
8
|
+
function transformToAttributes(season, leagueId) {
|
|
9
9
|
return {
|
|
10
10
|
season_id: season.id,
|
|
11
11
|
iteration: season.iteration,
|
|
12
|
-
league_id:
|
|
12
|
+
league_id: leagueId,
|
|
13
|
+
champion: season.champion != null ? season.champion.id : undefined
|
|
13
14
|
};
|
|
14
15
|
}
|
|
15
16
|
exports.transformFromSeason = transformToAttributes;
|
|
@@ -19,6 +20,7 @@ function transformToObject(model) {
|
|
|
19
20
|
matches: model.Matches != null ? model.Matches.map(match_1.transformToMatch) : [],
|
|
20
21
|
iteration: model.iteration,
|
|
21
22
|
teams: model.seasonTeams != null ? model.seasonTeams.map(team_1.transformToTeam) : [],
|
|
23
|
+
champion: model.Champion != null ? (0, team_1.transformToTeam)(model.Champion) : undefined
|
|
22
24
|
});
|
|
23
25
|
}
|
|
24
26
|
exports.transformToSeason = transformToObject;
|
|
@@ -30,7 +32,8 @@ function transformToAPIObject(model) {
|
|
|
30
32
|
iteration: model.iteration,
|
|
31
33
|
teams: model.seasonTeams != null ? model.seasonTeams.map(team_1.transformToAPITeam) : [],
|
|
32
34
|
league: (0, league_1.transformToLeague)(model.league),
|
|
33
|
-
standings: season.standings
|
|
35
|
+
standings: season.standings,
|
|
36
|
+
champion: model.Champion != null ? (0, team_1.transformToAPITeam)(model.Champion) : undefined
|
|
34
37
|
};
|
|
35
38
|
}
|
|
36
39
|
exports.transformToAPISeason = transformToAPIObject;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Substitution } from '../../service';
|
|
2
2
|
import { SubstitutionAttributes, SubstitutionModel } from '../models';
|
|
3
3
|
import { APISubstitution } from '../../routing';
|
|
4
|
-
declare function transformToAttributes(event: Substitution,
|
|
4
|
+
declare function transformToAttributes(event: Substitution, rallyId: string): SubstitutionAttributes;
|
|
5
5
|
declare function transformToObject(event: SubstitutionModel): Substitution;
|
|
6
6
|
declare function transformToAPIObject(event: SubstitutionModel): APISubstitution;
|
|
7
7
|
export { transformToObject as transformToSubstitution, transformToAPIObject as transformToAPISubstitution, transformToAttributes as transformFromSubstitution };
|
|
@@ -4,14 +4,14 @@ exports.transformFromSubstitution = exports.transformToAPISubstitution = exports
|
|
|
4
4
|
const service_1 = require("../../service");
|
|
5
5
|
const event_type_1 = require("./event-type");
|
|
6
6
|
const player_1 = require("./player");
|
|
7
|
-
function transformToAttributes(event,
|
|
7
|
+
function transformToAttributes(event, rallyId) {
|
|
8
8
|
return {
|
|
9
9
|
player_id: event.player.id,
|
|
10
10
|
event_id: event.id,
|
|
11
11
|
order: event.order,
|
|
12
12
|
event_type: (0, event_type_1.transformFromEventType)(event.eventType),
|
|
13
13
|
player_out: event.playerOut.id,
|
|
14
|
-
rally_id:
|
|
14
|
+
rally_id: rallyId
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
17
|
exports.transformFromSubstitution = transformToAttributes;
|
|
@@ -6,6 +6,7 @@ export interface SeasonOpts {
|
|
|
6
6
|
readonly teams: Team[];
|
|
7
7
|
readonly matches: Match[];
|
|
8
8
|
readonly iteration: number;
|
|
9
|
+
readonly champion?: Team;
|
|
9
10
|
}
|
|
10
11
|
export declare class Season {
|
|
11
12
|
readonly id: string;
|
|
@@ -13,7 +14,7 @@ export declare class Season {
|
|
|
13
14
|
readonly matches: Match[];
|
|
14
15
|
readonly iteration: number;
|
|
15
16
|
readonly standings: Standing[];
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
champion?: Team;
|
|
18
|
+
constructor({ id, iteration, teams, matches, champion }: SeasonOpts);
|
|
18
19
|
calculateStandings(): Standing[];
|
|
19
20
|
}
|
|
@@ -3,17 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Season = void 0;
|
|
4
4
|
const standing_1 = require("./standing");
|
|
5
5
|
class Season {
|
|
6
|
-
constructor({ id, iteration, teams, matches }) {
|
|
6
|
+
constructor({ id, iteration, teams, matches, champion }) {
|
|
7
7
|
this.id = id;
|
|
8
8
|
this.teams = teams;
|
|
9
9
|
this.matches = matches;
|
|
10
10
|
this.iteration = iteration;
|
|
11
11
|
this.standings = this.calculateStandings();
|
|
12
|
-
|
|
13
|
-
get champion() {
|
|
14
|
-
if (this.matches.every(match => !match.isOver()))
|
|
15
|
-
return undefined;
|
|
16
|
-
return this.teams.find(team => team.id === this.standings[0].teamId);
|
|
12
|
+
this.champion = champion;
|
|
17
13
|
}
|
|
18
14
|
calculateStandings() {
|
|
19
15
|
return this.teams.map(team => {
|
|
@@ -152,6 +152,8 @@ export function initModels(sequelize) {
|
|
|
152
152
|
Season.hasMany(Match, { as: 'Matches', foreignKey: 'season_id' });
|
|
153
153
|
Team.belongsTo(League, { as: 'league', foreignKey: 'league_id' });
|
|
154
154
|
League.hasMany(League, { as: 'Teams', foreignKey: 'league_id' });
|
|
155
|
+
Season.belongsTo(Team, { as: 'champion', foreignKey: 'champion' });
|
|
156
|
+
Team.hasMany(Season, { as: 'titles', foreignKey: 'champion' });
|
|
155
157
|
return {
|
|
156
158
|
Block,
|
|
157
159
|
Coach,
|
|
@@ -11,6 +11,7 @@ export interface SeasonAttributes {
|
|
|
11
11
|
seasonTeams?: TeamAttributes[];
|
|
12
12
|
Matches?: MatchAttributes[];
|
|
13
13
|
league?: LeagueAttributes;
|
|
14
|
+
champion?: string;
|
|
14
15
|
}
|
|
15
16
|
export type SeasonPk = 'season_id';
|
|
16
17
|
export type SeasonId = SeasonModel[SeasonPk];
|
|
@@ -56,5 +57,9 @@ export declare class SeasonModel extends Model<SeasonAttributes, SeasonCreationA
|
|
|
56
57
|
hasTeam_id_Team: Sequelize.BelongsToManyHasAssociationMixin<TeamModel, TeamId>;
|
|
57
58
|
hasseasonTeams: Sequelize.BelongsToManyHasAssociationsMixin<TeamModel, TeamId>;
|
|
58
59
|
countseasonTeams: Sequelize.BelongsToManyCountAssociationsMixin;
|
|
60
|
+
Champion: TeamModel;
|
|
61
|
+
getChampion: Sequelize.BelongsToGetAssociationMixin<TeamModel>;
|
|
62
|
+
setChampion: Sequelize.BelongsToSetAssociationMixin<TeamModel, TeamId>;
|
|
63
|
+
createChampion: Sequelize.BelongsToCreateAssociationMixin<TeamModel>;
|
|
59
64
|
static initModel(sequelize: Sequelize.Sequelize): typeof SeasonModel;
|
|
60
65
|
}
|
|
@@ -118,5 +118,16 @@ export declare class TeamModel extends Model<TeamAttributes, TeamCreationAttribu
|
|
|
118
118
|
hasSeasonTeam: Sequelize.HasManyHasAssociationMixin<SeasonTeamsModel, SeasonTeamsId>;
|
|
119
119
|
hasSeasonTeams: Sequelize.HasManyHasAssociationsMixin<SeasonTeamsModel, SeasonTeamsId>;
|
|
120
120
|
countSeasonTeams: Sequelize.HasManyCountAssociationsMixin;
|
|
121
|
+
titles: SeasonModel[];
|
|
122
|
+
getTitles: Sequelize.HasManyGetAssociationsMixin<SeasonModel>;
|
|
123
|
+
setTitles: Sequelize.HasManySetAssociationsMixin<SeasonModel, SeasonId>;
|
|
124
|
+
addTitle: Sequelize.HasManyAddAssociationMixin<SeasonModel, SeasonId>;
|
|
125
|
+
addTitles: Sequelize.HasManyAddAssociationsMixin<SeasonModel, SeasonId>;
|
|
126
|
+
createTitle: Sequelize.HasManyCreateAssociationMixin<SeasonModel>;
|
|
127
|
+
removeTitle: Sequelize.HasManyRemoveAssociationMixin<SeasonModel, SeasonId>;
|
|
128
|
+
removeTitles: Sequelize.HasManyRemoveAssociationsMixin<SeasonModel, SeasonId>;
|
|
129
|
+
hasTitle: Sequelize.HasManyHasAssociationMixin<SeasonModel, SeasonId>;
|
|
130
|
+
hasTitles: Sequelize.HasManyHasAssociationsMixin<SeasonModel, SeasonId>;
|
|
131
|
+
countTitles: Sequelize.HasManyCountAssociationsMixin;
|
|
121
132
|
static initModel(sequelize: Sequelize.Sequelize): typeof TeamModel;
|
|
122
133
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CoachAttributes, CoachModel } from '../models';
|
|
2
2
|
import { Coach } from '../../service';
|
|
3
|
-
import { APICoach } from '../../routing
|
|
3
|
+
import { APICoach } from '../../routing';
|
|
4
4
|
declare function transformToAttributes(coach: Coach): CoachAttributes;
|
|
5
5
|
declare function transformToObject(model: CoachModel): Coach;
|
|
6
6
|
declare function transformToAPIObject(model: CoachModel): APICoach;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MatchSetStatsAttributes, MatchSetStatsModel } from '../models';
|
|
2
|
-
import {
|
|
2
|
+
import { SetStatistics } from '../../service';
|
|
3
3
|
import { APISetStatistics } from '../../routing';
|
|
4
|
-
declare function transformToAttributes(stats: SetStatistics,
|
|
4
|
+
declare function transformToAttributes(stats: SetStatistics, setId: string): MatchSetStatsAttributes;
|
|
5
5
|
declare function transformToObject(model: MatchSetStatsModel): SetStatistics;
|
|
6
6
|
declare function transformToAPIObject(model: MatchSetStatsModel, order: number): APISetStatistics;
|
|
7
7
|
export { transformToObject as transformToMatchSetStats, transformToAPIObject as transformToAPIMatchSetStats, transformToAttributes as transformFromMatchSetStats };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { transformToPlayer } from './player';
|
|
2
|
-
function transformToAttributes(stats,
|
|
2
|
+
function transformToAttributes(stats, setId) {
|
|
3
3
|
return {
|
|
4
4
|
player_id: stats.player.id,
|
|
5
|
-
match_set_id:
|
|
5
|
+
match_set_id: setId,
|
|
6
6
|
aces: stats.ace,
|
|
7
7
|
assists: stats.assists,
|
|
8
8
|
attempts: stats.attempts,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MatchSetAttributes, MatchSetModel } from '../models';
|
|
2
|
-
import {
|
|
2
|
+
import { MatchSet } from '../../service';
|
|
3
3
|
import { APIMatchSet } from '../../routing';
|
|
4
|
-
declare function transformToAttributes(set: MatchSet,
|
|
4
|
+
declare function transformToAttributes(set: MatchSet, matchId: string): MatchSetAttributes;
|
|
5
5
|
declare function transformToObject(model: MatchSetModel): MatchSet;
|
|
6
6
|
declare function transformToAPIObject(model: MatchSetModel): APIMatchSet;
|
|
7
7
|
export { transformToObject as transformToMatchSet, transformToAPIObject as transformToAPIMatchSet, transformToAttributes as transformFromMatchSet };
|
|
@@ -2,10 +2,10 @@ import { MatchSet } from '../../service';
|
|
|
2
2
|
import { transformToPlayer } from './player';
|
|
3
3
|
import { transformToAPIRally, transformToRally } from './rally';
|
|
4
4
|
import { transformToAPIMatchSetStats, transformToMatchSetStats } from './match-set-stats';
|
|
5
|
-
function transformToAttributes(set,
|
|
5
|
+
function transformToAttributes(set, matchId) {
|
|
6
6
|
return {
|
|
7
7
|
match_set_id: set.id,
|
|
8
|
-
match_id:
|
|
8
|
+
match_id: matchId,
|
|
9
9
|
order: set.order,
|
|
10
10
|
away_libero: set.awayLibero?.id,
|
|
11
11
|
home_libero: set.homeLibero?.id,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MatchAttributes, MatchModel } from '../models';
|
|
2
|
-
import { Match
|
|
2
|
+
import { Match } from '../../service';
|
|
3
3
|
import { APIMatch } from '../../routing';
|
|
4
|
-
declare function transformToAttributes(match: Match,
|
|
4
|
+
declare function transformToAttributes(match: Match, seasonId: string): MatchAttributes;
|
|
5
5
|
declare function transformToObject(model: MatchModel): Match;
|
|
6
6
|
declare function transformToAPIObject(model: MatchModel): APIMatch;
|
|
7
7
|
export { transformToObject as transformToMatch, transformToAPIObject as transformToAPIMatch, transformToAttributes as transformFromMatch };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Match } from '../../service';
|
|
2
2
|
import { transformToAPITeam, transformToTeam } from './team';
|
|
3
3
|
import { transformToAPIMatchSet, transformToMatchSet } from './match-set';
|
|
4
|
-
function transformToAttributes(match,
|
|
4
|
+
function transformToAttributes(match, seasonId) {
|
|
5
5
|
return {
|
|
6
6
|
match_id: match.id,
|
|
7
|
-
season_id:
|
|
7
|
+
season_id: seasonId,
|
|
8
8
|
away_team: match.awayTeam.id,
|
|
9
9
|
home_team: match.homeTeam.id,
|
|
10
10
|
scheduled_date: match.scheduledDate.toISOString(),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PlayerAttributes, PlayerModel } from '../models';
|
|
2
|
-
import { Player
|
|
2
|
+
import { Player } from '../../service';
|
|
3
3
|
import { APIPlayer } from '../../routing';
|
|
4
|
-
declare function transformToAttributes(player: Player,
|
|
4
|
+
declare function transformToAttributes(player: Player, teamId: string): PlayerAttributes;
|
|
5
5
|
declare function transformToObject(model: PlayerModel): Player;
|
|
6
6
|
declare function transformToAPIObject(model: PlayerModel): APIPlayer;
|
|
7
7
|
export { transformToObject as transformToPlayer, transformToAPIObject as transformToAPIPlayer, transformToAttributes as transformFromPlayer };
|
|
@@ -4,10 +4,10 @@ import { transformFromRole, transformToRole } from './role';
|
|
|
4
4
|
import { transformToPerformanceStats } from './performance-stats';
|
|
5
5
|
import { transformToCountry } from './country';
|
|
6
6
|
import { transformToAPIMatchSetStats } from './match-set-stats';
|
|
7
|
-
function transformToAttributes(player,
|
|
7
|
+
function transformToAttributes(player, teamId) {
|
|
8
8
|
return {
|
|
9
9
|
player_id: player.id,
|
|
10
|
-
team_id:
|
|
10
|
+
team_id: teamId,
|
|
11
11
|
country_id: player.country.id,
|
|
12
12
|
jersey_number: player.jerseyNumber,
|
|
13
13
|
first_name: player.name.first,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { RallyAttributes, RallyModel } from '../models';
|
|
2
|
-
import {
|
|
2
|
+
import { Rally } from '../../service';
|
|
3
3
|
import { APIRally } from '../../routing';
|
|
4
|
-
declare function transformToAttributes(rally: Rally,
|
|
4
|
+
declare function transformToAttributes(rally: Rally, setId: string): RallyAttributes;
|
|
5
5
|
declare function transformToObject(model: RallyModel): Rally;
|
|
6
6
|
declare function transformToAPIObject(model: RallyModel): APIRally;
|
|
7
7
|
export { transformToObject as transformToRally, transformToAPIObject as transformToAPIRally, transformToAttributes as transformFromRally };
|
|
@@ -9,7 +9,7 @@ import { transformFromSet, transformToAPISet, transformToSet } from './set';
|
|
|
9
9
|
import { transformFromSpike, transformToAPISpike, transformToSpike } from './spike';
|
|
10
10
|
import { transformFromBlock, transformToAPIBlock, transformToBlock } from './block';
|
|
11
11
|
import { transformFromScore, transformToAPIScore, transformToScore } from './score';
|
|
12
|
-
function transformToAttributes(rally,
|
|
12
|
+
function transformToAttributes(rally, setId) {
|
|
13
13
|
const rallyPositions = [
|
|
14
14
|
...rally.awayPlayerPosition.map(pp => transformFromPlayerPosition(pp, 'Away', rally)),
|
|
15
15
|
...rally.homePlayerPosition.map(pp => transformFromPlayerPosition(pp, 'Home', rally))
|
|
@@ -27,14 +27,14 @@ function transformToAttributes(rally, set) {
|
|
|
27
27
|
}
|
|
28
28
|
return {
|
|
29
29
|
rally_id: rally.id,
|
|
30
|
-
match_set_id:
|
|
30
|
+
match_set_id: setId,
|
|
31
31
|
order: rally.order,
|
|
32
32
|
serving_team: rally.servingTeam.id,
|
|
33
33
|
RallyPositions: rallyPositions,
|
|
34
34
|
LiberoReplacements: rally.events.filter(event => event.eventType === EventType.LIBERO_REPLACEMENT)
|
|
35
35
|
.map(event => transformFromLiberoReplacement(event, rally)),
|
|
36
36
|
Substitutions: rally.events.filter(event => event.eventType === EventType.SUBSTITUTION)
|
|
37
|
-
.map(event => transformFromSubstitution(event, rally)),
|
|
37
|
+
.map(event => transformFromSubstitution(event, rally.id)),
|
|
38
38
|
Serves: rally.events.filter(event => event.eventType === EventType.SERVE)
|
|
39
39
|
.map(event => transformFromServe(event, rally)),
|
|
40
40
|
Receptions: rally.events.filter(event => event.eventType === EventType.RECEPTION)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SeasonAttributes, SeasonModel } from '../models';
|
|
2
|
-
import {
|
|
2
|
+
import { Season } from '../../service';
|
|
3
3
|
import { APISeason } from '../../routing';
|
|
4
|
-
declare function transformToAttributes(season: Season,
|
|
4
|
+
declare function transformToAttributes(season: Season, leagueId: string): SeasonAttributes;
|
|
5
5
|
declare function transformToObject(model: SeasonModel): Season;
|
|
6
6
|
declare function transformToAPIObject(model: SeasonModel): APISeason;
|
|
7
7
|
export { transformToObject as transformToSeason, transformToAPIObject as transformToAPISeason, transformToAttributes as transformFromSeason };
|
|
@@ -2,11 +2,12 @@ import { transformToAPITeam, transformToTeam } from './team';
|
|
|
2
2
|
import { Season } from '../../service';
|
|
3
3
|
import { transformToAPIMatch, transformToMatch } from './match';
|
|
4
4
|
import { transformToLeague } from './league';
|
|
5
|
-
function transformToAttributes(season,
|
|
5
|
+
function transformToAttributes(season, leagueId) {
|
|
6
6
|
return {
|
|
7
7
|
season_id: season.id,
|
|
8
8
|
iteration: season.iteration,
|
|
9
|
-
league_id:
|
|
9
|
+
league_id: leagueId,
|
|
10
|
+
champion: season.champion != null ? season.champion.id : undefined
|
|
10
11
|
};
|
|
11
12
|
}
|
|
12
13
|
function transformToObject(model) {
|
|
@@ -15,6 +16,7 @@ function transformToObject(model) {
|
|
|
15
16
|
matches: model.Matches != null ? model.Matches.map(transformToMatch) : [],
|
|
16
17
|
iteration: model.iteration,
|
|
17
18
|
teams: model.seasonTeams != null ? model.seasonTeams.map(transformToTeam) : [],
|
|
19
|
+
champion: model.Champion != null ? transformToTeam(model.Champion) : undefined
|
|
18
20
|
});
|
|
19
21
|
}
|
|
20
22
|
function transformToAPIObject(model) {
|
|
@@ -25,7 +27,8 @@ function transformToAPIObject(model) {
|
|
|
25
27
|
iteration: model.iteration,
|
|
26
28
|
teams: model.seasonTeams != null ? model.seasonTeams.map(transformToAPITeam) : [],
|
|
27
29
|
league: transformToLeague(model.league),
|
|
28
|
-
standings: season.standings
|
|
30
|
+
standings: season.standings,
|
|
31
|
+
champion: model.Champion != null ? transformToAPITeam(model.Champion) : undefined
|
|
29
32
|
};
|
|
30
33
|
}
|
|
31
34
|
export { transformToObject as transformToSeason, transformToAPIObject as transformToAPISeason, transformToAttributes as transformFromSeason };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Substitution } from '../../service';
|
|
2
2
|
import { SubstitutionAttributes, SubstitutionModel } from '../models';
|
|
3
3
|
import { APISubstitution } from '../../routing';
|
|
4
|
-
declare function transformToAttributes(event: Substitution,
|
|
4
|
+
declare function transformToAttributes(event: Substitution, rallyId: string): SubstitutionAttributes;
|
|
5
5
|
declare function transformToObject(event: SubstitutionModel): Substitution;
|
|
6
6
|
declare function transformToAPIObject(event: SubstitutionModel): APISubstitution;
|
|
7
7
|
export { transformToObject as transformToSubstitution, transformToAPIObject as transformToAPISubstitution, transformToAttributes as transformFromSubstitution };
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { Substitution } from '../../service';
|
|
2
2
|
import { transformFromEventType, transformToEventType } from './event-type';
|
|
3
3
|
import { transformToPlayer } from './player';
|
|
4
|
-
function transformToAttributes(event,
|
|
4
|
+
function transformToAttributes(event, rallyId) {
|
|
5
5
|
return {
|
|
6
6
|
player_id: event.player.id,
|
|
7
7
|
event_id: event.id,
|
|
8
8
|
order: event.order,
|
|
9
9
|
event_type: transformFromEventType(event.eventType),
|
|
10
10
|
player_out: event.playerOut.id,
|
|
11
|
-
rally_id:
|
|
11
|
+
rally_id: rallyId
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
14
|
function transformToObject(event) {
|
|
@@ -6,6 +6,7 @@ export interface SeasonOpts {
|
|
|
6
6
|
readonly teams: Team[];
|
|
7
7
|
readonly matches: Match[];
|
|
8
8
|
readonly iteration: number;
|
|
9
|
+
readonly champion?: Team;
|
|
9
10
|
}
|
|
10
11
|
export declare class Season {
|
|
11
12
|
readonly id: string;
|
|
@@ -13,7 +14,7 @@ export declare class Season {
|
|
|
13
14
|
readonly matches: Match[];
|
|
14
15
|
readonly iteration: number;
|
|
15
16
|
readonly standings: Standing[];
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
champion?: Team;
|
|
18
|
+
constructor({ id, iteration, teams, matches, champion }: SeasonOpts);
|
|
18
19
|
calculateStandings(): Standing[];
|
|
19
20
|
}
|
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
import { Standing } from './standing';
|
|
2
2
|
export class Season {
|
|
3
|
-
constructor({ id, iteration, teams, matches }) {
|
|
3
|
+
constructor({ id, iteration, teams, matches, champion }) {
|
|
4
4
|
this.id = id;
|
|
5
5
|
this.teams = teams;
|
|
6
6
|
this.matches = matches;
|
|
7
7
|
this.iteration = iteration;
|
|
8
8
|
this.standings = this.calculateStandings();
|
|
9
|
-
|
|
10
|
-
get champion() {
|
|
11
|
-
if (this.matches.every(match => !match.isOver()))
|
|
12
|
-
return undefined;
|
|
13
|
-
return this.teams.find(team => team.id === this.standings[0].teamId);
|
|
9
|
+
this.champion = champion;
|
|
14
10
|
}
|
|
15
11
|
calculateStandings() {
|
|
16
12
|
return this.teams.map(team => {
|