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.
package/dist/index.mjs CHANGED
@@ -2404,7 +2404,7 @@ const matchUpFormatCode = {
2404
2404
  };
2405
2405
 
2406
2406
  function factoryVersion() {
2407
- return "1.8.43";
2407
+ return "1.8.44";
2408
2408
  }
2409
2409
 
2410
2410
  function getObjectTieFormat(obj) {
@@ -2467,6 +2467,57 @@ function resolveTieFormat({
2467
2467
  };
2468
2468
  }
2469
2469
 
2470
+ function decorateResult({
2471
+ context,
2472
+ result,
2473
+ stack,
2474
+ info
2475
+ }) {
2476
+ if (result && !Array.isArray(result?.stack))
2477
+ result.stack = [];
2478
+ if (result && Array.isArray(result?.stack) && typeof stack === "string") {
2479
+ result.stack.push(stack);
2480
+ }
2481
+ if (result && info) {
2482
+ result.info = info;
2483
+ }
2484
+ if (result && typeof context === "object" && Object.keys(context).length) {
2485
+ Object.assign(result, definedAttributes(context));
2486
+ }
2487
+ if (result && !result?.error && !result?.success) {
2488
+ Object.assign(result, { ...SUCCESS });
2489
+ }
2490
+ return result ?? { success: true };
2491
+ }
2492
+
2493
+ const ANY = "ANY";
2494
+ const MALE = "MALE";
2495
+ const MIXED = "MIXED";
2496
+ const OTHER$3 = "OTHER";
2497
+ const FEMALE = "FEMALE";
2498
+ const genderConstants = {
2499
+ ANY,
2500
+ MALE,
2501
+ FEMALE,
2502
+ MIXED,
2503
+ OTHER: OTHER$3
2504
+ };
2505
+
2506
+ const SINGLES_MATCHUP = "SINGLES";
2507
+ const SINGLES$1 = "SINGLES";
2508
+ const DOUBLES_MATCHUP = "DOUBLES";
2509
+ const DOUBLES$1 = "DOUBLES";
2510
+ const TEAM_MATCHUP = "TEAM";
2511
+ const TEAM$2 = "TEAM";
2512
+ const matchUpTypes = {
2513
+ SINGLES_MATCHUP,
2514
+ SINGLES: SINGLES$1,
2515
+ DOUBLES_MATCHUP,
2516
+ DOUBLES: DOUBLES$1,
2517
+ TEAM_MATCHUP,
2518
+ TEAM: TEAM$2
2519
+ };
2520
+
2470
2521
  var DrawTypeEnum = /* @__PURE__ */ ((DrawTypeEnum2) => {
2471
2522
  DrawTypeEnum2["AdHoc"] = "AD_HOC";
2472
2523
  DrawTypeEnum2["Compass"] = "COMPASS";
@@ -2581,60 +2632,32 @@ var ParticipantTypeEnum = /* @__PURE__ */ ((ParticipantTypeEnum2) => {
2581
2632
  return ParticipantTypeEnum2;
2582
2633
  })(ParticipantTypeEnum || {});
2583
2634
 
2584
- function decorateResult({
2585
- context,
2586
- result,
2587
- stack,
2588
- info
2589
- }) {
2590
- if (result && !Array.isArray(result?.stack))
2591
- result.stack = [];
2592
- if (result && Array.isArray(result?.stack) && typeof stack === "string") {
2593
- result.stack.push(stack);
2594
- }
2595
- if (result && info) {
2596
- result.info = info;
2597
- }
2598
- if (result && typeof context === "object" && Object.keys(context).length) {
2599
- Object.assign(result, definedAttributes(context));
2600
- }
2601
- if (result && !result?.error && !result?.success) {
2602
- Object.assign(result, { ...SUCCESS });
2603
- }
2604
- return result ?? { success: true };
2605
- }
2606
-
2607
- const ANY = "ANY";
2608
- const MALE = "MALE";
2609
- const MIXED = "MIXED";
2610
- const OTHER$3 = "OTHER";
2611
- const FEMALE = "FEMALE";
2612
- const genderConstants = {
2613
- ANY,
2614
- MALE,
2615
- FEMALE,
2616
- MIXED,
2617
- OTHER: OTHER$3
2618
- };
2619
-
2620
- function genderValidityCheck({
2635
+ const mixedGenderError = "MIXED events can not contain mixed singles or { gender: ANY } collections";
2636
+ const anyMixedError = "events with { gender: ANY } can not contain MIXED singles collections";
2637
+ function tieFormatGenderValidityCheck({
2638
+ referenceEvent,
2621
2639
  referenceGender,
2622
2640
  matchUpType,
2623
2641
  gender
2624
2642
  }) {
2625
- const stack = "genderValidityCheck";
2626
- if (referenceGender && gender && [GenderEnum.Male, GenderEnum.Female].includes(referenceGender)) {
2627
- const valid = gender === referenceGender;
2628
- return valid ? { valid: true } : decorateResult({
2643
+ const stack = "tieFormatGenderValidityCheck";
2644
+ if (referenceGender && gender && [GenderEnum.Male, GenderEnum.Female].includes(referenceGender) && referenceGender !== gender)
2645
+ return decorateResult({
2629
2646
  result: { valid: false, error: INVALID_GENDER },
2630
2647
  context: { gender },
2631
2648
  stack
2632
2649
  });
2650
+ if (referenceGender === MIXED && (referenceEvent?.eventType !== TEAM$2 || gender === ANY || gender === MIXED && matchUpType !== TypeEnum.Doubles)) {
2651
+ return decorateResult({
2652
+ result: { error: INVALID_GENDER, valid: false },
2653
+ info: mixedGenderError,
2654
+ stack
2655
+ });
2633
2656
  }
2634
- if (referenceGender === MIXED && (gender !== MIXED || matchUpType === TypeEnum.Singles))
2657
+ if (referenceGender === ANY && gender === MIXED && matchUpType !== TypeEnum.Doubles)
2635
2658
  return decorateResult({
2636
- info: "MIXED events can only contain MIXED doubles collections",
2637
2659
  result: { error: INVALID_GENDER, valid: false },
2660
+ info: anyMixedError,
2638
2661
  stack
2639
2662
  });
2640
2663
  return { valid: true };
@@ -3027,7 +3050,8 @@ function validateCollectionDefinition({
3027
3050
  errors.push(`Invalid matchUpFormat: ${matchUpFormat}`);
3028
3051
  }
3029
3052
  if (checkGender) {
3030
- const result = genderValidityCheck({
3053
+ const result = tieFormatGenderValidityCheck({
3054
+ referenceEvent: event,
3031
3055
  referenceGender,
3032
3056
  matchUpType,
3033
3057
  gender
@@ -3471,21 +3495,6 @@ function calculatePercentages({
3471
3495
  });
3472
3496
  }
3473
3497
 
3474
- const SINGLES_MATCHUP = "SINGLES";
3475
- const SINGLES$1 = "SINGLES";
3476
- const DOUBLES_MATCHUP = "DOUBLES";
3477
- const DOUBLES$1 = "DOUBLES";
3478
- const TEAM_MATCHUP = "TEAM";
3479
- const TEAM$2 = "TEAM";
3480
- const matchUpTypes = {
3481
- SINGLES_MATCHUP,
3482
- SINGLES: SINGLES$1,
3483
- DOUBLES_MATCHUP,
3484
- DOUBLES: DOUBLES$1,
3485
- TEAM_MATCHUP,
3486
- TEAM: TEAM$2
3487
- };
3488
-
3489
3498
  function getParticipantResults({
3490
3499
  participantIds,
3491
3500
  matchUpFormat,
@@ -21030,7 +21039,7 @@ function allPlayoffPositionsFilled(params) {
21030
21039
  if (!playoffStructures?.length)
21031
21040
  return false;
21032
21041
  const enteredParticipantsCount = drawDefinition?.entries?.filter(
21033
- (entry) => STRUCTURE_SELECTED_STATUSES.includes(entry?.entryStatus)
21042
+ (entry) => entry?.entryStatus && STRUCTURE_SELECTED_STATUSES.includes(entry.entryStatus)
21034
21043
  )?.length || 0;
21035
21044
  let participantIdsCount = 0;
21036
21045
  const allPositionsFilled = (playoffStructures || []).reduce(
@@ -22443,9 +22452,9 @@ function getSeedsCount(params) {
22443
22452
  }
22444
22453
  }
22445
22454
  const consideredParticipantCount = requireParticipantCount && participantsCount || drawSize;
22446
- if (consideredParticipantCount > drawSize)
22455
+ if (consideredParticipantCount && consideredParticipantCount > drawSize)
22447
22456
  return { error: PARTICIPANT_COUNT_EXCEEDS_DRAW_SIZE };
22448
- const policy = policyDefinitions[POLICY_TYPE_SEEDING];
22457
+ const policy = policyDefinitions?.[POLICY_TYPE_SEEDING];
22449
22458
  if (!policy)
22450
22459
  return { error: INVALID_POLICY_DEFINITION };
22451
22460
  const seedsCountThresholds = policy.seedsCountThresholds;
@@ -22457,7 +22466,7 @@ function getSeedsCount(params) {
22457
22466
  return drawSizeProgression ? threshold.drawSize <= drawSize : drawSize === threshold.drawSize;
22458
22467
  });
22459
22468
  const seedsCount = relevantThresholds.reduce((seedsCount2, threshold) => {
22460
- return participantsCount >= threshold.minimumParticipantCount ? threshold.seedsCount : seedsCount2;
22469
+ return participantsCount && participantsCount >= threshold.minimumParticipantCount ? threshold.seedsCount : seedsCount2;
22461
22470
  }, 0);
22462
22471
  return { seedsCount };
22463
22472
  }
@@ -65547,7 +65556,7 @@ const utilities = {
65547
65556
  findExtension: findExtension$2,
65548
65557
  flattenJSON,
65549
65558
  garman,
65550
- genderValidityCheck,
65559
+ tieFormatGenderValidityCheck,
65551
65560
  generateHashCode,
65552
65561
  generateRange,
65553
65562
  generateScoreString,