tods-competition-factory 1.7.5 → 1.7.6

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.7.5';
365
+ return '1.7.6';
366
366
  }
367
367
 
368
368
  /******************************************************************************
@@ -5289,7 +5289,7 @@ var _a$j, _b$6;
5289
5289
  var POLICY_COMPETITIVE_BANDS_DEFAULT = (_a$j = {},
5290
5290
  _a$j[POLICY_TYPE_COMPETITIVE_BANDS] = {
5291
5291
  policyName: 'Competitive Bands Default',
5292
- competitiveProfile: (_b$6 = {},
5292
+ profileBands: (_b$6 = {},
5293
5293
  _b$6[DECISIVE] = 20,
5294
5294
  _b$6[ROUTINE] = 50,
5295
5295
  _b$6),
@@ -5374,7 +5374,7 @@ function pctSpread(pcts) {
5374
5374
  return pcts
5375
5375
  .map(gamesPercent)
5376
5376
  .sort()
5377
- .map(function (p) { return p.toFixed(2); });
5377
+ .map(function (p) { return parseFloat(p.toFixed(2)); });
5378
5378
  }
5379
5379
 
5380
5380
  function findPolicy(_a) {
@@ -5392,27 +5392,27 @@ function findPolicy(_a) {
5392
5392
  : { error: POLICY_NOT_FOUND };
5393
5393
  }
5394
5394
 
5395
- function getMatchUpCompetitiveness(_a) {
5396
- var competitiveProfile = _a.competitiveProfile, tournamentRecord = _a.tournamentRecord, matchUp = _a.matchUp;
5395
+ function getMatchUpCompetitiveProfile(_a) {
5396
+ var profileBands = _a.profileBands, tournamentRecord = _a.tournamentRecord, matchUp = _a.matchUp;
5397
5397
  if (!matchUp)
5398
5398
  return { error: MISSING_MATCHUP };
5399
5399
  var score = matchUp.score, winningSide = matchUp.winningSide;
5400
5400
  if (!winningSide)
5401
5401
  return { error: INVALID_VALUES };
5402
- var policy = !competitiveProfile &&
5402
+ var policy = !profileBands &&
5403
5403
  tournamentRecord &&
5404
5404
  findPolicy({
5405
5405
  policyType: POLICY_TYPE_COMPETITIVE_BANDS,
5406
5406
  tournamentRecord: tournamentRecord,
5407
5407
  }).policy;
5408
- var bandProfiles = competitiveProfile ||
5409
- (policy === null || policy === void 0 ? void 0 : policy.competitiveProfile) ||
5408
+ var bandProfiles = profileBands ||
5409
+ (policy === null || policy === void 0 ? void 0 : policy.profileBands) ||
5410
5410
  POLICY_COMPETITIVE_BANDS_DEFAULT[POLICY_TYPE_COMPETITIVE_BANDS]
5411
- .competitiveProfile;
5411
+ .profileBands;
5412
5412
  var scoreComponents = getScoreComponents({ score: score });
5413
5413
  var spread = pctSpread([scoreComponents]);
5414
5414
  var competitiveness = getBand(spread, bandProfiles);
5415
- return __assign(__assign({}, SUCCESS), { competitiveness: competitiveness });
5415
+ return __assign(__assign({}, SUCCESS), { competitiveness: competitiveness, pctSpread: spread });
5416
5416
  }
5417
5417
 
5418
5418
  function findMatchupFormatAverageTimes(params) {
@@ -9436,8 +9436,8 @@ function getAllStructureMatchUps(_a) {
9436
9436
  (((_m = drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.processCodes) === null || _m === void 0 ? void 0 : _m.length) && (drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.processCodes)) ||
9437
9437
  (((_o = event === null || event === void 0 ? void 0 : event.processCodes) === null || _o === void 0 ? void 0 : _o.length) && (event === null || event === void 0 ? void 0 : event.processCodes)) ||
9438
9438
  (tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.processCodes);
9439
- var competitiveness = (contextProfile === null || contextProfile === void 0 ? void 0 : contextProfile.withCompetitiveness) &&
9440
- getMatchUpCompetitiveness(__assign(__assign({}, contextContent), { matchUp: matchUp })).competitiveness;
9439
+ var competitiveProfile = (contextProfile === null || contextProfile === void 0 ? void 0 : contextProfile.withCompetitiveness) &&
9440
+ getMatchUpCompetitiveProfile(__assign(__assign({}, contextContent), { matchUp: matchUp }));
9441
9441
  // necessry for SINGLES/DOUBLES matchUps that are part of TEAM tournaments
9442
9442
  var finishingPositionRange = matchUp.finishingPositionRange ||
9443
9443
  additionalContext.finishingPositionRange;
@@ -9456,7 +9456,7 @@ function getAllStructureMatchUps(_a) {
9456
9456
  finishingPositionRange: finishingPositionRange,
9457
9457
  abbreviatedRoundName: abbreviatedRoundName,
9458
9458
  drawPositionsRange: drawPositionsRange,
9459
- competitiveness: competitiveness,
9459
+ competitiveProfile: competitiveProfile,
9460
9460
  structureName: structureName,
9461
9461
  stageSequence: stageSequence,
9462
9462
  drawPositions: drawPositions,
@@ -14954,13 +14954,19 @@ var ratingConstants = {
14954
14954
 
14955
14955
  var _a$g;
14956
14956
  var ratingsParameters = (_a$g = {},
14957
- _a$g[ELO] = { range: [0, 3000], decimalsCount: 0, defaultInitialization: 1500 },
14957
+ _a$g[ELO] = {
14958
+ defaultInitialization: 1500,
14959
+ decimalsCount: 0,
14960
+ range: [0, 3000],
14961
+ ascending: true,
14962
+ },
14958
14963
  _a$g[NTRP] = {
14959
14964
  accessors: ['ntrpRating', 'dntrpRatingHundredths'],
14960
14965
  attributes: { ustaRatingType: '' },
14961
14966
  accessor: 'dntrpRatingHundredths',
14962
14967
  defaultInitialization: 3,
14963
14968
  decimalsCount: 1,
14969
+ ascending: true,
14964
14970
  range: [1, 7],
14965
14971
  },
14966
14972
  _a$g[UTR] = {
@@ -14968,6 +14974,7 @@ var ratingsParameters = (_a$g = {},
14968
14974
  accessors: ['utrRating'],
14969
14975
  accessor: 'utrRating',
14970
14976
  decimalsCount: 2,
14977
+ ascending: true,
14971
14978
  range: [1, 16],
14972
14979
  },
14973
14980
  _a$g[WTN] = {
@@ -14975,6 +14982,7 @@ var ratingsParameters = (_a$g = {},
14975
14982
  accessors: ['wtnRating', 'confidence'],
14976
14983
  defaultInitialization: 23,
14977
14984
  accessor: 'wtnRating',
14985
+ ascending: false,
14978
14986
  decimalsCount: 2,
14979
14987
  range: [40, 1],
14980
14988
  },
@@ -34844,7 +34852,7 @@ function checkSchedulingProfile$1(_a) {
34844
34852
 
34845
34853
  function scheduledSortedMatchUps(_a) {
34846
34854
  var e_1, _b, e_2, _c, e_3, _d, e_4, _e;
34847
- var _f = _a.matchUps, matchUps = _f === void 0 ? [] : _f, schedulingProfile = _a.schedulingProfile;
34855
+ var schedulingProfile = _a.schedulingProfile, _f = _a.matchUps, matchUps = _f === void 0 ? [] : _f;
34848
34856
  var profileHash = {};
34849
34857
  // hash is used to store a sort order value for scheduled rounds
34850
34858
  var getHash = function (_a) {
@@ -50543,6 +50551,10 @@ function removeDelegatedOutcome$1(_a) {
50543
50551
  });
50544
50552
  }
50545
50553
 
50554
+ function stringSort(a, b) {
50555
+ return (a || '').localeCompare(b || '');
50556
+ }
50557
+
50546
50558
  function generateCandidate(_a) {
50547
50559
  var _b = _a.maxIterations, maxIterations = _b === void 0 ? 4000 : _b, // cap the processing intensity of the candidate generator
50548
50560
  valueSortedPairings = _a.valueSortedPairings, // pairings sorted by value from low to high
@@ -50686,7 +50698,7 @@ function roundCandidate(_a) {
50686
50698
  return { value: candidateValue, participantIdPairings: participantIdPairings, maxDelta: maxDelta, maxDiff: maxDiff };
50687
50699
  }
50688
50700
  function pairingHash(id1, id2) {
50689
- return [id1, id2].sort().join('|');
50701
+ return [id1, id2].sort(stringSort).join('|');
50690
50702
  }
50691
50703
 
50692
50704
  function getPairingsData(_a) {
@@ -57365,6 +57377,30 @@ function setTournamentStatus(_a) {
57365
57377
  return __assign({}, SUCCESS);
57366
57378
  }
57367
57379
 
57380
+ // TODO: ability to add onlineResources to other items, e.g. organisations, participants, persons, venues, courts
57381
+ function addOnlineResource(_a) {
57382
+ var tournamentRecord = _a.tournamentRecord, onlineResource = _a.onlineResource;
57383
+ if (!tournamentRecord)
57384
+ return { error: MISSING_TOURNAMENT_RECORD };
57385
+ if (!onlineResource)
57386
+ return { error: MISSING_VALUE };
57387
+ if (!tournamentRecord.onlineResources)
57388
+ tournamentRecord.onlineResources = [];
57389
+ // TODO: onlineResource validation
57390
+ tournamentRecord.onlineResources.push(onlineResource);
57391
+ return __assign({}, SUCCESS);
57392
+ /**
57393
+ [
57394
+ {
57395
+ identifier:
57396
+ resourceSubType: 'IMAGE',
57397
+ name: 'tournamentImage',
57398
+ resourceType: 'URL',
57399
+ },
57400
+ ];
57401
+ */
57402
+ }
57403
+
57368
57404
  function analyzeDraws(_a) {
57369
57405
  var _b;
57370
57406
  var tournamentRecord = _a.tournamentRecord;
@@ -57722,10 +57758,11 @@ function removeInvalidScheduling(_a) {
57722
57758
 
57723
57759
  // undocumented access to mocksEngine method
57724
57760
  var tournamentGovernor = {
57725
- addNotes: addNotes,
57726
- removeNotes: removeNotes,
57727
- analyzeDraws: analyzeDraws,
57728
57761
  analyzeTournament: analyzeTournament,
57762
+ analyzeDraws: analyzeDraws,
57763
+ addOnlineResource: addOnlineResource,
57764
+ removeNotes: removeNotes,
57765
+ addNotes: addNotes,
57729
57766
  completeDrawMatchUps: completeDrawMatchUps,
57730
57767
  getRounds: getRounds,
57731
57768
  getProfileRounds: getProfileRounds,
@@ -63138,21 +63175,24 @@ function getMaxEntryPosition(params) {
63138
63175
  }
63139
63176
 
63140
63177
  function getPredictiveAccuracy(params) {
63141
- var _a, _b, _c, _d;
63178
+ var _a, _b, _c, _d, _e, _f, _g;
63142
63179
  var matchUps = params.matchUps;
63143
- var tournamentRecord = params.tournamentRecord, _e = params.ascending, ascending = _e === void 0 ? true : _e, drawDefinition = params.drawDefinition, excludeMargin = params.excludeMargin, exclusionRule = params.exclusionRule, valueAccessor = params.valueAccessor, zoneDoubling = params.zoneDoubling, matchUpType = params.matchUpType, zoneMargin = params.zoneMargin, scaleName = params.scaleName, eventId = params.eventId, drawId = params.drawId, event = params.event;
63180
+ var tournamentRecord = params.tournamentRecord, drawDefinition = params.drawDefinition, excludeMargin = params.excludeMargin, exclusionRule = params.exclusionRule, zoneDoubling = params.zoneDoubling, matchUpType = params.matchUpType, zoneMargin = params.zoneMargin, scaleName = params.scaleName, eventId = params.eventId, drawId = params.drawId, event = params.event;
63144
63181
  if (!tournamentRecord && !matchUps)
63145
63182
  return { error: MISSING_TOURNAMENT_RECORD };
63146
63183
  if (matchUpType && ![SINGLES$1, DOUBLES$1].includes(matchUpType))
63147
63184
  return { error: INVALID_VALUES, info: { matchUpType: matchUpType } };
63148
63185
  if (matchUps && !validMatchUps(matchUps))
63149
63186
  return { error: INVALID_VALUES, context: { matchUps: matchUps } };
63187
+ var scaleProfile = ratingsParameters[scaleName];
63188
+ var ascending = (_b = (_a = scaleProfile === null || scaleProfile === void 0 ? void 0 : scaleProfile.ascending) !== null && _a !== void 0 ? _a : params.ascending) !== null && _b !== void 0 ? _b : false;
63189
+ var valueAccessor = (_c = scaleProfile === null || scaleProfile === void 0 ? void 0 : scaleProfile.accessor) !== null && _c !== void 0 ? _c : params.valueAccessor;
63150
63190
  var contextProfile = { withScaleValues: true, withCompetitiveness: true };
63151
63191
  var contextFilters = {
63152
63192
  matchUpTypes: matchUpType ? [matchUpType] : [SINGLES$1, DOUBLES$1],
63153
63193
  };
63154
63194
  var participants = tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.participants;
63155
- if ((_a = matchUps === null || matchUps === void 0 ? void 0 : matchUps[0]) === null || _a === void 0 ? void 0 : _a.hasContext) {
63195
+ if ((_d = matchUps === null || matchUps === void 0 ? void 0 : matchUps[0]) === null || _d === void 0 ? void 0 : _d.hasContext) {
63156
63196
  if (drawId) {
63157
63197
  matchUps = matchUps.filter(function (matchUp) { return matchUp.drawId === drawId; });
63158
63198
  }
@@ -63165,27 +63205,27 @@ function getPredictiveAccuracy(params) {
63165
63205
  (drawId && !drawDefinition && []) ||
63166
63206
  (!drawId && eventId && !event && []) ||
63167
63207
  (drawId &&
63168
- ((_b = allDrawMatchUps$1({
63208
+ ((_e = allDrawMatchUps$1({
63169
63209
  inContext: true,
63170
63210
  drawDefinition: drawDefinition,
63171
63211
  contextFilters: contextFilters,
63172
63212
  contextProfile: contextProfile,
63173
63213
  participants: participants,
63174
- })) === null || _b === void 0 ? void 0 : _b.matchUps)) ||
63214
+ })) === null || _e === void 0 ? void 0 : _e.matchUps)) ||
63175
63215
  (!drawId &&
63176
63216
  eventId &&
63177
- ((_c = allEventMatchUps({
63217
+ ((_f = allEventMatchUps({
63178
63218
  inContext: true,
63179
63219
  contextFilters: contextFilters,
63180
63220
  contextProfile: contextProfile,
63181
63221
  participants: participants,
63182
63222
  event: event,
63183
- })) === null || _c === void 0 ? void 0 : _c.matchUps)) ||
63184
- ((_d = allTournamentMatchUps({
63223
+ })) === null || _f === void 0 ? void 0 : _f.matchUps)) ||
63224
+ ((_g = allTournamentMatchUps({
63185
63225
  tournamentRecord: tournamentRecord,
63186
63226
  contextFilters: contextFilters,
63187
63227
  contextProfile: contextProfile,
63188
- })) === null || _d === void 0 ? void 0 : _d.matchUps) ||
63228
+ })) === null || _g === void 0 ? void 0 : _g.matchUps) ||
63189
63229
  [];
63190
63230
  }
63191
63231
  if (matchUpType) {
@@ -63210,7 +63250,7 @@ function getPredictiveAccuracy(params) {
63210
63250
  var zoneData = zoneMargin &&
63211
63251
  relevantMatchUps
63212
63252
  .map(function (_a) {
63213
- var competitiveness = _a.competitiveness, matchUpType = _a.matchUpType, score = _a.score, sides = _a.sides;
63253
+ var competitiveProfile = _a.competitiveProfile, matchUpType = _a.matchUpType, score = _a.score, sides = _a.sides;
63214
63254
  var sideValues = getSideValues({
63215
63255
  valueAccessor: valueAccessor,
63216
63256
  matchUpType: matchUpType,
@@ -63218,7 +63258,11 @@ function getPredictiveAccuracy(params) {
63218
63258
  sides: sides,
63219
63259
  });
63220
63260
  var valuesGap = Math.abs(sideValues[0].value - sideValues[1].value);
63221
- return { competitiveness: competitiveness, score: score, valuesGap: valuesGap };
63261
+ return {
63262
+ competitiveness: competitiveProfile === null || competitiveProfile === void 0 ? void 0 : competitiveProfile.competitiveness,
63263
+ valuesGap: valuesGap,
63264
+ score: score,
63265
+ };
63222
63266
  })
63223
63267
  .filter(function (_a) {
63224
63268
  var valuesGap = _a.valuesGap;
@@ -63410,8 +63454,8 @@ function getGroupingAccuracy(_a) {
63410
63454
  });
63411
63455
  continue;
63412
63456
  }
63413
- // when ascending is true winning value will be less than losing value
63414
- var signedGap = ascending ? valuesGap * -1 : valuesGap;
63457
+ // when ascending is true winning value will be greater than losing value
63458
+ var signedGap = ascending ? valuesGap : valuesGap * -1;
63415
63459
  var winningScoreString = winningSide === 1 ? score === null || score === void 0 ? void 0 : score.scoreStringSide1 : score === null || score === void 0 ? void 0 : score.scoreStringSide2;
63416
63460
  if (signedGap > 0) {
63417
63461
  accuracy.affirmative.push({
@@ -63506,18 +63550,18 @@ function getMatchUpFormat(_a) {
63506
63550
 
63507
63551
  function getMatchUpsStats(_a) {
63508
63552
  var _b, _c;
63509
- var competitiveProfile = _a.competitiveProfile, tournamentRecord = _a.tournamentRecord, matchUps = _a.matchUps;
63553
+ var profileBands = _a.profileBands, tournamentRecord = _a.tournamentRecord, matchUps = _a.matchUps;
63510
63554
  if (!validMatchUps(matchUps))
63511
63555
  return { error: MISSING_MATCHUPS };
63512
- var policy = !competitiveProfile &&
63556
+ var policy = !profileBands &&
63513
63557
  findPolicy({
63514
63558
  policyType: POLICY_TYPE_COMPETITIVE_BANDS,
63515
63559
  tournamentRecord: tournamentRecord,
63516
63560
  }).policy;
63517
- var bandProfiles = competitiveProfile ||
63518
- (policy === null || policy === void 0 ? void 0 : policy.competitiveProfile) ||
63561
+ var bandProfiles = profileBands ||
63562
+ (policy === null || policy === void 0 ? void 0 : policy.profileBands) ||
63519
63563
  POLICY_COMPETITIVE_BANDS_DEFAULT[POLICY_TYPE_COMPETITIVE_BANDS]
63520
- .competitiveProfile;
63564
+ .profileBands;
63521
63565
  var relevantMatchUps = matchUps.filter(function (_a) {
63522
63566
  var winningSide = _a.winningSide;
63523
63567
  return winningSide;
@@ -63710,7 +63754,7 @@ var queryGovernor = {
63710
63754
  getPositionAssignments: getPositionAssignments,
63711
63755
  isValidMatchUpFormat: isValid,
63712
63756
  getMaxEntryPosition: getMaxEntryPosition,
63713
- getMatchUpCompetitiveness: getMatchUpCompetitiveness,
63757
+ getMatchUpCompetitiveProfile: getMatchUpCompetitiveProfile,
63714
63758
  findVenue: findVenue,
63715
63759
  getCourts: getCourts,
63716
63760
  getVenuesAndCourts: getVenuesAndCourts$1,