volleyballsimtypes 0.0.377 → 0.0.379

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/dist/cjs/src/api/index.d.ts +8 -1
  2. package/dist/cjs/src/data/init-models.js +8 -0
  3. package/dist/cjs/src/data/models/competition-match.d.ts +2 -0
  4. package/dist/cjs/src/data/models/competition-match.js +4 -0
  5. package/dist/cjs/src/data/models/competition.d.ts +7 -2
  6. package/dist/cjs/src/data/models/competition.js +4 -1
  7. package/dist/cjs/src/data/models/index.d.ts +1 -0
  8. package/dist/cjs/src/data/models/index.js +1 -0
  9. package/dist/cjs/src/data/models/national-country.d.ts +29 -0
  10. package/dist/cjs/src/data/models/national-country.js +51 -0
  11. package/dist/cjs/src/data/transformers/index.d.ts +2 -0
  12. package/dist/cjs/src/data/transformers/index.js +2 -0
  13. package/dist/cjs/src/data/transformers/national-match.d.ts +5 -0
  14. package/dist/cjs/src/data/transformers/national-match.js +24 -0
  15. package/dist/cjs/src/data/transformers/national.d.ts +5 -0
  16. package/dist/cjs/src/data/transformers/national.js +60 -0
  17. package/dist/cjs/src/service/competition/index.d.ts +2 -0
  18. package/dist/cjs/src/service/competition/index.js +2 -0
  19. package/dist/cjs/src/service/competition/national-match.d.ts +10 -0
  20. package/dist/cjs/src/service/competition/national-match.js +32 -0
  21. package/dist/cjs/src/service/competition/national.d.ts +18 -0
  22. package/dist/cjs/src/service/competition/national.js +36 -0
  23. package/dist/cjs/src/service/competition/schemas/national-match.z.d.ts +10 -0
  24. package/dist/cjs/src/service/competition/schemas/national-match.z.js +17 -0
  25. package/dist/cjs/src/service/competition/schemas/national.z.d.ts +20 -0
  26. package/dist/cjs/src/service/competition/schemas/national.z.js +32 -0
  27. package/dist/cjs/src/service/match/match-rating.d.ts +1 -0
  28. package/dist/cjs/src/service/match/match-rating.js +4 -0
  29. package/dist/cjs/src/service/match/schemas/match-rating.z.d.ts +8 -0
  30. package/dist/cjs/src/service/match/schemas/match-rating.z.js +5 -0
  31. package/dist/esm/src/api/index.d.ts +8 -1
  32. package/dist/esm/src/data/init-models.js +9 -1
  33. package/dist/esm/src/data/models/competition-match.d.ts +2 -0
  34. package/dist/esm/src/data/models/competition-match.js +4 -0
  35. package/dist/esm/src/data/models/competition.d.ts +7 -2
  36. package/dist/esm/src/data/models/competition.js +5 -2
  37. package/dist/esm/src/data/models/index.d.ts +1 -0
  38. package/dist/esm/src/data/models/index.js +1 -0
  39. package/dist/esm/src/data/models/national-country.d.ts +29 -0
  40. package/dist/esm/src/data/models/national-country.js +47 -0
  41. package/dist/esm/src/data/transformers/index.d.ts +2 -0
  42. package/dist/esm/src/data/transformers/index.js +2 -0
  43. package/dist/esm/src/data/transformers/national-match.d.ts +5 -0
  44. package/dist/esm/src/data/transformers/national-match.js +21 -0
  45. package/dist/esm/src/data/transformers/national.d.ts +5 -0
  46. package/dist/esm/src/data/transformers/national.js +57 -0
  47. package/dist/esm/src/service/competition/index.d.ts +2 -0
  48. package/dist/esm/src/service/competition/index.js +2 -0
  49. package/dist/esm/src/service/competition/national-match.d.ts +10 -0
  50. package/dist/esm/src/service/competition/national-match.js +28 -0
  51. package/dist/esm/src/service/competition/national.d.ts +18 -0
  52. package/dist/esm/src/service/competition/national.js +32 -0
  53. package/dist/esm/src/service/competition/schemas/national-match.z.d.ts +10 -0
  54. package/dist/esm/src/service/competition/schemas/national-match.z.js +14 -0
  55. package/dist/esm/src/service/competition/schemas/national.z.d.ts +20 -0
  56. package/dist/esm/src/service/competition/schemas/national.z.js +29 -0
  57. package/dist/esm/src/service/match/match-rating.d.ts +1 -0
  58. package/dist/esm/src/service/match/match-rating.js +4 -0
  59. package/dist/esm/src/service/match/schemas/match-rating.z.d.ts +8 -0
  60. package/dist/esm/src/service/match/schemas/match-rating.z.js +5 -0
  61. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import { BoxScore, DataProps, DeclineStatus, Division as _Division, League as _League, Match as _Match, MatchSet as _MatchSet, Player as _Player, PlayerPosition, Qualifier as _Qualifier, QualifierMatch as _QualifierMatch, Rally as _Rally, RallyEvent as _RallyEvent, Season as _Season, Standing as _Standing, Team as _Team, Tournament as _Tournament, TournamentMatch as _TournamentMatch, Country as _Country, CourtPosition } from '../service';
1
+ import { BoxScore, DataProps, DeclineStatus, Division as _Division, League as _League, Match as _Match, MatchSet as _MatchSet, Player as _Player, PlayerPosition, Qualifier as _Qualifier, QualifierMatch as _QualifierMatch, Rally as _Rally, RallyEvent as _RallyEvent, Season as _Season, Standing as _Standing, Team as _Team, Tournament as _Tournament, TournamentMatch as _TournamentMatch, National as _National, NationalMatch as _NationalMatch, Country as _Country, CourtPosition } from '../service';
2
2
  export type Rally = DataProps<_Rally> & {
3
3
  homePlayerPosition: PlayerPosition[];
4
4
  awayPlayerPosition: PlayerPosition[];
@@ -24,6 +24,7 @@ export type Match = Omit<DataProps<_Match>, 'sets' | 'homeTeam' | 'awayTeam' | '
24
24
  season?: Season;
25
25
  tournament?: Tournament;
26
26
  qualifier?: Qualifier;
27
+ national?: National;
27
28
  results?: Results;
28
29
  };
29
30
  export type RallyEvent = DataProps<_RallyEvent> & {
@@ -100,6 +101,12 @@ export type QualifierMatch = Omit<DataProps<_QualifierMatch>, 'match'> & {
100
101
  export type Qualifier = Omit<DataProps<_Qualifier>, 'matches'> & {
101
102
  matches: QualifierMatch[];
102
103
  };
104
+ export type NationalMatch = Omit<DataProps<_NationalMatch>, 'match'> & {
105
+ match: Match;
106
+ };
107
+ export type National = Omit<DataProps<_National>, 'matches' | 'teamsByTier'> & {
108
+ matches: NationalMatch[];
109
+ };
103
110
  export interface VPER {
104
111
  playerId: string;
105
112
  value: number;
@@ -44,6 +44,7 @@ function initModels(sequelize) {
44
44
  const Rally = models_1.RallyModel.initModel(sequelize);
45
45
  const PromotionMatch = models_1.PromotionMatchModel.initModel(sequelize);
46
46
  const RegionQualifier = models_1.RegionQualifierModel.initModel(sequelize);
47
+ const NationalCountry = models_1.NationalCountryModel.initModel(sequelize);
47
48
  const Team = models_1.TeamModel.initModel(sequelize);
48
49
  const TeamReplacement = models_1.TeamReplacementModel.initModel(sequelize);
49
50
  const VPER = models_1.VPERModel.initModel(sequelize);
@@ -182,6 +183,12 @@ function initModels(sequelize) {
182
183
  RegionQualifier.belongsTo(Country, { as: 'countryRegion', foreignKey: 'region_code', targetKey: 'region_code' });
183
184
  RegionQualifier.belongsTo(Competition, { as: 'competition', foreignKey: 'competition_id' });
184
185
  Competition.hasOne(RegionQualifier, { as: 'RegionQualifier', foreignKey: 'competition_id' });
186
+ NationalCountry.belongsTo(Iteration, { as: 'Iteration', foreignKey: 'iteration' });
187
+ NationalCountry.belongsTo(Country, { as: 'country', foreignKey: 'country_id' });
188
+ NationalCountry.belongsTo(Competition, { as: 'competition', foreignKey: 'competition_id' });
189
+ Competition.hasOne(NationalCountry, { as: 'NationalCountry', foreignKey: 'competition_id' });
190
+ Country.hasMany(NationalCountry, { as: 'NationalCountries', foreignKey: 'country_id' });
191
+ Iteration.hasMany(NationalCountry, { as: 'NationalCountries', foreignKey: 'iteration' });
185
192
  VPER.belongsTo(Player, { as: 'Player', foreignKey: 'player_id' });
186
193
  VPER.belongsTo(Match, { as: 'Match', foreignKey: 'match_id' });
187
194
  Team.hasOne(Coach, { as: 'Coach', foreignKey: 'team_id' });
@@ -250,6 +257,7 @@ function initModels(sequelize) {
250
257
  PlayerImprovementLog,
251
258
  PromotionMatch,
252
259
  RegionQualifier,
260
+ NationalCountry,
253
261
  Rally,
254
262
  Team,
255
263
  TeamReplacement,
@@ -6,6 +6,7 @@ export interface CompetitionMatchAttributes {
6
6
  match_id: string;
7
7
  index: number;
8
8
  stage: CompetitionStage;
9
+ round?: number | null;
9
10
  Match?: MatchAttributes;
10
11
  }
11
12
  export type CompetitionMatchPk = 'match_id';
@@ -17,6 +18,7 @@ export declare class CompetitionMatchModel extends Model<CompetitionMatchAttribu
17
18
  match_id: string;
18
19
  index: number;
19
20
  stage: CompetitionStage;
21
+ round: number | null;
20
22
  Competition: CompetitionModel;
21
23
  getCompetition: Sequelize.BelongsToGetAssociationMixin<CompetitionModel>;
22
24
  setCompetition: Sequelize.BelongsToSetAssociationMixin<CompetitionModel, CompetitionId>;
@@ -29,6 +29,10 @@ class CompetitionMatchModel extends sequelize_1.Model {
29
29
  stage: {
30
30
  type: sequelize_1.DataTypes.ENUM('FINAL', 'LEAGUE', 'QUARTERFINALS', 'ROUND_OF_8', 'THIRD_PLACE', 'SEMIFINALS', 'ROUND_OF_16', 'ROUND_OF_32', 'ROUND_OF_64', 'ROUND_OF_128', 'ROUND_OF_256'),
31
31
  allowNull: false
32
+ },
33
+ round: {
34
+ type: sequelize_1.DataTypes.INTEGER,
35
+ allowNull: true
32
36
  }
33
37
  }, {
34
38
  sequelize,
@@ -1,6 +1,6 @@
1
1
  import * as Sequelize from 'sequelize';
2
2
  import { Model } from 'sequelize';
3
- import { CompetitionChampionAttributes, CompetitionChampionId, CompetitionChampionModel, CompetitionMVPAttributes, CompetitionMVPId, CompetitionMVPModel, CompetitionMatchAttributes, CompetitionMatchId, CompetitionMatchModel, CompetitionStandingsAttributes, CompetitionStandingsId, CompetitionStandingsModel, CompetitionTeamsAttributes, CompetitionTeamsId, CompetitionTeamsModel, PromotionMatchAttributes, PromotionMatchId, PromotionMatchModel, RegionQualifierAttributes, RegionQualifierId, RegionQualifierModel, DivisionSeasonAttributes, DivisionSeasonId, DivisionSeasonModel, IterationId, IterationModel, TeamId, TeamModel } from '.';
3
+ import { CompetitionChampionAttributes, CompetitionChampionId, CompetitionChampionModel, CompetitionMVPAttributes, CompetitionMVPId, CompetitionMVPModel, CompetitionMatchAttributes, CompetitionMatchId, CompetitionMatchModel, CompetitionStandingsAttributes, CompetitionStandingsId, CompetitionStandingsModel, CompetitionTeamsAttributes, CompetitionTeamsId, CompetitionTeamsModel, PromotionMatchAttributes, PromotionMatchId, PromotionMatchModel, RegionQualifierAttributes, RegionQualifierId, RegionQualifierModel, NationalCountryAttributes, NationalCountryId, NationalCountryModel, DivisionSeasonAttributes, DivisionSeasonId, DivisionSeasonModel, IterationId, IterationModel, TeamId, TeamModel } from '.';
4
4
  import { Status } from '../common';
5
5
  export interface CompetitionAttributes {
6
6
  competition_id: string;
@@ -14,11 +14,12 @@ export interface CompetitionAttributes {
14
14
  CompetitionStandings?: CompetitionStandingsAttributes[];
15
15
  CompetitionTeams?: CompetitionTeamsAttributes[];
16
16
  RegionQualifier?: RegionQualifierAttributes;
17
+ NationalCountry?: NationalCountryAttributes;
17
18
  UpperPromotionMatches?: PromotionMatchAttributes[];
18
19
  LowerPromotionMatches?: PromotionMatchAttributes[];
19
20
  }
20
21
  export type CompetitionPk = 'competition_id';
21
- export type CompetitionType = 'LEAGUE' | 'TOURNAMENT' | 'QUALIFIER';
22
+ export type CompetitionType = 'LEAGUE' | 'TOURNAMENT' | 'QUALIFIER' | 'NATIONAL';
22
23
  export type CompetitionId = CompetitionModel[CompetitionPk];
23
24
  export type CompetitionCreationAttributes = CompetitionAttributes;
24
25
  export declare class CompetitionModel extends Model<CompetitionAttributes, CompetitionCreationAttributes> implements CompetitionAttributes {
@@ -67,6 +68,10 @@ export declare class CompetitionModel extends Model<CompetitionAttributes, Compe
67
68
  getRegionQualifier: Sequelize.HasOneGetAssociationMixin<RegionQualifierModel>;
68
69
  setRegionQualifier: Sequelize.HasOneSetAssociationMixin<RegionQualifierModel, RegionQualifierId>;
69
70
  createRegionQualifier: Sequelize.HasOneCreateAssociationMixin<RegionQualifierModel>;
71
+ NationalCountry: NationalCountryModel;
72
+ getNationalCountry: Sequelize.HasOneGetAssociationMixin<NationalCountryModel>;
73
+ setNationalCountry: Sequelize.HasOneSetAssociationMixin<NationalCountryModel, NationalCountryId>;
74
+ createNationalCountry: Sequelize.HasOneCreateAssociationMixin<NationalCountryModel>;
70
75
  UpperPromotionMatches: PromotionMatchModel[];
71
76
  getUpperPromotionMatches: Sequelize.HasManyGetAssociationsMixin<PromotionMatchModel>;
72
77
  setUpperPromotionMatches: Sequelize.HasManySetAssociationsMixin<PromotionMatchModel, PromotionMatchId>;
@@ -21,7 +21,7 @@ class CompetitionModel extends sequelize_1.Model {
21
21
  }
22
22
  },
23
23
  type: {
24
- type: sequelize_1.DataTypes.ENUM('LEAGUE', 'TOURNAMENT', 'QUALIFIER'),
24
+ type: sequelize_1.DataTypes.ENUM('LEAGUE', 'TOURNAMENT', 'QUALIFIER', 'NATIONAL'),
25
25
  allowNull: false
26
26
  },
27
27
  status: {
@@ -44,6 +44,9 @@ class CompetitionModel extends sequelize_1.Model {
44
44
  }, {
45
45
  model: _1.RegionQualifierModel,
46
46
  as: 'RegionQualifier'
47
+ }, {
48
+ model: _1.NationalCountryModel,
49
+ as: 'NationalCountry'
47
50
  }]
48
51
  },
49
52
  indexes: [{
@@ -27,6 +27,7 @@ export * from './retired-player';
27
27
  export * from './rally';
28
28
  export * from './promotion-match';
29
29
  export * from './region-qualifier';
30
+ export * from './national-country';
30
31
  export * from './coach';
31
32
  export * from './team';
32
33
  export * from './team-replacement';
@@ -43,6 +43,7 @@ __exportStar(require("./retired-player"), exports);
43
43
  __exportStar(require("./rally"), exports);
44
44
  __exportStar(require("./promotion-match"), exports);
45
45
  __exportStar(require("./region-qualifier"), exports);
46
+ __exportStar(require("./national-country"), exports);
46
47
  __exportStar(require("./coach"), exports);
47
48
  __exportStar(require("./team"), exports);
48
49
  __exportStar(require("./team-replacement"), exports);
@@ -0,0 +1,29 @@
1
+ import * as Sequelize from 'sequelize';
2
+ import { Model } from 'sequelize';
3
+ import { CompetitionId, CompetitionModel, CountryId, CountryModel, IterationId, IterationModel } from '.';
4
+ export interface NationalCountryAttributes {
5
+ competition_id: string;
6
+ country_id: string;
7
+ iteration: number;
8
+ }
9
+ export type NationalCountryPk = 'country_id' | 'iteration';
10
+ export type NationalCountryId = NationalCountryModel[NationalCountryPk];
11
+ export type NationalCountryCreationAttributes = NationalCountryAttributes;
12
+ export declare class NationalCountryModel extends Model<NationalCountryAttributes, NationalCountryCreationAttributes> implements NationalCountryAttributes {
13
+ competition_id: string;
14
+ country_id: string;
15
+ iteration: number;
16
+ Iteration: IterationModel;
17
+ getIteration: Sequelize.BelongsToGetAssociationMixin<IterationModel>;
18
+ setIteration: Sequelize.BelongsToSetAssociationMixin<IterationModel, IterationId>;
19
+ createIteration: Sequelize.BelongsToCreateAssociationMixin<IterationModel>;
20
+ competition: CompetitionModel;
21
+ getCompetition: Sequelize.BelongsToGetAssociationMixin<CompetitionModel>;
22
+ setCompetition: Sequelize.BelongsToSetAssociationMixin<CompetitionModel, CompetitionId>;
23
+ createCompetition: Sequelize.BelongsToCreateAssociationMixin<CompetitionModel>;
24
+ country: CountryModel;
25
+ getCountry: Sequelize.BelongsToGetAssociationMixin<CountryModel>;
26
+ setCountry: Sequelize.BelongsToSetAssociationMixin<CountryModel, CountryId>;
27
+ createCountry: Sequelize.BelongsToCreateAssociationMixin<CountryModel>;
28
+ static initModel(sequelize: Sequelize.Sequelize): typeof NationalCountryModel;
29
+ }
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NationalCountryModel = void 0;
4
+ const sequelize_1 = require("sequelize");
5
+ class NationalCountryModel extends sequelize_1.Model {
6
+ static initModel(sequelize) {
7
+ return NationalCountryModel.init({
8
+ country_id: {
9
+ type: sequelize_1.DataTypes.UUID,
10
+ allowNull: false,
11
+ primaryKey: true,
12
+ references: {
13
+ model: 'Country',
14
+ key: 'country_id'
15
+ }
16
+ },
17
+ iteration: {
18
+ type: sequelize_1.DataTypes.INTEGER,
19
+ allowNull: false,
20
+ primaryKey: true,
21
+ references: {
22
+ model: 'Iteration',
23
+ key: 'iteration_id'
24
+ }
25
+ },
26
+ competition_id: {
27
+ type: sequelize_1.DataTypes.UUID,
28
+ allowNull: false,
29
+ references: {
30
+ model: 'Competition',
31
+ key: 'competition_id'
32
+ }
33
+ }
34
+ }, {
35
+ sequelize,
36
+ tableName: 'NationalCountry',
37
+ schema: 'public',
38
+ timestamps: false,
39
+ indexes: [{
40
+ name: 'nationalcountry_pk',
41
+ unique: true,
42
+ fields: [{ name: 'country_id' }, { name: 'iteration' }]
43
+ }, {
44
+ name: 'nationalcountry_competition_uq',
45
+ unique: true,
46
+ fields: [{ name: 'competition_id' }]
47
+ }]
48
+ });
49
+ }
50
+ }
51
+ exports.NationalCountryModel = NationalCountryModel;
@@ -22,6 +22,8 @@ export * from './competition-team-order';
22
22
  export * from './region-qualifier';
23
23
  export * from './qualifier';
24
24
  export * from './qualifier-match';
25
+ export * from './national';
26
+ export * from './national-match';
25
27
  export * from './team';
26
28
  export * from './tactics';
27
29
  export * from './vper';
@@ -38,6 +38,8 @@ __exportStar(require("./competition-team-order"), exports);
38
38
  __exportStar(require("./region-qualifier"), exports);
39
39
  __exportStar(require("./qualifier"), exports);
40
40
  __exportStar(require("./qualifier-match"), exports);
41
+ __exportStar(require("./national"), exports);
42
+ __exportStar(require("./national-match"), exports);
41
43
  __exportStar(require("./team"), exports);
42
44
  __exportStar(require("./tactics"), exports);
43
45
  __exportStar(require("./vper"), exports);
@@ -0,0 +1,5 @@
1
+ import { NationalMatch } from '../../service';
2
+ import { CompetitionMatchAttributes, CompetitionMatchModel } from '../models';
3
+ declare function transformToAttributes(nationalMatch: NationalMatch, nationalId: string): CompetitionMatchAttributes;
4
+ declare function transformToObject(model: CompetitionMatchModel): NationalMatch;
5
+ export { transformToObject as transformToNationalMatch, transformToAttributes as transformFromNationalMatch };
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.transformToNationalMatch = transformToObject;
4
+ exports.transformFromNationalMatch = transformToAttributes;
5
+ const service_1 = require("../../service");
6
+ const _1 = require(".");
7
+ function transformToAttributes(nationalMatch, nationalId) {
8
+ return {
9
+ competition_id: nationalId,
10
+ match_id: nationalMatch.match.id,
11
+ index: nationalMatch.index,
12
+ stage: (0, _1.transformFromStage)(nationalMatch.stage),
13
+ round: nationalMatch.round,
14
+ Match: (0, _1.transformFromMatch)(nationalMatch.match)
15
+ };
16
+ }
17
+ function transformToObject(model) {
18
+ return service_1.NationalMatch.create({
19
+ round: model.round ?? 1,
20
+ stage: (0, _1.transformToStage)(model.stage),
21
+ match: (0, _1.transformToMatch)(model.Match),
22
+ index: model.index
23
+ });
24
+ }
@@ -0,0 +1,5 @@
1
+ import { CompetitionAttributes, CompetitionModel } from '../models';
2
+ import { National } from '../../service';
3
+ declare function transformToAttributes(national: National): CompetitionAttributes;
4
+ declare function transformToObject(model: CompetitionModel): National;
5
+ export { transformToObject as transformToNational, transformToAttributes as transformFromNational };
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.transformToNational = transformToObject;
4
+ exports.transformFromNational = transformToAttributes;
5
+ const _1 = require(".");
6
+ const service_1 = require("../../service");
7
+ function transformToAttributes(national) {
8
+ const CompetitionMatches = national.matches.map((match) => (0, _1.transformFromNationalMatch)(match, national.id));
9
+ const CompetitionTeams = national.teams.map((team, index) => ({
10
+ competition_id: national.id,
11
+ team_id: team.id,
12
+ index
13
+ }));
14
+ const NationalCountry = {
15
+ competition_id: national.id,
16
+ country_id: national.country.id,
17
+ iteration: national.iteration.id
18
+ };
19
+ const CompetitionChampion = (national.champion != null)
20
+ ? {
21
+ competition_id: national.id,
22
+ team_id: national.champion.id
23
+ }
24
+ : undefined;
25
+ return {
26
+ competition_id: national.id,
27
+ type: 'NATIONAL',
28
+ iteration: national.iteration.id,
29
+ status: national.status,
30
+ CompetitionMatches,
31
+ CompetitionTeams,
32
+ CompetitionChampion,
33
+ NationalCountry
34
+ };
35
+ }
36
+ function transformToObject(model) {
37
+ const teamModels = (0, _1.sortTeamsByCompetitionIndex)(model.Teams ?? []);
38
+ const teamsByTier = new Map();
39
+ for (const teamModel of teamModels) {
40
+ const tier = teamModel.Division?.tier ?? 1;
41
+ const bucket = teamsByTier.get(tier) ?? [];
42
+ bucket.push((0, _1.transformToTeam)(teamModel));
43
+ teamsByTier.set(tier, bucket);
44
+ }
45
+ const countryModel = model.NationalCountry?.country ?? teamModels[0]?.country;
46
+ if (countryModel == null)
47
+ throw new Error(`MISSING_NATIONAL_COUNTRY competition=${model.competition_id}`);
48
+ const champion = model.CompetitionChampion?.team != null
49
+ ? (0, _1.transformToTeam)(model.CompetitionChampion.team)
50
+ : undefined;
51
+ return service_1.National.create({
52
+ id: model.competition_id,
53
+ iteration: (0, _1.transformToIteration)(model.Iteration),
54
+ country: (0, _1.transformToCountry)(countryModel),
55
+ matches: (model.CompetitionMatches ?? []).map(_1.transformToNationalMatch),
56
+ teamsByTier,
57
+ status: model.status,
58
+ champion
59
+ });
60
+ }
@@ -9,3 +9,5 @@ export * from './promotion-match';
9
9
  export * from './stage';
10
10
  export * from './qualifier-match';
11
11
  export * from './qualifier';
12
+ export * from './national-match';
13
+ export * from './national';
@@ -25,3 +25,5 @@ __exportStar(require("./promotion-match"), exports);
25
25
  __exportStar(require("./stage"), exports);
26
26
  __exportStar(require("./qualifier-match"), exports);
27
27
  __exportStar(require("./qualifier"), exports);
28
+ __exportStar(require("./national-match"), exports);
29
+ __exportStar(require("./national"), exports);
@@ -0,0 +1,10 @@
1
+ import { Match } from '../match';
2
+ import { Stage } from './stage';
3
+ export declare class NationalMatch {
4
+ readonly round: number;
5
+ readonly stage: Stage;
6
+ readonly match: Match;
7
+ readonly index: number;
8
+ static create(input: unknown): NationalMatch;
9
+ private constructor();
10
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NationalMatch = void 0;
4
+ const stage_1 = require("./stage");
5
+ const national_match_z_1 = require("./schemas/national-match.z");
6
+ class NationalMatch {
7
+ static create(input) {
8
+ const result = national_match_z_1.NationalMatchInputSchema.safeParse(input);
9
+ if (!result.success) {
10
+ throw new Error(`INVALID_NATIONAL_MATCH: ${result.error.message}. RECEIVED=${(() => { try {
11
+ return JSON.stringify(input);
12
+ }
13
+ catch {
14
+ return String(input);
15
+ } })()}`);
16
+ }
17
+ return new NationalMatch(result.data);
18
+ }
19
+ constructor({ round, stage, match, index }) {
20
+ if (round < 1)
21
+ throw new Error(`INVALID_ROUND: ${round}`);
22
+ if (index < 0)
23
+ throw new Error('INDEX_OUT_OF_BOUNDS');
24
+ if (stage_1.Stage.LEAGUE === stage)
25
+ throw new Error(`INVALID_STAGE: ${stage}`);
26
+ this.round = round;
27
+ this.stage = stage;
28
+ this.match = match;
29
+ this.index = index;
30
+ }
31
+ }
32
+ exports.NationalMatch = NationalMatch;
@@ -0,0 +1,18 @@
1
+ import { NationalMatch } from './national-match';
2
+ import { Team } from '../team';
3
+ import { Iteration } from './iteration';
4
+ import { Country } from '../country';
5
+ import { StatusEnum } from '../../data';
6
+ export declare class National {
7
+ readonly id: string;
8
+ readonly iteration: Iteration;
9
+ readonly country: Country;
10
+ readonly matches: NationalMatch[];
11
+ readonly teamsByTier: Map<number, Team[]>;
12
+ readonly teams: Team[];
13
+ readonly status: StatusEnum;
14
+ champion?: Team;
15
+ static create(input: unknown): National;
16
+ private constructor();
17
+ static sortMatchesFn(m1: NationalMatch, m2: NationalMatch): number;
18
+ }
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.National = void 0;
4
+ const national_z_1 = require("./schemas/national.z");
5
+ class National {
6
+ static create(input) {
7
+ const result = national_z_1.NationalInputSchema.safeParse(input);
8
+ if (!result.success) {
9
+ throw new Error(`INVALID_NATIONAL: ${result.error.message}. RECEIVED=${(() => { try {
10
+ return JSON.stringify(input);
11
+ }
12
+ catch {
13
+ return String(input);
14
+ } })()}`);
15
+ }
16
+ return new National(result.data);
17
+ }
18
+ constructor({ id, iteration, country, matches, teamsByTier, champion, status }) {
19
+ this.id = id;
20
+ this.iteration = iteration;
21
+ this.country = country;
22
+ this.matches = matches;
23
+ this.teamsByTier = teamsByTier;
24
+ this.teams = Array.from(teamsByTier.values()).flat();
25
+ this.champion = champion;
26
+ this.status = status;
27
+ this.matches.sort(National.sortMatchesFn);
28
+ }
29
+ // Ascending round, then ascending index within a round.
30
+ static sortMatchesFn(m1, m2) {
31
+ if (m1.round !== m2.round)
32
+ return m1.round - m2.round;
33
+ return m1.index - m2.index;
34
+ }
35
+ }
36
+ exports.National = National;
@@ -0,0 +1,10 @@
1
+ import { z } from 'zod';
2
+ import { Match } from '../../match';
3
+ import { Stage } from '../stage';
4
+ export declare const NationalMatchInputSchema: z.ZodObject<{
5
+ round: z.ZodNumber;
6
+ stage: z.ZodCustom<Stage, Stage>;
7
+ match: z.ZodCustom<Match, Match>;
8
+ index: z.ZodNumber;
9
+ }, z.core.$strip>;
10
+ export type NationalMatchInput = z.infer<typeof NationalMatchInputSchema>;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NationalMatchInputSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const match_1 = require("../../match");
6
+ const stage_1 = require("../stage");
7
+ const matchSchema = zod_1.z.custom((v) => v instanceof match_1.Match, { message: 'INVALID_MATCH_INSTANCE' });
8
+ exports.NationalMatchInputSchema = zod_1.z.object({
9
+ round: zod_1.z.number().int().min(1),
10
+ stage: zod_1.z.custom((v) => typeof v === 'number', { message: 'INVALID_STAGE' }),
11
+ match: matchSchema,
12
+ index: zod_1.z.number().int().min(0)
13
+ }).superRefine((data, ctx) => {
14
+ if (stage_1.Stage.LEAGUE === data.stage) {
15
+ ctx.addIssue({ code: 'custom', message: `INVALID_STAGE: ${data.stage}`, path: ['stage'] });
16
+ }
17
+ });
@@ -0,0 +1,20 @@
1
+ import { z } from 'zod';
2
+ import { Team } from '../../team';
3
+ import { Iteration } from '../iteration';
4
+ import { Country } from '../../country';
5
+ import { StatusEnum } from '../../../data/common';
6
+ import { NationalMatch } from '../national-match';
7
+ export declare const NationalInputSchema: z.ZodObject<{
8
+ id: z.ZodUUID;
9
+ iteration: z.ZodCustom<Iteration, Iteration>;
10
+ country: z.ZodCustom<Country, Country>;
11
+ matches: z.ZodArray<z.ZodCustom<NationalMatch, NationalMatch>>;
12
+ teamsByTier: z.ZodMap<z.ZodNumber, z.ZodArray<z.ZodCustom<Team, Team>>>;
13
+ status: z.ZodEnum<{
14
+ PENDING: StatusEnum.PENDING;
15
+ IN_PROGRESS: StatusEnum.IN_PROGRESS;
16
+ COMPLETE: StatusEnum.COMPLETE;
17
+ }>;
18
+ champion: z.ZodOptional<z.ZodCustom<Team, Team>>;
19
+ }, z.core.$strip>;
20
+ export type NationalInput = z.infer<typeof NationalInputSchema>;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NationalInputSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const team_1 = require("../../team");
6
+ const iteration_1 = require("../iteration");
7
+ const country_1 = require("../../country");
8
+ const common_1 = require("../../../data/common");
9
+ const national_match_1 = require("../national-match");
10
+ const teamSchema = zod_1.z.custom((v) => v instanceof team_1.Team, { message: 'INVALID_TEAM_INSTANCE' });
11
+ const iterationSchema = zod_1.z.custom((v) => v instanceof iteration_1.Iteration, { message: 'INVALID_ITERATION_INSTANCE' });
12
+ const countrySchema = zod_1.z.custom((v) => v instanceof country_1.Country, { message: 'INVALID_COUNTRY_INSTANCE' });
13
+ const nationalMatchSchema = zod_1.z.custom((v) => v instanceof national_match_1.NationalMatch, { message: 'INVALID_NATIONAL_MATCH_INSTANCE' });
14
+ const teamsByTierSchema = zod_1.z.map(zod_1.z.number().int().positive(), zod_1.z.array(teamSchema));
15
+ exports.NationalInputSchema = zod_1.z.object({
16
+ id: zod_1.z.uuid(),
17
+ iteration: iterationSchema,
18
+ country: countrySchema,
19
+ matches: zod_1.z.array(nationalMatchSchema),
20
+ teamsByTier: teamsByTierSchema,
21
+ status: zod_1.z.enum(Object.values(common_1.StatusEnum)),
22
+ champion: teamSchema.optional()
23
+ }).superRefine((data, ctx) => {
24
+ const ids = Array.from(data.teamsByTier.values()).flat().map(t => t.id);
25
+ if (new Set(ids).size !== ids.length) {
26
+ ctx.addIssue({
27
+ code: 'custom',
28
+ message: 'NATIONAL_TEAMS_CONTAINS_DUPLICATES',
29
+ path: ['teamsByTier']
30
+ });
31
+ }
32
+ });
@@ -21,6 +21,7 @@ export declare class MatchRating {
21
21
  static readonly TIER_PENALTY: number;
22
22
  static readonly QUALIFIER_WEIGHT: number;
23
23
  static readonly TOURNAMENT_WEIGHT: number;
24
+ static readonly NATIONAL_WEIGHT: number;
24
25
  readonly match: Match;
25
26
  readonly weight: number;
26
27
  static create(input: unknown): MatchRating;
@@ -42,6 +42,8 @@ class MatchRating {
42
42
  return MatchRating.applyBotPenalty(MatchRating.QUALIFIER_WEIGHT, context.homeIsBot, context.awayIsBot);
43
43
  case 'TOURNAMENT':
44
44
  return MatchRating.applyBotPenalty(MatchRating.TOURNAMENT_WEIGHT, context.homeIsBot, context.awayIsBot);
45
+ case 'NATIONAL':
46
+ return MatchRating.applyBotPenalty(MatchRating.NATIONAL_WEIGHT, context.homeIsBot, context.awayIsBot);
45
47
  }
46
48
  }
47
49
  static calculateProbability(z) {
@@ -95,3 +97,5 @@ MatchRating.TIER_PENALTY = 5;
95
97
  MatchRating.QUALIFIER_WEIGHT = 45;
96
98
  // WCC tournament — top of the hierarchy
97
99
  MatchRating.TOURNAMENT_WEIGHT = 55;
100
+ // National cup, between qualifier and tournament prestige
101
+ MatchRating.NATIONAL_WEIGHT = 50;
@@ -19,6 +19,10 @@ export declare const MatchContextSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
19
19
  kind: z.ZodLiteral<"TOURNAMENT">;
20
20
  homeIsBot: z.ZodBoolean;
21
21
  awayIsBot: z.ZodBoolean;
22
+ }, z.core.$strip>, z.ZodObject<{
23
+ kind: z.ZodLiteral<"NATIONAL">;
24
+ homeIsBot: z.ZodBoolean;
25
+ awayIsBot: z.ZodBoolean;
22
26
  }, z.core.$strip>], "kind">;
23
27
  export declare const MatchRatingInputSchema: z.ZodObject<{
24
28
  match: z.ZodCustom<Match, Match>;
@@ -41,6 +45,10 @@ export declare const MatchRatingInputSchema: z.ZodObject<{
41
45
  kind: z.ZodLiteral<"TOURNAMENT">;
42
46
  homeIsBot: z.ZodBoolean;
43
47
  awayIsBot: z.ZodBoolean;
48
+ }, z.core.$strip>, z.ZodObject<{
49
+ kind: z.ZodLiteral<"NATIONAL">;
50
+ homeIsBot: z.ZodBoolean;
51
+ awayIsBot: z.ZodBoolean;
44
52
  }, z.core.$strip>], "kind">;
45
53
  }, z.core.$strip>;
46
54
  export type MatchContext = z.infer<typeof MatchContextSchema>;
@@ -26,6 +26,11 @@ exports.MatchContextSchema = zod_1.z.discriminatedUnion('kind', [
26
26
  kind: zod_1.z.literal('TOURNAMENT'),
27
27
  homeIsBot: zod_1.z.boolean(),
28
28
  awayIsBot: zod_1.z.boolean()
29
+ }),
30
+ zod_1.z.object({
31
+ kind: zod_1.z.literal('NATIONAL'),
32
+ homeIsBot: zod_1.z.boolean(),
33
+ awayIsBot: zod_1.z.boolean()
29
34
  })
30
35
  ]);
31
36
  exports.MatchRatingInputSchema = zod_1.z.object({