tods-competition-factory 1.6.29 → 1.7.0

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.29';
365
+ return '1.7.0';
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 }; }
@@ -43935,10 +43951,10 @@ function getGenerators(params) {
43935
43951
 
43936
43952
  function generateDrawStructuresAndLinks$1(params) {
43937
43953
  var e_1, _a, e_2, _b;
43938
- var _c, _d, _e, _f, _g, _h;
43939
- var _j = params || {}, _k = _j.enforceMinimumDrawSize, enforceMinimumDrawSize = _k === void 0 ? true : _k, _l = _j.drawTypeCoercion, drawTypeCoercion = _l === void 0 ? true : _l, // coerce to SINGLE_ELIMINATION for drawSize: 2
43940
- overwriteExisting = _j.overwriteExisting, appliedPolicies = _j.appliedPolicies, staggeredEntry = _j.staggeredEntry, // optional - specifies main structure FEED_IN for drawTypes CURTIS_CONSOLATION, FEED_IN_CHAMPIONSHIPS, FMLC
43941
- drawDefinition = _j.drawDefinition, tieFormat = _j.tieFormat, drawSize = _j.drawSize, isMock = _j.isMock, uuids = _j.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;
43942
43958
  var stack = 'generateDrawStructuresAndLinks';
43943
43959
  var drawType = (drawTypeCoercion &&
43944
43960
  params.drawSize === 2 &&
@@ -43946,8 +43962,8 @@ function generateDrawStructuresAndLinks$1(params) {
43946
43962
  params.drawType ||
43947
43963
  DrawTypeEnum.SingleElimination;
43948
43964
  var structures = [], links = [];
43949
- var matchUpType = (_c = params === null || params === void 0 ? void 0 : params.matchUpType) !== null && _c !== void 0 ? _c : SINGLES$1;
43950
- var existingQualifyingStructures = (_d = drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.structures) === null || _d === void 0 ? void 0 : _d.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) {
43951
43967
  var stage = _a.stage;
43952
43968
  return stage === QUALIFYING;
43953
43969
  });
@@ -43958,11 +43974,11 @@ function generateDrawStructuresAndLinks$1(params) {
43958
43974
  var structureId = _a.structureId;
43959
43975
  return structureId;
43960
43976
  });
43961
- var existingMainStructure = (_e = drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.structures) === null || _e === void 0 ? void 0 : _e.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) {
43962
43978
  var stage = _a.stage, stageSequence = _a.stageSequence;
43963
43979
  return stage === MAIN && stageSequence === 1;
43964
43980
  });
43965
- var existingQualifyingLinks = (_f = drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.links) === null || _f === void 0 ? void 0 : _f.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) {
43966
43982
  return link.target.structureId === (existingMainStructure === null || existingMainStructure === void 0 ? void 0 : existingMainStructure.structureId) &&
43967
43983
  (existingQualifyingStructureIds === null || existingQualifyingStructureIds === void 0 ? void 0 : existingQualifyingStructureIds.includes(link.source.structureId));
43968
43984
  });
@@ -43997,7 +44013,7 @@ function generateDrawStructuresAndLinks$1(params) {
43997
44013
  var structure = existingQualifyingStructures === null || existingQualifyingStructures === void 0 ? void 0 : existingQualifyingStructures.find(function (structure) { return structure.structureId === qualifyingStructureId; });
43998
44014
  return getQualifiersCount(link, structure);
43999
44015
  }).filter(Boolean).reduce(function (a, b) { return a + b; }, 0);
44000
- var mainStructureIsPlaceholder = !!(existingMainStructure && !((_g = existingMainStructure === null || existingMainStructure === void 0 ? void 0 : existingMainStructure.matchUps) === null || _g === void 0 ? void 0 : _g.length));
44016
+ var mainStructureIsPlaceholder = !!(existingMainStructure && !((_k = existingMainStructure === null || existingMainStructure === void 0 ? void 0 : existingMainStructure.matchUps) === null || _k === void 0 ? void 0 : _k.length));
44001
44017
  if ((existingQualifyingStructures === null || existingQualifyingStructures === void 0 ? void 0 : existingQualifyingStructures.length) && !mainStructureIsPlaceholder) {
44002
44018
  return { error: EXISTING_STAGE };
44003
44019
  }
@@ -44014,10 +44030,10 @@ function generateDrawStructuresAndLinks$1(params) {
44014
44030
  if (qualifyingResult === null || qualifyingResult === void 0 ? void 0 : qualifyingResult.error) {
44015
44031
  return qualifyingResult;
44016
44032
  }
44017
- var _m = qualifyingResult || {
44033
+ var _p = qualifyingResult || {
44018
44034
  qualifyingDrawPositionsCount: existingQualifyingDrawPositionsCount,
44019
44035
  qualifiersCount: existingQualifiersCount,
44020
- }, qualifyingDrawPositionsCount = _m.qualifyingDrawPositionsCount, qualifyingDetails = _m.qualifyingDetails, qualifiersCount = _m.qualifiersCount;
44036
+ }, qualifyingDrawPositionsCount = _p.qualifyingDrawPositionsCount, qualifyingDetails = _p.qualifyingDetails, qualifiersCount = _p.qualifiersCount;
44021
44037
  if (qualifyingDrawPositionsCount) {
44022
44038
  if (qualifyingResult === null || qualifyingResult === void 0 ? void 0 : qualifyingResult.structures) {
44023
44039
  structures.push.apply(structures, __spreadArray([], __read(qualifyingResult.structures), false));
@@ -44062,7 +44078,7 @@ function generateDrawStructuresAndLinks$1(params) {
44062
44078
  });
44063
44079
  }
44064
44080
  }
44065
- var _o = getGenerators(params), generators = _o.generators, error = _o.error;
44081
+ var _q = getGenerators(params), generators = _q.generators, error = _q.error;
44066
44082
  if (error) {
44067
44083
  return { error: error };
44068
44084
  }
@@ -44118,18 +44134,18 @@ function generateDrawStructuresAndLinks$1(params) {
44118
44134
  return stage === MAIN && stageSequence === 1;
44119
44135
  });
44120
44136
  try {
44121
- for (var _p = __values(qualifyingDetails || []), _q = _p.next(); !_q.done; _q = _p.next()) {
44122
- var qualifyingDetail = _q.value;
44137
+ for (var _r = __values(qualifyingDetails || []), _s = _r.next(); !_s.done; _s = _r.next()) {
44138
+ var qualifyingDetail = _s.value;
44123
44139
  var qualifyingRoundNumber = qualifyingDetail.finalQualifyingRoundNumber, qualifyingStructureId = qualifyingDetail.finalQualifyingStructureId, targetEntryRound = qualifyingDetail.roundTarget, finishingPositions = qualifyingDetail.finishingPositions, linkType = qualifyingDetail.linkType;
44124
44140
  var link = mainStructure &&
44125
- ((_h = generateQualifyingLink({
44141
+ ((_l = generateQualifyingLink({
44126
44142
  targetStructureId: mainStructure.structureId,
44127
44143
  sourceStructureId: qualifyingStructureId,
44128
44144
  sourceRoundNumber: qualifyingRoundNumber,
44129
44145
  finishingPositions: finishingPositions,
44130
44146
  targetEntryRound: targetEntryRound,
44131
44147
  linkType: linkType,
44132
- })) === null || _h === void 0 ? void 0 : _h.link);
44148
+ })) === null || _l === void 0 ? void 0 : _l.link);
44133
44149
  if (link === null || link === void 0 ? void 0 : link.error)
44134
44150
  return link;
44135
44151
  if (link) {
@@ -44140,7 +44156,7 @@ function generateDrawStructuresAndLinks$1(params) {
44140
44156
  catch (e_2_1) { e_2 = { error: e_2_1 }; }
44141
44157
  finally {
44142
44158
  try {
44143
- if (_q && !_q.done && (_b = _p.return)) _b.call(_p);
44159
+ if (_s && !_s.done && (_b = _r.return)) _b.call(_r);
44144
44160
  }
44145
44161
  finally { if (e_2) throw e_2.error; }
44146
44162
  }
@@ -52768,28 +52784,21 @@ var drawEngine = (function () {
52768
52784
  return engine;
52769
52785
  function importGovernors(governors) {
52770
52786
  governors.forEach(function (governor) {
52771
- Object.keys(governor).forEach(function (governorMethod) {
52772
- engine[governorMethod] = function (params) {
52787
+ Object.keys(governor).forEach(function (methodName) {
52788
+ engine[methodName] = function (params) {
52773
52789
  if (getDevContext()) {
52774
- return invoke({ params: params, governor: governor, governorMethod: governorMethod });
52790
+ return invoke({ params: params, governor: governor, methodName: methodName });
52775
52791
  }
52776
52792
  else {
52777
52793
  try {
52778
- return invoke({ params: params, governor: governor, governorMethod: governorMethod });
52794
+ return invoke({ params: params, governor: governor, methodName: methodName });
52779
52795
  }
52780
52796
  catch (err) {
52781
- var error = void 0;
52782
- if (typeof err === 'string') {
52783
- error = err.toUpperCase();
52784
- }
52785
- else if (err instanceof Error) {
52786
- error = err.message;
52787
- }
52788
- console.log('ERROR', {
52789
- params: JSON.stringify(params),
52790
- drawId: drawDefinition$1 === null || drawDefinition$1 === void 0 ? void 0 : drawDefinition$1.drawId,
52791
- method: governorMethod,
52792
- error: error,
52797
+ handleCaughtError({
52798
+ engineName: 'drawEngine',
52799
+ methodName: methodName,
52800
+ params: params,
52801
+ err: err,
52793
52802
  });
52794
52803
  }
52795
52804
  }
@@ -52798,14 +52807,14 @@ var drawEngine = (function () {
52798
52807
  });
52799
52808
  }
52800
52809
  function invoke(_a) {
52801
- var params = _a.params, governor = _a.governor, governorMethod = _a.governorMethod;
52810
+ var params = _a.params, governor = _a.governor, methodName = _a.methodName;
52802
52811
  delete engine.success;
52803
52812
  delete engine.error;
52804
52813
  var snapshot = (params === null || params === void 0 ? void 0 : params.rollbackOnError) && makeDeepCopy(drawDefinition$1, false, true);
52805
52814
  // TODO: perhaps prefetch based on targeted methods (e.g. specific governors)
52806
52815
  var additionalParams = {};
52807
52816
  params = __assign(__assign(__assign({}, params), additionalParams), { tournamentParticipants: tournamentParticipants$1, drawDefinition: drawDefinition$1 });
52808
- var result = governor[governorMethod](params);
52817
+ var result = governor[methodName](params);
52809
52818
  if (result === null || result === void 0 ? void 0 : result.error) {
52810
52819
  if (snapshot)
52811
52820
  setState$3(snapshot);
@@ -52899,33 +52908,26 @@ function drawEngineAsync(test) {
52899
52908
  _loop_1 = function (governor) {
52900
52909
  var e_2, _c;
52901
52910
  var governorMethods = Object.keys(governor);
52902
- var _loop_2 = function (governorMethod) {
52903
- engine[governorMethod] = function (params) { return __awaiter(_this, void 0, void 0, function () {
52904
- 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;
52905
52914
  return __generator(this, function (_a) {
52906
52915
  switch (_a.label) {
52907
52916
  case 0:
52908
52917
  if (!getDevContext()) return [3 /*break*/, 2];
52909
- return [4 /*yield*/, invoke({ params: params, governor: governor, governorMethod: governorMethod })];
52918
+ return [4 /*yield*/, invoke({ params: params, governor: governor, methodName: methodName })];
52910
52919
  case 1: return [2 /*return*/, _a.sent()];
52911
52920
  case 2:
52912
52921
  _a.trys.push([2, 4, , 5]);
52913
- return [4 /*yield*/, invoke({ params: params, governor: governor, governorMethod: governorMethod })];
52922
+ return [4 /*yield*/, invoke({ params: params, governor: governor, methodName: methodName })];
52914
52923
  case 3: return [2 /*return*/, _a.sent()];
52915
52924
  case 4:
52916
52925
  err_1 = _a.sent();
52917
- error = void 0;
52918
- if (typeof err_1 === 'string') {
52919
- error = err_1.toUpperCase();
52920
- }
52921
- else if (err_1 instanceof Error) {
52922
- error = err_1.message;
52923
- }
52924
- console.log('ERROR', {
52925
- params: JSON.stringify(params),
52926
- drawId: drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.drawId,
52927
- method: governorMethod,
52928
- error: error,
52926
+ handleCaughtError({
52927
+ engineName: 'drawEngine',
52928
+ methodName: methodName,
52929
+ params: params,
52930
+ err: err_1,
52929
52931
  });
52930
52932
  return [3 /*break*/, 5];
52931
52933
  case 5: return [2 /*return*/];
@@ -52935,8 +52937,8 @@ function drawEngineAsync(test) {
52935
52937
  };
52936
52938
  try {
52937
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()) {
52938
- var governorMethod = governorMethods_1_1.value;
52939
- _loop_2(governorMethod);
52940
+ var methodName = governorMethods_1_1.value;
52941
+ _loop_2(methodName);
52940
52942
  }
52941
52943
  }
52942
52944
  catch (e_2_1) { e_2 = { error: e_2_1 }; }
@@ -52965,7 +52967,7 @@ function drawEngineAsync(test) {
52965
52967
  });
52966
52968
  }
52967
52969
  function invoke(_a) {
52968
- var params = _a.params, governor = _a.governor, governorMethod = _a.governorMethod;
52970
+ var params = _a.params, governor = _a.governor, methodName = _a.methodName;
52969
52971
  return __awaiter(this, void 0, void 0, function () {
52970
52972
  var snapshot, additionalParams, result, notify;
52971
52973
  return __generator(this, function (_b) {
@@ -52976,7 +52978,7 @@ function drawEngineAsync(test) {
52976
52978
  snapshot = (params === null || params === void 0 ? void 0 : params.rollbackOnError) && makeDeepCopy(drawDefinition, false, true);
52977
52979
  additionalParams = {};
52978
52980
  params = __assign(__assign(__assign({}, params), additionalParams), { tournamentParticipants: tournamentParticipants, drawDefinition: drawDefinition });
52979
- result = governor[governorMethod](params);
52981
+ result = governor[methodName](params);
52980
52982
  if (result === null || result === void 0 ? void 0 : result.error) {
52981
52983
  if (snapshot)
52982
52984
  setState$3(snapshot);
@@ -53553,27 +53555,21 @@ var matchUpEngine = (function () {
53553
53555
  return engine;
53554
53556
  function importGovernors(governors) {
53555
53557
  governors.forEach(function (governor) {
53556
- Object.keys(governor).forEach(function (governorMethod) {
53557
- engine[governorMethod] = function (params) {
53558
+ Object.keys(governor).forEach(function (methodName) {
53559
+ engine[methodName] = function (params) {
53558
53560
  if (getDevContext()) {
53559
- return invoke({ params: params, governor: governor, governorMethod: governorMethod });
53561
+ return invoke({ params: params, governor: governor, methodName: methodName });
53560
53562
  }
53561
53563
  else {
53562
53564
  try {
53563
- return invoke({ params: params, governor: governor, governorMethod: governorMethod });
53565
+ return invoke({ params: params, governor: governor, methodName: methodName });
53564
53566
  }
53565
53567
  catch (err) {
53566
- var error = void 0;
53567
- if (typeof err === 'string') {
53568
- error = err.toUpperCase();
53569
- }
53570
- else if (err instanceof Error) {
53571
- error = err.message;
53572
- }
53573
- console.log('ERROR', {
53574
- params: JSON.stringify(params),
53575
- method: governorMethod,
53576
- error: error,
53568
+ handleCaughtError({
53569
+ engineName: 'matchUpEngine',
53570
+ methodName: methodName,
53571
+ params: params,
53572
+ err: err,
53577
53573
  });
53578
53574
  }
53579
53575
  }
@@ -53582,14 +53578,14 @@ var matchUpEngine = (function () {
53582
53578
  });
53583
53579
  }
53584
53580
  function invoke(_a) {
53585
- var params = _a.params, governor = _a.governor, governorMethod = _a.governorMethod;
53581
+ var params = _a.params, governor = _a.governor, methodName = _a.methodName;
53586
53582
  engine.error = undefined;
53587
53583
  engine.success = false;
53588
53584
  var matchUp = (params === null || params === void 0 ? void 0 : params.matchUp) || getMatchUp();
53589
53585
  var matchUps = (params === null || params === void 0 ? void 0 : params.matchUps) || getMatchUps();
53590
53586
  var snapshot = (params === null || params === void 0 ? void 0 : params.rollbackOnError) && makeDeepCopy(matchUp, false, true);
53591
53587
  params = __assign(__assign({}, params), { matchUpId: matchUp === null || matchUp === void 0 ? void 0 : matchUp.matchUpId, matchUps: matchUps, matchUp: matchUp });
53592
- var result = governor[governorMethod](params);
53588
+ var result = governor[methodName](params);
53593
53589
  if (result === null || result === void 0 ? void 0 : result.error) {
53594
53590
  if (snapshot)
53595
53591
  setState$2(snapshot);
@@ -53658,32 +53654,26 @@ function matchUpEngineAsync(test) {
53658
53654
  _loop_1 = function (governor) {
53659
53655
  var e_2, _c;
53660
53656
  var governorMethods = Object.keys(governor);
53661
- var _loop_2 = function (governorMethod) {
53662
- engine[governorMethod] = function (params) { return __awaiter(_this, void 0, void 0, function () {
53663
- 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;
53664
53660
  return __generator(this, function (_a) {
53665
53661
  switch (_a.label) {
53666
53662
  case 0:
53667
53663
  if (!getDevContext()) return [3 /*break*/, 2];
53668
- return [4 /*yield*/, invoke({ params: params, governor: governor, governorMethod: governorMethod })];
53664
+ return [4 /*yield*/, invoke({ params: params, governor: governor, methodName: methodName })];
53669
53665
  case 1: return [2 /*return*/, _a.sent()];
53670
53666
  case 2:
53671
53667
  _a.trys.push([2, 4, , 5]);
53672
- return [4 /*yield*/, invoke({ params: params, governor: governor, governorMethod: governorMethod })];
53668
+ return [4 /*yield*/, invoke({ params: params, governor: governor, methodName: methodName })];
53673
53669
  case 3: return [2 /*return*/, _a.sent()];
53674
53670
  case 4:
53675
53671
  err_1 = _a.sent();
53676
- error = void 0;
53677
- if (typeof err_1 === 'string') {
53678
- error = err_1.toUpperCase();
53679
- }
53680
- else if (err_1 instanceof Error) {
53681
- error = err_1.message;
53682
- }
53683
- console.log('ERROR', {
53684
- params: JSON.stringify(params),
53685
- method: governorMethod,
53686
- error: error,
53672
+ handleCaughtError({
53673
+ engineName: 'matchUpEngine',
53674
+ methodName: methodName,
53675
+ params: params,
53676
+ err: err_1,
53687
53677
  });
53688
53678
  return [3 /*break*/, 5];
53689
53679
  case 5: return [2 /*return*/];
@@ -53693,8 +53683,8 @@ function matchUpEngineAsync(test) {
53693
53683
  };
53694
53684
  try {
53695
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()) {
53696
- var governorMethod = governorMethods_1_1.value;
53697
- _loop_2(governorMethod);
53686
+ var methodName = governorMethods_1_1.value;
53687
+ _loop_2(methodName);
53698
53688
  }
53699
53689
  }
53700
53690
  catch (e_2_1) { e_2 = { error: e_2_1 }; }
@@ -53723,7 +53713,7 @@ function matchUpEngineAsync(test) {
53723
53713
  });
53724
53714
  }
53725
53715
  function invoke(_a) {
53726
- var params = _a.params, governor = _a.governor, governorMethod = _a.governorMethod;
53716
+ var params = _a.params, governor = _a.governor, methodName = _a.methodName;
53727
53717
  return __awaiter(this, void 0, void 0, function () {
53728
53718
  var matchUp, matchUps, snapshot, result, notify;
53729
53719
  return __generator(this, function (_b) {
@@ -53735,7 +53725,7 @@ function matchUpEngineAsync(test) {
53735
53725
  matchUps = (params === null || params === void 0 ? void 0 : params.matchUps) || getMatchUps();
53736
53726
  snapshot = (params === null || params === void 0 ? void 0 : params.rollbackOnError) && makeDeepCopy(matchUp, false, true);
53737
53727
  params = __assign(__assign({}, params), { matchUpId: matchUp === null || matchUp === void 0 ? void 0 : matchUp.matchUpId, matchUps: matchUps, matchUp: matchUp });
53738
- result = governor[governorMethod](params);
53728
+ result = governor[methodName](params);
53739
53729
  if (result === null || result === void 0 ? void 0 : result.error) {
53740
53730
  if (snapshot)
53741
53731
  setState$2(snapshot);
@@ -59355,7 +59345,10 @@ function addEventEntryPairs(_a) {
59355
59345
  event: event,
59356
59346
  });
59357
59347
  if (newParticipants.length) {
59358
- addNotice({ topic: ADD_PARTICIPANTS, participants: newParticipants });
59348
+ addNotice({
59349
+ payload: { participants: newParticipants },
59350
+ topic: ADD_PARTICIPANTS,
59351
+ });
59359
59352
  }
59360
59353
  var newParticipantIds = newParticipants.map(getParticipantId);
59361
59354
  return __assign(__assign({}, result), { info: info, newParticipantIds: newParticipantIds });
@@ -62186,11 +62179,15 @@ function prepareStage(params) {
62186
62179
 
62187
62180
  function generateDrawDefinition(params) {
62188
62181
  var e_1, _a, e_2, _b, e_3, _c, e_4, _d, _e, e_5, _f, e_6, _g, _h;
62189
- 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;
62190
62183
  var stack = 'generateDrawDefinition';
62191
- var _22 = params.considerEventEntries, considerEventEntries = _22 === void 0 ? true : _22, // in the absence of drawSize and drawEntries, look to event.entries
62192
- _23 = params.drawTypeCoercion, // in the absence of drawSize and drawEntries, look to event.entries
62193
- drawTypeCoercion = _23 === void 0 ? true : _23, 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;
62184
+ var _25 = params.considerEventEntries, considerEventEntries = _25 === void 0 ? true : _25, // in the absence of drawSize and drawEntries, look to event.entries
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;
62194
62191
  var drawType = (drawTypeCoercion &&
62195
62192
  params.drawSize === 2 &&
62196
62193
  DrawTypeEnum.SingleElimination) ||
@@ -62202,27 +62199,23 @@ function generateDrawDefinition(params) {
62202
62199
  tournamentRecord: tournamentRecord,
62203
62200
  inContext: true,
62204
62201
  }).tournamentParticipants;
62205
- var appliedPolicies = (_j = getAppliedPolicies({
62206
- tournamentRecord: tournamentRecord,
62207
- event: event,
62208
- }).appliedPolicies) !== null && _j !== void 0 ? _j : {};
62209
- 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;
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;
62210
62203
  // if tournamentRecord is provided, and unless instructed to ignore valid types,
62211
62204
  // check for restrictions on allowed drawTypes
62212
62205
  var allowedDrawTypes = !ignoreAllowedDrawTypes &&
62213
62206
  tournamentRecord &&
62214
62207
  getAllowedDrawTypes({
62215
62208
  tournamentRecord: tournamentRecord,
62216
- categoryType: (_r = event === null || event === void 0 ? void 0 : event.category) === null || _r === void 0 ? void 0 : _r.categoryType,
62217
- 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,
62218
62211
  });
62219
62212
  if ((allowedDrawTypes === null || allowedDrawTypes === void 0 ? void 0 : allowedDrawTypes.length) && !allowedDrawTypes.includes(drawType)) {
62220
62213
  return decorateResult({ result: { error: INVALID_DRAW_TYPE }, stack: stack });
62221
62214
  }
62222
- 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) {
62223
62216
  return entry.entryStatus &&
62224
62217
  __spreadArray(__spreadArray([], __read(STRUCTURE_ENTERED_TYPES), false), [QUALIFIER], false).includes(entry.entryStatus);
62225
- })) !== null && _u !== void 0 ? _u : [];
62218
+ })) !== null && _x !== void 0 ? _x : [];
62226
62219
  var consideredEntries = ((qualifyingOnly && []) ||
62227
62220
  drawEntries ||
62228
62221
  (considerEventEntries ? eventEntries : [])).filter(function (_a) {
@@ -62264,12 +62257,12 @@ function generateDrawDefinition(params) {
62264
62257
  });
62265
62258
  }
62266
62259
  var seedsCount = typeof params.seedsCount !== 'number'
62267
- ? ensureInt((_v = params.seedsCount) !== null && _v !== void 0 ? _v : 0)
62268
- : (_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;
62269
62262
  var eventType = event === null || event === void 0 ? void 0 : event.eventType;
62270
- var matchUpType = (_x = params.matchUpType) !== null && _x !== void 0 ? _x : eventType;
62263
+ var matchUpType = (_0 = params.matchUpType) !== null && _0 !== void 0 ? _0 : eventType;
62271
62264
  var existingDrawDefinition = params.drawId
62272
- ? (_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; })
62273
62266
  : undefined;
62274
62267
  // drawDefinition cannot have both tieFormat and matchUpFormat
62275
62268
  var tieFormat = params.tieFormat, matchUpFormat = params.matchUpFormat;
@@ -62277,16 +62270,16 @@ function generateDrawDefinition(params) {
62277
62270
  if (matchUpType === TEAM$2 && eventType === TEAM$2) {
62278
62271
  // if there is an existingDrawDefinition which has a tieFormat on MAIN structure
62279
62272
  // use this tieFormat ONLY when no tieFormat is specified in params
62280
- 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) {
62281
62274
  var stage = _a.stage;
62282
62275
  return stage === MAIN;
62283
- })) === null || _0 === void 0 ? void 0 : _0.tieFormat;
62276
+ })) === null || _3 === void 0 ? void 0 : _3.tieFormat;
62284
62277
  tieFormat =
62285
62278
  tieFormat ||
62286
62279
  existingMainTieFormat ||
62287
62280
  // if tieFormatName is provided and it matches the name of the tieFormat attached to parent event...
62288
62281
  (tieFormatName &&
62289
- ((_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 &&
62290
62283
  event.tieFormat) ||
62291
62284
  // if the tieFormatName is not found in the factory then will use default
62292
62285
  (tieFormatName &&
@@ -62338,7 +62331,7 @@ function generateDrawDefinition(params) {
62338
62331
  var result = checkTieFormat(tieFormat);
62339
62332
  if (result.error)
62340
62333
  return decorateResult({ result: result, stack: stack });
62341
- drawDefinition.tieFormat = (_2 = result.tieFormat) !== null && _2 !== void 0 ? _2 : tieFormat;
62334
+ drawDefinition.tieFormat = (_5 = result.tieFormat) !== null && _5 !== void 0 ? _5 : tieFormat;
62342
62335
  }
62343
62336
  else if (matchUpFormat) {
62344
62337
  var result = setMatchUpFormat$1({
@@ -62371,8 +62364,8 @@ function generateDrawDefinition(params) {
62371
62364
  else {
62372
62365
  var policiesToAttach = {};
62373
62366
  try {
62374
- for (var _24 = __values(Object.keys(policyDefinitions)), _25 = _24.next(); !_25.done; _25 = _24.next()) {
62375
- 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;
62376
62369
  if (JSON.stringify(appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[key]) !==
62377
62370
  JSON.stringify(policyDefinitions[key])) {
62378
62371
  policiesToAttach[key] = policyDefinitions[key];
@@ -62382,7 +62375,7 @@ function generateDrawDefinition(params) {
62382
62375
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
62383
62376
  finally {
62384
62377
  try {
62385
- if (_25 && !_25.done && (_a = _24.return)) _a.call(_24);
62378
+ if (_27 && !_27.done && (_a = _26.return)) _a.call(_26);
62386
62379
  }
62387
62380
  finally { if (e_1) throw e_1.error; }
62388
62381
  }
@@ -62398,19 +62391,19 @@ function generateDrawDefinition(params) {
62398
62391
  Object.assign(appliedPolicies, POLICY_SEEDING_USTA);
62399
62392
  }
62400
62393
  // find existing MAIN structureId if existingDrawDefinition
62401
- 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;
62402
62395
  var entries = drawEntries !== null && drawEntries !== void 0 ? drawEntries : eventEntries;
62403
62396
  var positioningReports = [];
62404
62397
  var drawTypeResult;
62405
62398
  var conflicts = [];
62406
62399
  var generateQualifyingPlaceholder = params.qualifyingPlaceholder &&
62407
- !((_5 = params.qualifyingProfiles) === null || _5 === void 0 ? void 0 : _5.length) &&
62400
+ !((_8 = params.qualifyingProfiles) === null || _8 === void 0 ? void 0 : _8.length) &&
62408
62401
  !existingDrawDefinition;
62409
62402
  var existingQualifyingStructures = existingDrawDefinition
62410
- ? (_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; })
62411
62404
  : [];
62412
62405
  var existingQualifyingPlaceholderStructureId = (existingQualifyingStructures === null || existingQualifyingStructures === void 0 ? void 0 : existingQualifyingStructures.length) === 1 &&
62413
- !((_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) &&
62414
62407
  existingQualifyingStructures[0].structureId;
62415
62408
  if (existingQualifyingPlaceholderStructureId) {
62416
62409
  var qualifyingProfiles = params.qualifyingProfiles;
@@ -62426,24 +62419,24 @@ function generateDrawDefinition(params) {
62426
62419
  if (qualifyingResult === null || qualifyingResult === void 0 ? void 0 : qualifyingResult.error) {
62427
62420
  return qualifyingResult;
62428
62421
  }
62429
- 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) {
62430
62423
  var structureId = _a.structureId;
62431
62424
  return structureId !== existingQualifyingPlaceholderStructureId;
62432
62425
  });
62433
- 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) {
62434
62427
  var source = _a.source;
62435
62428
  return source.structureId !== existingQualifyingPlaceholderStructureId;
62436
62429
  });
62437
- 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;
62438
62431
  if (qualifyingDrawPositionsCount) {
62439
62432
  if (qualifyingResult === null || qualifyingResult === void 0 ? void 0 : qualifyingResult.structures) {
62440
- (_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));
62441
62434
  }
62442
62435
  if (qualifyingResult === null || qualifyingResult === void 0 ? void 0 : qualifyingResult.links) {
62443
- (_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));
62444
62437
  }
62445
62438
  }
62446
- 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) {
62447
62440
  var stage = _a.stage, stageSequence = _a.stageSequence;
62448
62441
  return stage === MAIN && stageSequence === 1;
62449
62442
  });
@@ -62469,12 +62462,12 @@ function generateDrawDefinition(params) {
62469
62462
  if (result.error)
62470
62463
  return result;
62471
62464
  try {
62472
- 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) {
62473
62466
  var entryStage = _a.entryStage;
62474
62467
  return entryStage === StageTypeEnum.Qualifying;
62475
- })), _28 = _27.next(); !_28.done; _28 = _27.next()) {
62476
- var entry = _28.value;
62477
- 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 });
62478
62471
  // ignore errors (EXITING_PARTICIPANT)
62479
62472
  addDrawEntry(entryData);
62480
62473
  }
@@ -62482,23 +62475,23 @@ function generateDrawDefinition(params) {
62482
62475
  catch (e_2_1) { e_2 = { error: e_2_1 }; }
62483
62476
  finally {
62484
62477
  try {
62485
- if (_28 && !_28.done && (_b = _27.return)) _b.call(_27);
62478
+ if (_30 && !_30.done && (_b = _29.return)) _b.call(_29);
62486
62479
  }
62487
62480
  finally { if (e_2) throw e_2.error; }
62488
62481
  }
62489
62482
  try {
62490
- for (var _29 = __values(qualifyingDetails || []), _30 = _29.next(); !_30.done; _30 = _29.next()) {
62491
- var qualifyingDetail = _30.value;
62483
+ for (var _31 = __values(qualifyingDetails || []), _32 = _31.next(); !_32.done; _32 = _31.next()) {
62484
+ var qualifyingDetail = _32.value;
62492
62485
  var qualifyingRoundNumber = qualifyingDetail.finalQualifyingRoundNumber, qualifyingStructureId = qualifyingDetail.finalQualifyingStructureId, targetEntryRound = qualifyingDetail.roundTarget, finishingPositions = qualifyingDetail.finishingPositions, linkType = qualifyingDetail.linkType;
62493
62486
  var link = mainStructure &&
62494
- ((_14 = generateQualifyingLink({
62487
+ ((_17 = generateQualifyingLink({
62495
62488
  targetStructureId: mainStructure.structureId,
62496
62489
  sourceStructureId: qualifyingStructureId,
62497
62490
  sourceRoundNumber: qualifyingRoundNumber,
62498
62491
  finishingPositions: finishingPositions,
62499
62492
  targetEntryRound: targetEntryRound,
62500
62493
  linkType: linkType,
62501
- })) === null || _14 === void 0 ? void 0 : _14.link);
62494
+ })) === null || _17 === void 0 ? void 0 : _17.link);
62502
62495
  if (link === null || link === void 0 ? void 0 : link.error)
62503
62496
  return link;
62504
62497
  if (link) {
@@ -62511,7 +62504,7 @@ function generateDrawDefinition(params) {
62511
62504
  catch (e_3_1) { e_3 = { error: e_3_1 }; }
62512
62505
  finally {
62513
62506
  try {
62514
- if (_30 && !_30.done && (_c = _29.return)) _c.call(_29);
62507
+ if (_32 && !_32.done && (_c = _31.return)) _c.call(_31);
62515
62508
  }
62516
62509
  finally { if (e_3) throw e_3.error; }
62517
62510
  }
@@ -62532,7 +62525,7 @@ function generateDrawDefinition(params) {
62532
62525
  entry.entryStage &&
62533
62526
  entry.entryStage !== StageTypeEnum.Main)
62534
62527
  continue;
62535
- 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 });
62536
62529
  var result = addDrawEntry(entryData);
62537
62530
  if (drawEntries && result.error) {
62538
62531
  // only report errors with drawEntries
@@ -62556,13 +62549,13 @@ function generateDrawDefinition(params) {
62556
62549
  if (structureResult.error && !structureResult.conflicts) {
62557
62550
  return structureResult;
62558
62551
  }
62559
- 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)
62560
62553
  positioningReports.push((_e = {}, _e[MAIN] = structureResult.positioningReport, _e));
62561
62554
  structureId = structureResult.structureId;
62562
62555
  if (structureResult.conflicts)
62563
62556
  conflicts = structureResult.conflicts;
62564
62557
  if (drawType === AD_HOC && params.roundsCount) {
62565
- 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) {
62566
62559
  var entryStage = _a.entryStage, entryStatus = _a.entryStatus;
62567
62560
  return (!entryStage || entryStage === MAIN) &&
62568
62561
  entryStatus &&
@@ -62609,20 +62602,20 @@ function generateDrawDefinition(params) {
62609
62602
  var roundTarget = 1;
62610
62603
  params.qualifyingProfiles.sort(roundTargetSort);
62611
62604
  try {
62612
- for (var _31 = __values(params.qualifyingProfiles), _32 = _31.next(); !_32.done; _32 = _31.next()) {
62613
- var roundTargetProfile = _32.value;
62605
+ for (var _33 = __values(params.qualifyingProfiles), _34 = _33.next(); !_34.done; _34 = _33.next()) {
62606
+ var roundTargetProfile = _34.value;
62614
62607
  if (!Array.isArray(roundTargetProfile.structureProfiles))
62615
62608
  return decorateResult({
62616
62609
  result: { error: MISSING_VALUE },
62617
62610
  info: mustBeAnArray('structureProfiles'),
62618
62611
  });
62619
62612
  roundTarget = roundTargetProfile.roundTarget || roundTarget;
62620
- 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)) || [];
62621
62614
  var sequence = 1;
62622
62615
  try {
62623
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()) {
62624
62617
  var structureProfile = sortedStructureProfiles_1_1.value;
62625
- 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;
62626
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 }));
62627
62620
  if (qualifyingStageResult.error) {
62628
62621
  return qualifyingStageResult;
@@ -62631,9 +62624,9 @@ function generateDrawDefinition(params) {
62631
62624
  preparedStructureIds.push(qualifyingStageResult.structureId);
62632
62625
  }
62633
62626
  sequence += 1;
62634
- 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)
62635
62628
  qualifyingConflicts.push.apply(qualifyingConflicts, __spreadArray([], __read(qualifyingStageResult.conflicts), false));
62636
- 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)
62637
62630
  positioningReports.push((_h = {},
62638
62631
  _h[QUALIFYING] = qualifyingStageResult.positioningReport,
62639
62632
  _h));
@@ -62652,7 +62645,7 @@ function generateDrawDefinition(params) {
62652
62645
  catch (e_5_1) { e_5 = { error: e_5_1 }; }
62653
62646
  finally {
62654
62647
  try {
62655
- if (_32 && !_32.done && (_f = _31.return)) _f.call(_31);
62648
+ if (_34 && !_34.done && (_f = _33.return)) _f.call(_33);
62656
62649
  }
62657
62650
  finally { if (e_5) throw e_5.error; }
62658
62651
  }
@@ -62675,7 +62668,7 @@ function generateDrawDefinition(params) {
62675
62668
  drawDefinition.links = [];
62676
62669
  drawDefinition.links.push(link);
62677
62670
  }
62678
- drawDefinition.drawName = (_21 = params.drawName) !== null && _21 !== void 0 ? _21 : drawType;
62671
+ drawDefinition.drawName = (_24 = params.drawName) !== null && _24 !== void 0 ? _24 : drawType;
62679
62672
  if (typeof voluntaryConsolation === 'object') {
62680
62673
  addVoluntaryConsolationStructure(__assign(__assign({}, voluntaryConsolation), { tournamentRecord: tournamentRecord, appliedPolicies: appliedPolicies, drawDefinition: drawDefinition, matchUpType: matchUpType }));
62681
62674
  }
@@ -63759,18 +63752,11 @@ var tournamentEngine = (function () {
63759
63752
  return engineInvoke(governor[methodName], params, methodName);
63760
63753
  }
63761
63754
  catch (err) {
63762
- var error = void 0;
63763
- if (typeof err === 'string') {
63764
- error = err.toUpperCase();
63765
- }
63766
- else if (err instanceof Error) {
63767
- error = err.message;
63768
- }
63769
- console.log('ERROR', {
63770
- tournamentId: getTournamentId(),
63771
- params: JSON.stringify(params),
63755
+ handleCaughtError({
63756
+ engineName: 'tournamentEngine',
63772
63757
  methodName: methodName,
63773
- error: error,
63758
+ params: params,
63759
+ err: err,
63774
63760
  });
63775
63761
  }
63776
63762
  }
@@ -63974,34 +63960,26 @@ function tournamentEngineAsync(test) {
63974
63960
  var _loop_1 = function (governor) {
63975
63961
  var e_2, _b;
63976
63962
  var governorMethods = Object.keys(governor);
63977
- var _loop_2 = function (method) {
63978
- engine[method] = function (params) { return __awaiter(_this, void 0, void 0, function () {
63979
- 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;
63980
63966
  return __generator(this, function (_a) {
63981
63967
  switch (_a.label) {
63982
63968
  case 0:
63983
63969
  if (!getDevContext()) return [3 /*break*/, 2];
63984
- return [4 /*yield*/, engineInvoke(governor[method], params)];
63970
+ return [4 /*yield*/, engineInvoke(governor[methodName], params)];
63985
63971
  case 1: return [2 /*return*/, _a.sent()];
63986
63972
  case 2:
63987
63973
  _a.trys.push([2, 4, , 5]);
63988
- return [4 /*yield*/, engineInvoke(governor[method], params)];
63974
+ return [4 /*yield*/, engineInvoke(governor[methodName], params)];
63989
63975
  case 3: return [2 /*return*/, _a.sent()];
63990
63976
  case 4:
63991
63977
  err_1 = _a.sent();
63992
- tournamentId = getTournamentId();
63993
- error = void 0;
63994
- if (typeof err_1 === 'string') {
63995
- error = err_1.toUpperCase();
63996
- }
63997
- else if (err_1 instanceof Error) {
63998
- error = err_1.message;
63999
- }
64000
- console.log('ERROR', {
64001
- params: JSON.stringify(params),
64002
- tournamentId: tournamentId,
64003
- method: method,
64004
- error: error,
63978
+ handleCaughtError({
63979
+ engineName: 'tournamentEngine',
63980
+ methodName: methodName,
63981
+ params: params,
63982
+ err: err_1,
64005
63983
  });
64006
63984
  return [3 /*break*/, 5];
64007
63985
  case 5: return [2 /*return*/];
@@ -64011,8 +63989,8 @@ function tournamentEngineAsync(test) {
64011
63989
  };
64012
63990
  try {
64013
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()) {
64014
- var method = governorMethods_1_1.value;
64015
- _loop_2(method);
63992
+ var methodName = governorMethods_1_1.value;
63993
+ _loop_2(methodName);
64016
63994
  }
64017
63995
  }
64018
63996
  catch (e_2_1) { e_2 = { error: e_2_1 }; }
@@ -64881,27 +64859,21 @@ var scaleEngine = (function () {
64881
64859
  }
64882
64860
  function importGovernors(governors) {
64883
64861
  governors.forEach(function (governor) {
64884
- Object.keys(governor).forEach(function (method) {
64885
- engine[method] = function (params) {
64862
+ Object.keys(governor).forEach(function (methodName) {
64863
+ engine[methodName] = function (params) {
64886
64864
  if (getDevContext()) {
64887
- return engineInvoke(governor[method], params);
64865
+ return engineInvoke(governor[methodName], params);
64888
64866
  }
64889
64867
  else {
64890
64868
  try {
64891
- return engineInvoke(governor[method], params);
64869
+ return engineInvoke(governor[methodName], params);
64892
64870
  }
64893
64871
  catch (err) {
64894
- var error = void 0;
64895
- if (typeof err === 'string') {
64896
- error = err.toUpperCase();
64897
- }
64898
- else if (err instanceof Error) {
64899
- error = err.message;
64900
- }
64901
- console.log('ERROR', {
64902
- error: error,
64903
- method: method,
64904
- params: JSON.stringify(params),
64872
+ handleCaughtError({
64873
+ engineName: 'scaleEngine',
64874
+ methodName: methodName,
64875
+ params: params,
64876
+ err: err,
64905
64877
  });
64906
64878
  }
64907
64879
  }
@@ -65004,20 +64976,37 @@ function scaleEngineAsync(test) {
65004
64976
  var _loop_1 = function (governor) {
65005
64977
  var e_2, _b;
65006
64978
  var governorMethods = Object.keys(governor);
65007
- var _loop_2 = function (governorMethod) {
65008
- 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;
65009
64982
  return __generator(this, function (_a) {
65010
64983
  switch (_a.label) {
65011
- 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)];
65012
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*/];
65013
65002
  }
65014
65003
  });
65015
65004
  }); };
65016
65005
  };
65017
65006
  try {
65018
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()) {
65019
- var governorMethod = governorMethods_1_1.value;
65020
- _loop_2(governorMethod);
65008
+ var methodName = governorMethods_1_1.value;
65009
+ _loop_2(methodName);
65021
65010
  }
65022
65011
  }
65023
65012
  catch (e_2_1) { e_2 = { error: e_2_1 }; }