tods-competition-factory 1.7.14 → 1.7.15

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.
@@ -975,29 +975,6 @@ function UUID() {
975
975
  lut[d3 & 255] + lut[d3 >> 8 & 255] + lut[d3 >> 16 & 255] + lut[d3 >> 24 & 255];
976
976
  }
977
977
 
978
- function decorateResult({
979
- context,
980
- result,
981
- stack,
982
- info
983
- }) {
984
- if (result && !Array.isArray(result?.stack))
985
- result.stack = [];
986
- if (result && Array.isArray(result?.stack) && typeof stack === "string") {
987
- result.stack.push(stack);
988
- }
989
- if (result && info) {
990
- result.info = info;
991
- }
992
- if (result && typeof context === "object" && Object.keys(context).length) {
993
- Object.assign(result, definedAttributes(context));
994
- }
995
- if (result && !result?.error && !result?.success) {
996
- Object.assign(result, { ...SUCCESS });
997
- }
998
- return result ?? { success: true };
999
- }
1000
-
1001
978
  const RANKING = "RANKING";
1002
979
  const RATING = "RATING";
1003
980
  const SCALE = "SCALE";
@@ -1069,6 +1046,29 @@ function findParticipant({
1069
1046
  return participant;
1070
1047
  }
1071
1048
 
1049
+ function decorateResult({
1050
+ context,
1051
+ result,
1052
+ stack,
1053
+ info
1054
+ }) {
1055
+ if (result && !Array.isArray(result?.stack))
1056
+ result.stack = [];
1057
+ if (result && Array.isArray(result?.stack) && typeof stack === "string") {
1058
+ result.stack.push(stack);
1059
+ }
1060
+ if (result && info) {
1061
+ result.info = info;
1062
+ }
1063
+ if (result && typeof context === "object" && Object.keys(context).length) {
1064
+ Object.assign(result, definedAttributes(context));
1065
+ }
1066
+ if (result && !result?.error && !result?.success) {
1067
+ Object.assign(result, { ...SUCCESS });
1068
+ }
1069
+ return result ?? { success: true };
1070
+ }
1071
+
1072
1072
  const stack = "extensionQueries";
1073
1073
  function findExtension$1({
1074
1074
  element,
@@ -1142,19 +1142,15 @@ function findEvent({
1142
1142
  }) {
1143
1143
  const stack = "findEvent";
1144
1144
  if (!tournamentRecord)
1145
- return {
1146
- event: void 0,
1147
- drawDefinition: void 0,
1148
- ...decorateResult({
1149
- result: { error: MISSING_TOURNAMENT_RECORD },
1150
- stack
1151
- })
1152
- };
1153
- const events = tournamentRecord?.events || [];
1145
+ return decorateResult({
1146
+ result: { error: MISSING_TOURNAMENT_RECORD },
1147
+ stack
1148
+ });
1149
+ const events = tournamentRecord?.events ?? [];
1154
1150
  if (drawId) {
1155
1151
  let drawDefinition;
1156
1152
  const event = events.find((event2) => {
1157
- const drawDefinitions = event2?.drawDefinitions || [];
1153
+ const drawDefinitions = event2?.drawDefinitions ?? [];
1158
1154
  const targetDrawDefinition = drawDefinitions.find(
1159
1155
  (drawDefinition2) => drawDefinition2.drawId === drawId
1160
1156
  );
@@ -1347,7 +1343,7 @@ function addExtension$1(params) {
1347
1343
  });
1348
1344
  if (!params.element.extensions)
1349
1345
  params.element.extensions = [];
1350
- const creationTime = params.creationTime !== void 0 ? params.creationTime : true;
1346
+ const creationTime = params?.creationTime ?? true;
1351
1347
  if (creationTime) {
1352
1348
  const createdAt = (/* @__PURE__ */ new Date()).toISOString();
1353
1349
  Object.assign(params.extension, { createdAt });
@@ -1731,31 +1727,25 @@ function validateTieFormat(params) {
1731
1727
  if (!params || !tieFormat || typeof tieFormat !== "object") {
1732
1728
  errors.push("tieFormat must be an object");
1733
1729
  return decorateResult({
1734
- result: {
1735
- context: { tieFormat, errors },
1736
- error: INVALID_TIE_FORMAT,
1737
- stack
1738
- }
1730
+ result: { error: INVALID_TIE_FORMAT },
1731
+ context: { tieFormat, errors },
1732
+ stack
1739
1733
  });
1740
1734
  }
1741
1735
  if (typeof tieFormat.winCriteria !== "object") {
1742
1736
  errors.push("tieFormat.winCriteria must be an object");
1743
1737
  return decorateResult({
1744
- result: {
1745
- context: { tieFormat, errors },
1746
- error: INVALID_TIE_FORMAT,
1747
- stack
1748
- }
1738
+ result: { error: INVALID_TIE_FORMAT },
1739
+ context: { tieFormat, errors },
1740
+ stack
1749
1741
  });
1750
1742
  }
1751
1743
  if (!Array.isArray(tieFormat.collectionDefinitions)) {
1752
1744
  errors.push(mustBeAnArray("tieFormat.collectionDefinitions"));
1753
1745
  return decorateResult({
1754
- result: {
1755
- context: { tieFormat, errors },
1756
- error: INVALID_TIE_FORMAT,
1757
- stack
1758
- }
1746
+ result: { error: INVALID_TIE_FORMAT },
1747
+ context: { tieFormat, errors },
1748
+ stack
1759
1749
  });
1760
1750
  }
1761
1751
  let aggregateValueImperative;
@@ -1788,11 +1778,9 @@ function validateTieFormat(params) {
1788
1778
  );
1789
1779
  }
1790
1780
  return decorateResult({
1791
- result: {
1792
- context: { tieFormat, errors, aggregateValueImperative },
1793
- error: INVALID_TIE_FORMAT,
1794
- stack
1795
- }
1781
+ context: { tieFormat, errors, aggregateValueImperative },
1782
+ result: { error: INVALID_TIE_FORMAT },
1783
+ stack
1796
1784
  });
1797
1785
  }
1798
1786
  const collectionIds = tieFormat.collectionDefinitions.map(
@@ -1803,11 +1791,9 @@ function validateTieFormat(params) {
1803
1791
  const result = { valid, errors };
1804
1792
  if (!valid) {
1805
1793
  return decorateResult({
1806
- result: {
1807
- context: { tieFormat, errors },
1808
- error: INVALID_TIE_FORMAT,
1809
- stack
1810
- }
1794
+ result: { error: INVALID_TIE_FORMAT },
1795
+ context: { tieFormat, errors },
1796
+ stack
1811
1797
  });
1812
1798
  }
1813
1799
  return result;
@@ -3817,7 +3803,7 @@ function findCourt({
3817
3803
  } else if (tournamentRecords) {
3818
3804
  const linkedTournamentIds = getLinkedTournamentIds({
3819
3805
  tournamentRecords
3820
- }).linkedTournamentIds || [];
3806
+ }).linkedTournamentIds ?? [];
3821
3807
  const relevantIds = linkedTournamentIds[tournamentRecord.tournamentId];
3822
3808
  for (const tournamentId of relevantIds) {
3823
3809
  const record = tournamentRecords[tournamentId];
@@ -10832,7 +10818,7 @@ function removeSubsequentRoundsParticipant({
10832
10818
  const positionAssignments = getPositionAssignments({
10833
10819
  drawDefinition,
10834
10820
  structureId
10835
- }).positionAssignments || [];
10821
+ }).positionAssignments ?? [];
10836
10822
  relevantMatchUps?.forEach(
10837
10823
  (matchUp) => removeDrawPosition({
10838
10824
  drawPosition: targetDrawPosition,
@@ -10862,7 +10848,7 @@ function removeDrawPosition({
10862
10848
  const initialDrawPositions = targetMatchUp.drawPositions?.slice();
10863
10849
  const initialMatchUpStatus = targetMatchUp.matchUpStatus;
10864
10850
  const initialWinningSide = targetMatchUp.winningSide;
10865
- matchUpsMap = matchUpsMap || getMatchUpsMap({ drawDefinition });
10851
+ matchUpsMap = matchUpsMap ?? getMatchUpsMap({ drawDefinition });
10866
10852
  const mappedMatchUps = matchUpsMap.mappedMatchUps;
10867
10853
  const matchUps = mappedMatchUps[structure.structureId].matchUps;
10868
10854
  const { initialRoundNumber } = getInitialRoundNumber({
@@ -10870,7 +10856,7 @@ function removeDrawPosition({
10870
10856
  matchUps
10871
10857
  });
10872
10858
  if (targetMatchUp.roundNumber && initialRoundNumber && targetMatchUp.roundNumber > initialRoundNumber) {
10873
- const drawPositions = (targetMatchUp.drawPositions || []).map(
10859
+ const drawPositions = (targetMatchUp.drawPositions ?? []).map(
10874
10860
  (currentDrawPosition) => currentDrawPosition === drawPosition ? void 0 : currentDrawPosition
10875
10861
  );
10876
10862
  targetMatchUp.drawPositions = drawPositions;
@@ -10879,7 +10865,7 @@ function removeDrawPosition({
10879
10865
  const inContextTargetMatchUp = inContextDrawMatchUps?.find(
10880
10866
  (matchUp) => matchUp.matchUpId === targetMatchUp.matchUpId
10881
10867
  );
10882
- const sides = inContextTargetMatchUp?.sides || [];
10868
+ const sides = inContextTargetMatchUp?.sides ?? [];
10883
10869
  const drawPositionSideIndex = sides.reduce(
10884
10870
  (index, side, i) => side.drawPosition === drawPosition ? i : index,
10885
10871
  void 0
@@ -12457,9 +12443,7 @@ function assignMatchUpDrawPosition({
12457
12443
  return { ...SUCCESS };
12458
12444
  } else {
12459
12445
  return decorateResult({
12460
- result: {
12461
- error: DRAW_POSITION_ASSIGNED
12462
- },
12446
+ result: { error: DRAW_POSITION_ASSIGNED },
12463
12447
  context: { drawPosition },
12464
12448
  stack
12465
12449
  });
@@ -13167,8 +13151,8 @@ function getSeedGroups({
13167
13151
  return {
13168
13152
  seedGroups: void 0,
13169
13153
  ...decorateResult({
13170
- result: { error: INVALID_VALUES },
13171
13154
  context: { roundRobinGroupsCount },
13155
+ result: { error: INVALID_VALUES },
13172
13156
  stack
13173
13157
  })
13174
13158
  };
@@ -14195,7 +14179,8 @@ function directLoser(params) {
14195
14179
  if (result.error)
14196
14180
  return decorateResult({ result, stack });
14197
14181
  } else if (loserParticipantId && isFeedRound) {
14198
- const fedDrawPosition = unfilledTargetMatchUpDrawPositions.sort(numericSort)[0];
14182
+ unfilledTargetMatchUpDrawPositions.sort(numericSort);
14183
+ const fedDrawPosition = unfilledTargetMatchUpDrawPositions[0];
14199
14184
  const result = assignDrawPosition({
14200
14185
  participantId: loserParticipantId,
14201
14186
  structureId: targetStructureId,
@@ -16081,7 +16066,7 @@ function setMatchUpStatus$2(params) {
16081
16066
  drawDefinition
16082
16067
  });
16083
16068
  if (score && matchUp.matchUpType !== TEAM$2 && !disableScoreValidation) {
16084
- const matchUpFormat = matchUp.matchUpFormat || structure?.matchUpFormat || drawDefinition?.matchUpFormat || event?.matchUpFormat;
16069
+ const matchUpFormat = matchUp.matchUpFormat ?? structure?.matchUpFormat ?? drawDefinition?.matchUpFormat ?? event?.matchUpFormat;
16085
16070
  const result2 = validateScore({
16086
16071
  existingMatchUpStatus: matchUp.matchUpStatus,
16087
16072
  matchUpFormat,
@@ -16102,9 +16087,9 @@ function setMatchUpStatus$2(params) {
16102
16087
  ).every((assignment) => assignment.participantId);
16103
16088
  if (matchUpStatus && particicipantsRequiredMatchUpStatuses.includes(matchUpStatus) && !bothSideParticipants) {
16104
16089
  return decorateResult({
16105
- result: { error: INVALID_MATCHUP_STATUS },
16106
16090
  info: "present in participantRequiredMatchUpStatuses",
16107
- context: { matchUpStatus, bothSideParticipants }
16091
+ context: { matchUpStatus, bothSideParticipants },
16092
+ result: { error: INVALID_MATCHUP_STATUS }
16108
16093
  });
16109
16094
  }
16110
16095
  const appliedPolicies = getAppliedPolicies({
@@ -16227,8 +16212,8 @@ function winningSideWithDownstreamDependencies(params) {
16227
16212
  return applyMatchUpValues(params);
16228
16213
  } else {
16229
16214
  return decorateResult({
16230
- result: { error: CANNOT_CHANGE_WINNING_SIDE },
16231
16215
  stack: "winningSideWithDownstreamDependencies",
16216
+ result: { error: CANNOT_CHANGE_WINNING_SIDE },
16232
16217
  context: { winningSide, matchUp }
16233
16218
  });
16234
16219
  }