volleyballsimtypes 0.0.188 → 0.0.190
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 +10 -8
- package/dist/cjs/src/data/models/competition.d.ts +6 -6
- package/dist/cjs/src/data/models/division-season.d.ts +23 -0
- package/dist/cjs/src/data/models/{league-season.js → division-season.js} +9 -9
- package/dist/cjs/src/data/models/division.d.ts +35 -0
- package/dist/cjs/src/data/models/division.js +47 -0
- package/dist/cjs/src/data/models/index.d.ts +2 -1
- package/dist/cjs/src/data/models/index.js +2 -1
- package/dist/cjs/src/data/models/league.d.ts +13 -24
- package/dist/cjs/src/data/models/team.d.ts +1 -8
- package/dist/cjs/src/data/models/team.js +0 -8
- package/dist/cjs/src/data/transformers/division.d.ts +5 -0
- package/dist/cjs/src/data/transformers/division.js +23 -0
- package/dist/cjs/src/data/transformers/index.d.ts +1 -0
- package/dist/cjs/src/data/transformers/index.js +1 -0
- package/dist/cjs/src/data/transformers/league.js +3 -6
- package/dist/cjs/src/data/transformers/season.d.ts +1 -1
- package/dist/cjs/src/data/transformers/season.js +1 -2
- package/dist/cjs/src/data/transformers/team.js +0 -2
- package/dist/cjs/src/service/coach/formation.js +13 -13
- package/dist/cjs/src/service/competition/division.d.ts +15 -0
- package/dist/cjs/src/service/competition/division.js +12 -0
- package/dist/cjs/src/service/competition/index.d.ts +1 -0
- package/dist/cjs/src/service/competition/index.js +1 -0
- package/dist/cjs/src/service/competition/league.d.ts +4 -4
- package/dist/cjs/src/service/competition/league.js +2 -2
- package/dist/cjs/src/service/match/match-rating.js +13 -19
- package/dist/cjs/src/service/team/team.d.ts +1 -4
- package/dist/cjs/src/service/team/team.js +1 -2
- package/dist/cjs/src/service/utils/number-utils.d.ts +1 -0
- package/dist/cjs/src/service/utils/number-utils.js +19 -1
- package/dist/esm/src/data/init-models.js +11 -9
- package/dist/esm/src/data/models/competition.d.ts +6 -6
- package/dist/esm/src/data/models/division-season.d.ts +23 -0
- package/dist/esm/src/data/models/{league-season.js → division-season.js} +7 -7
- package/dist/esm/src/data/models/division.d.ts +35 -0
- package/dist/esm/src/data/models/division.js +43 -0
- package/dist/esm/src/data/models/index.d.ts +2 -1
- package/dist/esm/src/data/models/index.js +2 -1
- package/dist/esm/src/data/models/league.d.ts +13 -24
- package/dist/esm/src/data/models/team.d.ts +1 -8
- package/dist/esm/src/data/models/team.js +0 -8
- package/dist/esm/src/data/transformers/division.d.ts +5 -0
- package/dist/esm/src/data/transformers/division.js +19 -0
- package/dist/esm/src/data/transformers/index.d.ts +1 -0
- package/dist/esm/src/data/transformers/index.js +1 -0
- package/dist/esm/src/data/transformers/league.js +4 -7
- package/dist/esm/src/data/transformers/season.d.ts +1 -1
- package/dist/esm/src/data/transformers/season.js +1 -2
- package/dist/esm/src/data/transformers/team.js +1 -3
- package/dist/esm/src/service/coach/formation.js +13 -13
- package/dist/esm/src/service/competition/division.d.ts +15 -0
- package/dist/esm/src/service/competition/division.js +8 -0
- package/dist/esm/src/service/competition/index.d.ts +1 -0
- package/dist/esm/src/service/competition/index.js +1 -0
- package/dist/esm/src/service/competition/league.d.ts +4 -4
- package/dist/esm/src/service/competition/league.js +2 -2
- package/dist/esm/src/service/match/match-rating.js +14 -20
- package/dist/esm/src/service/team/team.d.ts +1 -4
- package/dist/esm/src/service/team/team.js +1 -2
- package/dist/esm/src/service/utils/number-utils.d.ts +1 -0
- package/dist/esm/src/service/utils/number-utils.js +17 -0
- package/package.json +1 -1
- package/dist/cjs/src/data/models/league-season.d.ts +0 -23
- package/dist/esm/src/data/models/league-season.d.ts +0 -23
|
@@ -2,27 +2,21 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MatchRating = void 0;
|
|
4
4
|
const _1 = require(".");
|
|
5
|
+
const utils_1 = require("../utils");
|
|
5
6
|
class MatchRating {
|
|
6
7
|
constructor({ match, competitionType }) {
|
|
7
8
|
this.match = match;
|
|
8
9
|
this.weight = MatchRating.MWF[competitionType];
|
|
9
10
|
}
|
|
10
11
|
getPoints(team) {
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return weighted * -1;
|
|
12
|
+
const homeScoreKey = this.match.getScore();
|
|
13
|
+
const emr = this.getExpectedResult();
|
|
14
|
+
const ssv = MatchRating.SSV[homeScoreKey];
|
|
15
|
+
const homeDelta = (ssv - emr) * this.weight / MatchRating.K;
|
|
16
|
+
return team === _1.MatchTeam.HOME ? homeDelta : -homeDelta;
|
|
17
17
|
}
|
|
18
18
|
static calculateProbability(z) {
|
|
19
|
-
|
|
20
|
-
const rectangles = 100000;
|
|
21
|
-
const width = (z - (-10)) / rectangles;
|
|
22
|
-
for (let i = 0; i < rectangles; i++) {
|
|
23
|
-
area += width * Math.exp(-Math.pow((width * i + (-10)), 2) / 2) / Math.sqrt(2 * Math.PI);
|
|
24
|
-
}
|
|
25
|
-
return area;
|
|
19
|
+
return 0.5 * (1 + (0, utils_1.erf)(z / Math.SQRT2));
|
|
26
20
|
}
|
|
27
21
|
getExpectedResult() {
|
|
28
22
|
const D = MatchRating.K * (this.match.homeTeam.rating - this.match.awayTeam.rating) / 1000; // Strength difference between the teams
|
|
@@ -47,12 +41,12 @@ class MatchRating {
|
|
|
47
41
|
exports.MatchRating = MatchRating;
|
|
48
42
|
MatchRating.K = 8; // Standard scaling factor
|
|
49
43
|
MatchRating.SSV = {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
44
|
+
'3-0': 2,
|
|
45
|
+
'3-1': 1.5,
|
|
46
|
+
'3-2': 1,
|
|
47
|
+
'2-3': -1,
|
|
48
|
+
'1-3': -1.5,
|
|
49
|
+
'0-3': -2
|
|
56
50
|
};
|
|
57
51
|
MatchRating.C1 = -1.060;
|
|
58
52
|
MatchRating.C2 = -0.394;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Coach } from '../coach';
|
|
2
2
|
import { Player } from '../player';
|
|
3
3
|
import { Country } from '../country';
|
|
4
|
-
import { League } from '../competition';
|
|
5
4
|
interface TeamParams {
|
|
6
5
|
readonly id: string;
|
|
7
6
|
readonly rating: number;
|
|
@@ -9,7 +8,6 @@ interface TeamParams {
|
|
|
9
8
|
readonly shortName: string;
|
|
10
9
|
readonly roster: Player[];
|
|
11
10
|
readonly country?: Country;
|
|
12
|
-
readonly league?: League;
|
|
13
11
|
readonly coach?: Coach;
|
|
14
12
|
}
|
|
15
13
|
export declare class Team {
|
|
@@ -18,10 +16,9 @@ export declare class Team {
|
|
|
18
16
|
readonly name: string;
|
|
19
17
|
readonly shortName: string;
|
|
20
18
|
readonly coach?: Coach;
|
|
21
|
-
readonly league?: League;
|
|
22
19
|
readonly country?: Country;
|
|
23
20
|
private _rating;
|
|
24
|
-
constructor({ id, rating, name, shortName, country, roster, coach
|
|
21
|
+
constructor({ id, rating, name, shortName, country, roster, coach }: TeamParams);
|
|
25
22
|
get rating(): number;
|
|
26
23
|
set rating(value: number);
|
|
27
24
|
isPlayerInRoster(player: Player): boolean;
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Team = void 0;
|
|
4
4
|
const utils_1 = require("../utils");
|
|
5
5
|
class Team {
|
|
6
|
-
constructor({ id, rating, name, shortName, country, roster, coach
|
|
6
|
+
constructor({ id, rating, name, shortName, country, roster, coach }) {
|
|
7
7
|
(0, utils_1.validateUUID)(id);
|
|
8
8
|
this.id = id;
|
|
9
9
|
this._rating = rating;
|
|
@@ -12,7 +12,6 @@ class Team {
|
|
|
12
12
|
this.name = name;
|
|
13
13
|
this.shortName = shortName;
|
|
14
14
|
this.country = country;
|
|
15
|
-
this.league = league;
|
|
16
15
|
}
|
|
17
16
|
get rating() {
|
|
18
17
|
return this._rating;
|
|
@@ -1,7 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.clamp = void 0;
|
|
3
|
+
exports.erf = exports.clamp = void 0;
|
|
4
4
|
function clamp(min, max, value) {
|
|
5
5
|
return Math.max(min, Math.min(value, max));
|
|
6
6
|
}
|
|
7
7
|
exports.clamp = clamp;
|
|
8
|
+
// Approximation of the error function
|
|
9
|
+
function erf(x) {
|
|
10
|
+
// constants
|
|
11
|
+
const a1 = 0.254829592;
|
|
12
|
+
const a2 = -0.284496736;
|
|
13
|
+
const a3 = 1.421413741;
|
|
14
|
+
const a4 = -1.453152027;
|
|
15
|
+
const a5 = 1.061405429;
|
|
16
|
+
const p = 0.3275911;
|
|
17
|
+
// Save the sign of x
|
|
18
|
+
const sign = x < 0 ? -1 : 1;
|
|
19
|
+
x = Math.abs(x);
|
|
20
|
+
// Abramowitz & Stegun 7.1.26
|
|
21
|
+
const t = 1.0 / (1.0 + p * x);
|
|
22
|
+
const y = 1.0 - ((((a5 * t + a4) * t + a3) * t + a2) * t + a1) * t * Math.exp(-x * x);
|
|
23
|
+
return sign * y;
|
|
24
|
+
}
|
|
25
|
+
exports.erf = erf;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BoxScoreModel, CoachModel, CompetitionChampionModel, CompetitionMatchModel, CompetitionModel, CompetitionTeamsModel, CountryModel, DraftModel, DraftPickModel, IterationModel, LeagueModel,
|
|
1
|
+
import { BoxScoreModel, CoachModel, CompetitionChampionModel, CompetitionMatchModel, CompetitionModel, CompetitionTeamsModel, CountryModel, DivisionModel, DivisionSeasonModel, DraftModel, DraftPickModel, IterationModel, LeagueModel, MatchModel, MatchRatingModel, MatchResultModel, MatchSetModel, PerformanceStatsModel, PlayerModel, PlayerTeamModel, RallyModel, SetPositionModel, TeamModel, UserModel } from './models';
|
|
2
2
|
export function initModels(sequelize) {
|
|
3
3
|
const Coach = CoachModel.initModel(sequelize);
|
|
4
4
|
const Country = CountryModel.initModel(sequelize);
|
|
@@ -10,7 +10,8 @@ export function initModels(sequelize) {
|
|
|
10
10
|
const DraftPick = DraftPickModel.initModel(sequelize);
|
|
11
11
|
const Iteration = IterationModel.initModel(sequelize);
|
|
12
12
|
const League = LeagueModel.initModel(sequelize);
|
|
13
|
-
const
|
|
13
|
+
const Division = DivisionModel.initModel(sequelize);
|
|
14
|
+
const DivisionSeason = DivisionSeasonModel.initModel(sequelize);
|
|
14
15
|
const Match = MatchModel.initModel(sequelize);
|
|
15
16
|
const MatchRating = MatchRatingModel.initModel(sequelize);
|
|
16
17
|
const MatchResult = MatchResultModel.initModel(sequelize);
|
|
@@ -29,7 +30,7 @@ export function initModels(sequelize) {
|
|
|
29
30
|
Competition.hasMany(CompetitionMatch, { as: 'CompetitionMatches', foreignKey: 'competition_id' });
|
|
30
31
|
Competition.hasMany(CompetitionTeams, { as: 'CompetitionTeams', foreignKey: 'competition_id' });
|
|
31
32
|
Competition.hasOne(CompetitionChampion, { as: 'CompetitionChampion', foreignKey: 'competition_id' });
|
|
32
|
-
Competition.hasOne(
|
|
33
|
+
Competition.hasOne(DivisionSeason, { as: 'DivisionSeason', foreignKey: 'competition_id' });
|
|
33
34
|
Competition.belongsToMany(Team, {
|
|
34
35
|
as: 'Teams',
|
|
35
36
|
through: CompetitionTeams,
|
|
@@ -52,10 +53,11 @@ export function initModels(sequelize) {
|
|
|
52
53
|
DraftPick.belongsTo(Team, { as: 'team', foreignKey: 'team_id' });
|
|
53
54
|
Iteration.hasMany(Competition, { as: 'Competitions', foreignKey: 'iteration' });
|
|
54
55
|
League.belongsTo(Country, { as: 'country', foreignKey: 'country_id' });
|
|
55
|
-
League.hasMany(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
League.hasMany(Division, { as: 'Divisions', foreignKey: 'league_id' });
|
|
57
|
+
Division.belongsTo(League, { as: 'league', foreignKey: 'league_id' });
|
|
58
|
+
Division.hasMany(DivisionSeason, { as: 'DivisionSeasons', foreignKey: 'division_id' });
|
|
59
|
+
DivisionSeason.belongsTo(Competition, { as: 'competition', foreignKey: 'competition_id' });
|
|
60
|
+
DivisionSeason.belongsTo(Division, { as: 'division', foreignKey: 'division_id' });
|
|
59
61
|
Match.belongsTo(Team, { as: 'AwayTeam', foreignKey: 'away_team' });
|
|
60
62
|
Match.belongsTo(Team, { as: 'HomeTeam', foreignKey: 'home_team' });
|
|
61
63
|
Match.belongsToMany(Team, {
|
|
@@ -123,7 +125,6 @@ export function initModels(sequelize) {
|
|
|
123
125
|
SetPosition.belongsTo(Player, { as: 'player', foreignKey: 'player_id' });
|
|
124
126
|
Team.belongsTo(Coach, { as: 'coach', foreignKey: 'coach_id' });
|
|
125
127
|
Team.belongsTo(Country, { as: 'country', foreignKey: 'country_id' });
|
|
126
|
-
Team.belongsTo(League, { as: 'league', foreignKey: 'league_id' });
|
|
127
128
|
Team.belongsToMany(Competition, {
|
|
128
129
|
as: 'Competitions',
|
|
129
130
|
through: CompetitionTeams,
|
|
@@ -158,11 +159,12 @@ export function initModels(sequelize) {
|
|
|
158
159
|
CompetitionMatch,
|
|
159
160
|
CompetitionTeams,
|
|
160
161
|
Country,
|
|
162
|
+
Division,
|
|
161
163
|
Draft,
|
|
162
164
|
DraftPick,
|
|
163
165
|
Iteration,
|
|
164
166
|
League,
|
|
165
|
-
|
|
167
|
+
DivisionSeason,
|
|
166
168
|
Match,
|
|
167
169
|
MatchRating,
|
|
168
170
|
MatchResult,
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import * as Sequelize from 'sequelize';
|
|
2
2
|
import { Model } from 'sequelize';
|
|
3
|
-
import { CompetitionChampionAttributes, CompetitionChampionId, CompetitionChampionModel, CompetitionMatchAttributes, CompetitionMatchId, CompetitionMatchModel, CompetitionTeamsAttributes, CompetitionTeamsId, CompetitionTeamsModel,
|
|
3
|
+
import { CompetitionChampionAttributes, CompetitionChampionId, CompetitionChampionModel, CompetitionMatchAttributes, CompetitionMatchId, CompetitionMatchModel, CompetitionTeamsAttributes, CompetitionTeamsId, CompetitionTeamsModel, DivisionSeasonAttributes, DivisionSeasonId, DivisionSeasonModel, IterationId, IterationModel, TeamId, TeamModel } from '.';
|
|
4
4
|
import { Status } from '../common';
|
|
5
5
|
export interface CompetitionAttributes {
|
|
6
6
|
competition_id: string;
|
|
7
7
|
iteration: number;
|
|
8
8
|
status: Status;
|
|
9
9
|
type: CompetitionType;
|
|
10
|
-
|
|
10
|
+
DivisionSeason?: DivisionSeasonAttributes;
|
|
11
11
|
CompetitionChampion?: CompetitionChampionAttributes;
|
|
12
12
|
CompetitionMatches?: CompetitionMatchAttributes[];
|
|
13
13
|
CompetitionTeams?: CompetitionTeamsAttributes[];
|
|
@@ -47,10 +47,10 @@ export declare class CompetitionModel extends Model<CompetitionAttributes, Compe
|
|
|
47
47
|
hasCompetitionTeam: Sequelize.HasManyHasAssociationMixin<CompetitionTeamsModel, CompetitionTeamsId>;
|
|
48
48
|
hasCompetitionTeams: Sequelize.HasManyHasAssociationsMixin<CompetitionTeamsModel, CompetitionTeamsId>;
|
|
49
49
|
countCompetitionTeams: Sequelize.HasManyCountAssociationsMixin;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
DivisionSeason: DivisionSeasonModel;
|
|
51
|
+
getDivisionSeason: Sequelize.HasOneGetAssociationMixin<DivisionSeasonModel>;
|
|
52
|
+
setDivisionSeason: Sequelize.HasOneSetAssociationMixin<DivisionSeasonModel, DivisionSeasonId>;
|
|
53
|
+
createDivisionSeason: Sequelize.HasOneCreateAssociationMixin<DivisionSeasonModel>;
|
|
54
54
|
Teams: TeamModel[];
|
|
55
55
|
getTeams: Sequelize.BelongsToManyGetAssociationsMixin<TeamModel>;
|
|
56
56
|
setTeams: Sequelize.BelongsToManySetAssociationsMixin<TeamModel, TeamId>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as Sequelize from 'sequelize';
|
|
2
|
+
import { Model } from 'sequelize';
|
|
3
|
+
import { CompetitionId, CompetitionModel, DivisionId, DivisionModel } from '.';
|
|
4
|
+
export interface DivisionSeasonAttributes {
|
|
5
|
+
division_id: string;
|
|
6
|
+
competition_id: string;
|
|
7
|
+
}
|
|
8
|
+
export type DivisionSeasonPk = 'competition_id';
|
|
9
|
+
export type DivisionSeasonId = DivisionSeasonModel[DivisionSeasonPk];
|
|
10
|
+
export type DivisionSeasonCreationAttributes = DivisionSeasonAttributes;
|
|
11
|
+
export declare class DivisionSeasonModel extends Model<DivisionSeasonAttributes, DivisionSeasonCreationAttributes> implements DivisionSeasonAttributes {
|
|
12
|
+
division_id: string;
|
|
13
|
+
competition_id: string;
|
|
14
|
+
competition: CompetitionModel;
|
|
15
|
+
getCompetition: Sequelize.BelongsToGetAssociationMixin<CompetitionModel>;
|
|
16
|
+
setCompetition: Sequelize.BelongsToSetAssociationMixin<CompetitionModel, CompetitionId>;
|
|
17
|
+
createCompetition: Sequelize.BelongsToCreateAssociationMixin<CompetitionModel>;
|
|
18
|
+
division: DivisionModel;
|
|
19
|
+
getDivision: Sequelize.BelongsToGetAssociationMixin<DivisionModel>;
|
|
20
|
+
setDivision: Sequelize.BelongsToSetAssociationMixin<DivisionModel, DivisionId>;
|
|
21
|
+
createDivision: Sequelize.BelongsToCreateAssociationMixin<DivisionModel>;
|
|
22
|
+
static initModel(sequelize: Sequelize.Sequelize): typeof DivisionSeasonModel;
|
|
23
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { DataTypes, Model } from 'sequelize';
|
|
2
|
-
export class
|
|
2
|
+
export class DivisionSeasonModel extends Model {
|
|
3
3
|
static initModel(sequelize) {
|
|
4
|
-
return
|
|
5
|
-
|
|
4
|
+
return DivisionSeasonModel.init({
|
|
5
|
+
division_id: {
|
|
6
6
|
type: DataTypes.UUID,
|
|
7
7
|
allowNull: false,
|
|
8
8
|
references: {
|
|
9
|
-
model: '
|
|
10
|
-
key: '
|
|
9
|
+
model: 'Division',
|
|
10
|
+
key: 'division_id'
|
|
11
11
|
}
|
|
12
12
|
},
|
|
13
13
|
competition_id: {
|
|
@@ -21,11 +21,11 @@ export class LeagueSeasonModel extends Model {
|
|
|
21
21
|
}
|
|
22
22
|
}, {
|
|
23
23
|
sequelize,
|
|
24
|
-
tableName: '
|
|
24
|
+
tableName: 'DivisionSeason',
|
|
25
25
|
schema: 'public',
|
|
26
26
|
timestamps: false,
|
|
27
27
|
indexes: [{
|
|
28
|
-
name: '
|
|
28
|
+
name: 'divisionseason_pk',
|
|
29
29
|
unique: true,
|
|
30
30
|
fields: [{ name: 'competition_id' }]
|
|
31
31
|
}]
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import * as Sequelize from 'sequelize';
|
|
2
|
+
import { Model } from 'sequelize';
|
|
3
|
+
import { DivisionSeasonAttributes, DivisionSeasonId, DivisionSeasonModel, LeagueId, LeagueModel } from '.';
|
|
4
|
+
export interface DivisionAttributes {
|
|
5
|
+
division_id: string;
|
|
6
|
+
league_id: string;
|
|
7
|
+
tier: number;
|
|
8
|
+
name: string;
|
|
9
|
+
DivisionSeasons?: DivisionSeasonAttributes[];
|
|
10
|
+
}
|
|
11
|
+
export type DivisionPk = 'division_id';
|
|
12
|
+
export type DivisionId = DivisionModel[DivisionPk];
|
|
13
|
+
export type DivisionCreationAttributes = DivisionAttributes;
|
|
14
|
+
export declare class DivisionModel extends Model<DivisionAttributes, DivisionCreationAttributes> implements DivisionAttributes {
|
|
15
|
+
division_id: string;
|
|
16
|
+
league_id: string;
|
|
17
|
+
tier: number;
|
|
18
|
+
name: string;
|
|
19
|
+
league: LeagueModel;
|
|
20
|
+
getLeague: Sequelize.BelongsToGetAssociationMixin<LeagueModel>;
|
|
21
|
+
setLeague: Sequelize.BelongsToSetAssociationMixin<LeagueModel, LeagueId>;
|
|
22
|
+
createLeague: Sequelize.BelongsToCreateAssociationMixin<LeagueModel>;
|
|
23
|
+
DivisionSeasons: DivisionSeasonModel[];
|
|
24
|
+
getDivisionSeasons: Sequelize.HasManyGetAssociationsMixin<DivisionSeasonModel>;
|
|
25
|
+
setDivisionSeasons: Sequelize.HasManySetAssociationsMixin<DivisionSeasonModel, DivisionSeasonId>;
|
|
26
|
+
addDivisionSeason: Sequelize.HasManyAddAssociationMixin<DivisionSeasonModel, DivisionSeasonId>;
|
|
27
|
+
addDivisionSeasons: Sequelize.HasManyAddAssociationsMixin<DivisionSeasonModel, DivisionSeasonId>;
|
|
28
|
+
createDivisionSeason: Sequelize.HasManyCreateAssociationMixin<DivisionSeasonModel>;
|
|
29
|
+
removeDivisionSeason: Sequelize.HasManyRemoveAssociationMixin<DivisionSeasonModel, DivisionSeasonId>;
|
|
30
|
+
removeDivisionSeasons: Sequelize.HasManyRemoveAssociationsMixin<DivisionSeasonModel, DivisionSeasonId>;
|
|
31
|
+
hasDivisionSeason: Sequelize.HasManyHasAssociationMixin<DivisionSeasonModel, DivisionSeasonId>;
|
|
32
|
+
hasDivisionSeasons: Sequelize.HasManyHasAssociationsMixin<DivisionSeasonModel, DivisionSeasonId>;
|
|
33
|
+
countDivisionSeasons: Sequelize.HasManyCountAssociationsMixin;
|
|
34
|
+
static initModel(sequelize: Sequelize.Sequelize): typeof DivisionModel;
|
|
35
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { DataTypes, Model } from 'sequelize';
|
|
2
|
+
export class DivisionModel extends Model {
|
|
3
|
+
static initModel(sequelize) {
|
|
4
|
+
return DivisionModel.init({
|
|
5
|
+
division_id: {
|
|
6
|
+
type: DataTypes.UUID,
|
|
7
|
+
allowNull: false,
|
|
8
|
+
primaryKey: true
|
|
9
|
+
},
|
|
10
|
+
league_id: {
|
|
11
|
+
type: DataTypes.UUID,
|
|
12
|
+
allowNull: false,
|
|
13
|
+
references: {
|
|
14
|
+
model: 'League',
|
|
15
|
+
key: 'league_id'
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
tier: {
|
|
19
|
+
type: DataTypes.INTEGER,
|
|
20
|
+
allowNull: false
|
|
21
|
+
},
|
|
22
|
+
name: {
|
|
23
|
+
type: DataTypes.STRING,
|
|
24
|
+
allowNull: false,
|
|
25
|
+
unique: true
|
|
26
|
+
}
|
|
27
|
+
}, {
|
|
28
|
+
sequelize,
|
|
29
|
+
tableName: 'Division',
|
|
30
|
+
schema: 'public',
|
|
31
|
+
timestamps: false,
|
|
32
|
+
indexes: [{
|
|
33
|
+
name: 'Division_pk',
|
|
34
|
+
unique: true,
|
|
35
|
+
fields: [{ name: 'division_id' }]
|
|
36
|
+
}, {
|
|
37
|
+
name: 'Division_name_key',
|
|
38
|
+
unique: true,
|
|
39
|
+
fields: [{ name: 'name' }]
|
|
40
|
+
}]
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -9,7 +9,8 @@ export * from './draft';
|
|
|
9
9
|
export * from './draft-pick';
|
|
10
10
|
export * from './iteration';
|
|
11
11
|
export * from './league';
|
|
12
|
-
export * from './
|
|
12
|
+
export * from './division';
|
|
13
|
+
export * from './division-season';
|
|
13
14
|
export * from './match';
|
|
14
15
|
export * from './match-rating';
|
|
15
16
|
export * from './match-result';
|
|
@@ -9,7 +9,8 @@ export * from './draft';
|
|
|
9
9
|
export * from './draft-pick';
|
|
10
10
|
export * from './iteration';
|
|
11
11
|
export * from './league';
|
|
12
|
-
export * from './
|
|
12
|
+
export * from './division';
|
|
13
|
+
export * from './division-season';
|
|
13
14
|
export * from './match';
|
|
14
15
|
export * from './match-rating';
|
|
15
16
|
export * from './match-result';
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as Sequelize from 'sequelize';
|
|
2
2
|
import { Model } from 'sequelize';
|
|
3
|
-
import { CountryId, CountryModel,
|
|
3
|
+
import { CountryId, CountryModel, DivisionAttributes, DivisionId, DivisionModel } from '.';
|
|
4
4
|
export interface LeagueAttributes {
|
|
5
5
|
league_id: string;
|
|
6
6
|
country_id: string;
|
|
7
7
|
name: string;
|
|
8
|
-
|
|
8
|
+
Divisions?: DivisionAttributes[];
|
|
9
9
|
}
|
|
10
10
|
export type LeaguePk = 'league_id';
|
|
11
11
|
export type LeagueId = LeagueModel[LeaguePk];
|
|
@@ -18,27 +18,16 @@ export declare class LeagueModel extends Model<LeagueAttributes, LeagueCreationA
|
|
|
18
18
|
getCountry: Sequelize.BelongsToGetAssociationMixin<CountryModel>;
|
|
19
19
|
setCountry: Sequelize.BelongsToSetAssociationMixin<CountryModel, CountryId>;
|
|
20
20
|
createCountry: Sequelize.BelongsToCreateAssociationMixin<CountryModel>;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
Teams: TeamModel[];
|
|
33
|
-
getTeams: Sequelize.HasManyGetAssociationsMixin<TeamModel>;
|
|
34
|
-
setTeams: Sequelize.HasManySetAssociationsMixin<TeamModel, TeamId>;
|
|
35
|
-
addTeam: Sequelize.HasManyAddAssociationMixin<TeamModel, TeamId>;
|
|
36
|
-
addTeams: Sequelize.HasManyAddAssociationsMixin<TeamModel, TeamId>;
|
|
37
|
-
createTeam: Sequelize.HasManyCreateAssociationMixin<TeamModel>;
|
|
38
|
-
removeTeam: Sequelize.HasManyRemoveAssociationMixin<TeamModel, TeamId>;
|
|
39
|
-
removeTeams: Sequelize.HasManyRemoveAssociationsMixin<TeamModel, TeamId>;
|
|
40
|
-
hasTeam: Sequelize.HasManyHasAssociationMixin<TeamModel, TeamId>;
|
|
41
|
-
hasTeams: Sequelize.HasManyHasAssociationsMixin<TeamModel, TeamId>;
|
|
42
|
-
countTeams: Sequelize.HasManyCountAssociationsMixin;
|
|
21
|
+
Divisions: DivisionModel[];
|
|
22
|
+
getDivisions: Sequelize.HasManyGetAssociationsMixin<DivisionModel>;
|
|
23
|
+
setDivisions: Sequelize.HasManySetAssociationsMixin<DivisionModel, DivisionId>;
|
|
24
|
+
addDivision: Sequelize.HasManyAddAssociationMixin<DivisionModel, DivisionId>;
|
|
25
|
+
addDivisions: Sequelize.HasManyAddAssociationsMixin<DivisionModel, DivisionId>;
|
|
26
|
+
createDivision: Sequelize.HasManyCreateAssociationMixin<DivisionModel>;
|
|
27
|
+
removeDivision: Sequelize.HasManyRemoveAssociationMixin<DivisionModel, DivisionId>;
|
|
28
|
+
removeDivisions: Sequelize.HasManyRemoveAssociationsMixin<DivisionModel, DivisionId>;
|
|
29
|
+
hasDivision: Sequelize.HasManyHasAssociationMixin<DivisionModel, DivisionId>;
|
|
30
|
+
hasDivisions: Sequelize.HasManyHasAssociationsMixin<DivisionModel, DivisionId>;
|
|
31
|
+
countDivisions: Sequelize.HasManyCountAssociationsMixin;
|
|
43
32
|
static initModel(sequelize: Sequelize.Sequelize): typeof LeagueModel;
|
|
44
33
|
}
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import * as Sequelize from 'sequelize';
|
|
2
2
|
import { Model, Optional } from 'sequelize';
|
|
3
|
-
import { CoachAttributes, CoachId, CoachModel, CompetitionChampionId, CompetitionChampionModel, CompetitionId, CompetitionModel, CompetitionTeamsId, CompetitionTeamsModel, CountryId, CountryModel, DraftPickId, DraftPickModel,
|
|
3
|
+
import { CoachAttributes, CoachId, CoachModel, CompetitionChampionId, CompetitionChampionModel, CompetitionId, CompetitionModel, CompetitionTeamsId, CompetitionTeamsModel, CountryId, CountryModel, DraftPickId, DraftPickModel, MatchId, MatchModel, MatchRatingId, MatchRatingModel, PlayerAttributes, PlayerId, PlayerModel, PlayerTeamId, PlayerTeamModel, RallyId, RallyModel } from '.';
|
|
4
4
|
export interface TeamAttributes {
|
|
5
5
|
team_id: string;
|
|
6
6
|
name: string;
|
|
7
7
|
short_name: string;
|
|
8
8
|
rating: number;
|
|
9
9
|
coach_id?: string;
|
|
10
|
-
league_id?: string;
|
|
11
10
|
country_id?: string;
|
|
12
11
|
coach?: CoachAttributes;
|
|
13
|
-
league?: LeagueAttributes;
|
|
14
12
|
Players?: PlayerAttributes[];
|
|
15
13
|
}
|
|
16
14
|
export type TeamPk = 'team_id';
|
|
@@ -23,7 +21,6 @@ export declare class TeamModel extends Model<TeamAttributes, TeamCreationAttribu
|
|
|
23
21
|
name: string;
|
|
24
22
|
short_name: string;
|
|
25
23
|
country_id: string;
|
|
26
|
-
league_id: string;
|
|
27
24
|
rating: number;
|
|
28
25
|
coach: CoachModel;
|
|
29
26
|
getCoach: Sequelize.BelongsToGetAssociationMixin<CoachModel>;
|
|
@@ -33,10 +30,6 @@ export declare class TeamModel extends Model<TeamAttributes, TeamCreationAttribu
|
|
|
33
30
|
getCountry: Sequelize.BelongsToGetAssociationMixin<CountryModel>;
|
|
34
31
|
setCountry: Sequelize.BelongsToSetAssociationMixin<CountryModel, CountryId>;
|
|
35
32
|
createCountry: Sequelize.BelongsToCreateAssociationMixin<CountryModel>;
|
|
36
|
-
league: LeagueModel;
|
|
37
|
-
getLeague: Sequelize.BelongsToGetAssociationMixin<LeagueModel>;
|
|
38
|
-
setLeague: Sequelize.BelongsToSetAssociationMixin<LeagueModel, LeagueId>;
|
|
39
|
-
createLeague: Sequelize.BelongsToCreateAssociationMixin<LeagueModel>;
|
|
40
33
|
Competitions: CompetitionModel[];
|
|
41
34
|
getCompetitions: Sequelize.BelongsToManyGetAssociationsMixin<CompetitionModel>;
|
|
42
35
|
setCompetitions: Sequelize.BelongsToManySetAssociationsMixin<CompetitionModel, CompetitionId>;
|
|
@@ -31,14 +31,6 @@ export class TeamModel extends Model {
|
|
|
31
31
|
key: 'country_id'
|
|
32
32
|
}
|
|
33
33
|
},
|
|
34
|
-
league_id: {
|
|
35
|
-
type: DataTypes.UUID,
|
|
36
|
-
allowNull: false,
|
|
37
|
-
references: {
|
|
38
|
-
model: 'League',
|
|
39
|
-
key: 'league_id'
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
34
|
rating: {
|
|
43
35
|
type: DataTypes.REAL,
|
|
44
36
|
allowNull: false,
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { DivisionAttributes, DivisionModel } from '../models';
|
|
2
|
+
import { Division } from '../../service';
|
|
3
|
+
declare function transformToAttributes(division: Division, leagueId: string): DivisionAttributes;
|
|
4
|
+
declare function transformToObject(model: DivisionModel): Division;
|
|
5
|
+
export { transformToObject as transformToDivision, transformToAttributes as transformFromDivision };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Division } from '../../service';
|
|
2
|
+
import { transformToSeason } from './season';
|
|
3
|
+
function transformToAttributes(division, leagueId) {
|
|
4
|
+
return {
|
|
5
|
+
division_id: division.id,
|
|
6
|
+
league_id: leagueId,
|
|
7
|
+
tier: division.tier,
|
|
8
|
+
name: division.name
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
function transformToObject(model) {
|
|
12
|
+
return new Division({
|
|
13
|
+
id: model.division_id,
|
|
14
|
+
name: model.name,
|
|
15
|
+
tier: model.tier,
|
|
16
|
+
seasons: (model.DivisionSeasons ?? []).map((ds) => transformToSeason(ds.competition))
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
export { transformToObject as transformToDivision, transformToAttributes as transformFromDivision };
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import { League } from '../../service';
|
|
2
|
-
import { transformToCountry,
|
|
2
|
+
import { transformFromDivision, transformToCountry, transformToDivision } from '.';
|
|
3
3
|
function transformToAttributes(league) {
|
|
4
|
-
const
|
|
5
|
-
league_id: league.id,
|
|
6
|
-
competition_id: season.id
|
|
7
|
-
}));
|
|
4
|
+
const Divisions = league.division?.map(div => transformFromDivision(div, league.id));
|
|
8
5
|
return {
|
|
9
6
|
league_id: league.id,
|
|
10
7
|
country_id: league.country.id,
|
|
11
8
|
name: league.name,
|
|
12
|
-
|
|
9
|
+
Divisions
|
|
13
10
|
};
|
|
14
11
|
}
|
|
15
12
|
function transformToObject(model) {
|
|
@@ -17,7 +14,7 @@ function transformToObject(model) {
|
|
|
17
14
|
id: model.league_id,
|
|
18
15
|
name: model.name,
|
|
19
16
|
country: transformToCountry(model.country),
|
|
20
|
-
|
|
17
|
+
division: (model.Divisions ?? []).map((division) => transformToDivision(division))
|
|
21
18
|
});
|
|
22
19
|
}
|
|
23
20
|
export { transformToObject as transformToLeague, transformToAttributes as transformFromLeague };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CompetitionAttributes, CompetitionModel } from '../models';
|
|
2
2
|
import { Season } from '../../service';
|
|
3
|
-
declare function transformToAttributes(season: Season
|
|
3
|
+
declare function transformToAttributes(season: Season): CompetitionAttributes;
|
|
4
4
|
declare function transformToObject(model: CompetitionModel): Season;
|
|
5
5
|
export { transformToObject as transformToSeason, transformToAttributes as transformFromSeason };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { transformFromSeasonMatch, transformToIteration, transformToMatch, transformToTeam } from '.';
|
|
2
2
|
import { Season } from '../../service';
|
|
3
|
-
function transformToAttributes(season
|
|
3
|
+
function transformToAttributes(season) {
|
|
4
4
|
const matches = (season.matches ?? []).map((match, index) => transformFromSeasonMatch(season.id, match, index));
|
|
5
5
|
const teams = season.teams.map(team => ({
|
|
6
6
|
competition_id: season.id,
|
|
@@ -16,7 +16,6 @@ function transformToAttributes(season, leagueId) {
|
|
|
16
16
|
competition_id: season.id,
|
|
17
17
|
type: 'LEAGUE',
|
|
18
18
|
iteration: season.iteration.id,
|
|
19
|
-
LeagueSeason: { league_id: leagueId, competition_id: season.id },
|
|
20
19
|
CompetitionChampion: champion,
|
|
21
20
|
CompetitionMatches: matches,
|
|
22
21
|
CompetitionTeams: teams,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Team } from '../../service';
|
|
2
|
-
import { transformFromCoach, transformToCoach, transformToCountry,
|
|
2
|
+
import { transformFromCoach, transformToCoach, transformToCountry, transformToPlayer } from '.';
|
|
3
3
|
function transformToAttributes(team) {
|
|
4
4
|
return {
|
|
5
5
|
team_id: team.id,
|
|
@@ -7,7 +7,6 @@ function transformToAttributes(team) {
|
|
|
7
7
|
short_name: team.shortName,
|
|
8
8
|
coach_id: team.coach?.id,
|
|
9
9
|
country_id: team.country?.id,
|
|
10
|
-
league_id: team.league?.id,
|
|
11
10
|
coach: team.coach != null ? transformFromCoach(team.coach) : undefined,
|
|
12
11
|
rating: team.rating
|
|
13
12
|
};
|
|
@@ -20,7 +19,6 @@ function transformToObject(model) {
|
|
|
20
19
|
country: model.country != null ? transformToCountry(model.country) : undefined,
|
|
21
20
|
coach: model.coach != null ? transformToCoach(model.coach) : undefined,
|
|
22
21
|
roster: (model.PlayerTeams ?? []).map((pt) => transformToPlayer(pt.player)),
|
|
23
|
-
league: model.league != null ? transformToLeague(model.league) : undefined,
|
|
24
22
|
rating: model.rating
|
|
25
23
|
});
|
|
26
24
|
}
|