tods-competition-factory 2.2.16 → 2.2.18
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 +7 -7
- package/dist/tods-competition-factory.d.ts +6 -1
- package/dist/tods-competition-factory.development.cjs.js +120 -81
- 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 +23 -23
|
@@ -2874,8 +2874,8 @@ declare function addVoluntaryConsolationStage(params: any): {
|
|
|
2874
2874
|
interface ResetQualifyingStructureArgs {
|
|
2875
2875
|
tournamentRecord?: Tournament;
|
|
2876
2876
|
drawDefinition: DrawDefinition;
|
|
2877
|
-
event?: Event$1;
|
|
2878
2877
|
structureId: string;
|
|
2878
|
+
event?: Event$1;
|
|
2879
2879
|
}
|
|
2880
2880
|
declare function resetQualifyingStructure({ tournamentRecord, drawDefinition, event, structureId, }: ResetQualifyingStructureArgs): {
|
|
2881
2881
|
error: {
|
|
@@ -3649,6 +3649,7 @@ type GenerateDrawTypeAndModify = {
|
|
|
3649
3649
|
matchUpType?: EventTypeUnion;
|
|
3650
3650
|
drawDefinition: DrawDefinition;
|
|
3651
3651
|
drawTypeCoercion?: boolean;
|
|
3652
|
+
qualifyingOnly?: boolean;
|
|
3652
3653
|
modifyOriginal?: boolean;
|
|
3653
3654
|
qualifiersCount?: number;
|
|
3654
3655
|
stageSequence?: number;
|
|
@@ -3789,16 +3790,19 @@ declare function generateDrawDefinition(params: GenerateDrawDefinitionArgs): Res
|
|
|
3789
3790
|
};
|
|
3790
3791
|
|
|
3791
3792
|
type GenerateQualifyingStructureArgs = {
|
|
3793
|
+
hasExistingDrawDefinition?: boolean;
|
|
3792
3794
|
appliedPolicies?: PolicyDefinitions;
|
|
3793
3795
|
qualifyingRoundNumber: number;
|
|
3794
3796
|
drawDefinition: DrawDefinition;
|
|
3795
3797
|
qualifyingPositions?: number;
|
|
3796
3798
|
participantsCount?: number;
|
|
3797
3799
|
targetStructureId: string;
|
|
3800
|
+
qualifyingOnly?: boolean;
|
|
3798
3801
|
drawType?: DrawTypeUnion;
|
|
3799
3802
|
structureOptions?: any;
|
|
3800
3803
|
matchUpFormat?: string;
|
|
3801
3804
|
structureName?: string;
|
|
3805
|
+
tieFormat?: TieFormat;
|
|
3802
3806
|
structureId?: string;
|
|
3803
3807
|
roundTarget: number;
|
|
3804
3808
|
drawSize?: number;
|
|
@@ -3824,6 +3828,7 @@ type GenerateDrawStructuresAndLinksArgs = {
|
|
|
3824
3828
|
overwriteExisting?: boolean;
|
|
3825
3829
|
drawTypeCoercion?: boolean;
|
|
3826
3830
|
staggeredEntry?: boolean;
|
|
3831
|
+
qualifyingOnly?: boolean;
|
|
3827
3832
|
qualifyingProfiles?: any;
|
|
3828
3833
|
structureName?: string;
|
|
3829
3834
|
tieFormat?: TieFormat;
|
|
@@ -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.18';
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
const SINGLES_MATCHUP = 'SINGLES';
|
|
@@ -15575,22 +15575,7 @@ function withdrawParticipantAtDrawPosition(params) {
|
|
|
15575
15575
|
return removeDrawPositionAssignment(params);
|
|
15576
15576
|
}
|
|
15577
15577
|
|
|
15578
|
-
|
|
15579
|
-
return !isString(str)
|
|
15580
|
-
? str
|
|
15581
|
-
: str
|
|
15582
|
-
.split(' ')
|
|
15583
|
-
.map((name) => name
|
|
15584
|
-
.split('')
|
|
15585
|
-
.map((c, i) => (i ? c.toLowerCase() : c.toUpperCase()))
|
|
15586
|
-
.join(''))
|
|
15587
|
-
.join(' ');
|
|
15588
|
-
}
|
|
15589
|
-
function constantToString(str) {
|
|
15590
|
-
return !isString(str) ? '' : capitalizeFirst(str.replace(/_/g, ' '));
|
|
15591
|
-
}
|
|
15592
|
-
|
|
15593
|
-
const structureTemplate = ({ finishingPosition = ROUND_OUTCOME, qualifyingRoundNumber, structureAbbreviation, seedAssignments = [], stageSequence = 1, structureOrder, seedingProfile, matchUpFormat, structureType, structureName, matchUpType, matchUps = [], structureId, roundOffset, roundLimit, stageOrder, structures, stage, }) => {
|
|
15578
|
+
const structureTemplate = ({ finishingPosition = ROUND_OUTCOME, hasExistingDrawDefinition, qualifyingRoundNumber, structureAbbreviation, seedAssignments = [], stageSequence = 1, qualifyingOnly, structureOrder, seedingProfile, matchUpFormat, structureType, structureName, matchUps = [], matchUpType, structureId, roundOffset, roundLimit, stageOrder, structures, tieFormat, stage, }) => {
|
|
15594
15579
|
const structure = {
|
|
15595
15580
|
structureId: structureId ?? UUID(),
|
|
15596
15581
|
structureAbbreviation,
|
|
@@ -15600,6 +15585,8 @@ const structureTemplate = ({ finishingPosition = ROUND_OUTCOME, qualifyingRoundN
|
|
|
15600
15585
|
stageSequence,
|
|
15601
15586
|
structureName,
|
|
15602
15587
|
};
|
|
15588
|
+
if (qualifyingOnly || (hasExistingDrawDefinition && tieFormat))
|
|
15589
|
+
structure.tieFormat = tieFormat;
|
|
15603
15590
|
if (structureOrder)
|
|
15604
15591
|
structure.structureOrder = structureOrder;
|
|
15605
15592
|
if (structureType)
|
|
@@ -15637,6 +15624,21 @@ const structureTemplate = ({ finishingPosition = ROUND_OUTCOME, qualifyingRoundN
|
|
|
15637
15624
|
return structure;
|
|
15638
15625
|
};
|
|
15639
15626
|
|
|
15627
|
+
function capitalizeFirst(str) {
|
|
15628
|
+
return !isString(str)
|
|
15629
|
+
? str
|
|
15630
|
+
: str
|
|
15631
|
+
.split(' ')
|
|
15632
|
+
.map((name) => name
|
|
15633
|
+
.split('')
|
|
15634
|
+
.map((c, i) => (i ? c.toLowerCase() : c.toUpperCase()))
|
|
15635
|
+
.join(''))
|
|
15636
|
+
.join(' ');
|
|
15637
|
+
}
|
|
15638
|
+
function constantToString(str) {
|
|
15639
|
+
return !isString(str) ? '' : capitalizeFirst(str.replace(/_/g, ' '));
|
|
15640
|
+
}
|
|
15641
|
+
|
|
15640
15642
|
function addVoluntaryConsolationStructure({ structureName = constantToString(VOLUNTARY_CONSOLATION), structureAbbreviation, drawDefinition, matchUpType, structureId, }) {
|
|
15641
15643
|
if (!drawDefinition)
|
|
15642
15644
|
return { error: MISSING_DRAW_DEFINITION };
|
|
@@ -15717,7 +15719,7 @@ const roundRobinGroups = {
|
|
|
15717
15719
|
};
|
|
15718
15720
|
|
|
15719
15721
|
function generateRoundRobin(params) {
|
|
15720
|
-
const { groupNameBase = 'Group', playoffAttributes, stageSequence = 1, structureOptions, appliedPolicies, seedingProfile, stage = MAIN, matchUpType, roundTarget, structureId, groupNames, drawSize, idPrefix, isMock, uuids, } = params;
|
|
15722
|
+
const { hasExistingDrawDefinition, groupNameBase = 'Group', playoffAttributes, stageSequence = 1, structureOptions, appliedPolicies, qualifyingOnly, seedingProfile, stage = MAIN, matchUpType, roundTarget, structureId, groupNames, tieFormat, drawSize, idPrefix, isMock, uuids, } = params;
|
|
15721
15723
|
const structureName = params.structureName ?? playoffAttributes?.['0']?.name ?? constantToString(MAIN);
|
|
15722
15724
|
const { groupCount, groupSize } = deriveGroups({
|
|
15723
15725
|
structureOptions,
|
|
@@ -15739,21 +15741,26 @@ function generateRoundRobin(params) {
|
|
|
15739
15741
|
const structureName = groupNames?.[structureOrder - 1] ?? `${groupNameBase} ${structureOrder}`;
|
|
15740
15742
|
return structureTemplate({
|
|
15741
15743
|
structureId: uuids?.pop(),
|
|
15744
|
+
hasExistingDrawDefinition,
|
|
15742
15745
|
structureType: ITEM,
|
|
15743
15746
|
finishingPosition,
|
|
15747
|
+
qualifyingOnly,
|
|
15744
15748
|
structureOrder,
|
|
15745
15749
|
structureName,
|
|
15750
|
+
tieFormat,
|
|
15746
15751
|
matchUps,
|
|
15747
15752
|
});
|
|
15748
15753
|
});
|
|
15749
15754
|
const structure = structureTemplate({
|
|
15750
15755
|
structureId: structureId ?? uuids?.pop(),
|
|
15756
|
+
hasExistingDrawDefinition,
|
|
15751
15757
|
structureType: CONTAINER,
|
|
15752
15758
|
finishingPosition,
|
|
15753
15759
|
seedingProfile,
|
|
15754
15760
|
structureName,
|
|
15755
15761
|
stageSequence,
|
|
15756
15762
|
structures,
|
|
15763
|
+
tieFormat,
|
|
15757
15764
|
stage,
|
|
15758
15765
|
});
|
|
15759
15766
|
if (roundTarget)
|
|
@@ -19728,6 +19735,9 @@ function resetQualifyingStructure({ tournamentRecord, drawDefinition, event, str
|
|
|
19728
19735
|
const structure = drawDefinition.structures?.find((structure) => structure.stage === QUALIFYING && structure.structureId === structureId);
|
|
19729
19736
|
if (!structure)
|
|
19730
19737
|
return { error: STRUCTURE_NOT_FOUND };
|
|
19738
|
+
const scoresPresent = structure.matchUps?.some(({ matchUpStatus, score }) => checkScoreHasValue({ score }) ?? completedMatchUpStatuses.includes(matchUpStatus));
|
|
19739
|
+
if (scoresPresent)
|
|
19740
|
+
return { error: SCORES_PRESENT };
|
|
19731
19741
|
const removedMatchUpIds = structure.matchUps?.map(({ matchUpId }) => matchUpId) || [];
|
|
19732
19742
|
structure.positionAssignments = [];
|
|
19733
19743
|
structure.seedAssignments = [];
|
|
@@ -20073,6 +20083,38 @@ function generateQualifyingLink({ targetEntryRound = 1, finishingPositions, sour
|
|
|
20073
20083
|
return { link };
|
|
20074
20084
|
}
|
|
20075
20085
|
|
|
20086
|
+
function generateTieMatchUps({ matchUp, tieFormat, isMock, uuids }) {
|
|
20087
|
+
const { collectionDefinitions } = tieFormat ?? {};
|
|
20088
|
+
const tieMatchUps = (collectionDefinitions ?? [])
|
|
20089
|
+
.map((collectionDefinition) => generateCollectionMatchUps({ matchUp, collectionDefinition, uuids, isMock }))
|
|
20090
|
+
.filter(Boolean)
|
|
20091
|
+
.flat();
|
|
20092
|
+
return { tieMatchUps };
|
|
20093
|
+
}
|
|
20094
|
+
function generateCollectionMatchUps({ collectionPositionOffset = 0, collectionDefinition, matchUpsLimit, matchUp, isMock, uuids, }) {
|
|
20095
|
+
const { matchUpCount, matchUpType, collectionId, processCodes } = collectionDefinition || {};
|
|
20096
|
+
const numberToGenerate = matchUpsLimit ?? matchUpCount ?? 0;
|
|
20097
|
+
const getMatchUpId = (index) => {
|
|
20098
|
+
if (!isMock && !matchUp?.isMock)
|
|
20099
|
+
return uuids?.pop() ?? UUID();
|
|
20100
|
+
const collectionId = collectionDefinition?.collectionId;
|
|
20101
|
+
return uuids?.pop() ?? `${matchUp?.matchUpId}-${collectionId}-TMU-${index + 1}`;
|
|
20102
|
+
};
|
|
20103
|
+
return generateRange(0, numberToGenerate).map((index) => {
|
|
20104
|
+
const collectionPosition = collectionPositionOffset + index + 1;
|
|
20105
|
+
return {
|
|
20106
|
+
sides: [{ sideNumber: 1 }, { sideNumber: 2 }],
|
|
20107
|
+
matchUpId: getMatchUpId(index),
|
|
20108
|
+
matchUpStatus: TO_BE_PLAYED,
|
|
20109
|
+
collectionPosition,
|
|
20110
|
+
collectionId,
|
|
20111
|
+
processCodes,
|
|
20112
|
+
matchUpType,
|
|
20113
|
+
isMock,
|
|
20114
|
+
};
|
|
20115
|
+
});
|
|
20116
|
+
}
|
|
20117
|
+
|
|
20076
20118
|
function generateMatchUpId({ roundPosition, roundNumber, idPrefix, uuids }) {
|
|
20077
20119
|
return idPrefix ? `${idPrefix}-${roundNumber}-${roundPosition}` : uuids?.pop() || UUID();
|
|
20078
20120
|
}
|
|
@@ -20200,7 +20242,7 @@ function generateQualifyingStructure(params) {
|
|
|
20200
20242
|
return decorateResult({ result: { error: INVALID_VALUES }, stack });
|
|
20201
20243
|
}
|
|
20202
20244
|
let drawSize = params.drawSize ?? coerceEven(params.participantsCount);
|
|
20203
|
-
const { qualifyingRoundNumber, qualifyingPositions, targetStructureId, structureOptions, appliedPolicies, drawDefinition, matchUpFormat, structureName, structureId, roundTarget, drawType, idPrefix, isMock, uuids, } = params;
|
|
20245
|
+
const { hasExistingDrawDefinition, qualifyingRoundNumber, qualifyingPositions, targetStructureId, structureOptions, appliedPolicies, qualifyingOnly, drawDefinition, matchUpFormat, structureName, structureId, roundTarget, tieFormat, drawType, idPrefix, isMock, uuids, } = params;
|
|
20204
20246
|
if (!params.drawSize)
|
|
20205
20247
|
return decorateResult({
|
|
20206
20248
|
result: { error: MISSING_DRAW_SIZE },
|
|
@@ -20240,12 +20282,15 @@ function generateQualifyingStructure(params) {
|
|
|
20240
20282
|
const { maxRoundNumber, structures, groupCount } = generateRoundRobin({
|
|
20241
20283
|
structureName: structureName ?? qualifyingStructureName,
|
|
20242
20284
|
structureId: structureId ?? uuids?.pop(),
|
|
20285
|
+
hasExistingDrawDefinition,
|
|
20243
20286
|
stage: QUALIFYING,
|
|
20244
20287
|
structureOptions,
|
|
20245
20288
|
appliedPolicies,
|
|
20289
|
+
qualifyingOnly,
|
|
20246
20290
|
stageSequence,
|
|
20247
20291
|
matchUpType,
|
|
20248
20292
|
roundTarget,
|
|
20293
|
+
tieFormat,
|
|
20249
20294
|
idPrefix,
|
|
20250
20295
|
drawSize,
|
|
20251
20296
|
isMock,
|
|
@@ -20297,6 +20342,13 @@ function generateQualifyingStructure(params) {
|
|
|
20297
20342
|
finishingPositions,
|
|
20298
20343
|
linkType,
|
|
20299
20344
|
})?.link;
|
|
20345
|
+
if (tieFormat) {
|
|
20346
|
+
matchUps = getAllStructureMatchUps({ structure })?.matchUps || [];
|
|
20347
|
+
matchUps?.forEach((matchUp) => {
|
|
20348
|
+
const { tieMatchUps } = generateTieMatchUps({ tieFormat, matchUp, isMock });
|
|
20349
|
+
Object.assign(matchUp, { tieMatchUps, matchUpType });
|
|
20350
|
+
});
|
|
20351
|
+
}
|
|
20300
20352
|
return {
|
|
20301
20353
|
qualifyingDrawPositionsCount: drawSize,
|
|
20302
20354
|
qualifiersCount,
|
|
@@ -21513,38 +21565,6 @@ function generatePlayoffLink({ playoffStructureId, finishingPositions, sourceStr
|
|
|
21513
21565
|
};
|
|
21514
21566
|
}
|
|
21515
21567
|
|
|
21516
|
-
function generateTieMatchUps({ matchUp, tieFormat, isMock, uuids }) {
|
|
21517
|
-
const { collectionDefinitions } = tieFormat ?? {};
|
|
21518
|
-
const tieMatchUps = (collectionDefinitions ?? [])
|
|
21519
|
-
.map((collectionDefinition) => generateCollectionMatchUps({ matchUp, collectionDefinition, uuids, isMock }))
|
|
21520
|
-
.filter(Boolean)
|
|
21521
|
-
.flat();
|
|
21522
|
-
return { tieMatchUps };
|
|
21523
|
-
}
|
|
21524
|
-
function generateCollectionMatchUps({ collectionPositionOffset = 0, collectionDefinition, matchUpsLimit, matchUp, isMock, uuids, }) {
|
|
21525
|
-
const { matchUpCount, matchUpType, collectionId, processCodes } = collectionDefinition || {};
|
|
21526
|
-
const numberToGenerate = matchUpsLimit ?? matchUpCount ?? 0;
|
|
21527
|
-
const getMatchUpId = (index) => {
|
|
21528
|
-
if (!isMock && !matchUp?.isMock)
|
|
21529
|
-
return uuids?.pop() ?? UUID();
|
|
21530
|
-
const collectionId = collectionDefinition?.collectionId;
|
|
21531
|
-
return uuids?.pop() ?? `${matchUp?.matchUpId}-${collectionId}-TMU-${index + 1}`;
|
|
21532
|
-
};
|
|
21533
|
-
return generateRange(0, numberToGenerate).map((index) => {
|
|
21534
|
-
const collectionPosition = collectionPositionOffset + index + 1;
|
|
21535
|
-
return {
|
|
21536
|
-
sides: [{ sideNumber: 1 }, { sideNumber: 2 }],
|
|
21537
|
-
matchUpId: getMatchUpId(index),
|
|
21538
|
-
matchUpStatus: TO_BE_PLAYED,
|
|
21539
|
-
collectionPosition,
|
|
21540
|
-
collectionId,
|
|
21541
|
-
processCodes,
|
|
21542
|
-
matchUpType,
|
|
21543
|
-
isMock,
|
|
21544
|
-
};
|
|
21545
|
-
});
|
|
21546
|
-
}
|
|
21547
|
-
|
|
21548
21568
|
function generateAndPopulateRRplayoffStructures(params) {
|
|
21549
21569
|
const stack = 'generateAndPopulateRRplayoffStructures';
|
|
21550
21570
|
if (!params.playoffGroups) {
|
|
@@ -21586,11 +21606,7 @@ function generateAndPopulateRRplayoffStructures(params) {
|
|
|
21586
21606
|
const tieFormat = resolveTieFormat({ drawDefinition, event })?.tieFormat;
|
|
21587
21607
|
if (tieFormat) {
|
|
21588
21608
|
addedMatchUps.forEach((matchUp) => {
|
|
21589
|
-
const { tieMatchUps } = generateTieMatchUps({
|
|
21590
|
-
isMock: params.isMock,
|
|
21591
|
-
tieFormat,
|
|
21592
|
-
matchUp,
|
|
21593
|
-
});
|
|
21609
|
+
const { tieMatchUps } = generateTieMatchUps({ isMock: params.isMock, tieFormat, matchUp });
|
|
21594
21610
|
Object.assign(matchUp, { tieMatchUps, matchUpType: TEAM_MATCHUP });
|
|
21595
21611
|
});
|
|
21596
21612
|
}
|
|
@@ -21919,36 +21935,37 @@ function calculatePercentages({ participantResults, matchUpFormat, tallyPolicy,
|
|
|
21919
21935
|
const bestOfGames = parsedGroupMatchUpFormat.bestOf;
|
|
21920
21936
|
const bracketSetsToWin = (bestOfGames && Math.ceil(bestOfGames / 2)) || 1;
|
|
21921
21937
|
const bracketGamesForSet = parsedGroupMatchUpFormat.setFormat?.setTo;
|
|
21938
|
+
const precision = Math.pow(10, tallyPolicy?.precision || 3);
|
|
21922
21939
|
Object.keys(participantResults).forEach((participantId) => {
|
|
21923
21940
|
const setsWon = participantResults[participantId].setsWon;
|
|
21924
21941
|
const setsLost = participantResults[participantId].setsLost;
|
|
21925
21942
|
const setsTotal = tallyPolicy?.groupTotalSetsPlayed
|
|
21926
21943
|
? totalSets
|
|
21927
21944
|
: perPlayer * (bracketSetsToWin || 0) || setsWon + setsLost;
|
|
21928
|
-
let setsPct = Math.round((setsWon / setsTotal) *
|
|
21945
|
+
let setsPct = Math.round((setsWon / setsTotal) * precision) / precision;
|
|
21929
21946
|
if (setsPct === Infinity || isNaN(setsPct))
|
|
21930
21947
|
setsPct = setsTotal;
|
|
21931
21948
|
const tieMatchUpsWon = participantResults[participantId].tieMatchUpsWon;
|
|
21932
21949
|
const tieMatchUpsLost = participantResults[participantId].tieMatchUpsLost;
|
|
21933
21950
|
const tieMatchUpsTotal = tieMatchUpsWon + tieMatchUpsLost;
|
|
21934
|
-
let tieMatchUpsPct = Math.round((tieMatchUpsWon / tieMatchUpsTotal) *
|
|
21951
|
+
let tieMatchUpsPct = Math.round((tieMatchUpsWon / tieMatchUpsTotal) * precision) / precision;
|
|
21935
21952
|
if (tieMatchUpsPct === Infinity || isNaN(tieMatchUpsPct))
|
|
21936
21953
|
tieMatchUpsPct = tieMatchUpsWon;
|
|
21937
21954
|
const matchUpsWon = participantResults[participantId].matchUpsWon;
|
|
21938
21955
|
const matchUpsLost = participantResults[participantId].matchUpsLost;
|
|
21939
21956
|
const matchUpsTotal = matchUpsWon + matchUpsLost;
|
|
21940
|
-
let matchUpsPct = Math.round((matchUpsWon / matchUpsTotal) *
|
|
21957
|
+
let matchUpsPct = Math.round((matchUpsWon / matchUpsTotal) * precision) / precision;
|
|
21941
21958
|
if (matchUpsPct === Infinity || isNaN(matchUpsPct))
|
|
21942
21959
|
matchUpsPct = matchUpsWon;
|
|
21943
21960
|
const gamesWon = participantResults[participantId].gamesWon || 0;
|
|
21944
21961
|
const gamesLost = participantResults[participantId].gamesLost || 0;
|
|
21945
21962
|
const minimumExpectedGames = (perPlayer || 0) * (bracketSetsToWin || 0) * (bracketGamesForSet || 0);
|
|
21946
21963
|
const gamesTotal = Math.max(minimumExpectedGames, gamesWon + gamesLost);
|
|
21947
|
-
let gamesPct = Math.round((gamesWon / gamesTotal) *
|
|
21964
|
+
let gamesPct = Math.round((gamesWon / gamesTotal) * precision) / precision;
|
|
21948
21965
|
if (gamesPct === Infinity || isNaN(gamesPct))
|
|
21949
21966
|
gamesPct = 0;
|
|
21950
21967
|
const pointsTotal = participantResults[participantId].pointsWon + participantResults[participantId].pointsLost;
|
|
21951
|
-
let pointsPct = Math.round((participantResults[participantId].pointsWon / pointsTotal) *
|
|
21968
|
+
let pointsPct = Math.round((participantResults[participantId].pointsWon / pointsTotal) * precision) / precision;
|
|
21952
21969
|
if (pointsPct === Infinity || isNaN(pointsPct))
|
|
21953
21970
|
pointsPct = 0;
|
|
21954
21971
|
participantResults[participantId].setsWon = setsWon;
|
|
@@ -27051,7 +27068,7 @@ var query$b = {
|
|
|
27051
27068
|
positionActions: positionActions
|
|
27052
27069
|
};
|
|
27053
27070
|
|
|
27054
|
-
function generateQualifyingStructures({ qualifyingProfiles, appliedPolicies, idPrefix, isMock, uuids, }) {
|
|
27071
|
+
function generateQualifyingStructures({ hasExistingDrawDefinition, qualifyingProfiles, appliedPolicies, qualifyingOnly, tieFormat, idPrefix, isMock, uuids, }) {
|
|
27055
27072
|
const stack = 'generateQualifyingSTructures';
|
|
27056
27073
|
const qualifyingDetails = [];
|
|
27057
27074
|
const structures = [];
|
|
@@ -27085,12 +27102,15 @@ function generateQualifyingStructures({ qualifyingProfiles, appliedPolicies, idP
|
|
|
27085
27102
|
const { structures, groupCount, maxRoundNumber } = generateRoundRobin({
|
|
27086
27103
|
structureName: structureProfile.structureName || qualifyingStructureName,
|
|
27087
27104
|
structureId: structureId || uuids?.pop(),
|
|
27105
|
+
hasExistingDrawDefinition,
|
|
27088
27106
|
stage: QUALIFYING,
|
|
27089
27107
|
structureOptions,
|
|
27090
27108
|
appliedPolicies,
|
|
27109
|
+
qualifyingOnly,
|
|
27091
27110
|
stageSequence,
|
|
27092
27111
|
matchUpType,
|
|
27093
27112
|
roundTarget,
|
|
27113
|
+
tieFormat,
|
|
27094
27114
|
drawSize,
|
|
27095
27115
|
idPrefix,
|
|
27096
27116
|
isMock,
|
|
@@ -27115,11 +27135,14 @@ function generateQualifyingStructures({ qualifyingProfiles, appliedPolicies, idP
|
|
|
27115
27135
|
structureName: structureProfile.structureName || qualifyingStructureName,
|
|
27116
27136
|
structureId: structureId || uuids?.pop(),
|
|
27117
27137
|
qualifyingRoundNumber: roundLimit,
|
|
27138
|
+
hasExistingDrawDefinition,
|
|
27118
27139
|
stage: QUALIFYING,
|
|
27140
|
+
qualifyingOnly,
|
|
27119
27141
|
matchUpFormat,
|
|
27120
27142
|
stageSequence,
|
|
27121
27143
|
matchUpType,
|
|
27122
27144
|
roundLimit,
|
|
27145
|
+
tieFormat,
|
|
27123
27146
|
matchUps,
|
|
27124
27147
|
});
|
|
27125
27148
|
if (roundTarget) {
|
|
@@ -27147,6 +27170,13 @@ function generateQualifyingStructures({ qualifyingProfiles, appliedPolicies, idP
|
|
|
27147
27170
|
linkType = drawType === ROUND_ROBIN ? POSITION : WINNER;
|
|
27148
27171
|
finalQualifyingStructureId = structure.structureId;
|
|
27149
27172
|
finalQualifyingRoundNumber = roundLimit;
|
|
27173
|
+
if (tieFormat) {
|
|
27174
|
+
matchUps = getAllStructureMatchUps({ structure })?.matchUps || [];
|
|
27175
|
+
matchUps?.forEach((matchUp) => {
|
|
27176
|
+
const { tieMatchUps } = generateTieMatchUps({ tieFormat, matchUp, isMock });
|
|
27177
|
+
Object.assign(matchUp, { tieMatchUps, matchUpType });
|
|
27178
|
+
});
|
|
27179
|
+
}
|
|
27150
27180
|
structures.push(structure);
|
|
27151
27181
|
stageSequence += 1;
|
|
27152
27182
|
}
|
|
@@ -27457,7 +27487,7 @@ function luckyRoundProfiles(drawSize) {
|
|
|
27457
27487
|
}
|
|
27458
27488
|
|
|
27459
27489
|
function getGenerators(params) {
|
|
27460
|
-
const { playoffAttributes, stageSequence = 1, stage = MAIN, matchUpType, drawSize, uuids } = params;
|
|
27490
|
+
const { playoffAttributes, stageSequence = 1, stage = MAIN, tieFormat, matchUpType, drawSize, uuids } = params;
|
|
27461
27491
|
const getPrefixedStructureId = () => {
|
|
27462
27492
|
if (!params.isMock && !params.idPrefix)
|
|
27463
27493
|
return undefined;
|
|
@@ -27476,6 +27506,7 @@ function getGenerators(params) {
|
|
|
27476
27506
|
structureName,
|
|
27477
27507
|
matchUpType,
|
|
27478
27508
|
structureId,
|
|
27509
|
+
tieFormat,
|
|
27479
27510
|
matchUps,
|
|
27480
27511
|
stage,
|
|
27481
27512
|
});
|
|
@@ -27529,6 +27560,7 @@ function getGenerators(params) {
|
|
|
27529
27560
|
matchUpType,
|
|
27530
27561
|
structureId,
|
|
27531
27562
|
stage: MAIN,
|
|
27563
|
+
tieFormat,
|
|
27532
27564
|
matchUps,
|
|
27533
27565
|
});
|
|
27534
27566
|
return { structures: [structure], links: [], ...SUCCESS };
|
|
@@ -27548,7 +27580,7 @@ function getGenerators(params) {
|
|
|
27548
27580
|
}
|
|
27549
27581
|
|
|
27550
27582
|
function generateDrawStructuresAndLinks(params) {
|
|
27551
|
-
const { enforceMinimumDrawSize = true, overwriteExisting, appliedPolicies, staggeredEntry, drawDefinition, tieFormat, isMock, uuids, } = params || {};
|
|
27583
|
+
const { enforceMinimumDrawSize = true, overwriteExisting, appliedPolicies, qualifyingOnly, staggeredEntry, drawDefinition, tieFormat, isMock, uuids, } = params || {};
|
|
27552
27584
|
const drawSize = ensureInt(params.drawSize);
|
|
27553
27585
|
const drawTypeCoercion = params.drawTypeCoercion ?? getDrawTypeCoercion({ appliedPolicies, drawType: params.drawType });
|
|
27554
27586
|
const stack = 'generateDrawStructuresAndLinks';
|
|
@@ -27613,6 +27645,8 @@ function generateDrawStructuresAndLinks(params) {
|
|
|
27613
27645
|
idPrefix: params.idPrefix,
|
|
27614
27646
|
qualifyingProfiles,
|
|
27615
27647
|
appliedPolicies,
|
|
27648
|
+
qualifyingOnly,
|
|
27649
|
+
tieFormat,
|
|
27616
27650
|
isMock,
|
|
27617
27651
|
uuids,
|
|
27618
27652
|
});
|
|
@@ -27787,11 +27821,7 @@ function generateDrawTypeAndModifyDrawDefinition(params) {
|
|
|
27787
27821
|
if (tieFormat) {
|
|
27788
27822
|
matchUps?.forEach((matchUp) => {
|
|
27789
27823
|
if (!existingMatchUpIds.includes(matchUp.matchUpId)) {
|
|
27790
|
-
const { tieMatchUps } = generateTieMatchUps({
|
|
27791
|
-
tieFormat,
|
|
27792
|
-
matchUp,
|
|
27793
|
-
isMock,
|
|
27794
|
-
});
|
|
27824
|
+
const { tieMatchUps } = generateTieMatchUps({ tieFormat, matchUp, isMock });
|
|
27795
27825
|
Object.assign(matchUp, { tieMatchUps, matchUpType });
|
|
27796
27826
|
}
|
|
27797
27827
|
});
|
|
@@ -32383,13 +32413,16 @@ function getDrawFormat(params) {
|
|
|
32383
32413
|
|
|
32384
32414
|
function processExistingDrawDefinition(params) {
|
|
32385
32415
|
const drawDefinition = params.drawDefinition;
|
|
32386
|
-
const { existingQualifyingPlaceholderStructureId, appliedPolicies, drawEntries, structureId, idPrefix, isMock, event, } = params;
|
|
32416
|
+
const { existingQualifyingPlaceholderStructureId, appliedPolicies, qualifyingOnly, drawEntries, structureId, tieFormat, idPrefix, isMock, event, } = params;
|
|
32387
32417
|
const qualifyingProfiles = params.qualifyingProfiles;
|
|
32388
32418
|
const qualifyingResult = qualifyingProfiles?.length
|
|
32389
32419
|
? generateQualifyingStructures({
|
|
32420
|
+
hasExistingDrawDefinition: true,
|
|
32390
32421
|
uuids: params.uuids,
|
|
32391
32422
|
qualifyingProfiles,
|
|
32392
32423
|
appliedPolicies,
|
|
32424
|
+
qualifyingOnly,
|
|
32425
|
+
tieFormat,
|
|
32393
32426
|
idPrefix,
|
|
32394
32427
|
isMock,
|
|
32395
32428
|
})
|
|
@@ -33130,7 +33163,7 @@ function checkTieFormat({ tieFormat }) {
|
|
|
33130
33163
|
return { tieFormat };
|
|
33131
33164
|
}
|
|
33132
33165
|
|
|
33133
|
-
function checkFormatScopeEquivalence({ tournamentRecord, drawDefinition, matchUpFormat, matchUpType, tieFormat, event, }) {
|
|
33166
|
+
function checkFormatScopeEquivalence({ existingQualifyingStructures, tournamentRecord, drawDefinition, matchUpFormat, matchUpType, tieFormat, event, }) {
|
|
33134
33167
|
if (matchUpFormat || tieFormat) {
|
|
33135
33168
|
const equivalentInScope = (matchUpFormat && event?.matchUpFormat === matchUpFormat) ||
|
|
33136
33169
|
(event?.tieFormat && tieFormat && JSON.stringify(event.tieFormat) === JSON.stringify(tieFormat));
|
|
@@ -33139,7 +33172,10 @@ function checkFormatScopeEquivalence({ tournamentRecord, drawDefinition, matchUp
|
|
|
33139
33172
|
const result = checkTieFormat({ tieFormat });
|
|
33140
33173
|
if (result.error)
|
|
33141
33174
|
return result;
|
|
33142
|
-
|
|
33175
|
+
const existingQualifyingTieFormats = existingQualifyingStructures?.every((structure) => structure.tieFormat);
|
|
33176
|
+
if (!existingQualifyingStructures?.length || existingQualifyingTieFormats) {
|
|
33177
|
+
drawDefinition.tieFormat = result.tieFormat ?? tieFormat;
|
|
33178
|
+
}
|
|
33143
33179
|
}
|
|
33144
33180
|
else if (matchUpFormat) {
|
|
33145
33181
|
const result = setMatchUpMatchUpFormat({
|
|
@@ -33307,10 +33343,17 @@ function existingPolicyDefinitions({ policyDefinitions, appliedPolicies, policie
|
|
|
33307
33343
|
}
|
|
33308
33344
|
|
|
33309
33345
|
function setUpDrawGeneration(params) {
|
|
33310
|
-
const { tournamentRecord,
|
|
33346
|
+
const { tournamentRecord, policyDefinitions, appliedPolicies, matchUpFormat, matchUpType, tieFormat, drawType, stack, event, } = params;
|
|
33311
33347
|
const existingDrawDefinition = params.drawId
|
|
33312
33348
|
? event?.drawDefinitions?.find((d) => d.drawId === params.drawId)
|
|
33313
33349
|
: undefined;
|
|
33350
|
+
const structureId = existingDrawDefinition?.structures?.find((structure) => structure.stage === MAIN && structure.stageSequence === 1)?.structureId;
|
|
33351
|
+
const existingQualifyingStructures = existingDrawDefinition
|
|
33352
|
+
? existingDrawDefinition.structures?.filter((structure) => structure.stage === QUALIFYING)
|
|
33353
|
+
: [];
|
|
33354
|
+
const existingQualifyingPlaceholderStructureId = existingQualifyingStructures?.length === 1 &&
|
|
33355
|
+
!existingQualifyingStructures[0].matchUps?.length &&
|
|
33356
|
+
existingQualifyingStructures[0].structureId;
|
|
33314
33357
|
if (existingDrawDefinition && drawType !== existingDrawDefinition.drawType)
|
|
33315
33358
|
existingDrawDefinition.drawType = drawType;
|
|
33316
33359
|
const drawDefinition = existingDrawDefinition ??
|
|
@@ -33320,6 +33363,7 @@ function setUpDrawGeneration(params) {
|
|
|
33320
33363
|
drawType,
|
|
33321
33364
|
});
|
|
33322
33365
|
const equivalenceResult = checkFormatScopeEquivalence({
|
|
33366
|
+
existingQualifyingStructures,
|
|
33323
33367
|
tournamentRecord,
|
|
33324
33368
|
drawDefinition,
|
|
33325
33369
|
matchUpFormat,
|
|
@@ -33332,13 +33376,6 @@ function setUpDrawGeneration(params) {
|
|
|
33332
33376
|
const attachmentResult = policyAttachment({ appliedPolicies, policyDefinitions, drawDefinition, stack });
|
|
33333
33377
|
if (attachmentResult.error)
|
|
33334
33378
|
return attachmentResult;
|
|
33335
|
-
const structureId = existingDrawDefinition?.structures?.find((structure) => structure.stage === MAIN && structure.stageSequence === 1)?.structureId;
|
|
33336
|
-
const existingQualifyingStructures = existingDrawDefinition
|
|
33337
|
-
? existingDrawDefinition.structures?.filter((structure) => structure.stage === QUALIFYING)
|
|
33338
|
-
: [];
|
|
33339
|
-
const existingQualifyingPlaceholderStructureId = existingQualifyingStructures?.length === 1 &&
|
|
33340
|
-
!existingQualifyingStructures[0].matchUps?.length &&
|
|
33341
|
-
existingQualifyingStructures[0].structureId;
|
|
33342
33379
|
return { drawDefinition, structureId, existingDrawDefinition, existingQualifyingPlaceholderStructureId };
|
|
33343
33380
|
}
|
|
33344
33381
|
|
|
@@ -33375,7 +33412,7 @@ function generateOrGetExisting(params) {
|
|
|
33375
33412
|
}
|
|
33376
33413
|
|
|
33377
33414
|
function qualifyingGeneration(params) {
|
|
33378
|
-
const { qualifyingPlaceholder,
|
|
33415
|
+
const { qualifyingPlaceholder, existingDrawDefinition, positioningReports, qualifyingProfiles, appliedPolicies, qualifyingOnly, drawDefinition, seedingProfile, participants, structureId, tieFormat, entries, stack, } = params;
|
|
33379
33416
|
const generateQualifyingPlaceholder = qualifyingPlaceholder && !qualifyingProfiles?.length && !existingDrawDefinition;
|
|
33380
33417
|
const qualifyingConflicts = [];
|
|
33381
33418
|
if (qualifyingProfiles) {
|
|
@@ -33438,6 +33475,8 @@ function qualifyingGeneration(params) {
|
|
|
33438
33475
|
const qualifyingStructure = structureTemplate({
|
|
33439
33476
|
structureName: constantToString(QUALIFYING),
|
|
33440
33477
|
stage: QUALIFYING,
|
|
33478
|
+
qualifyingOnly,
|
|
33479
|
+
tieFormat,
|
|
33441
33480
|
});
|
|
33442
33481
|
const { link } = generateQualifyingLink({
|
|
33443
33482
|
sourceStructureId: qualifyingStructure.structureId,
|