tods-competition-factory 0.201.0 → 0.201.1

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.
@@ -249,7 +249,7 @@ const matchUpFormatCode = {
249
249
  };
250
250
 
251
251
  function factoryVersion() {
252
- return '0.201.0';
252
+ return '0.201.1';
253
253
  }
254
254
 
255
255
  function decorateResult({
@@ -303,7 +303,7 @@ function isConvertableInteger(n) {
303
303
  return Number.isSafeInteger(typeof n === 'string' ? +n : n);
304
304
  } // produces an approximated normal distribution between 0 and max
305
305
 
306
- function weightedRandom(max = 1, weight = 3, round = true) {
306
+ function weightedRandom(max = 1, weight, round = true) {
307
307
  let num = 0;
308
308
 
309
309
  for (let i = 0; i < weight; i++) {
@@ -4027,7 +4027,7 @@ function getHighTiebreakValue({
4027
4027
  lowValue = 0,
4028
4028
  NoAD = false,
4029
4029
  tiebreakTo
4030
- } = {}) {
4030
+ }) {
4031
4031
  const winBy = NoAD ? 1 : 2;
4032
4032
 
4033
4033
  if (lowValue + 1 >= tiebreakTo) {
@@ -5562,7 +5562,7 @@ function findCategoryTiming({
5562
5562
  function findMatchupFormatAverageTimes({
5563
5563
  matchUpAverageTimes,
5564
5564
  matchUpFormat
5565
- } = {}) {
5565
+ }) {
5566
5566
  // first find all matchUpAverageTime definitions which include matchUpFormats...
5567
5567
  // ... that either exactly match or start with the target matchUpFormat.
5568
5568
  const codeMatches = (matchUpAverageTimes === null || matchUpAverageTimes === void 0 ? void 0 : matchUpAverageTimes.map(({
@@ -5586,7 +5586,7 @@ function findMatchupFormatRecoveryTimes({
5586
5586
  matchUpRecoveryTimes,
5587
5587
  averageMinutes,
5588
5588
  matchUpFormat
5589
- } = {}) {
5589
+ }) {
5590
5590
  var _matchUpRecoveryTimes;
5591
5591
 
5592
5592
  return matchUpRecoveryTimes === null || matchUpRecoveryTimes === void 0 ? void 0 : (_matchUpRecoveryTimes = matchUpRecoveryTimes.find(({
@@ -7102,7 +7102,7 @@ function getRoundMatchUps$1({
7102
7102
 
7103
7103
  function getMatchUpType({
7104
7104
  matchUp = {}
7105
- } = {}) {
7105
+ }) {
7106
7106
  var _matchUp$sides;
7107
7107
 
7108
7108
  let matchUpType = matchUp.matchUpType;
@@ -7465,7 +7465,7 @@ function isValidExtension(extension) {
7465
7465
  function addExtension$1({
7466
7466
  element,
7467
7467
  extension
7468
- } = {}) {
7468
+ }) {
7469
7469
  if (!element) return {
7470
7470
  error: MISSING_VALUE
7471
7471
  };
@@ -7496,7 +7496,7 @@ function addExtension$1({
7496
7496
  function removeExtension$1({
7497
7497
  element,
7498
7498
  name
7499
- } = {}) {
7499
+ }) {
7500
7500
  if (!element) return {
7501
7501
  error: MISSING_VALUE
7502
7502
  };
@@ -9379,7 +9379,9 @@ function getAllStructureMatchUps({
9379
9379
  });
9380
9380
  }
9381
9381
 
9382
- if (contextProfile !== null && contextProfile !== void 0 && contextProfile.inferGender && !matchUpWithContext.gender && ((_matchUpWithContext$s = matchUpWithContext.sides) === null || _matchUpWithContext$s === void 0 ? void 0 : _matchUpWithContext$s.length) === 2 && matchUpWithContext.matchUpType !== TEAM$2) {
9382
+ const inferGender = (contextProfile === null || contextProfile === void 0 ? void 0 : contextProfile.inferGender) && !matchUpWithContext.gender && ((_matchUpWithContext$s = matchUpWithContext.sides) === null || _matchUpWithContext$s === void 0 ? void 0 : _matchUpWithContext$s.length) === 2 && matchUpWithContext.matchUpType !== TEAM$2; // if (contextProfile) console.log({ contextProfile, inferGender });
9383
+
9384
+ if (inferGender) {
9383
9385
  const sideGenders = matchUpWithContext.sides.map(side => {
9384
9386
  var _side$participant2, _side$participant2$pe, _side$individualParti;
9385
9387
 
@@ -12343,7 +12345,7 @@ function getNextToBePlayedMatchUp({
12343
12345
 
12344
12346
  function getUpcomingInfo({
12345
12347
  upcomingMatchUp
12346
- } = {}) {
12348
+ }) {
12347
12349
  if (!upcomingMatchUp) return;
12348
12350
  return (({
12349
12351
  matchUpId,
@@ -12478,12 +12480,17 @@ function getStructureMatchUps({
12478
12480
  */
12479
12481
 
12480
12482
  function getAllDrawMatchUps(params) {
12481
- if (!params.drawDefinition) return {
12482
- error: MISSING_DRAW_DEFINITION
12483
- };
12483
+ const stack = 'getAllDrawMatchUps';
12484
12484
  Object.assign(params, {
12485
12485
  requireParticipants: false
12486
12486
  });
12487
+ const result = getDrawMatchUps({ ...params,
12488
+ contextProfile: params.contextProfile
12489
+ });
12490
+ if (result.error) return decorateResult({
12491
+ result,
12492
+ stack
12493
+ });
12487
12494
  const {
12488
12495
  abandonedMatchUps,
12489
12496
  completedMatchUps,
@@ -12491,7 +12498,7 @@ function getAllDrawMatchUps(params) {
12491
12498
  pendingMatchUps,
12492
12499
  byeMatchUps,
12493
12500
  matchUpsMap
12494
- } = getDrawMatchUps(params);
12501
+ } = result;
12495
12502
  const matchUps = [].concat(...abandonedMatchUps, ...completedMatchUps, ...upcomingMatchUps, ...pendingMatchUps, ...byeMatchUps);
12496
12503
  return {
12497
12504
  matchUps,
@@ -15406,7 +15413,7 @@ function getMatchUpFormatMap({
15406
15413
  }
15407
15414
  const baseAttributeKeys = ['collectionId', 'collectionPosition', 'drawPositions', 'extensions', 'finishingPositionRange', 'finishingRound', 'isMock', 'matchUpId', 'matchUpStatus', 'matchUpStatusCodes', 'orderOfFinish', 'processCodes', 'roundNumber', 'tieFormat', 'tieMatchUps', 'roundPosition', 'score', 'sides', // can be removed only if drawPositions is present and is not a TEAM matchUp
15408
15415
  'winnerMatchUpId', 'loserMatchUpId', 'matchUpDuration', 'winningSide'];
15409
- function removeExtraneousAttributes(matchUps, matchUpFormatMap = {}) {
15416
+ function removeExtraneousAttributes(matchUps, matchUpFormatMap) {
15410
15417
  for (const matchUp of matchUps) {
15411
15418
  const {
15412
15419
  structureId,
@@ -17707,7 +17714,7 @@ function tournamentRelevantSchedulingIds({
17707
17714
  tournamentRecord = {},
17708
17715
  tournamentMap = {},
17709
17716
  requireCourts
17710
- } = {}) {
17717
+ }) {
17711
17718
  const drawIds = [];
17712
17719
  const eventIds = [];
17713
17720
  const structureIds = [];
@@ -17775,7 +17782,7 @@ function tournamentRelevantSchedulingIds({
17775
17782
  }
17776
17783
  function getAllRelevantSchedulingIds({
17777
17784
  tournamentRecords = {}
17778
- } = {}) {
17785
+ }) {
17779
17786
  const records = tournamentRecords && Object.values(tournamentRecords) || [];
17780
17787
  const tournamentsMap = {};
17781
17788
  const {
@@ -23552,7 +23559,7 @@ function noDownstreamDependencies(params) {
23552
23559
 
23553
23560
  const removeDirected = ({
23554
23561
  removeScore
23555
- } = {}) => {
23562
+ }) => {
23556
23563
  let connectedStructures;
23557
23564
  const {
23558
23565
  structure,
@@ -23652,6 +23659,11 @@ function isActiveDownstream(params) {
23652
23659
  },
23653
23660
  targetLinks
23654
23661
  } = targetData;
23662
+ if (getDevContext({
23663
+ qualifying: true
23664
+ })) console.log({
23665
+ targetData
23666
+ });
23655
23667
  const loserMatchUpWalkover = [WALKOVER$2].includes(loserMatchUp === null || loserMatchUp === void 0 ? void 0 : loserMatchUp.matchUpStatus);
23656
23668
  const winnerDrawPositionsCount = (winnerMatchUp === null || winnerMatchUp === void 0 ? void 0 : (_winnerMatchUp$drawPo = winnerMatchUp.drawPositions) === null || _winnerMatchUp$drawPo === void 0 ? void 0 : _winnerMatchUp$drawPo.filter(Boolean).length) || 0;
23657
23669
 
@@ -24044,9 +24056,16 @@ function winningSideWithDownstreamDependencies(params) {
24044
24056
  if (winningSide === matchUp.winningSide || matchUpTieId && !dualWinningSideChange) {
24045
24057
  return applyMatchUpValues(params);
24046
24058
  } else {
24047
- return {
24048
- error: CANNOT_CHANGE_WINNING_SIDE
24049
- };
24059
+ return decorateResult({
24060
+ result: {
24061
+ error: CANNOT_CHANGE_WINNING_SIDE
24062
+ },
24063
+ stack: 'winningSideWithDownstreamDependencies',
24064
+ context: {
24065
+ winningSide,
24066
+ matchUp
24067
+ }
24068
+ });
24050
24069
  }
24051
24070
  }
24052
24071
 
@@ -24625,7 +24644,7 @@ function deletionMessage({
24625
24644
  function validTimePeriod({
24626
24645
  startTime,
24627
24646
  endTime
24628
- } = {}) {
24647
+ }) {
24629
24648
  if (!timeValidation.test(startTime) || !timeValidation.test(endTime)) return false;
24630
24649
  const [startHour, startMinute] = startTime.split(':');
24631
24650
  const [endHour, endMinute] = endTime.split(':');
@@ -40459,7 +40478,7 @@ function getAssignedParticipantIds({
40459
40478
 
40460
40479
  function refreshEntryPositions({
40461
40480
  entries = []
40462
- } = {}) {
40481
+ }) {
40463
40482
  const stagedEntries = entries.filter(Boolean).reduce((stages, entry) => {
40464
40483
  const {
40465
40484
  entryStage,
@@ -45021,7 +45040,7 @@ function newDrawDefinition({
45021
45040
  drawId = UUID(),
45022
45041
  matchUpType,
45023
45042
  drawType
45024
- } = {}) {
45043
+ }) {
45025
45044
  const drawDefinition = definitionTemplate();
45026
45045
  return Object.assign(drawDefinition, {
45027
45046
  drawId,
@@ -45343,7 +45362,7 @@ function getState$1({
45343
45362
  convertExtensions,
45344
45363
  removeExtensions,
45345
45364
  tournamentId
45346
- } = {}) {
45365
+ }) {
45347
45366
  if (typeof tournamentId !== 'string') return {};
45348
45367
  const tournamentRecord = getTournamentRecord(tournamentId);
45349
45368
  return {
@@ -46206,7 +46225,7 @@ function getState({
46206
46225
  convertExtensions,
46207
46226
  removeExtensions,
46208
46227
  tournamentId
46209
- } = {}) {
46228
+ }) {
46210
46229
  if (typeof tournamentId !== 'string') return {};
46211
46230
  const tournamentRecord = getTournamentRecord(tournamentId);
46212
46231
  return {
@@ -56801,7 +56820,7 @@ function generatePersons({
56801
56820
  count = 1,
56802
56821
  category,
56803
56822
  sex
56804
- } = {}) {
56823
+ }) {
56805
56824
  if (isNaN(count)) return {
56806
56825
  error: INVALID_VALUES
56807
56826
  };
@@ -56982,7 +57001,7 @@ var namesData = [
56982
57001
  function nameMocks({
56983
57002
  nameRoot = 'TEAM',
56984
57003
  count = 1
56985
- } = {}) {
57004
+ }) {
56986
57005
  const shuffledTeamNames = shuffleArray(namesData);
56987
57006
  const names = shuffledTeamNames.slice(0, count);
56988
57007
 
@@ -57356,7 +57375,7 @@ var citiesData = [
57356
57375
  function cityMocks({
57357
57376
  count = 1,
57358
57377
  participantsCount = 32
57359
- } = {}) {
57378
+ }) {
57360
57379
  const shuffledCities = shuffleArray(citiesData);
57361
57380
  const candidateCities = shuffledCities.slice(0, count); // the following ensures that all of the generated items are used at least once
57362
57381
 
@@ -57368,7 +57387,7 @@ function cityMocks({
57368
57387
  function stateMocks({
57369
57388
  count = 1,
57370
57389
  participantsCount = 32
57371
- } = {}) {
57390
+ }) {
57372
57391
  const shuffledStates = shuffleArray(statesData);
57373
57392
  const candidateStates = shuffledStates.slice(0, count).map(state => Object.keys(state)).flat(); // the following ensures that all of the generated items are used at least once
57374
57393
 
@@ -57380,7 +57399,7 @@ function stateMocks({
57380
57399
  function postalCodeMocks({
57381
57400
  count = 1,
57382
57401
  participantsCount = 32
57383
- } = {}) {
57402
+ }) {
57384
57403
  const candidatePostalCodes = generateRange(0, count).map(() => generateRange(0, 5).map(() => randomInt(0, 9)).join('')); // the following ensures that all of the generated items are used at least once
57385
57404
 
57386
57405
  const postalCodes = generateRange(0, participantsCount).map(i => i < count ? candidatePostalCodes[i] : randomMember(candidatePostalCodes));