tods-competition-factory 1.8.18 → 1.8.20
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.mjs +148 -29
- package/dist/forge/generate.mjs.map +1 -1
- package/dist/forge/query.d.ts +5 -1
- package/dist/forge/query.mjs +13 -5
- package/dist/forge/query.mjs.map +1 -1
- package/dist/forge/transform.mjs +239 -167
- package/dist/forge/transform.mjs.map +1 -1
- package/dist/index.mjs +470 -398
- package/dist/index.mjs.map +1 -1
- package/dist/tods-competition-factory.development.cjs.js +585 -504
- 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
package/dist/forge/transform.mjs
CHANGED
|
@@ -1588,28 +1588,53 @@ function getCategoryAgeDetails(params) {
|
|
|
1588
1588
|
return result;
|
|
1589
1589
|
}
|
|
1590
1590
|
|
|
1591
|
+
function validateCategory({ category }) {
|
|
1592
|
+
if (!isObject(category))
|
|
1593
|
+
return { error: INVALID_VALUES };
|
|
1594
|
+
const categoryDetails = getCategoryAgeDetails({ category });
|
|
1595
|
+
if (categoryDetails.error)
|
|
1596
|
+
return { error: categoryDetails };
|
|
1597
|
+
const { ratingMax, ratingMin } = category;
|
|
1598
|
+
if (ratingMax && !isNumeric(ratingMax))
|
|
1599
|
+
return decorateResult({
|
|
1600
|
+
result: { error: INVALID_VALUES },
|
|
1601
|
+
context: { ratingMax }
|
|
1602
|
+
});
|
|
1603
|
+
if (ratingMin && !isNumeric(ratingMin))
|
|
1604
|
+
return decorateResult({
|
|
1605
|
+
result: { error: INVALID_VALUES },
|
|
1606
|
+
context: { ratingMin }
|
|
1607
|
+
});
|
|
1608
|
+
return { ...categoryDetails };
|
|
1609
|
+
}
|
|
1610
|
+
|
|
1591
1611
|
function categoryCanContain({
|
|
1592
1612
|
childCategory,
|
|
1593
1613
|
withDetails,
|
|
1594
1614
|
category
|
|
1595
1615
|
}) {
|
|
1596
|
-
const categoryDetails =
|
|
1597
|
-
const childCategoryDetails =
|
|
1616
|
+
const categoryDetails = validateCategory({ category });
|
|
1617
|
+
const childCategoryDetails = validateCategory({
|
|
1598
1618
|
category: childCategory
|
|
1599
1619
|
});
|
|
1600
1620
|
const invalidAgeMin = childCategoryDetails.ageMin && (categoryDetails.ageMin && childCategoryDetails.ageMin < categoryDetails.ageMin || categoryDetails.ageMax && childCategoryDetails.ageMin > categoryDetails.ageMax);
|
|
1601
1621
|
const invalidAgeMax = childCategoryDetails.ageMax && (categoryDetails.ageMax && childCategoryDetails.ageMax > categoryDetails.ageMax || categoryDetails.ageMin && childCategoryDetails.ageMax < categoryDetails.ageMin);
|
|
1602
1622
|
const invalidAgeMinDate = childCategoryDetails.ageMinDate && categoryDetails.ageMaxDate && new Date(childCategoryDetails.ageMinDate) > new Date(categoryDetails.ageMaxDate);
|
|
1603
1623
|
const invalidAgeMaxDate = childCategoryDetails.ageMaxDate && categoryDetails.ageMinDate && new Date(childCategoryDetails.ageMaxDate) < new Date(categoryDetails.ageMinDate);
|
|
1604
|
-
const
|
|
1624
|
+
const ratingComparison = category.ratingType && childCategory.ratingType && category.ratingType === childCategory.ratingType;
|
|
1625
|
+
const invalidRatingRange = ratingComparison && (category.ratingMin && childCategory.ratingMin && childCategory.ratingMin < category.ratingMin || category.ratingMax && childCategory.ratingMax && childCategory.ratingMax > category.ratingMax || category.ratingMin && childCategory.ratingMax && childCategory.ratingMax < category.ratingMin || category.ratingMax && childCategory.ratingMin && childCategory.ratingMin > category.ratingMax);
|
|
1626
|
+
const invalidBallType = category.ballType && childCategory.ballType && category.ballType !== childCategory.ballType;
|
|
1627
|
+
const valid = !invalidRatingRange && !invalidAgeMinDate && !invalidAgeMaxDate && !invalidBallType && !invalidAgeMax && !invalidAgeMin;
|
|
1605
1628
|
const ignoreFalse = true;
|
|
1606
1629
|
const result = definedAttributes(
|
|
1607
1630
|
{
|
|
1608
|
-
|
|
1631
|
+
invalidRatingRange,
|
|
1632
|
+
invalidAgeMinDate,
|
|
1633
|
+
invalidAgeMaxDate,
|
|
1634
|
+
invalidBallType,
|
|
1609
1635
|
invalidAgeMax,
|
|
1610
1636
|
invalidAgeMin,
|
|
1611
|
-
|
|
1612
|
-
invalidAgeMaxDate
|
|
1637
|
+
valid
|
|
1613
1638
|
},
|
|
1614
1639
|
ignoreFalse
|
|
1615
1640
|
);
|
|
@@ -2091,8 +2116,8 @@ function validateCollectionDefinition({
|
|
|
2091
2116
|
if (checkGender && referenceGender && gender && [GenderEnum.Male, GenderEnum.Female].includes(referenceGender) && referenceGender !== gender) {
|
|
2092
2117
|
errors.push(`Invalid gender: ${gender}`);
|
|
2093
2118
|
return decorateResult({
|
|
2119
|
+
result: { error: INVALID_GENDER, errors },
|
|
2094
2120
|
context: { referenceGender, gender },
|
|
2095
|
-
result: { error: INVALID_GENDER },
|
|
2096
2121
|
stack
|
|
2097
2122
|
});
|
|
2098
2123
|
}
|
|
@@ -3250,142 +3275,6 @@ function tallyParticipantResults({
|
|
|
3250
3275
|
return result;
|
|
3251
3276
|
}
|
|
3252
3277
|
|
|
3253
|
-
function evaluateCollectionResult({
|
|
3254
|
-
collectionDefinition,
|
|
3255
|
-
groupValueNumbers,
|
|
3256
|
-
groupValueGroups,
|
|
3257
|
-
sideTieValues,
|
|
3258
|
-
tieMatchUps
|
|
3259
|
-
}) {
|
|
3260
|
-
const collectionMatchUps = tieMatchUps.filter(
|
|
3261
|
-
(matchUp) => matchUp.collectionId === collectionDefinition.collectionId
|
|
3262
|
-
);
|
|
3263
|
-
const sideMatchUpValues = [0, 0];
|
|
3264
|
-
let sideCollectionValues = [0, 0];
|
|
3265
|
-
const allCollectionMatchUpsCompleted = collectionMatchUps.every(
|
|
3266
|
-
(matchUp) => completedMatchUpStatuses.includes(matchUp.matchUpStatus)
|
|
3267
|
-
);
|
|
3268
|
-
const {
|
|
3269
|
-
collectionValueProfiles,
|
|
3270
|
-
collectionGroupNumber,
|
|
3271
|
-
collectionValue,
|
|
3272
|
-
matchUpValue,
|
|
3273
|
-
winCriteria,
|
|
3274
|
-
scoreValue,
|
|
3275
|
-
setValue
|
|
3276
|
-
} = collectionDefinition;
|
|
3277
|
-
const belongsToValueGroup = collectionGroupNumber && groupValueNumbers.includes(collectionGroupNumber);
|
|
3278
|
-
const sideWins = [0, 0];
|
|
3279
|
-
collectionMatchUps.forEach((matchUp) => {
|
|
3280
|
-
if (matchUp.winningSide)
|
|
3281
|
-
sideWins[matchUp.winningSide - 1] += 1;
|
|
3282
|
-
});
|
|
3283
|
-
if (isConvertableInteger(matchUpValue)) {
|
|
3284
|
-
collectionMatchUps.forEach((matchUp) => {
|
|
3285
|
-
if (matchUp.winningSide) {
|
|
3286
|
-
sideMatchUpValues[matchUp.winningSide - 1] += matchUpValue;
|
|
3287
|
-
}
|
|
3288
|
-
});
|
|
3289
|
-
} else if (isConvertableInteger(setValue)) {
|
|
3290
|
-
collectionMatchUps.forEach((matchUp) => {
|
|
3291
|
-
matchUp.score?.sets?.forEach((set) => {
|
|
3292
|
-
if (set.winningSide)
|
|
3293
|
-
sideMatchUpValues[set.winningSide - 1] += setValue;
|
|
3294
|
-
});
|
|
3295
|
-
});
|
|
3296
|
-
} else if (isConvertableInteger(scoreValue)) {
|
|
3297
|
-
collectionMatchUps.forEach((matchUp) => {
|
|
3298
|
-
matchUp.score?.sets?.forEach((set) => {
|
|
3299
|
-
const {
|
|
3300
|
-
side1TiebreakScore = 0,
|
|
3301
|
-
side2TiebreakScore = 0,
|
|
3302
|
-
side1Score = 0,
|
|
3303
|
-
side2Score = 0
|
|
3304
|
-
} = set;
|
|
3305
|
-
if (matchUp.matchUpStatus === COMPLETED || matchUp.winningSide || set.winningSide) {
|
|
3306
|
-
if (side1Score || side2Score) {
|
|
3307
|
-
sideMatchUpValues[0] += side1Score;
|
|
3308
|
-
sideMatchUpValues[1] += side2Score;
|
|
3309
|
-
} else if ((side1TiebreakScore || side2TiebreakScore) && set.winningSide) {
|
|
3310
|
-
sideMatchUpValues[set.winningSide - 1] += 1;
|
|
3311
|
-
}
|
|
3312
|
-
}
|
|
3313
|
-
});
|
|
3314
|
-
});
|
|
3315
|
-
} else if (Array.isArray(collectionValueProfiles)) {
|
|
3316
|
-
collectionMatchUps.forEach((matchUp) => {
|
|
3317
|
-
if (matchUp.winningSide) {
|
|
3318
|
-
const collectionPosition = matchUp.collectionPosition;
|
|
3319
|
-
const matchUpValue2 = getCollectionPositionValue({
|
|
3320
|
-
collectionDefinition,
|
|
3321
|
-
collectionPosition
|
|
3322
|
-
});
|
|
3323
|
-
if (isConvertableInteger(matchUpValue2)) {
|
|
3324
|
-
sideMatchUpValues[matchUp.winningSide - 1] += matchUpValue2;
|
|
3325
|
-
}
|
|
3326
|
-
}
|
|
3327
|
-
});
|
|
3328
|
-
}
|
|
3329
|
-
if (isConvertableInteger(collectionValue)) {
|
|
3330
|
-
let collectionWinningSide;
|
|
3331
|
-
if (winCriteria?.aggregateValue) {
|
|
3332
|
-
if (allCollectionMatchUpsCompleted) {
|
|
3333
|
-
if (isConvertableInteger(matchUpValue || setValue || scoreValue) && sideMatchUpValues[0] !== sideMatchUpValues[1]) {
|
|
3334
|
-
collectionWinningSide = sideMatchUpValues[0] > sideMatchUpValues[1] ? 1 : 2;
|
|
3335
|
-
} else if (sideWins[0] !== sideWins[1]) {
|
|
3336
|
-
collectionWinningSide = sideWins[0] > sideWins[1] ? 1 : 2;
|
|
3337
|
-
}
|
|
3338
|
-
}
|
|
3339
|
-
} else if (winCriteria?.valueGoal) {
|
|
3340
|
-
collectionWinningSide = sideMatchUpValues.reduce(
|
|
3341
|
-
(winningSide, side, i) => {
|
|
3342
|
-
return side >= winCriteria.valueGoal ? i + 1 : winningSide;
|
|
3343
|
-
},
|
|
3344
|
-
0
|
|
3345
|
-
);
|
|
3346
|
-
} else {
|
|
3347
|
-
const winGoal = Math.floor(collectionDefinition.matchUpCount / 2) + 1;
|
|
3348
|
-
collectionWinningSide = sideWins.reduce((winningSide, side, i) => {
|
|
3349
|
-
return side >= winGoal ? i + 1 : winningSide;
|
|
3350
|
-
}, 0);
|
|
3351
|
-
}
|
|
3352
|
-
if (collectionWinningSide) {
|
|
3353
|
-
if (belongsToValueGroup) {
|
|
3354
|
-
groupValueGroups[collectionGroupNumber].values[collectionWinningSide - 1] += collectionValue;
|
|
3355
|
-
} else {
|
|
3356
|
-
sideCollectionValues[collectionWinningSide - 1] += collectionValue;
|
|
3357
|
-
}
|
|
3358
|
-
}
|
|
3359
|
-
} else {
|
|
3360
|
-
if (belongsToValueGroup) {
|
|
3361
|
-
groupValueGroups[collectionGroupNumber].values[0] += sideMatchUpValues[0] || 0;
|
|
3362
|
-
groupValueGroups[collectionGroupNumber].values[1] += sideMatchUpValues[1] || 0;
|
|
3363
|
-
} else {
|
|
3364
|
-
sideCollectionValues = sideMatchUpValues;
|
|
3365
|
-
}
|
|
3366
|
-
}
|
|
3367
|
-
if (!belongsToValueGroup) {
|
|
3368
|
-
sideCollectionValues.forEach(
|
|
3369
|
-
(sideCollectionValue, i) => sideTieValues[i] += sideCollectionValue || 0
|
|
3370
|
-
);
|
|
3371
|
-
} else {
|
|
3372
|
-
groupValueGroups[collectionGroupNumber].sideWins[0] += sideWins[0] || 0;
|
|
3373
|
-
groupValueGroups[collectionGroupNumber].sideWins[1] += sideWins[1] || 0;
|
|
3374
|
-
groupValueGroups[collectionGroupNumber].allGroupMatchUpsCompleted = groupValueGroups[collectionGroupNumber].allGroupMatchUpsCompleted && allCollectionMatchUpsCompleted;
|
|
3375
|
-
groupValueGroups[collectionGroupNumber].matchUpsCount += collectionMatchUps.length;
|
|
3376
|
-
}
|
|
3377
|
-
}
|
|
3378
|
-
function getCollectionPositionValue({
|
|
3379
|
-
collectionDefinition,
|
|
3380
|
-
collectionPosition
|
|
3381
|
-
}) {
|
|
3382
|
-
const collectionValueProfiles = collectionDefinition.collectionValueProfiles || [];
|
|
3383
|
-
const profile = collectionValueProfiles?.find(
|
|
3384
|
-
(profile2) => profile2.collectionPosition === collectionPosition
|
|
3385
|
-
);
|
|
3386
|
-
return profile?.matchUpValue;
|
|
3387
|
-
}
|
|
3388
|
-
|
|
3389
3278
|
function getAppliedPolicies({
|
|
3390
3279
|
onlySpecifiedPolicyTypes = false,
|
|
3391
3280
|
policyTypes = [],
|
|
@@ -6501,7 +6390,7 @@ function getAllStructureMatchUps({
|
|
|
6501
6390
|
}
|
|
6502
6391
|
}
|
|
6503
6392
|
|
|
6504
|
-
function
|
|
6393
|
+
function findDrawMatchUp({
|
|
6505
6394
|
tournamentParticipants,
|
|
6506
6395
|
afterRecoveryTimes,
|
|
6507
6396
|
contextContent,
|
|
@@ -6542,6 +6431,142 @@ function findMatchUp({
|
|
|
6542
6431
|
return { error: MATCHUP_NOT_FOUND };
|
|
6543
6432
|
}
|
|
6544
6433
|
|
|
6434
|
+
function evaluateCollectionResult({
|
|
6435
|
+
collectionDefinition,
|
|
6436
|
+
groupValueNumbers,
|
|
6437
|
+
groupValueGroups,
|
|
6438
|
+
sideTieValues,
|
|
6439
|
+
tieMatchUps
|
|
6440
|
+
}) {
|
|
6441
|
+
const collectionMatchUps = tieMatchUps.filter(
|
|
6442
|
+
(matchUp) => matchUp.collectionId === collectionDefinition.collectionId
|
|
6443
|
+
);
|
|
6444
|
+
const sideMatchUpValues = [0, 0];
|
|
6445
|
+
let sideCollectionValues = [0, 0];
|
|
6446
|
+
const allCollectionMatchUpsCompleted = collectionMatchUps.every(
|
|
6447
|
+
(matchUp) => completedMatchUpStatuses.includes(matchUp.matchUpStatus)
|
|
6448
|
+
);
|
|
6449
|
+
const {
|
|
6450
|
+
collectionValueProfiles,
|
|
6451
|
+
collectionGroupNumber,
|
|
6452
|
+
collectionValue,
|
|
6453
|
+
matchUpValue,
|
|
6454
|
+
winCriteria,
|
|
6455
|
+
scoreValue,
|
|
6456
|
+
setValue
|
|
6457
|
+
} = collectionDefinition;
|
|
6458
|
+
const belongsToValueGroup = collectionGroupNumber && groupValueNumbers.includes(collectionGroupNumber);
|
|
6459
|
+
const sideWins = [0, 0];
|
|
6460
|
+
collectionMatchUps.forEach((matchUp) => {
|
|
6461
|
+
if (matchUp.winningSide)
|
|
6462
|
+
sideWins[matchUp.winningSide - 1] += 1;
|
|
6463
|
+
});
|
|
6464
|
+
if (isConvertableInteger(matchUpValue)) {
|
|
6465
|
+
collectionMatchUps.forEach((matchUp) => {
|
|
6466
|
+
if (matchUp.winningSide) {
|
|
6467
|
+
sideMatchUpValues[matchUp.winningSide - 1] += matchUpValue;
|
|
6468
|
+
}
|
|
6469
|
+
});
|
|
6470
|
+
} else if (isConvertableInteger(setValue)) {
|
|
6471
|
+
collectionMatchUps.forEach((matchUp) => {
|
|
6472
|
+
matchUp.score?.sets?.forEach((set) => {
|
|
6473
|
+
if (set.winningSide)
|
|
6474
|
+
sideMatchUpValues[set.winningSide - 1] += setValue;
|
|
6475
|
+
});
|
|
6476
|
+
});
|
|
6477
|
+
} else if (isConvertableInteger(scoreValue)) {
|
|
6478
|
+
collectionMatchUps.forEach((matchUp) => {
|
|
6479
|
+
matchUp.score?.sets?.forEach((set) => {
|
|
6480
|
+
const {
|
|
6481
|
+
side1TiebreakScore = 0,
|
|
6482
|
+
side2TiebreakScore = 0,
|
|
6483
|
+
side1Score = 0,
|
|
6484
|
+
side2Score = 0
|
|
6485
|
+
} = set;
|
|
6486
|
+
if (matchUp.matchUpStatus === COMPLETED || matchUp.winningSide || set.winningSide) {
|
|
6487
|
+
if (side1Score || side2Score) {
|
|
6488
|
+
sideMatchUpValues[0] += side1Score;
|
|
6489
|
+
sideMatchUpValues[1] += side2Score;
|
|
6490
|
+
} else if ((side1TiebreakScore || side2TiebreakScore) && set.winningSide) {
|
|
6491
|
+
sideMatchUpValues[set.winningSide - 1] += 1;
|
|
6492
|
+
}
|
|
6493
|
+
}
|
|
6494
|
+
});
|
|
6495
|
+
});
|
|
6496
|
+
} else if (Array.isArray(collectionValueProfiles)) {
|
|
6497
|
+
collectionMatchUps.forEach((matchUp) => {
|
|
6498
|
+
if (matchUp.winningSide) {
|
|
6499
|
+
const collectionPosition = matchUp.collectionPosition;
|
|
6500
|
+
const matchUpValue2 = getCollectionPositionValue({
|
|
6501
|
+
collectionDefinition,
|
|
6502
|
+
collectionPosition
|
|
6503
|
+
});
|
|
6504
|
+
if (isConvertableInteger(matchUpValue2)) {
|
|
6505
|
+
sideMatchUpValues[matchUp.winningSide - 1] += matchUpValue2;
|
|
6506
|
+
}
|
|
6507
|
+
}
|
|
6508
|
+
});
|
|
6509
|
+
}
|
|
6510
|
+
if (isConvertableInteger(collectionValue)) {
|
|
6511
|
+
let collectionWinningSide;
|
|
6512
|
+
if (winCriteria?.aggregateValue) {
|
|
6513
|
+
if (allCollectionMatchUpsCompleted) {
|
|
6514
|
+
if (isConvertableInteger(matchUpValue || setValue || scoreValue) && sideMatchUpValues[0] !== sideMatchUpValues[1]) {
|
|
6515
|
+
collectionWinningSide = sideMatchUpValues[0] > sideMatchUpValues[1] ? 1 : 2;
|
|
6516
|
+
} else if (sideWins[0] !== sideWins[1]) {
|
|
6517
|
+
collectionWinningSide = sideWins[0] > sideWins[1] ? 1 : 2;
|
|
6518
|
+
}
|
|
6519
|
+
}
|
|
6520
|
+
} else if (winCriteria?.valueGoal) {
|
|
6521
|
+
collectionWinningSide = sideMatchUpValues.reduce(
|
|
6522
|
+
(winningSide, side, i) => {
|
|
6523
|
+
return side >= winCriteria.valueGoal ? i + 1 : winningSide;
|
|
6524
|
+
},
|
|
6525
|
+
0
|
|
6526
|
+
);
|
|
6527
|
+
} else {
|
|
6528
|
+
const winGoal = Math.floor(collectionDefinition.matchUpCount / 2) + 1;
|
|
6529
|
+
collectionWinningSide = sideWins.reduce((winningSide, side, i) => {
|
|
6530
|
+
return side >= winGoal ? i + 1 : winningSide;
|
|
6531
|
+
}, 0);
|
|
6532
|
+
}
|
|
6533
|
+
if (collectionWinningSide) {
|
|
6534
|
+
if (belongsToValueGroup) {
|
|
6535
|
+
groupValueGroups[collectionGroupNumber].values[collectionWinningSide - 1] += collectionValue;
|
|
6536
|
+
} else {
|
|
6537
|
+
sideCollectionValues[collectionWinningSide - 1] += collectionValue;
|
|
6538
|
+
}
|
|
6539
|
+
}
|
|
6540
|
+
} else {
|
|
6541
|
+
if (belongsToValueGroup) {
|
|
6542
|
+
groupValueGroups[collectionGroupNumber].values[0] += sideMatchUpValues[0] || 0;
|
|
6543
|
+
groupValueGroups[collectionGroupNumber].values[1] += sideMatchUpValues[1] || 0;
|
|
6544
|
+
} else {
|
|
6545
|
+
sideCollectionValues = sideMatchUpValues;
|
|
6546
|
+
}
|
|
6547
|
+
}
|
|
6548
|
+
if (!belongsToValueGroup) {
|
|
6549
|
+
sideCollectionValues.forEach(
|
|
6550
|
+
(sideCollectionValue, i) => sideTieValues[i] += sideCollectionValue || 0
|
|
6551
|
+
);
|
|
6552
|
+
} else {
|
|
6553
|
+
groupValueGroups[collectionGroupNumber].sideWins[0] += sideWins[0] || 0;
|
|
6554
|
+
groupValueGroups[collectionGroupNumber].sideWins[1] += sideWins[1] || 0;
|
|
6555
|
+
groupValueGroups[collectionGroupNumber].allGroupMatchUpsCompleted = groupValueGroups[collectionGroupNumber].allGroupMatchUpsCompleted && allCollectionMatchUpsCompleted;
|
|
6556
|
+
groupValueGroups[collectionGroupNumber].matchUpsCount += collectionMatchUps.length;
|
|
6557
|
+
}
|
|
6558
|
+
}
|
|
6559
|
+
function getCollectionPositionValue({
|
|
6560
|
+
collectionDefinition,
|
|
6561
|
+
collectionPosition
|
|
6562
|
+
}) {
|
|
6563
|
+
const collectionValueProfiles = collectionDefinition.collectionValueProfiles || [];
|
|
6564
|
+
const profile = collectionValueProfiles?.find(
|
|
6565
|
+
(profile2) => profile2.collectionPosition === collectionPosition
|
|
6566
|
+
);
|
|
6567
|
+
return profile?.matchUpValue;
|
|
6568
|
+
}
|
|
6569
|
+
|
|
6545
6570
|
function getGroupValueGroups({
|
|
6546
6571
|
collectionGroups = []
|
|
6547
6572
|
}) {
|
|
@@ -6655,7 +6680,7 @@ function generateTieMatchUpScore(params) {
|
|
|
6655
6680
|
}
|
|
6656
6681
|
if (!winningSide && tallyDirectives) {
|
|
6657
6682
|
const matchUpId = matchUp.matchUpId;
|
|
6658
|
-
const inContextMatchUp = matchUp.hasContext ? matchUp : matchUpsMap?.drawMatchUps?.[matchUpId] || drawDefinition &&
|
|
6683
|
+
const inContextMatchUp = matchUp.hasContext ? matchUp : matchUpsMap?.drawMatchUps?.[matchUpId] || drawDefinition && findDrawMatchUp({
|
|
6659
6684
|
inContext: true,
|
|
6660
6685
|
drawDefinition,
|
|
6661
6686
|
matchUpId
|
|
@@ -7807,8 +7832,8 @@ function updateInContextMatchUp({ tournamentId, inContextMatchUp }) {
|
|
|
7807
7832
|
return { error: MISSING_MATCHUP };
|
|
7808
7833
|
}
|
|
7809
7834
|
addNotice({
|
|
7810
|
-
topic: UPDATE_INCONTEXT_MATCHUP,
|
|
7811
7835
|
payload: { inContextMatchUp, tournamentId },
|
|
7836
|
+
topic: UPDATE_INCONTEXT_MATCHUP,
|
|
7812
7837
|
key: inContextMatchUp.matchUpId
|
|
7813
7838
|
});
|
|
7814
7839
|
return { ...SUCCESS };
|
|
@@ -11277,6 +11302,48 @@ function includesMatchUpStatuses({
|
|
|
11277
11302
|
};
|
|
11278
11303
|
}
|
|
11279
11304
|
|
|
11305
|
+
function ensureSideLineUps({
|
|
11306
|
+
inContextDualMatchUp,
|
|
11307
|
+
drawDefinition,
|
|
11308
|
+
tournamentId,
|
|
11309
|
+
dualMatchUp,
|
|
11310
|
+
eventId
|
|
11311
|
+
}) {
|
|
11312
|
+
if (dualMatchUp && !dualMatchUp?.sides?.length) {
|
|
11313
|
+
if (!inContextDualMatchUp) {
|
|
11314
|
+
inContextDualMatchUp = findDrawMatchUp({
|
|
11315
|
+
matchUpId: dualMatchUp.matchUpId,
|
|
11316
|
+
inContext: true,
|
|
11317
|
+
drawDefinition
|
|
11318
|
+
})?.matchUp;
|
|
11319
|
+
}
|
|
11320
|
+
const { extension } = findExtension$1({
|
|
11321
|
+
element: drawDefinition,
|
|
11322
|
+
name: LINEUPS
|
|
11323
|
+
});
|
|
11324
|
+
const lineUps = makeDeepCopy(extension?.value || {}, false, true);
|
|
11325
|
+
const extractSideDetail = ({
|
|
11326
|
+
displaySideNumber,
|
|
11327
|
+
drawPosition,
|
|
11328
|
+
sideNumber
|
|
11329
|
+
}) => ({ drawPosition, sideNumber, displaySideNumber });
|
|
11330
|
+
dualMatchUp.sides = inContextDualMatchUp?.sides?.map((side) => {
|
|
11331
|
+
const participantId = side.participantId;
|
|
11332
|
+
return {
|
|
11333
|
+
...extractSideDetail(side),
|
|
11334
|
+
lineUp: participantId && lineUps[participantId] || []
|
|
11335
|
+
};
|
|
11336
|
+
});
|
|
11337
|
+
modifyMatchUpNotice({
|
|
11338
|
+
context: "ensureSidLineUps",
|
|
11339
|
+
matchUp: dualMatchUp,
|
|
11340
|
+
drawDefinition,
|
|
11341
|
+
tournamentId,
|
|
11342
|
+
eventId
|
|
11343
|
+
});
|
|
11344
|
+
}
|
|
11345
|
+
}
|
|
11346
|
+
|
|
11280
11347
|
function copyTieFormat(tieFormat) {
|
|
11281
11348
|
if (!tieFormat)
|
|
11282
11349
|
return void 0;
|
|
@@ -11403,7 +11470,7 @@ function modifyMatchUpScore({
|
|
|
11403
11470
|
const isDualMatchUp = matchUp.matchUpType === TEAM$2;
|
|
11404
11471
|
if (isDualMatchUp && drawDefinition) {
|
|
11405
11472
|
if (matchUpId && matchUp.matchUpId !== matchUpId) {
|
|
11406
|
-
const findResult =
|
|
11473
|
+
const findResult = findDrawMatchUp({
|
|
11407
11474
|
drawDefinition,
|
|
11408
11475
|
matchUpId,
|
|
11409
11476
|
event
|
|
@@ -11432,7 +11499,7 @@ function modifyMatchUpScore({
|
|
|
11432
11499
|
if (removeWinningSide)
|
|
11433
11500
|
matchUp.winningSide = void 0;
|
|
11434
11501
|
if (!structure && drawDefinition) {
|
|
11435
|
-
({ structure } =
|
|
11502
|
+
({ structure } = findDrawMatchUp({
|
|
11436
11503
|
drawDefinition,
|
|
11437
11504
|
matchUpId,
|
|
11438
11505
|
event
|
|
@@ -11548,7 +11615,7 @@ function updateTieMatchUpScore({
|
|
|
11548
11615
|
matchUpId,
|
|
11549
11616
|
event
|
|
11550
11617
|
}) {
|
|
11551
|
-
const result =
|
|
11618
|
+
const result = findDrawMatchUp({ drawDefinition, event, matchUpId });
|
|
11552
11619
|
if (result.error)
|
|
11553
11620
|
return result;
|
|
11554
11621
|
if (!result.matchUp)
|
|
@@ -11556,6 +11623,12 @@ function updateTieMatchUpScore({
|
|
|
11556
11623
|
const { matchUp, structure } = result;
|
|
11557
11624
|
if (!matchUp.tieMatchUps)
|
|
11558
11625
|
return { error: INVALID_MATCHUP };
|
|
11626
|
+
ensureSideLineUps({
|
|
11627
|
+
tournamentId: tournamentRecord?.tournamentId,
|
|
11628
|
+
eventId: event?.eventId,
|
|
11629
|
+
dualMatchUp: matchUp,
|
|
11630
|
+
drawDefinition
|
|
11631
|
+
});
|
|
11559
11632
|
const { extension } = findExtension({
|
|
11560
11633
|
name: DISABLE_AUTO_CALC,
|
|
11561
11634
|
element: matchUp
|
|
@@ -12433,8 +12506,8 @@ function updateSideLineUp({
|
|
|
12433
12506
|
element: drawDefinition,
|
|
12434
12507
|
name: LINEUPS
|
|
12435
12508
|
});
|
|
12436
|
-
const
|
|
12437
|
-
const lineUp =
|
|
12509
|
+
const lineUps = existingExtension?.value || {};
|
|
12510
|
+
const lineUp = makeDeepCopy(lineUps[teamParticipantId], false, true);
|
|
12438
12511
|
if (sideExists) {
|
|
12439
12512
|
matchUp?.sides?.forEach((side) => {
|
|
12440
12513
|
if (side.sideNumber === drawPositionSideNumber) {
|
|
@@ -12449,13 +12522,12 @@ function updateSideLineUp({
|
|
|
12449
12522
|
const targetSide = matchUp.sides.find(
|
|
12450
12523
|
(side) => side.sideNumber === drawPositionSideNumber
|
|
12451
12524
|
);
|
|
12452
|
-
if (targetSide)
|
|
12525
|
+
if (targetSide)
|
|
12453
12526
|
targetSide.lineUp = lineUp;
|
|
12454
|
-
}
|
|
12455
12527
|
}
|
|
12456
12528
|
modifyMatchUpNotice({
|
|
12457
12529
|
tournamentId: tournamentRecord?.tournamentId,
|
|
12458
|
-
context: "
|
|
12530
|
+
context: "updateSidLineUp",
|
|
12459
12531
|
eventId: event?.eventId,
|
|
12460
12532
|
drawDefinition,
|
|
12461
12533
|
matchUp
|
|
@@ -13270,10 +13342,10 @@ function removeLineUpSubstitutions({ lineUp }) {
|
|
|
13270
13342
|
const participantAssignments = {};
|
|
13271
13343
|
const permutations = unique(
|
|
13272
13344
|
lineUp.flatMap(
|
|
13273
|
-
({ collectionAssignments }) => collectionAssignments
|
|
13345
|
+
({ collectionAssignments }) => collectionAssignments?.map(
|
|
13274
13346
|
({ collectionId, collectionPosition }) => [collectionId, collectionPosition].join("|")
|
|
13275
13347
|
)
|
|
13276
|
-
)
|
|
13348
|
+
).filter(Boolean)
|
|
13277
13349
|
);
|
|
13278
13350
|
permutations.forEach((permutation) => {
|
|
13279
13351
|
const [collectionId, position] = permutation.split("|");
|
|
@@ -15332,7 +15404,7 @@ function addMatchUpTimeItem({
|
|
|
15332
15404
|
timeItem,
|
|
15333
15405
|
event
|
|
15334
15406
|
}) {
|
|
15335
|
-
const { matchUp } =
|
|
15407
|
+
const { matchUp } = findDrawMatchUp({ drawDefinition, event, matchUpId });
|
|
15336
15408
|
if (!matchUp)
|
|
15337
15409
|
return { error: MATCHUP_NOT_FOUND };
|
|
15338
15410
|
const result = addTimeItem({
|
|
@@ -15367,7 +15439,7 @@ function allocateTeamMatchUpCourts({
|
|
|
15367
15439
|
return { error: MISSING_TOURNAMENT_RECORD };
|
|
15368
15440
|
if (!matchUpId)
|
|
15369
15441
|
return { error: MISSING_MATCHUP_ID };
|
|
15370
|
-
const result =
|
|
15442
|
+
const result = findDrawMatchUp({
|
|
15371
15443
|
drawDefinition,
|
|
15372
15444
|
matchUpId
|
|
15373
15445
|
});
|
|
@@ -15517,7 +15589,7 @@ function addMatchUpScheduledTime$1(params) {
|
|
|
15517
15589
|
if (!validTimeValue(scheduledTime))
|
|
15518
15590
|
return decorateResult({ result: { error: INVALID_TIME }, stack });
|
|
15519
15591
|
if (!matchUp) {
|
|
15520
|
-
const result =
|
|
15592
|
+
const result = findDrawMatchUp({ drawDefinition, matchUpId });
|
|
15521
15593
|
if (result.error)
|
|
15522
15594
|
return decorateResult({ result, stack });
|
|
15523
15595
|
matchUp = result.matchUp;
|
|
@@ -15574,7 +15646,7 @@ function addMatchUpTimeModifiers({
|
|
|
15574
15646
|
stack
|
|
15575
15647
|
});
|
|
15576
15648
|
if (!matchUp) {
|
|
15577
|
-
const result =
|
|
15649
|
+
const result = findDrawMatchUp({ drawDefinition, matchUpId });
|
|
15578
15650
|
if (result.error)
|
|
15579
15651
|
return decorateResult({ result, stack });
|
|
15580
15652
|
matchUp = result.matchUp;
|
|
@@ -15648,7 +15720,7 @@ function addMatchUpScheduleItems({
|
|
|
15648
15720
|
const stack = "drawEngine.addMatchUpScheduleItems";
|
|
15649
15721
|
let matchUp, warning;
|
|
15650
15722
|
if (!drawMatchUps) {
|
|
15651
|
-
const result =
|
|
15723
|
+
const result = findDrawMatchUp({ drawDefinition, event, matchUpId });
|
|
15652
15724
|
if (result.error)
|
|
15653
15725
|
return result;
|
|
15654
15726
|
matchUp = result.matchUp;
|
|
@@ -15916,7 +15988,7 @@ function addMatchUpStartTime({
|
|
|
15916
15988
|
return { error: MISSING_MATCHUP_ID };
|
|
15917
15989
|
if (!validTimeValue(startTime))
|
|
15918
15990
|
return { error: INVALID_TIME };
|
|
15919
|
-
const { matchUp } =
|
|
15991
|
+
const { matchUp } = findDrawMatchUp({ drawDefinition, event, matchUpId });
|
|
15920
15992
|
const { scheduledDate } = scheduledMatchUpDate({ matchUp });
|
|
15921
15993
|
const timeItems = matchUp?.timeItems ?? [];
|
|
15922
15994
|
const earliestRelevantTimeValue = timeItems.filter(
|
|
@@ -15960,7 +16032,7 @@ function addMatchUpEndTime({
|
|
|
15960
16032
|
return { error: MISSING_MATCHUP_ID };
|
|
15961
16033
|
if (!validTimeValue(endTime))
|
|
15962
16034
|
return { error: INVALID_TIME };
|
|
15963
|
-
const { matchUp } =
|
|
16035
|
+
const { matchUp } = findDrawMatchUp({ drawDefinition, event, matchUpId });
|
|
15964
16036
|
const { scheduledDate } = scheduledMatchUpDate({ matchUp });
|
|
15965
16037
|
const timeItems = matchUp?.timeItems ?? [];
|
|
15966
16038
|
const latestRelevantTimeValue = timeItems.filter(
|
|
@@ -16003,7 +16075,7 @@ function addMatchUpStopTime({
|
|
|
16003
16075
|
return { error: MISSING_MATCHUP_ID };
|
|
16004
16076
|
if (!validTimeValue(stopTime))
|
|
16005
16077
|
return { error: INVALID_TIME };
|
|
16006
|
-
const { matchUp } =
|
|
16078
|
+
const { matchUp } = findDrawMatchUp({ drawDefinition, event, matchUpId });
|
|
16007
16079
|
const { scheduledDate } = scheduledMatchUpDate({ matchUp });
|
|
16008
16080
|
const timeItems = matchUp?.timeItems ?? [];
|
|
16009
16081
|
const hasEndTime = timeItems.reduce((hasEndTime2, timeItem) => {
|
|
@@ -16062,7 +16134,7 @@ function addMatchUpResumeTime({
|
|
|
16062
16134
|
return { error: MISSING_MATCHUP_ID };
|
|
16063
16135
|
if (!validTimeValue(resumeTime))
|
|
16064
16136
|
return { error: INVALID_TIME };
|
|
16065
|
-
const { matchUp } =
|
|
16137
|
+
const { matchUp } = findDrawMatchUp({ drawDefinition, event, matchUpId });
|
|
16066
16138
|
const { scheduledDate } = scheduledMatchUpDate({ matchUp });
|
|
16067
16139
|
const timeItems = matchUp?.timeItems ?? [];
|
|
16068
16140
|
const hasEndTime = timeItems.reduce((hasEndTime2, timeItem) => {
|
|
@@ -16362,7 +16434,7 @@ function setMatchUpStatus$2(params) {
|
|
|
16362
16434
|
matchUp
|
|
16363
16435
|
});
|
|
16364
16436
|
if (matchUpTieId) {
|
|
16365
|
-
const { matchUp: dualMatchUp } =
|
|
16437
|
+
const { matchUp: dualMatchUp } = findDrawMatchUp({
|
|
16366
16438
|
matchUpId: matchUpTieId,
|
|
16367
16439
|
inContext: true,
|
|
16368
16440
|
drawDefinition,
|
|
@@ -16503,7 +16575,7 @@ function setMatchUpFormat(params) {
|
|
|
16503
16575
|
return { error: UNRECOGNIZED_MATCHUP_FORMAT };
|
|
16504
16576
|
const stack = "setMatchUpFormat";
|
|
16505
16577
|
if (matchUpId) {
|
|
16506
|
-
const result =
|
|
16578
|
+
const result = findDrawMatchUp({
|
|
16507
16579
|
drawDefinition,
|
|
16508
16580
|
matchUpId,
|
|
16509
16581
|
event
|