tods-competition-factory 0.57.0 → 0.59.2
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/tods-competition-factory.cjs.development.js +359 -208
- package/dist/tods-competition-factory.cjs.development.js.map +1 -1
- package/dist/tods-competition-factory.esm.js +359 -208
- package/dist/tods-competition-factory.esm.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 +4 -4
|
@@ -3439,6 +3439,174 @@ function getCollectionPositionMatchUps({
|
|
|
3439
3439
|
};
|
|
3440
3440
|
}
|
|
3441
3441
|
|
|
3442
|
+
function validateTieFormat({
|
|
3443
|
+
checkCollectionIds = true,
|
|
3444
|
+
tieFormat
|
|
3445
|
+
} = {}) {
|
|
3446
|
+
var _tieFormat$winCriteri, _tieFormat$winCriteri2;
|
|
3447
|
+
|
|
3448
|
+
const errors = [];
|
|
3449
|
+
|
|
3450
|
+
if (typeof tieFormat !== 'object') {
|
|
3451
|
+
errors.push('tieformat must be an object');
|
|
3452
|
+
return {
|
|
3453
|
+
error: INVALID_TIE_FORMAT,
|
|
3454
|
+
errors
|
|
3455
|
+
};
|
|
3456
|
+
}
|
|
3457
|
+
|
|
3458
|
+
if (typeof tieFormat.winCriteria !== 'object') {
|
|
3459
|
+
errors.push('tieFormat.winCriteria must be an object');
|
|
3460
|
+
return {
|
|
3461
|
+
error: INVALID_TIE_FORMAT,
|
|
3462
|
+
errors
|
|
3463
|
+
};
|
|
3464
|
+
}
|
|
3465
|
+
|
|
3466
|
+
if (!Array.isArray(tieFormat.collectionDefinitions)) {
|
|
3467
|
+
errors.push('tieFormat.collectionDefinitiosn must be an array of objects');
|
|
3468
|
+
return {
|
|
3469
|
+
error: INVALID_TIE_FORMAT,
|
|
3470
|
+
errors
|
|
3471
|
+
};
|
|
3472
|
+
}
|
|
3473
|
+
|
|
3474
|
+
const validWinCriteria = typeof ((_tieFormat$winCriteri = tieFormat.winCriteria) === null || _tieFormat$winCriteri === void 0 ? void 0 : _tieFormat$winCriteri.valueGoal) === 'number' && ((_tieFormat$winCriteri2 = tieFormat.winCriteria) === null || _tieFormat$winCriteri2 === void 0 ? void 0 : _tieFormat$winCriteri2.valueGoal) > 0;
|
|
3475
|
+
|
|
3476
|
+
if (!(validWinCriteria || tieFormat.winCriteria.aggregateValue)) {
|
|
3477
|
+
errors.push('Either non-zero valueGoal, or { aggregateValue: true } must be specified in winCriteria');
|
|
3478
|
+
return {
|
|
3479
|
+
error: INVALID_TIE_FORMAT,
|
|
3480
|
+
errors
|
|
3481
|
+
};
|
|
3482
|
+
}
|
|
3483
|
+
|
|
3484
|
+
const validCollections = tieFormat.collectionDefinitions.every(collectionDefinition => {
|
|
3485
|
+
if (typeof collectionDefinition !== 'object') {
|
|
3486
|
+
errors.push(`collectionDefinition must be an object: ${collectionDefinition}`);
|
|
3487
|
+
return false;
|
|
3488
|
+
}
|
|
3489
|
+
|
|
3490
|
+
const {
|
|
3491
|
+
collectionValueProfile,
|
|
3492
|
+
collectionGroupNumber,
|
|
3493
|
+
collectionValue,
|
|
3494
|
+
collectionId,
|
|
3495
|
+
matchUpCount,
|
|
3496
|
+
matchUpFormat,
|
|
3497
|
+
matchUpValue,
|
|
3498
|
+
matchUpType,
|
|
3499
|
+
scoreValue,
|
|
3500
|
+
setValue
|
|
3501
|
+
} = collectionDefinition;
|
|
3502
|
+
|
|
3503
|
+
if (checkCollectionIds && typeof collectionId !== 'string') {
|
|
3504
|
+
errors.push(`collectionId is not type string: ${collectionId}`);
|
|
3505
|
+
return false;
|
|
3506
|
+
}
|
|
3507
|
+
|
|
3508
|
+
if (typeof matchUpCount !== 'number') {
|
|
3509
|
+
errors.push(`matchUpCount is not type number: ${matchUpCount}`);
|
|
3510
|
+
return false;
|
|
3511
|
+
}
|
|
3512
|
+
|
|
3513
|
+
if (![SINGLES$1, DOUBLES$1].includes(matchUpType)) {
|
|
3514
|
+
errors.push(`matchUpType must be SINGLES or DOUBLES: ${matchUpType}`);
|
|
3515
|
+
return false;
|
|
3516
|
+
}
|
|
3517
|
+
|
|
3518
|
+
if (!matchUpValue && !collectionValue && !collectionValueProfile && !scoreValue && !setValue) {
|
|
3519
|
+
errors.push('Missing value definition for matchUps: matchUpValue, collectionValue, or collectionValueProfile');
|
|
3520
|
+
return false;
|
|
3521
|
+
}
|
|
3522
|
+
|
|
3523
|
+
if (matchUpValue && typeof matchUpValue !== 'number') {
|
|
3524
|
+
errors.push(`matchUpValue is not type number: ${matchUpValue}`);
|
|
3525
|
+
return false;
|
|
3526
|
+
}
|
|
3527
|
+
|
|
3528
|
+
if (collectionValue && typeof collectionValue !== 'number') {
|
|
3529
|
+
errors.push(`collectionValue is not type number: ${collectionValue}`);
|
|
3530
|
+
return false;
|
|
3531
|
+
}
|
|
3532
|
+
|
|
3533
|
+
if (collectionValueProfile) {
|
|
3534
|
+
if (!Array.isArray(collectionValueProfile)) {
|
|
3535
|
+
errors.push(`collectionValueProfile is not an array: ${collectionValueProfile}`);
|
|
3536
|
+
return false;
|
|
3537
|
+
}
|
|
3538
|
+
|
|
3539
|
+
if (collectionValueProfile.length !== matchUpCount) {
|
|
3540
|
+
errors.push(`collectionValueProfile does not align with matchUpsCount`);
|
|
3541
|
+
return false;
|
|
3542
|
+
}
|
|
3543
|
+
|
|
3544
|
+
for (const valueProfile of collectionValueProfile) {
|
|
3545
|
+
if (typeof valueProfile !== 'object') {
|
|
3546
|
+
errors.push(`valueProfile is not type object: ${valueProfile}`);
|
|
3547
|
+
return false;
|
|
3548
|
+
}
|
|
3549
|
+
|
|
3550
|
+
const {
|
|
3551
|
+
value,
|
|
3552
|
+
collectionPosition
|
|
3553
|
+
} = valueProfile;
|
|
3554
|
+
|
|
3555
|
+
if (typeof value !== 'number' || typeof collectionPosition !== 'number' || collectionPosition > matchUpCount || collectionPosition < 1) {
|
|
3556
|
+
errors.push(`Invalid value profile: value and collectionPosition must be numeric. collectionPosition cannot be greater than matchUpCount`);
|
|
3557
|
+
return false;
|
|
3558
|
+
}
|
|
3559
|
+
}
|
|
3560
|
+
|
|
3561
|
+
const collectionPositions = collectionValueProfile.map(valueProfile => valueProfile.collectionPosition);
|
|
3562
|
+
|
|
3563
|
+
if (collectionPositions.length !== unique(collectionPositions).length) {
|
|
3564
|
+
errors.push('collectionPositions are not unique');
|
|
3565
|
+
return false;
|
|
3566
|
+
}
|
|
3567
|
+
}
|
|
3568
|
+
|
|
3569
|
+
if (collectionGroupNumber && typeof collectionGroupNumber !== 'number') {
|
|
3570
|
+
errors.push(`collectionValue is not type number: ${collectionValue}`);
|
|
3571
|
+
return false;
|
|
3572
|
+
}
|
|
3573
|
+
|
|
3574
|
+
if (matchUpFormat && !matchUpFormatCode.isValid(matchUpFormat)) {
|
|
3575
|
+
errors.push(`Invalid matchUpFormat: ${matchUpFormat}`);
|
|
3576
|
+
return false;
|
|
3577
|
+
}
|
|
3578
|
+
|
|
3579
|
+
return true;
|
|
3580
|
+
});
|
|
3581
|
+
const collectionIds = tieFormat.collectionDefinitions.map(({
|
|
3582
|
+
collectionId
|
|
3583
|
+
}) => collectionId);
|
|
3584
|
+
const uniqueCollectionIds = !checkCollectionIds || collectionIds.length === unique(collectionIds).length;
|
|
3585
|
+
const valid = validCollections && validWinCriteria && uniqueCollectionIds;
|
|
3586
|
+
const result = {
|
|
3587
|
+
valid,
|
|
3588
|
+
errors
|
|
3589
|
+
};
|
|
3590
|
+
if (!valid) result.error = INVALID_TIE_FORMAT;
|
|
3591
|
+
return result;
|
|
3592
|
+
} // add collectionIds if missing
|
|
3593
|
+
|
|
3594
|
+
function checkTieFormat(tieFormat) {
|
|
3595
|
+
const result = validateTieFormat({
|
|
3596
|
+
tieFormat,
|
|
3597
|
+
checkCollectionIds: false
|
|
3598
|
+
});
|
|
3599
|
+
if (result.error) return result;
|
|
3600
|
+
|
|
3601
|
+
for (const collectionDefinition of tieFormat.collectionDefinitions) {
|
|
3602
|
+
if (!collectionDefinition.collectionId) collectionDefinition.collectionId = UUID();
|
|
3603
|
+
}
|
|
3604
|
+
|
|
3605
|
+
return {
|
|
3606
|
+
tieFormat
|
|
3607
|
+
};
|
|
3608
|
+
}
|
|
3609
|
+
|
|
3442
3610
|
/**
|
|
3443
3611
|
* Calculates the number of wins per side and winningSide. When provided with `sideAdjustments`
|
|
3444
3612
|
* will calculate prjected score and winningSide which is necessary for checking validity of score
|
|
@@ -3457,7 +3625,7 @@ function generateTieMatchUpScore({
|
|
|
3457
3625
|
tieFormat,
|
|
3458
3626
|
matchUp
|
|
3459
3627
|
}) {
|
|
3460
|
-
var _tieFormat;
|
|
3628
|
+
var _tieFormat, _tieFormat2;
|
|
3461
3629
|
|
|
3462
3630
|
if (!Array.isArray(sideAdjustments) || sideAdjustments.length !== 2 || isNaN(sideAdjustments.reduce((a, b) => a + b))) {
|
|
3463
3631
|
return {
|
|
@@ -3469,28 +3637,42 @@ function generateTieMatchUpScore({
|
|
|
3469
3637
|
error: MISSING_MATCHUP
|
|
3470
3638
|
};
|
|
3471
3639
|
tieFormat = matchUp.tieFormat || tieFormat;
|
|
3472
|
-
|
|
3640
|
+
if (!tieFormat) return {
|
|
3641
|
+
error: MISSING_TIE_FORMAT
|
|
3642
|
+
};
|
|
3643
|
+
const result = validateTieFormat({
|
|
3644
|
+
tieFormat
|
|
3645
|
+
});
|
|
3646
|
+
if (!result.valid) return {
|
|
3647
|
+
error: INVALID_VALUES,
|
|
3648
|
+
errors: result.errors
|
|
3649
|
+
};
|
|
3650
|
+
const sideTieValues = [0, 0];
|
|
3473
3651
|
const tieMatchUps = (matchUp === null || matchUp === void 0 ? void 0 : matchUp.tieMatchUps) || [];
|
|
3474
3652
|
const collectionDefinitions = ((_tieFormat = tieFormat) === null || _tieFormat === void 0 ? void 0 : _tieFormat.collectionDefinitions) || [];
|
|
3475
|
-
collectionDefinitions.forEach(collectionDefinition => {
|
|
3476
|
-
const collectionMatchUps = tieMatchUps.filter(matchUp => matchUp.collectionId === collectionDefinition.collectionId);
|
|
3477
3653
|
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
3654
|
+
for (const collectionDefinition of collectionDefinitions) {
|
|
3655
|
+
const collectionMatchUps = tieMatchUps.filter(matchUp => matchUp.collectionId === collectionDefinition.collectionId); // keep track of the values derived from matchUps
|
|
3656
|
+
|
|
3657
|
+
const sideMatchUpValues = [0, 0]; // will be equivalent to sideMatchUpValues unless there is a collectionValue,
|
|
3658
|
+
// in which case the sideMatchUpValues are used in comparision with winCriteria
|
|
3659
|
+
|
|
3660
|
+
let sideCollectionValues = [0, 0];
|
|
3661
|
+
const allCollectionMatchUpsCompleted = collectionMatchUps.every(matchUp => completedMatchUpStatuses.includes(matchUp.matchUpStatus));
|
|
3662
|
+
const {
|
|
3663
|
+
collectionValueProfile,
|
|
3664
|
+
collectionValue,
|
|
3665
|
+
matchUpValue,
|
|
3666
|
+
winCriteria,
|
|
3667
|
+
scoreValue,
|
|
3668
|
+
setValue
|
|
3669
|
+
} = collectionDefinition;
|
|
3670
|
+
|
|
3671
|
+
if (matchUpValue) {
|
|
3486
3672
|
collectionMatchUps.forEach(matchUp => {
|
|
3487
|
-
if (matchUp.winningSide)
|
|
3673
|
+
if (matchUp.winningSide) sideMatchUpValues[matchUp.winningSide - 1] += matchUpValue;
|
|
3488
3674
|
});
|
|
3489
|
-
|
|
3490
|
-
return side >= winGoal ? side + 1 : winningSide;
|
|
3491
|
-
}, undefined);
|
|
3492
|
-
if (collectionWinningSide) sidePoints[collectionWinningSide] += collectionDefinition.collectionValue;
|
|
3493
|
-
} else if (collectionDefinition.collectionValueProfile) {
|
|
3675
|
+
} else if (Array.isArray(collectionValueProfile)) {
|
|
3494
3676
|
collectionMatchUps.forEach(matchUp => {
|
|
3495
3677
|
if (matchUp.winningSide) {
|
|
3496
3678
|
const collectionPosition = matchUp.collectionPosition;
|
|
@@ -3498,12 +3680,63 @@ function generateTieMatchUpScore({
|
|
|
3498
3680
|
collectionDefinition,
|
|
3499
3681
|
collectionPosition
|
|
3500
3682
|
});
|
|
3501
|
-
|
|
3683
|
+
sideMatchUpValues[matchUp.winningSide - 1] += matchUpValue;
|
|
3502
3684
|
}
|
|
3503
3685
|
});
|
|
3686
|
+
} else if (setValue) {
|
|
3687
|
+
collectionMatchUps.forEach(matchUp => {
|
|
3688
|
+
var _matchUp$score$sets;
|
|
3689
|
+
|
|
3690
|
+
(_matchUp$score$sets = matchUp.score.sets) === null || _matchUp$score$sets === void 0 ? void 0 : _matchUp$score$sets.forEach(set => {
|
|
3691
|
+
if (set.winningSide) sideMatchUpValues[set.winningSide - 1] += setValue;
|
|
3692
|
+
});
|
|
3693
|
+
});
|
|
3694
|
+
} else if (scoreValue) {
|
|
3695
|
+
collectionMatchUps.forEach(matchUp => {
|
|
3696
|
+
var _matchUp$score$sets2;
|
|
3697
|
+
|
|
3698
|
+
(_matchUp$score$sets2 = matchUp.score.sets) === null || _matchUp$score$sets2 === void 0 ? void 0 : _matchUp$score$sets2.forEach(set => {
|
|
3699
|
+
const {
|
|
3700
|
+
scoreSide1 = 0,
|
|
3701
|
+
scoreSide2 = 0
|
|
3702
|
+
} = set;
|
|
3703
|
+
sideMatchUpValues[0] = scoreSide1;
|
|
3704
|
+
sideMatchUpValues[2] = scoreSide2;
|
|
3705
|
+
});
|
|
3706
|
+
});
|
|
3504
3707
|
}
|
|
3505
|
-
|
|
3506
|
-
|
|
3708
|
+
|
|
3709
|
+
if (collectionValue) {
|
|
3710
|
+
const sideWins = [0, 0];
|
|
3711
|
+
collectionMatchUps.forEach(matchUp => {
|
|
3712
|
+
if (matchUp.winningSide) sideWins[matchUp.winningSide - 1] += 1;
|
|
3713
|
+
});
|
|
3714
|
+
let collectionWinningSide;
|
|
3715
|
+
|
|
3716
|
+
if (winCriteria !== null && winCriteria !== void 0 && winCriteria.aggregateValue) {
|
|
3717
|
+
if (allCollectionMatchUpsCompleted && sideMatchUpValues[0] !== sideMatchUpValues[1]) {
|
|
3718
|
+
collectionWinningSide = sideMatchUpValues[0] > sideMatchUpValues[1] ? 1 : 2;
|
|
3719
|
+
}
|
|
3720
|
+
} else if (winCriteria !== null && winCriteria !== void 0 && winCriteria.valueGoal) {
|
|
3721
|
+
collectionWinningSide = sideMatchUpValues.reduce((winningSide, side, i) => {
|
|
3722
|
+
return side >= winCriteria.valueGoal ? i + 1 : winningSide;
|
|
3723
|
+
}, undefined);
|
|
3724
|
+
} else {
|
|
3725
|
+
const winGoal = Math.floor(collectionDefinition.matchUpCount / 2) + 1;
|
|
3726
|
+
collectionWinningSide = sideWins.reduce((winningSide, side, i) => {
|
|
3727
|
+
return side >= winGoal ? i + 1 : winningSide;
|
|
3728
|
+
}, undefined);
|
|
3729
|
+
}
|
|
3730
|
+
|
|
3731
|
+
if (collectionWinningSide) sideCollectionValues[collectionWinningSide - 1] += collectionValue;
|
|
3732
|
+
} else {
|
|
3733
|
+
sideCollectionValues = sideMatchUpValues;
|
|
3734
|
+
}
|
|
3735
|
+
|
|
3736
|
+
sideCollectionValues.forEach((sideCollectionValue, i) => sideTieValues[i] += sideCollectionValue);
|
|
3737
|
+
}
|
|
3738
|
+
|
|
3739
|
+
const sideScores = sideTieValues.map((sideTieValue, i) => sideTieValue + sideAdjustments[i]);
|
|
3507
3740
|
const set = {
|
|
3508
3741
|
side1Score: sideScores[0],
|
|
3509
3742
|
side2Score: sideScores[1]
|
|
@@ -3513,10 +3746,11 @@ function generateTieMatchUpScore({
|
|
|
3513
3746
|
|
|
3514
3747
|
let winningSide;
|
|
3515
3748
|
|
|
3516
|
-
if (tieFormat) {
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3749
|
+
if ((_tieFormat2 = tieFormat) !== null && _tieFormat2 !== void 0 && _tieFormat2.winCriteria) {
|
|
3750
|
+
const {
|
|
3751
|
+
valueGoal,
|
|
3752
|
+
aggregateValue
|
|
3753
|
+
} = tieFormat.winCriteria;
|
|
3520
3754
|
|
|
3521
3755
|
if (valueGoal) {
|
|
3522
3756
|
const sideThatWon = sideScores.map((points, sideIndex) => ({
|
|
@@ -3526,6 +3760,12 @@ function generateTieMatchUpScore({
|
|
|
3526
3760
|
points
|
|
3527
3761
|
}) => points >= valueGoal);
|
|
3528
3762
|
winningSide = sideThatWon === null || sideThatWon === void 0 ? void 0 : sideThatWon.sideNumber;
|
|
3763
|
+
} else if (aggregateValue) {
|
|
3764
|
+
const allTieMatchUpsCompleted = tieMatchUps.every(matchUp => completedMatchUpStatuses.includes(matchUp.matchUpStatus));
|
|
3765
|
+
|
|
3766
|
+
if (allTieMatchUpsCompleted && sideScores[0] !== sideScores[1]) {
|
|
3767
|
+
winningSide = sideScores[0] > sideScores[1] ? 1 : 2;
|
|
3768
|
+
}
|
|
3529
3769
|
}
|
|
3530
3770
|
}
|
|
3531
3771
|
|
|
@@ -3542,7 +3782,7 @@ function getCollectionPositionValue({
|
|
|
3542
3782
|
collectionPosition
|
|
3543
3783
|
}) {
|
|
3544
3784
|
const collectionValueProfile = collectionDefinition.collectionValueProfile || [];
|
|
3545
|
-
const profile = collectionValueProfile.find(profile => profile.collectionPosition === collectionPosition);
|
|
3785
|
+
const profile = collectionValueProfile === null || collectionValueProfile === void 0 ? void 0 : collectionValueProfile.find(profile => profile.collectionPosition === collectionPosition);
|
|
3546
3786
|
return profile === null || profile === void 0 ? void 0 : profile.matchUpValue;
|
|
3547
3787
|
}
|
|
3548
3788
|
|
|
@@ -3661,162 +3901,6 @@ function getHighTiebreakValue$1(params) {
|
|
|
3661
3901
|
return tiebreakTo;
|
|
3662
3902
|
}
|
|
3663
3903
|
|
|
3664
|
-
function validateTieFormat({
|
|
3665
|
-
checkCollectionIds = true,
|
|
3666
|
-
tieFormat
|
|
3667
|
-
} = {}) {
|
|
3668
|
-
const errors = [];
|
|
3669
|
-
|
|
3670
|
-
if (typeof tieFormat !== 'object') {
|
|
3671
|
-
errors.push('tieformat must be an object');
|
|
3672
|
-
return {
|
|
3673
|
-
error: INVALID_TIE_FORMAT,
|
|
3674
|
-
errors
|
|
3675
|
-
};
|
|
3676
|
-
}
|
|
3677
|
-
|
|
3678
|
-
if (typeof tieFormat.winCriteria !== 'object') {
|
|
3679
|
-
errors.push('tieFormat.winCriteria must be an object');
|
|
3680
|
-
return {
|
|
3681
|
-
error: INVALID_TIE_FORMAT,
|
|
3682
|
-
errors
|
|
3683
|
-
};
|
|
3684
|
-
}
|
|
3685
|
-
|
|
3686
|
-
if (!Array.isArray(tieFormat.collectionDefinitions)) {
|
|
3687
|
-
errors.push('tieFormat.collectionDefinitiosn must be an array of objects');
|
|
3688
|
-
return {
|
|
3689
|
-
error: INVALID_TIE_FORMAT,
|
|
3690
|
-
errors
|
|
3691
|
-
};
|
|
3692
|
-
}
|
|
3693
|
-
|
|
3694
|
-
const validWinCriteria = typeof tieFormat.winCriteria.valueGoal === 'number' && tieFormat.winCriteria.valueGoal > 0;
|
|
3695
|
-
if (!validWinCriteria) errors.push('Non-zero valueGoal must be specified in winCriteria');
|
|
3696
|
-
const validCollections = tieFormat.collectionDefinitions.every(collectionDefinition => {
|
|
3697
|
-
if (typeof collectionDefinition !== 'object') {
|
|
3698
|
-
errors.push(`collectionDefinition must be an object: ${collectionDefinition}`);
|
|
3699
|
-
return false;
|
|
3700
|
-
}
|
|
3701
|
-
|
|
3702
|
-
const {
|
|
3703
|
-
collectionValueProfile,
|
|
3704
|
-
collectionGroupNumber,
|
|
3705
|
-
collectionValue,
|
|
3706
|
-
collectionId,
|
|
3707
|
-
matchUpCount,
|
|
3708
|
-
matchUpFormat,
|
|
3709
|
-
matchUpValue,
|
|
3710
|
-
matchUpType
|
|
3711
|
-
} = collectionDefinition;
|
|
3712
|
-
|
|
3713
|
-
if (checkCollectionIds && typeof collectionId !== 'string') {
|
|
3714
|
-
errors.push(`collectionId is not type string: ${collectionId}`);
|
|
3715
|
-
return false;
|
|
3716
|
-
}
|
|
3717
|
-
|
|
3718
|
-
if (typeof matchUpCount !== 'number') {
|
|
3719
|
-
errors.push(`matchUpCount is not type number: ${matchUpCount}`);
|
|
3720
|
-
return false;
|
|
3721
|
-
}
|
|
3722
|
-
|
|
3723
|
-
if (![SINGLES$1, DOUBLES$1].includes(matchUpType)) {
|
|
3724
|
-
errors.push(`matchUpType must be SINGLES or DOUBLES: ${matchUpType}`);
|
|
3725
|
-
return false;
|
|
3726
|
-
}
|
|
3727
|
-
|
|
3728
|
-
if (!matchUpValue && !collectionValue && !collectionValueProfile) {
|
|
3729
|
-
errors.push('Missing value definition for matchUps: matchUpValue, collectionValue, or collectionValueProfile');
|
|
3730
|
-
return false;
|
|
3731
|
-
}
|
|
3732
|
-
|
|
3733
|
-
if (matchUpValue && typeof matchUpValue !== 'number') {
|
|
3734
|
-
errors.push(`matchUpValue is not type number: ${matchUpValue}`);
|
|
3735
|
-
return false;
|
|
3736
|
-
}
|
|
3737
|
-
|
|
3738
|
-
if (collectionValue && typeof collectionValue !== 'number') {
|
|
3739
|
-
errors.push(`collectionValue is not type number: ${collectionValue}`);
|
|
3740
|
-
return false;
|
|
3741
|
-
}
|
|
3742
|
-
|
|
3743
|
-
if (collectionValueProfile) {
|
|
3744
|
-
if (!Array.isArray(collectionValueProfile)) {
|
|
3745
|
-
errors.push(`collectionValueProfile is not an array: ${collectionValueProfile}`);
|
|
3746
|
-
return false;
|
|
3747
|
-
}
|
|
3748
|
-
|
|
3749
|
-
if (collectionValueProfile.length !== matchUpCount) {
|
|
3750
|
-
errors.push(`collectionValueProfile does not align with matchUpsCount`);
|
|
3751
|
-
return false;
|
|
3752
|
-
}
|
|
3753
|
-
|
|
3754
|
-
for (const valueProfile of collectionValueProfile) {
|
|
3755
|
-
if (typeof valueProfile !== 'object') {
|
|
3756
|
-
errors.push(`valueProfile is not type object: ${valueProfile}`);
|
|
3757
|
-
return false;
|
|
3758
|
-
}
|
|
3759
|
-
|
|
3760
|
-
const {
|
|
3761
|
-
value,
|
|
3762
|
-
collectionPosition
|
|
3763
|
-
} = valueProfile;
|
|
3764
|
-
|
|
3765
|
-
if (typeof value !== 'number' || typeof collectionPosition !== 'number' || collectionPosition > matchUpCount || collectionPosition < 1) {
|
|
3766
|
-
errors.push(`Invalid value profile: value and collectionPosition must be numeric. collectionPosition cannot be greater than matchUpCount`);
|
|
3767
|
-
return false;
|
|
3768
|
-
}
|
|
3769
|
-
}
|
|
3770
|
-
|
|
3771
|
-
const collectionPositions = collectionValueProfile.map(valueProfile => valueProfile.collectionPosition);
|
|
3772
|
-
|
|
3773
|
-
if (collectionPositions.length !== unique(collectionPositions).length) {
|
|
3774
|
-
errors.push('collectionPositions are not unique');
|
|
3775
|
-
return false;
|
|
3776
|
-
}
|
|
3777
|
-
}
|
|
3778
|
-
|
|
3779
|
-
if (collectionGroupNumber && typeof collectionGroupNumber !== 'number') {
|
|
3780
|
-
errors.push(`collectionValue is not type number: ${collectionValue}`);
|
|
3781
|
-
return false;
|
|
3782
|
-
}
|
|
3783
|
-
|
|
3784
|
-
if (matchUpFormat && !matchUpFormatCode.isValid(matchUpFormat)) {
|
|
3785
|
-
errors.push(`Invalid matchUpFormat: ${matchUpFormat}`);
|
|
3786
|
-
return false;
|
|
3787
|
-
}
|
|
3788
|
-
|
|
3789
|
-
return true;
|
|
3790
|
-
});
|
|
3791
|
-
const collectionIds = tieFormat.collectionDefinitions.map(({
|
|
3792
|
-
collectionId
|
|
3793
|
-
}) => collectionId);
|
|
3794
|
-
const uniqueCollectionIds = !checkCollectionIds || collectionIds.length === unique(collectionIds).length;
|
|
3795
|
-
const valid = validCollections && validWinCriteria && uniqueCollectionIds;
|
|
3796
|
-
const result = {
|
|
3797
|
-
valid,
|
|
3798
|
-
errors
|
|
3799
|
-
};
|
|
3800
|
-
if (!valid) result.error = INVALID_TIE_FORMAT;
|
|
3801
|
-
return result;
|
|
3802
|
-
} // add collectionIds if missing
|
|
3803
|
-
|
|
3804
|
-
function checkTieFormat(tieFormat) {
|
|
3805
|
-
const result = validateTieFormat({
|
|
3806
|
-
tieFormat,
|
|
3807
|
-
checkCollectionIds: false
|
|
3808
|
-
});
|
|
3809
|
-
if (result.error) return result;
|
|
3810
|
-
|
|
3811
|
-
for (const collectionDefinition of tieFormat.collectionDefinitions) {
|
|
3812
|
-
if (!collectionDefinition.collectionId) collectionDefinition.collectionId = UUID();
|
|
3813
|
-
}
|
|
3814
|
-
|
|
3815
|
-
return {
|
|
3816
|
-
tieFormat
|
|
3817
|
-
};
|
|
3818
|
-
}
|
|
3819
|
-
|
|
3820
3904
|
function getWinningSide({
|
|
3821
3905
|
analysis,
|
|
3822
3906
|
set
|
|
@@ -7479,7 +7563,9 @@ const POLICY_POSITION_ACTIONS_UNRESTRICTED = {
|
|
|
7479
7563
|
policyName: 'positionActionsUnrestricted',
|
|
7480
7564
|
// positionActions will be selectively enabled for structures matching { stages: [], stageSequences: [] }
|
|
7481
7565
|
// enabledStructures: [] => all structures are enabled
|
|
7482
|
-
enabledStructures: []
|
|
7566
|
+
enabledStructures: [],
|
|
7567
|
+
// enables entries in other flights to be accessed as alternates
|
|
7568
|
+
otherFlightEntries: true
|
|
7483
7569
|
}
|
|
7484
7570
|
};
|
|
7485
7571
|
|
|
@@ -21770,6 +21856,17 @@ function getRelevantParticipantIdsMap({
|
|
|
21770
21856
|
};
|
|
21771
21857
|
}
|
|
21772
21858
|
|
|
21859
|
+
const SCALE = 'SCALE';
|
|
21860
|
+
const RATING = 'RATING';
|
|
21861
|
+
const RANKING = 'RANKING';
|
|
21862
|
+
const SEEDING = 'SEEDING';
|
|
21863
|
+
const scaleConstants = {
|
|
21864
|
+
SCALE,
|
|
21865
|
+
RATING,
|
|
21866
|
+
RANKING,
|
|
21867
|
+
SEEDING
|
|
21868
|
+
};
|
|
21869
|
+
|
|
21773
21870
|
function addParticipantContext(params) {
|
|
21774
21871
|
var _params$tournamentEve, _params$tournamentPar;
|
|
21775
21872
|
|
|
@@ -22286,18 +22383,72 @@ function addParticipantContext(params) {
|
|
|
22286
22383
|
};
|
|
22287
22384
|
}
|
|
22288
22385
|
|
|
22386
|
+
function annotatePerson(person) {
|
|
22387
|
+
const {
|
|
22388
|
+
nationalityCode
|
|
22389
|
+
} = person || {};
|
|
22390
|
+
|
|
22391
|
+
if (nationalityCode) {
|
|
22392
|
+
const country = countries.find(({
|
|
22393
|
+
ioc
|
|
22394
|
+
}) => ioc === nationalityCode);
|
|
22395
|
+
if (country !== null && country !== void 0 && country.iso && !person.iso) person.iso = country.iso;
|
|
22396
|
+
if (country !== null && country !== void 0 && country.label && !person.countryName) person.countryName = country.label;
|
|
22397
|
+
}
|
|
22398
|
+
}
|
|
22399
|
+
|
|
22289
22400
|
function annotateParticipant({
|
|
22290
|
-
withDraws = true,
|
|
22291
22401
|
withEvents = true,
|
|
22402
|
+
withDraws = true,
|
|
22403
|
+
participantIdMap,
|
|
22404
|
+
scheduleAnalysis,
|
|
22405
|
+
withStatistics,
|
|
22292
22406
|
withOpponents,
|
|
22293
22407
|
withMatchUps,
|
|
22294
|
-
withStatistics,
|
|
22295
|
-
scheduleAnalysis,
|
|
22296
22408
|
participant,
|
|
22297
|
-
|
|
22409
|
+
withISO
|
|
22298
22410
|
}) {
|
|
22411
|
+
var _participant$timeItem;
|
|
22412
|
+
|
|
22299
22413
|
const scheduleItems = [];
|
|
22300
22414
|
const scheduleConflicts = [];
|
|
22415
|
+
|
|
22416
|
+
if (withISO) {
|
|
22417
|
+
const {
|
|
22418
|
+
person,
|
|
22419
|
+
individualParticipants
|
|
22420
|
+
} = participant;
|
|
22421
|
+
const persons = [person, individualParticipants === null || individualParticipants === void 0 ? void 0 : individualParticipants.map(({
|
|
22422
|
+
person
|
|
22423
|
+
}) => person)].flat().filter(Boolean);
|
|
22424
|
+
persons.forEach(annotatePerson);
|
|
22425
|
+
}
|
|
22426
|
+
|
|
22427
|
+
const scaleItems = (_participant$timeItem = participant.timeItems) === null || _participant$timeItem === void 0 ? void 0 : _participant$timeItem.filter(({
|
|
22428
|
+
itemType
|
|
22429
|
+
}) => itemType.startsWith(SCALE) && [RANKING, RATING].includes(itemType.split('.')[1]));
|
|
22430
|
+
|
|
22431
|
+
if (scaleItems !== null && scaleItems !== void 0 && scaleItems.length) {
|
|
22432
|
+
const latestScaleItem = scaleType => scaleItems.filter(timeItem => (timeItem === null || timeItem === void 0 ? void 0 : timeItem.itemType) === scaleType).sort((a, b) => new Date(a.createdAt || undefined) - new Date(b.createdAt || undefined)).pop();
|
|
22433
|
+
|
|
22434
|
+
for (const scaleType of unique(scaleItems.map(({
|
|
22435
|
+
itemType
|
|
22436
|
+
}) => itemType))) {
|
|
22437
|
+
const scaleItem = latestScaleItem(scaleType);
|
|
22438
|
+
|
|
22439
|
+
if (scaleItem) {
|
|
22440
|
+
const [, type, format, scaleName] = scaleItem.itemType.split('.');
|
|
22441
|
+
const scaleType = type === RANKING ? 'rankings' : 'ratings';
|
|
22442
|
+
if (!participant[scaleType]) participant[scaleType] = {};
|
|
22443
|
+
if (!participant[scaleType][format]) participant[scaleType][format] = [];
|
|
22444
|
+
participant[scaleType][format].push({
|
|
22445
|
+
scaleValue: scaleItem.itemValue,
|
|
22446
|
+
scaleName
|
|
22447
|
+
});
|
|
22448
|
+
}
|
|
22449
|
+
}
|
|
22450
|
+
}
|
|
22451
|
+
|
|
22301
22452
|
const participantId = participant === null || participant === void 0 ? void 0 : participant.participantId;
|
|
22302
22453
|
if (!participantId || !participantIdMap[participantId]) return {};
|
|
22303
22454
|
const {
|
|
@@ -22655,7 +22806,8 @@ function getTournamentParticipants({
|
|
|
22655
22806
|
withMatchUps,
|
|
22656
22807
|
withEvents,
|
|
22657
22808
|
withDraws,
|
|
22658
|
-
inContext
|
|
22809
|
+
inContext,
|
|
22810
|
+
withISO
|
|
22659
22811
|
}) {
|
|
22660
22812
|
if (!tournamentRecord) return {
|
|
22661
22813
|
error: MISSING_TOURNAMENT_RECORD
|
|
@@ -22687,7 +22839,7 @@ function getTournamentParticipants({
|
|
|
22687
22839
|
participantFilters,
|
|
22688
22840
|
participants: tournamentParticipants
|
|
22689
22841
|
});
|
|
22690
|
-
const addContext =
|
|
22842
|
+
const addContext = withScheduleItems || scheduleAnalysis || withStatistics || withGroupings || withOpponents || withMatchUps || withEvents || withDraws || withISO || inContext;
|
|
22691
22843
|
let participantIdsWithConflicts;
|
|
22692
22844
|
|
|
22693
22845
|
if (addContext) {
|
|
@@ -22703,7 +22855,8 @@ function getTournamentParticipants({
|
|
|
22703
22855
|
withOpponents,
|
|
22704
22856
|
withMatchUps,
|
|
22705
22857
|
withEvents,
|
|
22706
|
-
withDraws
|
|
22858
|
+
withDraws,
|
|
22859
|
+
withISO
|
|
22707
22860
|
});
|
|
22708
22861
|
participantIdsWithConflicts = result === null || result === void 0 ? void 0 : result.participantIdsWithConflicts;
|
|
22709
22862
|
}
|
|
@@ -23784,8 +23937,8 @@ function getEventMatchUpFormatTiming$1({
|
|
|
23784
23937
|
const {
|
|
23785
23938
|
extension
|
|
23786
23939
|
} = findEventExtension({
|
|
23787
|
-
|
|
23788
|
-
|
|
23940
|
+
name: SCHEDULE_TIMING,
|
|
23941
|
+
event
|
|
23789
23942
|
});
|
|
23790
23943
|
|
|
23791
23944
|
if (extension !== null && extension !== void 0 && extension.value) {
|
|
@@ -27714,7 +27867,7 @@ const scheduleGovernor$1 = {
|
|
|
27714
27867
|
};
|
|
27715
27868
|
|
|
27716
27869
|
function factoryVersion() {
|
|
27717
|
-
return '0.
|
|
27870
|
+
return '0.59.2';
|
|
27718
27871
|
}
|
|
27719
27872
|
|
|
27720
27873
|
function attachPolicies$2({
|
|
@@ -35876,17 +36029,6 @@ function removeDelegatedOutcome$1({
|
|
|
35876
36029
|
});
|
|
35877
36030
|
}
|
|
35878
36031
|
|
|
35879
|
-
const SCALE = 'SCALE';
|
|
35880
|
-
const RATING = 'RATING';
|
|
35881
|
-
const RANKING = 'RANKING';
|
|
35882
|
-
const SEEDING = 'SEEDING';
|
|
35883
|
-
const scaleConstants = {
|
|
35884
|
-
SCALE,
|
|
35885
|
-
RATING,
|
|
35886
|
-
RANKING,
|
|
35887
|
-
SEEDING
|
|
35888
|
-
};
|
|
35889
|
-
|
|
35890
36032
|
function participantScaleItem({
|
|
35891
36033
|
requireTimeStamp,
|
|
35892
36034
|
scaleAttributes,
|
|
@@ -36376,13 +36518,13 @@ function getScaleValue({
|
|
|
36376
36518
|
var _result$scaleItem;
|
|
36377
36519
|
|
|
36378
36520
|
const scaleAttributes = {
|
|
36379
|
-
scaleType: RATING,
|
|
36380
36521
|
eventType: eventType || SINGLES,
|
|
36522
|
+
scaleType: RATING,
|
|
36381
36523
|
scaleName
|
|
36382
36524
|
};
|
|
36383
36525
|
const result = participant && participantScaleItem({
|
|
36384
|
-
|
|
36385
|
-
|
|
36526
|
+
scaleAttributes,
|
|
36527
|
+
participant
|
|
36386
36528
|
});
|
|
36387
36529
|
return result === null || result === void 0 ? void 0 : (_result$scaleItem = result.scaleItem) === null || _result$scaleItem === void 0 ? void 0 : _result$scaleItem.scaleValue;
|
|
36388
36530
|
}
|
|
@@ -43043,7 +43185,7 @@ function replaceTieMatchUpParticipantId(params) {
|
|
|
43043
43185
|
}
|
|
43044
43186
|
}
|
|
43045
43187
|
|
|
43046
|
-
|
|
43188
|
+
modifyMatchUpNotice({
|
|
43047
43189
|
drawDefinition,
|
|
43048
43190
|
matchUp: dualMatchUp
|
|
43049
43191
|
});
|
|
@@ -49098,6 +49240,7 @@ function generateParticipants({
|
|
|
49098
49240
|
personData,
|
|
49099
49241
|
sex,
|
|
49100
49242
|
inContext,
|
|
49243
|
+
withISO,
|
|
49101
49244
|
rankingRange = [1, 100],
|
|
49102
49245
|
// range of ranking positions to generate
|
|
49103
49246
|
scaledParticipantsCount // number of participants to assign rankings/ratings
|
|
@@ -49282,6 +49425,14 @@ function generateParticipants({
|
|
|
49282
49425
|
}
|
|
49283
49426
|
});
|
|
49284
49427
|
|
|
49428
|
+
if (withISO && nationalityCode) {
|
|
49429
|
+
const country = countries.find(({
|
|
49430
|
+
ioc
|
|
49431
|
+
}) => ioc === nationalityCode);
|
|
49432
|
+
if (country !== null && country !== void 0 && country.iso) participant.person.iso = country.iso;
|
|
49433
|
+
if (country !== null && country !== void 0 && country.label) participant.person.countryName = country.label;
|
|
49434
|
+
}
|
|
49435
|
+
|
|
49285
49436
|
if (category) {
|
|
49286
49437
|
const singlesRanking = singlesRankings[participantIndex];
|
|
49287
49438
|
const doublesRanking = doublesRankings[participantIndex];
|