tods-competition-factory 1.9.1 → 1.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1637,7 +1637,6 @@ function handleCaughtError$1(_a) {
1637
1637
  var globalState = {
1638
1638
  tournamentFactoryVersion: '0.0.0',
1639
1639
  timers: { default: { elapsedTime: 0 } },
1640
- iterators: { makeDeepCopy: 0 },
1641
1640
  deepCopyAttributes: {
1642
1641
  stringify: [],
1643
1642
  ignore: [],
@@ -1720,12 +1719,6 @@ function setGlobalLog(loggingFx) {
1720
1719
  function setDevContext(value) {
1721
1720
  globalState.devContext = value;
1722
1721
  }
1723
- function setDeepCopyIterations(value) {
1724
- globalState.iterators.makeDeepCopy = value;
1725
- }
1726
- function getDeepCopyIterations() {
1727
- return globalState.iterators.makeDeepCopy;
1728
- }
1729
1722
  function disableNotifications() {
1730
1723
  _globalStateProvider.disableNotifications();
1731
1724
  }
@@ -1821,7 +1814,14 @@ function handleCaughtError(_a) {
1821
1814
  }
1822
1815
  function globalLog$1(engine, log) {
1823
1816
  if (globalState.globalLog) {
1824
- return globalState.globalLog(engine, log);
1817
+ try {
1818
+ globalState.globalLog(engine, log);
1819
+ }
1820
+ catch (error) {
1821
+ console.log('globalLog error', error);
1822
+ console.log(engine, log);
1823
+ setGlobalLog(); // delete failing custom globalLog
1824
+ }
1825
1825
  }
1826
1826
  else {
1827
1827
  console.log(engine, log);
@@ -2193,18 +2193,6 @@ iteration // escape hatch - check against iteration threshold
2193
2193
  (typeof (deepCopy === null || deepCopy === void 0 ? void 0 : deepCopy.threshold) === 'number' && iteration >= deepCopy.threshold)) {
2194
2194
  return sourceObject;
2195
2195
  }
2196
- var devContext = getDevContext({ makeDeepCopy: true });
2197
- if (devContext) {
2198
- setDeepCopyIterations(iteration);
2199
- if (typeof devContext === 'object' &&
2200
- (iteration > (devContext.iterationThreshold || 15) ||
2201
- (devContext.firstIteration && iteration === 0)) &&
2202
- devContext.log &&
2203
- (!devContext.notInternalUse ||
2204
- (devContext.notInternalUse && !internalUse))) {
2205
- console.log({ devContext: devContext, iteration: iteration, internalUse: internalUse }, sourceObject);
2206
- }
2207
- }
2208
2196
  var targetObject = Array.isArray(sourceObject) ? [] : {};
2209
2197
  var sourceObjectKeys = Object.keys(sourceObject).filter(function (key) {
2210
2198
  return !internalUse ||
@@ -2958,7 +2946,7 @@ var matchUpFormatCode = {
2958
2946
  };
2959
2947
 
2960
2948
  function factoryVersion() {
2961
- return '1.9.1';
2949
+ return '1.9.2';
2962
2950
  }
2963
2951
 
2964
2952
  function getObjectTieFormat(obj) {
@@ -11712,8 +11700,8 @@ var toBePlayed = {
11712
11700
  };
11713
11701
 
11714
11702
  function modifyMatchUpScore(_a) {
11715
- var _b, e_1, _c;
11716
- var _d, _e, _f, _g, _h, _j, _k, _l;
11703
+ var e_1, _b;
11704
+ var _c, _d, _e, _f, _g, _h, _j, _k, _l;
11717
11705
  var matchUpStatusCodes = _a.matchUpStatusCodes, removeWinningSide = _a.removeWinningSide, tournamentRecord = _a.tournamentRecord, drawDefinition = _a.drawDefinition, matchUpFormat = _a.matchUpFormat, matchUpStatus = _a.matchUpStatus, removeScore = _a.removeScore, winningSide = _a.winningSide, matchUpId = _a.matchUpId, matchUp = _a.matchUp, // matchUp without context
11718
11706
  event = _a.event, notes = _a.notes, score = _a.score;
11719
11707
  var stack = 'modifyMatchUpScore';
@@ -11770,16 +11758,16 @@ function modifyMatchUpScore(_a) {
11770
11758
  matchUp.matchUpStatus = MatchUpStatusEnum.InProgress;
11771
11759
  }
11772
11760
  var defaultedProcessCodes;
11773
- if ((wasDefaulted && ((_d = matchUp === null || matchUp === void 0 ? void 0 : matchUp.processCodes) === null || _d === void 0 ? void 0 : _d.length)) ||
11761
+ if ((wasDefaulted && ((_c = matchUp === null || matchUp === void 0 ? void 0 : matchUp.processCodes) === null || _c === void 0 ? void 0 : _c.length)) ||
11774
11762
  matchUpStatus === DEFAULTED) {
11775
- var appliedPolicies = (_e = getAppliedPolicies({
11763
+ var appliedPolicies = (_d = getAppliedPolicies({
11776
11764
  tournamentRecord: tournamentRecord,
11777
11765
  drawDefinition: drawDefinition,
11778
11766
  structure: structure,
11779
11767
  event: event,
11780
- })) === null || _e === void 0 ? void 0 : _e.appliedPolicies;
11768
+ })) === null || _d === void 0 ? void 0 : _d.appliedPolicies;
11781
11769
  defaultedProcessCodes =
11782
- (_g = (_f = appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[POLICY_TYPE_SCORING]) === null || _f === void 0 ? void 0 : _f.processCodes) === null || _g === void 0 ? void 0 : _g.incompleteAssignmentsOnDefault;
11770
+ (_f = (_e = appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[POLICY_TYPE_SCORING]) === null || _e === void 0 ? void 0 : _e.processCodes) === null || _f === void 0 ? void 0 : _f.incompleteAssignmentsOnDefault;
11783
11771
  }
11784
11772
  if (!matchUp.collectionId) {
11785
11773
  var isRoundRobin = (structure === null || structure === void 0 ? void 0 : structure.structureType) === CONTAINER;
@@ -11838,7 +11826,7 @@ function modifyMatchUpScore(_a) {
11838
11826
  var matchUpsMap = (sendInContext || defaultedProcessCodes) &&
11839
11827
  getMatchUpsMap({ drawDefinition: drawDefinition });
11840
11828
  var inContextMatchUp = matchUpsMap &&
11841
- ((_h = getAllDrawMatchUps({
11829
+ ((_g = getAllDrawMatchUps({
11842
11830
  // client will not normally be receiving participants for the first time...
11843
11831
  // ... and should therefore already have groupings / ratings / rankings for participants
11844
11832
  // participantsProfile: { withGroupings: true },
@@ -11848,23 +11836,18 @@ function modifyMatchUpScore(_a) {
11848
11836
  inContext: true,
11849
11837
  drawDefinition: drawDefinition,
11850
11838
  matchUpsMap: matchUpsMap,
11851
- }).matchUps) === null || _h === void 0 ? void 0 : _h[0]);
11839
+ }).matchUps) === null || _g === void 0 ? void 0 : _g[0]);
11852
11840
  if (sendInContext && inContextMatchUp) {
11853
11841
  updateInContextMatchUp({ tournamentId: tournamentId, inContextMatchUp: inContextMatchUp });
11854
11842
  }
11855
11843
  if (Array.isArray(defaultedProcessCodes) &&
11856
11844
  inContextMatchUp &&
11857
- !((_j = inContextMatchUp.sides) === null || _j === void 0 ? void 0 : _j.every(function (_a) {
11845
+ !((_h = inContextMatchUp.sides) === null || _h === void 0 ? void 0 : _h.every(function (_a) {
11858
11846
  var participantId = _a.participantId;
11859
11847
  return participantId;
11860
11848
  }))) {
11861
11849
  if (matchUpStatus === DEFAULTED) {
11862
- if (matchUp.processCodes) {
11863
- (_b = matchUp.processCodes).push.apply(_b, __spreadArray([], __read(defaultedProcessCodes), false));
11864
- }
11865
- else {
11866
- matchUp.processCodes = defaultedProcessCodes;
11867
- }
11850
+ matchUp.processCodes = unique(__spreadArray(__spreadArray([], __read(((_j = matchUp.processCodes) !== null && _j !== void 0 ? _j : [])), false), __read(defaultedProcessCodes), false));
11868
11851
  }
11869
11852
  else {
11870
11853
  try {
@@ -11878,7 +11861,7 @@ function modifyMatchUpScore(_a) {
11878
11861
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
11879
11862
  finally {
11880
11863
  try {
11881
- if (_o && !_o.done && (_c = _m.return)) _c.call(_m);
11864
+ if (_o && !_o.done && (_b = _m.return)) _b.call(_m);
11882
11865
  }
11883
11866
  finally { if (e_1) throw e_1.error; }
11884
11867
  }
@@ -29168,6 +29151,43 @@ function updateFactoryExtension(_a) {
29168
29151
  addExtension$1({ element: tournamentRecord, extension: updatedExtension });
29169
29152
  }
29170
29153
 
29154
+ function engineLogging(_a) {
29155
+ var _b, _c;
29156
+ var methodName = _a.methodName, elapsed = _a.elapsed, engine = _a.engine, params = _a.params, result = _a.result;
29157
+ var devContext = getDevContext();
29158
+ if (typeof devContext !== 'object')
29159
+ return;
29160
+ var log = { method: methodName };
29161
+ var logError = (result === null || result === void 0 ? void 0 : result.error) &&
29162
+ (devContext.errors === true ||
29163
+ (Array.isArray(devContext.errors) &&
29164
+ devContext.errors.includes(methodName)));
29165
+ var specifiedMethodParams = Array.isArray(devContext.params) && ((_b = devContext.params) === null || _b === void 0 ? void 0 : _b.includes(methodName));
29166
+ var logParams = (devContext.params && !Array.isArray(devContext.params)) ||
29167
+ specifiedMethodParams;
29168
+ var exclude = Array.isArray(devContext.exclude) &&
29169
+ devContext.exclude.includes(methodName);
29170
+ if (!exclude &&
29171
+ ![undefined, false].includes(devContext.perf) &&
29172
+ (isNaN(devContext.perf) || elapsed > devContext.perf)) {
29173
+ log.elapsed = elapsed;
29174
+ }
29175
+ if (!exclude && (logError || logParams)) {
29176
+ log.params = params;
29177
+ }
29178
+ if (!exclude &&
29179
+ (logError ||
29180
+ (devContext.result &&
29181
+ !Array.isArray(devContext.result) &&
29182
+ (!Array.isArray(devContext.params) || specifiedMethodParams)) ||
29183
+ (Array.isArray(devContext.result) &&
29184
+ ((_c = devContext.result) === null || _c === void 0 ? void 0 : _c.includes(methodName))))) {
29185
+ log.result = result;
29186
+ }
29187
+ if (Object.keys(log).length > 1)
29188
+ globalLog$1(engine, log);
29189
+ }
29190
+
29171
29191
  var _a$2;
29172
29192
  function notifySubscribers(params) {
29173
29193
  var e_1, _a;
@@ -44098,42 +44118,6 @@ function setState$4(records, deepCopyOption) {
44098
44118
  return setTournamentRecords(deepCopyOption ? makeDeepCopy(records) : records);
44099
44119
  }
44100
44120
 
44101
- function engineLogging(_a) {
44102
- var _b, _c;
44103
- var result = _a.result, methodName = _a.methodName, elapsed = _a.elapsed, params = _a.params, engine = _a.engine;
44104
- var devContext = getDevContext();
44105
- var log = { method: methodName };
44106
- var logError = (result === null || result === void 0 ? void 0 : result.error) &&
44107
- (devContext.errors === true ||
44108
- (Array.isArray(devContext.errors) &&
44109
- devContext.errors.includes(methodName)));
44110
- var specifiedMethodParams = Array.isArray(devContext.params) && ((_b = devContext.params) === null || _b === void 0 ? void 0 : _b.includes(methodName));
44111
- var logParams = (devContext.params && !Array.isArray(devContext.params)) ||
44112
- specifiedMethodParams;
44113
- var exclude = Array.isArray(devContext.exclude) &&
44114
- devContext.exclude.includes(methodName);
44115
- if (!exclude &&
44116
- ![undefined, false].includes(devContext.perf) &&
44117
- (isNaN(devContext.perf) || elapsed > devContext.perf))
44118
- log.elapsed = elapsed;
44119
- if (!exclude && (logError || logParams)) {
44120
- log.params = params;
44121
- }
44122
- if (!exclude &&
44123
- (logError ||
44124
- (devContext.result &&
44125
- !Array.isArray(devContext.result) &&
44126
- (!Array.isArray(devContext.params) || specifiedMethodParams)) ||
44127
- (Array.isArray(devContext.result) &&
44128
- ((_c = devContext.result) === null || _c === void 0 ? void 0 : _c.includes(methodName))))) {
44129
- log.result = result;
44130
- }
44131
- if (Object.keys(log).length > 1)
44132
- globalLog$1(engine, log);
44133
- if (result && devContext.makeDeepCopy)
44134
- result.deepCopyIterations = getDeepCopyIterations();
44135
- }
44136
-
44137
44121
  var competitionEngine = (function () {
44138
44122
  var engine = {
44139
44123
  getState: function (params) {
@@ -44263,11 +44247,11 @@ var competitionEngine = (function () {
44263
44247
  }
44264
44248
  function executionQueue(directives, rollbackOnError) {
44265
44249
  var e_1, _a;
44266
- var _b;
44267
44250
  if (!Array.isArray(directives))
44268
44251
  return { error: INVALID_VALUES };
44269
44252
  var tournamentRecords = getTournamentRecords();
44270
44253
  var activeTournamentId = getTournamentId();
44254
+ var start = Date.now();
44271
44255
  var snapshot = rollbackOnError && makeDeepCopy(tournamentRecords, false, true);
44272
44256
  var timeStamp;
44273
44257
  var results = [];
@@ -44279,12 +44263,8 @@ var competitionEngine = (function () {
44279
44263
  var methodName = directive.method, params = directive.params;
44280
44264
  if (!engine[methodName]) {
44281
44265
  var result_1 = { error: METHOD_NOT_FOUND, methodName: methodName };
44282
- var devContext = getDevContext();
44283
- if ((devContext.result && !Array.isArray(devContext.result)) ||
44284
- (Array.isArray(devContext.result) &&
44285
- ((_b = devContext.result) === null || _b === void 0 ? void 0 : _b.includes(methodName)))) {
44286
- console.log('ce:', result_1);
44287
- }
44266
+ var elapsed = Date.now() - start;
44267
+ engineLogging({ result: result_1, methodName: methodName, elapsed: elapsed, params: params, engine: 'ce:' });
44288
44268
  return result_1;
44289
44269
  }
44290
44270
  var result_2 = executeFunction(tournamentRecords, engine[methodName], __assign({ activeTournamentId: activeTournamentId }, params), methodName);
@@ -61410,11 +61390,9 @@ function replaceTieMatchUpParticipantId(params) {
61410
61390
  }
61411
61391
  if (substitution || ((_u = side.substitutions) === null || _u === void 0 ? void 0 : _u.length) === 1) {
61412
61392
  if (substitution) {
61413
- var processCodes = (_v = tieMatchUp === null || tieMatchUp === void 0 ? void 0 : tieMatchUp.processCodes) !== null && _v !== void 0 ? _v : [];
61414
- if (substitutionProcessCodes)
61415
- processCodes.push.apply(processCodes, __spreadArray([], __read(substitutionProcessCodes), false));
61416
- if (tieMatchUp)
61417
- tieMatchUp.processCodes = processCodes;
61393
+ if (substitutionProcessCodes && tieMatchUp) {
61394
+ tieMatchUp.processCodes = unique(__spreadArray(__spreadArray([], __read(((_v = tieMatchUp === null || tieMatchUp === void 0 ? void 0 : tieMatchUp.processCodes) !== null && _v !== void 0 ? _v : [])), false), __read(substitutionProcessCodes), false));
61395
+ }
61418
61396
  }
61419
61397
  else {
61420
61398
  try {
@@ -67106,9 +67084,9 @@ var tournamentEngine = (function () {
67106
67084
  }
67107
67085
  function executionQueue(directives, rollbackOnError) {
67108
67086
  var e_1, _a;
67109
- var _b;
67110
67087
  if (!Array.isArray(directives))
67111
67088
  return { error: INVALID_VALUES };
67089
+ var start = Date.now();
67112
67090
  var tournamentId = getTournamentId();
67113
67091
  var tournamentRecord = getTournamentRecord(tournamentId);
67114
67092
  var snapshot = rollbackOnError && makeDeepCopy(tournamentRecord, false, true);
@@ -67121,12 +67099,8 @@ var tournamentEngine = (function () {
67121
67099
  var methodName = directive.method, params = directive.params;
67122
67100
  if (!engine[methodName]) {
67123
67101
  var result_1 = { error: METHOD_NOT_FOUND, methodName: methodName };
67124
- var devContext = getDevContext();
67125
- if ((devContext.result && !Array.isArray(devContext.result)) ||
67126
- (Array.isArray(devContext.result) &&
67127
- ((_b = devContext.result) === null || _b === void 0 ? void 0 : _b.includes(methodName)))) {
67128
- console.log('te:', result_1);
67129
- }
67102
+ var elapsed = Date.now() - start;
67103
+ engineLogging({ result: result_1, methodName: methodName, elapsed: elapsed, params: params, engine: 'te:' });
67130
67104
  return result_1;
67131
67105
  }
67132
67106
  var result_2 = executeFunction(tournamentRecord, engine[methodName], params, methodName);