tods-competition-factory 2.2.42 → 2.2.45
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/index.mjs +6 -6
- package/dist/tods-competition-factory.d.ts +11 -3
- package/dist/tods-competition-factory.development.cjs.js +88 -73
- 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
|
@@ -4644,13 +4644,13 @@ type ModifyEventMatchUpFormatTimingArgs = {
|
|
|
4644
4644
|
event?: Event$1;
|
|
4645
4645
|
};
|
|
4646
4646
|
declare function modifyEventMatchUpFormatTiming(params: ModifyEventMatchUpFormatTimingArgs): {
|
|
4647
|
+
success: boolean;
|
|
4648
|
+
error?: undefined;
|
|
4649
|
+
} | {
|
|
4647
4650
|
error: {
|
|
4648
4651
|
message: string;
|
|
4649
4652
|
code: string;
|
|
4650
4653
|
};
|
|
4651
|
-
} | {
|
|
4652
|
-
success: boolean;
|
|
4653
|
-
error?: undefined;
|
|
4654
4654
|
};
|
|
4655
4655
|
|
|
4656
4656
|
type RemoveEventMatchUpFormatTimingArgs = {
|
|
@@ -4894,6 +4894,12 @@ declare function removeSeeding({ tournamentRecord, drawDefinition, entryStatuses
|
|
|
4894
4894
|
event: any;
|
|
4895
4895
|
stage: any;
|
|
4896
4896
|
}): ResultType | {
|
|
4897
|
+
error: {
|
|
4898
|
+
message: string;
|
|
4899
|
+
code: string;
|
|
4900
|
+
};
|
|
4901
|
+
info: string;
|
|
4902
|
+
} | {
|
|
4897
4903
|
success: boolean;
|
|
4898
4904
|
error?: undefined;
|
|
4899
4905
|
info?: undefined;
|
|
@@ -9964,6 +9970,8 @@ type ParsedSetString = {
|
|
|
9964
9970
|
side1Score?: number;
|
|
9965
9971
|
side2Score?: number;
|
|
9966
9972
|
setNumber: number;
|
|
9973
|
+
NoAD?: boolean;
|
|
9974
|
+
tiebreakSet?: boolean;
|
|
9967
9975
|
};
|
|
9968
9976
|
declare function parseScoreString({ tiebreakTo, scoreString, matchUpFormat }: ParseScoreArgs): ParsedSetString[];
|
|
9969
9977
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
function factoryVersion() {
|
|
6
|
-
return '2.2.
|
|
6
|
+
return '2.2.45';
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
const SINGLES_MATCHUP = 'SINGLES';
|
|
@@ -10345,7 +10345,7 @@ function addMatchUpContext({ scheduleVisibilityFilters, sourceDrawPositionRanges
|
|
|
10345
10345
|
const sourceDrawPositionRoundRanges = sourceDrawPositionRanges?.[roundNumber];
|
|
10346
10346
|
const matchUpCategory = collectionDefinition?.category
|
|
10347
10347
|
? {
|
|
10348
|
-
...
|
|
10348
|
+
...context?.category,
|
|
10349
10349
|
...collectionDefinition.category,
|
|
10350
10350
|
}
|
|
10351
10351
|
: (context?.category ?? event?.category);
|
|
@@ -10363,7 +10363,7 @@ function addMatchUpContext({ scheduleVisibilityFilters, sourceDrawPositionRanges
|
|
|
10363
10363
|
...onlyDefined(context),
|
|
10364
10364
|
...onlyDefined({
|
|
10365
10365
|
matchUpFormat: matchUpType === TEAM$1 ? undefined : matchUpFormat,
|
|
10366
|
-
tieFormat: matchUpType
|
|
10366
|
+
tieFormat: matchUpType === TEAM$1 ? tieFormat : undefined,
|
|
10367
10367
|
gender: collectionDefinition?.gender ?? event?.gender,
|
|
10368
10368
|
endDate: matchUp.endDate ?? endDate,
|
|
10369
10369
|
discipline: event?.discipline,
|
|
@@ -10404,16 +10404,19 @@ function addMatchUpContext({ scheduleVisibilityFilters, sourceDrawPositionRanges
|
|
|
10404
10404
|
.sort((a, b) => a.setNumber - b.setNumber)
|
|
10405
10405
|
.map((set, i) => {
|
|
10406
10406
|
const setNumber = i + 1;
|
|
10407
|
-
|
|
10408
|
-
|
|
10409
|
-
|
|
10410
|
-
|
|
10411
|
-
|
|
10407
|
+
const isDecidingSet = setNumber === bestOf;
|
|
10408
|
+
const currentSetFormat = isDecidingSet && finalSetFormat ? finalSetFormat : setFormat;
|
|
10409
|
+
const isTiebreakOnly = currentSetFormat?.tiebreakSet && !currentSetFormat?.timed;
|
|
10410
|
+
const isTimed = currentSetFormat?.timed;
|
|
10411
|
+
if (isTiebreakOnly) {
|
|
10412
10412
|
set.tiebreakSet = true;
|
|
10413
|
+
if ([1, 2].includes(set.winningSide)) {
|
|
10414
|
+
set.side1Score = set.winningSide === 1 ? 1 : 0;
|
|
10415
|
+
set.side2Score = set.winningSide === 2 ? 1 : 0;
|
|
10416
|
+
}
|
|
10413
10417
|
}
|
|
10414
|
-
if (
|
|
10415
|
-
set.
|
|
10416
|
-
set.side2Score = set.winningSide === 2 ? 1 : 0;
|
|
10418
|
+
else if (isTimed) {
|
|
10419
|
+
set.timed = true;
|
|
10417
10420
|
}
|
|
10418
10421
|
return set;
|
|
10419
10422
|
});
|
|
@@ -21622,7 +21625,7 @@ function processPlayoffGroups({ requireSequential = true, playoffMatchUpFormat,
|
|
|
21622
21625
|
}
|
|
21623
21626
|
for (const playoffGroup of playoffGroups) {
|
|
21624
21627
|
const finishingPositions = playoffGroup.finishingPositions;
|
|
21625
|
-
const positionsPlayedOff = positionRangeMap && finishingPositions.
|
|
21628
|
+
const positionsPlayedOff = positionRangeMap && finishingPositions.flatMap((p) => positionRangeMap[p]?.finishingPositions ?? []);
|
|
21626
21629
|
const participantsInDraw = groupCount * finishingPositions.length;
|
|
21627
21630
|
const drawSize = nextPowerOf2(participantsInDraw);
|
|
21628
21631
|
const playoffDrawType = (drawSize === 2 && SINGLE_ELIMINATION) || playoffGroup.drawType || SINGLE_ELIMINATION;
|
|
@@ -32436,6 +32439,62 @@ function validateMatchUpScore(sets, matchUpFormat, matchUpStatus) {
|
|
|
32436
32439
|
return { isValid: true };
|
|
32437
32440
|
}
|
|
32438
32441
|
|
|
32442
|
+
function validateTiebreak(tiebreakFormat, side1TiebreakScore, side2TiebreakScore, setWinningSide, isLastSet, irregularEnding) {
|
|
32443
|
+
const { tiebreakTo, NoAD } = tiebreakFormat || {};
|
|
32444
|
+
const maxTiebreakScore = Math.max(side1TiebreakScore ?? 0, side2TiebreakScore ?? 0);
|
|
32445
|
+
if (NoAD && maxTiebreakScore > tiebreakTo)
|
|
32446
|
+
return false;
|
|
32447
|
+
if (maxTiebreakScore < tiebreakTo && setWinningSide) {
|
|
32448
|
+
if (isLastSet && !irregularEnding)
|
|
32449
|
+
return false;
|
|
32450
|
+
if (!isLastSet)
|
|
32451
|
+
return false;
|
|
32452
|
+
}
|
|
32453
|
+
return true;
|
|
32454
|
+
}
|
|
32455
|
+
function validateSet(set, i, matchUpScoringFormat, totalSets, isLastSet, irregularEnding) {
|
|
32456
|
+
const setNumber = i + 1;
|
|
32457
|
+
const isFinalSet = setNumber === totalSets;
|
|
32458
|
+
const { side1Score, side2Score, side1TiebreakScore, side2TiebreakScore, winningSide: setWinningSide } = set;
|
|
32459
|
+
const maxSetScore = Math.max(side1Score ?? 0, side2Score ?? 0);
|
|
32460
|
+
const hasTiebreak = side1TiebreakScore ?? side2TiebreakScore;
|
|
32461
|
+
const { finalSetFormat, setFormat } = matchUpScoringFormat;
|
|
32462
|
+
const setValues = isFinalSet ? finalSetFormat || setFormat : setFormat;
|
|
32463
|
+
if (hasTiebreak) {
|
|
32464
|
+
const isValidTiebreak = validateTiebreak(setValues?.tiebreakFormat, side1TiebreakScore, side2TiebreakScore, setWinningSide, isLastSet, irregularEnding);
|
|
32465
|
+
if (!isValidTiebreak)
|
|
32466
|
+
return false;
|
|
32467
|
+
}
|
|
32468
|
+
if (!setValues.setTo)
|
|
32469
|
+
return true;
|
|
32470
|
+
const excessiveSetScore = !setValues.noTiebreak && maxSetScore > setValues.setTo + 1;
|
|
32471
|
+
return !excessiveSetScore;
|
|
32472
|
+
}
|
|
32473
|
+
function calculateAggregateWinner(sets) {
|
|
32474
|
+
const aggregateTotals = sets.reduce((totals, set) => {
|
|
32475
|
+
if (set.side1Score !== undefined || set.side2Score !== undefined) {
|
|
32476
|
+
totals[0] += set.side1Score ?? 0;
|
|
32477
|
+
totals[1] += set.side2Score ?? 0;
|
|
32478
|
+
}
|
|
32479
|
+
return totals;
|
|
32480
|
+
}, [0, 0]);
|
|
32481
|
+
if (aggregateTotals[0] > aggregateTotals[1]) {
|
|
32482
|
+
return 1;
|
|
32483
|
+
}
|
|
32484
|
+
else if (aggregateTotals[1] > aggregateTotals[0]) {
|
|
32485
|
+
return 2;
|
|
32486
|
+
}
|
|
32487
|
+
else {
|
|
32488
|
+
const tiebreakSet = sets.find((set) => set.side1TiebreakScore !== undefined || set.side2TiebreakScore !== undefined);
|
|
32489
|
+
return tiebreakSet?.winningSide;
|
|
32490
|
+
}
|
|
32491
|
+
}
|
|
32492
|
+
function calculateStandardWinner(maxSetsCount, setsToWin, maxSetsInstances, setsWinCounts, matchUpFormat) {
|
|
32493
|
+
return (((!matchUpFormat || maxSetsCount === setsToWin) &&
|
|
32494
|
+
maxSetsInstances === 1 &&
|
|
32495
|
+
setsWinCounts.indexOf(maxSetsCount) + 1) ||
|
|
32496
|
+
undefined);
|
|
32497
|
+
}
|
|
32439
32498
|
function analyzeScore({ existingMatchUpStatus, matchUpFormat, matchUpStatus, winningSide, score, }) {
|
|
32440
32499
|
const sets = score?.sets ?? [];
|
|
32441
32500
|
const completedSets = sets?.filter((set) => set?.winningSide) || [];
|
|
@@ -32457,71 +32516,23 @@ function analyzeScore({ existingMatchUpStatus, matchUpFormat, matchUpStatus, win
|
|
|
32457
32516
|
const maxSetsCount = Math.max(...setsWinCounts);
|
|
32458
32517
|
const maxSetsInstances = instanceCount(setsWinCounts)[maxSetsCount];
|
|
32459
32518
|
const timed = matchUpScoringFormat?.setFormat?.timed || matchUpScoringFormat?.finalSetFormat?.timed;
|
|
32460
|
-
const
|
|
32461
|
-
const setsToWin = (
|
|
32519
|
+
const totalSets = matchUpScoringFormat?.bestOf || matchUpScoringFormat?.exactly;
|
|
32520
|
+
const setsToWin = (totalSets && Math.ceil(totalSets / 2)) || 1;
|
|
32462
32521
|
const relevantMatchUpStatus = matchUpStatus ?? existingMatchUpStatus;
|
|
32463
|
-
const irregularEnding = relevantMatchUpStatus && [DEFAULTED, RETIRED$1, WALKOVER$2].includes(relevantMatchUpStatus);
|
|
32522
|
+
const irregularEnding = !!(relevantMatchUpStatus && [DEFAULTED, RETIRED$1, WALKOVER$2].includes(relevantMatchUpStatus));
|
|
32464
32523
|
const validSets = !matchUpScoringFormat ||
|
|
32465
32524
|
!sets.length ||
|
|
32466
|
-
sets.every((set, i) =>
|
|
32467
|
-
const setNumber = i + 1;
|
|
32468
|
-
const isFinalSet = setNumber === bestOf;
|
|
32469
|
-
const isLastSet = setNumber === sets.length;
|
|
32470
|
-
const { side1Score, side2Score, side1TiebreakScore, side2TiebreakScore, winningSide: setWinningSide } = set;
|
|
32471
|
-
const maxSetScore = Math.max(side1Score ?? 0, side2Score ?? 0);
|
|
32472
|
-
const hasTiebreak = side1TiebreakScore ?? side2TiebreakScore;
|
|
32473
|
-
const { finalSetFormat, setFormat } = matchUpScoringFormat;
|
|
32474
|
-
const setValues = isFinalSet ? finalSetFormat || setFormat : setFormat;
|
|
32475
|
-
if (hasTiebreak) {
|
|
32476
|
-
const { tiebreakTo, NoAD } = setValues?.tiebreakFormat || {};
|
|
32477
|
-
const maxTiebreakScore = Math.max(side1TiebreakScore ?? 0, side2TiebreakScore ?? 0);
|
|
32478
|
-
if (NoAD && maxTiebreakScore > tiebreakTo)
|
|
32479
|
-
return false;
|
|
32480
|
-
if (maxTiebreakScore < tiebreakTo && setWinningSide) {
|
|
32481
|
-
if (isLastSet && !irregularEnding)
|
|
32482
|
-
return false;
|
|
32483
|
-
if (!isLastSet)
|
|
32484
|
-
return false;
|
|
32485
|
-
}
|
|
32486
|
-
}
|
|
32487
|
-
if (!setValues.setTo)
|
|
32488
|
-
return true;
|
|
32489
|
-
const excessiveSetScore = !setValues.noTiebreak && maxSetScore > setValues.setTo + 1;
|
|
32490
|
-
return !excessiveSetScore;
|
|
32491
|
-
});
|
|
32525
|
+
sets.every((set, i) => validateSet(set, i, matchUpScoringFormat, totalSets ?? 0, i === sets.length - 1, irregularEnding));
|
|
32492
32526
|
const isAggregateScoring = matchUpScoringFormat?.setFormat?.based === 'A' || matchUpScoringFormat?.finalSetFormat?.based === 'A';
|
|
32493
|
-
|
|
32494
|
-
|
|
32495
|
-
|
|
32496
|
-
if (set.side1Score !== undefined || set.side2Score !== undefined) {
|
|
32497
|
-
totals[0] += set.side1Score ?? 0;
|
|
32498
|
-
totals[1] += set.side2Score ?? 0;
|
|
32499
|
-
}
|
|
32500
|
-
return totals;
|
|
32501
|
-
}, [0, 0]);
|
|
32502
|
-
if (aggregateTotals[0] > aggregateTotals[1]) {
|
|
32503
|
-
calculatedWinningSide = 1;
|
|
32504
|
-
}
|
|
32505
|
-
else if (aggregateTotals[1] > aggregateTotals[0]) {
|
|
32506
|
-
calculatedWinningSide = 2;
|
|
32507
|
-
}
|
|
32508
|
-
else {
|
|
32509
|
-
const tiebreakSet = sets.find((set) => set.side1TiebreakScore !== undefined || set.side2TiebreakScore !== undefined);
|
|
32510
|
-
if (tiebreakSet) {
|
|
32511
|
-
calculatedWinningSide = tiebreakSet.winningSide;
|
|
32512
|
-
}
|
|
32513
|
-
}
|
|
32514
|
-
}
|
|
32515
|
-
else {
|
|
32516
|
-
calculatedWinningSide =
|
|
32517
|
-
((!matchUpFormat || maxSetsCount === setsToWin) &&
|
|
32518
|
-
maxSetsInstances === 1 &&
|
|
32519
|
-
setsWinCounts.indexOf(maxSetsCount) + 1) ||
|
|
32520
|
-
undefined;
|
|
32521
|
-
}
|
|
32527
|
+
const calculatedWinningSide = isAggregateScoring && sets.length > 0
|
|
32528
|
+
? calculateAggregateWinner(sets)
|
|
32529
|
+
: calculateStandardWinner(maxSetsCount, setsToWin, maxSetsInstances, setsWinCounts, matchUpFormat);
|
|
32522
32530
|
const valid = !!(validSets &&
|
|
32523
32531
|
((winningSide && isAggregateScoring && winningSide === calculatedWinningSide) ||
|
|
32524
|
-
(winningSide &&
|
|
32532
|
+
(winningSide &&
|
|
32533
|
+
!isAggregateScoring &&
|
|
32534
|
+
winningSideSetsCount > losingSideSetsCount &&
|
|
32535
|
+
winningSide === calculatedWinningSide) ||
|
|
32525
32536
|
(winningSide && irregularEnding) ||
|
|
32526
32537
|
(!winningSide &&
|
|
32527
32538
|
!calculatedWinningSide &&
|
|
@@ -32735,6 +32746,8 @@ function parseScoreString({ tiebreakTo = 7, scoreString = '', matchUpFormat }) {
|
|
|
32735
32746
|
const bracketed = inBrackets.exec(set);
|
|
32736
32747
|
const isTiebreakOnlySet = set?.startsWith('[') && bracketed;
|
|
32737
32748
|
const isTiebreakOnlyFormat = checkIsTiebreakOnlyFormat(setNumber, !!isTiebreakOnlySet);
|
|
32749
|
+
const setSpecificTiebreakTo = getTiebreakToForSet(setNumber);
|
|
32750
|
+
const isNoAD = isTiebreakOnlyFormat && setSpecificTiebreakTo === 1;
|
|
32738
32751
|
let result;
|
|
32739
32752
|
if (isTiebreakOnlySet) {
|
|
32740
32753
|
const bracketedScores = bracketed[1].split('-').map((score) => Number.parseInt(score));
|
|
@@ -32750,6 +32763,8 @@ function parseScoreString({ tiebreakTo = 7, scoreString = '', matchUpFormat }) {
|
|
|
32750
32763
|
side2TiebreakScore: result.side2TiebreakScore,
|
|
32751
32764
|
winningSide: result.winningSide,
|
|
32752
32765
|
setNumber,
|
|
32766
|
+
...(isNoAD && { NoAD: true }),
|
|
32767
|
+
...(isTiebreakOnlyFormat && { tiebreakSet: true }),
|
|
32753
32768
|
};
|
|
32754
32769
|
}
|
|
32755
32770
|
}
|
|
@@ -59605,7 +59620,7 @@ async function asyncExecutionQueue(engine, directives, rollbackOnError) {
|
|
|
59605
59620
|
if (!methods[methodName])
|
|
59606
59621
|
return logMethodNotFound({ methodName, start, params });
|
|
59607
59622
|
if (pipe) {
|
|
59608
|
-
const lastResult = results
|
|
59623
|
+
const lastResult = results.at(-1);
|
|
59609
59624
|
const pipeKeys = Object.keys(pipe);
|
|
59610
59625
|
for (const pipeKey of pipeKeys) {
|
|
59611
59626
|
if (lastResult[pipeKey])
|
|
@@ -59787,7 +59802,7 @@ function executionQueue(engine, directives, rollbackOnError) {
|
|
|
59787
59802
|
if (!methods[methodName])
|
|
59788
59803
|
return logMethodNotFound({ methodName, start, params });
|
|
59789
59804
|
if (pipe) {
|
|
59790
|
-
const lastResult = results
|
|
59805
|
+
const lastResult = results.at(-1);
|
|
59791
59806
|
const pipeKeys = Object.keys(pipe);
|
|
59792
59807
|
for (const pipeKey of pipeKeys) {
|
|
59793
59808
|
if (lastResult[pipeKey])
|