volleyballsimtypes 0.0.19 → 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.
@@ -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
  }
@@ -9,7 +9,8 @@ function transformToAttributes(season, leagueId) {
9
9
  return {
10
10
  season_id: season.id,
11
11
  iteration: season.iteration,
12
- league_id: leagueId
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;
@@ -10,4 +10,5 @@ export interface APISeason {
10
10
  iteration: number;
11
11
  standings: Standing[];
12
12
  league: League;
13
+ champion?: APITeam;
13
14
  }
@@ -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
- constructor({ id, iteration, teams, matches }: SeasonOpts);
17
- get champion(): Team | undefined;
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
  }
@@ -18,6 +18,14 @@ export class SeasonModel extends Model {
18
18
  model: 'League',
19
19
  key: 'league_id'
20
20
  }
21
+ },
22
+ champion: {
23
+ type: DataTypes.UUID,
24
+ allowNull: true,
25
+ references: {
26
+ model: 'Team',
27
+ key: 'team_id'
28
+ }
21
29
  }
22
30
  }, {
23
31
  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
  }
@@ -6,7 +6,8 @@ function transformToAttributes(season, leagueId) {
6
6
  return {
7
7
  season_id: season.id,
8
8
  iteration: season.iteration,
9
- league_id: leagueId
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 };
@@ -10,4 +10,5 @@ export interface APISeason {
10
10
  iteration: number;
11
11
  standings: Standing[];
12
12
  league: League;
13
+ champion?: APITeam;
13
14
  }
@@ -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
- constructor({ id, iteration, teams, matches }: SeasonOpts);
17
- get champion(): Team | undefined;
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 => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "volleyballsimtypes",
3
- "version": "0.0.19",
3
+ "version": "0.0.20",
4
4
  "description": "vbsim types",
5
5
  "main": "./dist/cjs/src/index.js",
6
6
  "module": "./dist/esm/src/index.js",