tods-competition-factory 2.2.47 → 2.2.49

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.
@@ -5739,6 +5739,7 @@ declare function bulkMatchUpStatusUpdate(params: any): ResultType | {
5739
5739
  message: string;
5740
5740
  code: string;
5741
5741
  };
5742
+ info?: undefined;
5742
5743
  } | {
5743
5744
  error: {
5744
5745
  message: string;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  function factoryVersion() {
6
- return '2.2.47';
6
+ return '2.2.49';
7
7
  }
8
8
 
9
9
  const SINGLES_MATCHUP = 'SINGLES';
@@ -2256,7 +2256,7 @@ function isValidMatchUpFormat({ matchUpFormat }) {
2256
2256
  const preserveRedundant = !!((setParts && tiebreakTo && setsTo === tiebreakAt) ||
2257
2257
  (finalSetParts && finalSetTiebreakTo && finalSetTo === finalTiebreakAt));
2258
2258
  const stringified = stringify(parsedFormat, preserveRedundant);
2259
- return stringified === matchUpFormat;
2259
+ return stringified === matchUpFormat.replace(/G/, '');
2260
2260
  }
2261
2261
 
2262
2262
  const validDateString = /^[\d]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][\d]|3[0-1])$/;
@@ -32384,12 +32384,10 @@ function validateSetScore(set, matchUpFormat, isDecidingSet, allowIncomplete) {
32384
32384
  if (side1Score === 0 && side2Score === 0) {
32385
32385
  return { isValid: false, error: 'Timed set requires at least one side to have scored' };
32386
32386
  }
32387
- if (setFormat.based === 'P') {
32388
- if (side1Score === side2Score && side1Score > 0 && setFormat.tiebreakFormat) {
32389
- const hasTiebreak = set.side1TiebreakScore !== undefined || set.side2TiebreakScore !== undefined;
32390
- if (!hasTiebreak) {
32391
- return { isValid: false, error: 'Tied timed set requires tiebreak' };
32392
- }
32387
+ if (setFormat.based === 'P' && side1Score === side2Score && side1Score > 0 && setFormat.tiebreakFormat) {
32388
+ const hasTiebreak = set.side1TiebreakScore !== undefined || set.side2TiebreakScore !== undefined;
32389
+ if (!hasTiebreak) {
32390
+ return { isValid: false, error: 'Tied timed set requires tiebreak' };
32393
32391
  }
32394
32392
  }
32395
32393
  }
@@ -47346,7 +47344,7 @@ function generateScoreForWinnerOrder(neutralParsedSets, inferredWinningSide, mat
47346
47344
  };
47347
47345
  }
47348
47346
  function generateOutcomeFromScoreString(params) {
47349
- const { matchUpFormat, matchUpStatus, winningSide, scoreString, setTBlast } = params;
47347
+ const { matchUpFormat, matchUpStatus, winningSide, scoreString, setTBlast, preserveSideOrder = false } = params;
47350
47348
  if (!scoreString)
47351
47349
  return {
47352
47350
  outcome: {
@@ -47362,7 +47360,7 @@ function generateOutcomeFromScoreString(params) {
47362
47360
  const inferredWinningSide = inferWinningSide(winningSide, matchUpFormat, neutralParsedSets);
47363
47361
  const parsedFormat = parse(matchUpFormat);
47364
47362
  const isAggregateScoring = parsedFormat?.setFormat?.based === 'A' || parsedFormat?.finalSetFormat?.based === 'A';
47365
- const score = isBracketNotation || isAggregateScoring
47363
+ const score = preserveSideOrder || isBracketNotation || isAggregateScoring
47366
47364
  ? generateScoreForSideOrder(scoreString, matchUpFormat, setTBlast)
47367
47365
  : generateScoreForWinnerOrder(neutralParsedSets, inferredWinningSide, matchUpFormat, setTBlast);
47368
47366
  return definedAttributes({
@@ -52051,8 +52049,7 @@ function processLeagueProfiles(params) {
52051
52049
  homeVenueIds,
52052
52050
  };
52053
52051
  homeVenueIds.forEach((venueId) => !venueIds.includes(venueId) && venueIds.push(venueId));
52054
- allUniqueParticipantIds.push(...individualParticipantIds);
52055
- allUniqueParticipantIds.push(teamParticipantId);
52052
+ allUniqueParticipantIds.push(...individualParticipantIds, teamParticipantId);
52056
52053
  const result = addParticipants({
52057
52054
  participants: [teamParticipant, ...participants],
52058
52055
  tournamentRecord,
@@ -55533,12 +55530,12 @@ function proConflicts({ tournamentRecords, matchUps, }) {
55533
55530
  const sourceMatchUpIds = deps[matchUpId].matchUpIds;
55534
55531
  sourceMatchUpIds.length && profile.sourceMatchUpIds.push(...sourceMatchUpIds);
55535
55532
  const matchUpParticipantIds = sides
55536
- ?.map((side) => [side.participant?.individualParticipantIds, side.participantId])
55533
+ ?.flatMap((side) => [side.participant?.individualParticipantIds, side.participantId])
55537
55534
  .flat()
55538
55535
  .filter(Boolean) ?? [];
55539
55536
  const potentialMatchUpParticipantIds = potentialParticipants
55540
55537
  ?.flat()
55541
- .map(({ individualParticipantIds, participantId }) => [individualParticipantIds, participantId])
55538
+ .flatMap(({ individualParticipantIds, participantId }) => [individualParticipantIds, participantId])
55542
55539
  .flat()
55543
55540
  .filter(Boolean) || [];
55544
55541
  profile.participantIds.push(...potentialMatchUpParticipantIds, ...matchUpParticipantIds);
@@ -55553,6 +55550,41 @@ function proConflicts({ tournamentRecords, matchUps, }) {
55553
55550
  }));
55554
55551
  const sourceDistance = (a, b) => deps[a].sources.reduce((distance, round, index) => (round.includes(b) && index + 1) || distance, 0);
55555
55552
  const rowIssues = rowProfiles.map(() => []);
55553
+ const addWarningToMatchUp = (matchUpId, warnedMatchUpIds, participantConflicts) => {
55554
+ if (!participantConflicts[matchUpId])
55555
+ participantConflicts[matchUpId] = {};
55556
+ if (!participantConflicts[matchUpId][SCHEDULE_WARNING]) {
55557
+ participantConflicts[matchUpId][SCHEDULE_WARNING] = warnedMatchUpIds.filter((id) => id !== matchUpId);
55558
+ }
55559
+ };
55560
+ const processParticipantWarnings = (previousRow, row, participantConflicts) => {
55561
+ const previousRowWarnings = row.participantIds.filter((id) => previousRow.participantIds.includes(id));
55562
+ previousRowWarnings.forEach((participantId) => {
55563
+ const warnedMatchUpIds = row.matchUpIds
55564
+ .concat(previousRow.matchUpIds)
55565
+ .filter((matchUpId) => deps[matchUpId].participantIds.includes(participantId));
55566
+ warnedMatchUpIds.forEach((matchUpId) => {
55567
+ addWarningToMatchUp(matchUpId, warnedMatchUpIds, participantConflicts);
55568
+ });
55569
+ });
55570
+ };
55571
+ const addConflictToMatchUp = (matchUpId, conflictedMatchUpIds, participantConflicts) => {
55572
+ if (!participantConflicts[matchUpId])
55573
+ participantConflicts[matchUpId] = {};
55574
+ if (!participantConflicts[matchUpId][SCHEDULE_CONFLICT]) {
55575
+ participantConflicts[matchUpId][SCHEDULE_CONFLICT] = conflictedMatchUpIds.filter((id) => id !== matchUpId);
55576
+ }
55577
+ };
55578
+ const processParticipantConflicts = (row) => {
55579
+ const participantConflicts = {};
55580
+ const instances = instanceCount(row.participantIds);
55581
+ const conflictedParticipantIds = new Set(Object.keys(instances).filter((key) => instances[key] > 1));
55582
+ const conflictedMatchUpIds = row.matchUpIds.filter((matchUpId) => deps[matchUpId].participantIds.some((id) => conflictedParticipantIds.has(id)));
55583
+ conflictedMatchUpIds.forEach((matchUpId) => {
55584
+ addConflictToMatchUp(matchUpId, conflictedMatchUpIds, participantConflicts);
55585
+ });
55586
+ return participantConflicts;
55587
+ };
55556
55588
  const annotate = (matchUpId, issue, issueType, issueIds) => {
55557
55589
  if (!mappedMatchUps[matchUpId].schedule[SCHEDULE_STATE]) {
55558
55590
  mappedMatchUps[matchUpId].schedule[SCHEDULE_STATE] = issue;
@@ -55572,31 +55604,9 @@ function proConflicts({ tournamentRecords, matchUps, }) {
55572
55604
  rowProfiles.forEach((row, rowIndex) => {
55573
55605
  const previousRow = rowIndex ? rowProfiles[rowIndex - 1] : undefined;
55574
55606
  const subsequentRows = rowProfiles.slice(rowIndex + 1);
55575
- const participantConflicts = {};
55576
- const instances = instanceCount(row.participantIds);
55577
- const conflictedParticipantIds = Object.keys(instances).filter((key) => instances[key] > 1);
55578
- const conflictedMatchUpIds = row.matchUpIds.filter((matchUpId) => deps[matchUpId].participantIds.some((id) => conflictedParticipantIds.includes(id)));
55579
- conflictedMatchUpIds.forEach((matchUpId) => {
55580
- if (!participantConflicts[matchUpId])
55581
- participantConflicts[matchUpId] = {};
55582
- if (!participantConflicts[matchUpId][SCHEDULE_CONFLICT]) {
55583
- participantConflicts[matchUpId][SCHEDULE_CONFLICT] = conflictedMatchUpIds.filter((id) => id !== matchUpId);
55584
- }
55585
- });
55586
- const previousRowWarnings = previousRow && row.participantIds.filter((id) => previousRow.participantIds.includes(id));
55587
- if (previousRowWarnings) {
55588
- previousRowWarnings.forEach((participantId) => {
55589
- const warnedMatchUpIds = row.matchUpIds
55590
- .concat(previousRow.matchUpIds)
55591
- .filter((matchUpId) => deps[matchUpId].participantIds.includes(participantId));
55592
- warnedMatchUpIds.forEach((matchUpId) => {
55593
- if (!participantConflicts[matchUpId])
55594
- participantConflicts[matchUpId] = {};
55595
- if (!participantConflicts[matchUpId][SCHEDULE_WARNING]) {
55596
- participantConflicts[matchUpId][SCHEDULE_WARNING] = warnedMatchUpIds.filter((id) => id !== matchUpId);
55597
- }
55598
- });
55599
- });
55607
+ const participantConflicts = processParticipantConflicts(row);
55608
+ if (previousRow) {
55609
+ processParticipantWarnings(previousRow, row, participantConflicts);
55600
55610
  }
55601
55611
  row.matchUpIds.forEach((matchUpId) => {
55602
55612
  const sourceMatchUpIds = deps[matchUpId].matchUpIds;