volleyballsimtypes 0.0.146 → 0.0.148
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/common/status.d.ts +8 -0
- package/dist/cjs/src/common/status.js +11 -0
- package/dist/cjs/src/data/models/competition.d.ts +3 -0
- package/dist/cjs/src/data/models/competition.js +6 -0
- package/dist/cjs/src/data/models/match.d.ts +3 -2
- package/dist/cjs/src/data/models/match.js +4 -3
- package/dist/cjs/src/data/transformers/match.js +2 -2
- package/dist/cjs/src/data/transformers/season.js +4 -2
- package/dist/cjs/src/data/transformers/tournament.js +4 -2
- package/dist/cjs/src/service/competition/season.d.ts +4 -1
- package/dist/cjs/src/service/competition/season.js +2 -1
- package/dist/cjs/src/service/competition/tournament.d.ts +4 -1
- package/dist/cjs/src/service/competition/tournament.js +2 -1
- package/dist/cjs/src/service/match/court-position.d.ts +1 -1
- package/dist/cjs/src/service/match/court-position.js +3 -3
- package/dist/cjs/src/service/match/match.d.ts +5 -3
- package/dist/cjs/src/service/match/match.js +6 -2
- package/dist/cjs/src/service/player/trait.js +1 -1
- package/dist/esm/src/common/status.d.ts +8 -0
- package/dist/esm/src/common/status.js +8 -0
- package/dist/esm/src/data/models/competition.d.ts +3 -0
- package/dist/esm/src/data/models/competition.js +6 -0
- package/dist/esm/src/data/models/match.d.ts +3 -2
- package/dist/esm/src/data/models/match.js +4 -3
- package/dist/esm/src/data/transformers/match.js +2 -2
- package/dist/esm/src/data/transformers/season.js +4 -2
- package/dist/esm/src/data/transformers/tournament.js +4 -2
- package/dist/esm/src/service/competition/season.d.ts +4 -1
- package/dist/esm/src/service/competition/season.js +2 -1
- package/dist/esm/src/service/competition/tournament.d.ts +4 -1
- package/dist/esm/src/service/competition/tournament.js +2 -1
- package/dist/esm/src/service/match/court-position.d.ts +1 -1
- package/dist/esm/src/service/match/court-position.js +1 -1
- package/dist/esm/src/service/match/match.d.ts +5 -3
- package/dist/esm/src/service/match/match.js +6 -2
- package/dist/esm/src/service/player/trait.js +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { EnumDataType } from 'sequelize';
|
|
2
|
+
export declare enum StatusEnum {
|
|
3
|
+
PENDING = "PENDING",
|
|
4
|
+
IN_PROGRESS = "IN_PROGRESS",
|
|
5
|
+
COMPLETE = "COMPLETE"
|
|
6
|
+
}
|
|
7
|
+
export type Status = StatusEnum.PENDING | StatusEnum.IN_PROGRESS | StatusEnum.COMPLETE;
|
|
8
|
+
export declare const StatusDataType: EnumDataType<Status>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StatusDataType = exports.StatusEnum = void 0;
|
|
4
|
+
const sequelize_1 = require("sequelize");
|
|
5
|
+
var StatusEnum;
|
|
6
|
+
(function (StatusEnum) {
|
|
7
|
+
StatusEnum["PENDING"] = "PENDING";
|
|
8
|
+
StatusEnum["IN_PROGRESS"] = "IN_PROGRESS";
|
|
9
|
+
StatusEnum["COMPLETE"] = "COMPLETE";
|
|
10
|
+
})(StatusEnum = exports.StatusEnum || (exports.StatusEnum = {}));
|
|
11
|
+
exports.StatusDataType = sequelize_1.DataTypes.ENUM(...Object.values(StatusEnum));
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import * as Sequelize from 'sequelize';
|
|
2
2
|
import { Model } from 'sequelize';
|
|
3
3
|
import { CompetitionChampionAttributes, CompetitionChampionId, CompetitionChampionModel, CompetitionMatchAttributes, CompetitionMatchId, CompetitionMatchModel, CompetitionTeamsAttributes, CompetitionTeamsId, CompetitionTeamsModel, IterationId, IterationModel, LeagueSeasonAttributes, LeagueSeasonId, LeagueSeasonModel, TeamId, TeamModel } from '.';
|
|
4
|
+
import { Status } from '../../common/status';
|
|
4
5
|
export interface CompetitionAttributes {
|
|
5
6
|
competition_id: string;
|
|
6
7
|
iteration: number;
|
|
8
|
+
status: Status;
|
|
7
9
|
type: CompetitionType;
|
|
8
10
|
LeagueSeason?: LeagueSeasonAttributes;
|
|
9
11
|
CompetitionChampion?: CompetitionChampionAttributes;
|
|
@@ -18,6 +20,7 @@ export declare class CompetitionModel extends Model<CompetitionAttributes, Compe
|
|
|
18
20
|
competition_id: string;
|
|
19
21
|
iteration: number;
|
|
20
22
|
type: CompetitionType;
|
|
23
|
+
status: Status;
|
|
21
24
|
CompetitionChampion: CompetitionChampionModel;
|
|
22
25
|
getCompetitionChampion: Sequelize.HasOneGetAssociationMixin<CompetitionChampionModel>;
|
|
23
26
|
setCompetitionChampion: Sequelize.HasOneSetAssociationMixin<CompetitionChampionModel, CompetitionChampionId>;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CompetitionModel = void 0;
|
|
4
4
|
const sequelize_1 = require("sequelize");
|
|
5
|
+
const status_1 = require("../../common/status");
|
|
5
6
|
class CompetitionModel extends sequelize_1.Model {
|
|
6
7
|
static initModel(sequelize) {
|
|
7
8
|
return CompetitionModel.init({
|
|
@@ -21,6 +22,11 @@ class CompetitionModel extends sequelize_1.Model {
|
|
|
21
22
|
type: {
|
|
22
23
|
type: sequelize_1.DataTypes.ENUM('LEAGUE', 'TOURNAMENT'),
|
|
23
24
|
allowNull: false
|
|
25
|
+
},
|
|
26
|
+
status: {
|
|
27
|
+
type: status_1.StatusDataType,
|
|
28
|
+
allowNull: false,
|
|
29
|
+
defaultValue: 'PENDING'
|
|
24
30
|
}
|
|
25
31
|
}, {
|
|
26
32
|
sequelize,
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import * as Sequelize from 'sequelize';
|
|
2
2
|
import { Model } from 'sequelize';
|
|
3
3
|
import { CompetitionMatchId, CompetitionMatchModel, MatchRatingId, MatchRatingModel, MatchSetAttributes, MatchSetId, MatchSetModel, TeamId, TeamModel } from '.';
|
|
4
|
+
import { Status } from '../../common/status';
|
|
4
5
|
export interface MatchAttributes {
|
|
5
6
|
match_id: string;
|
|
6
7
|
home_team: string;
|
|
7
8
|
away_team: string;
|
|
8
9
|
scheduled_date: Date;
|
|
9
|
-
|
|
10
|
+
status: Status;
|
|
10
11
|
MatchSets?: MatchSetAttributes[];
|
|
11
12
|
}
|
|
12
13
|
export type MatchPk = 'match_id';
|
|
@@ -17,7 +18,7 @@ export declare class MatchModel extends Model<MatchAttributes, MatchCreationAttr
|
|
|
17
18
|
home_team: string;
|
|
18
19
|
away_team: string;
|
|
19
20
|
scheduled_date: Date;
|
|
20
|
-
|
|
21
|
+
status: Status;
|
|
21
22
|
CompetitionMatch: CompetitionMatchModel;
|
|
22
23
|
getCompetitionMatch: Sequelize.HasOneGetAssociationMixin<CompetitionMatchModel>;
|
|
23
24
|
setCompetitionMatch: Sequelize.HasOneSetAssociationMixin<CompetitionMatchModel, CompetitionMatchId>;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MatchModel = void 0;
|
|
4
4
|
const sequelize_1 = require("sequelize");
|
|
5
|
+
const status_1 = require("../../common/status");
|
|
5
6
|
class MatchModel extends sequelize_1.Model {
|
|
6
7
|
static initModel(sequelize) {
|
|
7
8
|
return MatchModel.init({
|
|
@@ -30,10 +31,10 @@ class MatchModel extends sequelize_1.Model {
|
|
|
30
31
|
type: sequelize_1.DataTypes.DATE,
|
|
31
32
|
allowNull: false
|
|
32
33
|
},
|
|
33
|
-
|
|
34
|
-
type:
|
|
34
|
+
status: {
|
|
35
|
+
type: status_1.StatusDataType,
|
|
35
36
|
allowNull: false,
|
|
36
|
-
defaultValue:
|
|
37
|
+
defaultValue: 'PENDING'
|
|
37
38
|
}
|
|
38
39
|
}, {
|
|
39
40
|
sequelize,
|
|
@@ -10,7 +10,7 @@ function transformToAttributes(match) {
|
|
|
10
10
|
away_team: match.awayTeam.id,
|
|
11
11
|
home_team: match.homeTeam.id,
|
|
12
12
|
scheduled_date: match.scheduledDate,
|
|
13
|
-
|
|
13
|
+
status: match.status
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
16
|
exports.transformFromMatch = transformToAttributes;
|
|
@@ -25,7 +25,7 @@ function transformToObject(model) {
|
|
|
25
25
|
awayTeam: (0, team_1.transformToTeam)(model.AwayTeam),
|
|
26
26
|
scheduledDate: new Date(model.scheduled_date),
|
|
27
27
|
sets,
|
|
28
|
-
|
|
28
|
+
status: model.status
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
31
|
exports.transformToMatch = transformToObject;
|
|
@@ -24,7 +24,8 @@ function transformToAttributes(season, leagueId) {
|
|
|
24
24
|
LeagueSeason: { league_id: leagueId, competition_id: season.id },
|
|
25
25
|
CompetitionChampion: champion,
|
|
26
26
|
CompetitionMatches: matches,
|
|
27
|
-
CompetitionTeams: teams
|
|
27
|
+
CompetitionTeams: teams,
|
|
28
|
+
status: season.status
|
|
28
29
|
};
|
|
29
30
|
}
|
|
30
31
|
exports.transformFromSeason = transformToAttributes;
|
|
@@ -37,7 +38,8 @@ function transformToObject(model) {
|
|
|
37
38
|
matches,
|
|
38
39
|
iteration: (0, _1.transformToIteration)(model.Iteration),
|
|
39
40
|
teams: model.Teams != null ? model.Teams.map(_1.transformToTeam) : [],
|
|
40
|
-
champion: model.CompetitionChampion != null ? (0, _1.transformToTeam)(model.CompetitionChampion.team) : undefined
|
|
41
|
+
champion: model.CompetitionChampion != null ? (0, _1.transformToTeam)(model.CompetitionChampion.team) : undefined,
|
|
42
|
+
status: model.status
|
|
41
43
|
});
|
|
42
44
|
}
|
|
43
45
|
exports.transformToSeason = transformToObject;
|
|
@@ -21,7 +21,8 @@ function transformToAttributes(tournament) {
|
|
|
21
21
|
iteration: tournament.iteration.id,
|
|
22
22
|
CompetitionChampion: champion,
|
|
23
23
|
CompetitionMatches: matches,
|
|
24
|
-
CompetitionTeams: teams
|
|
24
|
+
CompetitionTeams: teams,
|
|
25
|
+
status: tournament.status
|
|
25
26
|
};
|
|
26
27
|
}
|
|
27
28
|
exports.transformFromTournament = transformToAttributes;
|
|
@@ -31,7 +32,8 @@ function transformToObject(model) {
|
|
|
31
32
|
iteration: (0, _1.transformToIteration)(model.Iteration),
|
|
32
33
|
matches: model.CompetitionMatches != null ? model.CompetitionMatches.map(_1.transformToTournamentMatch) : [],
|
|
33
34
|
teams: model.Teams != null ? model.Teams.map(_1.transformToTeam) : [],
|
|
34
|
-
champion: model.CompetitionChampion != null ? (0, _1.transformToTeam)(model.CompetitionChampion.team) : undefined
|
|
35
|
+
champion: model.CompetitionChampion != null ? (0, _1.transformToTeam)(model.CompetitionChampion.team) : undefined,
|
|
36
|
+
status: model.status
|
|
35
37
|
});
|
|
36
38
|
}
|
|
37
39
|
exports.transformToTournament = transformToObject;
|
|
@@ -2,12 +2,14 @@ import { Team } from '../team';
|
|
|
2
2
|
import { Match } from '../match';
|
|
3
3
|
import { Standing } from './standing';
|
|
4
4
|
import { Iteration } from './iteration';
|
|
5
|
+
import { StatusEnum } from '../../common/status';
|
|
5
6
|
interface SeasonOpts {
|
|
6
7
|
readonly id: string;
|
|
7
8
|
readonly teams: Team[];
|
|
8
9
|
readonly matches: Match[];
|
|
9
10
|
readonly iteration: Iteration;
|
|
10
11
|
readonly champion?: Team;
|
|
12
|
+
readonly status: StatusEnum;
|
|
11
13
|
}
|
|
12
14
|
export declare class Season {
|
|
13
15
|
readonly id: string;
|
|
@@ -15,8 +17,9 @@ export declare class Season {
|
|
|
15
17
|
readonly matches: Match[];
|
|
16
18
|
readonly iteration: Iteration;
|
|
17
19
|
readonly standings: Standing[];
|
|
20
|
+
readonly status: StatusEnum;
|
|
18
21
|
champion?: Team;
|
|
19
|
-
constructor({ id, iteration, teams, matches, champion }: SeasonOpts);
|
|
22
|
+
constructor({ id, iteration, teams, matches, champion, status }: SeasonOpts);
|
|
20
23
|
calculateStandings(): Standing[];
|
|
21
24
|
updateStandings(): void;
|
|
22
25
|
}
|
|
@@ -3,13 +3,14 @@ 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, champion }) {
|
|
6
|
+
constructor({ id, iteration, teams, matches, champion, status }) {
|
|
7
7
|
this.id = id;
|
|
8
8
|
this.teams = teams;
|
|
9
9
|
this.matches = matches;
|
|
10
10
|
this.iteration = iteration;
|
|
11
11
|
this.champion = champion;
|
|
12
12
|
this.standings = this.calculateStandings();
|
|
13
|
+
this.status = status;
|
|
13
14
|
}
|
|
14
15
|
calculateStandings() {
|
|
15
16
|
return this.teams.map(team => {
|
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
import { TournamentMatch } from './tournament-match';
|
|
2
2
|
import { Team } from '../team';
|
|
3
3
|
import { Iteration } from './iteration';
|
|
4
|
+
import { StatusEnum } from '../../common/status';
|
|
4
5
|
interface TournamentOpts {
|
|
5
6
|
readonly id: string;
|
|
6
7
|
readonly iteration: Iteration;
|
|
7
8
|
readonly matches: TournamentMatch[];
|
|
8
9
|
readonly teams: Team[];
|
|
9
10
|
readonly champion?: Team;
|
|
11
|
+
readonly status: StatusEnum;
|
|
10
12
|
}
|
|
11
13
|
export declare class Tournament {
|
|
12
14
|
readonly id: string;
|
|
13
15
|
readonly iteration: Iteration;
|
|
14
16
|
readonly matches: TournamentMatch[];
|
|
15
17
|
readonly teams: Team[];
|
|
18
|
+
readonly status: StatusEnum;
|
|
16
19
|
champion?: Team;
|
|
17
|
-
constructor({ id, iteration, matches, teams, champion }: TournamentOpts);
|
|
20
|
+
constructor({ id, iteration, matches, teams, champion, status }: TournamentOpts);
|
|
18
21
|
static sortMatchesFn(m1: TournamentMatch, m2: TournamentMatch): number;
|
|
19
22
|
}
|
|
20
23
|
export {};
|
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Tournament = void 0;
|
|
4
4
|
class Tournament {
|
|
5
|
-
constructor({ id, iteration, matches, teams, champion }) {
|
|
5
|
+
constructor({ id, iteration, matches, teams, champion, status }) {
|
|
6
6
|
this.id = id;
|
|
7
7
|
this.iteration = iteration;
|
|
8
8
|
this.matches = matches;
|
|
9
9
|
this.teams = teams;
|
|
10
10
|
this.champion = champion;
|
|
11
|
+
this.status = status;
|
|
11
12
|
this.matches.sort(Tournament.sortMatchesFn);
|
|
12
13
|
}
|
|
13
14
|
static sortMatchesFn(m1, m2) {
|
|
@@ -31,4 +31,4 @@ export declare function getPositions(): CourtPosition[];
|
|
|
31
31
|
export declare function rotatePosition(position: number): CourtPosition;
|
|
32
32
|
export declare function isFrontRow(position: number): boolean;
|
|
33
33
|
export declare function isBackRow(position: number): boolean;
|
|
34
|
-
export declare function
|
|
34
|
+
export declare function getCourtRow(row: CourtRow): CourtPosition[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getCourtRow = exports.isBackRow = exports.isFrontRow = exports.rotatePosition = exports.getPositions = exports.CourtTarget = exports.CourtPosition = exports.CourtRow = void 0;
|
|
4
4
|
var CourtRow;
|
|
5
5
|
(function (CourtRow) {
|
|
6
6
|
CourtRow["BACK"] = "BACK_ROW";
|
|
@@ -62,9 +62,9 @@ function isBackRow(position) {
|
|
|
62
62
|
return BACK_ROW.includes(position);
|
|
63
63
|
}
|
|
64
64
|
exports.isBackRow = isBackRow;
|
|
65
|
-
function
|
|
65
|
+
function getCourtRow(row) {
|
|
66
66
|
if (![CourtRow.BACK, CourtRow.FRONT].includes(row))
|
|
67
67
|
throw new Error(`INVALID_ROW: ${row}`);
|
|
68
68
|
return CourtRow.BACK === row ? [...BACK_ROW] : [...FRONT_ROW];
|
|
69
69
|
}
|
|
70
|
-
exports.
|
|
70
|
+
exports.getCourtRow = getCourtRow;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { MatchSet } from './match-set';
|
|
2
2
|
import { Team } from '../team';
|
|
3
3
|
import { MatchTeam } from './match-team';
|
|
4
|
+
import { StatusEnum } from '../../common/status';
|
|
4
5
|
interface MatchParams {
|
|
5
6
|
readonly id: string;
|
|
6
7
|
readonly homeTeam: Team;
|
|
7
8
|
readonly awayTeam: Team;
|
|
8
9
|
readonly scheduledDate: Date;
|
|
9
10
|
readonly sets: MatchSet[];
|
|
10
|
-
readonly
|
|
11
|
+
readonly status: StatusEnum;
|
|
11
12
|
}
|
|
12
13
|
export declare enum MatchScore {
|
|
13
14
|
'3-0' = "3-0",
|
|
@@ -24,13 +25,14 @@ export declare class Match {
|
|
|
24
25
|
readonly awayTeam: Team;
|
|
25
26
|
readonly sets: MatchSet[];
|
|
26
27
|
readonly scheduledDate: Date;
|
|
27
|
-
|
|
28
|
-
constructor({ id, homeTeam, awayTeam, scheduledDate, sets,
|
|
28
|
+
status: StatusEnum;
|
|
29
|
+
constructor({ id, homeTeam, awayTeam, scheduledDate, sets, status }: MatchParams);
|
|
29
30
|
addSet(set: MatchSet): void;
|
|
30
31
|
getTeamSets(team: MatchTeam): number;
|
|
31
32
|
getScore(): MatchScore;
|
|
32
33
|
isOver(): boolean;
|
|
33
34
|
getWinner(): Team;
|
|
34
35
|
isWinner(team: MatchTeam): boolean;
|
|
36
|
+
isSimulated(): boolean;
|
|
35
37
|
}
|
|
36
38
|
export {};
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Match = exports.MatchScore = void 0;
|
|
4
4
|
const utils_1 = require("../utils");
|
|
5
5
|
const match_team_1 = require("./match-team");
|
|
6
|
+
const status_1 = require("../../common/status");
|
|
6
7
|
var MatchScore;
|
|
7
8
|
(function (MatchScore) {
|
|
8
9
|
MatchScore["3-0"] = "3-0";
|
|
@@ -13,14 +14,14 @@ var MatchScore;
|
|
|
13
14
|
MatchScore["0-3"] = "0-3";
|
|
14
15
|
})(MatchScore = exports.MatchScore || (exports.MatchScore = {}));
|
|
15
16
|
class Match {
|
|
16
|
-
constructor({ id, homeTeam, awayTeam, scheduledDate, sets,
|
|
17
|
+
constructor({ id, homeTeam, awayTeam, scheduledDate, sets, status }) {
|
|
17
18
|
(0, utils_1.validateUUID)(id);
|
|
18
19
|
this.id = id;
|
|
19
20
|
this.homeTeam = homeTeam;
|
|
20
21
|
this.awayTeam = awayTeam;
|
|
21
22
|
this.scheduledDate = scheduledDate;
|
|
22
23
|
this.sets = sets;
|
|
23
|
-
this.
|
|
24
|
+
this.status = status;
|
|
24
25
|
}
|
|
25
26
|
addSet(set) {
|
|
26
27
|
if (this.sets.length >= Match.BEST_OF)
|
|
@@ -56,6 +57,9 @@ class Match {
|
|
|
56
57
|
else
|
|
57
58
|
return team === match_team_1.MatchTeam.AWAY && this.getWinner() === this.awayTeam;
|
|
58
59
|
}
|
|
60
|
+
isSimulated() {
|
|
61
|
+
return this.status === status_1.StatusEnum.COMPLETE;
|
|
62
|
+
}
|
|
59
63
|
}
|
|
60
64
|
exports.Match = Match;
|
|
61
65
|
Match.BEST_OF = 5;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { EnumDataType } from 'sequelize';
|
|
2
|
+
export declare enum StatusEnum {
|
|
3
|
+
PENDING = "PENDING",
|
|
4
|
+
IN_PROGRESS = "IN_PROGRESS",
|
|
5
|
+
COMPLETE = "COMPLETE"
|
|
6
|
+
}
|
|
7
|
+
export type Status = StatusEnum.PENDING | StatusEnum.IN_PROGRESS | StatusEnum.COMPLETE;
|
|
8
|
+
export declare const StatusDataType: EnumDataType<Status>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { DataTypes } from 'sequelize';
|
|
2
|
+
export var StatusEnum;
|
|
3
|
+
(function (StatusEnum) {
|
|
4
|
+
StatusEnum["PENDING"] = "PENDING";
|
|
5
|
+
StatusEnum["IN_PROGRESS"] = "IN_PROGRESS";
|
|
6
|
+
StatusEnum["COMPLETE"] = "COMPLETE";
|
|
7
|
+
})(StatusEnum || (StatusEnum = {}));
|
|
8
|
+
export const StatusDataType = DataTypes.ENUM(...Object.values(StatusEnum));
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import * as Sequelize from 'sequelize';
|
|
2
2
|
import { Model } from 'sequelize';
|
|
3
3
|
import { CompetitionChampionAttributes, CompetitionChampionId, CompetitionChampionModel, CompetitionMatchAttributes, CompetitionMatchId, CompetitionMatchModel, CompetitionTeamsAttributes, CompetitionTeamsId, CompetitionTeamsModel, IterationId, IterationModel, LeagueSeasonAttributes, LeagueSeasonId, LeagueSeasonModel, TeamId, TeamModel } from '.';
|
|
4
|
+
import { Status } from '../../common/status';
|
|
4
5
|
export interface CompetitionAttributes {
|
|
5
6
|
competition_id: string;
|
|
6
7
|
iteration: number;
|
|
8
|
+
status: Status;
|
|
7
9
|
type: CompetitionType;
|
|
8
10
|
LeagueSeason?: LeagueSeasonAttributes;
|
|
9
11
|
CompetitionChampion?: CompetitionChampionAttributes;
|
|
@@ -18,6 +20,7 @@ export declare class CompetitionModel extends Model<CompetitionAttributes, Compe
|
|
|
18
20
|
competition_id: string;
|
|
19
21
|
iteration: number;
|
|
20
22
|
type: CompetitionType;
|
|
23
|
+
status: Status;
|
|
21
24
|
CompetitionChampion: CompetitionChampionModel;
|
|
22
25
|
getCompetitionChampion: Sequelize.HasOneGetAssociationMixin<CompetitionChampionModel>;
|
|
23
26
|
setCompetitionChampion: Sequelize.HasOneSetAssociationMixin<CompetitionChampionModel, CompetitionChampionId>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DataTypes, Model } from 'sequelize';
|
|
2
|
+
import { StatusDataType } from '../../common/status';
|
|
2
3
|
export class CompetitionModel extends Model {
|
|
3
4
|
static initModel(sequelize) {
|
|
4
5
|
return CompetitionModel.init({
|
|
@@ -18,6 +19,11 @@ export class CompetitionModel extends Model {
|
|
|
18
19
|
type: {
|
|
19
20
|
type: DataTypes.ENUM('LEAGUE', 'TOURNAMENT'),
|
|
20
21
|
allowNull: false
|
|
22
|
+
},
|
|
23
|
+
status: {
|
|
24
|
+
type: StatusDataType,
|
|
25
|
+
allowNull: false,
|
|
26
|
+
defaultValue: 'PENDING'
|
|
21
27
|
}
|
|
22
28
|
}, {
|
|
23
29
|
sequelize,
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import * as Sequelize from 'sequelize';
|
|
2
2
|
import { Model } from 'sequelize';
|
|
3
3
|
import { CompetitionMatchId, CompetitionMatchModel, MatchRatingId, MatchRatingModel, MatchSetAttributes, MatchSetId, MatchSetModel, TeamId, TeamModel } from '.';
|
|
4
|
+
import { Status } from '../../common/status';
|
|
4
5
|
export interface MatchAttributes {
|
|
5
6
|
match_id: string;
|
|
6
7
|
home_team: string;
|
|
7
8
|
away_team: string;
|
|
8
9
|
scheduled_date: Date;
|
|
9
|
-
|
|
10
|
+
status: Status;
|
|
10
11
|
MatchSets?: MatchSetAttributes[];
|
|
11
12
|
}
|
|
12
13
|
export type MatchPk = 'match_id';
|
|
@@ -17,7 +18,7 @@ export declare class MatchModel extends Model<MatchAttributes, MatchCreationAttr
|
|
|
17
18
|
home_team: string;
|
|
18
19
|
away_team: string;
|
|
19
20
|
scheduled_date: Date;
|
|
20
|
-
|
|
21
|
+
status: Status;
|
|
21
22
|
CompetitionMatch: CompetitionMatchModel;
|
|
22
23
|
getCompetitionMatch: Sequelize.HasOneGetAssociationMixin<CompetitionMatchModel>;
|
|
23
24
|
setCompetitionMatch: Sequelize.HasOneSetAssociationMixin<CompetitionMatchModel, CompetitionMatchId>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DataTypes, Model } from 'sequelize';
|
|
2
|
+
import { StatusDataType } from '../../common/status';
|
|
2
3
|
export class MatchModel extends Model {
|
|
3
4
|
static initModel(sequelize) {
|
|
4
5
|
return MatchModel.init({
|
|
@@ -27,10 +28,10 @@ export class MatchModel extends Model {
|
|
|
27
28
|
type: DataTypes.DATE,
|
|
28
29
|
allowNull: false
|
|
29
30
|
},
|
|
30
|
-
|
|
31
|
-
type:
|
|
31
|
+
status: {
|
|
32
|
+
type: StatusDataType,
|
|
32
33
|
allowNull: false,
|
|
33
|
-
defaultValue:
|
|
34
|
+
defaultValue: 'PENDING'
|
|
34
35
|
}
|
|
35
36
|
}, {
|
|
36
37
|
sequelize,
|
|
@@ -7,7 +7,7 @@ function transformToAttributes(match) {
|
|
|
7
7
|
away_team: match.awayTeam.id,
|
|
8
8
|
home_team: match.homeTeam.id,
|
|
9
9
|
scheduled_date: match.scheduledDate,
|
|
10
|
-
|
|
10
|
+
status: match.status
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
13
|
function transformToObject(model) {
|
|
@@ -21,7 +21,7 @@ function transformToObject(model) {
|
|
|
21
21
|
awayTeam: transformToTeam(model.AwayTeam),
|
|
22
22
|
scheduledDate: new Date(model.scheduled_date),
|
|
23
23
|
sets,
|
|
24
|
-
|
|
24
|
+
status: model.status
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
27
|
export { transformToObject as transformToMatch, transformToAttributes as transformFromMatch };
|
|
@@ -21,7 +21,8 @@ function transformToAttributes(season, leagueId) {
|
|
|
21
21
|
LeagueSeason: { league_id: leagueId, competition_id: season.id },
|
|
22
22
|
CompetitionChampion: champion,
|
|
23
23
|
CompetitionMatches: matches,
|
|
24
|
-
CompetitionTeams: teams
|
|
24
|
+
CompetitionTeams: teams,
|
|
25
|
+
status: season.status
|
|
25
26
|
};
|
|
26
27
|
}
|
|
27
28
|
function transformToObject(model) {
|
|
@@ -33,7 +34,8 @@ function transformToObject(model) {
|
|
|
33
34
|
matches,
|
|
34
35
|
iteration: transformToIteration(model.Iteration),
|
|
35
36
|
teams: model.Teams != null ? model.Teams.map(transformToTeam) : [],
|
|
36
|
-
champion: model.CompetitionChampion != null ? transformToTeam(model.CompetitionChampion.team) : undefined
|
|
37
|
+
champion: model.CompetitionChampion != null ? transformToTeam(model.CompetitionChampion.team) : undefined,
|
|
38
|
+
status: model.status
|
|
37
39
|
});
|
|
38
40
|
}
|
|
39
41
|
export { transformToObject as transformToSeason, transformToAttributes as transformFromSeason };
|
|
@@ -18,7 +18,8 @@ function transformToAttributes(tournament) {
|
|
|
18
18
|
iteration: tournament.iteration.id,
|
|
19
19
|
CompetitionChampion: champion,
|
|
20
20
|
CompetitionMatches: matches,
|
|
21
|
-
CompetitionTeams: teams
|
|
21
|
+
CompetitionTeams: teams,
|
|
22
|
+
status: tournament.status
|
|
22
23
|
};
|
|
23
24
|
}
|
|
24
25
|
function transformToObject(model) {
|
|
@@ -27,7 +28,8 @@ function transformToObject(model) {
|
|
|
27
28
|
iteration: transformToIteration(model.Iteration),
|
|
28
29
|
matches: model.CompetitionMatches != null ? model.CompetitionMatches.map(transformToTournamentMatch) : [],
|
|
29
30
|
teams: model.Teams != null ? model.Teams.map(transformToTeam) : [],
|
|
30
|
-
champion: model.CompetitionChampion != null ? transformToTeam(model.CompetitionChampion.team) : undefined
|
|
31
|
+
champion: model.CompetitionChampion != null ? transformToTeam(model.CompetitionChampion.team) : undefined,
|
|
32
|
+
status: model.status
|
|
31
33
|
});
|
|
32
34
|
}
|
|
33
35
|
export { transformToObject as transformToTournament, transformToAttributes as transformFromTournament };
|
|
@@ -2,12 +2,14 @@ import { Team } from '../team';
|
|
|
2
2
|
import { Match } from '../match';
|
|
3
3
|
import { Standing } from './standing';
|
|
4
4
|
import { Iteration } from './iteration';
|
|
5
|
+
import { StatusEnum } from '../../common/status';
|
|
5
6
|
interface SeasonOpts {
|
|
6
7
|
readonly id: string;
|
|
7
8
|
readonly teams: Team[];
|
|
8
9
|
readonly matches: Match[];
|
|
9
10
|
readonly iteration: Iteration;
|
|
10
11
|
readonly champion?: Team;
|
|
12
|
+
readonly status: StatusEnum;
|
|
11
13
|
}
|
|
12
14
|
export declare class Season {
|
|
13
15
|
readonly id: string;
|
|
@@ -15,8 +17,9 @@ export declare class Season {
|
|
|
15
17
|
readonly matches: Match[];
|
|
16
18
|
readonly iteration: Iteration;
|
|
17
19
|
readonly standings: Standing[];
|
|
20
|
+
readonly status: StatusEnum;
|
|
18
21
|
champion?: Team;
|
|
19
|
-
constructor({ id, iteration, teams, matches, champion }: SeasonOpts);
|
|
22
|
+
constructor({ id, iteration, teams, matches, champion, status }: SeasonOpts);
|
|
20
23
|
calculateStandings(): Standing[];
|
|
21
24
|
updateStandings(): void;
|
|
22
25
|
}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { Standing } from './standing';
|
|
2
2
|
export class Season {
|
|
3
|
-
constructor({ id, iteration, teams, matches, champion }) {
|
|
3
|
+
constructor({ id, iteration, teams, matches, champion, status }) {
|
|
4
4
|
this.id = id;
|
|
5
5
|
this.teams = teams;
|
|
6
6
|
this.matches = matches;
|
|
7
7
|
this.iteration = iteration;
|
|
8
8
|
this.champion = champion;
|
|
9
9
|
this.standings = this.calculateStandings();
|
|
10
|
+
this.status = status;
|
|
10
11
|
}
|
|
11
12
|
calculateStandings() {
|
|
12
13
|
return this.teams.map(team => {
|
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
import { TournamentMatch } from './tournament-match';
|
|
2
2
|
import { Team } from '../team';
|
|
3
3
|
import { Iteration } from './iteration';
|
|
4
|
+
import { StatusEnum } from '../../common/status';
|
|
4
5
|
interface TournamentOpts {
|
|
5
6
|
readonly id: string;
|
|
6
7
|
readonly iteration: Iteration;
|
|
7
8
|
readonly matches: TournamentMatch[];
|
|
8
9
|
readonly teams: Team[];
|
|
9
10
|
readonly champion?: Team;
|
|
11
|
+
readonly status: StatusEnum;
|
|
10
12
|
}
|
|
11
13
|
export declare class Tournament {
|
|
12
14
|
readonly id: string;
|
|
13
15
|
readonly iteration: Iteration;
|
|
14
16
|
readonly matches: TournamentMatch[];
|
|
15
17
|
readonly teams: Team[];
|
|
18
|
+
readonly status: StatusEnum;
|
|
16
19
|
champion?: Team;
|
|
17
|
-
constructor({ id, iteration, matches, teams, champion }: TournamentOpts);
|
|
20
|
+
constructor({ id, iteration, matches, teams, champion, status }: TournamentOpts);
|
|
18
21
|
static sortMatchesFn(m1: TournamentMatch, m2: TournamentMatch): number;
|
|
19
22
|
}
|
|
20
23
|
export {};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
export class Tournament {
|
|
2
|
-
constructor({ id, iteration, matches, teams, champion }) {
|
|
2
|
+
constructor({ id, iteration, matches, teams, champion, status }) {
|
|
3
3
|
this.id = id;
|
|
4
4
|
this.iteration = iteration;
|
|
5
5
|
this.matches = matches;
|
|
6
6
|
this.teams = teams;
|
|
7
7
|
this.champion = champion;
|
|
8
|
+
this.status = status;
|
|
8
9
|
this.matches.sort(Tournament.sortMatchesFn);
|
|
9
10
|
}
|
|
10
11
|
static sortMatchesFn(m1, m2) {
|
|
@@ -31,4 +31,4 @@ export declare function getPositions(): CourtPosition[];
|
|
|
31
31
|
export declare function rotatePosition(position: number): CourtPosition;
|
|
32
32
|
export declare function isFrontRow(position: number): boolean;
|
|
33
33
|
export declare function isBackRow(position: number): boolean;
|
|
34
|
-
export declare function
|
|
34
|
+
export declare function getCourtRow(row: CourtRow): CourtPosition[];
|
|
@@ -55,7 +55,7 @@ export function isBackRow(position) {
|
|
|
55
55
|
throw new Error(`POSITION_INDEX_OUT_OF_BOUNDS: ${position}`);
|
|
56
56
|
return BACK_ROW.includes(position);
|
|
57
57
|
}
|
|
58
|
-
export function
|
|
58
|
+
export function getCourtRow(row) {
|
|
59
59
|
if (![CourtRow.BACK, CourtRow.FRONT].includes(row))
|
|
60
60
|
throw new Error(`INVALID_ROW: ${row}`);
|
|
61
61
|
return CourtRow.BACK === row ? [...BACK_ROW] : [...FRONT_ROW];
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { MatchSet } from './match-set';
|
|
2
2
|
import { Team } from '../team';
|
|
3
3
|
import { MatchTeam } from './match-team';
|
|
4
|
+
import { StatusEnum } from '../../common/status';
|
|
4
5
|
interface MatchParams {
|
|
5
6
|
readonly id: string;
|
|
6
7
|
readonly homeTeam: Team;
|
|
7
8
|
readonly awayTeam: Team;
|
|
8
9
|
readonly scheduledDate: Date;
|
|
9
10
|
readonly sets: MatchSet[];
|
|
10
|
-
readonly
|
|
11
|
+
readonly status: StatusEnum;
|
|
11
12
|
}
|
|
12
13
|
export declare enum MatchScore {
|
|
13
14
|
'3-0' = "3-0",
|
|
@@ -24,13 +25,14 @@ export declare class Match {
|
|
|
24
25
|
readonly awayTeam: Team;
|
|
25
26
|
readonly sets: MatchSet[];
|
|
26
27
|
readonly scheduledDate: Date;
|
|
27
|
-
|
|
28
|
-
constructor({ id, homeTeam, awayTeam, scheduledDate, sets,
|
|
28
|
+
status: StatusEnum;
|
|
29
|
+
constructor({ id, homeTeam, awayTeam, scheduledDate, sets, status }: MatchParams);
|
|
29
30
|
addSet(set: MatchSet): void;
|
|
30
31
|
getTeamSets(team: MatchTeam): number;
|
|
31
32
|
getScore(): MatchScore;
|
|
32
33
|
isOver(): boolean;
|
|
33
34
|
getWinner(): Team;
|
|
34
35
|
isWinner(team: MatchTeam): boolean;
|
|
36
|
+
isSimulated(): boolean;
|
|
35
37
|
}
|
|
36
38
|
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { validateUUID } from '../utils';
|
|
2
2
|
import { MatchTeam } from './match-team';
|
|
3
|
+
import { StatusEnum } from '../../common/status';
|
|
3
4
|
export var MatchScore;
|
|
4
5
|
(function (MatchScore) {
|
|
5
6
|
MatchScore["3-0"] = "3-0";
|
|
@@ -10,14 +11,14 @@ export var MatchScore;
|
|
|
10
11
|
MatchScore["0-3"] = "0-3";
|
|
11
12
|
})(MatchScore || (MatchScore = {}));
|
|
12
13
|
export class Match {
|
|
13
|
-
constructor({ id, homeTeam, awayTeam, scheduledDate, sets,
|
|
14
|
+
constructor({ id, homeTeam, awayTeam, scheduledDate, sets, status }) {
|
|
14
15
|
validateUUID(id);
|
|
15
16
|
this.id = id;
|
|
16
17
|
this.homeTeam = homeTeam;
|
|
17
18
|
this.awayTeam = awayTeam;
|
|
18
19
|
this.scheduledDate = scheduledDate;
|
|
19
20
|
this.sets = sets;
|
|
20
|
-
this.
|
|
21
|
+
this.status = status;
|
|
21
22
|
}
|
|
22
23
|
addSet(set) {
|
|
23
24
|
if (this.sets.length >= Match.BEST_OF)
|
|
@@ -53,5 +54,8 @@ export class Match {
|
|
|
53
54
|
else
|
|
54
55
|
return team === MatchTeam.AWAY && this.getWinner() === this.awayTeam;
|
|
55
56
|
}
|
|
57
|
+
isSimulated() {
|
|
58
|
+
return this.status === StatusEnum.COMPLETE;
|
|
59
|
+
}
|
|
56
60
|
}
|
|
57
61
|
Match.BEST_OF = 5;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "volleyballsimtypes",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.148",
|
|
4
4
|
"description": "vbsim types",
|
|
5
5
|
"main": "./dist/cjs/src/index.js",
|
|
6
6
|
"module": "./dist/esm/src/index.js",
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
"clean": "rimraf dist",
|
|
14
14
|
"validate": "npm run standard && npm run madge",
|
|
15
15
|
"build": "tsc -p tsconfig.json && tsc -p tsconfig-cjs.json",
|
|
16
|
-
"preversion": "npm run clean && npm run validate && npm run build &&
|
|
17
|
-
"postversion": "git push --follow-tags"
|
|
16
|
+
"preversion": "npm run clean && npm run validate && npm run build && git commit -a --amend --no-edit",
|
|
17
|
+
"postversion": "git push --follow-tags && npm publish"
|
|
18
18
|
},
|
|
19
19
|
"author": "Francisco Farias <fariasfranciscoe@gmail.com>",
|
|
20
20
|
"license": "ISC",
|