tods-competition-factory 1.8.21 → 1.8.23

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.
@@ -2071,7 +2071,7 @@ function findVenue({
2071
2071
  if (!venue && tournamentRecords) {
2072
2072
  const linkedTournamentIds = getLinkedTournamentIds({
2073
2073
  tournamentRecords
2074
- }).linkedTournamentIds || [];
2074
+ }).linkedTournamentIds ?? [];
2075
2075
  const relevantIds = linkedTournamentIds[tournamentRecord.tournamentId];
2076
2076
  for (const tournamentId of relevantIds) {
2077
2077
  const record = tournamentRecords[tournamentId];
@@ -2630,7 +2630,7 @@ function getPairedParticipant({
2630
2630
  result: { error: MISSING_PARTICIPANT_IDS },
2631
2631
  stack
2632
2632
  });
2633
- tournamentParticipants = tournamentParticipants || tournamentRecord?.participants || [];
2633
+ tournamentParticipants = tournamentParticipants ?? tournamentRecord?.participants ?? [];
2634
2634
  const existingPairedParticipants = tournamentParticipants.filter(
2635
2635
  (participant) => participant.participantType === PAIR && intersection(participantIds, participant.individualParticipantIds).length === participantIds.length && participant.individualParticipantIds.length === participantIds.length
2636
2636
  );
@@ -3354,7 +3354,6 @@ const DIRECT_ENTRY_STATUSES = [
3354
3354
  const STRUCTURE_SELECTED_STATUSES = [
3355
3355
  CONFIRMED,
3356
3356
  DIRECT_ACCEPTANCE,
3357
- FEED_IN,
3358
3357
  JUNIOR_EXEMPT,
3359
3358
  LUCKY_LOSER,
3360
3359
  QUALIFIER,
@@ -4355,7 +4354,7 @@ function getRoundContextProfile({
4355
4354
  ...(drawDefinition?.structures ?? []).filter((structure2) => structure2.stage === QUALIFYING).map(({ stageSequence }) => stageSequence ?? 1),
4356
4355
  0
4357
4356
  ) : 0;
4358
- const preQualifyingSequence = qualifyingStageSequences ? qualifyingStageSequences - (structure.stageSequence || 1) || "" : "";
4357
+ const preQualifyingSequence = qualifyingStageSequences ? qualifyingStageSequences - (structure.stageSequence ?? 1) || "" : "";
4359
4358
  const preQualifyingAffix = preQualifyingSequence ? roundNamingPolicy?.affixes?.preQualifying || defaultRoundNamingPolicy.affixes.preQualifying || "" : "";
4360
4359
  const roundNamingMap = roundNamingPolicy?.roundNamingMap || defaultRoundNamingPolicy.roundNamingMap || {};
4361
4360
  const abbreviatedRoundNamingMap = roundNamingPolicy?.abbreviatedRoundNamingMap || defaultRoundNamingPolicy.abbreviatedRoundNamingMap || {};
@@ -4653,7 +4652,13 @@ function getAllStructureMatchUps({
4653
4652
  matchUps
4654
4653
  }));
4655
4654
  }
4656
- return { matchUps, roundMatchUps, roundProfile, collectionPositionMatchUps };
4655
+ return {
4656
+ collectionPositionMatchUps,
4657
+ roundMatchUps,
4658
+ roundProfile,
4659
+ matchUpsMap,
4660
+ matchUps
4661
+ };
4657
4662
  function addMatchUpContext({
4658
4663
  scheduleVisibilityFilters: scheduleVisibilityFilters2,
4659
4664
  sourceDrawPositionRanges,
@@ -9199,7 +9204,7 @@ function getContainedStructures({
9199
9204
  const containerStructures = {};
9200
9205
  const structureContainers = drawDefinitions.map((dd) => dd?.structures?.filter((structure) => structure?.structures)).flat().filter(Boolean);
9201
9206
  for (const structureContainer of structureContainers) {
9202
- const { structures, structureId } = structureContainer || {};
9207
+ const { structures, structureId } = structureContainer ?? {};
9203
9208
  structures && structureId && (containedStructures[structureId] = structures?.map(
9204
9209
  (structure) => structure.structureId
9205
9210
  )) && structures.forEach(
@@ -13334,6 +13339,7 @@ function automatedPlayoffPositioning(params) {
13334
13339
 
13335
13340
  function getStructureRoundProfile({
13336
13341
  drawDefinition,
13342
+ matchUpsMap,
13337
13343
  structureId
13338
13344
  }) {
13339
13345
  const result = findStructure({
@@ -13341,9 +13347,12 @@ function getStructureRoundProfile({
13341
13347
  structureId
13342
13348
  });
13343
13349
  if (result.error)
13344
- return result;
13345
- const { matchUps } = getAllStructureMatchUps({ structure: result.structure });
13346
- return getRoundMatchUps({ matchUps });
13350
+ return decorateResult({ result });
13351
+ const { matchUps } = getAllStructureMatchUps({
13352
+ structure: result.structure,
13353
+ matchUpsMap
13354
+ });
13355
+ return { ...getRoundMatchUps({ matchUps }), matchUps, matchUpsMap };
13347
13356
  }
13348
13357
 
13349
13358
  function getFinishingPositionSourceRoundsMap({
@@ -13394,16 +13403,18 @@ function roundValueRanges(values) {
13394
13403
 
13395
13404
  function getPositionsPlayedOff({
13396
13405
  drawDefinition,
13397
- structureIds
13406
+ structureIds,
13407
+ matchUpsMap
13398
13408
  }) {
13399
13409
  if (structureIds && !Array.isArray(structureIds))
13400
13410
  return { error: INVALID_VALUES, context: { structureIds } };
13401
13411
  if (!drawDefinition)
13402
13412
  return { error: MISSING_DRAW_DEFINITION };
13403
- structureIds = structureIds || (drawDefinition.structures || []).filter((structure) => structure.stage !== QUALIFYING).map(({ structureId }) => structureId);
13413
+ structureIds = structureIds ?? (drawDefinition.structures ?? []).filter((structure) => structure.stage !== QUALIFYING).map(({ structureId }) => structureId);
13404
13414
  const allFinishingPositionRanges = structureIds.map((structureId) => {
13405
13415
  const { roundProfile } = getStructureRoundProfile({
13406
13416
  drawDefinition,
13417
+ matchUpsMap,
13407
13418
  structureId
13408
13419
  });
13409
13420
  const values = roundProfile && Object.values(roundProfile);
@@ -13498,18 +13509,19 @@ function getPlayoffRoundsRanges({ playoffSourceRounds, roundProfile }) {
13498
13509
  function getAvailablePlayoffProfiles({ drawDefinition, structureId }) {
13499
13510
  if (!drawDefinition)
13500
13511
  return { error: MISSING_DRAW_DEFINITION };
13501
- const { positionsNotPlayedOff, positionsPlayedOff } = getPositionsPlayedOff({
13512
+ const { matchUps, matchUpsMap } = allDrawMatchUps({
13513
+ inContext: true,
13502
13514
  drawDefinition
13503
13515
  });
13516
+ const { positionsNotPlayedOff, positionsPlayedOff } = getPositionsPlayedOff({
13517
+ drawDefinition,
13518
+ matchUpsMap
13519
+ });
13504
13520
  const { structures } = getDrawStructures({ drawDefinition });
13505
13521
  const filteredStructures = structures.filter(
13506
13522
  (structure) => !structureId && structure.stage !== VOLUNTARY_CONSOLATION || structure.structureId === structureId
13507
13523
  );
13508
13524
  const available = {};
13509
- const matchUps = allDrawMatchUps({
13510
- inContext: true,
13511
- drawDefinition
13512
- }).matchUps;
13513
13525
  for (const structure of filteredStructures) {
13514
13526
  const structureId2 = structure?.structureId;
13515
13527
  const result = availablePlayoffProfiles({
@@ -13983,7 +13995,7 @@ function treeMatchUps({
13983
13995
  uuids
13984
13996
  }));
13985
13997
  roundNumber++;
13986
- roundLimit = roundLimit || qualifyingRoundNumber;
13998
+ roundLimit = roundLimit ?? qualifyingRoundNumber;
13987
13999
  while (roundNodes.length > 1) {
13988
14000
  if (qualifyingPositions && roundNodes.length === qualifyingPositions) {
13989
14001
  roundLimit = roundNumber - 1;
@@ -14011,7 +14023,7 @@ function treeMatchUps({
14011
14023
  roundLimit = roundNumber - 1;
14012
14024
  } else {
14013
14025
  matchUps = matchUps.filter(
14014
- (matchUp) => roundLimit && (matchUp.roundNumber || 0) <= roundLimit
14026
+ (matchUp) => roundLimit && (matchUp.roundNumber ?? 0) <= roundLimit
14015
14027
  );
14016
14028
  }
14017
14029
  return { drawSize, matchUps, roundsCount, roundLimit };
@@ -19097,7 +19109,7 @@ function filterParticipants({
19097
19109
  );
19098
19110
  if (event.eventType === SINGLES)
19099
19111
  return enteredParticipantIds;
19100
- const individualParticipantIds = (tournamentRecord?.participants || []).filter(
19112
+ const individualParticipantIds = (tournamentRecord?.participants ?? []).filter(
19101
19113
  (participant) => enteredParticipantIds.includes(participant.participantId)
19102
19114
  ).map((participant) => participant.individualParticipantIds).flat(1);
19103
19115
  return enteredParticipantIds.concat(...individualParticipantIds);
@@ -20696,7 +20708,6 @@ function generateQualifyingStructures({
20696
20708
  roundTarget,
20697
20709
  linkType
20698
20710
  });
20699
- targetRoundQualifiersCount = 0;
20700
20711
  roundTarget += 1;
20701
20712
  }
20702
20713
  return {
@@ -23001,7 +23012,7 @@ function getScaledEntries({
23001
23012
  }) {
23002
23013
  if (!tournamentRecord)
23003
23014
  return { error: MISSING_TOURNAMENT_RECORD };
23004
- entries = entries || event?.entries || [];
23015
+ entries = entries ?? event?.entries ?? [];
23005
23016
  const stageEntries = entries.filter(
23006
23017
  (entry) => (!stage || !entry.entryStage || entry.entryStage === stage) && (!stageSequence || !entry.entryStageSequence || entry.entryStageSequence === stageSequence) && STRUCTURE_SELECTED_STATUSES.includes(entry.entryStatus)
23007
23018
  );
@@ -23872,7 +23883,7 @@ function generateFlightProfile(params) {
23872
23883
  } = params;
23873
23884
  if (!event)
23874
23885
  return { error: MISSING_EVENT };
23875
- const eventEntries = event.entries || [];
23886
+ const eventEntries = event.entries ?? [];
23876
23887
  const { flightProfile } = getFlightProfile({ event });
23877
23888
  if (flightProfile && attachFlightProfile$1 && !deleteExisting) {
23878
23889
  return { error: EXISTING_PROFILE };
@@ -23921,7 +23932,7 @@ function generateFlightProfile(params) {
23921
23932
  const flightNumber = index + 1;
23922
23933
  return {
23923
23934
  flightNumber,
23924
- drawId: uuids?.pop() || UUID(),
23935
+ drawId: uuids?.pop() ?? UUID(),
23925
23936
  drawEntries: getDrawEntries(splitEntries[index]),
23926
23937
  drawName: drawNames?.length && drawNames[index] || `${drawNameRoot} ${flightNumber}`
23927
23938
  };