tods-competition-factory 1.8.19 → 1.8.21

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.
@@ -1825,6 +1825,8 @@ declare function generateSeedingScaleItems({ scaleAttributes, scaledEntries, sta
1825
1825
  };
1826
1826
 
1827
1827
  type MatchUpActionsArgs$1 = TournamentRecordsArgs & {
1828
+ policyDefinitions?: PolicyDefinitions;
1829
+ enforceGender?: boolean;
1828
1830
  participantId: string;
1829
1831
  tournamentId: string;
1830
1832
  sideNumber?: number;
@@ -1948,13 +1950,14 @@ type MatchUpActionsArgs = {
1948
1950
  policyDefinitions?: PolicyDefinitions;
1949
1951
  drawDefinition?: DrawDefinition;
1950
1952
  tournamentRecord: Tournament;
1953
+ enforceGender?: boolean;
1951
1954
  participantId?: string;
1952
1955
  sideNumber?: number;
1953
1956
  matchUpId: string;
1954
1957
  drawId?: string;
1955
1958
  event?: Event;
1956
1959
  };
1957
- declare function matchUpActions({ policyDefinitions, tournamentRecord, drawDefinition, participantId, sideNumber, matchUpId, drawId, event, }: MatchUpActionsArgs): (ResultType & {
1960
+ declare function matchUpActions({ policyDefinitions, tournamentRecord, drawDefinition, enforceGender, participantId, sideNumber, matchUpId, drawId, event, }: MatchUpActionsArgs): (ResultType & {
1958
1961
  structureIsComplete?: boolean | undefined;
1959
1962
  isDoubleExit?: boolean | undefined;
1960
1963
  isByeMatchUp?: boolean | undefined;
@@ -2040,11 +2043,12 @@ declare function getOrderedDrawPositions({ drawPositions, roundProfile, roundNum
2040
2043
  };
2041
2044
 
2042
2045
  type GetRoundContextProfileArgs = {
2046
+ drawDefinition?: DrawDefinition;
2043
2047
  matchUps: HydratedMatchUp[];
2044
2048
  roundNamingPolicy: any;
2045
2049
  structure: Structure;
2046
2050
  };
2047
- declare function getRoundContextProfile({ roundNamingPolicy, structure, matchUps, }: GetRoundContextProfileArgs): ResultType & {
2051
+ declare function getRoundContextProfile({ roundNamingPolicy, drawDefinition, structure, matchUps, }: GetRoundContextProfileArgs): ResultType & {
2048
2052
  roundNamingProfile?: {
2049
2053
  [key: string]: {
2050
2054
  roundName: string;
@@ -2074,6 +2078,7 @@ declare function getParticipantScaleItem({ tournamentRecords, policyDefinitions,
2074
2078
  };
2075
2079
 
2076
2080
  type PositionActionsArgs = {
2081
+ restrictAdHocRoundParticipants?: boolean;
2077
2082
  policyDefinitions?: PolicyDefinitions;
2078
2083
  provisionalPositioning?: boolean;
2079
2084
  returnParticipants?: boolean;
@@ -2113,11 +2118,11 @@ type GetRoundMatchUpsArgs = {
2113
2118
  interpolate?: boolean;
2114
2119
  };
2115
2120
  type RoundMatchUpsResult = {
2116
- roundsNotPowerOf2?: boolean;
2117
2121
  roundMatchUps?: HydratedMatchUp[];
2118
2122
  hasNoRoundPositions?: boolean;
2119
- roundProfile?: RoundProfile;
2123
+ roundsNotPowerOf2?: boolean;
2120
2124
  maxMatchUpsCount?: number;
2125
+ roundProfile?: RoundProfile;
2121
2126
  roundNumbers?: number[];
2122
2127
  error?: ErrorType;
2123
2128
  };
@@ -6763,6 +6763,9 @@ const POLICY_ROUND_NAMING_DEFAULT = {
6763
6763
  namingConventions: {
6764
6764
  round: "Round"
6765
6765
  },
6766
+ qualifyingFinishMap: {
6767
+ 1: "Final"
6768
+ },
6766
6769
  abbreviatedRoundNamingMap: {
6767
6770
  // key is matchUpsCount for the round
6768
6771
  1: "F",
@@ -6776,7 +6779,8 @@ const POLICY_ROUND_NAMING_DEFAULT = {
6776
6779
  },
6777
6780
  affixes: {
6778
6781
  roundNumber: "R",
6779
- preFeedRound: "Q"
6782
+ preFeedRound: "Q",
6783
+ preQualifying: "P"
6780
6784
  },
6781
6785
  stageConstants: {
6782
6786
  [MAIN]: "",
@@ -6789,6 +6793,7 @@ const POLICY_ROUND_NAMING_DEFAULT = {
6789
6793
 
6790
6794
  function getRoundContextProfile({
6791
6795
  roundNamingPolicy,
6796
+ drawDefinition,
6792
6797
  structure,
6793
6798
  matchUps
6794
6799
  }) {
@@ -6799,21 +6804,31 @@ function getRoundContextProfile({
6799
6804
  const isRoundRobin = structure.structures;
6800
6805
  const roundNamingProfile = {};
6801
6806
  const defaultRoundNamingPolicy = POLICY_ROUND_NAMING_DEFAULT[POLICY_TYPE_ROUND_NAMING];
6807
+ const isQualifying = structure.stage === QUALIFYING;
6808
+ const qualifyingFinishgMap = isQualifying && (roundNamingPolicy?.qualifyingFinishMap || defaultRoundNamingPolicy?.qualifyingFinishMap || {});
6809
+ const qualifyingStageSequences = isQualifying ? Math.max(
6810
+ ...(drawDefinition?.structures ?? []).filter((structure2) => structure2.stage === QUALIFYING).map(({ stageSequence }) => stageSequence ?? 1),
6811
+ 0
6812
+ ) : 0;
6813
+ const preQualifyingSequence = qualifyingStageSequences ? qualifyingStageSequences - (structure.stageSequence || 1) || "" : "";
6814
+ const preQualifyingAffix = preQualifyingSequence ? roundNamingPolicy?.affixes?.preQualifying || defaultRoundNamingPolicy.affixes.preQualifying || "" : "";
6802
6815
  const roundNamingMap = roundNamingPolicy?.roundNamingMap || defaultRoundNamingPolicy.roundNamingMap || {};
6803
6816
  const abbreviatedRoundNamingMap = roundNamingPolicy?.abbreviatedRoundNamingMap || defaultRoundNamingPolicy.abbreviatedRoundNamingMap || {};
6804
- const roundNamePrefix = roundNamingPolicy?.affixes || defaultRoundNamingPolicy.affixes;
6805
- const roundNumberAffix = roundNamePrefix.roundNumber || defaultRoundNamingPolicy.affixes.roundNumber;
6817
+ const preFeedAffix = roundNamingPolicy?.affixes?.preFeedRound || defaultRoundNamingPolicy.affixes.preFeedRound;
6818
+ const roundNumberAffix = roundNamingPolicy?.affixes?.roundNumber || defaultRoundNamingPolicy.affixes.roundNumber;
6806
6819
  const namingConventions = roundNamingPolicy?.namingConventions || defaultRoundNamingPolicy.namingConventions;
6807
6820
  const roundNameFallback = namingConventions.round;
6808
- const stageInitial = stage && stage !== MAIN && stage[0];
6809
- const stageConstants = roundNamingPolicy?.stageConstants;
6810
- const stageConstant = stage && stageConstants?.[stage] || stageInitial;
6821
+ const stageInitial = stage && stage !== MAIN ? stage[0] : "";
6822
+ const stageConstants = roundNamingPolicy?.stageConstants || defaultRoundNamingPolicy.stageConstants;
6823
+ const stageIndicator = stage && stageConstants?.[stage] || stageInitial;
6824
+ const stageConstant = `${preQualifyingAffix}${stageIndicator}${preQualifyingSequence}`;
6811
6825
  const roundProfileKeys = roundProfile ? Object.keys(roundProfile) : [];
6826
+ const qualifyingAffix = isQualifying && stageConstants?.[QUALIFYING] ? `${stageConstants?.[QUALIFYING]}-` : "";
6812
6827
  if (isRoundRobin || isAdHocStructure || isLuckyStructure) {
6813
6828
  Object.assign(
6814
6829
  roundNamingProfile,
6815
6830
  ...roundProfileKeys.map((key) => {
6816
- const roundName = `${roundNameFallback} ${key}`;
6831
+ const roundName = `${qualifyingAffix}${roundNameFallback} ${key}`;
6817
6832
  const abbreviatedRoundName = `${roundNumberAffix}${key}`;
6818
6833
  return { [key]: { roundName, abbreviatedRoundName } };
6819
6834
  })
@@ -6826,15 +6841,15 @@ function getRoundContextProfile({
6826
6841
  return;
6827
6842
  const { matchUpsCount, preFeedRound } = roundProfile[round];
6828
6843
  const participantsCount = matchUpsCount * 2;
6829
- const sizedRoundName = roundNamingMap[matchUpsCount] || `${roundNamePrefix.roundNumber}${participantsCount}`;
6830
- const suffix = preFeedRound ? `-${roundNamePrefix.preFeedRound}` : "";
6844
+ const sizedRoundName = qualifyingFinishgMap?.[roundProfile?.[round].finishingRound] || qualifyingFinishgMap && `${roundNumberAffix}${participantsCount}` || roundNamingMap[matchUpsCount] || `${roundNumberAffix}${participantsCount}`;
6845
+ const suffix = preFeedRound ? `-${preFeedAffix}` : "";
6831
6846
  const profileRoundName = `${sizedRoundName}${suffix}`;
6832
6847
  const roundName = [
6833
6848
  stageConstant,
6834
6849
  structureAbbreviation,
6835
6850
  profileRoundName
6836
6851
  ].filter(Boolean).join("-");
6837
- const sizedAbbreviation = abbreviatedRoundNamingMap[matchUpsCount] || `${roundNamePrefix.roundNumber}${participantsCount}`;
6852
+ const sizedAbbreviation = abbreviatedRoundNamingMap[matchUpsCount] || `${roundNumberAffix}${participantsCount}`;
6838
6853
  const profileAbbreviation = `${sizedAbbreviation}${suffix}`;
6839
6854
  const abbreviatedRoundName = [
6840
6855
  stageConstant,
@@ -7008,6 +7023,7 @@ function getAllStructureMatchUps({
7008
7023
  const roundNamingPolicy = appliedPolicies?.[POLICY_TYPE_ROUND_NAMING];
7009
7024
  const result = getRoundContextProfile({
7010
7025
  roundNamingPolicy,
7026
+ drawDefinition,
7011
7027
  structure,
7012
7028
  matchUps
7013
7029
  });
@@ -9466,6 +9482,7 @@ function matchUpActions$2({
9466
9482
  inContextDrawMatchUps,
9467
9483
  tournamentRecord,
9468
9484
  drawDefinition,
9485
+ enforceGender,
9469
9486
  participantId,
9470
9487
  matchUpsMap,
9471
9488
  sideNumber,
@@ -9497,8 +9514,8 @@ function matchUpActions$2({
9497
9514
  event
9498
9515
  }).appliedPolicies ?? {};
9499
9516
  Object.assign(appliedPolicies, specifiedPolicyDefinitions ?? {});
9500
- const isAdHocMatchUp = isAdHoc({ drawDefinition, structure });
9501
9517
  const matchUpActionsPolicy = appliedPolicies?.[POLICY_TYPE_MATCHUP_ACTIONS] ?? POLICY_MATCHUP_ACTIONS_DEFAULT[POLICY_TYPE_MATCHUP_ACTIONS];
9518
+ const isAdHocMatchUp = isAdHoc({ drawDefinition, structure });
9502
9519
  const { enabledStructures } = getEnabledStructures({
9503
9520
  actionType: MATCHUP_ACTION,
9504
9521
  appliedPolicies,
@@ -9712,7 +9729,8 @@ function matchUpActions$2({
9712
9729
  );
9713
9730
  const assignedGender = inContextMatchUp.gender === MIXED && inContextMatchUp.sideNumber && inContextMatchUp.sides?.filter((side2) => side2.particiapntId).length === 1 && firstFoundSide?.participant?.person?.sex;
9714
9731
  const matchUpType = inContextMatchUp.matchUpType;
9715
- const gender = matchUpActionsPolicy?.participants?.enforceGender ? inContextMatchUp.gender : void 0;
9732
+ const genderEnforced = (enforceGender ?? matchUpActionsPolicy?.participants?.enforceGender) !== false;
9733
+ const gender = genderEnforced ? inContextMatchUp.gender : void 0;
9716
9734
  const allParticipants = inContextMatchUp.sides?.flatMap(
9717
9735
  (side2) => side2.participant?.individualParticipants || side2.participant
9718
9736
  ).filter(Boolean);
@@ -9842,6 +9860,7 @@ function matchUpActions$1({
9842
9860
  policyDefinitions,
9843
9861
  tournamentRecord,
9844
9862
  drawDefinition,
9863
+ enforceGender,
9845
9864
  participantId,
9846
9865
  sideNumber,
9847
9866
  matchUpId,
@@ -9876,6 +9895,7 @@ function matchUpActions$1({
9876
9895
  tournamentParticipants: tournamentRecord.participants,
9877
9896
  policyDefinitions,
9878
9897
  drawDefinition,
9898
+ enforceGender,
9879
9899
  participantId,
9880
9900
  sideNumber,
9881
9901
  matchUpId,
@@ -9889,6 +9909,8 @@ function matchUpActions$1({
9889
9909
  function matchUpActions(params) {
9890
9910
  const {
9891
9911
  tournamentRecords,
9912
+ policyDefinitions,
9913
+ enforceGender,
9892
9914
  participantId,
9893
9915
  tournamentId,
9894
9916
  sideNumber,
@@ -9910,7 +9932,9 @@ function matchUpActions(params) {
9910
9932
  return result;
9911
9933
  return matchUpActions$1({
9912
9934
  drawDefinition: result.drawDefinition,
9935
+ policyDefinitions,
9913
9936
  tournamentRecord,
9937
+ enforceGender,
9914
9938
  participantId,
9915
9939
  sideNumber,
9916
9940
  matchUpId,