tods-competition-factory 2.1.26 → 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.
@@ -2364,6 +2364,7 @@ type GetMatchUpsArgs = {
2364
2364
  matchUpFilters?: MatchUpFilters;
2365
2365
  contextContent?: ContextContent;
2366
2366
  participantMap?: ParticipantMap;
2367
+ hydrateParticipants?: boolean;
2367
2368
  tournamentRecord?: Tournament;
2368
2369
  contextProfile?: ContextProfile;
2369
2370
  drawDefinition?: DrawDefinition;
@@ -5574,6 +5575,7 @@ type CompetitionScheduleMatchUpsArgs = {
5574
5575
  alwaysReturnCompleted?: boolean;
5575
5576
  contextFilters?: MatchUpFilters;
5576
5577
  matchUpFilters?: MatchUpFilters;
5578
+ hydrateParticipants?: boolean;
5577
5579
  withCourtGridRows?: boolean;
5578
5580
  activeTournamentId?: string;
5579
5581
  sortDateMatchUps?: boolean;
@@ -5695,6 +5697,7 @@ type GetAllStructureMatchUps = {
5695
5697
  matchUpFilters?: MatchUpFilters;
5696
5698
  participantMap?: ParticipantMap;
5697
5699
  scheduleTiming?: ScheduleTiming;
5700
+ hydrateParticipants?: boolean;
5698
5701
  drawDefinition?: DrawDefinition;
5699
5702
  contextProfile?: ContextProfile;
5700
5703
  tournamentRecord?: Tournament;
@@ -5767,12 +5770,13 @@ type CompetitionMatchUpsArgs = {
5767
5770
  policyDefinitions?: PolicyDefinitions;
5768
5771
  matchUpFilters?: MatchUpFilters;
5769
5772
  contextFilters?: MatchUpFilters;
5773
+ hydrateParticipants?: boolean;
5770
5774
  afterRecoveryTimes?: boolean;
5771
5775
  usePublishState?: boolean;
5772
5776
  nextMatchUps?: boolean;
5773
5777
  inContext?: boolean;
5774
5778
  };
5775
- declare function getCompetitionMatchUps({ scheduleVisibilityFilters, participantsProfile, tournamentRecords, policyDefinitions, usePublishState, matchUpFilters, contextFilters, nextMatchUps, inContext, }: CompetitionMatchUpsArgs): ResultType & {
5779
+ declare function getCompetitionMatchUps({ scheduleVisibilityFilters, hydrateParticipants, participantsProfile, tournamentRecords, policyDefinitions, usePublishState, matchUpFilters, contextFilters, nextMatchUps, inContext, }: CompetitionMatchUpsArgs): ResultType & {
5776
5780
  abandonedMatchUps?: HydratedMatchUp[];
5777
5781
  completedMatchUps?: HydratedMatchUp[];
5778
5782
  upcomingMatchUps?: HydratedMatchUp[];
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  function factoryVersion() {
6
- return '2.1.26';
6
+ return '2.1.28';
7
7
  }
8
8
 
9
9
  const SINGLES_MATCHUP = 'SINGLES';
@@ -10177,7 +10177,7 @@ function getSeeding({ seedAssignments, participantId }) {
10177
10177
  return seedAssignments?.find((assignment) => !assignment.seedProxy && assignment.participantId === participantId);
10178
10178
  }
10179
10179
 
10180
- function addMatchUpContext({ scheduleVisibilityFilters, sourceDrawPositionRanges, tournamentParticipants, positionAssignments, drawPositionsRanges, afterRecoveryTimes, initialRoundOfPlay, additionalContext, roundNamingProfile, tournamentRecord, tieDrawPositions, appliedPolicies, isCollectionBye, seedAssignments, usePublishState, participantMap, contextContent, scheduleTiming, contextProfile, drawDefinition, publishStatus, scoringActive, matchUpTieId, isRoundRobin, roundProfile, sideLineUps, structure, context, matchUp, event, }) {
10180
+ function addMatchUpContext({ scheduleVisibilityFilters, sourceDrawPositionRanges, tournamentParticipants, positionAssignments, drawPositionsRanges, hydrateParticipants, afterRecoveryTimes, initialRoundOfPlay, additionalContext, roundNamingProfile, tournamentRecord, tieDrawPositions, appliedPolicies, isCollectionBye, seedAssignments, usePublishState, participantMap, contextContent, scheduleTiming, contextProfile, drawDefinition, publishStatus, scoringActive, matchUpTieId, isRoundRobin, roundProfile, sideLineUps, structure, context, matchUp, event, }) {
10181
10181
  additionalContext = additionalContext ?? {};
10182
10182
  const tieFormat = resolveTieFormat({
10183
10183
  drawDefinition,
@@ -10339,7 +10339,7 @@ function addMatchUpContext({ scheduleVisibilityFilters, sourceDrawPositionRanges
10339
10339
  });
10340
10340
  Object.assign(matchUpWithContext, makeDeepCopy({ sides }, true, true));
10341
10341
  }
10342
- if (tournamentParticipants && matchUpWithContext.sides) {
10342
+ if (tournamentParticipants && matchUpWithContext.sides && hydrateParticipants !== false) {
10343
10343
  const participantAttributes = appliedPolicies?.[POLICY_TYPE_PARTICIPANT];
10344
10344
  const getMappedParticipant = (participantId) => {
10345
10345
  const participant = participantMap?.[participantId]?.participant;
@@ -10707,10 +10707,8 @@ function getAllStructureMatchUps(params) {
10707
10707
  ...params.policyDefinitions,
10708
10708
  };
10709
10709
  const structureScoringPolicies = appliedPolicies?.scoring?.structures;
10710
- const stageSpecificPolicies = structure.stage && structureScoringPolicies?.stage && structureScoringPolicies?.stage[structure.stage];
10711
- const sequenceSpecificPolicies = structure.stageSequence &&
10712
- stageSpecificPolicies?.stageSequence &&
10713
- stageSpecificPolicies.stageSequence[structure.stageSequence];
10710
+ const stageSpecificPolicies = structure.stage && structureScoringPolicies?.stage?.[structure.stage];
10711
+ const sequenceSpecificPolicies = structure.stageSequence && stageSpecificPolicies?.stageSequence?.[structure.stageSequence];
10714
10712
  const requireAllPositionsAssigned = appliedPolicies?.scoring?.requireAllPositionsAssigned ||
10715
10713
  stageSpecificPolicies?.requireAllPositionsAssigned ||
10716
10714
  sequenceSpecificPolicies?.requireAllPositionsAssigned;
@@ -10775,6 +10773,7 @@ function getAllStructureMatchUps(params) {
10775
10773
  return addMatchUpContext({
10776
10774
  tournamentParticipants: params.tournamentParticipants ?? tournamentRecord?.participants,
10777
10775
  scheduleVisibilityFilters: params.scheduleVisibilityFilters,
10776
+ hydrateParticipants: params.hydrateParticipants,
10778
10777
  afterRecoveryTimes: params.afterRecoveryTimes,
10779
10778
  usePublishState: params.usePublishState,
10780
10779
  participantMap: params.participantMap,
@@ -10859,7 +10858,7 @@ function checkMatchUpIsComplete({ matchUp }) {
10859
10858
  return completedMatchUpStatuses.includes(matchUp?.matchUpStatus) || matchUp?.winningSide;
10860
10859
  }
10861
10860
 
10862
- function getStructureMatchUps({ requireParticipants = true, scheduleVisibilityFilters, tournamentAppliedPolicies, tournamentParticipants, afterRecoveryTimes, policyDefinitions, tournamentRecord, usePublishState, matchUpFilters, contextFilters, contextContent, participantMap, scheduleTiming, publishStatus, contextProfile, drawDefinition, exitProfiles, matchUpsMap, structureId, inContext, structure, context, event, }) {
10861
+ function getStructureMatchUps({ requireParticipants = true, scheduleVisibilityFilters, tournamentAppliedPolicies, tournamentParticipants, hydrateParticipants, afterRecoveryTimes, policyDefinitions, tournamentRecord, usePublishState, matchUpFilters, contextFilters, contextContent, participantMap, scheduleTiming, publishStatus, contextProfile, drawDefinition, exitProfiles, matchUpsMap, structureId, inContext, structure, context, event, }) {
10863
10862
  if (!structure && structureId) {
10864
10863
  ({ structure } = findStructure({ drawDefinition, structureId }));
10865
10864
  }
@@ -10867,6 +10866,7 @@ function getStructureMatchUps({ requireParticipants = true, scheduleVisibilityFi
10867
10866
  tournamentAppliedPolicies,
10868
10867
  scheduleVisibilityFilters,
10869
10868
  tournamentParticipants,
10869
+ hydrateParticipants,
10870
10870
  afterRecoveryTimes,
10871
10871
  policyDefinitions,
10872
10872
  tournamentRecord,
@@ -11440,6 +11440,7 @@ function getDrawMatchUps(params) {
11440
11440
  matchUpFilters: !nextMatchUps ? matchUpFilters : undefined,
11441
11441
  contextFilters: !nextMatchUps ? contextFilters : undefined,
11442
11442
  inContext: inContext || nextMatchUps || contextFilters,
11443
+ hydrateParticipants: params.hydrateParticipants,
11443
11444
  tournamentAppliedPolicies,
11444
11445
  scheduleVisibilityFilters,
11445
11446
  tournamentParticipants,
@@ -27761,6 +27762,9 @@ function setParticipantScaleItem(params) {
27761
27762
  if (participantId && Array.isArray(tournamentRecord.participants)) {
27762
27763
  participant = tournamentRecord.participants.find((participant) => participant.participantId === participantId);
27763
27764
  if (participant) {
27765
+ if (participant.participantType === TEAM_PARTICIPANT && scaleItem?.eventType !== TEAM_EVENT) {
27766
+ return { error: INVALID_SCALE_ITEM };
27767
+ }
27764
27768
  const result = addParticipantScaleItem({
27765
27769
  removePriorValues,
27766
27770
  participant,
@@ -27815,16 +27819,23 @@ function setParticipantScaleItems(params) {
27815
27819
  }
27816
27820
  }
27817
27821
  }
27818
- tournamentRecord.participants.forEach((participant) => {
27822
+ for (const participant of tournamentRecord.participants) {
27819
27823
  const { participantId } = participant || {};
27820
27824
  if (Array.isArray(participantScaleItemsMap[participantId])) {
27821
- 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
+ }
27822
27833
  addParticipantScaleItem({ participant, scaleItem, removePriorValues });
27823
27834
  modifiedParticipants.push(participant);
27824
27835
  modificationsApplied++;
27825
- });
27836
+ }
27826
27837
  }
27827
- });
27838
+ }
27828
27839
  const info = !modificationsApplied ? NO_MODIFICATIONS_APPLIED : undefined;
27829
27840
  const { topics } = getTopics();
27830
27841
  if (topics.includes(MODIFY_PARTICIPANTS) && modificationsApplied) {
@@ -34805,7 +34816,8 @@ function getDrawData(params) {
34805
34816
  drawId,
34806
34817
  }))(drawDefinition);
34807
34818
  drawInfo.display = findExtension({ element: drawDefinition, name: DISPLAY }).extension?.value;
34808
- let mainStageSeedAssignments, qualificationStageSeedAssignments;
34819
+ const qualificationStageSeedAssignments = {};
34820
+ let mainStageSeedAssignments;
34809
34821
  const { allStructuresLinked, sourceStructureIds, hasDrawFeedProfile, structureGroups } = getStructureGroups({
34810
34822
  drawDefinition,
34811
34823
  });
@@ -34827,8 +34839,8 @@ function getDrawData(params) {
34827
34839
  if (structure?.stage === MAIN && structure.stageSequence === 1) {
34828
34840
  mainStageSeedAssignments = seedAssignments;
34829
34841
  }
34830
- if (structure?.stage === QUALIFYING && structure.stageSequence === 1) {
34831
- qualificationStageSeedAssignments = seedAssignments;
34842
+ if (structure?.stage === QUALIFYING) {
34843
+ qualificationStageSeedAssignments[structure.stageSequence ?? 0] = seedAssignments;
34832
34844
  }
34833
34845
  return structure;
34834
34846
  })
@@ -34841,8 +34853,9 @@ function getDrawData(params) {
34841
34853
  if (structure.stage && [MAIN, CONSOLATION, PLAY_OFF].includes(structure.stage)) {
34842
34854
  seedAssignments = mainStageSeedAssignments;
34843
34855
  }
34844
- if (structure?.stage === QUALIFYING)
34845
- seedAssignments = qualificationStageSeedAssignments;
34856
+ if (structure?.stage === QUALIFYING) {
34857
+ seedAssignments = qualificationStageSeedAssignments[structure.stageSequence ?? 0];
34858
+ }
34846
34859
  const { matchUps, roundMatchUps, roundProfile } = getAllStructureMatchUps({
34847
34860
  seedAssignments: !structure?.seedAssignments?.length ? seedAssignments : undefined,
34848
34861
  context: { drawId: drawInfo.drawId, ...context },
@@ -36432,6 +36445,7 @@ function eventMatchUps(params) {
36432
36445
  const drawDefinitions = event.drawDefinitions ?? [];
36433
36446
  const eventResult = drawDefinitions.reduce((results, drawDefinition) => {
36434
36447
  const drawMatchUpsResult = getDrawMatchUps({
36448
+ hydrateParticipants: params.hydrateParticipants,
36435
36449
  context: additionalContext,
36436
36450
  tournamentAppliedPolicies,
36437
36451
  scheduleVisibilityFilters,
@@ -36499,6 +36513,7 @@ function tournamentMatchUps(params) {
36499
36513
  ...context,
36500
36514
  };
36501
36515
  return eventMatchUps({
36516
+ hydrateParticipants: params.hydrateParticipants,
36502
36517
  context: additionalContext,
36503
36518
  tournamentAppliedPolicies,
36504
36519
  scheduleVisibilityFilters,
@@ -36534,7 +36549,7 @@ function tournamentMatchUps(params) {
36534
36549
  return { ...eventsDrawMatchUpsResult, groupInfo };
36535
36550
  }
36536
36551
 
36537
- function getCompetitionMatchUps({ scheduleVisibilityFilters, participantsProfile, tournamentRecords, policyDefinitions, usePublishState, matchUpFilters, contextFilters, nextMatchUps, inContext, }) {
36552
+ function getCompetitionMatchUps({ scheduleVisibilityFilters, hydrateParticipants, participantsProfile, tournamentRecords, policyDefinitions, usePublishState, matchUpFilters, contextFilters, nextMatchUps, inContext, }) {
36538
36553
  if (typeof tournamentRecords !== 'object' || !Object.keys(tournamentRecords).length)
36539
36554
  return { error: MISSING_TOURNAMENT_RECORDS };
36540
36555
  const tournamentIds = Object.keys(tournamentRecords);
@@ -36542,6 +36557,7 @@ function getCompetitionMatchUps({ scheduleVisibilityFilters, participantsProfile
36542
36557
  const tournamentRecord = tournamentRecords[tournamentId];
36543
36558
  return tournamentMatchUps({
36544
36559
  scheduleVisibilityFilters,
36560
+ hydrateParticipants,
36545
36561
  participantsProfile,
36546
36562
  policyDefinitions,
36547
36563
  tournamentRecord,
@@ -44915,6 +44931,22 @@ function setMatchUpState(params) {
44915
44931
  const { structure } = findStructure({ drawDefinition, structureId });
44916
44932
  const isTeam = isMatchUpEventType(TEAM$2)(matchUp.matchUpType);
44917
44933
  const assignedDrawPositions = inContextMatchUp?.drawPositions?.filter(Boolean);
44934
+ const matchUpTieId = inContextMatchUp?.matchUpTieId;
44935
+ const targetData = positionTargets({
44936
+ matchUpId: matchUpTieId || matchUpId,
44937
+ inContextDrawMatchUps,
44938
+ drawDefinition,
44939
+ });
44940
+ Object.assign(params, {
44941
+ inContextDrawMatchUps,
44942
+ inContextMatchUp,
44943
+ matchUpTieId,
44944
+ matchUpsMap,
44945
+ targetData,
44946
+ structure,
44947
+ matchUp,
44948
+ });
44949
+ const activeDownstream = isActiveDownstream(params);
44918
44950
  let dualWinningSideChange;
44919
44951
  if (isTeam) {
44920
44952
  if (disableAutoCalc) {
@@ -44925,7 +44957,6 @@ function setMatchUpState(params) {
44925
44957
  }
44926
44958
  else if (enableAutoCalc) {
44927
44959
  const existingDualMatchUpWinningSide = matchUp.winningSide;
44928
- removeExtension({ name: DISABLE_AUTO_CALC, element: matchUp });
44929
44960
  const { winningSide: projectedWinningSide, scoreStringSide1, scoreStringSide2, set, } = generateTieMatchUpScore({
44930
44961
  drawDefinition,
44931
44962
  matchUpsMap,
@@ -44939,6 +44970,14 @@ function setMatchUpState(params) {
44939
44970
  sets: set ? [set] : [],
44940
44971
  };
44941
44972
  dualWinningSideChange = projectedWinningSide !== existingDualMatchUpWinningSide;
44973
+ if (activeDownstream && dualWinningSideChange) {
44974
+ return decorateResult({
44975
+ stack: 'winningSideWithDownstreamDependencies',
44976
+ result: { error: CANNOT_CHANGE_WINNING_SIDE },
44977
+ context: { winningSide, matchUp },
44978
+ });
44979
+ }
44980
+ removeExtension({ name: DISABLE_AUTO_CALC, element: matchUp });
44942
44981
  Object.assign(params, {
44943
44982
  winningSide: projectedWinningSide,
44944
44983
  dualWinningSideChange,
@@ -44964,12 +45003,6 @@ function setMatchUpState(params) {
44964
45003
  error: INVALID_VALUES,
44965
45004
  };
44966
45005
  }
44967
- const matchUpTieId = inContextMatchUp?.matchUpTieId;
44968
- const targetData = positionTargets({
44969
- matchUpId: matchUpTieId || matchUpId,
44970
- inContextDrawMatchUps,
44971
- drawDefinition,
44972
- });
44973
45006
  if (score && !isTeam && !disableScoreValidation) {
44974
45007
  const matchUpFormat = matchUp.matchUpFormat ?? structure?.matchUpFormat ?? drawDefinition?.matchUpFormat ?? event?.matchUpFormat;
44975
45008
  const result = validateScore({
@@ -45016,17 +45049,10 @@ function setMatchUpState(params) {
45016
45049
  winningSide !== matchUp.winningSide &&
45017
45050
  matchUp.winningSide;
45018
45051
  Object.assign(params, {
45019
- inContextDrawMatchUps,
45020
45052
  qualifierAdvancing,
45021
45053
  qualifierChanging,
45022
45054
  removingQualifier,
45023
- inContextMatchUp,
45024
45055
  appliedPolicies,
45025
- matchUpTieId,
45026
- matchUpsMap,
45027
- targetData,
45028
- structure,
45029
- matchUp,
45030
45056
  });
45031
45057
  if (matchUpTieId) {
45032
45058
  const { matchUp: dualMatchUp } = findDrawMatchUp({
@@ -45070,7 +45096,6 @@ function setMatchUpState(params) {
45070
45096
  }
45071
45097
  }
45072
45098
  const directingMatchUpStatus = isDirectingMatchUpStatus({ matchUpStatus });
45073
- const activeDownstream = isActiveDownstream(params);
45074
45099
  if (!matchUpTieId) {
45075
45100
  if (activeDownstream &&
45076
45101
  !winningSide &&
@@ -49663,9 +49688,7 @@ function completeDrawMatchUps(params) {
49663
49688
  structure,
49664
49689
  event,
49665
49690
  }).matchUps;
49666
- if (!matchUps.length) {
49667
- console.log('##', drawDefinition);
49668
- }
49691
+ if (!matchUps.length) ;
49669
49692
  const sortedMatchUpIds = matchUps
49670
49693
  .filter(({ winningSide }) => !winningSide)
49671
49694
  .sort(matchUpSort)