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.
package/dist/index.mjs CHANGED
@@ -333,7 +333,7 @@ const matchUpFormatCode = {
333
333
  };
334
334
 
335
335
  function factoryVersion() {
336
- return "1.7.14";
336
+ return "1.7.15";
337
337
  }
338
338
 
339
339
  function getObjectTieFormat(obj) {
@@ -2561,31 +2561,25 @@ function validateTieFormat(params) {
2561
2561
  if (!params || !tieFormat || typeof tieFormat !== "object") {
2562
2562
  errors.push("tieFormat must be an object");
2563
2563
  return decorateResult({
2564
- result: {
2565
- context: { tieFormat, errors },
2566
- error: INVALID_TIE_FORMAT,
2567
- stack
2568
- }
2564
+ result: { error: INVALID_TIE_FORMAT },
2565
+ context: { tieFormat, errors },
2566
+ stack
2569
2567
  });
2570
2568
  }
2571
2569
  if (typeof tieFormat.winCriteria !== "object") {
2572
2570
  errors.push("tieFormat.winCriteria must be an object");
2573
2571
  return decorateResult({
2574
- result: {
2575
- context: { tieFormat, errors },
2576
- error: INVALID_TIE_FORMAT,
2577
- stack
2578
- }
2572
+ result: { error: INVALID_TIE_FORMAT },
2573
+ context: { tieFormat, errors },
2574
+ stack
2579
2575
  });
2580
2576
  }
2581
2577
  if (!Array.isArray(tieFormat.collectionDefinitions)) {
2582
2578
  errors.push(mustBeAnArray("tieFormat.collectionDefinitions"));
2583
2579
  return decorateResult({
2584
- result: {
2585
- context: { tieFormat, errors },
2586
- error: INVALID_TIE_FORMAT,
2587
- stack
2588
- }
2580
+ result: { error: INVALID_TIE_FORMAT },
2581
+ context: { tieFormat, errors },
2582
+ stack
2589
2583
  });
2590
2584
  }
2591
2585
  let aggregateValueImperative;
@@ -2618,11 +2612,9 @@ function validateTieFormat(params) {
2618
2612
  );
2619
2613
  }
2620
2614
  return decorateResult({
2621
- result: {
2622
- context: { tieFormat, errors, aggregateValueImperative },
2623
- error: INVALID_TIE_FORMAT,
2624
- stack
2625
- }
2615
+ context: { tieFormat, errors, aggregateValueImperative },
2616
+ result: { error: INVALID_TIE_FORMAT },
2617
+ stack
2626
2618
  });
2627
2619
  }
2628
2620
  const collectionIds = tieFormat.collectionDefinitions.map(
@@ -2633,11 +2625,9 @@ function validateTieFormat(params) {
2633
2625
  const result = { valid, errors };
2634
2626
  if (!valid) {
2635
2627
  return decorateResult({
2636
- result: {
2637
- context: { tieFormat, errors },
2638
- error: INVALID_TIE_FORMAT,
2639
- stack
2640
- }
2628
+ result: { error: INVALID_TIE_FORMAT },
2629
+ context: { tieFormat, errors },
2630
+ stack
2641
2631
  });
2642
2632
  }
2643
2633
  return result;
@@ -4814,19 +4804,15 @@ function findEvent({
4814
4804
  }) {
4815
4805
  const stack = "findEvent";
4816
4806
  if (!tournamentRecord)
4817
- return {
4818
- event: void 0,
4819
- drawDefinition: void 0,
4820
- ...decorateResult({
4821
- result: { error: MISSING_TOURNAMENT_RECORD },
4822
- stack
4823
- })
4824
- };
4825
- const events = tournamentRecord?.events || [];
4807
+ return decorateResult({
4808
+ result: { error: MISSING_TOURNAMENT_RECORD },
4809
+ stack
4810
+ });
4811
+ const events = tournamentRecord?.events ?? [];
4826
4812
  if (drawId) {
4827
4813
  let drawDefinition;
4828
4814
  const event = events.find((event2) => {
4829
- const drawDefinitions = event2?.drawDefinitions || [];
4815
+ const drawDefinitions = event2?.drawDefinitions ?? [];
4830
4816
  const targetDrawDefinition = drawDefinitions.find(
4831
4817
  (drawDefinition2) => drawDefinition2.drawId === drawId
4832
4818
  );
@@ -4905,7 +4891,7 @@ function addExtension$1(params) {
4905
4891
  });
4906
4892
  if (!params.element.extensions)
4907
4893
  params.element.extensions = [];
4908
- const creationTime = params.creationTime !== void 0 ? params.creationTime : true;
4894
+ const creationTime = params?.creationTime ?? true;
4909
4895
  if (creationTime) {
4910
4896
  const createdAt = (/* @__PURE__ */ new Date()).toISOString();
4911
4897
  Object.assign(params.extension, { createdAt });
@@ -5456,7 +5442,7 @@ function findCourt({
5456
5442
  } else if (tournamentRecords) {
5457
5443
  const linkedTournamentIds = getLinkedTournamentIds({
5458
5444
  tournamentRecords
5459
- }).linkedTournamentIds || [];
5445
+ }).linkedTournamentIds ?? [];
5460
5446
  const relevantIds = linkedTournamentIds[tournamentRecord.tournamentId];
5461
5447
  for (const tournamentId of relevantIds) {
5462
5448
  const record = tournamentRecords[tournamentId];
@@ -20808,7 +20794,7 @@ function removeSubsequentRoundsParticipant({
20808
20794
  const positionAssignments = getPositionAssignments$1({
20809
20795
  drawDefinition,
20810
20796
  structureId
20811
- }).positionAssignments || [];
20797
+ }).positionAssignments ?? [];
20812
20798
  relevantMatchUps?.forEach(
20813
20799
  (matchUp) => removeDrawPosition({
20814
20800
  drawPosition: targetDrawPosition,
@@ -20838,7 +20824,7 @@ function removeDrawPosition({
20838
20824
  const initialDrawPositions = targetMatchUp.drawPositions?.slice();
20839
20825
  const initialMatchUpStatus = targetMatchUp.matchUpStatus;
20840
20826
  const initialWinningSide = targetMatchUp.winningSide;
20841
- matchUpsMap = matchUpsMap || getMatchUpsMap({ drawDefinition });
20827
+ matchUpsMap = matchUpsMap ?? getMatchUpsMap({ drawDefinition });
20842
20828
  const mappedMatchUps = matchUpsMap.mappedMatchUps;
20843
20829
  const matchUps = mappedMatchUps[structure.structureId].matchUps;
20844
20830
  const { initialRoundNumber } = getInitialRoundNumber({
@@ -20846,7 +20832,7 @@ function removeDrawPosition({
20846
20832
  matchUps
20847
20833
  });
20848
20834
  if (targetMatchUp.roundNumber && initialRoundNumber && targetMatchUp.roundNumber > initialRoundNumber) {
20849
- const drawPositions = (targetMatchUp.drawPositions || []).map(
20835
+ const drawPositions = (targetMatchUp.drawPositions ?? []).map(
20850
20836
  (currentDrawPosition) => currentDrawPosition === drawPosition ? void 0 : currentDrawPosition
20851
20837
  );
20852
20838
  targetMatchUp.drawPositions = drawPositions;
@@ -20855,7 +20841,7 @@ function removeDrawPosition({
20855
20841
  const inContextTargetMatchUp = inContextDrawMatchUps?.find(
20856
20842
  (matchUp) => matchUp.matchUpId === targetMatchUp.matchUpId
20857
20843
  );
20858
- const sides = inContextTargetMatchUp?.sides || [];
20844
+ const sides = inContextTargetMatchUp?.sides ?? [];
20859
20845
  const drawPositionSideIndex = sides.reduce(
20860
20846
  (index, side, i) => side.drawPosition === drawPosition ? i : index,
20861
20847
  void 0
@@ -22074,9 +22060,7 @@ function assignMatchUpDrawPosition({
22074
22060
  return { ...SUCCESS };
22075
22061
  } else {
22076
22062
  return decorateResult({
22077
- result: {
22078
- error: DRAW_POSITION_ASSIGNED
22079
- },
22063
+ result: { error: DRAW_POSITION_ASSIGNED },
22080
22064
  context: { drawPosition },
22081
22065
  stack
22082
22066
  });
@@ -23153,8 +23137,8 @@ function getSeedGroups({
23153
23137
  return {
23154
23138
  seedGroups: void 0,
23155
23139
  ...decorateResult({
23156
- result: { error: INVALID_VALUES },
23157
23140
  context: { roundRobinGroupsCount },
23141
+ result: { error: INVALID_VALUES },
23158
23142
  stack
23159
23143
  })
23160
23144
  };
@@ -23198,8 +23182,8 @@ function getSeedingThresholds({
23198
23182
  const invalid = !validGroupsCounts?.includes(roundRobinGroupsCount);
23199
23183
  if (invalid) {
23200
23184
  return decorateResult({
23201
- result: { error: INVALID_VALUES },
23202
- context: { roundRobinGroupsCount }
23185
+ context: { roundRobinGroupsCount },
23186
+ result: { error: INVALID_VALUES }
23203
23187
  });
23204
23188
  }
23205
23189
  }
@@ -24306,7 +24290,8 @@ function directLoser(params) {
24306
24290
  if (result.error)
24307
24291
  return decorateResult({ result, stack });
24308
24292
  } else if (loserParticipantId && isFeedRound) {
24309
- const fedDrawPosition = unfilledTargetMatchUpDrawPositions.sort(numericSort)[0];
24293
+ unfilledTargetMatchUpDrawPositions.sort(numericSort);
24294
+ const fedDrawPosition = unfilledTargetMatchUpDrawPositions[0];
24310
24295
  const result = assignDrawPosition$1({
24311
24296
  participantId: loserParticipantId,
24312
24297
  structureId: targetStructureId,
@@ -25293,7 +25278,7 @@ function setMatchUpStatus$2(params) {
25293
25278
  drawDefinition
25294
25279
  });
25295
25280
  if (score && matchUp.matchUpType !== TEAM$2 && !disableScoreValidation) {
25296
- const matchUpFormat = matchUp.matchUpFormat || structure?.matchUpFormat || drawDefinition?.matchUpFormat || event?.matchUpFormat;
25281
+ const matchUpFormat = matchUp.matchUpFormat ?? structure?.matchUpFormat ?? drawDefinition?.matchUpFormat ?? event?.matchUpFormat;
25297
25282
  const result2 = validateScore({
25298
25283
  existingMatchUpStatus: matchUp.matchUpStatus,
25299
25284
  matchUpFormat,
@@ -25314,9 +25299,9 @@ function setMatchUpStatus$2(params) {
25314
25299
  ).every((assignment) => assignment.participantId);
25315
25300
  if (matchUpStatus && particicipantsRequiredMatchUpStatuses.includes(matchUpStatus) && !bothSideParticipants) {
25316
25301
  return decorateResult({
25317
- result: { error: INVALID_MATCHUP_STATUS },
25318
25302
  info: "present in participantRequiredMatchUpStatuses",
25319
- context: { matchUpStatus, bothSideParticipants }
25303
+ context: { matchUpStatus, bothSideParticipants },
25304
+ result: { error: INVALID_MATCHUP_STATUS }
25320
25305
  });
25321
25306
  }
25322
25307
  const appliedPolicies = getAppliedPolicies({
@@ -25439,8 +25424,8 @@ function winningSideWithDownstreamDependencies(params) {
25439
25424
  return applyMatchUpValues(params);
25440
25425
  } else {
25441
25426
  return decorateResult({
25442
- result: { error: CANNOT_CHANGE_WINNING_SIDE },
25443
25427
  stack: "winningSideWithDownstreamDependencies",
25428
+ result: { error: CANNOT_CHANGE_WINNING_SIDE },
25444
25429
  context: { winningSide, matchUp }
25445
25430
  });
25446
25431
  }
@@ -25844,14 +25829,14 @@ function addDrawDefinition$1(params) {
25844
25829
  if (relevantFlight && !drawEntriesPresentInFlight) {
25845
25830
  return decorateResult({
25846
25831
  result: {
25847
- error: INVALID_DRAW_DEFINITION,
25848
- context: {
25849
- drawEntriesPresentInFlight,
25850
- matchingEventEntries,
25851
- relevantFlight
25852
- },
25853
- info: "Draw entries are not present in flight or do not match entryStatuses"
25854
- }
25832
+ error: INVALID_DRAW_DEFINITION
25833
+ },
25834
+ context: {
25835
+ drawEntriesPresentInFlight,
25836
+ matchingEventEntries,
25837
+ relevantFlight
25838
+ },
25839
+ info: "Draw entries are not present in flight or do not match entryStatuses"
25855
25840
  });
25856
25841
  }
25857
25842
  if (modifyEventEntries) {
@@ -25870,9 +25855,9 @@ function addDrawDefinition$1(params) {
25870
25855
  if (eventEntries && !matchingEventEntries)
25871
25856
  return decorateResult({
25872
25857
  result: {
25873
- error: INVALID_DRAW_DEFINITION,
25858
+ info: "Draw entries do not match event entryStatuses",
25874
25859
  context: { matchingEventEntries, eventEntries },
25875
- info: "Draw entries do not match event entryStatuses"
25860
+ error: INVALID_DRAW_DEFINITION
25876
25861
  }
25877
25862
  });
25878
25863
  const flightNumbers = flightProfile?.flights?.map(
@@ -26051,10 +26036,8 @@ function addParticipant$1({
26051
26036
  });
26052
26037
  } else if (participant.individualParticipantIds.length !== 2 && !pairOverride) {
26053
26038
  return decorateResult({
26054
- result: {
26055
- error: INVALID_PARTICIPANT_IDS,
26056
- info: "PAIR must be 2 individualParticipantIds"
26057
- },
26039
+ info: "PAIR must be 2 individualParticipantIds",
26040
+ result: { error: INVALID_PARTICIPANT_IDS },
26058
26041
  stack
26059
26042
  });
26060
26043
  } else {
@@ -29756,6 +29739,7 @@ function updateTieFormat({
29756
29739
  event,
29757
29740
  uuids
29758
29741
  }) {
29742
+ console.log("booo", { matchUp });
29759
29743
  const stack = "updateTieFormat";
29760
29744
  const tournamentId = tournamentRecord?.tournamentId;
29761
29745
  let modifiedStructuresCount = 0;
@@ -29806,7 +29790,8 @@ function updateTieFormat({
29806
29790
  } else {
29807
29791
  return decorateResult({
29808
29792
  result: { error: CANNOT_MODIFY_TIEFORMAT },
29809
- info: "matchUp is IN_PROGRESS or COMPLETE"
29793
+ info: "matchUp is IN_PROGRESS or COMPLETE",
29794
+ stack
29810
29795
  });
29811
29796
  }
29812
29797
  } else if (changesArePossible) {
@@ -30674,6 +30659,7 @@ function addCollectionDefinition$1({
30674
30659
  uuids,
30675
30660
  event
30676
30661
  }) {
30662
+ const stack = "addCollectionDefinition";
30677
30663
  const appliedPolicies = getAppliedPolicies({
30678
30664
  tournamentRecord,
30679
30665
  drawDefinition,
@@ -30687,10 +30673,10 @@ function addCollectionDefinition$1({
30687
30673
  checkGender,
30688
30674
  event
30689
30675
  });
30690
- if (!valid)
30691
- return { error: INVALID_VALUES, errors };
30692
- const stack = "addCollectionDefinition";
30693
- let result = !matchUp ? getTieFormat$1({
30676
+ if (!valid) {
30677
+ return decorateResult({ result: { error: INVALID_VALUES, errors }, stack });
30678
+ }
30679
+ let result = !matchUp?.tieFormat ? getTieFormat$1({
30694
30680
  drawDefinition,
30695
30681
  structureId,
30696
30682
  matchUpId,
@@ -30698,14 +30684,15 @@ function addCollectionDefinition$1({
30698
30684
  event
30699
30685
  }) : void 0;
30700
30686
  if (result?.error)
30701
- return { error: result.error };
30687
+ return decorateResult({ result: { error: result.error }, stack });
30702
30688
  const structure = result?.structure;
30703
30689
  matchUp = matchUp ?? result?.matchUp;
30704
- const existingTieFormat = result?.tieFormat;
30690
+ const existingTieFormat = matchUp?.tieFormat ?? result?.tieFormat;
30705
30691
  const tieFormat = copyTieFormat(existingTieFormat);
30706
30692
  result = validateTieFormat({ tieFormat });
30707
- if (result?.error)
30708
- return { error: result.error };
30693
+ if (result?.error) {
30694
+ return decorateResult({ result: { error: result.error }, stack });
30695
+ }
30709
30696
  if (!collectionDefinition.collectionId) {
30710
30697
  collectionDefinition.collectionId = UUID();
30711
30698
  } else {
@@ -30738,8 +30725,9 @@ function addCollectionDefinition$1({
30738
30725
  let targetMatchUps = [];
30739
30726
  const prunedTieFormat = definedAttributes(tieFormat);
30740
30727
  result = validateTieFormat({ tieFormat: prunedTieFormat });
30741
- if (result?.error)
30742
- return { error: result.error };
30728
+ if (result?.error) {
30729
+ return decorateResult({ result: { error: result.error }, stack });
30730
+ }
30743
30731
  if (eventId && event) {
30744
30732
  event.tieFormat = prunedTieFormat;
30745
30733
  for (const drawDefinition2 of event.drawDefinitions ?? []) {
@@ -31168,10 +31156,8 @@ function addCollectionGroup$1({
31168
31156
  const { collectionId, collectionGroupNumber: collectionGroupNumber2 } = collectionDefinition;
31169
31157
  if (collectionGroupNumber2 && collectionIds.includes(collectionId))
31170
31158
  return decorateResult({
31171
- result: {
31172
- error: INVALID_VALUES,
31173
- info: "collectionIds cannot be part of other collectionGroups"
31174
- },
31159
+ info: "collectionIds cannot be part of other collectionGroups",
31160
+ result: { error: INVALID_VALUES },
31175
31161
  stack
31176
31162
  });
31177
31163
  }
@@ -31226,7 +31212,7 @@ function modifyTieFormat$1({
31226
31212
  uuids,
31227
31213
  event
31228
31214
  }) {
31229
- const stack = "updateTieFormat";
31215
+ const stack = "modifyTieFormat";
31230
31216
  if (!validateTieFormat({ tieFormat: modifiedTieFormat }).valid) {
31231
31217
  return decorateResult({
31232
31218
  result: { error: INVALID_TIE_FORMAT },
@@ -31252,11 +31238,16 @@ function modifyTieFormat$1({
31252
31238
  if (comparison.invalid) {
31253
31239
  return decorateResult({
31254
31240
  context: { invalid: comparison.invalid },
31255
- result: { error: INVALID_TIE_FORMAT }
31241
+ result: { error: INVALID_TIE_FORMAT },
31242
+ stack
31256
31243
  });
31257
31244
  }
31258
31245
  if (!comparison?.different) {
31259
- return decorateResult({ result: { ...SUCCESS }, info: "Nothing to do" });
31246
+ return decorateResult({
31247
+ result: { ...SUCCESS },
31248
+ info: "Nothing to do",
31249
+ stack
31250
+ });
31260
31251
  }
31261
31252
  const existingCollectionIds = tieFormat.collectionDefinitions.map(
31262
31253
  ({ collectionId }) => collectionId
@@ -42828,11 +42819,7 @@ function positionByes({
42828
42819
  }
42829
42820
 
42830
42821
  function positionQualifiers(params) {
42831
- let { structure, structureId } = params;
42832
- if (!structure)
42833
- ({ structure } = findStructure(params));
42834
- if (!structureId)
42835
- ({ structureId } = structure);
42822
+ const structure = params.structure ?? findStructure(params).structure;
42836
42823
  const stack = "positionQualifiers";
42837
42824
  const qualifierDrawPositions = [];
42838
42825
  if (structure.stage === CONSOLATION) {
@@ -43476,7 +43463,7 @@ function generateAndPopulatePlayoffStructures(params) {
43476
43463
  drawDefinition
43477
43464
  });
43478
43465
  if (!structure)
43479
- return decorateResult({ result: { error: STRUCTURE_NOT_FOUND } });
43466
+ return decorateResult({ result: { error: STRUCTURE_NOT_FOUND }, stack });
43480
43467
  if (structure.structureType === CONTAINER || structure.structures) {
43481
43468
  return generateAndPopulateRRplayoffStructures({
43482
43469
  sourceStructureId: structure.structureId,
@@ -44290,11 +44277,11 @@ function attachStructures$1({
44290
44277
  links = [],
44291
44278
  event
44292
44279
  }) {
44280
+ const stack = "attachStructures";
44293
44281
  if (!drawDefinition)
44294
44282
  return { error: MISSING_DRAW_DEFINITION };
44295
44283
  if (!Array.isArray(structures) || !Array.isArray(links))
44296
- return decorateResult({ result: { error: INVALID_VALUES } });
44297
- const stack = "attachStructures";
44284
+ return decorateResult({ result: { error: INVALID_VALUES }, stack });
44298
44285
  const linkHash = (link) => [
44299
44286
  link.source.structureId,
44300
44287
  link.source.roundNumber || link.source.finishingPositions?.join("|"),
@@ -45197,7 +45184,9 @@ function positionParticipantAction(params) {
45197
45184
  };
45198
45185
  addPositionActionTelemetry({ drawDefinition, positionAction });
45199
45186
  return decorateResult({
45200
- result: { ...SUCCESS, context: { removedParticipantId: removedParticipantId2 }, stack }
45187
+ context: { removedParticipantId: removedParticipantId2 },
45188
+ result: { ...SUCCESS },
45189
+ stack
45201
45190
  });
45202
45191
  }
45203
45192
  }
@@ -45965,8 +45954,8 @@ function addEventEntries(params) {
45965
45954
  const removedEntries = [];
45966
45955
  if (extensions && (!Array.isArray(extensions) || !extensions.every(isValidExtension)) || extension && !isValidExtension({ extension })) {
45967
45956
  return decorateResult({
45968
- result: { error: INVALID_VALUES },
45969
45957
  context: definedAttributes({ extension, extensions }),
45958
+ result: { error: INVALID_VALUES },
45970
45959
  info: "Invalid extension(s)",
45971
45960
  stack
45972
45961
  });
@@ -46071,8 +46060,8 @@ function addEventEntries(params) {
46071
46060
  const invalidParticipantIds = validParticipantIds.length !== participantIds.length;
46072
46061
  if (invalidParticipantIds)
46073
46062
  return decorateResult({
46074
- result: { error: INVALID_PARTICIPANT_IDS },
46075
46063
  context: { misMatchedGender, gender: event.gender },
46064
+ result: { error: INVALID_PARTICIPANT_IDS },
46076
46065
  stack
46077
46066
  });
46078
46067
  if (autoEntryPositions) {
@@ -47627,19 +47616,17 @@ function setOrderOfFinish$1({
47627
47616
  const stack = "setOrderOfFinish";
47628
47617
  if (!Array.isArray(finishingOrder))
47629
47618
  return decorateResult({
47630
- result: {
47631
- error: INVALID_VALUES
47632
- },
47633
47619
  info: mustBeAnArray("finishingOrder"),
47620
+ result: { error: INVALID_VALUES },
47634
47621
  stack
47635
47622
  });
47636
47623
  const { completedMatchUps, matchUpsMap } = getDrawMatchUps({
47637
47624
  inContext: true,
47638
47625
  drawDefinition
47639
47626
  });
47640
- const matchUpIds = completedMatchUps?.map(getMatchUpId) || [];
47627
+ const matchUpIds = completedMatchUps?.map(getMatchUpId) ?? [];
47641
47628
  const targetMatchUpIds = finishingOrder.map(getMatchUpId);
47642
- const { matchUpTypes, roundNumbers, structureIds, matchUpTieIds } = (completedMatchUps || []).filter(({ matchUpId }) => targetMatchUpIds.includes(matchUpId)).reduce(
47629
+ const { matchUpTypes, roundNumbers, structureIds, matchUpTieIds } = (completedMatchUps ?? []).filter(({ matchUpId }) => targetMatchUpIds.includes(matchUpId)).reduce(
47643
47630
  (aggregator, matchUp) => {
47644
47631
  const { matchUpTieId, matchUpType, roundNumber, structureId } = matchUp;
47645
47632
  if (!aggregator.matchUpTypes.includes(matchUpType))
@@ -47661,10 +47648,8 @@ function setOrderOfFinish$1({
47661
47648
  );
47662
47649
  if (matchUpTypes.length > 1 || matchUpTieIds.length > 1 || roundNumbers.length > 1 || structureIds.length > 1) {
47663
47650
  return decorateResult({
47664
- result: {
47665
- error: INVALID_VALUES
47666
- },
47667
47651
  info: "matchUpType, structureId and roundNumber must be equivalent",
47652
+ result: { error: INVALID_VALUES },
47668
47653
  stack
47669
47654
  });
47670
47655
  }
@@ -47693,7 +47678,7 @@ function setOrderOfFinish$1({
47693
47678
  const otherCohortMatchUps = completedMatchUps?.filter(
47694
47679
  (matchUp) => matchUp.structureId === structureIds[0] && matchUp.roundNumber === roundNumbers[0] && matchUp.matchUpType === matchUpTypes[0] && matchUp.matchUpTieId === matchUpTieIds[0] && !targetedMatchUpIds.includes(matchUp.matchUpId)
47695
47680
  );
47696
- for (const matchUp of otherCohortMatchUps || []) {
47681
+ for (const matchUp of otherCohortMatchUps ?? []) {
47697
47682
  const { orderOfFinish } = matchUp || {};
47698
47683
  if (orderOfFinish) {
47699
47684
  if (!isConvertableInteger(orderOfFinish))
@@ -47707,10 +47692,8 @@ function setOrderOfFinish$1({
47707
47692
  }
47708
47693
  if (uniqueValues(orderOfFinishValues).length !== orderOfFinishValues.length || Math.max(...orderOfFinishValues) > orderOfFinishValues.length) {
47709
47694
  return decorateResult({
47710
- result: {
47711
- error: INVALID_VALUES
47712
- },
47713
47695
  info: "Values not unique or greater than expected number of values",
47696
+ result: { error: INVALID_VALUES },
47714
47697
  stack
47715
47698
  });
47716
47699
  }
@@ -50343,10 +50326,8 @@ function addIndividualParticipantIds({
50343
50326
  return decorateResult({ result: { error: PARTICIPANT_NOT_FOUND }, stack });
50344
50327
  if (groupingParticipant?.participantType && ![TEAM, GROUP].includes(groupingParticipant.participantType)) {
50345
50328
  return decorateResult({
50346
- result: {
50347
- error: INVALID_PARTICIPANT_TYPE
50348
- },
50349
50329
  context: { participantType: groupingParticipant.participantType },
50330
+ result: { error: INVALID_PARTICIPANT_TYPE },
50350
50331
  stack
50351
50332
  });
50352
50333
  }
@@ -52376,7 +52357,7 @@ function assignTieMatchUpParticipantId(params) {
52376
52357
  const tieMatchUpSide = inContextTieMatchUp?.sides?.find(
52377
52358
  (side) => side.sideNumber === sideNumber
52378
52359
  );
52379
- const lineUp = dualMatchUpSide?.lineUp || getTeamLineUp({
52360
+ const lineUp = dualMatchUpSide?.lineUp ?? getTeamLineUp({
52380
52361
  participantId: teamParticipantId,
52381
52362
  drawDefinition
52382
52363
  })?.lineUp;
@@ -54926,8 +54907,8 @@ function deleteDrawDefinitions({
54926
54907
  const auditTrail = [];
54927
54908
  if (!event?.drawDefinitions)
54928
54909
  return decorateResult({
54929
- result: { ...SUCCESS },
54930
54910
  info: "event has no drawDefinition",
54911
+ result: { ...SUCCESS },
54931
54912
  stack
54932
54913
  });
54933
54914
  const eventDrawIds = event.drawDefinitions.map(({ drawId: drawId2 }) => drawId2);
@@ -54936,8 +54917,8 @@ function deleteDrawDefinitions({
54936
54917
  drawIds = drawIds.filter((drawId2) => eventDrawIds.includes(drawId2));
54937
54918
  if (!drawIds.length)
54938
54919
  return decorateResult({
54939
- result: { ...SUCCESS },
54940
54920
  info: "nothing to do; no matching drawIds in event.",
54921
+ result: { ...SUCCESS },
54941
54922
  stack
54942
54923
  });
54943
54924
  const flightProfile = makeDeepCopy(
@@ -57791,6 +57772,7 @@ function addVoluntaryConsolationStructure(params) {
57791
57772
  }
57792
57773
 
57793
57774
  function prepareStage(params) {
57775
+ const stack = "prepareStage";
57794
57776
  let { seedsCount } = params;
57795
57777
  const preparedStructureIds = params.preparedStructureIds || [];
57796
57778
  const {
@@ -57846,7 +57828,7 @@ function prepareStage(params) {
57846
57828
  ({ structureId: structureId2 }) => !preparedStructureIds.includes(structureId2)
57847
57829
  );
57848
57830
  if (!structure)
57849
- return decorateResult({ result: { error: STRUCTURE_NOT_FOUND } });
57831
+ return decorateResult({ result: { error: STRUCTURE_NOT_FOUND }, stack });
57850
57832
  const structureId = structure?.structureId;
57851
57833
  const seedBlockInfo = structure ? getValidSeedBlocks({
57852
57834
  provisionalPositioning,
@@ -57969,7 +57951,7 @@ function prepareStage(params) {
57969
57951
  positionAssignments = result?.positionAssignments;
57970
57952
  positioningReport = result?.positioningReport;
57971
57953
  if (result.error) {
57972
- return decorateResult({ result, stack: "prepareStage" });
57954
+ return decorateResult({ result, stack });
57973
57955
  }
57974
57956
  }
57975
57957
  return {
@@ -58115,10 +58097,8 @@ function generateDrawDefinition(params) {
58115
58097
  if (policyDefinitions) {
58116
58098
  if (typeof policyDefinitions !== "object") {
58117
58099
  return decorateResult({
58118
- result: {
58119
- info: "policyDefinitions must be an object",
58120
- error: INVALID_VALUES
58121
- },
58100
+ info: "policyDefinitions must be an object",
58101
+ result: { error: INVALID_VALUES },
58122
58102
  stack
58123
58103
  });
58124
58104
  } else {
@@ -58347,8 +58327,9 @@ function generateDrawDefinition(params) {
58347
58327
  for (const roundTargetProfile of params.qualifyingProfiles) {
58348
58328
  if (!Array.isArray(roundTargetProfile.structureProfiles))
58349
58329
  return decorateResult({
58330
+ info: mustBeAnArray("structureProfiles"),
58350
58331
  result: { error: MISSING_VALUE },
58351
- info: mustBeAnArray("structureProfiles")
58332
+ stack
58352
58333
  });
58353
58334
  roundTarget = roundTargetProfile.roundTarget || roundTarget;
58354
58335
  const sortedStructureProfiles = roundTargetProfile.structureProfiles?.sort(sequenceSort) || [];
@@ -58579,12 +58560,12 @@ function modifyEvent({
58579
58560
  const enteredParticipantIds = event?.entries?.filter(({ entryStatus }) => {
58580
58561
  const status = entryStatus;
58581
58562
  return [...STRUCTURE_SELECTED_STATUSES, ALTERNATE].includes(status);
58582
- }).map(({ participantId }) => participantId) || [];
58563
+ }).map(({ participantId }) => participantId) ?? [];
58583
58564
  const enteredParticipants = enteredParticipantIds ? getParticipants$1({
58584
58565
  participantFilters: { participantIds: enteredParticipantIds },
58585
58566
  withIndividualParticipants: true,
58586
58567
  tournamentRecord
58587
- }).participants || [] : [];
58568
+ }).participants ?? [] : [];
58588
58569
  const genderAccumulator = [];
58589
58570
  const enteredParticipantTypes = enteredParticipants.reduce(
58590
58571
  (types, participant) => {
@@ -58595,7 +58576,7 @@ function modifyEvent({
58595
58576
  []
58596
58577
  );
58597
58578
  const enteredParticipantGenders = unique(genderAccumulator);
58598
- const validGender = !enteredParticipantGenders.length || [MIXED, ANY].includes(eventUpdates.gender || "") || enteredParticipantGenders.length === 1 && enteredParticipantGenders[0] === eventUpdates.gender;
58579
+ const validGender = !enteredParticipantGenders.length || [MIXED, ANY].includes(eventUpdates.gender ?? "") || enteredParticipantGenders.length === 1 && enteredParticipantGenders[0] === eventUpdates.gender;
58599
58580
  if (eventUpdates.gender && !validGender)
58600
58581
  return decorateResult({
58601
58582
  context: { gender: eventUpdates.gender },
@@ -58606,14 +58587,14 @@ function modifyEvent({
58606
58587
  SINGLES,
58607
58588
  TEAM$1
58608
58589
  ];
58609
- const validEventType = validEventTypes.includes(eventUpdates.eventType || "");
58590
+ const validEventType = validEventTypes.includes(eventUpdates.eventType ?? "");
58610
58591
  if (eventUpdates.eventType && !validEventType)
58611
58592
  return decorateResult({
58612
58593
  context: { participantType: eventUpdates.eventType },
58613
58594
  result: { error: INVALID_VALUES }
58614
58595
  });
58615
58596
  if (eventUpdates.eventType)
58616
- event.eventType === eventUpdates.eventType;
58597
+ event.eventType = eventUpdates.eventType;
58617
58598
  if (eventUpdates.eventName)
58618
58599
  event.eventName = eventUpdates.eventName;
58619
58600
  if (eventUpdates.gender)