tods-competition-factory 0.86.1 → 0.86.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.development.cjs.js +239 -22
- 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/dist/tods-competition-factory.production.esm.min.js +1 -1
- package/dist/tods-competition-factory.production.esm.min.js.map +1 -1
- package/package.json +5 -5
|
@@ -249,7 +249,7 @@ const matchUpFormatCode = {
|
|
|
249
249
|
};
|
|
250
250
|
|
|
251
251
|
function factoryVersion() {
|
|
252
|
-
return '0.86.
|
|
252
|
+
return '0.86.2';
|
|
253
253
|
}
|
|
254
254
|
|
|
255
255
|
const FORMAT_STANDARD = 'SET3-S:6/TB7'; // Best of 3 Tiebreak Sets to 6
|
|
@@ -42686,24 +42686,30 @@ const publishingGovernor = {
|
|
|
42686
42686
|
unPublishEvent
|
|
42687
42687
|
};
|
|
42688
42688
|
|
|
42689
|
-
function analyzeDraws(
|
|
42689
|
+
function analyzeDraws({
|
|
42690
|
+
tournamentRecord
|
|
42691
|
+
}) {
|
|
42690
42692
|
var _tournamentRecord$eve;
|
|
42691
42693
|
|
|
42694
|
+
if (!tournamentRecord) return {
|
|
42695
|
+
error: MISSING_TOURNAMENT_RECORD
|
|
42696
|
+
};
|
|
42692
42697
|
const drawsAnalysis = {
|
|
42693
|
-
|
|
42694
|
-
// no positions assigned
|
|
42695
|
-
positionsNoOutcomes: 0,
|
|
42698
|
+
positionsNoOutcomes: [],
|
|
42696
42699
|
// all positions assigned and no outcomes
|
|
42697
|
-
|
|
42698
|
-
// only first round has active matchUps; some unassigned positions
|
|
42699
|
-
canBePruned: 0,
|
|
42700
|
+
canBePruned: [],
|
|
42700
42701
|
// partially assigned positions with outcomes => drawSizes can be reduced
|
|
42701
|
-
|
|
42702
|
+
matchPlay: [],
|
|
42703
|
+
// only first round has active matchUps; some unassigned positions
|
|
42704
|
+
inactive: [],
|
|
42705
|
+
drawAnalysis: {}
|
|
42702
42706
|
};
|
|
42703
42707
|
const drawDefinitions = (_tournamentRecord$eve = tournamentRecord.events) === null || _tournamentRecord$eve === void 0 ? void 0 : _tournamentRecord$eve.map(event => event === null || event === void 0 ? void 0 : event.drawDefinitions).flat().filter(Boolean);
|
|
42704
42708
|
drawDefinitions.forEach(drawDefinition => {
|
|
42709
|
+
let positionsAssignedCount = 0;
|
|
42710
|
+
let matchUpsWithWinningSideCount = 0;
|
|
42705
42711
|
const structures = (drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.structures) || [];
|
|
42706
|
-
const
|
|
42712
|
+
const structuresData = structures.map(structure => {
|
|
42707
42713
|
const {
|
|
42708
42714
|
stage,
|
|
42709
42715
|
stageSequence,
|
|
@@ -42716,6 +42722,16 @@ function analyzeDraws(tournamentRecord) {
|
|
|
42716
42722
|
drawDefinition,
|
|
42717
42723
|
structure
|
|
42718
42724
|
});
|
|
42725
|
+
const matchUpsWithWinningSide = inContextStructureMatchUps === null || inContextStructureMatchUps === void 0 ? void 0 : inContextStructureMatchUps.filter(({
|
|
42726
|
+
winningSide
|
|
42727
|
+
}) => winningSide);
|
|
42728
|
+
const winningSideCount = matchUpsWithWinningSide.filter(Boolean).length || 0;
|
|
42729
|
+
matchUpsWithWinningSideCount += winningSideCount;
|
|
42730
|
+
const maxWinningSideFirstRoundPosition = Math.max(matchUpsWithWinningSide.filter(({
|
|
42731
|
+
roundNumber
|
|
42732
|
+
}) => roundNumber === 1).map(({
|
|
42733
|
+
roundPosition
|
|
42734
|
+
}) => roundPosition));
|
|
42719
42735
|
const {
|
|
42720
42736
|
positionAssignments
|
|
42721
42737
|
} = getPositionAssignments$1({
|
|
@@ -42724,6 +42740,7 @@ function analyzeDraws(tournamentRecord) {
|
|
|
42724
42740
|
const positionsAssigned = positionAssignments === null || positionAssignments === void 0 ? void 0 : positionAssignments.filter(({
|
|
42725
42741
|
participantId
|
|
42726
42742
|
}) => participantId);
|
|
42743
|
+
positionsAssignedCount += positionsAssigned.length;
|
|
42727
42744
|
const unassignedPositionsCount = ((positionAssignments === null || positionAssignments === void 0 ? void 0 : positionAssignments.length) || 0) - ((positionsAssigned === null || positionsAssigned === void 0 ? void 0 : positionsAssigned.length) || 0);
|
|
42728
42745
|
const {
|
|
42729
42746
|
roundMatchUps,
|
|
@@ -42733,13 +42750,16 @@ function analyzeDraws(tournamentRecord) {
|
|
|
42733
42750
|
} = getRoundMatchUps$1({
|
|
42734
42751
|
matchUps: inContextStructureMatchUps
|
|
42735
42752
|
});
|
|
42736
|
-
const activeRounds = Object.keys(roundProfile).filter(roundNumber => !roundProfile[roundNumber].inactiveRound);
|
|
42753
|
+
const activeRounds = Object.keys(roundProfile).filter(roundNumber => !roundProfile[roundNumber].inactiveRound).map(roundNumber => parseInt(roundNumber));
|
|
42754
|
+
const inactiveRounds = Object.keys(roundProfile).filter(roundNumber => roundProfile[roundNumber].inactiveRound).map(roundNumber => parseInt(roundNumber));
|
|
42737
42755
|
const inactiveStructure = Object.values(roundProfile).every(profile => profile.inactiveRound);
|
|
42738
42756
|
return {
|
|
42739
42757
|
positionsAssignedCount: (positionsAssigned === null || positionsAssigned === void 0 ? void 0 : positionsAssigned.length) || 0,
|
|
42758
|
+
maxWinningSideFirstRoundPosition,
|
|
42740
42759
|
unassignedPositionsCount,
|
|
42741
42760
|
inactiveStructure,
|
|
42742
42761
|
maxMatchUpsCount,
|
|
42762
|
+
inactiveRounds,
|
|
42743
42763
|
roundMatchUps,
|
|
42744
42764
|
activeRounds,
|
|
42745
42765
|
roundNumbers,
|
|
@@ -42750,16 +42770,35 @@ function analyzeDraws(tournamentRecord) {
|
|
|
42750
42770
|
stage
|
|
42751
42771
|
};
|
|
42752
42772
|
});
|
|
42753
|
-
const mainStructure =
|
|
42754
|
-
const
|
|
42755
|
-
|
|
42756
|
-
|
|
42757
|
-
|
|
42758
|
-
|
|
42759
|
-
|
|
42760
|
-
|
|
42761
|
-
|
|
42773
|
+
const mainStructure = structuresData.find(data => data.orderNumber === 2 && data.stageSequence === 1);
|
|
42774
|
+
const activeStructuresCount = structuresData.filter(({
|
|
42775
|
+
inactiveStructure
|
|
42776
|
+
}) => !inactiveStructure).length;
|
|
42777
|
+
const {
|
|
42778
|
+
links
|
|
42779
|
+
} = getStructureLinks({
|
|
42780
|
+
drawDefinition,
|
|
42781
|
+
structureId: mainStructure.structureId
|
|
42762
42782
|
});
|
|
42783
|
+
const isMatchPlay = parseInt(mainStructure.activeRounds[0]) === 1 && mainStructure.activeRounds.length === 1 && activeStructuresCount === 1;
|
|
42784
|
+
const inactiveDraw = structuresData === null || structuresData === void 0 ? void 0 : structuresData.every(({
|
|
42785
|
+
inactiveStructure
|
|
42786
|
+
}) => inactiveStructure);
|
|
42787
|
+
const canBePruned = !links.length && mainStructure.activeRounds.length && (mainStructure.roundProfile[1].inactiveCount || mainStructure.inactiveRounds.length);
|
|
42788
|
+
const drawId = drawDefinition.drawId;
|
|
42789
|
+
if (positionsAssignedCount && !matchUpsWithWinningSideCount) drawsAnalysis.positionsNoOutcomes.push(drawId);
|
|
42790
|
+
if (inactiveDraw) drawsAnalysis.inactive.push(drawId);
|
|
42791
|
+
if (isMatchPlay) drawsAnalysis.matchPlay.push(drawId);
|
|
42792
|
+
if (canBePruned) drawsAnalysis.canBePruned.push(drawId);
|
|
42793
|
+
const drawAnalysis = {
|
|
42794
|
+
matchUpsWithWinningSideCount,
|
|
42795
|
+
positionsAssignedCount,
|
|
42796
|
+
structuresData,
|
|
42797
|
+
inactiveDraw,
|
|
42798
|
+
isMatchPlay,
|
|
42799
|
+
drawId
|
|
42800
|
+
};
|
|
42801
|
+
drawsAnalysis.drawAnalysis[drawId] = drawAnalysis;
|
|
42763
42802
|
});
|
|
42764
42803
|
return { ...SUCCESS,
|
|
42765
42804
|
drawsAnalysis
|
|
@@ -42777,7 +42816,7 @@ function checkIsDual(tournamentRecord) {
|
|
|
42777
42816
|
const drawDefinition = (event === null || event === void 0 ? void 0 : (_event$drawDefinition = event.drawDefinitions) === null || _event$drawDefinition === void 0 ? void 0 : _event$drawDefinition.length) === 1 && event.drawDefinitions[0];
|
|
42778
42817
|
const structure = (drawDefinition === null || drawDefinition === void 0 ? void 0 : (_drawDefinition$struc = drawDefinition.structures) === null || _drawDefinition$struc === void 0 ? void 0 : _drawDefinition$struc.length) === 1 && drawDefinition.structures[0];
|
|
42779
42818
|
const twoDrawPositions = (structure === null || structure === void 0 ? void 0 : (_structure$positionAs = structure.positionAssignments) === null || _structure$positionAs === void 0 ? void 0 : _structure$positionAs.length) === 2;
|
|
42780
|
-
return event.tieFormat && twoTeams && twoDrawPositions;
|
|
42819
|
+
return !!(event.tieFormat && twoTeams && twoDrawPositions);
|
|
42781
42820
|
}
|
|
42782
42821
|
|
|
42783
42822
|
function analyzeTournament({
|
|
@@ -42788,7 +42827,9 @@ function analyzeTournament({
|
|
|
42788
42827
|
};
|
|
42789
42828
|
const {
|
|
42790
42829
|
drawsAnalysis
|
|
42791
|
-
} = analyzeDraws(
|
|
42830
|
+
} = analyzeDraws({
|
|
42831
|
+
tournamentRecord
|
|
42832
|
+
});
|
|
42792
42833
|
const analysis = {
|
|
42793
42834
|
isDual: checkIsDual(tournamentRecord),
|
|
42794
42835
|
drawsAnalysis
|
|
@@ -42895,6 +42936,7 @@ const tournamentGovernor = {
|
|
|
42895
42936
|
addNotes,
|
|
42896
42937
|
removeNotes,
|
|
42897
42938
|
analyzeTournament,
|
|
42939
|
+
analyzeDraws,
|
|
42898
42940
|
setTournamentName,
|
|
42899
42941
|
setTournamentNotes,
|
|
42900
42942
|
setTournamentEndDate,
|
|
@@ -46577,6 +46619,179 @@ function deleteAdHocMatchUps(params) {
|
|
|
46577
46619
|
return deleteAdHocMatchUps$1(params);
|
|
46578
46620
|
}
|
|
46579
46621
|
|
|
46622
|
+
function resetDrawDefinition({
|
|
46623
|
+
drawDefinition,
|
|
46624
|
+
removeScheduling
|
|
46625
|
+
}) {
|
|
46626
|
+
if (!drawDefinition) return {
|
|
46627
|
+
error: MISSING_DRAW_DEFINITION
|
|
46628
|
+
}; // for matchups in all structures:
|
|
46629
|
+
// remove all drawPositions which are not first round or fed
|
|
46630
|
+
// remove all extensions
|
|
46631
|
+
// if removeScheudling, remove all scheduling timeItems
|
|
46632
|
+
// for all structures which are NOT QUALIFYING or MAIN { stageSequence: 1 }
|
|
46633
|
+
// remove all positionAssignments that are not BYE
|
|
46634
|
+
|
|
46635
|
+
const matchUpsMap = getMatchUpsMap({
|
|
46636
|
+
drawDefinition
|
|
46637
|
+
});
|
|
46638
|
+
|
|
46639
|
+
const getRawMatchUp = matchUpId => {
|
|
46640
|
+
var _matchUpsMap$drawMatc;
|
|
46641
|
+
|
|
46642
|
+
return matchUpsMap === null || matchUpsMap === void 0 ? void 0 : (_matchUpsMap$drawMatc = matchUpsMap.drawMatchUps) === null || _matchUpsMap$drawMatc === void 0 ? void 0 : _matchUpsMap$drawMatc.find(matchUp => matchUp.matchUpId === matchUpId);
|
|
46643
|
+
};
|
|
46644
|
+
|
|
46645
|
+
for (const structure of drawDefinition.structures || []) {
|
|
46646
|
+
const {
|
|
46647
|
+
positionAssignments,
|
|
46648
|
+
stage,
|
|
46649
|
+
stageSequence
|
|
46650
|
+
} = structure; // reset positionAssignments and seedAssignments where appropriate
|
|
46651
|
+
|
|
46652
|
+
if (positionAssignments && (stageSequence !== 1 || ![QUALIFYING, MAIN].includes(stage))) {
|
|
46653
|
+
structure.positionAssignments = positionAssignments.map(assignment => {
|
|
46654
|
+
delete assignment.participantId;
|
|
46655
|
+
return assignment;
|
|
46656
|
+
});
|
|
46657
|
+
structure.seedAssignments = [];
|
|
46658
|
+
}
|
|
46659
|
+
|
|
46660
|
+
const {
|
|
46661
|
+
matchUps: inContextMatchUps
|
|
46662
|
+
} = getAllStructureMatchUps({
|
|
46663
|
+
inContext: true,
|
|
46664
|
+
matchUpsMap,
|
|
46665
|
+
structure
|
|
46666
|
+
}); // reset all matchUps to initial state
|
|
46667
|
+
|
|
46668
|
+
for (const inContextMatchUp of inContextMatchUps) {
|
|
46669
|
+
var _matchUp$timeItems;
|
|
46670
|
+
|
|
46671
|
+
const {
|
|
46672
|
+
matchUpId,
|
|
46673
|
+
roundNumber,
|
|
46674
|
+
sides
|
|
46675
|
+
} = inContextMatchUp;
|
|
46676
|
+
const matchUp = getRawMatchUp(matchUpId);
|
|
46677
|
+
delete matchUp.extensions;
|
|
46678
|
+
delete matchUp.notes;
|
|
46679
|
+
|
|
46680
|
+
if (matchUp.matchUpStatus !== BYE) {
|
|
46681
|
+
matchUp.matchUpStatus = TO_BE_PLAYED;
|
|
46682
|
+
delete matchUp.matchUpStatusCodes;
|
|
46683
|
+
delete matchUp.matchUpFormat;
|
|
46684
|
+
delete matchUp.winningSide;
|
|
46685
|
+
delete matchUp.score;
|
|
46686
|
+
}
|
|
46687
|
+
|
|
46688
|
+
if (roundNumber && roundNumber > 1 && matchUp.drawPositions) {
|
|
46689
|
+
const fedDrawPositions = sides === null || sides === void 0 ? void 0 : sides.map(({
|
|
46690
|
+
drawPosition,
|
|
46691
|
+
participantFed
|
|
46692
|
+
}) => !participantFed && drawPosition).filter(Boolean);
|
|
46693
|
+
matchUp.drawPositions = matchUp.drawPositions.map(drawPosition => !fedDrawPositions.includes(drawPosition) ? drawPosition : undefined);
|
|
46694
|
+
}
|
|
46695
|
+
|
|
46696
|
+
if (removeScheduling) {
|
|
46697
|
+
delete matchUp.timeItems;
|
|
46698
|
+
} else if ((_matchUp$timeItems = matchUp.timeItems) !== null && _matchUp$timeItems !== void 0 && _matchUp$timeItems.length) {
|
|
46699
|
+
matchUp.timeItems = matchUp.timeItems.filter(timeItem => ![ASSIGN_COURT, ASSIGN_VENUE, ASSIGN_OFFICIAL, SCHEDULED_DATE, SCHEDULED_TIME].includes(timeItem.itemType));
|
|
46700
|
+
}
|
|
46701
|
+
|
|
46702
|
+
modifyMatchUpNotice({
|
|
46703
|
+
drawDefinition,
|
|
46704
|
+
matchUp
|
|
46705
|
+
});
|
|
46706
|
+
}
|
|
46707
|
+
}
|
|
46708
|
+
|
|
46709
|
+
const structureIds = (drawDefinition.structures || []).map(({
|
|
46710
|
+
structureId
|
|
46711
|
+
}) => structureId);
|
|
46712
|
+
modifyDrawNotice({
|
|
46713
|
+
drawDefinition,
|
|
46714
|
+
structureIds
|
|
46715
|
+
});
|
|
46716
|
+
return { ...SUCCESS
|
|
46717
|
+
};
|
|
46718
|
+
}
|
|
46719
|
+
|
|
46720
|
+
function pruneDrawDefinition({
|
|
46721
|
+
tournamentRecord,
|
|
46722
|
+
drawDefinition,
|
|
46723
|
+
drawId
|
|
46724
|
+
}) {
|
|
46725
|
+
if (!tournamentRecord) return {
|
|
46726
|
+
error: MISSING_TOURNAMENT_RECORD
|
|
46727
|
+
};
|
|
46728
|
+
if (!drawDefinition) return {
|
|
46729
|
+
error: MISSING_DRAW_DEFINITION
|
|
46730
|
+
};
|
|
46731
|
+
const {
|
|
46732
|
+
drawsAnalysis
|
|
46733
|
+
} = analyzeDraws({
|
|
46734
|
+
tournamentRecord
|
|
46735
|
+
});
|
|
46736
|
+
|
|
46737
|
+
if (drawsAnalysis.canBePruned.includes(drawId)) {
|
|
46738
|
+
const isMatchPlay = drawsAnalysis.matchPlay.includes(drawId);
|
|
46739
|
+
const drawAnalysis = drawsAnalysis.drawAnalysis[drawId];
|
|
46740
|
+
const {
|
|
46741
|
+
structures: [mainStructure]
|
|
46742
|
+
} = getDrawStructures({
|
|
46743
|
+
drawDefinition,
|
|
46744
|
+
stage: MAIN,
|
|
46745
|
+
stageSequence: 1
|
|
46746
|
+
});
|
|
46747
|
+
const structureData = drawAnalysis.structuresData.find(({
|
|
46748
|
+
structureId
|
|
46749
|
+
}) => mainStructure.structureId === structureId);
|
|
46750
|
+
const matchUps = mainStructure.matchUps || [];
|
|
46751
|
+
const relevantMatchUps = matchUps.sort((a, b) => a.roundPosition - b.roundPosition).filter(({
|
|
46752
|
+
roundNumber
|
|
46753
|
+
}) => !structureData.inactiveRounds.includes(roundNumber));
|
|
46754
|
+
const relevantMatchUpIds = relevantMatchUps.map(getMatchUpId);
|
|
46755
|
+
const deletedMatchUpIds = matchUps.map(getMatchUpId).filter(matchUpId => !relevantMatchUpIds.includes(matchUpId)); // only ifMatchPlay can the positionAssignments be reallocated
|
|
46756
|
+
|
|
46757
|
+
if (isMatchPlay) {
|
|
46758
|
+
const matchPlayMatchUps = relevantMatchUps.sort((a, b) => a.roundPosition - b.roundPosition).filter(({
|
|
46759
|
+
roundNumber
|
|
46760
|
+
}) => !structureData.inactiveRounds.includes(roundNumber)).filter(({
|
|
46761
|
+
winningSide
|
|
46762
|
+
}) => !isMatchPlay || winningSide);
|
|
46763
|
+
const matchPlayMatchUpIds = matchPlayMatchUps.map(getMatchUpId);
|
|
46764
|
+
const matchUpIdsToDelete = relevantMatchUpIds.filter(matchUpId => !matchPlayMatchUpIds.includes(matchUpId));
|
|
46765
|
+
deletedMatchUpIds.push(...matchUpIdsToDelete);
|
|
46766
|
+
const existingDrawPositionPairings = matchPlayMatchUps.map(({
|
|
46767
|
+
drawPositions
|
|
46768
|
+
}) => drawPositions);
|
|
46769
|
+
const existingDrawPositions = existingDrawPositionPairings.flat();
|
|
46770
|
+
const drawPositionsMap = Object.assign({}, ...existingDrawPositions.map((drawPosition, i) => ({
|
|
46771
|
+
[drawPosition]: i + 1
|
|
46772
|
+
})));
|
|
46773
|
+
matchPlayMatchUps.forEach(matchUp => matchUp.drawPositions = matchUp.drawPositions.map(drawPosition => drawPositionsMap[drawPosition]));
|
|
46774
|
+
const updatedPositionAssignments = mainStructure.positionAssignments.filter(assignment => existingDrawPositions.includes(assignment.drawPosition)).map(assignment => {
|
|
46775
|
+
assignment.drawPosition = drawPositionsMap[assignment.drawPosition];
|
|
46776
|
+
return assignment;
|
|
46777
|
+
});
|
|
46778
|
+
mainStructure.positionAssignments = updatedPositionAssignments;
|
|
46779
|
+
mainStructure.matchUps = matchPlayMatchUps;
|
|
46780
|
+
}
|
|
46781
|
+
|
|
46782
|
+
deleteMatchUpsNotice({
|
|
46783
|
+
drawDefinition,
|
|
46784
|
+
matchUpIds: deletedMatchUpIds
|
|
46785
|
+
});
|
|
46786
|
+
modifyDrawNotice({
|
|
46787
|
+
drawDefinition
|
|
46788
|
+
});
|
|
46789
|
+
}
|
|
46790
|
+
|
|
46791
|
+
return { ...SUCCESS
|
|
46792
|
+
};
|
|
46793
|
+
}
|
|
46794
|
+
|
|
46580
46795
|
/**
|
|
46581
46796
|
*
|
|
46582
46797
|
* @param {object} orderedDrawIdsMap - required - mapping of ALL present drawIds => { [drawId]: drawOrder }
|
|
@@ -47026,6 +47241,8 @@ const eventGovernor = {
|
|
|
47026
47241
|
deleteFlightAndFlightDraw,
|
|
47027
47242
|
generateFlightProfile,
|
|
47028
47243
|
attachFlightProfile,
|
|
47244
|
+
resetDrawDefinition,
|
|
47245
|
+
pruneDrawDefinition,
|
|
47029
47246
|
updateDrawIdsOrder,
|
|
47030
47247
|
getFlightProfile,
|
|
47031
47248
|
getScaledEntries,
|