tods-competition-factory 2.2.16 → 2.2.17

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.
@@ -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;
@@ -3824,6 +3825,7 @@ type GenerateDrawStructuresAndLinksArgs = {
3824
3825
  overwriteExisting?: boolean;
3825
3826
  drawTypeCoercion?: boolean;
3826
3827
  staggeredEntry?: boolean;
3828
+ qualifyingOnly?: boolean;
3827
3829
  qualifyingProfiles?: any;
3828
3830
  structureName?: string;
3829
3831
  tieFormat?: TieFormat;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  function factoryVersion() {
6
- return '2.2.16';
6
+ return '2.2.17';
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
- function capitalizeFirst(str) {
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 };
@@ -19728,6 +19730,9 @@ function resetQualifyingStructure({ tournamentRecord, drawDefinition, event, str
19728
19730
  const structure = drawDefinition.structures?.find((structure) => structure.stage === QUALIFYING && structure.structureId === structureId);
19729
19731
  if (!structure)
19730
19732
  return { error: STRUCTURE_NOT_FOUND };
19733
+ const scoresPresent = structure.matchUps?.some(({ matchUpStatus, score }) => checkScoreHasValue({ score }) ?? completedMatchUpStatuses.includes(matchUpStatus));
19734
+ if (scoresPresent)
19735
+ return { error: SCORES_PRESENT };
19731
19736
  const removedMatchUpIds = structure.matchUps?.map(({ matchUpId }) => matchUpId) || [];
19732
19737
  structure.positionAssignments = [];
19733
19738
  structure.seedAssignments = [];
@@ -21919,36 +21924,37 @@ function calculatePercentages({ participantResults, matchUpFormat, tallyPolicy,
21919
21924
  const bestOfGames = parsedGroupMatchUpFormat.bestOf;
21920
21925
  const bracketSetsToWin = (bestOfGames && Math.ceil(bestOfGames / 2)) || 1;
21921
21926
  const bracketGamesForSet = parsedGroupMatchUpFormat.setFormat?.setTo;
21927
+ const precision = Math.pow(10, tallyPolicy?.precision || 3);
21922
21928
  Object.keys(participantResults).forEach((participantId) => {
21923
21929
  const setsWon = participantResults[participantId].setsWon;
21924
21930
  const setsLost = participantResults[participantId].setsLost;
21925
21931
  const setsTotal = tallyPolicy?.groupTotalSetsPlayed
21926
21932
  ? totalSets
21927
21933
  : perPlayer * (bracketSetsToWin || 0) || setsWon + setsLost;
21928
- let setsPct = Math.round((setsWon / setsTotal) * 1000) / 1000;
21934
+ let setsPct = Math.round((setsWon / setsTotal) * precision) / precision;
21929
21935
  if (setsPct === Infinity || isNaN(setsPct))
21930
21936
  setsPct = setsTotal;
21931
21937
  const tieMatchUpsWon = participantResults[participantId].tieMatchUpsWon;
21932
21938
  const tieMatchUpsLost = participantResults[participantId].tieMatchUpsLost;
21933
21939
  const tieMatchUpsTotal = tieMatchUpsWon + tieMatchUpsLost;
21934
- let tieMatchUpsPct = Math.round((tieMatchUpsWon / tieMatchUpsTotal) * 1000) / 1000;
21940
+ let tieMatchUpsPct = Math.round((tieMatchUpsWon / tieMatchUpsTotal) * precision) / precision;
21935
21941
  if (tieMatchUpsPct === Infinity || isNaN(tieMatchUpsPct))
21936
21942
  tieMatchUpsPct = tieMatchUpsWon;
21937
21943
  const matchUpsWon = participantResults[participantId].matchUpsWon;
21938
21944
  const matchUpsLost = participantResults[participantId].matchUpsLost;
21939
21945
  const matchUpsTotal = matchUpsWon + matchUpsLost;
21940
- let matchUpsPct = Math.round((matchUpsWon / matchUpsTotal) * 1000) / 1000;
21946
+ let matchUpsPct = Math.round((matchUpsWon / matchUpsTotal) * precision) / precision;
21941
21947
  if (matchUpsPct === Infinity || isNaN(matchUpsPct))
21942
21948
  matchUpsPct = matchUpsWon;
21943
21949
  const gamesWon = participantResults[participantId].gamesWon || 0;
21944
21950
  const gamesLost = participantResults[participantId].gamesLost || 0;
21945
21951
  const minimumExpectedGames = (perPlayer || 0) * (bracketSetsToWin || 0) * (bracketGamesForSet || 0);
21946
21952
  const gamesTotal = Math.max(minimumExpectedGames, gamesWon + gamesLost);
21947
- let gamesPct = Math.round((gamesWon / gamesTotal) * 1000) / 1000;
21953
+ let gamesPct = Math.round((gamesWon / gamesTotal) * precision) / precision;
21948
21954
  if (gamesPct === Infinity || isNaN(gamesPct))
21949
21955
  gamesPct = 0;
21950
21956
  const pointsTotal = participantResults[participantId].pointsWon + participantResults[participantId].pointsLost;
21951
- let pointsPct = Math.round((participantResults[participantId].pointsWon / pointsTotal) * 1000) / 1000;
21957
+ let pointsPct = Math.round((participantResults[participantId].pointsWon / pointsTotal) * precision) / precision;
21952
21958
  if (pointsPct === Infinity || isNaN(pointsPct))
21953
21959
  pointsPct = 0;
21954
21960
  participantResults[participantId].setsWon = setsWon;
@@ -27051,7 +27057,7 @@ var query$b = {
27051
27057
  positionActions: positionActions
27052
27058
  };
27053
27059
 
27054
- function generateQualifyingStructures({ qualifyingProfiles, appliedPolicies, idPrefix, isMock, uuids, }) {
27060
+ function generateQualifyingStructures({ hasExistingDrawDefinition, qualifyingProfiles, appliedPolicies, qualifyingOnly, tieFormat, idPrefix, isMock, uuids, }) {
27055
27061
  const stack = 'generateQualifyingSTructures';
27056
27062
  const qualifyingDetails = [];
27057
27063
  const structures = [];
@@ -27115,11 +27121,14 @@ function generateQualifyingStructures({ qualifyingProfiles, appliedPolicies, idP
27115
27121
  structureName: structureProfile.structureName || qualifyingStructureName,
27116
27122
  structureId: structureId || uuids?.pop(),
27117
27123
  qualifyingRoundNumber: roundLimit,
27124
+ hasExistingDrawDefinition,
27118
27125
  stage: QUALIFYING,
27126
+ qualifyingOnly,
27119
27127
  matchUpFormat,
27120
27128
  stageSequence,
27121
27129
  matchUpType,
27122
27130
  roundLimit,
27131
+ tieFormat,
27123
27132
  matchUps,
27124
27133
  });
27125
27134
  if (roundTarget) {
@@ -27457,7 +27466,7 @@ function luckyRoundProfiles(drawSize) {
27457
27466
  }
27458
27467
 
27459
27468
  function getGenerators(params) {
27460
- const { playoffAttributes, stageSequence = 1, stage = MAIN, matchUpType, drawSize, uuids } = params;
27469
+ const { playoffAttributes, stageSequence = 1, stage = MAIN, tieFormat, matchUpType, drawSize, uuids } = params;
27461
27470
  const getPrefixedStructureId = () => {
27462
27471
  if (!params.isMock && !params.idPrefix)
27463
27472
  return undefined;
@@ -27476,6 +27485,7 @@ function getGenerators(params) {
27476
27485
  structureName,
27477
27486
  matchUpType,
27478
27487
  structureId,
27488
+ tieFormat,
27479
27489
  matchUps,
27480
27490
  stage,
27481
27491
  });
@@ -27529,6 +27539,7 @@ function getGenerators(params) {
27529
27539
  matchUpType,
27530
27540
  structureId,
27531
27541
  stage: MAIN,
27542
+ tieFormat,
27532
27543
  matchUps,
27533
27544
  });
27534
27545
  return { structures: [structure], links: [], ...SUCCESS };
@@ -27548,7 +27559,7 @@ function getGenerators(params) {
27548
27559
  }
27549
27560
 
27550
27561
  function generateDrawStructuresAndLinks(params) {
27551
- const { enforceMinimumDrawSize = true, overwriteExisting, appliedPolicies, staggeredEntry, drawDefinition, tieFormat, isMock, uuids, } = params || {};
27562
+ const { enforceMinimumDrawSize = true, overwriteExisting, appliedPolicies, qualifyingOnly, staggeredEntry, drawDefinition, tieFormat, isMock, uuids, } = params || {};
27552
27563
  const drawSize = ensureInt(params.drawSize);
27553
27564
  const drawTypeCoercion = params.drawTypeCoercion ?? getDrawTypeCoercion({ appliedPolicies, drawType: params.drawType });
27554
27565
  const stack = 'generateDrawStructuresAndLinks';
@@ -27613,6 +27624,8 @@ function generateDrawStructuresAndLinks(params) {
27613
27624
  idPrefix: params.idPrefix,
27614
27625
  qualifyingProfiles,
27615
27626
  appliedPolicies,
27627
+ qualifyingOnly,
27628
+ tieFormat,
27616
27629
  isMock,
27617
27630
  uuids,
27618
27631
  });
@@ -32383,13 +32396,16 @@ function getDrawFormat(params) {
32383
32396
 
32384
32397
  function processExistingDrawDefinition(params) {
32385
32398
  const drawDefinition = params.drawDefinition;
32386
- const { existingQualifyingPlaceholderStructureId, appliedPolicies, drawEntries, structureId, idPrefix, isMock, event, } = params;
32399
+ const { existingQualifyingPlaceholderStructureId, appliedPolicies, qualifyingOnly, drawEntries, structureId, tieFormat, idPrefix, isMock, event, } = params;
32387
32400
  const qualifyingProfiles = params.qualifyingProfiles;
32388
32401
  const qualifyingResult = qualifyingProfiles?.length
32389
32402
  ? generateQualifyingStructures({
32403
+ hasExistingDrawDefinition: true,
32390
32404
  uuids: params.uuids,
32391
32405
  qualifyingProfiles,
32392
32406
  appliedPolicies,
32407
+ qualifyingOnly,
32408
+ tieFormat,
32393
32409
  idPrefix,
32394
32410
  isMock,
32395
32411
  })
@@ -33375,7 +33391,7 @@ function generateOrGetExisting(params) {
33375
33391
  }
33376
33392
 
33377
33393
  function qualifyingGeneration(params) {
33378
- const { qualifyingPlaceholder, qualifyingProfiles, existingDrawDefinition, positioningReports, appliedPolicies, qualifyingOnly, drawDefinition, seedingProfile, participants, structureId, entries, stack, } = params;
33394
+ const { qualifyingPlaceholder, existingDrawDefinition, positioningReports, qualifyingProfiles, appliedPolicies, qualifyingOnly, drawDefinition, seedingProfile, participants, structureId, tieFormat, entries, stack, } = params;
33379
33395
  const generateQualifyingPlaceholder = qualifyingPlaceholder && !qualifyingProfiles?.length && !existingDrawDefinition;
33380
33396
  const qualifyingConflicts = [];
33381
33397
  if (qualifyingProfiles) {
@@ -33438,6 +33454,8 @@ function qualifyingGeneration(params) {
33438
33454
  const qualifyingStructure = structureTemplate({
33439
33455
  structureName: constantToString(QUALIFYING),
33440
33456
  stage: QUALIFYING,
33457
+ qualifyingOnly,
33458
+ tieFormat,
33441
33459
  });
33442
33460
  const { link } = generateQualifyingLink({
33443
33461
  sourceStructureId: qualifyingStructure.structureId,