tods-competition-factory 2.1.27 → 2.1.28

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.28';
7
7
  }
8
8
 
9
9
  const SINGLES_MATCHUP = 'SINGLES';
@@ -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 },