tods-competition-factory 1.6.28 → 1.6.30

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.6.28';
365
+ return '1.6.30';
366
366
  }
367
367
 
368
368
  /******************************************************************************
@@ -1710,6 +1710,7 @@ var syncGlobalState$1 = {
1710
1710
  setTournamentId: setTournamentId$1,
1711
1711
  setTournamentRecord: setTournamentRecord$2,
1712
1712
  setTournamentRecords: setTournamentRecords$1,
1713
+ handleCaughtError: handleCaughtError$1,
1713
1714
  };
1714
1715
  function disableNotifications$1() {
1715
1716
  syncGlobalState.disableNotifications = true;
@@ -1823,6 +1824,23 @@ function callListener$1(_a) {
1823
1824
  method(notices);
1824
1825
  }
1825
1826
  }
1827
+ function handleCaughtError$1(_a) {
1828
+ var engineName = _a.engineName, methodName = _a.methodName, params = _a.params, err = _a.err;
1829
+ var error;
1830
+ if (typeof err === 'string') {
1831
+ error = err.toUpperCase();
1832
+ }
1833
+ else if (err instanceof Error) {
1834
+ error = err.message;
1835
+ }
1836
+ console.log('ERROR', {
1837
+ tournamentId: getTournamentId$1(),
1838
+ params: JSON.stringify(params),
1839
+ engine: engineName,
1840
+ methodName: methodName,
1841
+ error: error,
1842
+ });
1843
+ }
1826
1844
 
1827
1845
  var globalState = {
1828
1846
  tournamentFactoryVersion: '0.0.0',
@@ -1842,6 +1860,8 @@ var requiredStateProviderMethods = [
1842
1860
  'cycleMutationStatus',
1843
1861
  'deleteNotice',
1844
1862
  'deleteNotices',
1863
+ 'disableNotifications',
1864
+ 'enableNotifications',
1845
1865
  'getNotices',
1846
1866
  'getTopics',
1847
1867
  'getTournamentId',
@@ -1943,8 +1963,8 @@ function cycleMutationStatus() {
1943
1963
  function addNotice(notice) {
1944
1964
  return _globalStateProvider.addNotice(notice);
1945
1965
  }
1946
- function getNotices(topic) {
1947
- return _globalStateProvider.getNotices(topic);
1966
+ function getNotices(params) {
1967
+ return _globalStateProvider.getNotices(params);
1948
1968
  }
1949
1969
  function deleteNotice(_a) {
1950
1970
  var key = _a.key, topic = _a.topic;
@@ -1984,6 +2004,18 @@ function setTournamentId(tournamentId) {
1984
2004
  function removeTournamentRecord(tournamentId) {
1985
2005
  return _globalStateProvider.removeTournamentRecord(tournamentId);
1986
2006
  }
2007
+ function handleCaughtError(_a) {
2008
+ var engineName = _a.engineName, methodName = _a.methodName, params = _a.params, err = _a.err;
2009
+ var caughtErrorHandler = (typeof _globalStateProvider.handleCaughtError === 'function' &&
2010
+ _globalStateProvider.handleCaughtError) ||
2011
+ syncGlobalState$1.handleCaughtError;
2012
+ return caughtErrorHandler({
2013
+ engineName: engineName,
2014
+ methodName: methodName,
2015
+ params: params,
2016
+ err: err,
2017
+ });
2018
+ }
1987
2019
 
1988
2020
  function isObject(obj) {
1989
2021
  return typeof obj === 'object';
@@ -41625,19 +41657,11 @@ var competitionEngine = (function () {
41625
41657
  return engineInvoke(governor[methodName], params, methodName);
41626
41658
  }
41627
41659
  catch (err) {
41628
- var activeTournamentId = getTournamentId();
41629
- var error = void 0;
41630
- if (typeof err === 'string') {
41631
- error = err.toUpperCase();
41632
- }
41633
- else if (err instanceof Error) {
41634
- error = err.message;
41635
- }
41636
- console.log('ERROR', {
41637
- params: JSON.stringify(params),
41638
- activeTournamentId: activeTournamentId,
41660
+ handleCaughtError({
41661
+ engineName: 'competitionEngine',
41639
41662
  methodName: methodName,
41640
- error: error,
41663
+ params: params,
41664
+ err: err,
41641
41665
  });
41642
41666
  }
41643
41667
  }
@@ -41826,35 +41850,27 @@ function competitionEngineAsync(test) {
41826
41850
  _loop_1 = function (governor) {
41827
41851
  var e_2, _c;
41828
41852
  var govKeys = Object.keys(governor);
41829
- var _loop_2 = function (method) {
41830
- engine[method] = function (params) {
41853
+ var _loop_2 = function (methodName) {
41854
+ engine[methodName] = function (params) {
41831
41855
  return __awaiter(this, void 0, void 0, function () {
41832
- var err_1, activeTournamentId, error;
41856
+ var err_1;
41833
41857
  return __generator(this, function (_a) {
41834
41858
  switch (_a.label) {
41835
41859
  case 0:
41836
41860
  if (!getDevContext()) return [3 /*break*/, 2];
41837
- return [4 /*yield*/, engineInvoke(governor[method], params)];
41861
+ return [4 /*yield*/, engineInvoke(governor[methodName], params)];
41838
41862
  case 1: return [2 /*return*/, _a.sent()];
41839
41863
  case 2:
41840
41864
  _a.trys.push([2, 4, , 5]);
41841
- return [4 /*yield*/, engineInvoke(governor[method], params)];
41865
+ return [4 /*yield*/, engineInvoke(governor[methodName], params)];
41842
41866
  case 3: return [2 /*return*/, _a.sent()];
41843
41867
  case 4:
41844
41868
  err_1 = _a.sent();
41845
- activeTournamentId = getTournamentId();
41846
- error = void 0;
41847
- if (typeof err_1 === 'string') {
41848
- error = err_1.toUpperCase();
41849
- }
41850
- else if (err_1 instanceof Error) {
41851
- error = err_1.message;
41852
- }
41853
- console.log('ERROR', {
41854
- params: JSON.stringify(params),
41855
- activeTournamentId: activeTournamentId,
41856
- method: method,
41857
- error: error,
41869
+ handleCaughtError({
41870
+ engineName: 'competitionEngine',
41871
+ methodName: methodName,
41872
+ params: params,
41873
+ err: err_1,
41858
41874
  });
41859
41875
  return [3 /*break*/, 5];
41860
41876
  case 5: return [2 /*return*/];
@@ -41865,8 +41881,8 @@ function competitionEngineAsync(test) {
41865
41881
  };
41866
41882
  try {
41867
41883
  for (var govKeys_1 = (e_2 = void 0, __values(govKeys)), govKeys_1_1 = govKeys_1.next(); !govKeys_1_1.done; govKeys_1_1 = govKeys_1.next()) {
41868
- var method = govKeys_1_1.value;
41869
- _loop_2(method);
41884
+ var methodName = govKeys_1_1.value;
41885
+ _loop_2(methodName);
41870
41886
  }
41871
41887
  }
41872
41888
  catch (e_2_1) { e_2 = { error: e_2_1 }; }
@@ -43348,9 +43364,11 @@ function processPlayoffGroups(_a) {
43348
43364
  finishingPositions
43349
43365
  .map(function (p) { var _a; return (_a = positionRangeMap[p]) === null || _a === void 0 ? void 0 : _a.finishingPositions; })
43350
43366
  .flat();
43351
- var playoffDrawType = playoffGroup.drawType || SINGLE_ELIMINATION;
43352
43367
  var participantsInDraw = groupCount * finishingPositions.length;
43353
43368
  var drawSize = nextPowerOf2(participantsInDraw);
43369
+ var playoffDrawType = (drawSize === 2 && SINGLE_ELIMINATION) ||
43370
+ playoffGroup.drawType ||
43371
+ SINGLE_ELIMINATION;
43354
43372
  if (positionsPlayedOff) {
43355
43373
  finishingPositionOffset = Math.min.apply(Math, __spreadArray([], __read(positionsPlayedOff), false)) - 1;
43356
43374
  }
@@ -43933,15 +43951,19 @@ function getGenerators(params) {
43933
43951
 
43934
43952
  function generateDrawStructuresAndLinks$1(params) {
43935
43953
  var e_1, _a, e_2, _b;
43936
- var _c, _d, _e, _f, _g, _h, _j;
43937
- var _k = params || {}, _l = _k.enforceMinimumDrawSize, enforceMinimumDrawSize = _l === void 0 ? true : _l, overwriteExisting = _k.overwriteExisting, drawTypeCoercion = _k.drawTypeCoercion, // coerce to SINGLE_ELIMINATION for drawSize: 2
43938
- appliedPolicies = _k.appliedPolicies, staggeredEntry = _k.staggeredEntry, // optional - specifies main structure FEED_IN for drawTypes CURTIS_CONSOLATION, FEED_IN_CHAMPIONSHIPS, FMLC
43939
- drawDefinition = _k.drawDefinition, tieFormat = _k.tieFormat, drawSize = _k.drawSize, isMock = _k.isMock, uuids = _k.uuids;
43954
+ var _c, _d, _e, _f, _g, _h, _j, _k, _l;
43955
+ var _m = params || {}, _o = _m.enforceMinimumDrawSize, enforceMinimumDrawSize = _o === void 0 ? true : _o, overwriteExisting = _m.overwriteExisting, appliedPolicies = _m.appliedPolicies, staggeredEntry = _m.staggeredEntry, // optional - specifies main structure FEED_IN for drawTypes CURTIS_CONSOLATION, FEED_IN_CHAMPIONSHIPS, FMLC
43956
+ drawDefinition = _m.drawDefinition, tieFormat = _m.tieFormat, drawSize = _m.drawSize, isMock = _m.isMock, uuids = _m.uuids;
43957
+ var drawTypeCoercion = (_e = (_c = params.drawTypeCoercion) !== null && _c !== void 0 ? _c : (_d = appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[POLICY_TYPE_DRAWS]) === null || _d === void 0 ? void 0 : _d.drawTypeCoercion) !== null && _e !== void 0 ? _e : true;
43940
43958
  var stack = 'generateDrawStructuresAndLinks';
43941
- var drawType = (_c = params.drawType) !== null && _c !== void 0 ? _c : SINGLE_ELIMINATION;
43959
+ var drawType = (drawTypeCoercion &&
43960
+ params.drawSize === 2 &&
43961
+ DrawTypeEnum.SingleElimination) ||
43962
+ params.drawType ||
43963
+ DrawTypeEnum.SingleElimination;
43942
43964
  var structures = [], links = [];
43943
- var matchUpType = (_d = params === null || params === void 0 ? void 0 : params.matchUpType) !== null && _d !== void 0 ? _d : SINGLES$1;
43944
- var existingQualifyingStructures = (_e = drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.structures) === null || _e === void 0 ? void 0 : _e.filter(function (_a) {
43965
+ var matchUpType = (_f = params === null || params === void 0 ? void 0 : params.matchUpType) !== null && _f !== void 0 ? _f : SINGLES$1;
43966
+ var existingQualifyingStructures = (_g = drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.structures) === null || _g === void 0 ? void 0 : _g.filter(function (_a) {
43945
43967
  var stage = _a.stage;
43946
43968
  return stage === QUALIFYING;
43947
43969
  });
@@ -43952,11 +43974,11 @@ function generateDrawStructuresAndLinks$1(params) {
43952
43974
  var structureId = _a.structureId;
43953
43975
  return structureId;
43954
43976
  });
43955
- var existingMainStructure = (_f = drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.structures) === null || _f === void 0 ? void 0 : _f.find(function (_a) {
43977
+ var existingMainStructure = (_h = drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.structures) === null || _h === void 0 ? void 0 : _h.find(function (_a) {
43956
43978
  var stage = _a.stage, stageSequence = _a.stageSequence;
43957
43979
  return stage === MAIN && stageSequence === 1;
43958
43980
  });
43959
- var existingQualifyingLinks = (_g = drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.links) === null || _g === void 0 ? void 0 : _g.filter(function (link) {
43981
+ var existingQualifyingLinks = (_j = drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.links) === null || _j === void 0 ? void 0 : _j.filter(function (link) {
43960
43982
  return link.target.structureId === (existingMainStructure === null || existingMainStructure === void 0 ? void 0 : existingMainStructure.structureId) &&
43961
43983
  (existingQualifyingStructureIds === null || existingQualifyingStructureIds === void 0 ? void 0 : existingQualifyingStructureIds.includes(link.source.structureId));
43962
43984
  });
@@ -43991,7 +44013,7 @@ function generateDrawStructuresAndLinks$1(params) {
43991
44013
  var structure = existingQualifyingStructures === null || existingQualifyingStructures === void 0 ? void 0 : existingQualifyingStructures.find(function (structure) { return structure.structureId === qualifyingStructureId; });
43992
44014
  return getQualifiersCount(link, structure);
43993
44015
  }).filter(Boolean).reduce(function (a, b) { return a + b; }, 0);
43994
- var mainStructureIsPlaceholder = !!(existingMainStructure && !((_h = existingMainStructure === null || existingMainStructure === void 0 ? void 0 : existingMainStructure.matchUps) === null || _h === void 0 ? void 0 : _h.length));
44016
+ var mainStructureIsPlaceholder = !!(existingMainStructure && !((_k = existingMainStructure === null || existingMainStructure === void 0 ? void 0 : existingMainStructure.matchUps) === null || _k === void 0 ? void 0 : _k.length));
43995
44017
  if ((existingQualifyingStructures === null || existingQualifyingStructures === void 0 ? void 0 : existingQualifyingStructures.length) && !mainStructureIsPlaceholder) {
43996
44018
  return { error: EXISTING_STAGE };
43997
44019
  }
@@ -44008,10 +44030,10 @@ function generateDrawStructuresAndLinks$1(params) {
44008
44030
  if (qualifyingResult === null || qualifyingResult === void 0 ? void 0 : qualifyingResult.error) {
44009
44031
  return qualifyingResult;
44010
44032
  }
44011
- var _m = qualifyingResult || {
44033
+ var _p = qualifyingResult || {
44012
44034
  qualifyingDrawPositionsCount: existingQualifyingDrawPositionsCount,
44013
44035
  qualifiersCount: existingQualifiersCount,
44014
- }, qualifyingDrawPositionsCount = _m.qualifyingDrawPositionsCount, qualifyingDetails = _m.qualifyingDetails, qualifiersCount = _m.qualifiersCount;
44036
+ }, qualifyingDrawPositionsCount = _p.qualifyingDrawPositionsCount, qualifyingDetails = _p.qualifyingDetails, qualifiersCount = _p.qualifiersCount;
44015
44037
  if (qualifyingDrawPositionsCount) {
44016
44038
  if (qualifyingResult === null || qualifyingResult === void 0 ? void 0 : qualifyingResult.structures) {
44017
44039
  structures.push.apply(structures, __spreadArray([], __read(qualifyingResult.structures), false));
@@ -44056,7 +44078,7 @@ function generateDrawStructuresAndLinks$1(params) {
44056
44078
  });
44057
44079
  }
44058
44080
  }
44059
- var _o = getGenerators(params), generators = _o.generators, error = _o.error;
44081
+ var _q = getGenerators(params), generators = _q.generators, error = _q.error;
44060
44082
  if (error) {
44061
44083
  return { error: error };
44062
44084
  }
@@ -44112,18 +44134,18 @@ function generateDrawStructuresAndLinks$1(params) {
44112
44134
  return stage === MAIN && stageSequence === 1;
44113
44135
  });
44114
44136
  try {
44115
- for (var _p = __values(qualifyingDetails || []), _q = _p.next(); !_q.done; _q = _p.next()) {
44116
- var qualifyingDetail = _q.value;
44137
+ for (var _r = __values(qualifyingDetails || []), _s = _r.next(); !_s.done; _s = _r.next()) {
44138
+ var qualifyingDetail = _s.value;
44117
44139
  var qualifyingRoundNumber = qualifyingDetail.finalQualifyingRoundNumber, qualifyingStructureId = qualifyingDetail.finalQualifyingStructureId, targetEntryRound = qualifyingDetail.roundTarget, finishingPositions = qualifyingDetail.finishingPositions, linkType = qualifyingDetail.linkType;
44118
44140
  var link = mainStructure &&
44119
- ((_j = generateQualifyingLink({
44141
+ ((_l = generateQualifyingLink({
44120
44142
  targetStructureId: mainStructure.structureId,
44121
44143
  sourceStructureId: qualifyingStructureId,
44122
44144
  sourceRoundNumber: qualifyingRoundNumber,
44123
44145
  finishingPositions: finishingPositions,
44124
44146
  targetEntryRound: targetEntryRound,
44125
44147
  linkType: linkType,
44126
- })) === null || _j === void 0 ? void 0 : _j.link);
44148
+ })) === null || _l === void 0 ? void 0 : _l.link);
44127
44149
  if (link === null || link === void 0 ? void 0 : link.error)
44128
44150
  return link;
44129
44151
  if (link) {
@@ -44134,7 +44156,7 @@ function generateDrawStructuresAndLinks$1(params) {
44134
44156
  catch (e_2_1) { e_2 = { error: e_2_1 }; }
44135
44157
  finally {
44136
44158
  try {
44137
- if (_q && !_q.done && (_b = _p.return)) _b.call(_p);
44159
+ if (_s && !_s.done && (_b = _r.return)) _b.call(_r);
44138
44160
  }
44139
44161
  finally { if (e_2) throw e_2.error; }
44140
44162
  }
@@ -52762,28 +52784,21 @@ var drawEngine = (function () {
52762
52784
  return engine;
52763
52785
  function importGovernors(governors) {
52764
52786
  governors.forEach(function (governor) {
52765
- Object.keys(governor).forEach(function (governorMethod) {
52766
- engine[governorMethod] = function (params) {
52787
+ Object.keys(governor).forEach(function (methodName) {
52788
+ engine[methodName] = function (params) {
52767
52789
  if (getDevContext()) {
52768
- return invoke({ params: params, governor: governor, governorMethod: governorMethod });
52790
+ return invoke({ params: params, governor: governor, methodName: methodName });
52769
52791
  }
52770
52792
  else {
52771
52793
  try {
52772
- return invoke({ params: params, governor: governor, governorMethod: governorMethod });
52794
+ return invoke({ params: params, governor: governor, methodName: methodName });
52773
52795
  }
52774
52796
  catch (err) {
52775
- var error = void 0;
52776
- if (typeof err === 'string') {
52777
- error = err.toUpperCase();
52778
- }
52779
- else if (err instanceof Error) {
52780
- error = err.message;
52781
- }
52782
- console.log('ERROR', {
52783
- params: JSON.stringify(params),
52784
- drawId: drawDefinition$1 === null || drawDefinition$1 === void 0 ? void 0 : drawDefinition$1.drawId,
52785
- method: governorMethod,
52786
- error: error,
52797
+ handleCaughtError({
52798
+ engineName: 'drawEngine',
52799
+ methodName: methodName,
52800
+ params: params,
52801
+ err: err,
52787
52802
  });
52788
52803
  }
52789
52804
  }
@@ -52792,14 +52807,14 @@ var drawEngine = (function () {
52792
52807
  });
52793
52808
  }
52794
52809
  function invoke(_a) {
52795
- var params = _a.params, governor = _a.governor, governorMethod = _a.governorMethod;
52810
+ var params = _a.params, governor = _a.governor, methodName = _a.methodName;
52796
52811
  delete engine.success;
52797
52812
  delete engine.error;
52798
52813
  var snapshot = (params === null || params === void 0 ? void 0 : params.rollbackOnError) && makeDeepCopy(drawDefinition$1, false, true);
52799
52814
  // TODO: perhaps prefetch based on targeted methods (e.g. specific governors)
52800
52815
  var additionalParams = {};
52801
52816
  params = __assign(__assign(__assign({}, params), additionalParams), { tournamentParticipants: tournamentParticipants$1, drawDefinition: drawDefinition$1 });
52802
- var result = governor[governorMethod](params);
52817
+ var result = governor[methodName](params);
52803
52818
  if (result === null || result === void 0 ? void 0 : result.error) {
52804
52819
  if (snapshot)
52805
52820
  setState$3(snapshot);
@@ -52893,33 +52908,26 @@ function drawEngineAsync(test) {
52893
52908
  _loop_1 = function (governor) {
52894
52909
  var e_2, _c;
52895
52910
  var governorMethods = Object.keys(governor);
52896
- var _loop_2 = function (governorMethod) {
52897
- engine[governorMethod] = function (params) { return __awaiter(_this, void 0, void 0, function () {
52898
- var err_1, error;
52911
+ var _loop_2 = function (methodName) {
52912
+ engine[methodName] = function (params) { return __awaiter(_this, void 0, void 0, function () {
52913
+ var err_1;
52899
52914
  return __generator(this, function (_a) {
52900
52915
  switch (_a.label) {
52901
52916
  case 0:
52902
52917
  if (!getDevContext()) return [3 /*break*/, 2];
52903
- return [4 /*yield*/, invoke({ params: params, governor: governor, governorMethod: governorMethod })];
52918
+ return [4 /*yield*/, invoke({ params: params, governor: governor, methodName: methodName })];
52904
52919
  case 1: return [2 /*return*/, _a.sent()];
52905
52920
  case 2:
52906
52921
  _a.trys.push([2, 4, , 5]);
52907
- return [4 /*yield*/, invoke({ params: params, governor: governor, governorMethod: governorMethod })];
52922
+ return [4 /*yield*/, invoke({ params: params, governor: governor, methodName: methodName })];
52908
52923
  case 3: return [2 /*return*/, _a.sent()];
52909
52924
  case 4:
52910
52925
  err_1 = _a.sent();
52911
- error = void 0;
52912
- if (typeof err_1 === 'string') {
52913
- error = err_1.toUpperCase();
52914
- }
52915
- else if (err_1 instanceof Error) {
52916
- error = err_1.message;
52917
- }
52918
- console.log('ERROR', {
52919
- params: JSON.stringify(params),
52920
- drawId: drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.drawId,
52921
- method: governorMethod,
52922
- error: error,
52926
+ handleCaughtError({
52927
+ engineName: 'drawEngine',
52928
+ methodName: methodName,
52929
+ params: params,
52930
+ err: err_1,
52923
52931
  });
52924
52932
  return [3 /*break*/, 5];
52925
52933
  case 5: return [2 /*return*/];
@@ -52929,8 +52937,8 @@ function drawEngineAsync(test) {
52929
52937
  };
52930
52938
  try {
52931
52939
  for (var governorMethods_1 = (e_2 = void 0, __values(governorMethods)), governorMethods_1_1 = governorMethods_1.next(); !governorMethods_1_1.done; governorMethods_1_1 = governorMethods_1.next()) {
52932
- var governorMethod = governorMethods_1_1.value;
52933
- _loop_2(governorMethod);
52940
+ var methodName = governorMethods_1_1.value;
52941
+ _loop_2(methodName);
52934
52942
  }
52935
52943
  }
52936
52944
  catch (e_2_1) { e_2 = { error: e_2_1 }; }
@@ -52959,7 +52967,7 @@ function drawEngineAsync(test) {
52959
52967
  });
52960
52968
  }
52961
52969
  function invoke(_a) {
52962
- var params = _a.params, governor = _a.governor, governorMethod = _a.governorMethod;
52970
+ var params = _a.params, governor = _a.governor, methodName = _a.methodName;
52963
52971
  return __awaiter(this, void 0, void 0, function () {
52964
52972
  var snapshot, additionalParams, result, notify;
52965
52973
  return __generator(this, function (_b) {
@@ -52970,7 +52978,7 @@ function drawEngineAsync(test) {
52970
52978
  snapshot = (params === null || params === void 0 ? void 0 : params.rollbackOnError) && makeDeepCopy(drawDefinition, false, true);
52971
52979
  additionalParams = {};
52972
52980
  params = __assign(__assign(__assign({}, params), additionalParams), { tournamentParticipants: tournamentParticipants, drawDefinition: drawDefinition });
52973
- result = governor[governorMethod](params);
52981
+ result = governor[methodName](params);
52974
52982
  if (result === null || result === void 0 ? void 0 : result.error) {
52975
52983
  if (snapshot)
52976
52984
  setState$3(snapshot);
@@ -53547,27 +53555,21 @@ var matchUpEngine = (function () {
53547
53555
  return engine;
53548
53556
  function importGovernors(governors) {
53549
53557
  governors.forEach(function (governor) {
53550
- Object.keys(governor).forEach(function (governorMethod) {
53551
- engine[governorMethod] = function (params) {
53558
+ Object.keys(governor).forEach(function (methodName) {
53559
+ engine[methodName] = function (params) {
53552
53560
  if (getDevContext()) {
53553
- return invoke({ params: params, governor: governor, governorMethod: governorMethod });
53561
+ return invoke({ params: params, governor: governor, methodName: methodName });
53554
53562
  }
53555
53563
  else {
53556
53564
  try {
53557
- return invoke({ params: params, governor: governor, governorMethod: governorMethod });
53565
+ return invoke({ params: params, governor: governor, methodName: methodName });
53558
53566
  }
53559
53567
  catch (err) {
53560
- var error = void 0;
53561
- if (typeof err === 'string') {
53562
- error = err.toUpperCase();
53563
- }
53564
- else if (err instanceof Error) {
53565
- error = err.message;
53566
- }
53567
- console.log('ERROR', {
53568
- params: JSON.stringify(params),
53569
- method: governorMethod,
53570
- error: error,
53568
+ handleCaughtError({
53569
+ engineName: 'matchUpEngine',
53570
+ methodName: methodName,
53571
+ params: params,
53572
+ err: err,
53571
53573
  });
53572
53574
  }
53573
53575
  }
@@ -53576,14 +53578,14 @@ var matchUpEngine = (function () {
53576
53578
  });
53577
53579
  }
53578
53580
  function invoke(_a) {
53579
- var params = _a.params, governor = _a.governor, governorMethod = _a.governorMethod;
53581
+ var params = _a.params, governor = _a.governor, methodName = _a.methodName;
53580
53582
  engine.error = undefined;
53581
53583
  engine.success = false;
53582
53584
  var matchUp = (params === null || params === void 0 ? void 0 : params.matchUp) || getMatchUp();
53583
53585
  var matchUps = (params === null || params === void 0 ? void 0 : params.matchUps) || getMatchUps();
53584
53586
  var snapshot = (params === null || params === void 0 ? void 0 : params.rollbackOnError) && makeDeepCopy(matchUp, false, true);
53585
53587
  params = __assign(__assign({}, params), { matchUpId: matchUp === null || matchUp === void 0 ? void 0 : matchUp.matchUpId, matchUps: matchUps, matchUp: matchUp });
53586
- var result = governor[governorMethod](params);
53588
+ var result = governor[methodName](params);
53587
53589
  if (result === null || result === void 0 ? void 0 : result.error) {
53588
53590
  if (snapshot)
53589
53591
  setState$2(snapshot);
@@ -53652,32 +53654,26 @@ function matchUpEngineAsync(test) {
53652
53654
  _loop_1 = function (governor) {
53653
53655
  var e_2, _c;
53654
53656
  var governorMethods = Object.keys(governor);
53655
- var _loop_2 = function (governorMethod) {
53656
- engine[governorMethod] = function (params) { return __awaiter(_this, void 0, void 0, function () {
53657
- var err_1, error;
53657
+ var _loop_2 = function (methodName) {
53658
+ engine[methodName] = function (params) { return __awaiter(_this, void 0, void 0, function () {
53659
+ var err_1;
53658
53660
  return __generator(this, function (_a) {
53659
53661
  switch (_a.label) {
53660
53662
  case 0:
53661
53663
  if (!getDevContext()) return [3 /*break*/, 2];
53662
- return [4 /*yield*/, invoke({ params: params, governor: governor, governorMethod: governorMethod })];
53664
+ return [4 /*yield*/, invoke({ params: params, governor: governor, methodName: methodName })];
53663
53665
  case 1: return [2 /*return*/, _a.sent()];
53664
53666
  case 2:
53665
53667
  _a.trys.push([2, 4, , 5]);
53666
- return [4 /*yield*/, invoke({ params: params, governor: governor, governorMethod: governorMethod })];
53668
+ return [4 /*yield*/, invoke({ params: params, governor: governor, methodName: methodName })];
53667
53669
  case 3: return [2 /*return*/, _a.sent()];
53668
53670
  case 4:
53669
53671
  err_1 = _a.sent();
53670
- error = void 0;
53671
- if (typeof err_1 === 'string') {
53672
- error = err_1.toUpperCase();
53673
- }
53674
- else if (err_1 instanceof Error) {
53675
- error = err_1.message;
53676
- }
53677
- console.log('ERROR', {
53678
- params: JSON.stringify(params),
53679
- method: governorMethod,
53680
- error: error,
53672
+ handleCaughtError({
53673
+ engineName: 'matchUpEngine',
53674
+ methodName: methodName,
53675
+ params: params,
53676
+ err: err_1,
53681
53677
  });
53682
53678
  return [3 /*break*/, 5];
53683
53679
  case 5: return [2 /*return*/];
@@ -53687,8 +53683,8 @@ function matchUpEngineAsync(test) {
53687
53683
  };
53688
53684
  try {
53689
53685
  for (var governorMethods_1 = (e_2 = void 0, __values(governorMethods)), governorMethods_1_1 = governorMethods_1.next(); !governorMethods_1_1.done; governorMethods_1_1 = governorMethods_1.next()) {
53690
- var governorMethod = governorMethods_1_1.value;
53691
- _loop_2(governorMethod);
53686
+ var methodName = governorMethods_1_1.value;
53687
+ _loop_2(methodName);
53692
53688
  }
53693
53689
  }
53694
53690
  catch (e_2_1) { e_2 = { error: e_2_1 }; }
@@ -53717,7 +53713,7 @@ function matchUpEngineAsync(test) {
53717
53713
  });
53718
53714
  }
53719
53715
  function invoke(_a) {
53720
- var params = _a.params, governor = _a.governor, governorMethod = _a.governorMethod;
53716
+ var params = _a.params, governor = _a.governor, methodName = _a.methodName;
53721
53717
  return __awaiter(this, void 0, void 0, function () {
53722
53718
  var matchUp, matchUps, snapshot, result, notify;
53723
53719
  return __generator(this, function (_b) {
@@ -53729,7 +53725,7 @@ function matchUpEngineAsync(test) {
53729
53725
  matchUps = (params === null || params === void 0 ? void 0 : params.matchUps) || getMatchUps();
53730
53726
  snapshot = (params === null || params === void 0 ? void 0 : params.rollbackOnError) && makeDeepCopy(matchUp, false, true);
53731
53727
  params = __assign(__assign({}, params), { matchUpId: matchUp === null || matchUp === void 0 ? void 0 : matchUp.matchUpId, matchUps: matchUps, matchUp: matchUp });
53732
- result = governor[governorMethod](params);
53728
+ result = governor[methodName](params);
53733
53729
  if (result === null || result === void 0 ? void 0 : result.error) {
53734
53730
  if (snapshot)
53735
53731
  setState$2(snapshot);
@@ -59349,14 +59345,18 @@ function addEventEntryPairs(_a) {
59349
59345
  event: event,
59350
59346
  });
59351
59347
  if (newParticipants.length) {
59352
- addNotice({ topic: ADD_PARTICIPANTS, participants: newParticipants });
59348
+ addNotice({
59349
+ payload: { participants: newParticipants },
59350
+ topic: ADD_PARTICIPANTS,
59351
+ });
59353
59352
  }
59354
59353
  var newParticipantIds = newParticipants.map(getParticipantId);
59355
59354
  return __assign(__assign({}, result), { info: info, newParticipantIds: newParticipantIds });
59356
59355
  }
59357
59356
 
59358
59357
  function checkValidEntries(_a) {
59359
- var _b = _a.enforceGender, enforceGender = _b === void 0 ? true : _b, participants = _a.participants, event = _a.event;
59358
+ var _b = _a.enforceGender, enforceGender = _b === void 0 ? true : _b, consideredEntries = _a.consideredEntries, tournamentRecord = _a.tournamentRecord, participants = _a.participants, event = _a.event;
59359
+ participants = participants || (tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.participants);
59360
59360
  if (!participants)
59361
59361
  return { error: MISSING_PARTICIPANTS };
59362
59362
  if (!Array.isArray(participants))
@@ -59367,7 +59367,7 @@ function checkValidEntries(_a) {
59367
59367
  var participantType = (eventType === TEAM_EVENT && TEAM) ||
59368
59368
  (eventType === DOUBLES_EVENT && PAIR) ||
59369
59369
  INDIVIDUAL;
59370
- var entryStatusMap = Object.assign.apply(Object, __spreadArray([{}], __read((event.entries || []).map(function (entry) {
59370
+ var entryStatusMap = Object.assign.apply(Object, __spreadArray([{}], __read((consideredEntries || event.entries || []).map(function (entry) {
59371
59371
  var _a;
59372
59372
  return (_a = {},
59373
59373
  _a[entry.participantId] = entry.entryStatus,
@@ -62179,50 +62179,61 @@ function prepareStage(params) {
62179
62179
 
62180
62180
  function generateDrawDefinition(params) {
62181
62181
  var e_1, _a, e_2, _b, e_3, _c, e_4, _d, _e, e_5, _f, e_6, _g, _h;
62182
- var _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21;
62182
+ var _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24;
62183
62183
  var stack = 'generateDrawDefinition';
62184
- var _22 = params.drawType, drawType = _22 === void 0 ? DrawTypeEnum.SingleElimination : _22, _23 = params.considerEventEntries, considerEventEntries = _23 === void 0 ? true : _23, // in the absence of drawSize and drawEntries, look to event.entries
62184
+ var _25 = params.considerEventEntries, considerEventEntries = _25 === void 0 ? true : _25, // in the absence of drawSize and drawEntries, look to event.entries
62185
62185
  ignoreAllowedDrawTypes = params.ignoreAllowedDrawTypes, voluntaryConsolation = params.voluntaryConsolation, hydrateCollections = params.hydrateCollections, policyDefinitions = params.policyDefinitions, ignoreStageSpace = params.ignoreStageSpace, tournamentRecord = params.tournamentRecord, qualifyingOnly = params.qualifyingOnly, tieFormatName = params.tieFormatName, drawEntries = params.drawEntries, addToEvent = params.addToEvent, placeByes = params.placeByes, event = params.event;
62186
+ var appliedPolicies = (_j = getAppliedPolicies({
62187
+ tournamentRecord: tournamentRecord,
62188
+ event: event,
62189
+ }).appliedPolicies) !== null && _j !== void 0 ? _j : {};
62190
+ var drawTypeCoercion = (_m = (_k = params.drawTypeCoercion) !== null && _k !== void 0 ? _k : (_l = appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[POLICY_TYPE_DRAWS]) === null || _l === void 0 ? void 0 : _l.drawTypeCoercion) !== null && _m !== void 0 ? _m : true;
62191
+ var drawType = (drawTypeCoercion &&
62192
+ params.drawSize === 2 &&
62193
+ DrawTypeEnum.SingleElimination) ||
62194
+ params.drawType ||
62195
+ DrawTypeEnum.SingleElimination;
62186
62196
  // get participants both for entry validation and for automated placement
62187
62197
  // automated placement requires them to be "inContext" for avoidance policies to work
62188
62198
  var participants = getTournamentParticipants({
62189
62199
  tournamentRecord: tournamentRecord,
62190
62200
  inContext: true,
62191
62201
  }).tournamentParticipants;
62192
- var appliedPolicies = (_j = getAppliedPolicies({
62193
- tournamentRecord: tournamentRecord,
62194
- event: event,
62195
- }).appliedPolicies) !== null && _j !== void 0 ? _j : {};
62196
- var enforceGender = (_o = (_k = params.enforceGender) !== null && _k !== void 0 ? _k : (_m = (_l = policyDefinitions === null || policyDefinitions === void 0 ? void 0 : policyDefinitions[POLICY_TYPE_MATCHUP_ACTIONS]) === null || _l === void 0 ? void 0 : _l.participants) === null || _m === void 0 ? void 0 : _m.enforceGender) !== null && _o !== void 0 ? _o : (_q = (_p = appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[POLICY_TYPE_MATCHUP_ACTIONS]) === null || _p === void 0 ? void 0 : _p.participants) === null || _q === void 0 ? void 0 : _q.enforceGender;
62197
- // entries participantTypes must correspond with eventType
62198
- // this is only possible if the event is provided
62199
- var validEntriesResult = event &&
62200
- participants &&
62201
- checkValidEntries({ event: event, participants: participants, enforceGender: enforceGender });
62202
- if (validEntriesResult === null || validEntriesResult === void 0 ? void 0 : validEntriesResult.error)
62203
- return decorateResult({ result: validEntriesResult, stack: stack });
62202
+ var enforceGender = (_r = (_o = params.enforceGender) !== null && _o !== void 0 ? _o : (_q = (_p = policyDefinitions === null || policyDefinitions === void 0 ? void 0 : policyDefinitions[POLICY_TYPE_MATCHUP_ACTIONS]) === null || _p === void 0 ? void 0 : _p.participants) === null || _q === void 0 ? void 0 : _q.enforceGender) !== null && _r !== void 0 ? _r : (_t = (_s = appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[POLICY_TYPE_MATCHUP_ACTIONS]) === null || _s === void 0 ? void 0 : _s.participants) === null || _t === void 0 ? void 0 : _t.enforceGender;
62204
62203
  // if tournamentRecord is provided, and unless instructed to ignore valid types,
62205
62204
  // check for restrictions on allowed drawTypes
62206
62205
  var allowedDrawTypes = !ignoreAllowedDrawTypes &&
62207
62206
  tournamentRecord &&
62208
62207
  getAllowedDrawTypes({
62209
62208
  tournamentRecord: tournamentRecord,
62210
- categoryType: (_r = event === null || event === void 0 ? void 0 : event.category) === null || _r === void 0 ? void 0 : _r.categoryType,
62211
- categoryName: (_s = event === null || event === void 0 ? void 0 : event.category) === null || _s === void 0 ? void 0 : _s.categoryName,
62209
+ categoryType: (_u = event === null || event === void 0 ? void 0 : event.category) === null || _u === void 0 ? void 0 : _u.categoryType,
62210
+ categoryName: (_v = event === null || event === void 0 ? void 0 : event.category) === null || _v === void 0 ? void 0 : _v.categoryName,
62212
62211
  });
62213
62212
  if ((allowedDrawTypes === null || allowedDrawTypes === void 0 ? void 0 : allowedDrawTypes.length) && !allowedDrawTypes.includes(drawType)) {
62214
62213
  return decorateResult({ result: { error: INVALID_DRAW_TYPE }, stack: stack });
62215
62214
  }
62216
- var eventEntries = (_u = (_t = event === null || event === void 0 ? void 0 : event.entries) === null || _t === void 0 ? void 0 : _t.filter(function (entry) {
62215
+ var eventEntries = (_x = (_w = event === null || event === void 0 ? void 0 : event.entries) === null || _w === void 0 ? void 0 : _w.filter(function (entry) {
62217
62216
  return entry.entryStatus &&
62218
62217
  __spreadArray(__spreadArray([], __read(STRUCTURE_ENTERED_TYPES), false), [QUALIFIER], false).includes(entry.entryStatus);
62219
- })) !== null && _u !== void 0 ? _u : [];
62218
+ })) !== null && _x !== void 0 ? _x : [];
62220
62219
  var consideredEntries = ((qualifyingOnly && []) ||
62221
62220
  drawEntries ||
62222
62221
  (considerEventEntries ? eventEntries : [])).filter(function (_a) {
62223
62222
  var entryStage = _a.entryStage;
62224
62223
  return !entryStage || entryStage === MAIN;
62225
62224
  });
62225
+ // entries participantTypes must correspond with eventType
62226
+ // this is only possible if the event is provided
62227
+ var validEntriesResult = event &&
62228
+ participants &&
62229
+ checkValidEntries({
62230
+ consideredEntries: consideredEntries,
62231
+ enforceGender: enforceGender,
62232
+ participants: participants,
62233
+ event: event,
62234
+ });
62235
+ if (validEntriesResult === null || validEntriesResult === void 0 ? void 0 : validEntriesResult.error)
62236
+ return decorateResult({ result: validEntriesResult, stack: stack });
62226
62237
  var derivedDrawSize = !params.drawSize &&
62227
62238
  consideredEntries.length &&
62228
62239
  ![
@@ -62246,12 +62257,12 @@ function generateDrawDefinition(params) {
62246
62257
  });
62247
62258
  }
62248
62259
  var seedsCount = typeof params.seedsCount !== 'number'
62249
- ? ensureInt((_v = params.seedsCount) !== null && _v !== void 0 ? _v : 0)
62250
- : (_w = params.seedsCount) !== null && _w !== void 0 ? _w : 0;
62260
+ ? ensureInt((_y = params.seedsCount) !== null && _y !== void 0 ? _y : 0)
62261
+ : (_z = params.seedsCount) !== null && _z !== void 0 ? _z : 0;
62251
62262
  var eventType = event === null || event === void 0 ? void 0 : event.eventType;
62252
- var matchUpType = (_x = params.matchUpType) !== null && _x !== void 0 ? _x : eventType;
62263
+ var matchUpType = (_0 = params.matchUpType) !== null && _0 !== void 0 ? _0 : eventType;
62253
62264
  var existingDrawDefinition = params.drawId
62254
- ? (_y = event === null || event === void 0 ? void 0 : event.drawDefinitions) === null || _y === void 0 ? void 0 : _y.find(function (d) { return d.drawId === params.drawId; })
62265
+ ? (_1 = event === null || event === void 0 ? void 0 : event.drawDefinitions) === null || _1 === void 0 ? void 0 : _1.find(function (d) { return d.drawId === params.drawId; })
62255
62266
  : undefined;
62256
62267
  // drawDefinition cannot have both tieFormat and matchUpFormat
62257
62268
  var tieFormat = params.tieFormat, matchUpFormat = params.matchUpFormat;
@@ -62259,16 +62270,16 @@ function generateDrawDefinition(params) {
62259
62270
  if (matchUpType === TEAM$2 && eventType === TEAM$2) {
62260
62271
  // if there is an existingDrawDefinition which has a tieFormat on MAIN structure
62261
62272
  // use this tieFormat ONLY when no tieFormat is specified in params
62262
- var existingMainTieFormat = (_0 = (_z = existingDrawDefinition === null || existingDrawDefinition === void 0 ? void 0 : existingDrawDefinition.structures) === null || _z === void 0 ? void 0 : _z.find(function (_a) {
62273
+ var existingMainTieFormat = (_3 = (_2 = existingDrawDefinition === null || existingDrawDefinition === void 0 ? void 0 : existingDrawDefinition.structures) === null || _2 === void 0 ? void 0 : _2.find(function (_a) {
62263
62274
  var stage = _a.stage;
62264
62275
  return stage === MAIN;
62265
- })) === null || _0 === void 0 ? void 0 : _0.tieFormat;
62276
+ })) === null || _3 === void 0 ? void 0 : _3.tieFormat;
62266
62277
  tieFormat =
62267
62278
  tieFormat ||
62268
62279
  existingMainTieFormat ||
62269
62280
  // if tieFormatName is provided and it matches the name of the tieFormat attached to parent event...
62270
62281
  (tieFormatName &&
62271
- ((_1 = event === null || event === void 0 ? void 0 : event.tieFormat) === null || _1 === void 0 ? void 0 : _1.tieFormatName) === tieFormatName &&
62282
+ ((_4 = event === null || event === void 0 ? void 0 : event.tieFormat) === null || _4 === void 0 ? void 0 : _4.tieFormatName) === tieFormatName &&
62272
62283
  event.tieFormat) ||
62273
62284
  // if the tieFormatName is not found in the factory then will use default
62274
62285
  (tieFormatName &&
@@ -62320,7 +62331,7 @@ function generateDrawDefinition(params) {
62320
62331
  var result = checkTieFormat(tieFormat);
62321
62332
  if (result.error)
62322
62333
  return decorateResult({ result: result, stack: stack });
62323
- drawDefinition.tieFormat = (_2 = result.tieFormat) !== null && _2 !== void 0 ? _2 : tieFormat;
62334
+ drawDefinition.tieFormat = (_5 = result.tieFormat) !== null && _5 !== void 0 ? _5 : tieFormat;
62324
62335
  }
62325
62336
  else if (matchUpFormat) {
62326
62337
  var result = setMatchUpFormat$1({
@@ -62353,8 +62364,8 @@ function generateDrawDefinition(params) {
62353
62364
  else {
62354
62365
  var policiesToAttach = {};
62355
62366
  try {
62356
- for (var _24 = __values(Object.keys(policyDefinitions)), _25 = _24.next(); !_25.done; _25 = _24.next()) {
62357
- var key = _25.value;
62367
+ for (var _26 = __values(Object.keys(policyDefinitions)), _27 = _26.next(); !_27.done; _27 = _26.next()) {
62368
+ var key = _27.value;
62358
62369
  if (JSON.stringify(appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[key]) !==
62359
62370
  JSON.stringify(policyDefinitions[key])) {
62360
62371
  policiesToAttach[key] = policyDefinitions[key];
@@ -62364,7 +62375,7 @@ function generateDrawDefinition(params) {
62364
62375
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
62365
62376
  finally {
62366
62377
  try {
62367
- if (_25 && !_25.done && (_a = _24.return)) _a.call(_24);
62378
+ if (_27 && !_27.done && (_a = _26.return)) _a.call(_26);
62368
62379
  }
62369
62380
  finally { if (e_1) throw e_1.error; }
62370
62381
  }
@@ -62380,19 +62391,19 @@ function generateDrawDefinition(params) {
62380
62391
  Object.assign(appliedPolicies, POLICY_SEEDING_USTA);
62381
62392
  }
62382
62393
  // find existing MAIN structureId if existingDrawDefinition
62383
- var structureId = (_4 = (_3 = existingDrawDefinition === null || existingDrawDefinition === void 0 ? void 0 : existingDrawDefinition.structures) === null || _3 === void 0 ? void 0 : _3.find(function (structure) { return structure.stage === MAIN && structure.stageSequence === 1; })) === null || _4 === void 0 ? void 0 : _4.structureId;
62394
+ var structureId = (_7 = (_6 = existingDrawDefinition === null || existingDrawDefinition === void 0 ? void 0 : existingDrawDefinition.structures) === null || _6 === void 0 ? void 0 : _6.find(function (structure) { return structure.stage === MAIN && structure.stageSequence === 1; })) === null || _7 === void 0 ? void 0 : _7.structureId;
62384
62395
  var entries = drawEntries !== null && drawEntries !== void 0 ? drawEntries : eventEntries;
62385
62396
  var positioningReports = [];
62386
62397
  var drawTypeResult;
62387
62398
  var conflicts = [];
62388
62399
  var generateQualifyingPlaceholder = params.qualifyingPlaceholder &&
62389
- !((_5 = params.qualifyingProfiles) === null || _5 === void 0 ? void 0 : _5.length) &&
62400
+ !((_8 = params.qualifyingProfiles) === null || _8 === void 0 ? void 0 : _8.length) &&
62390
62401
  !existingDrawDefinition;
62391
62402
  var existingQualifyingStructures = existingDrawDefinition
62392
- ? (_6 = existingDrawDefinition.structures) === null || _6 === void 0 ? void 0 : _6.filter(function (structure) { return structure.stage === QUALIFYING; })
62403
+ ? (_9 = existingDrawDefinition.structures) === null || _9 === void 0 ? void 0 : _9.filter(function (structure) { return structure.stage === QUALIFYING; })
62393
62404
  : [];
62394
62405
  var existingQualifyingPlaceholderStructureId = (existingQualifyingStructures === null || existingQualifyingStructures === void 0 ? void 0 : existingQualifyingStructures.length) === 1 &&
62395
- !((_7 = existingQualifyingStructures[0].matchUps) === null || _7 === void 0 ? void 0 : _7.length) &&
62406
+ !((_10 = existingQualifyingStructures[0].matchUps) === null || _10 === void 0 ? void 0 : _10.length) &&
62396
62407
  existingQualifyingStructures[0].structureId;
62397
62408
  if (existingQualifyingPlaceholderStructureId) {
62398
62409
  var qualifyingProfiles = params.qualifyingProfiles;
@@ -62408,24 +62419,24 @@ function generateDrawDefinition(params) {
62408
62419
  if (qualifyingResult === null || qualifyingResult === void 0 ? void 0 : qualifyingResult.error) {
62409
62420
  return qualifyingResult;
62410
62421
  }
62411
- drawDefinition.structures = (_8 = drawDefinition.structures) === null || _8 === void 0 ? void 0 : _8.filter(function (_a) {
62422
+ drawDefinition.structures = (_11 = drawDefinition.structures) === null || _11 === void 0 ? void 0 : _11.filter(function (_a) {
62412
62423
  var structureId = _a.structureId;
62413
62424
  return structureId !== existingQualifyingPlaceholderStructureId;
62414
62425
  });
62415
- drawDefinition.links = (_9 = drawDefinition.links) === null || _9 === void 0 ? void 0 : _9.filter(function (_a) {
62426
+ drawDefinition.links = (_12 = drawDefinition.links) === null || _12 === void 0 ? void 0 : _12.filter(function (_a) {
62416
62427
  var source = _a.source;
62417
62428
  return source.structureId !== existingQualifyingPlaceholderStructureId;
62418
62429
  });
62419
- var _26 = qualifyingResult !== null && qualifyingResult !== void 0 ? qualifyingResult : {}, qualifiersCount = _26.qualifiersCount, qualifyingDrawPositionsCount = _26.qualifyingDrawPositionsCount, qualifyingDetails = _26.qualifyingDetails;
62430
+ var _28 = qualifyingResult !== null && qualifyingResult !== void 0 ? qualifyingResult : {}, qualifiersCount = _28.qualifiersCount, qualifyingDrawPositionsCount = _28.qualifyingDrawPositionsCount, qualifyingDetails = _28.qualifyingDetails;
62420
62431
  if (qualifyingDrawPositionsCount) {
62421
62432
  if (qualifyingResult === null || qualifyingResult === void 0 ? void 0 : qualifyingResult.structures) {
62422
- (_10 = drawDefinition.structures) === null || _10 === void 0 ? void 0 : _10.push.apply(_10, __spreadArray([], __read(qualifyingResult.structures), false));
62433
+ (_13 = drawDefinition.structures) === null || _13 === void 0 ? void 0 : _13.push.apply(_13, __spreadArray([], __read(qualifyingResult.structures), false));
62423
62434
  }
62424
62435
  if (qualifyingResult === null || qualifyingResult === void 0 ? void 0 : qualifyingResult.links) {
62425
- (_11 = drawDefinition.links) === null || _11 === void 0 ? void 0 : _11.push.apply(_11, __spreadArray([], __read(qualifyingResult.links), false));
62436
+ (_14 = drawDefinition.links) === null || _14 === void 0 ? void 0 : _14.push.apply(_14, __spreadArray([], __read(qualifyingResult.links), false));
62426
62437
  }
62427
62438
  }
62428
- var mainStructure = (_12 = drawDefinition.structures) === null || _12 === void 0 ? void 0 : _12.find(function (_a) {
62439
+ var mainStructure = (_15 = drawDefinition.structures) === null || _15 === void 0 ? void 0 : _15.find(function (_a) {
62429
62440
  var stage = _a.stage, stageSequence = _a.stageSequence;
62430
62441
  return stage === MAIN && stageSequence === 1;
62431
62442
  });
@@ -62451,12 +62462,12 @@ function generateDrawDefinition(params) {
62451
62462
  if (result.error)
62452
62463
  return result;
62453
62464
  try {
62454
- for (var _27 = __values((drawEntries !== null && drawEntries !== void 0 ? drawEntries : []).filter(function (_a) {
62465
+ for (var _29 = __values((drawEntries !== null && drawEntries !== void 0 ? drawEntries : []).filter(function (_a) {
62455
62466
  var entryStage = _a.entryStage;
62456
62467
  return entryStage === StageTypeEnum.Qualifying;
62457
- })), _28 = _27.next(); !_28.done; _28 = _27.next()) {
62458
- var entry = _28.value;
62459
- var entryData = __assign(__assign({}, entry), { entryStage: (_13 = entry.entryStage) !== null && _13 !== void 0 ? _13 : StageTypeEnum.Main, drawDefinition: drawDefinition });
62468
+ })), _30 = _29.next(); !_30.done; _30 = _29.next()) {
62469
+ var entry = _30.value;
62470
+ var entryData = __assign(__assign({}, entry), { entryStage: (_16 = entry.entryStage) !== null && _16 !== void 0 ? _16 : StageTypeEnum.Main, drawDefinition: drawDefinition });
62460
62471
  // ignore errors (EXITING_PARTICIPANT)
62461
62472
  addDrawEntry(entryData);
62462
62473
  }
@@ -62464,23 +62475,23 @@ function generateDrawDefinition(params) {
62464
62475
  catch (e_2_1) { e_2 = { error: e_2_1 }; }
62465
62476
  finally {
62466
62477
  try {
62467
- if (_28 && !_28.done && (_b = _27.return)) _b.call(_27);
62478
+ if (_30 && !_30.done && (_b = _29.return)) _b.call(_29);
62468
62479
  }
62469
62480
  finally { if (e_2) throw e_2.error; }
62470
62481
  }
62471
62482
  try {
62472
- for (var _29 = __values(qualifyingDetails || []), _30 = _29.next(); !_30.done; _30 = _29.next()) {
62473
- var qualifyingDetail = _30.value;
62483
+ for (var _31 = __values(qualifyingDetails || []), _32 = _31.next(); !_32.done; _32 = _31.next()) {
62484
+ var qualifyingDetail = _32.value;
62474
62485
  var qualifyingRoundNumber = qualifyingDetail.finalQualifyingRoundNumber, qualifyingStructureId = qualifyingDetail.finalQualifyingStructureId, targetEntryRound = qualifyingDetail.roundTarget, finishingPositions = qualifyingDetail.finishingPositions, linkType = qualifyingDetail.linkType;
62475
62486
  var link = mainStructure &&
62476
- ((_14 = generateQualifyingLink({
62487
+ ((_17 = generateQualifyingLink({
62477
62488
  targetStructureId: mainStructure.structureId,
62478
62489
  sourceStructureId: qualifyingStructureId,
62479
62490
  sourceRoundNumber: qualifyingRoundNumber,
62480
62491
  finishingPositions: finishingPositions,
62481
62492
  targetEntryRound: targetEntryRound,
62482
62493
  linkType: linkType,
62483
- })) === null || _14 === void 0 ? void 0 : _14.link);
62494
+ })) === null || _17 === void 0 ? void 0 : _17.link);
62484
62495
  if (link === null || link === void 0 ? void 0 : link.error)
62485
62496
  return link;
62486
62497
  if (link) {
@@ -62493,7 +62504,7 @@ function generateDrawDefinition(params) {
62493
62504
  catch (e_3_1) { e_3 = { error: e_3_1 }; }
62494
62505
  finally {
62495
62506
  try {
62496
- if (_30 && !_30.done && (_c = _29.return)) _c.call(_29);
62507
+ if (_32 && !_32.done && (_c = _31.return)) _c.call(_31);
62497
62508
  }
62498
62509
  finally { if (e_3) throw e_3.error; }
62499
62510
  }
@@ -62514,7 +62525,7 @@ function generateDrawDefinition(params) {
62514
62525
  entry.entryStage &&
62515
62526
  entry.entryStage !== StageTypeEnum.Main)
62516
62527
  continue;
62517
- var entryData = __assign(__assign({}, entry), { ignoreStageSpace: ignoreStageSpace !== null && ignoreStageSpace !== void 0 ? ignoreStageSpace : drawType === AD_HOC, entryStage: (_15 = entry.entryStage) !== null && _15 !== void 0 ? _15 : StageTypeEnum.Main, drawDefinition: drawDefinition, drawType: drawType });
62528
+ var entryData = __assign(__assign({}, entry), { ignoreStageSpace: ignoreStageSpace !== null && ignoreStageSpace !== void 0 ? ignoreStageSpace : drawType === AD_HOC, entryStage: (_18 = entry.entryStage) !== null && _18 !== void 0 ? _18 : StageTypeEnum.Main, drawDefinition: drawDefinition, drawType: drawType });
62518
62529
  var result = addDrawEntry(entryData);
62519
62530
  if (drawEntries && result.error) {
62520
62531
  // only report errors with drawEntries
@@ -62538,13 +62549,13 @@ function generateDrawDefinition(params) {
62538
62549
  if (structureResult.error && !structureResult.conflicts) {
62539
62550
  return structureResult;
62540
62551
  }
62541
- if ((_16 = structureResult.positioningReport) === null || _16 === void 0 ? void 0 : _16.length)
62552
+ if ((_19 = structureResult.positioningReport) === null || _19 === void 0 ? void 0 : _19.length)
62542
62553
  positioningReports.push((_e = {}, _e[MAIN] = structureResult.positioningReport, _e));
62543
62554
  structureId = structureResult.structureId;
62544
62555
  if (structureResult.conflicts)
62545
62556
  conflicts = structureResult.conflicts;
62546
62557
  if (drawType === AD_HOC && params.roundsCount) {
62547
- var entries_2 = (_17 = event === null || event === void 0 ? void 0 : event.entries) === null || _17 === void 0 ? void 0 : _17.filter(function (_a) {
62558
+ var entries_2 = (_20 = event === null || event === void 0 ? void 0 : event.entries) === null || _20 === void 0 ? void 0 : _20.filter(function (_a) {
62548
62559
  var entryStage = _a.entryStage, entryStatus = _a.entryStatus;
62549
62560
  return (!entryStage || entryStage === MAIN) &&
62550
62561
  entryStatus &&
@@ -62591,20 +62602,20 @@ function generateDrawDefinition(params) {
62591
62602
  var roundTarget = 1;
62592
62603
  params.qualifyingProfiles.sort(roundTargetSort);
62593
62604
  try {
62594
- for (var _31 = __values(params.qualifyingProfiles), _32 = _31.next(); !_32.done; _32 = _31.next()) {
62595
- var roundTargetProfile = _32.value;
62605
+ for (var _33 = __values(params.qualifyingProfiles), _34 = _33.next(); !_34.done; _34 = _33.next()) {
62606
+ var roundTargetProfile = _34.value;
62596
62607
  if (!Array.isArray(roundTargetProfile.structureProfiles))
62597
62608
  return decorateResult({
62598
62609
  result: { error: MISSING_VALUE },
62599
62610
  info: mustBeAnArray('structureProfiles'),
62600
62611
  });
62601
62612
  roundTarget = roundTargetProfile.roundTarget || roundTarget;
62602
- var sortedStructureProfiles = ((_18 = roundTargetProfile.structureProfiles) === null || _18 === void 0 ? void 0 : _18.sort(sequenceSort)) || [];
62613
+ var sortedStructureProfiles = ((_21 = roundTargetProfile.structureProfiles) === null || _21 === void 0 ? void 0 : _21.sort(sequenceSort)) || [];
62603
62614
  var sequence = 1;
62604
62615
  try {
62605
62616
  for (var sortedStructureProfiles_1 = (e_6 = void 0, __values(sortedStructureProfiles)), sortedStructureProfiles_1_1 = sortedStructureProfiles_1.next(); !sortedStructureProfiles_1_1.done; sortedStructureProfiles_1_1 = sortedStructureProfiles_1.next()) {
62606
62617
  var structureProfile = sortedStructureProfiles_1_1.value;
62607
- var qualifyingRoundNumber = structureProfile.qualifyingRoundNumber, qualifyingPositions = structureProfile.qualifyingPositions, seededParticipants = structureProfile.seededParticipants, seedingScaleName = structureProfile.seedingScaleName, _33 = structureProfile.seedsCount, seedsCount_1 = _33 === void 0 ? 0 : _33, seedingProfile = structureProfile.seedingProfile, seedByRanking = structureProfile.seedByRanking, placeByes_1 = structureProfile.placeByes, drawSize_1 = structureProfile.drawSize;
62618
+ var qualifyingRoundNumber = structureProfile.qualifyingRoundNumber, qualifyingPositions = structureProfile.qualifyingPositions, seededParticipants = structureProfile.seededParticipants, seedingScaleName = structureProfile.seedingScaleName, _35 = structureProfile.seedsCount, seedsCount_1 = _35 === void 0 ? 0 : _35, seedingProfile = structureProfile.seedingProfile, seedByRanking = structureProfile.seedByRanking, placeByes_1 = structureProfile.placeByes, drawSize_1 = structureProfile.drawSize;
62608
62619
  var qualifyingStageResult = prepareStage(__assign(__assign(__assign({}, drawTypeResult), params), { stageSequence: sequence, qualifyingRoundNumber: qualifyingRoundNumber, preparedStructureIds: preparedStructureIds, qualifyingPositions: qualifyingPositions, seededParticipants: seededParticipants, stage: QUALIFYING, seedingScaleName: seedingScaleName, appliedPolicies: appliedPolicies, drawDefinition: drawDefinition, qualifyingOnly: qualifyingOnly, seedingProfile: seedingProfile, seedByRanking: seedByRanking, participants: participants, roundTarget: roundTarget, seedsCount: seedsCount_1, placeByes: placeByes_1, drawSize: drawSize_1, entries: entries }));
62609
62620
  if (qualifyingStageResult.error) {
62610
62621
  return qualifyingStageResult;
@@ -62613,9 +62624,9 @@ function generateDrawDefinition(params) {
62613
62624
  preparedStructureIds.push(qualifyingStageResult.structureId);
62614
62625
  }
62615
62626
  sequence += 1;
62616
- if ((_19 = qualifyingStageResult.conflicts) === null || _19 === void 0 ? void 0 : _19.length)
62627
+ if ((_22 = qualifyingStageResult.conflicts) === null || _22 === void 0 ? void 0 : _22.length)
62617
62628
  qualifyingConflicts.push.apply(qualifyingConflicts, __spreadArray([], __read(qualifyingStageResult.conflicts), false));
62618
- if ((_20 = qualifyingStageResult.positioningReport) === null || _20 === void 0 ? void 0 : _20.length)
62629
+ if ((_23 = qualifyingStageResult.positioningReport) === null || _23 === void 0 ? void 0 : _23.length)
62619
62630
  positioningReports.push((_h = {},
62620
62631
  _h[QUALIFYING] = qualifyingStageResult.positioningReport,
62621
62632
  _h));
@@ -62634,7 +62645,7 @@ function generateDrawDefinition(params) {
62634
62645
  catch (e_5_1) { e_5 = { error: e_5_1 }; }
62635
62646
  finally {
62636
62647
  try {
62637
- if (_32 && !_32.done && (_f = _31.return)) _f.call(_31);
62648
+ if (_34 && !_34.done && (_f = _33.return)) _f.call(_33);
62638
62649
  }
62639
62650
  finally { if (e_5) throw e_5.error; }
62640
62651
  }
@@ -62657,7 +62668,7 @@ function generateDrawDefinition(params) {
62657
62668
  drawDefinition.links = [];
62658
62669
  drawDefinition.links.push(link);
62659
62670
  }
62660
- drawDefinition.drawName = (_21 = params.drawName) !== null && _21 !== void 0 ? _21 : drawType;
62671
+ drawDefinition.drawName = (_24 = params.drawName) !== null && _24 !== void 0 ? _24 : drawType;
62661
62672
  if (typeof voluntaryConsolation === 'object') {
62662
62673
  addVoluntaryConsolationStructure(__assign(__assign({}, voluntaryConsolation), { tournamentRecord: tournamentRecord, appliedPolicies: appliedPolicies, drawDefinition: drawDefinition, matchUpType: matchUpType }));
62663
62674
  }
@@ -63741,18 +63752,11 @@ var tournamentEngine = (function () {
63741
63752
  return engineInvoke(governor[methodName], params, methodName);
63742
63753
  }
63743
63754
  catch (err) {
63744
- var error = void 0;
63745
- if (typeof err === 'string') {
63746
- error = err.toUpperCase();
63747
- }
63748
- else if (err instanceof Error) {
63749
- error = err.message;
63750
- }
63751
- console.log('ERROR', {
63752
- tournamentId: getTournamentId(),
63753
- params: JSON.stringify(params),
63755
+ handleCaughtError({
63756
+ engineName: 'tournamentEngine',
63754
63757
  methodName: methodName,
63755
- error: error,
63758
+ params: params,
63759
+ err: err,
63756
63760
  });
63757
63761
  }
63758
63762
  }
@@ -63956,34 +63960,26 @@ function tournamentEngineAsync(test) {
63956
63960
  var _loop_1 = function (governor) {
63957
63961
  var e_2, _b;
63958
63962
  var governorMethods = Object.keys(governor);
63959
- var _loop_2 = function (method) {
63960
- engine[method] = function (params) { return __awaiter(_this, void 0, void 0, function () {
63961
- var err_1, tournamentId, error;
63963
+ var _loop_2 = function (methodName) {
63964
+ engine[methodName] = function (params) { return __awaiter(_this, void 0, void 0, function () {
63965
+ var err_1;
63962
63966
  return __generator(this, function (_a) {
63963
63967
  switch (_a.label) {
63964
63968
  case 0:
63965
63969
  if (!getDevContext()) return [3 /*break*/, 2];
63966
- return [4 /*yield*/, engineInvoke(governor[method], params)];
63970
+ return [4 /*yield*/, engineInvoke(governor[methodName], params)];
63967
63971
  case 1: return [2 /*return*/, _a.sent()];
63968
63972
  case 2:
63969
63973
  _a.trys.push([2, 4, , 5]);
63970
- return [4 /*yield*/, engineInvoke(governor[method], params)];
63974
+ return [4 /*yield*/, engineInvoke(governor[methodName], params)];
63971
63975
  case 3: return [2 /*return*/, _a.sent()];
63972
63976
  case 4:
63973
63977
  err_1 = _a.sent();
63974
- tournamentId = getTournamentId();
63975
- error = void 0;
63976
- if (typeof err_1 === 'string') {
63977
- error = err_1.toUpperCase();
63978
- }
63979
- else if (err_1 instanceof Error) {
63980
- error = err_1.message;
63981
- }
63982
- console.log('ERROR', {
63983
- params: JSON.stringify(params),
63984
- tournamentId: tournamentId,
63985
- method: method,
63986
- error: error,
63978
+ handleCaughtError({
63979
+ engineName: 'tournamentEngine',
63980
+ methodName: methodName,
63981
+ params: params,
63982
+ err: err_1,
63987
63983
  });
63988
63984
  return [3 /*break*/, 5];
63989
63985
  case 5: return [2 /*return*/];
@@ -63993,8 +63989,8 @@ function tournamentEngineAsync(test) {
63993
63989
  };
63994
63990
  try {
63995
63991
  for (var governorMethods_1 = (e_2 = void 0, __values(governorMethods)), governorMethods_1_1 = governorMethods_1.next(); !governorMethods_1_1.done; governorMethods_1_1 = governorMethods_1.next()) {
63996
- var method = governorMethods_1_1.value;
63997
- _loop_2(method);
63992
+ var methodName = governorMethods_1_1.value;
63993
+ _loop_2(methodName);
63998
63994
  }
63999
63995
  }
64000
63996
  catch (e_2_1) { e_2 = { error: e_2_1 }; }
@@ -64863,27 +64859,21 @@ var scaleEngine = (function () {
64863
64859
  }
64864
64860
  function importGovernors(governors) {
64865
64861
  governors.forEach(function (governor) {
64866
- Object.keys(governor).forEach(function (method) {
64867
- engine[method] = function (params) {
64862
+ Object.keys(governor).forEach(function (methodName) {
64863
+ engine[methodName] = function (params) {
64868
64864
  if (getDevContext()) {
64869
- return engineInvoke(governor[method], params);
64865
+ return engineInvoke(governor[methodName], params);
64870
64866
  }
64871
64867
  else {
64872
64868
  try {
64873
- return engineInvoke(governor[method], params);
64869
+ return engineInvoke(governor[methodName], params);
64874
64870
  }
64875
64871
  catch (err) {
64876
- var error = void 0;
64877
- if (typeof err === 'string') {
64878
- error = err.toUpperCase();
64879
- }
64880
- else if (err instanceof Error) {
64881
- error = err.message;
64882
- }
64883
- console.log('ERROR', {
64884
- error: error,
64885
- method: method,
64886
- params: JSON.stringify(params),
64872
+ handleCaughtError({
64873
+ engineName: 'scaleEngine',
64874
+ methodName: methodName,
64875
+ params: params,
64876
+ err: err,
64887
64877
  });
64888
64878
  }
64889
64879
  }
@@ -64986,20 +64976,37 @@ function scaleEngineAsync(test) {
64986
64976
  var _loop_1 = function (governor) {
64987
64977
  var e_2, _b;
64988
64978
  var governorMethods = Object.keys(governor);
64989
- var _loop_2 = function (governorMethod) {
64990
- engine[governorMethod] = function (params) { return __awaiter(_this, void 0, void 0, function () {
64979
+ var _loop_2 = function (methodName) {
64980
+ engine[methodName] = function (params) { return __awaiter(_this, void 0, void 0, function () {
64981
+ var err_1;
64991
64982
  return __generator(this, function (_a) {
64992
64983
  switch (_a.label) {
64993
- case 0: return [4 /*yield*/, engineInvoke(governor[governorMethod], params)];
64984
+ case 0:
64985
+ if (!getDevContext()) return [3 /*break*/, 2];
64986
+ return [4 /*yield*/, engineInvoke(governor[methodName], params)];
64994
64987
  case 1: return [2 /*return*/, _a.sent()];
64988
+ case 2:
64989
+ _a.trys.push([2, 4, , 5]);
64990
+ return [4 /*yield*/, engineInvoke(governor[methodName], params)];
64991
+ case 3: return [2 /*return*/, _a.sent()];
64992
+ case 4:
64993
+ err_1 = _a.sent();
64994
+ handleCaughtError({
64995
+ engineName: 'scaleEngine',
64996
+ methodName: methodName,
64997
+ params: params,
64998
+ err: err_1,
64999
+ });
65000
+ return [3 /*break*/, 5];
65001
+ case 5: return [2 /*return*/];
64995
65002
  }
64996
65003
  });
64997
65004
  }); };
64998
65005
  };
64999
65006
  try {
65000
65007
  for (var governorMethods_1 = (e_2 = void 0, __values(governorMethods)), governorMethods_1_1 = governorMethods_1.next(); !governorMethods_1_1.done; governorMethods_1_1 = governorMethods_1.next()) {
65001
- var governorMethod = governorMethods_1_1.value;
65002
- _loop_2(governorMethod);
65008
+ var methodName = governorMethods_1_1.value;
65009
+ _loop_2(methodName);
65003
65010
  }
65004
65011
  }
65005
65012
  catch (e_2_1) { e_2 = { error: e_2_1 }; }