tods-competition-factory 1.8.26 → 1.8.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.
@@ -907,6 +907,9 @@ function getAccessorValue({ element, accessor }) {
907
907
  }
908
908
  }
909
909
 
910
+ function isString(obj) {
911
+ return typeof obj === "string";
912
+ }
910
913
  function isObject(obj) {
911
914
  return typeof obj === "object";
912
915
  }
@@ -1420,6 +1423,88 @@ function removeTournamentExtension(params) {
1420
1423
  });
1421
1424
  }
1422
1425
 
1426
+ var EntryStatusEnum = /* @__PURE__ */ ((EntryStatusEnum2) => {
1427
+ EntryStatusEnum2["Alternate"] = "ALTERNATE";
1428
+ EntryStatusEnum2["Confirmed"] = "CONFIRMED";
1429
+ EntryStatusEnum2["DirectAcceptance"] = "DIRECT_ACCEPTANCE";
1430
+ EntryStatusEnum2["FeedIn"] = "FEED_IN";
1431
+ EntryStatusEnum2["JuniorExempt"] = "JUNIOR_EXEMPT";
1432
+ EntryStatusEnum2["LuckyLoser"] = "LUCKY_LOSER";
1433
+ EntryStatusEnum2["OrganiserAcceptance"] = "ORGANISER_ACCEPTANCE";
1434
+ EntryStatusEnum2["Qualifier"] = "QUALIFIER";
1435
+ EntryStatusEnum2["SpecialExempt"] = "SPECIAL_EXEMPT";
1436
+ EntryStatusEnum2["Registered"] = "Registered";
1437
+ EntryStatusEnum2["Ungrouped"] = "UNGROUPED";
1438
+ EntryStatusEnum2["Unpaired"] = "UNPAIRED";
1439
+ EntryStatusEnum2["Wildcard"] = "WILDCARD";
1440
+ EntryStatusEnum2["Withdrawn"] = "WITHDRAWN";
1441
+ return EntryStatusEnum2;
1442
+ })(EntryStatusEnum || {});
1443
+ var TypeEnum = /* @__PURE__ */ ((TypeEnum2) => {
1444
+ TypeEnum2["Doubles"] = "DOUBLES";
1445
+ TypeEnum2["Singles"] = "SINGLES";
1446
+ TypeEnum2["Team"] = "TEAM";
1447
+ return TypeEnum2;
1448
+ })(TypeEnum || {});
1449
+ var MatchUpStatusEnum = /* @__PURE__ */ ((MatchUpStatusEnum2) => {
1450
+ MatchUpStatusEnum2["Abandoned"] = "ABANDONED";
1451
+ MatchUpStatusEnum2["AwaitingResult"] = "AWAITING_RESULT";
1452
+ MatchUpStatusEnum2["Bye"] = "BYE";
1453
+ MatchUpStatusEnum2["Cancelled"] = "CANCELLED";
1454
+ MatchUpStatusEnum2["Completed"] = "COMPLETED";
1455
+ MatchUpStatusEnum2["DeadRubber"] = "DEAD_RUBBER";
1456
+ MatchUpStatusEnum2["Defaulted"] = "DEFAULTED";
1457
+ MatchUpStatusEnum2["DoubleDefault"] = "DOUBLE_DEFAULT";
1458
+ MatchUpStatusEnum2["DoubleWalkover"] = "DOUBLE_WALKOVER";
1459
+ MatchUpStatusEnum2["InProgress"] = "IN_PROGRESS";
1460
+ MatchUpStatusEnum2["Incomplete"] = "INCOMPLETE";
1461
+ MatchUpStatusEnum2["NotPlayed"] = "NOT_PLAYED";
1462
+ MatchUpStatusEnum2["Retired"] = "RETIRED";
1463
+ MatchUpStatusEnum2["Suspended"] = "SUSPENDED";
1464
+ MatchUpStatusEnum2["ToBePlayed"] = "TO_BE_PLAYED";
1465
+ MatchUpStatusEnum2["Walkover"] = "WALKOVER";
1466
+ return MatchUpStatusEnum2;
1467
+ })(MatchUpStatusEnum || {});
1468
+ var GenderEnum = /* @__PURE__ */ ((GenderEnum2) => {
1469
+ GenderEnum2["Any"] = "ANY";
1470
+ GenderEnum2["Female"] = "FEMALE";
1471
+ GenderEnum2["Male"] = "MALE";
1472
+ GenderEnum2["Mixed"] = "MIXED";
1473
+ return GenderEnum2;
1474
+ })(GenderEnum || {});
1475
+ var ParticipantTypeEnum = /* @__PURE__ */ ((ParticipantTypeEnum2) => {
1476
+ ParticipantTypeEnum2["Group"] = "GROUP";
1477
+ ParticipantTypeEnum2["Individual"] = "INDIVIDUAL";
1478
+ ParticipantTypeEnum2["Pair"] = "PAIR";
1479
+ ParticipantTypeEnum2["Team"] = "TEAM";
1480
+ return ParticipantTypeEnum2;
1481
+ })(ParticipantTypeEnum || {});
1482
+
1483
+ const MIXED = "MIXED";
1484
+
1485
+ function genderValidityCheck({
1486
+ referenceGender,
1487
+ matchUpType,
1488
+ gender
1489
+ }) {
1490
+ const stack = "genderValidityCheck";
1491
+ if (referenceGender && gender && [GenderEnum.Male, GenderEnum.Female].includes(referenceGender) && [GenderEnum.Male, GenderEnum.Female].includes(gender)) {
1492
+ const valid = gender === referenceGender;
1493
+ return valid ? { valid: true } : decorateResult({
1494
+ result: { valid: false, error: INVALID_GENDER },
1495
+ context: { gender },
1496
+ stack
1497
+ });
1498
+ }
1499
+ if (referenceGender === MIXED && (gender !== MIXED || matchUpType === TypeEnum.Singles))
1500
+ return decorateResult({
1501
+ info: "MIXED events can only contain MIXED doubles collections",
1502
+ result: { error: INVALID_GENDER, valid: false },
1503
+ stack
1504
+ });
1505
+ return { valid: true };
1506
+ }
1507
+
1423
1508
  const typeMatch = (arr, type) => arr.filter(Boolean).every((i) => typeof i === type);
1424
1509
  const allNumeric = (arr) => arr.filter(Boolean).every(isNumeric);
1425
1510
  function getCategoryAgeDetails(params) {
@@ -1904,63 +1989,6 @@ const matchUpFormatCode = {
1904
1989
  parse
1905
1990
  };
1906
1991
 
1907
- var EntryStatusEnum = /* @__PURE__ */ ((EntryStatusEnum2) => {
1908
- EntryStatusEnum2["Alternate"] = "ALTERNATE";
1909
- EntryStatusEnum2["Confirmed"] = "CONFIRMED";
1910
- EntryStatusEnum2["DirectAcceptance"] = "DIRECT_ACCEPTANCE";
1911
- EntryStatusEnum2["FeedIn"] = "FEED_IN";
1912
- EntryStatusEnum2["JuniorExempt"] = "JUNIOR_EXEMPT";
1913
- EntryStatusEnum2["LuckyLoser"] = "LUCKY_LOSER";
1914
- EntryStatusEnum2["OrganiserAcceptance"] = "ORGANISER_ACCEPTANCE";
1915
- EntryStatusEnum2["Qualifier"] = "QUALIFIER";
1916
- EntryStatusEnum2["SpecialExempt"] = "SPECIAL_EXEMPT";
1917
- EntryStatusEnum2["Registered"] = "Registered";
1918
- EntryStatusEnum2["Ungrouped"] = "UNGROUPED";
1919
- EntryStatusEnum2["Unpaired"] = "UNPAIRED";
1920
- EntryStatusEnum2["Wildcard"] = "WILDCARD";
1921
- EntryStatusEnum2["Withdrawn"] = "WITHDRAWN";
1922
- return EntryStatusEnum2;
1923
- })(EntryStatusEnum || {});
1924
- var TypeEnum = /* @__PURE__ */ ((TypeEnum2) => {
1925
- TypeEnum2["Doubles"] = "DOUBLES";
1926
- TypeEnum2["Singles"] = "SINGLES";
1927
- TypeEnum2["Team"] = "TEAM";
1928
- return TypeEnum2;
1929
- })(TypeEnum || {});
1930
- var MatchUpStatusEnum = /* @__PURE__ */ ((MatchUpStatusEnum2) => {
1931
- MatchUpStatusEnum2["Abandoned"] = "ABANDONED";
1932
- MatchUpStatusEnum2["AwaitingResult"] = "AWAITING_RESULT";
1933
- MatchUpStatusEnum2["Bye"] = "BYE";
1934
- MatchUpStatusEnum2["Cancelled"] = "CANCELLED";
1935
- MatchUpStatusEnum2["Completed"] = "COMPLETED";
1936
- MatchUpStatusEnum2["DeadRubber"] = "DEAD_RUBBER";
1937
- MatchUpStatusEnum2["Defaulted"] = "DEFAULTED";
1938
- MatchUpStatusEnum2["DoubleDefault"] = "DOUBLE_DEFAULT";
1939
- MatchUpStatusEnum2["DoubleWalkover"] = "DOUBLE_WALKOVER";
1940
- MatchUpStatusEnum2["InProgress"] = "IN_PROGRESS";
1941
- MatchUpStatusEnum2["Incomplete"] = "INCOMPLETE";
1942
- MatchUpStatusEnum2["NotPlayed"] = "NOT_PLAYED";
1943
- MatchUpStatusEnum2["Retired"] = "RETIRED";
1944
- MatchUpStatusEnum2["Suspended"] = "SUSPENDED";
1945
- MatchUpStatusEnum2["ToBePlayed"] = "TO_BE_PLAYED";
1946
- MatchUpStatusEnum2["Walkover"] = "WALKOVER";
1947
- return MatchUpStatusEnum2;
1948
- })(MatchUpStatusEnum || {});
1949
- var GenderEnum = /* @__PURE__ */ ((GenderEnum2) => {
1950
- GenderEnum2["Any"] = "ANY";
1951
- GenderEnum2["Female"] = "FEMALE";
1952
- GenderEnum2["Male"] = "MALE";
1953
- GenderEnum2["Mixed"] = "MIXED";
1954
- return GenderEnum2;
1955
- })(GenderEnum || {});
1956
- var ParticipantTypeEnum = /* @__PURE__ */ ((ParticipantTypeEnum2) => {
1957
- ParticipantTypeEnum2["Group"] = "GROUP";
1958
- ParticipantTypeEnum2["Individual"] = "INDIVIDUAL";
1959
- ParticipantTypeEnum2["Pair"] = "PAIR";
1960
- ParticipantTypeEnum2["Team"] = "TEAM";
1961
- return ParticipantTypeEnum2;
1962
- })(ParticipantTypeEnum || {});
1963
-
1964
1992
  function validateTieFormat(params) {
1965
1993
  const checkCategory = !!(params?.enforceCategory !== false && params?.category);
1966
1994
  const checkGender = !!(params?.enforceGender !== false && params?.gender);
@@ -2116,13 +2144,19 @@ function validateCollectionDefinition({
2116
2144
  if (matchUpFormat && !matchUpFormatCode.isValid(matchUpFormat)) {
2117
2145
  errors.push(`Invalid matchUpFormat: ${matchUpFormat}`);
2118
2146
  }
2119
- if (checkGender && referenceGender && gender && [GenderEnum.Male, GenderEnum.Female].includes(referenceGender) && referenceGender !== gender) {
2120
- errors.push(`Invalid gender: ${gender}`);
2121
- return decorateResult({
2122
- result: { error: INVALID_GENDER, errors },
2123
- context: { referenceGender, gender },
2124
- stack
2147
+ if (checkGender) {
2148
+ const result = genderValidityCheck({
2149
+ referenceGender,
2150
+ matchUpType,
2151
+ gender
2125
2152
  });
2153
+ if (result.error) {
2154
+ return decorateResult({
2155
+ context: { referenceGender, gender },
2156
+ result,
2157
+ stack
2158
+ });
2159
+ }
2126
2160
  }
2127
2161
  if (checkCategory && referenceCategory && category) {
2128
2162
  const result = categoryCanContain({
@@ -5943,8 +5977,6 @@ function getSeeding({ seedAssignments, participantId }) {
5943
5977
  );
5944
5978
  }
5945
5979
 
5946
- const MIXED = "MIXED";
5947
-
5948
5980
  function getAllStructureMatchUps({
5949
5981
  scheduleVisibilityFilters,
5950
5982
  tournamentAppliedPolicies,
@@ -8032,10 +8064,11 @@ function updateMatchUpStatusCodes({
8032
8064
  );
8033
8065
  matchUp.matchUpStatusCodes = (matchUp.matchUpStatusCodes ?? []).map(
8034
8066
  (code) => {
8035
- if (code.sideNumber === sourceSideNumber) {
8036
- return { ...code, previousMatchUpStatus: sourceMatchUpStatus };
8067
+ const value = isString(code) || !isNaN(code) ? { code } : code;
8068
+ if (value.sideNumber === sourceSideNumber) {
8069
+ return { ...value, previousMatchUpStatus: sourceMatchUpStatus };
8037
8070
  }
8038
- return code;
8071
+ return value;
8039
8072
  }
8040
8073
  );
8041
8074
  }