tods-competition-factory 1.8.15 → 1.8.16
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/forge/generate.d.ts +1 -0
- package/dist/forge/generate.mjs +34 -24
- package/dist/forge/generate.mjs.map +1 -1
- package/dist/forge/query.d.ts +1 -0
- package/dist/forge/query.mjs.map +1 -1
- package/dist/forge/transform.d.ts +1 -0
- package/dist/forge/transform.mjs +34 -24
- package/dist/forge/transform.mjs.map +1 -1
- package/dist/index.mjs +230 -30
- package/dist/index.mjs.map +1 -1
- package/dist/tods-competition-factory.development.cjs.js +331 -42
- package/dist/tods-competition-factory.development.cjs.js.map +1 -1
- package/dist/tods-competition-factory.production.cjs.min.js +1 -1
- package/dist/tods-competition-factory.production.cjs.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -2905,7 +2905,7 @@ var matchUpFormatCode = {
|
|
|
2905
2905
|
};
|
|
2906
2906
|
|
|
2907
2907
|
function factoryVersion() {
|
|
2908
|
-
return '1.8.
|
|
2908
|
+
return '1.8.16';
|
|
2909
2909
|
}
|
|
2910
2910
|
|
|
2911
2911
|
function getObjectTieFormat(obj) {
|
|
@@ -4190,12 +4190,13 @@ function countSets(_a) {
|
|
|
4190
4190
|
var _c;
|
|
4191
4191
|
var matchUpWinningSide = _a.winningSide, _d = _a.matchUpFormat, matchUpFormat = _d === void 0 ? FORMAT_STANDARD : _d, matchUpStatus = _a.matchUpStatus, tallyPolicy = _a.tallyPolicy, score = _a.score;
|
|
4192
4192
|
var setsTally = [0, 0];
|
|
4193
|
-
var sets =
|
|
4194
|
-
var matchUpWinnerIndex = matchUpWinningSide - 1;
|
|
4193
|
+
var sets = score === null || score === void 0 ? void 0 : score.sets;
|
|
4194
|
+
var matchUpWinnerIndex = typeof matchUpWinningSide === 'number' && matchUpWinningSide - 1;
|
|
4195
4195
|
var parsedMatchUpFormat = parse(matchUpFormat);
|
|
4196
4196
|
var setsToWin = getSetsToWin((_c = parsedMatchUpFormat === null || parsedMatchUpFormat === void 0 ? void 0 : parsedMatchUpFormat.bestOf) !== null && _c !== void 0 ? _c : 1);
|
|
4197
|
-
if (
|
|
4198
|
-
(matchUpStatus ===
|
|
4197
|
+
if (typeof matchUpWinnerIndex === 'number' &&
|
|
4198
|
+
((matchUpStatus === DEFAULTED && (tallyPolicy === null || tallyPolicy === void 0 ? void 0 : tallyPolicy.setsCreditForDefaults)) ||
|
|
4199
|
+
(matchUpStatus === WALKOVER$2 && (tallyPolicy === null || tallyPolicy === void 0 ? void 0 : tallyPolicy.setsCreditForWalkovers)))) {
|
|
4199
4200
|
// in the case of WALKOVER or DEFAULT, matchUp winner gets full sets to win value
|
|
4200
4201
|
setsTally[matchUpWinnerIndex] = setsToWin;
|
|
4201
4202
|
}
|
|
@@ -4216,7 +4217,7 @@ function countSets(_a) {
|
|
|
4216
4217
|
finally { if (e_1) throw e_1.error; }
|
|
4217
4218
|
}
|
|
4218
4219
|
}
|
|
4219
|
-
if (matchUpStatus === RETIRED$1) {
|
|
4220
|
+
if (typeof matchUpWinnerIndex === 'number' && matchUpStatus === RETIRED$1) {
|
|
4220
4221
|
// if the loser has setsToWin then last set was incomplete and needs to be subtracted from loser
|
|
4221
4222
|
if (+setsTally[1 - matchUpWinnerIndex] === setsToWin)
|
|
4222
4223
|
setsTally[1 - matchUpWinnerIndex] -= 1;
|
|
@@ -4232,14 +4233,15 @@ function countGames(_a) {
|
|
|
4232
4233
|
var sets = (score || {}).sets;
|
|
4233
4234
|
if (!sets)
|
|
4234
4235
|
return [0, 0];
|
|
4235
|
-
var matchUpWinnerIndex = matchUpWinningSide - 1;
|
|
4236
|
+
var matchUpWinnerIndex = typeof matchUpWinningSide === 'number' && matchUpWinningSide - 1;
|
|
4236
4237
|
var parsedMatchUpFormat = parse(matchUpFormat);
|
|
4237
4238
|
var bestOf = (_b = parsedMatchUpFormat === null || parsedMatchUpFormat === void 0 ? void 0 : parsedMatchUpFormat.bestOf) !== null && _b !== void 0 ? _b : 1;
|
|
4238
4239
|
var setsToWin = getSetsToWin(bestOf);
|
|
4239
4240
|
var tiebreakAt = ((_c = parsedMatchUpFormat === null || parsedMatchUpFormat === void 0 ? void 0 : parsedMatchUpFormat.setFormat) === null || _c === void 0 ? void 0 : _c.tiebreakAt) || 0;
|
|
4240
4241
|
var gamesTally = [[], []];
|
|
4241
|
-
if (
|
|
4242
|
-
(matchUpStatus ===
|
|
4242
|
+
if (typeof matchUpWinnerIndex === 'number' &&
|
|
4243
|
+
((matchUpStatus === DEFAULTED && (tallyPolicy === null || tallyPolicy === void 0 ? void 0 : tallyPolicy.gamesCreditForDefaults)) ||
|
|
4244
|
+
(matchUpStatus === WALKOVER$2 && (tallyPolicy === null || tallyPolicy === void 0 ? void 0 : tallyPolicy.gamesCreditForWalkovers)))) {
|
|
4243
4245
|
var gamesForSet = ((_d = parsedMatchUpFormat === null || parsedMatchUpFormat === void 0 ? void 0 : parsedMatchUpFormat.setFormat) === null || _d === void 0 ? void 0 : _d.setTo) || 0;
|
|
4244
4246
|
var minimumGameWins = setsToWin * gamesForSet;
|
|
4245
4247
|
gamesTally[matchUpWinnerIndex].push(minimumGameWins);
|
|
@@ -4258,18 +4260,6 @@ function countGames(_a) {
|
|
|
4258
4260
|
gamesTally[0].push(ensureInt(side1Score || 0));
|
|
4259
4261
|
gamesTally[1].push(ensureInt(side2Score || 0));
|
|
4260
4262
|
}
|
|
4261
|
-
// count a tiebreak as a game won
|
|
4262
|
-
/*
|
|
4263
|
-
*if (
|
|
4264
|
-
* !based &&
|
|
4265
|
-
* !isTiebreakSet &&
|
|
4266
|
-
* set.winningSide &&
|
|
4267
|
-
* (side1TiebreakScore || side2TiebreakScore) &&
|
|
4268
|
-
* tallyPolicy?.gamesCreditForTiebreaks !== false
|
|
4269
|
-
*) {
|
|
4270
|
-
* gamesTally[set.winningSide - 1].push(1);
|
|
4271
|
-
*}
|
|
4272
|
-
*/
|
|
4273
4263
|
// count a tiebreak set also as a game won
|
|
4274
4264
|
if (isTiebreakSet &&
|
|
4275
4265
|
set.winningSide &&
|
|
@@ -4278,7 +4268,7 @@ function countGames(_a) {
|
|
|
4278
4268
|
}
|
|
4279
4269
|
});
|
|
4280
4270
|
}
|
|
4281
|
-
if (matchUpStatus === RETIRED$1) {
|
|
4271
|
+
if (matchUpStatus === RETIRED$1 && typeof matchUpWinnerIndex === 'number') {
|
|
4282
4272
|
// setFormat must consider whether retirment occurred in a finalSet which has a different format
|
|
4283
4273
|
var whichFormat = sets.length > setsToWin && (parsedMatchUpFormat === null || parsedMatchUpFormat === void 0 ? void 0 : parsedMatchUpFormat.finalSetFormat)
|
|
4284
4274
|
? 'finalSetFormat'
|
|
@@ -4328,9 +4318,10 @@ function countGames(_a) {
|
|
|
4328
4318
|
function countPoints(_a) {
|
|
4329
4319
|
var _b, _c;
|
|
4330
4320
|
var matchUpFormat = _a.matchUpFormat, score = _a.score;
|
|
4331
|
-
var parsedMatchUpFormat = parse(matchUpFormat);
|
|
4321
|
+
var parsedMatchUpFormat = matchUpFormat ? parse(matchUpFormat) : undefined;
|
|
4332
4322
|
var bestOf = (_b = parsedMatchUpFormat === null || parsedMatchUpFormat === void 0 ? void 0 : parsedMatchUpFormat.bestOf) !== null && _b !== void 0 ? _b : 1;
|
|
4333
4323
|
var setsToWin = getSetsToWin(bestOf);
|
|
4324
|
+
var tiebreaksTally = [0, 0];
|
|
4334
4325
|
var pointsTally = [0, 0];
|
|
4335
4326
|
(_c = score === null || score === void 0 ? void 0 : score.sets) === null || _c === void 0 ? void 0 : _c.forEach(function (set, i) {
|
|
4336
4327
|
var _a;
|
|
@@ -4351,9 +4342,11 @@ function countPoints(_a) {
|
|
|
4351
4342
|
pointsTally[0] += ensureInt(set.side1TiebreakScore || 0);
|
|
4352
4343
|
if (set.side2TiebreakScore)
|
|
4353
4344
|
pointsTally[1] += ensureInt(set.side2TiebreakScore || 0);
|
|
4345
|
+
if ((set.side1TiebreakScore || set.side2TiebreakScore) && set.winningSide)
|
|
4346
|
+
tiebreaksTally[set.winningSide - 1] += 1;
|
|
4354
4347
|
}
|
|
4355
4348
|
});
|
|
4356
|
-
return pointsTally;
|
|
4349
|
+
return { pointsTally: pointsTally, tiebreaksTally: tiebreaksTally };
|
|
4357
4350
|
}
|
|
4358
4351
|
function getSetsToWin(bestOfGames) {
|
|
4359
4352
|
return (bestOfGames && Math.ceil(bestOfGames / 2)) || 1;
|
|
@@ -4436,7 +4429,7 @@ var matchUpTypes = {
|
|
|
4436
4429
|
|
|
4437
4430
|
function getParticipantResults(_a) {
|
|
4438
4431
|
var e_1, _b, e_2, _c, e_3, _d;
|
|
4439
|
-
var _e, _f, _g, _h;
|
|
4432
|
+
var _e, _f, _g, _h, _j, _k;
|
|
4440
4433
|
var participantIds = _a.participantIds, matchUpFormat = _a.matchUpFormat, tallyPolicy = _a.tallyPolicy, perPlayer = _a.perPlayer, matchUps = _a.matchUps;
|
|
4441
4434
|
var participantResults = {};
|
|
4442
4435
|
var excludeMatchUpStatuses = (tallyPolicy === null || tallyPolicy === void 0 ? void 0 : tallyPolicy.excludeMatchUpStatuses) || [];
|
|
@@ -4483,7 +4476,7 @@ function getParticipantResults(_a) {
|
|
|
4483
4476
|
var winningParticipantId = winningSide && getWinningSideId(matchUp);
|
|
4484
4477
|
var losingParticipantId = winningSide && getLosingSideId(matchUp);
|
|
4485
4478
|
if (!winningParticipantId && !losingParticipantId) {
|
|
4486
|
-
if (completedMatchUpStatuses.includes(matchUpStatus)) {
|
|
4479
|
+
if (matchUpStatus && completedMatchUpStatuses.includes(matchUpStatus)) {
|
|
4487
4480
|
var participantIdSide1 = getSideId(matchUp, 0);
|
|
4488
4481
|
var participantIdSide2 = getSideId(matchUp, 1);
|
|
4489
4482
|
if (participantIdSide1) {
|
|
@@ -4499,11 +4492,11 @@ function getParticipantResults(_a) {
|
|
|
4499
4492
|
perPlayer = 0; // if any matchUps are matchUpType: TEAM don't calculate perPlayer
|
|
4500
4493
|
var _loop_1 = function (tieMatchUp) {
|
|
4501
4494
|
if (tieMatchUp.winningSide) {
|
|
4502
|
-
var tieWinningParticipantId = (_e = sides.find(function (_a) {
|
|
4495
|
+
var tieWinningParticipantId = (_e = sides === null || sides === void 0 ? void 0 : sides.find(function (_a) {
|
|
4503
4496
|
var sideNumber = _a.sideNumber;
|
|
4504
4497
|
return sideNumber === tieMatchUp.winningSide;
|
|
4505
4498
|
})) === null || _e === void 0 ? void 0 : _e.participantId;
|
|
4506
|
-
var tieLosingParticipantId = (_f = sides.find(function (_a) {
|
|
4499
|
+
var tieLosingParticipantId = (_f = sides === null || sides === void 0 ? void 0 : sides.find(function (_a) {
|
|
4507
4500
|
var sideNumber = _a.sideNumber;
|
|
4508
4501
|
return sideNumber === tieMatchUp.winningSide;
|
|
4509
4502
|
})) === null || _f === void 0 ? void 0 : _f.participantId;
|
|
@@ -4645,22 +4638,26 @@ function getParticipantResults(_a) {
|
|
|
4645
4638
|
}
|
|
4646
4639
|
}
|
|
4647
4640
|
if (manualGamesOverride) {
|
|
4648
|
-
var side1participantId = (_g = sides.find(function (_a) {
|
|
4641
|
+
var side1participantId = (_g = sides === null || sides === void 0 ? void 0 : sides.find(function (_a) {
|
|
4649
4642
|
var sideNumber = _a.sideNumber;
|
|
4650
4643
|
return sideNumber === 1;
|
|
4651
4644
|
})) === null || _g === void 0 ? void 0 : _g.participantId;
|
|
4652
|
-
var side2participantId = (_h = sides.find(function (_a) {
|
|
4645
|
+
var side2participantId = (_h = sides === null || sides === void 0 ? void 0 : sides.find(function (_a) {
|
|
4653
4646
|
var sideNumber = _a.sideNumber;
|
|
4654
4647
|
return sideNumber === 2;
|
|
4655
4648
|
})) === null || _h === void 0 ? void 0 : _h.participantId;
|
|
4656
4649
|
checkInitializeParticipant(participantResults, side1participantId);
|
|
4657
4650
|
checkInitializeParticipant(participantResults, side2participantId);
|
|
4658
|
-
var gamesWonSide1 = score.sets.reduce(function (total, set) { return total + set.side1Score; }, 0);
|
|
4659
|
-
var gamesWonSide2 = score.sets.reduce(function (total, set) { return total + set.side2Score; }, 0);
|
|
4660
|
-
|
|
4661
|
-
|
|
4662
|
-
|
|
4663
|
-
|
|
4651
|
+
var gamesWonSide1 = (_j = score === null || score === void 0 ? void 0 : score.sets) === null || _j === void 0 ? void 0 : _j.reduce(function (total, set) { var _a; return total + ((_a = set === null || set === void 0 ? void 0 : set.side1Score) !== null && _a !== void 0 ? _a : 0); }, 0);
|
|
4652
|
+
var gamesWonSide2 = (_k = score === null || score === void 0 ? void 0 : score.sets) === null || _k === void 0 ? void 0 : _k.reduce(function (total, set) { var _a; return total + ((_a = set.side2Score) !== null && _a !== void 0 ? _a : 0); }, 0);
|
|
4653
|
+
if (side1participantId) {
|
|
4654
|
+
participantResults[side1participantId].gamesWon += gamesWonSide1;
|
|
4655
|
+
participantResults[side1participantId].gamesLost += gamesWonSide2;
|
|
4656
|
+
}
|
|
4657
|
+
if (side2participantId) {
|
|
4658
|
+
participantResults[side2participantId].gamesWon += gamesWonSide2;
|
|
4659
|
+
participantResults[side2participantId].gamesLost += gamesWonSide1;
|
|
4660
|
+
}
|
|
4664
4661
|
}
|
|
4665
4662
|
}
|
|
4666
4663
|
}
|
|
@@ -4792,7 +4789,7 @@ function processMatchUp$1(_a) {
|
|
|
4792
4789
|
winningSide: winningSide,
|
|
4793
4790
|
score: score,
|
|
4794
4791
|
});
|
|
4795
|
-
var pointsTally = countPoints({ score: score, matchUpFormat: matchUpFormat });
|
|
4792
|
+
var pointsTally = countPoints({ score: score, matchUpFormat: matchUpFormat }).pointsTally;
|
|
4796
4793
|
if (winningParticipantId) {
|
|
4797
4794
|
participantResults[winningParticipantId].setsWon +=
|
|
4798
4795
|
setsTally[winningSideIndex];
|
|
@@ -41205,7 +41202,7 @@ function engineLogging(_a) {
|
|
|
41205
41202
|
var result = _a.result, methodName = _a.methodName, elapsed = _a.elapsed, params = _a.params, engine = _a.engine;
|
|
41206
41203
|
var devContext = getDevContext();
|
|
41207
41204
|
var log = { method: methodName };
|
|
41208
|
-
var logError = result.error &&
|
|
41205
|
+
var logError = (result === null || result === void 0 ? void 0 : result.error) &&
|
|
41209
41206
|
(devContext.errors === true ||
|
|
41210
41207
|
(Array.isArray(devContext.errors) &&
|
|
41211
41208
|
devContext.errors.includes(methodName)));
|
|
@@ -41232,7 +41229,7 @@ function engineLogging(_a) {
|
|
|
41232
41229
|
}
|
|
41233
41230
|
if (Object.keys(log).length > 1)
|
|
41234
41231
|
console.log(engine, log);
|
|
41235
|
-
if (devContext.makeDeepCopy)
|
|
41232
|
+
if (result && devContext.makeDeepCopy)
|
|
41236
41233
|
result.deepCopyIterations = getDeepCopyIterations();
|
|
41237
41234
|
}
|
|
41238
41235
|
|
|
@@ -47018,7 +47015,7 @@ function buildDrawHierarchy(_a) {
|
|
|
47018
47015
|
var secondRoundEntries = secondRoundDrawPositions
|
|
47019
47016
|
.filter(function (drawPosition) { return !firstRoundDrawPositions.includes(drawPosition); })
|
|
47020
47017
|
.sort(drawPositionSort);
|
|
47021
|
-
var
|
|
47018
|
+
var secondRoundEntrySides = secondRoundMatchUps
|
|
47022
47019
|
.filter(function (matchUp) {
|
|
47023
47020
|
var _a;
|
|
47024
47021
|
return (_a = matchUp.drawPositions) === null || _a === void 0 ? void 0 : _a.reduce(function (p, c) { return secondRoundEntries.includes(c) || p; }, undefined);
|
|
@@ -47036,7 +47033,7 @@ function buildDrawHierarchy(_a) {
|
|
|
47036
47033
|
var missingPairs = secondRoundEntries.map(function (drawPosition, index) {
|
|
47037
47034
|
return [drawPosition, missingDrawPositions[index]].sort(drawPositionSort);
|
|
47038
47035
|
});
|
|
47039
|
-
var entrySides_1 = Object.assign.apply(Object, __spreadArray([{}], __read(
|
|
47036
|
+
var entrySides_1 = Object.assign.apply(Object, __spreadArray([{}], __read(secondRoundEntrySides), false));
|
|
47040
47037
|
var finishingRound_1 = makeDeepCopy(firstRoundMatchUps === null || firstRoundMatchUps === void 0 ? void 0 : firstRoundMatchUps[0].finishingRound, false, true);
|
|
47041
47038
|
var finishingPositionRange_1 = makeDeepCopy(firstRoundMatchUps === null || firstRoundMatchUps === void 0 ? void 0 : firstRoundMatchUps[0].finishingPositionRange, false, true);
|
|
47042
47039
|
missingMatchUps = missingPairs.map(function (drawPositions, index) {
|
|
@@ -59466,7 +59463,299 @@ function getPositionManipulations(_a) {
|
|
|
59466
59463
|
})) === null || _b === void 0 ? void 0 : _b.value) === null || _c === void 0 ? void 0 : _c.slice(1);
|
|
59467
59464
|
}
|
|
59468
59465
|
|
|
59469
|
-
|
|
59466
|
+
function getTeamStats(_a) {
|
|
59467
|
+
var e_1, _b, e_2, _c, e_3, _d, e_4, _e, e_5, _f, e_6, _g;
|
|
59468
|
+
var _h, _j, _k, _l;
|
|
59469
|
+
var opponentParticipantId = _a.opponentParticipantId, teamParticipantId = _a.teamParticipantId, tournamentRecord = _a.tournamentRecord, tallyPolicy = _a.tallyPolicy, matchUps = _a.matchUps;
|
|
59470
|
+
if (!tournamentRecord)
|
|
59471
|
+
return { error: MISSING_TOURNAMENT_RECORD };
|
|
59472
|
+
if (matchUps && !Array.isArray(matchUps))
|
|
59473
|
+
return { error: INVALID_MATCHUP };
|
|
59474
|
+
matchUps = matchUps || allTournamentMatchUps({ tournamentRecord: tournamentRecord }).matchUps;
|
|
59475
|
+
if (!(matchUps === null || matchUps === void 0 ? void 0 : matchUps.length))
|
|
59476
|
+
return { error: MISSING_MATCHUPS };
|
|
59477
|
+
var teamParticipantIds = [];
|
|
59478
|
+
if (opponentParticipantId)
|
|
59479
|
+
teamParticipantIds.push(opponentParticipantId);
|
|
59480
|
+
if (teamParticipantId)
|
|
59481
|
+
teamParticipantIds.push(teamParticipantId);
|
|
59482
|
+
var participantFilters = !teamParticipantIds.length
|
|
59483
|
+
? { participantTypes: [TEAM_PARTICIPANT] }
|
|
59484
|
+
: { participantIds: teamParticipantIds };
|
|
59485
|
+
var teamParticipants = (_h = getParticipants$1({ participantFilters: participantFilters, tournamentRecord: tournamentRecord }).participants) !== null && _h !== void 0 ? _h : [];
|
|
59486
|
+
if (!teamParticipants.every(function (_a) {
|
|
59487
|
+
var participantType = _a.participantType;
|
|
59488
|
+
return participantType === TEAM_PARTICIPANT;
|
|
59489
|
+
})) {
|
|
59490
|
+
return { error: INVALID_PARTICIPANT_IDS };
|
|
59491
|
+
}
|
|
59492
|
+
if (!teamParticipantIds.length)
|
|
59493
|
+
teamParticipantIds.push.apply(teamParticipantIds, __spreadArray([], __read(teamParticipants.map(extractAttributes('participantId'))), false));
|
|
59494
|
+
var teamStats = new Map();
|
|
59495
|
+
var teamMap = new Map();
|
|
59496
|
+
try {
|
|
59497
|
+
for (var teamParticipants_1 = __values(teamParticipants), teamParticipants_1_1 = teamParticipants_1.next(); !teamParticipants_1_1.done; teamParticipants_1_1 = teamParticipants_1.next()) {
|
|
59498
|
+
var teamParticipant = teamParticipants_1_1.value;
|
|
59499
|
+
var participantId = teamParticipant.participantId, individualParticipantIds = teamParticipant.individualParticipantIds;
|
|
59500
|
+
teamMap.set(participantId, individualParticipantIds !== null && individualParticipantIds !== void 0 ? individualParticipantIds : []);
|
|
59501
|
+
teamStats.set(participantId, {
|
|
59502
|
+
participantName: (_j = teamParticipant.participantName) !== null && _j !== void 0 ? _j : '',
|
|
59503
|
+
matchUpStatuses: {},
|
|
59504
|
+
competitorIds: [],
|
|
59505
|
+
tiebreaks: [0, 0],
|
|
59506
|
+
matchUps: [0, 0],
|
|
59507
|
+
points: [0, 0],
|
|
59508
|
+
participantId: participantId,
|
|
59509
|
+
games: [0, 0],
|
|
59510
|
+
sets: [0, 0],
|
|
59511
|
+
});
|
|
59512
|
+
}
|
|
59513
|
+
}
|
|
59514
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
59515
|
+
finally {
|
|
59516
|
+
try {
|
|
59517
|
+
if (teamParticipants_1_1 && !teamParticipants_1_1.done && (_b = teamParticipants_1.return)) _b.call(teamParticipants_1);
|
|
59518
|
+
}
|
|
59519
|
+
finally { if (e_1) throw e_1.error; }
|
|
59520
|
+
}
|
|
59521
|
+
if (teamParticipantId && !teamMap.get(teamParticipantId))
|
|
59522
|
+
return decorateResult({
|
|
59523
|
+
result: { error: PARTICIPANT_NOT_FOUND },
|
|
59524
|
+
context: { teamParticipantId: teamParticipantId },
|
|
59525
|
+
});
|
|
59526
|
+
if (opponentParticipantId && !teamMap.get(opponentParticipantId))
|
|
59527
|
+
return decorateResult({
|
|
59528
|
+
result: { error: PARTICIPANT_NOT_FOUND },
|
|
59529
|
+
context: { opponentParticipantId: opponentParticipantId },
|
|
59530
|
+
});
|
|
59531
|
+
var relevantMatchUps = [];
|
|
59532
|
+
var getTeamParticipantIds = function (sides) {
|
|
59533
|
+
var e_7, _a, e_8, _b, e_9, _c;
|
|
59534
|
+
var _d, _e;
|
|
59535
|
+
var sideTeamParticipantIds = [];
|
|
59536
|
+
var isTeamSide = function (side, individualParticipantIds) {
|
|
59537
|
+
var _a, _b, _c, _d, _e;
|
|
59538
|
+
return !!((side.participantId &&
|
|
59539
|
+
individualParticipantIds.includes(side.participantId)) ||
|
|
59540
|
+
(((_b = (_a = side.participant) === null || _a === void 0 ? void 0 : _a.individualParticipantIds) === null || _b === void 0 ? void 0 : _b.length) &&
|
|
59541
|
+
intersection(individualParticipantIds, (_c = side.participant) === null || _c === void 0 ? void 0 : _c.individualParticipantIds).length === ((_e = (_d = side.participant) === null || _d === void 0 ? void 0 : _d.individualParticipantIds) === null || _e === void 0 ? void 0 : _e.length)));
|
|
59542
|
+
};
|
|
59543
|
+
try {
|
|
59544
|
+
for (var teamMap_1 = __values(teamMap), teamMap_1_1 = teamMap_1.next(); !teamMap_1_1.done; teamMap_1_1 = teamMap_1.next()) {
|
|
59545
|
+
var _f = __read(teamMap_1_1.value, 2), teamParticipantId_1 = _f[0], individualParticipantIds = _f[1];
|
|
59546
|
+
try {
|
|
59547
|
+
for (var sides_1 = (e_8 = void 0, __values(sides)), sides_1_1 = sides_1.next(); !sides_1_1.done; sides_1_1 = sides_1.next()) {
|
|
59548
|
+
var side = sides_1_1.value;
|
|
59549
|
+
if (!side.participant)
|
|
59550
|
+
continue;
|
|
59551
|
+
if (isTeamSide(side, individualParticipantIds)) {
|
|
59552
|
+
var sideNumber = side.sideNumber;
|
|
59553
|
+
if (!sideNumber)
|
|
59554
|
+
continue;
|
|
59555
|
+
sideTeamParticipantIds[sideNumber - 1] = teamParticipantId_1;
|
|
59556
|
+
var competitorIds = ((_e = (_d = side.participant) === null || _d === void 0 ? void 0 : _d.individualParticipantIds) === null || _e === void 0 ? void 0 : _e.length)
|
|
59557
|
+
? side.participant.individualParticipantIds
|
|
59558
|
+
: [side.participant.participantId];
|
|
59559
|
+
var stats = teamStats.get(teamParticipantId_1);
|
|
59560
|
+
try {
|
|
59561
|
+
for (var competitorIds_1 = (e_9 = void 0, __values(competitorIds)), competitorIds_1_1 = competitorIds_1.next(); !competitorIds_1_1.done; competitorIds_1_1 = competitorIds_1.next()) {
|
|
59562
|
+
var id = competitorIds_1_1.value;
|
|
59563
|
+
if (stats && !stats.competitorIds.includes(id))
|
|
59564
|
+
stats.competitorIds.push(id);
|
|
59565
|
+
}
|
|
59566
|
+
}
|
|
59567
|
+
catch (e_9_1) { e_9 = { error: e_9_1 }; }
|
|
59568
|
+
finally {
|
|
59569
|
+
try {
|
|
59570
|
+
if (competitorIds_1_1 && !competitorIds_1_1.done && (_c = competitorIds_1.return)) _c.call(competitorIds_1);
|
|
59571
|
+
}
|
|
59572
|
+
finally { if (e_9) throw e_9.error; }
|
|
59573
|
+
}
|
|
59574
|
+
}
|
|
59575
|
+
}
|
|
59576
|
+
}
|
|
59577
|
+
catch (e_8_1) { e_8 = { error: e_8_1 }; }
|
|
59578
|
+
finally {
|
|
59579
|
+
try {
|
|
59580
|
+
if (sides_1_1 && !sides_1_1.done && (_b = sides_1.return)) _b.call(sides_1);
|
|
59581
|
+
}
|
|
59582
|
+
finally { if (e_8) throw e_8.error; }
|
|
59583
|
+
}
|
|
59584
|
+
}
|
|
59585
|
+
}
|
|
59586
|
+
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
59587
|
+
finally {
|
|
59588
|
+
try {
|
|
59589
|
+
if (teamMap_1_1 && !teamMap_1_1.done && (_a = teamMap_1.return)) _a.call(teamMap_1);
|
|
59590
|
+
}
|
|
59591
|
+
finally { if (e_7) throw e_7.error; }
|
|
59592
|
+
}
|
|
59593
|
+
return sideTeamParticipantIds;
|
|
59594
|
+
};
|
|
59595
|
+
var _loop_1 = function (matchUp) {
|
|
59596
|
+
if (!isObject(matchUp))
|
|
59597
|
+
return { value: { error: INVALID_MATCHUP } };
|
|
59598
|
+
var matchUpStatus = matchUp.matchUpStatus, matchUpFormat = matchUp.matchUpFormat, matchUpType = matchUp.matchUpType, winningSide = matchUp.winningSide, score = matchUp.score, sides = matchUp.sides;
|
|
59599
|
+
if (!sides ||
|
|
59600
|
+
!score ||
|
|
59601
|
+
matchUpType === TEAM_MATCHUP ||
|
|
59602
|
+
matchUpStatus === BYE)
|
|
59603
|
+
return "continue";
|
|
59604
|
+
var teamParticipantIds_1 = getTeamParticipantIds(sides);
|
|
59605
|
+
if (!teamParticipantIds_1.filter(Boolean).length)
|
|
59606
|
+
return "continue";
|
|
59607
|
+
relevantMatchUps.push(matchUp);
|
|
59608
|
+
var setsTally = countSets({
|
|
59609
|
+
matchUpStatus: matchUpStatus,
|
|
59610
|
+
matchUpFormat: matchUpFormat,
|
|
59611
|
+
tallyPolicy: tallyPolicy,
|
|
59612
|
+
winningSide: winningSide,
|
|
59613
|
+
score: score,
|
|
59614
|
+
});
|
|
59615
|
+
var gamesTally = countGames({
|
|
59616
|
+
matchUpStatus: matchUpStatus,
|
|
59617
|
+
matchUpFormat: matchUpFormat,
|
|
59618
|
+
tallyPolicy: tallyPolicy,
|
|
59619
|
+
winningSide: winningSide,
|
|
59620
|
+
score: score,
|
|
59621
|
+
});
|
|
59622
|
+
var _r = countPoints({
|
|
59623
|
+
matchUpFormat: matchUpFormat,
|
|
59624
|
+
score: score,
|
|
59625
|
+
}), pointsTally = _r.pointsTally, tiebreaksTally = _r.tiebreaksTally;
|
|
59626
|
+
teamParticipantIds_1.forEach(function (teamParticipantId, index) {
|
|
59627
|
+
if (teamParticipantId) {
|
|
59628
|
+
var stats_1 = teamStats.get(teamParticipantId);
|
|
59629
|
+
if (stats_1) {
|
|
59630
|
+
var teamSumTally = function (stat, tally) {
|
|
59631
|
+
return tally.forEach(function (t, i) { return (stats_1[stat][i] += t); });
|
|
59632
|
+
};
|
|
59633
|
+
var tiebreaks = index
|
|
59634
|
+
? __spreadArray([], __read(tiebreaksTally), false).reverse()
|
|
59635
|
+
: tiebreaksTally;
|
|
59636
|
+
var points = index ? __spreadArray([], __read(pointsTally), false).reverse() : pointsTally;
|
|
59637
|
+
var games = index ? __spreadArray([], __read(gamesTally), false).reverse() : gamesTally;
|
|
59638
|
+
var sets = index ? __spreadArray([], __read(setsTally), false).reverse() : setsTally;
|
|
59639
|
+
teamSumTally('tiebreaks', tiebreaks);
|
|
59640
|
+
teamSumTally('points', points);
|
|
59641
|
+
teamSumTally('games', games);
|
|
59642
|
+
teamSumTally('sets', sets);
|
|
59643
|
+
if (winningSide) {
|
|
59644
|
+
var tallyIndex = winningSide - 1 === index ? 0 : 1;
|
|
59645
|
+
stats_1.matchUps[tallyIndex] += 1;
|
|
59646
|
+
}
|
|
59647
|
+
if (matchUpStatus) {
|
|
59648
|
+
if (!stats_1.matchUpStatuses[matchUpStatus])
|
|
59649
|
+
stats_1.matchUpStatuses[matchUpStatus] = 0;
|
|
59650
|
+
stats_1.matchUpStatuses[matchUpStatus] += 1;
|
|
59651
|
+
}
|
|
59652
|
+
}
|
|
59653
|
+
}
|
|
59654
|
+
});
|
|
59655
|
+
};
|
|
59656
|
+
try {
|
|
59657
|
+
for (var matchUps_1 = __values(matchUps), matchUps_1_1 = matchUps_1.next(); !matchUps_1_1.done; matchUps_1_1 = matchUps_1.next()) {
|
|
59658
|
+
var matchUp = matchUps_1_1.value;
|
|
59659
|
+
var state_1 = _loop_1(matchUp);
|
|
59660
|
+
if (typeof state_1 === "object")
|
|
59661
|
+
return state_1.value;
|
|
59662
|
+
}
|
|
59663
|
+
}
|
|
59664
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
59665
|
+
finally {
|
|
59666
|
+
try {
|
|
59667
|
+
if (matchUps_1_1 && !matchUps_1_1.done && (_c = matchUps_1.return)) _c.call(matchUps_1);
|
|
59668
|
+
}
|
|
59669
|
+
finally { if (e_2) throw e_2.error; }
|
|
59670
|
+
}
|
|
59671
|
+
var attrs = ['tiebreaks', 'matchUps', 'points', 'games', 'sets'];
|
|
59672
|
+
var ratio = new Map();
|
|
59673
|
+
var add = function (a, b) { return (a !== null && a !== void 0 ? a : 0) + (b !== null && b !== void 0 ? b : 0); };
|
|
59674
|
+
try {
|
|
59675
|
+
for (var _m = __values(teamStats.values()), _o = _m.next(); !_o.done; _o = _m.next()) {
|
|
59676
|
+
var stats = _o.value;
|
|
59677
|
+
try {
|
|
59678
|
+
for (var attrs_1 = (e_4 = void 0, __values(attrs)), attrs_1_1 = attrs_1.next(); !attrs_1_1.done; attrs_1_1 = attrs_1.next()) {
|
|
59679
|
+
var attr = attrs_1_1.value;
|
|
59680
|
+
var total = stats[attr].reduce(add);
|
|
59681
|
+
if (total) {
|
|
59682
|
+
var value = stats[attr][0] / total;
|
|
59683
|
+
var accessor = "".concat(attr, "Ratio");
|
|
59684
|
+
var fixedValue = parseFloat(value.toFixed(2));
|
|
59685
|
+
stats[accessor] = fixedValue;
|
|
59686
|
+
if (!ratio.has(accessor))
|
|
59687
|
+
ratio.set(accessor, []);
|
|
59688
|
+
(_k = ratio.get(accessor)) === null || _k === void 0 ? void 0 : _k.push(fixedValue);
|
|
59689
|
+
}
|
|
59690
|
+
}
|
|
59691
|
+
}
|
|
59692
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
59693
|
+
finally {
|
|
59694
|
+
try {
|
|
59695
|
+
if (attrs_1_1 && !attrs_1_1.done && (_e = attrs_1.return)) _e.call(attrs_1);
|
|
59696
|
+
}
|
|
59697
|
+
finally { if (e_4) throw e_4.error; }
|
|
59698
|
+
}
|
|
59699
|
+
}
|
|
59700
|
+
}
|
|
59701
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
59702
|
+
finally {
|
|
59703
|
+
try {
|
|
59704
|
+
if (_o && !_o.done && (_d = _m.return)) _d.call(_m);
|
|
59705
|
+
}
|
|
59706
|
+
finally { if (e_3) throw e_3.error; }
|
|
59707
|
+
}
|
|
59708
|
+
var highLowSort = function (a, b) { return b - a; };
|
|
59709
|
+
try {
|
|
59710
|
+
for (var _p = __values(teamStats.values()), _q = _p.next(); !_q.done; _q = _p.next()) {
|
|
59711
|
+
var stats = _q.value;
|
|
59712
|
+
try {
|
|
59713
|
+
for (var attrs_2 = (e_6 = void 0, __values(attrs)), attrs_2_1 = attrs_2.next(); !attrs_2_1.done; attrs_2_1 = attrs_2.next()) {
|
|
59714
|
+
var attr = attrs_2_1.value;
|
|
59715
|
+
var accessor = "".concat(attr, "Ratio");
|
|
59716
|
+
if (typeof stats[accessor] === 'number') {
|
|
59717
|
+
var index = (_l = ratio
|
|
59718
|
+
.get(accessor)) === null || _l === void 0 ? void 0 : _l.sort(highLowSort).indexOf(stats[accessor]);
|
|
59719
|
+
if (typeof index === 'number' && index >= 0) {
|
|
59720
|
+
var rankAccessor = "".concat(attr, "Rank");
|
|
59721
|
+
stats[rankAccessor] = index + 1;
|
|
59722
|
+
}
|
|
59723
|
+
}
|
|
59724
|
+
}
|
|
59725
|
+
}
|
|
59726
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
59727
|
+
finally {
|
|
59728
|
+
try {
|
|
59729
|
+
if (attrs_2_1 && !attrs_2_1.done && (_g = attrs_2.return)) _g.call(attrs_2);
|
|
59730
|
+
}
|
|
59731
|
+
finally { if (e_6) throw e_6.error; }
|
|
59732
|
+
}
|
|
59733
|
+
}
|
|
59734
|
+
}
|
|
59735
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
59736
|
+
finally {
|
|
59737
|
+
try {
|
|
59738
|
+
if (_q && !_q.done && (_f = _p.return)) _f.call(_p);
|
|
59739
|
+
}
|
|
59740
|
+
finally { if (e_5) throw e_5.error; }
|
|
59741
|
+
}
|
|
59742
|
+
var result = __assign({ relevantMatchUps: relevantMatchUps }, SUCCESS);
|
|
59743
|
+
if (teamParticipantId) {
|
|
59744
|
+
result.teamStats = teamStats.get(teamParticipantId);
|
|
59745
|
+
if (opponentParticipantId)
|
|
59746
|
+
result.opponentStats = teamStats.get(opponentParticipantId);
|
|
59747
|
+
}
|
|
59748
|
+
else {
|
|
59749
|
+
result.allTeamStats = __spreadArray([], __read(teamStats.values()), false);
|
|
59750
|
+
}
|
|
59751
|
+
return result;
|
|
59752
|
+
}
|
|
59753
|
+
|
|
59754
|
+
var reportGovernor = {
|
|
59755
|
+
getStructureReports: getStructureReports,
|
|
59756
|
+
getEntryStatusReports: getEntryStatusReports,
|
|
59757
|
+
getTeamStats: getTeamStats,
|
|
59758
|
+
};
|
|
59470
59759
|
|
|
59471
59760
|
function setDrawParticipantRepresentativeIds(_a) {
|
|
59472
59761
|
var representativeParticipantIds = _a.representativeParticipantIds, drawDefinition = _a.drawDefinition;
|