tods-competition-factory 1.8.43 → 1.8.44

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.
@@ -4493,6 +4493,7 @@ function getSeeding({ seedAssignments, participantId }) {
4493
4493
  );
4494
4494
  }
4495
4495
 
4496
+ const ANY = "ANY";
4496
4497
  const MIXED = "MIXED";
4497
4498
 
4498
4499
  function getAllStructureMatchUps({
@@ -16478,24 +16479,32 @@ function ensureSideLineUps({
16478
16479
  }
16479
16480
  }
16480
16481
 
16481
- function genderValidityCheck({
16482
+ const mixedGenderError = "MIXED events can not contain mixed singles or { gender: ANY } collections";
16483
+ const anyMixedError = "events with { gender: ANY } can not contain MIXED singles collections";
16484
+ function tieFormatGenderValidityCheck({
16485
+ referenceEvent,
16482
16486
  referenceGender,
16483
16487
  matchUpType,
16484
16488
  gender
16485
16489
  }) {
16486
- const stack = "genderValidityCheck";
16487
- if (referenceGender && gender && [GenderEnum.Male, GenderEnum.Female].includes(referenceGender)) {
16488
- const valid = gender === referenceGender;
16489
- return valid ? { valid: true } : decorateResult({
16490
+ const stack = "tieFormatGenderValidityCheck";
16491
+ if (referenceGender && gender && [GenderEnum.Male, GenderEnum.Female].includes(referenceGender) && referenceGender !== gender)
16492
+ return decorateResult({
16490
16493
  result: { valid: false, error: INVALID_GENDER },
16491
16494
  context: { gender },
16492
16495
  stack
16493
16496
  });
16497
+ if (referenceGender === MIXED && (referenceEvent?.eventType !== TEAM$2 || gender === ANY || gender === MIXED && matchUpType !== TypeEnum.Doubles)) {
16498
+ return decorateResult({
16499
+ result: { error: INVALID_GENDER, valid: false },
16500
+ info: mixedGenderError,
16501
+ stack
16502
+ });
16494
16503
  }
16495
- if (referenceGender === MIXED && (gender !== MIXED || matchUpType === TypeEnum.Singles))
16504
+ if (referenceGender === ANY && gender === MIXED && matchUpType !== TypeEnum.Doubles)
16496
16505
  return decorateResult({
16497
- info: "MIXED events can only contain MIXED doubles collections",
16498
16506
  result: { error: INVALID_GENDER, valid: false },
16507
+ info: anyMixedError,
16499
16508
  stack
16500
16509
  });
16501
16510
  return { valid: true };
@@ -16991,7 +17000,8 @@ function validateCollectionDefinition({
16991
17000
  errors.push(`Invalid matchUpFormat: ${matchUpFormat}`);
16992
17001
  }
16993
17002
  if (checkGender) {
16994
- const result = genderValidityCheck({
17003
+ const result = tieFormatGenderValidityCheck({
17004
+ referenceEvent: event,
16995
17005
  referenceGender,
16996
17006
  matchUpType,
16997
17007
  gender
@@ -23127,9 +23137,9 @@ function getSeedsCount(params) {
23127
23137
  }
23128
23138
  }
23129
23139
  const consideredParticipantCount = requireParticipantCount && participantsCount || drawSize;
23130
- if (consideredParticipantCount > drawSize)
23140
+ if (consideredParticipantCount && consideredParticipantCount > drawSize)
23131
23141
  return { error: PARTICIPANT_COUNT_EXCEEDS_DRAW_SIZE };
23132
- const policy = policyDefinitions[POLICY_TYPE_SEEDING];
23142
+ const policy = policyDefinitions?.[POLICY_TYPE_SEEDING];
23133
23143
  if (!policy)
23134
23144
  return { error: INVALID_POLICY_DEFINITION };
23135
23145
  const seedsCountThresholds = policy.seedsCountThresholds;
@@ -23141,7 +23151,7 @@ function getSeedsCount(params) {
23141
23151
  return drawSizeProgression ? threshold.drawSize <= drawSize : drawSize === threshold.drawSize;
23142
23152
  });
23143
23153
  const seedsCount = relevantThresholds.reduce((seedsCount2, threshold) => {
23144
- return participantsCount >= threshold.minimumParticipantCount ? threshold.seedsCount : seedsCount2;
23154
+ return participantsCount && participantsCount >= threshold.minimumParticipantCount ? threshold.seedsCount : seedsCount2;
23145
23155
  }, 0);
23146
23156
  return { seedsCount };
23147
23157
  }