tods-competition-factory 2.1.27 → 2.1.29

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.
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  function factoryVersion() {
6
- return '2.1.27';
6
+ return '2.1.29';
7
7
  }
8
8
 
9
9
  const SINGLES_MATCHUP = 'SINGLES';
@@ -10164,6 +10164,9 @@ function getSideValue$1({ displaySideNumber, seedAssignments, participantId, ass
10164
10164
  if (participantId) {
10165
10165
  const seeding = getSeeding({ seedAssignments, participantId });
10166
10166
  Object.assign(side, seeding, { participantId });
10167
+ if (seeding?.seedNumber && seeding?.seedValue === '') {
10168
+ side.seedValue = '~';
10169
+ }
10167
10170
  }
10168
10171
  else if (assignment.bye) {
10169
10172
  Object.assign(side, { bye: true });
@@ -16991,7 +16994,8 @@ function assignDrawPosition$1({ provisionalPositioning, inContextDrawMatchUps, i
16991
16994
  positionAssignment.participantId = participantId;
16992
16995
  if (isQualifierPosition)
16993
16996
  positionAssignment.qualifier = true;
16994
- if ((structure?.stageSequence || 0) > 1 || (structure.stage && [CONSOLATION, PLAY_OFF].includes(structure.stage))) {
16997
+ const mainSeeding = structure.stage === MAIN && (!structure.stageSequence || structure.stageSequence > 1);
16998
+ if (mainSeeding || (structure.stage && [CONSOLATION, PLAY_OFF].includes(structure.stage))) {
16995
16999
  const targetStage = structure.stage === QUALIFYING ? QUALIFYING : MAIN;
16996
17000
  const targetStructure = drawDefinition.structures?.find((structure) => structure?.stage === targetStage && structure?.stageSequence === 1);
16997
17001
  const seedAssignments = targetStructure?.seedAssignments ?? [];
@@ -26363,16 +26367,16 @@ function getValidQualifiersAction({ drawPositionInitialRounds, tournamentPartici
26363
26367
  }
26364
26368
  if (qualifyingParticipantIds.length) {
26365
26369
  validAssignmentActions.push(definedAttributes({
26370
+ qualifyingParticipants: returnParticipants ? qualifyingParticipants : undefined,
26371
+ method: QUALIFYING_PARTICIPANT_METHOD,
26372
+ type: QUALIFYING_PARTICIPANT,
26373
+ qualifyingParticipantIds,
26366
26374
  payload: {
26367
26375
  qualifyingParticipantId: undefined,
26368
26376
  drawPosition,
26369
26377
  structureId,
26370
26378
  drawId,
26371
26379
  },
26372
- method: QUALIFYING_PARTICIPANT_METHOD,
26373
- type: QUALIFYING_PARTICIPANT,
26374
- qualifyingParticipantIds,
26375
- qualifyingParticipants: returnParticipants ? qualifyingParticipants : undefined,
26376
26380
  }));
26377
26381
  }
26378
26382
  return { validAssignmentActions, sourceStructureIds };
@@ -26486,13 +26490,7 @@ function positionActions(params) {
26486
26490
  }) || {};
26487
26491
  let sourceStructuresComplete;
26488
26492
  if (positionSourceStructureIds?.length) {
26489
- sourceStructuresComplete = positionSourceStructureIds.reduce((ready, sourceStructureId) => {
26490
- const completed = isCompletedStructure({
26491
- structureId: sourceStructureId,
26492
- drawDefinition,
26493
- });
26494
- return completed && ready;
26495
- }, true);
26493
+ sourceStructuresComplete = positionSourceStructureIds.every((sourceStructureId) => isCompletedStructure({ structureId: sourceStructureId, drawDefinition }));
26496
26494
  }
26497
26495
  const isWinRatioFedStructure = positionSourceStructureIds.length;
26498
26496
  const disablePlacementActions = positionSourceStructureIds.length && !sourceStructuresComplete;
@@ -26506,6 +26504,7 @@ function positionActions(params) {
26506
26504
  const validActions = [];
26507
26505
  const { assignedPositions, positionAssignments } = structureAssignedDrawPositions({ structure });
26508
26506
  const positionAssignment = assignedPositions?.find((assignment) => assignment.drawPosition === drawPosition);
26507
+ const hasPositionAssigned = !!positionAssignment;
26509
26508
  const drawPositions = positionAssignments?.map((assignment) => assignment.drawPosition);
26510
26509
  if (!drawPositions?.includes(drawPosition))
26511
26510
  return { error: INVALID_DRAW_POSITION };
@@ -26534,10 +26533,10 @@ function positionActions(params) {
26534
26533
  const isActiveDrawPosition = activeDrawPositions.includes(drawPosition);
26535
26534
  if (actionsDisabled)
26536
26535
  return {
26537
- hasPositionAssigned: !!positionAssignment,
26538
26536
  info: 'Actions Disabled for structure',
26539
26537
  isActiveDrawPosition,
26540
26538
  isDrawPosition: true,
26539
+ hasPositionAssigned,
26541
26540
  validActions: [],
26542
26541
  isByePosition,
26543
26542
  };
@@ -26563,7 +26562,7 @@ function positionActions(params) {
26563
26562
  });
26564
26563
  validAssignmentActions?.forEach((action) => validActions.push(action));
26565
26564
  }
26566
- if (isAvailableAction({ policyActions, action: QUALIFYING_PARTICIPANT })) {
26565
+ if (isAvailableAction({ policyActions, action: QUALIFYING_PARTICIPANT }) && !isActiveDrawPosition) {
26567
26566
  const { validAssignmentActions } = getValidQualifiersAction({
26568
26567
  drawPositionInitialRounds,
26569
26568
  tournamentParticipants,
@@ -26730,6 +26729,7 @@ function positionActions(params) {
26730
26729
  }
26731
26730
  if (isAvailableAction({ policyActions, action: LUCKY_PARTICIPANT }) &&
26732
26731
  !disablePlacementActions &&
26732
+ !isActiveDrawPosition &&
26733
26733
  positionAssignments) {
26734
26734
  const { validLuckyLosersAction } = getValidLuckyLosersAction({
26735
26735
  sourceStructuresComplete,
@@ -26760,9 +26760,9 @@ function positionActions(params) {
26760
26760
  validActions.push(validModifyAssignedPairAction);
26761
26761
  }
26762
26762
  return {
26763
- hasPositionAssigned: !!positionAssignment,
26764
26763
  isActiveDrawPosition,
26765
26764
  isDrawPosition: true,
26765
+ hasPositionAssigned,
26766
26766
  isByePosition,
26767
26767
  validActions,
26768
26768
  ...SUCCESS,
@@ -27762,6 +27762,9 @@ function setParticipantScaleItem(params) {
27762
27762
  if (participantId && Array.isArray(tournamentRecord.participants)) {
27763
27763
  participant = tournamentRecord.participants.find((participant) => participant.participantId === participantId);
27764
27764
  if (participant) {
27765
+ if (participant.participantType === TEAM_PARTICIPANT && scaleItem?.eventType !== TEAM_EVENT) {
27766
+ return { error: INVALID_SCALE_ITEM };
27767
+ }
27765
27768
  const result = addParticipantScaleItem({
27766
27769
  removePriorValues,
27767
27770
  participant,
@@ -27816,16 +27819,23 @@ function setParticipantScaleItems(params) {
27816
27819
  }
27817
27820
  }
27818
27821
  }
27819
- tournamentRecord.participants.forEach((participant) => {
27822
+ for (const participant of tournamentRecord.participants) {
27820
27823
  const { participantId } = participant || {};
27821
27824
  if (Array.isArray(participantScaleItemsMap[participantId])) {
27822
- participantScaleItemsMap[participantId].forEach((scaleItem) => {
27825
+ for (const scaleItem of participantScaleItemsMap[participantId]) {
27826
+ if (participant.participantType === TEAM_PARTICIPANT && scaleItem?.eventType !== TEAM_EVENT) {
27827
+ return decorateResult({
27828
+ context: { participantId, scaleItem, participantType: participant.participantType },
27829
+ info: 'Invalid participantType for eventType',
27830
+ result: { error: INVALID_SCALE_ITEM },
27831
+ });
27832
+ }
27823
27833
  addParticipantScaleItem({ participant, scaleItem, removePriorValues });
27824
27834
  modifiedParticipants.push(participant);
27825
27835
  modificationsApplied++;
27826
- });
27836
+ }
27827
27837
  }
27828
- });
27838
+ }
27829
27839
  const info = !modificationsApplied ? NO_MODIFICATIONS_APPLIED : undefined;
27830
27840
  const { topics } = getTopics();
27831
27841
  if (topics.includes(MODIFY_PARTICIPANTS) && modificationsApplied) {
@@ -34806,7 +34816,8 @@ function getDrawData(params) {
34806
34816
  drawId,
34807
34817
  }))(drawDefinition);
34808
34818
  drawInfo.display = findExtension({ element: drawDefinition, name: DISPLAY }).extension?.value;
34809
- let mainStageSeedAssignments, qualificationStageSeedAssignments;
34819
+ const qualificationStageSeedAssignments = {};
34820
+ let mainStageSeedAssignments;
34810
34821
  const { allStructuresLinked, sourceStructureIds, hasDrawFeedProfile, structureGroups } = getStructureGroups({
34811
34822
  drawDefinition,
34812
34823
  });
@@ -34828,8 +34839,8 @@ function getDrawData(params) {
34828
34839
  if (structure?.stage === MAIN && structure.stageSequence === 1) {
34829
34840
  mainStageSeedAssignments = seedAssignments;
34830
34841
  }
34831
- if (structure?.stage === QUALIFYING && structure.stageSequence === 1) {
34832
- qualificationStageSeedAssignments = seedAssignments;
34842
+ if (structure?.stage === QUALIFYING) {
34843
+ qualificationStageSeedAssignments[structure.stageSequence ?? 0] = seedAssignments;
34833
34844
  }
34834
34845
  return structure;
34835
34846
  })
@@ -34842,8 +34853,9 @@ function getDrawData(params) {
34842
34853
  if (structure.stage && [MAIN, CONSOLATION, PLAY_OFF].includes(structure.stage)) {
34843
34854
  seedAssignments = mainStageSeedAssignments;
34844
34855
  }
34845
- if (structure?.stage === QUALIFYING)
34846
- seedAssignments = qualificationStageSeedAssignments;
34856
+ if (structure?.stage === QUALIFYING) {
34857
+ seedAssignments = qualificationStageSeedAssignments[structure.stageSequence ?? 0];
34858
+ }
34847
34859
  const { matchUps, roundMatchUps, roundProfile } = getAllStructureMatchUps({
34848
34860
  seedAssignments: !structure?.seedAssignments?.length ? seedAssignments : undefined,
34849
34861
  context: { drawId: drawInfo.drawId, ...context },