tods-competition-factory 1.8.25 → 1.8.27

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.
@@ -496,18 +496,21 @@ function cycleMutationStatus() {
496
496
  return status;
497
497
  }
498
498
  function addNotice$1({ topic, payload, key }) {
499
- syncGlobalState.modified = true;
500
499
  if (typeof topic !== "string" || typeof payload !== "object") {
501
500
  return;
502
501
  }
503
- if (syncGlobalState.disableNotifications || !syncGlobalState.subscriptions[topic])
502
+ if (!syncGlobalState.disableNotifications)
503
+ syncGlobalState.modified = true;
504
+ if (syncGlobalState.disableNotifications || !syncGlobalState.subscriptions[topic]) {
504
505
  return;
506
+ }
505
507
  if (key) {
506
508
  syncGlobalState.notices = syncGlobalState.notices.filter(
507
509
  (notice) => !(notice.topic === topic && notice.key === key)
508
510
  );
509
511
  }
510
512
  syncGlobalState.notices.push({ topic, payload, key });
513
+ return { ...SUCCESS };
511
514
  }
512
515
  function getNotices({ topic }) {
513
516
  const notices = syncGlobalState.notices.filter((notice) => notice.topic === topic).map((notice) => notice.payload);
@@ -904,6 +907,9 @@ function getAccessorValue({ element, accessor }) {
904
907
  }
905
908
  }
906
909
 
910
+ function isString(obj) {
911
+ return typeof obj === "string";
912
+ }
907
913
  function isObject(obj) {
908
914
  return typeof obj === "object";
909
915
  }
@@ -1417,6 +1423,88 @@ function removeTournamentExtension(params) {
1417
1423
  });
1418
1424
  }
1419
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 (matchUpType === TypeEnum.Singles && referenceGender === MIXED)
1500
+ return decorateResult({
1501
+ info: "matchUpType SINGLES is invalid for gender MIXED",
1502
+ result: { error: INVALID_GENDER, valid: false },
1503
+ stack
1504
+ });
1505
+ return { valid: true };
1506
+ }
1507
+
1420
1508
  const typeMatch = (arr, type) => arr.filter(Boolean).every((i) => typeof i === type);
1421
1509
  const allNumeric = (arr) => arr.filter(Boolean).every(isNumeric);
1422
1510
  function getCategoryAgeDetails(params) {
@@ -1901,63 +1989,6 @@ const matchUpFormatCode = {
1901
1989
  parse
1902
1990
  };
1903
1991
 
1904
- var EntryStatusEnum = /* @__PURE__ */ ((EntryStatusEnum2) => {
1905
- EntryStatusEnum2["Alternate"] = "ALTERNATE";
1906
- EntryStatusEnum2["Confirmed"] = "CONFIRMED";
1907
- EntryStatusEnum2["DirectAcceptance"] = "DIRECT_ACCEPTANCE";
1908
- EntryStatusEnum2["FeedIn"] = "FEED_IN";
1909
- EntryStatusEnum2["JuniorExempt"] = "JUNIOR_EXEMPT";
1910
- EntryStatusEnum2["LuckyLoser"] = "LUCKY_LOSER";
1911
- EntryStatusEnum2["OrganiserAcceptance"] = "ORGANISER_ACCEPTANCE";
1912
- EntryStatusEnum2["Qualifier"] = "QUALIFIER";
1913
- EntryStatusEnum2["SpecialExempt"] = "SPECIAL_EXEMPT";
1914
- EntryStatusEnum2["Registered"] = "Registered";
1915
- EntryStatusEnum2["Ungrouped"] = "UNGROUPED";
1916
- EntryStatusEnum2["Unpaired"] = "UNPAIRED";
1917
- EntryStatusEnum2["Wildcard"] = "WILDCARD";
1918
- EntryStatusEnum2["Withdrawn"] = "WITHDRAWN";
1919
- return EntryStatusEnum2;
1920
- })(EntryStatusEnum || {});
1921
- var TypeEnum = /* @__PURE__ */ ((TypeEnum2) => {
1922
- TypeEnum2["Doubles"] = "DOUBLES";
1923
- TypeEnum2["Singles"] = "SINGLES";
1924
- TypeEnum2["Team"] = "TEAM";
1925
- return TypeEnum2;
1926
- })(TypeEnum || {});
1927
- var MatchUpStatusEnum = /* @__PURE__ */ ((MatchUpStatusEnum2) => {
1928
- MatchUpStatusEnum2["Abandoned"] = "ABANDONED";
1929
- MatchUpStatusEnum2["AwaitingResult"] = "AWAITING_RESULT";
1930
- MatchUpStatusEnum2["Bye"] = "BYE";
1931
- MatchUpStatusEnum2["Cancelled"] = "CANCELLED";
1932
- MatchUpStatusEnum2["Completed"] = "COMPLETED";
1933
- MatchUpStatusEnum2["DeadRubber"] = "DEAD_RUBBER";
1934
- MatchUpStatusEnum2["Defaulted"] = "DEFAULTED";
1935
- MatchUpStatusEnum2["DoubleDefault"] = "DOUBLE_DEFAULT";
1936
- MatchUpStatusEnum2["DoubleWalkover"] = "DOUBLE_WALKOVER";
1937
- MatchUpStatusEnum2["InProgress"] = "IN_PROGRESS";
1938
- MatchUpStatusEnum2["Incomplete"] = "INCOMPLETE";
1939
- MatchUpStatusEnum2["NotPlayed"] = "NOT_PLAYED";
1940
- MatchUpStatusEnum2["Retired"] = "RETIRED";
1941
- MatchUpStatusEnum2["Suspended"] = "SUSPENDED";
1942
- MatchUpStatusEnum2["ToBePlayed"] = "TO_BE_PLAYED";
1943
- MatchUpStatusEnum2["Walkover"] = "WALKOVER";
1944
- return MatchUpStatusEnum2;
1945
- })(MatchUpStatusEnum || {});
1946
- var GenderEnum = /* @__PURE__ */ ((GenderEnum2) => {
1947
- GenderEnum2["Any"] = "ANY";
1948
- GenderEnum2["Female"] = "FEMALE";
1949
- GenderEnum2["Male"] = "MALE";
1950
- GenderEnum2["Mixed"] = "MIXED";
1951
- return GenderEnum2;
1952
- })(GenderEnum || {});
1953
- var ParticipantTypeEnum = /* @__PURE__ */ ((ParticipantTypeEnum2) => {
1954
- ParticipantTypeEnum2["Group"] = "GROUP";
1955
- ParticipantTypeEnum2["Individual"] = "INDIVIDUAL";
1956
- ParticipantTypeEnum2["Pair"] = "PAIR";
1957
- ParticipantTypeEnum2["Team"] = "TEAM";
1958
- return ParticipantTypeEnum2;
1959
- })(ParticipantTypeEnum || {});
1960
-
1961
1992
  function validateTieFormat(params) {
1962
1993
  const checkCategory = !!(params?.enforceCategory !== false && params?.category);
1963
1994
  const checkGender = !!(params?.enforceGender !== false && params?.gender);
@@ -2113,13 +2144,19 @@ function validateCollectionDefinition({
2113
2144
  if (matchUpFormat && !matchUpFormatCode.isValid(matchUpFormat)) {
2114
2145
  errors.push(`Invalid matchUpFormat: ${matchUpFormat}`);
2115
2146
  }
2116
- if (checkGender && referenceGender && gender && [GenderEnum.Male, GenderEnum.Female].includes(referenceGender) && referenceGender !== gender) {
2117
- errors.push(`Invalid gender: ${gender}`);
2118
- return decorateResult({
2119
- result: { error: INVALID_GENDER, errors },
2120
- context: { referenceGender, gender },
2121
- stack
2147
+ if (checkGender) {
2148
+ const result = genderValidityCheck({
2149
+ referenceGender,
2150
+ matchUpType,
2151
+ gender
2122
2152
  });
2153
+ if (result.error) {
2154
+ return decorateResult({
2155
+ context: { referenceGender, gender },
2156
+ result,
2157
+ stack
2158
+ });
2159
+ }
2123
2160
  }
2124
2161
  if (checkCategory && referenceCategory && category) {
2125
2162
  const result = categoryCanContain({
@@ -4857,6 +4894,66 @@ function getDrawStructures({
4857
4894
  }
4858
4895
  }
4859
4896
 
4897
+ function getPositionAssignments({
4898
+ drawDefinition,
4899
+ structureId,
4900
+ structure
4901
+ }) {
4902
+ let error, positionAssignments = [];
4903
+ if (!structure) {
4904
+ if (!drawDefinition) {
4905
+ return { positionAssignments, error: MISSING_DRAW_DEFINITION };
4906
+ }
4907
+ ({ structure, error } = findStructure({ drawDefinition, structureId }));
4908
+ if (error)
4909
+ return { positionAssignments, error };
4910
+ }
4911
+ if (structure.structures) {
4912
+ positionAssignments = [].concat(
4913
+ ...structure.structures.map((structure2) => {
4914
+ return getPositionAssignments({ structure: structure2 }).positionAssignments;
4915
+ })
4916
+ );
4917
+ } else if (structure.positionAssignments) {
4918
+ positionAssignments = structure.positionAssignments;
4919
+ } else {
4920
+ error = MISSING_POSITION_ASSIGNMENTS;
4921
+ }
4922
+ return { positionAssignments, error };
4923
+ }
4924
+ function structureAssignedDrawPositions({
4925
+ drawDefinition,
4926
+ structureId,
4927
+ structure
4928
+ }) {
4929
+ const positionAssignments = getPositionAssignments({
4930
+ drawDefinition,
4931
+ structureId,
4932
+ structure
4933
+ })?.positionAssignments || [];
4934
+ const assignedPositions = positionAssignments?.filter((assignment) => {
4935
+ return assignment.participantId ?? assignment.bye ?? assignment.qualifier;
4936
+ });
4937
+ const allPositionsAssigned = positionAssignments && positionAssignments?.length === assignedPositions?.length;
4938
+ const unassignedPositions = positionAssignments?.filter((assignment) => {
4939
+ return !assignment.participantId && !assignment.bye && !assignment.qualifier;
4940
+ });
4941
+ const byePositions = positionAssignments?.filter((assignment) => {
4942
+ return !assignment.participantId && assignment.bye;
4943
+ });
4944
+ const qualifierPositions = positionAssignments?.filter((assignment) => {
4945
+ return !assignment.participantId && assignment.qualifier;
4946
+ });
4947
+ return {
4948
+ allPositionsAssigned,
4949
+ positionAssignments,
4950
+ unassignedPositions,
4951
+ assignedPositions,
4952
+ qualifierPositions,
4953
+ byePositions
4954
+ };
4955
+ }
4956
+
4860
4957
  EntryStatusEnum.Alternate;
4861
4958
  EntryStatusEnum.Confirmed;
4862
4959
  EntryStatusEnum.DirectAcceptance;
@@ -4983,6 +5080,7 @@ function getPlayoffEntries({
4983
5080
 
4984
5081
  function getStructureSeedAssignments({
4985
5082
  provisionalPositioning,
5083
+ returnAllProxies,
4986
5084
  drawDefinition,
4987
5085
  structureId,
4988
5086
  structure
@@ -4991,6 +5089,9 @@ function getStructureSeedAssignments({
4991
5089
  if (!structure) {
4992
5090
  ({ structure, error } = findStructure({ drawDefinition, structureId }));
4993
5091
  }
5092
+ const positionAssignments = getPositionAssignments({
5093
+ structure
5094
+ }).positionAssignments;
4994
5095
  if (error || !structure)
4995
5096
  return { seedAssignments: [], error: STRUCTURE_NOT_FOUND };
4996
5097
  if (!structureId)
@@ -5004,18 +5105,22 @@ function getStructureSeedAssignments({
5004
5105
  structureId,
5005
5106
  stage
5006
5107
  });
5007
- const seedProxies = entries ? entries.filter((entry) => entry.placementGroup === 1).sort((a, b) => {
5108
+ const proxiedEntries = entries ? entries.filter((entry) => entry.placementGroup === 1).sort((a, b) => {
5008
5109
  return a.GEMscore < b.GEMscore && 1 || a.GEMscore > b.GEMscore && -1 || 0;
5009
5110
  }).map((entry, index) => {
5010
5111
  const seedNumber = index + 1;
5011
5112
  return {
5012
5113
  participantId: entry.participantId,
5013
5114
  seedValue: seedNumber,
5014
- seedNumber,
5015
- seedProxy: true
5115
+ seedProxy: true,
5016
5116
  // flag so that proxy seeding information doesn't get used externally
5117
+ seedNumber
5017
5118
  };
5018
5119
  }) : [];
5120
+ const seedProxies = proxiedEntries?.slice(
5121
+ 0,
5122
+ returnAllProxies ? proxiedEntries.length : positionAssignments.length / 2
5123
+ );
5019
5124
  if (seedProxies.length) {
5020
5125
  seedAssignments = seedProxies;
5021
5126
  } else if (structure.seedAssignments) {
@@ -5024,7 +5129,13 @@ function getStructureSeedAssignments({
5024
5129
  error = MISSING_SEED_ASSIGNMENTS;
5025
5130
  }
5026
5131
  const seedLimit = structure.seedLimit || structure?.positionAssignments?.length;
5027
- return { seedAssignments, seedLimit, stage, stageSequence, error };
5132
+ return {
5133
+ seedAssignments,
5134
+ stageSequence,
5135
+ seedLimit,
5136
+ stage,
5137
+ error
5138
+ };
5028
5139
  }
5029
5140
 
5030
5141
  function getExitProfiles({ drawDefinition }) {
@@ -5303,66 +5414,6 @@ function getSourceDrawPositionRanges({
5303
5414
  return { sourceDrawPositionRanges };
5304
5415
  }
5305
5416
 
5306
- function getPositionAssignments({
5307
- drawDefinition,
5308
- structureId,
5309
- structure
5310
- }) {
5311
- let error, positionAssignments = [];
5312
- if (!structure) {
5313
- if (!drawDefinition) {
5314
- return { positionAssignments, error: MISSING_DRAW_DEFINITION };
5315
- }
5316
- ({ structure, error } = findStructure({ drawDefinition, structureId }));
5317
- if (error)
5318
- return { positionAssignments, error };
5319
- }
5320
- if (structure.structures) {
5321
- positionAssignments = [].concat(
5322
- ...structure.structures.map((structure2) => {
5323
- return getPositionAssignments({ structure: structure2 }).positionAssignments;
5324
- })
5325
- );
5326
- } else if (structure.positionAssignments) {
5327
- positionAssignments = structure.positionAssignments;
5328
- } else {
5329
- error = MISSING_POSITION_ASSIGNMENTS;
5330
- }
5331
- return { positionAssignments, error };
5332
- }
5333
- function structureAssignedDrawPositions({
5334
- drawDefinition,
5335
- structureId,
5336
- structure
5337
- }) {
5338
- const positionAssignments = getPositionAssignments({
5339
- drawDefinition,
5340
- structureId,
5341
- structure
5342
- })?.positionAssignments || [];
5343
- const assignedPositions = positionAssignments?.filter((assignment) => {
5344
- return assignment.participantId ?? assignment.bye ?? assignment.qualifier;
5345
- });
5346
- const allPositionsAssigned = positionAssignments && positionAssignments?.length === assignedPositions?.length;
5347
- const unassignedPositions = positionAssignments?.filter((assignment) => {
5348
- return !assignment.participantId && !assignment.bye && !assignment.qualifier;
5349
- });
5350
- const byePositions = positionAssignments?.filter((assignment) => {
5351
- return !assignment.participantId && assignment.bye;
5352
- });
5353
- const qualifierPositions = positionAssignments?.filter((assignment) => {
5354
- return !assignment.participantId && assignment.qualifier;
5355
- });
5356
- return {
5357
- allPositionsAssigned,
5358
- positionAssignments,
5359
- unassignedPositions,
5360
- assignedPositions,
5361
- qualifierPositions,
5362
- byePositions
5363
- };
5364
- }
5365
-
5366
5417
  function getOrderedDrawPositions({
5367
5418
  drawPositions,
5368
5419
  roundProfile,
@@ -5926,8 +5977,6 @@ function getSeeding({ seedAssignments, participantId }) {
5926
5977
  );
5927
5978
  }
5928
5979
 
5929
- const MIXED = "MIXED";
5930
-
5931
5980
  function getAllStructureMatchUps({
5932
5981
  scheduleVisibilityFilters,
5933
5982
  tournamentAppliedPolicies,
@@ -8015,10 +8064,11 @@ function updateMatchUpStatusCodes({
8015
8064
  );
8016
8065
  matchUp.matchUpStatusCodes = (matchUp.matchUpStatusCodes ?? []).map(
8017
8066
  (code) => {
8018
- if (code.sideNumber === sourceSideNumber) {
8019
- return { ...code, previousMatchUpStatus: sourceMatchUpStatus };
8067
+ const value = isString(code) || !isNaN(code) ? { code } : code;
8068
+ if (value.sideNumber === sourceSideNumber) {
8069
+ return { ...value, previousMatchUpStatus: sourceMatchUpStatus };
8020
8070
  }
8021
- return code;
8071
+ return value;
8022
8072
  }
8023
8073
  );
8024
8074
  }
@@ -13525,6 +13575,7 @@ function getSeedGroups({
13525
13575
 
13526
13576
  function getValidSeedBlocks({
13527
13577
  provisionalPositioning,
13578
+ returnAllProxies,
13528
13579
  appliedPolicies,
13529
13580
  drawDefinition,
13530
13581
  allPositions,
@@ -13540,6 +13591,7 @@ function getValidSeedBlocks({
13540
13591
  });
13541
13592
  const { seedAssignments } = getStructureSeedAssignments({
13542
13593
  provisionalPositioning,
13594
+ returnAllProxies,
13543
13595
  drawDefinition,
13544
13596
  structure
13545
13597
  });