tods-competition-factory 1.8.1 → 1.8.2

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.
@@ -362,7 +362,7 @@ var matchUpFormatCode = {
362
362
  };
363
363
 
364
364
  function factoryVersion() {
365
- return '1.8.1';
365
+ return '1.8.2';
366
366
  }
367
367
 
368
368
  /******************************************************************************
@@ -16773,6 +16773,137 @@ var fixtures = {
16773
16773
  flagIOC: flagIOC,
16774
16774
  };
16775
16775
 
16776
+ var logColors = {
16777
+ reset: '\x1b[0m',
16778
+ bright: '\x1b[1m',
16779
+ dim: '\x1b[2m',
16780
+ red: '\x1b[31m',
16781
+ brightred: '\x1b[91m',
16782
+ green: '\x1b[32m',
16783
+ brightgreen: '\x1b[92m',
16784
+ yellow: '\x1b[33m',
16785
+ brightyellow: '\x1b[93m',
16786
+ blue: '\x1b[34m',
16787
+ brightblue: '\x1b[94m',
16788
+ lightblue: '\x1b[105m',
16789
+ magenta: '\x1b[35m',
16790
+ brightmagenta: '\x1b[95m',
16791
+ cyan: '\x1b[36m',
16792
+ brightcyan: '\x1b[96m',
16793
+ white: '\x1b[37m',
16794
+ brightwhite: '\x1b[97m',
16795
+ };
16796
+
16797
+ var globalLog = [];
16798
+ function pushGlobalLog(value, devContextOverride) {
16799
+ if (typeof value === 'string')
16800
+ value = { method: value };
16801
+ if (devContextOverride || getDevContext())
16802
+ globalLog.push(value);
16803
+ }
16804
+ function getGlobalLog(purge) {
16805
+ var globalLogCopy = globalLog.slice();
16806
+ if (purge) {
16807
+ globalLog.length = 0;
16808
+ }
16809
+ return globalLogCopy;
16810
+ }
16811
+ function printGlobalLog(purge) {
16812
+ var globalLogCopy = getGlobalLog(purge);
16813
+ var modifiedText = globalLogCopy.map(function (line) {
16814
+ var color = line.color, keyColors = line.keyColors, method = line.method, newline = line.newline;
16815
+ var methodColor = Object.keys(logColors).includes(color)
16816
+ ? logColors[color]
16817
+ : logColors.cyan;
16818
+ var bodyKeys = Object.keys(line).filter(function (key) { return !['color', 'keyColors', 'method', 'newline'].includes(key); });
16819
+ var body = bodyKeys
16820
+ .map(function (key) {
16821
+ var keyColor = keyColors &&
16822
+ Object.keys(keyColors).includes(key) &&
16823
+ logColors[keyColors[key]]
16824
+ ? logColors[keyColors[key]]
16825
+ : logColors.brightwhite;
16826
+ return "".concat(logColors.white).concat(key, ": ").concat(keyColor).concat(line[key]);
16827
+ })
16828
+ .join(', ');
16829
+ var tabs = (method === null || method === void 0 ? void 0 : method.length) < 15 ? "\t\t" : '\t';
16830
+ return [
16831
+ newline ? '\n' : '',
16832
+ methodColor,
16833
+ method,
16834
+ tabs,
16835
+ logColors.white,
16836
+ body,
16837
+ logColors.reset,
16838
+ '\n',
16839
+ ].join('');
16840
+ });
16841
+ if (modifiedText === null || modifiedText === void 0 ? void 0 : modifiedText.length)
16842
+ console.log.apply(console, __spreadArray([], __read(modifiedText), false));
16843
+ }
16844
+ function purgeGlobalLog() {
16845
+ globalLog.length = 0;
16846
+ }
16847
+
16848
+ function visualizeScheduledMatchUps(_a) {
16849
+ var scheduledMatchUps = _a.scheduledMatchUps, showGlobalLog = _a.showGlobalLog;
16850
+ purgeGlobalLog();
16851
+ var structureIds = scheduledMatchUps === null || scheduledMatchUps === void 0 ? void 0 : scheduledMatchUps.reduce(function (structureIds, _a) {
16852
+ var structureId = _a.structureId;
16853
+ return structureIds.includes(structureId)
16854
+ ? structureIds
16855
+ : structureIds.concat(structureId);
16856
+ }, []);
16857
+ var structureNames = Object.assign.apply(Object, __spreadArray([{}], __read((structureIds || []).map(function (structureId) {
16858
+ var _a;
16859
+ var _b = scheduledMatchUps.find(function (matchUp) { return matchUp.structureId === structureId; }), structureName = _b.structureName, matchUpType = _b.matchUpType;
16860
+ return _a = {},
16861
+ _a[structureId] = "".concat(structureName, " ").concat(matchUpType),
16862
+ _a;
16863
+ })), false));
16864
+ structureIds === null || structureIds === void 0 ? void 0 : structureIds.forEach(function (structureId) {
16865
+ var _a;
16866
+ pushGlobalLog({
16867
+ color: 'blue',
16868
+ method: 'draw',
16869
+ structure: structureNames[structureId],
16870
+ keyColors: {
16871
+ structure: 'magenta',
16872
+ },
16873
+ }, true);
16874
+ var structureMatchUps = scheduledMatchUps.filter(function (matchUp) { return matchUp.structureId === structureId; });
16875
+ var roundMatchUps = ((_a = getRoundMatchUps$1({
16876
+ matchUps: structureMatchUps,
16877
+ })) === null || _a === void 0 ? void 0 : _a.roundMatchUps) || [];
16878
+ Object.keys(roundMatchUps).forEach(function (roundNumber) {
16879
+ pushGlobalLog({
16880
+ roundNumber: roundNumber,
16881
+ keyColors: {
16882
+ roundNumber: 'brightcyan',
16883
+ },
16884
+ }, true);
16885
+ roundMatchUps[roundNumber].forEach(function (_a) {
16886
+ var matchUpId = _a.matchUpId, schedule = _a.schedule;
16887
+ var scheduledTime = extractTime(schedule.scheduledTime);
16888
+ pushGlobalLog({
16889
+ matchUpId: matchUpId,
16890
+ time: scheduledTime,
16891
+ date: schedule.scheduledDate,
16892
+ venue: schedule.venueId,
16893
+ keyColors: {
16894
+ time: 'brightcyan',
16895
+ date: 'brightcyan',
16896
+ matchUpId: 'yellow',
16897
+ venue: 'magenta',
16898
+ },
16899
+ }, true);
16900
+ });
16901
+ });
16902
+ });
16903
+ if (showGlobalLog)
16904
+ printGlobalLog();
16905
+ }
16906
+
16776
16907
  function calculateWinCriteria(_a) {
16777
16908
  var e_1, _b, e_2, _c, e_3, _d;
16778
16909
  var _e = _a.collectionDefinitions, collectionDefinitions = _e === void 0 ? [] : _e, _f = _a.collectionGroups, collectionGroups = _f === void 0 ? [] : _f;
@@ -22808,11 +22939,6 @@ function getStructureDrawPositionProfiles(params) {
22808
22939
  };
22809
22940
  }
22810
22941
 
22811
- function pushGlobalLog(value, devContextOverride) {
22812
- if (devContextOverride || getDevContext())
22813
- ;
22814
- }
22815
-
22816
22942
  function clearDrawPosition(params) {
22817
22943
  var inContextDrawMatchUps = params.inContextDrawMatchUps, participantId = params.participantId, drawPosition = params.drawPosition;
22818
22944
  var tournamentRecord = params.tournamentRecord, drawDefinition = params.drawDefinition, structureId = params.structureId, matchUpsMap = params.matchUpsMap, event = params.event;
@@ -23100,7 +23226,11 @@ function removeDrawPosition(_a) {
23100
23226
  initialWinningSide === targetMatchUp.winningSide;
23101
23227
  if (!noChange) {
23102
23228
  if (removedDrawPosition) {
23103
- pushGlobalLog();
23229
+ pushGlobalLog({
23230
+ method: stack,
23231
+ color: 'brightyellow',
23232
+ removedDrawPosition: removedDrawPosition,
23233
+ });
23104
23234
  }
23105
23235
  modifyMatchUpNotice({
23106
23236
  tournamentId: tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.tournamentId,
@@ -23148,7 +23278,11 @@ function removeDrawPosition(_a) {
23148
23278
  }).initialRoundNumber;
23149
23279
  // if clearing a drawPosition from a feed round the initialRoundNumber for the drawPosition must be { roundNumber: 1 }
23150
23280
  if (initialRoundNumber_1 === 1) {
23151
- pushGlobalLog();
23281
+ pushGlobalLog({
23282
+ method: stack,
23283
+ color: 'brightyellow',
23284
+ loserMatchUpDrawPosition: loserMatchUpDrawPosition,
23285
+ });
23152
23286
  drawPositionRemovals({
23153
23287
  structureId: loserMatchUp.structureId,
23154
23288
  drawPosition: loserMatchUpDrawPosition,
@@ -23546,7 +23680,7 @@ function assignDrawPositionBye$1(_a) {
23546
23680
  if (!structureId)
23547
23681
  (structureId = structure.structureId);
23548
23682
  var stack = 'assignDrawPositionBye';
23549
- pushGlobalLog();
23683
+ pushGlobalLog({ method: stack, color: 'cyan', drawPosition: drawPosition });
23550
23684
  if (!matchUpsMap) {
23551
23685
  matchUpsMap = getMatchUpsMap({ drawDefinition: drawDefinition });
23552
23686
  }
@@ -23715,7 +23849,8 @@ function assignRoundRobinBYE(_a) {
23715
23849
  function advanceDrawPosition(_a) {
23716
23850
  var _b;
23717
23851
  var drawPositionToAdvance = _a.drawPositionToAdvance, inContextDrawMatchUps = _a.inContextDrawMatchUps, sourceDrawPositions = _a.sourceDrawPositions, tournamentRecord = _a.tournamentRecord, drawDefinition = _a.drawDefinition, matchUpsMap = _a.matchUpsMap, matchUpId = _a.matchUpId, event = _a.event;
23718
- pushGlobalLog();
23852
+ var stack = 'advanceDrawPosition';
23853
+ pushGlobalLog({ method: stack, color: 'cyan', drawPositionToAdvance: drawPositionToAdvance });
23719
23854
  var matchUp = matchUpsMap.drawMatchUps.find(function (matchUp) { return matchUp.matchUpId === matchUpId; });
23720
23855
  var inContextMatchUp = inContextDrawMatchUps.find(function (matchUp) { return matchUp.matchUpId === matchUpId; });
23721
23856
  var structureId = inContextMatchUp === null || inContextMatchUp === void 0 ? void 0 : inContextMatchUp.structureId;
@@ -23857,8 +23992,14 @@ function advanceWinner(_a) {
23857
23992
  winningSide: undefined,
23858
23993
  drawPositions: drawPositions,
23859
23994
  });
23860
- noContextWinnerMatchUp.drawPositions.find(function (position) { return !twoDrawPositions.includes(position); });
23861
- pushGlobalLog();
23995
+ var changedDrawPosition = noContextWinnerMatchUp.drawPositions.find(function (position) { return !twoDrawPositions.includes(position); });
23996
+ pushGlobalLog({
23997
+ method: stack,
23998
+ color: 'brightyellow',
23999
+ changedDrawPosition: changedDrawPosition,
24000
+ pairedDrawPositionIsBye: pairedDrawPositionIsBye,
24001
+ drawPositionIsBye: drawPositionIsBye,
24002
+ });
23862
24003
  modifyMatchUpNotice({
23863
24004
  tournamentId: tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.tournamentId,
23864
24005
  matchUp: noContextWinnerMatchUp,
@@ -23917,7 +24058,8 @@ function advanceWinner(_a) {
23917
24058
  function assignFedDrawPositionBye(_a) {
23918
24059
  var loserTargetDrawPosition = _a.loserTargetDrawPosition, tournamentRecord = _a.tournamentRecord, loserTargetLink = _a.loserTargetLink, drawDefinition = _a.drawDefinition, loserMatchUp = _a.loserMatchUp, matchUpsMap = _a.matchUpsMap, event = _a.event;
23919
24060
  var roundNumber = loserMatchUp.roundNumber;
23920
- pushGlobalLog();
24061
+ var stack = 'assignFedDrawPositionBye';
24062
+ pushGlobalLog({ method: stack, color: 'cyan', loserTargetDrawPosition: loserTargetDrawPosition });
23921
24063
  var mappedMatchUps = (matchUpsMap === null || matchUpsMap === void 0 ? void 0 : matchUpsMap.mappedMatchUps) || {};
23922
24064
  var loserStructureMatchUps = mappedMatchUps[loserMatchUp.structureId].matchUps;
23923
24065
  var initialRoundNumber = getInitialRoundNumber({
@@ -26935,18 +27077,35 @@ function attemptToSetWinningSide(params) {
26935
27077
  });
26936
27078
  }
26937
27079
 
27080
+ var keyColors = {
27081
+ drawPositionToRemove: 'green',
27082
+ iteration: 'brightred',
27083
+ winner: 'green',
27084
+ loser: 'brightred',
27085
+ };
26938
27086
  function removeDoubleExit(params) {
26939
27087
  var _a;
26940
27088
  var inContextDrawMatchUps = params.inContextDrawMatchUps, appliedPolicies = params.appliedPolicies, drawDefinition = params.drawDefinition, matchUpsMap = params.matchUpsMap, targetData = params.targetData, matchUp = params.matchUp;
26941
27089
  var _b = params.iteration, iteration = _b === void 0 ? 0 : _b;
26942
27090
  iteration += 1;
26943
27091
  var stack = 'removeDoubleExit';
26944
- pushGlobalLog();
27092
+ pushGlobalLog({
27093
+ method: stack,
27094
+ color: 'brightyellow',
27095
+ iteration: iteration,
27096
+ keyColors: keyColors,
27097
+ });
26945
27098
  var loserTargetLink = targetData.targetLinks.loserTargetLink, _c = targetData.targetMatchUps, loserMatchUp = _c.loserMatchUp, winnerMatchUp = _c.winnerMatchUp, loserTargetDrawPosition = _c.loserTargetDrawPosition;
26946
27099
  // only handles winnerMatchUps in the same structure
26947
27100
  if (winnerMatchUp && winnerMatchUp.matchUpStatus !== BYE) {
26948
- winnerMatchUp.stage; winnerMatchUp.roundNumber; winnerMatchUp.roundPosition;
26949
- pushGlobalLog();
27101
+ var stage = winnerMatchUp.stage, roundNumber = winnerMatchUp.roundNumber, roundPosition = winnerMatchUp.roundPosition;
27102
+ pushGlobalLog({
27103
+ winner: 'winner',
27104
+ stage: stage,
27105
+ roundNumber: roundNumber,
27106
+ roundPosition: roundPosition,
27107
+ keyColors: keyColors,
27108
+ });
26950
27109
  conditionallyRemoveDrawPosition(__assign(__assign({}, params), { targetMatchUp: winnerMatchUp, sourceMatchUp: matchUp, iteration: iteration }));
26951
27110
  }
26952
27111
  if (loserMatchUp && loserMatchUp.matchUpStatus !== BYE) {
@@ -26958,8 +27117,15 @@ function removeDoubleExit(params) {
26958
27117
  drawDefinition: drawDefinition,
26959
27118
  structureId: inContextLoserMatchUp.structureId,
26960
27119
  }).structure;
26961
- loserMatchUp.stage; loserMatchUp.roundNumber; loserMatchUp.roundPosition; loserMatchUp.feedRound;
26962
- pushGlobalLog();
27120
+ var stage = loserMatchUp.stage, roundNumber = loserMatchUp.roundNumber, roundPosition = loserMatchUp.roundPosition, feedRound = loserMatchUp.feedRound;
27121
+ pushGlobalLog({
27122
+ loser: 'loser',
27123
+ stage: stage,
27124
+ roundNumber: roundNumber,
27125
+ roundPosition: roundPosition,
27126
+ keyColors: keyColors,
27127
+ feedRound: feedRound,
27128
+ });
26963
27129
  if ((_a = appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies.progression) === null || _a === void 0 ? void 0 : _a.doubleExitPropagateBye) {
26964
27130
  removeDirectedBye({
26965
27131
  drawPosition: loserTargetDrawPosition,
@@ -26981,7 +27147,7 @@ function conditionallyRemoveDrawPosition(params) {
26981
27147
  var _a, _b, _c, _d, _e;
26982
27148
  var inContextDrawMatchUps = params.inContextDrawMatchUps, appliedPolicies = params.appliedPolicies, drawDefinition = params.drawDefinition, sourceMatchUp = params.sourceMatchUp, targetMatchUp = params.targetMatchUp, matchUpsMap = params.matchUpsMap, structure = params.structure, iteration = params.iteration;
26983
27149
  var stack = 'conditionallyRemoveDrawPosition';
26984
- pushGlobalLog();
27150
+ pushGlobalLog({ method: stack });
26985
27151
  // only handles winnerMatchUps in the same structure
26986
27152
  var nextTargetData = positionTargets({
26987
27153
  matchUpId: targetMatchUp.matchUpId,
@@ -27025,8 +27191,16 @@ function conditionallyRemoveDrawPosition(params) {
27025
27191
  }
27026
27192
  }
27027
27193
  if (nextWinnerMatchUp && drawPositionToRemove) {
27028
- nextWinnerMatchUp.stage; nextWinnerMatchUp.roundNumber; nextWinnerMatchUp.roundPosition;
27029
- pushGlobalLog();
27194
+ var stage = nextWinnerMatchUp.stage, roundNumber = nextWinnerMatchUp.roundNumber, roundPosition = nextWinnerMatchUp.roundPosition;
27195
+ pushGlobalLog({
27196
+ method: 'removeDirectedWinner',
27197
+ drawPositionToRemove: drawPositionToRemove,
27198
+ keyColors: keyColors,
27199
+ color: 'brightgreen',
27200
+ stage: stage,
27201
+ roundNumber: roundNumber,
27202
+ roundPosition: roundPosition,
27203
+ });
27030
27204
  removeDirectedWinner({
27031
27205
  winningDrawPosition: drawPositionToRemove,
27032
27206
  winnerMatchUp: nextWinnerMatchUp,
@@ -27637,7 +27811,12 @@ function setMatchUpStatus$2(params) {
27637
27811
  return swapWinnerLoser(params);
27638
27812
  }
27639
27813
  var matchUpWinner = (winningSide && !matchUpTieId) || params.projectedWinningSide;
27640
- pushGlobalLog();
27814
+ pushGlobalLog({
27815
+ method: stack,
27816
+ activeDownstream: activeDownstream,
27817
+ matchUpWinner: matchUpWinner,
27818
+ winningSide: winningSide,
27819
+ });
27641
27820
  var result = (!activeDownstream && noDownstreamDependencies(params)) ||
27642
27821
  (matchUpWinner && winningSideWithDownstreamDependencies(params)) ||
27643
27822
  (directingMatchUpStatus && applyMatchUpValues(params)) || {
@@ -35724,7 +35903,8 @@ function getGroupedRounds(_a) {
35724
35903
  }
35725
35904
 
35726
35905
  function getMatchUpsToSchedule(_a) {
35727
- var matchUpPotentialParticipantIds = _a.matchUpPotentialParticipantIds, scheduleCompletedMatchUps = _a.scheduleCompletedMatchUps, dateScheduledMatchUpIds = _a.dateScheduledMatchUpIds, matchUpNotBeforeTimes = _a.matchUpNotBeforeTimes, orderedMatchUpIds = _a.orderedMatchUpIds, clearDate = _a.clearDate, matchUps = _a.matchUps;
35906
+ var matchUpPotentialParticipantIds = _a.matchUpPotentialParticipantIds, scheduleCompletedMatchUps = _a.scheduleCompletedMatchUps, dateScheduledMatchUpIds = _a.dateScheduledMatchUpIds, matchUpNotBeforeTimes = _a.matchUpNotBeforeTimes, matchUpScheduleTimes = _a.matchUpScheduleTimes, orderedMatchUpIds = _a.orderedMatchUpIds, clearDate = _a.clearDate, matchUps = _a.matchUps;
35907
+ var alreadyScheduledMatchUpIds = Object.keys(matchUpScheduleTimes);
35728
35908
  // this must be done to preserve the order of matchUpIds
35729
35909
  var matchUpsToSchedule = orderedMatchUpIds
35730
35910
  .map(function (matchUpId) {
@@ -35732,7 +35912,9 @@ function getMatchUpsToSchedule(_a) {
35732
35912
  })
35733
35913
  .filter(Boolean)
35734
35914
  .filter(function (matchUp) {
35735
- var alreadyScheduled = !clearDate && dateScheduledMatchUpIds.includes(matchUp.matchUpId);
35915
+ var alreadyScheduled = !clearDate &&
35916
+ (dateScheduledMatchUpIds.includes(matchUp.matchUpId) ||
35917
+ alreadyScheduledMatchUpIds.includes(matchUp.matchUpId));
35736
35918
  var doNotSchedule = [
35737
35919
  BYE,
35738
35920
  DEFAULTED,
@@ -35955,6 +36137,7 @@ function getVenueSchedulingDetails(_a) {
35955
36137
  scheduleCompletedMatchUps: scheduleCompletedMatchUps,
35956
36138
  dateScheduledMatchUpIds: dateScheduledMatchUpIds,
35957
36139
  matchUpNotBeforeTimes: matchUpNotBeforeTimes,
36140
+ matchUpScheduleTimes: matchUpScheduleTimes,
35958
36141
  orderedMatchUpIds: orderedMatchUpIds,
35959
36142
  clearDate: clearDate,
35960
36143
  matchUps: matchUps,
@@ -69457,6 +69640,7 @@ var utilities = {
69457
69640
  UUID: UUID,
69458
69641
  UUIDS: UUIDS,
69459
69642
  validateTieFormat: validateTieFormat,
69643
+ visualizeScheduledMatchUps: visualizeScheduledMatchUps,
69460
69644
  };
69461
69645
  // END
69462
69646