tods-competition-factory 1.6.21 → 1.6.23

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.21';
365
+ return '1.6.23';
366
366
  }
367
367
 
368
368
  /******************************************************************************
@@ -10625,15 +10625,15 @@ function targetByRoundOutcome(_a) {
10625
10625
  matchUp: matchUp,
10626
10626
  targetLinks: { loserTargetLink: loserTargetLink, winnerTargetLink: winnerTargetLink, byeTargetLink: byeTargetLink },
10627
10627
  targetMatchUps: {
10628
- byeMatchUp: byeMatchUp,
10629
- loserMatchUp: loserMatchUp,
10630
- winnerMatchUp: winnerMatchUp,
10631
- byeTargetDrawPosition: byeTargetDrawPosition,
10632
- loserTargetDrawPosition: loserTargetDrawPosition,
10633
- winnerTargetDrawPosition: winnerTargetDrawPosition,
10634
- byeMatchUpDrawPositionIndex: byeMatchUpDrawPositionIndex,
10635
- loserMatchUpDrawPositionIndex: loserMatchUpDrawPositionIndex,
10636
10628
  winnerMatchUpDrawPositionIndex: winnerMatchUpDrawPositionIndex,
10629
+ loserMatchUpDrawPositionIndex: loserMatchUpDrawPositionIndex,
10630
+ byeMatchUpDrawPositionIndex: byeMatchUpDrawPositionIndex,
10631
+ winnerTargetDrawPosition: winnerTargetDrawPosition,
10632
+ loserTargetDrawPosition: loserTargetDrawPosition,
10633
+ byeTargetDrawPosition: byeTargetDrawPosition,
10634
+ winnerMatchUp: winnerMatchUp,
10635
+ loserMatchUp: loserMatchUp,
10636
+ byeMatchUp: byeMatchUp,
10637
10637
  },
10638
10638
  targetMatchUpIds: !!(winnerMatchUpId || loserMatchUpId),
10639
10639
  });
@@ -10641,9 +10641,9 @@ function targetByRoundOutcome(_a) {
10641
10641
  function targetByWinRatio(_a) {
10642
10642
  var matchUp = _a.matchUp;
10643
10643
  return {
10644
- matchUp: matchUp,
10645
10644
  targetLinks: { loserTargetLink: undefined, winnerTargetLink: undefined },
10646
10645
  targetMatchUps: { loserMatchUp: undefined, winnerMatchUp: undefined },
10646
+ matchUp: matchUp,
10647
10647
  };
10648
10648
  }
10649
10649
 
@@ -44836,6 +44836,30 @@ function generateAndPopulatePlayoffStructures(params) {
44836
44836
  if (result.error)
44837
44837
  console.log(result.error);
44838
44838
  });
44839
+ var byeMatchUps = inContextDrawMatchUps === null || inContextDrawMatchUps === void 0 ? void 0 : inContextDrawMatchUps.filter(function (matchUp) {
44840
+ return matchUp.matchUpStatus === BYE && matchUp.structureId === sourceStructureId;
44841
+ });
44842
+ byeMatchUps === null || byeMatchUps === void 0 ? void 0 : byeMatchUps.forEach(function (matchUp) {
44843
+ var matchUpId = matchUp.matchUpId;
44844
+ var targetData = positionTargets({
44845
+ inContextDrawMatchUps: inContextDrawMatchUps,
44846
+ drawDefinition: drawDefinition,
44847
+ matchUpId: matchUpId,
44848
+ });
44849
+ var loserTargetLink = targetData.targetLinks.loserTargetLink, _a = targetData.targetMatchUps, loserMatchUpDrawPositionIndex = _a.loserMatchUpDrawPositionIndex, // only present when positionTargets found without loserMatchUpId
44850
+ loserMatchUp = _a.loserMatchUp;
44851
+ var targetStructureId = loserTargetLink.target.structureId;
44852
+ var targetDrawPosition = loserMatchUp.drawPositions[loserMatchUpDrawPositionIndex];
44853
+ var result = assignDrawPositionBye$1({
44854
+ drawPosition: targetDrawPosition,
44855
+ structureId: targetStructureId,
44856
+ tournamentRecord: tournamentRecord,
44857
+ drawDefinition: drawDefinition,
44858
+ event: event,
44859
+ });
44860
+ if (result.error)
44861
+ console.log(result.error);
44862
+ });
44839
44863
  // the matchUps in the source structure must have goesTo details added
44840
44864
  var matchUpModifications = [];
44841
44865
  var goesToMap = addGoesTo({
@@ -45424,7 +45448,7 @@ function attachStructures$1(_a) {
45424
45448
  if (!drawDefinition)
45425
45449
  return { error: MISSING_DRAW_DEFINITION };
45426
45450
  if (!Array.isArray(structures) || !Array.isArray(links))
45427
- return { error: INVALID_VALUES };
45451
+ return decorateResult({ result: { error: INVALID_VALUES } });
45428
45452
  var stack = 'attachStructures';
45429
45453
  var linkHash = function (link) {
45430
45454
  var _a;
@@ -48517,12 +48541,22 @@ var DEFAULT_RATING = 0;
48517
48541
  var MAX_ITERATIONS = 5000;
48518
48542
  function generateDrawMaticRound(_a) {
48519
48543
  var e_1, _b, e_2, _c, e_3, _d;
48520
- var _e = _a.maxIterations, maxIterations = _e === void 0 ? MAX_ITERATIONS : _e, _f = _a.generateMatchUps, generateMatchUps = _f === void 0 ? true : _f, tournamentParticipants = _a.tournamentParticipants, tournamentRecord = _a.tournamentRecord, participantIds = _a.participantIds, addToStructure = _a.addToStructure, drawDefinition = _a.drawDefinition, adHocRatings = _a.adHocRatings, structureId = _a.structureId, matchUpIds = _a.matchUpIds, eventType = _a.eventType, structure = _a.structure;
48544
+ var _e;
48545
+ var _f = _a.maxIterations, maxIterations = _f === void 0 ? MAX_ITERATIONS : _f, _g = _a.generateMatchUps, generateMatchUps = _g === void 0 ? true : _g, tournamentParticipants = _a.tournamentParticipants, tournamentRecord = _a.tournamentRecord, participantIds = _a.participantIds, addToStructure = _a.addToStructure, drawDefinition = _a.drawDefinition, adHocRatings = _a.adHocRatings, structureId = _a.structureId, matchUpIds = _a.matchUpIds, eventType = _a.eventType, structure = _a.structure;
48546
+ if (!drawDefinition)
48547
+ return { error: MISSING_DRAW_DEFINITION };
48548
+ if (!structure && !structureId)
48549
+ return { error: STRUCTURE_NOT_FOUND };
48550
+ if (!structure) {
48551
+ structure = findStructure({ drawDefinition: drawDefinition, structureId: structureId }).structure;
48552
+ }
48553
+ if (!isObject(structure))
48554
+ return { error: MISSING_STRUCTURE };
48521
48555
  if (!(participantIds === null || participantIds === void 0 ? void 0 : participantIds.length)) {
48522
48556
  return { error: MISSING_PARTICIPANT_IDS };
48523
48557
  }
48524
48558
  // create valueObject for each previous encounter within the structure
48525
- var encounters = getEncounters({ matchUps: structure.matchUps }).encounters;
48559
+ var encounters = getEncounters({ matchUps: (_e = structure === null || structure === void 0 ? void 0 : structure.matchUps) !== null && _e !== void 0 ? _e : [] }).encounters;
48526
48560
  // valueObjects provide "weighting" to each possible pairing of participants
48527
48561
  // {
48528
48562
  // 'P-I-0|P-I-1': 1,
@@ -48587,9 +48621,9 @@ function generateDrawMaticRound(_a) {
48587
48621
  // 'P-I-0|P-I-2': 0,
48588
48622
  // 'P-I-0|P-I-3': 0
48589
48623
  // }
48590
- var _g = getPairingsData({
48624
+ var _h = getPairingsData({
48591
48625
  participantIds: participantIds,
48592
- }), uniquePairings = _g.uniquePairings, possiblePairings = _g.possiblePairings, deltaObjects = _g.deltaObjects;
48626
+ }), uniquePairings = _h.uniquePairings, possiblePairings = _h.possiblePairings, deltaObjects = _h.deltaObjects;
48593
48627
  var params = {
48594
48628
  tournamentParticipants: tournamentParticipants,
48595
48629
  possiblePairings: possiblePairings,
@@ -48603,18 +48637,18 @@ function generateDrawMaticRound(_a) {
48603
48637
  eventType: eventType,
48604
48638
  structure: structure,
48605
48639
  };
48606
- var _h = getPairings(params), candidatesCount = _h.candidatesCount, participantIdPairings = _h.participantIdPairings, iterations = _h.iterations;
48640
+ var _j = getPairings(params), candidatesCount = _j.candidatesCount, participantIdPairings = _j.participantIdPairings, iterations = _j.iterations;
48607
48641
  if (!candidatesCount)
48608
48642
  return { error: NO_CANDIDATES };
48609
48643
  var matchUps;
48610
48644
  if (generateMatchUps) {
48611
48645
  var result = generateAdHocMatchUps$1({
48646
+ structureId: structure === null || structure === void 0 ? void 0 : structure.structureId,
48612
48647
  participantIdPairings: participantIdPairings,
48613
48648
  tournamentRecord: tournamentRecord,
48614
48649
  addToStructure: addToStructure,
48615
48650
  newRound: true,
48616
48651
  drawDefinition: drawDefinition,
48617
- structureId: structureId,
48618
48652
  matchUpIds: matchUpIds,
48619
48653
  });
48620
48654
  if (result.error)
@@ -48759,8 +48793,8 @@ function getParticipantPairingValues(_a) {
48759
48793
 
48760
48794
  function drawMatic$1(_a) {
48761
48795
  var e_1, _b;
48762
- var _c, _d, _e, _f;
48763
- var tournamentParticipants = _a.tournamentParticipants, restrictEntryStatus = _a.restrictEntryStatus, tournamentRecord = _a.tournamentRecord, generateMatchUps = _a.generateMatchUps, addToStructure = _a.addToStructure, participantIds = _a.participantIds, drawDefinition = _a.drawDefinition, maxIterations = _a.maxIterations, structureId = _a.structureId, matchUpIds = _a.matchUpIds, scaleName = _a.scaleName, // custom rating name to seed dynamic ratings
48796
+ var _c, _d, _e, _f, _g;
48797
+ var tournamentParticipants = _a.tournamentParticipants, restrictEntryStatus = _a.restrictEntryStatus, tournamentRecord = _a.tournamentRecord, generateMatchUps = _a.generateMatchUps, addToStructure = _a.addToStructure, participantIds = _a.participantIds, drawDefinition = _a.drawDefinition, scaleAccessor = _a.scaleAccessor, maxIterations = _a.maxIterations, structureId = _a.structureId, matchUpIds = _a.matchUpIds, scaleName = _a.scaleName, // custom rating name to seed dynamic ratings
48764
48798
  eventType = _a.eventType, event = _a.event;
48765
48799
  if (typeof drawDefinition !== 'object' ||
48766
48800
  (drawDefinition.drawType && drawDefinition.drawType !== AD_HOC)) {
@@ -48808,6 +48842,8 @@ function drawMatic$1(_a) {
48808
48842
  var structureIsAdHoc = isAdHoc({ drawDefinition: drawDefinition, structure: structure });
48809
48843
  if (!structureIsAdHoc)
48810
48844
  return { error: INVALID_DRAW_DEFINITION };
48845
+ tournamentParticipants =
48846
+ (_g = tournamentParticipants !== null && tournamentParticipants !== void 0 ? tournamentParticipants : tournamentRecord.participants) !== null && _g !== void 0 ? _g : [];
48811
48847
  var adHocRatings = {};
48812
48848
  var _loop_1 = function (participantId) {
48813
48849
  var participant = tournamentParticipants === null || tournamentParticipants === void 0 ? void 0 : tournamentParticipants.find(function (participant) { return participant.participantId === participantId; });
@@ -48815,24 +48851,31 @@ function drawMatic$1(_a) {
48815
48851
  var scaleValue = getScaleValue({ eventType: eventType, participant: participant });
48816
48852
  // if no dynamic value found and a seeding scaleValue is provided...
48817
48853
  if (!scaleValue && scaleName) {
48818
- scaleValue = getScaleValue({ scaleName: scaleName, eventType: eventType, participant: participant });
48854
+ scaleValue = getScaleValue({
48855
+ scaleAccessor: scaleAccessor,
48856
+ participant: participant,
48857
+ scaleName: scaleName,
48858
+ eventType: eventType,
48859
+ });
48819
48860
  }
48820
48861
  if (scaleValue)
48821
48862
  adHocRatings[participantId] = scaleValue;
48822
48863
  };
48823
48864
  try {
48824
- for (var _g = __values(participantIds !== null && participantIds !== void 0 ? participantIds : []), _h = _g.next(); !_h.done; _h = _g.next()) {
48825
- var participantId = _h.value;
48865
+ for (var _h = __values(participantIds !== null && participantIds !== void 0 ? participantIds : []), _j = _h.next(); !_j.done; _j = _h.next()) {
48866
+ var participantId = _j.value;
48826
48867
  _loop_1(participantId);
48827
48868
  }
48828
48869
  }
48829
48870
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
48830
48871
  finally {
48831
48872
  try {
48832
- if (_h && !_h.done && (_b = _g.return)) _b.call(_g);
48873
+ if (_j && !_j.done && (_b = _h.return)) _b.call(_h);
48833
48874
  }
48834
48875
  finally { if (e_1) throw e_1.error; }
48835
48876
  }
48877
+ // TODO: update dynamic ratings based on matchUps present from last played round
48878
+ // use scaleEngine.processMatchUps(); see dynamicCalculations.test.ts
48836
48879
  return generateDrawMaticRound({
48837
48880
  tournamentParticipants: tournamentParticipants,
48838
48881
  tournamentRecord: tournamentRecord,
@@ -48842,7 +48885,6 @@ function drawMatic$1(_a) {
48842
48885
  drawDefinition: drawDefinition,
48843
48886
  maxIterations: maxIterations,
48844
48887
  adHocRatings: adHocRatings,
48845
- structureId: structureId,
48846
48888
  matchUpIds: matchUpIds,
48847
48889
  structure: structure,
48848
48890
  eventType: eventType,
@@ -48850,7 +48892,7 @@ function drawMatic$1(_a) {
48850
48892
  }
48851
48893
  function getScaleValue(_a) {
48852
48894
  var _b;
48853
- var _c = _a.scaleName, scaleName = _c === void 0 ? 'dynamic' : _c, eventType = _a.eventType, participant = _a.participant;
48895
+ var _c = _a.eventType, eventType = _c === void 0 ? TypeEnum.Singles : _c, _d = _a.scaleName, scaleName = _d === void 0 ? 'dynamic' : _d, scaleAccessor = _a.scaleAccessor, participant = _a.participant;
48854
48896
  var scaleAttributes = {
48855
48897
  eventType: eventType || TypeEnum.Singles,
48856
48898
  scaleType: RATING$2,
@@ -48861,7 +48903,10 @@ function getScaleValue(_a) {
48861
48903
  scaleAttributes: scaleAttributes,
48862
48904
  participant: participant,
48863
48905
  });
48864
- return (_b = result === null || result === void 0 ? void 0 : result.scaleItem) === null || _b === void 0 ? void 0 : _b.scaleValue;
48906
+ var scaleValue = (_b = result === null || result === void 0 ? void 0 : result.scaleItem) === null || _b === void 0 ? void 0 : _b.scaleValue;
48907
+ return scaleAccessor && isObject(scaleValue)
48908
+ ? scaleValue[scaleAccessor]
48909
+ : scaleValue;
48865
48910
  }
48866
48911
 
48867
48912
  function setDelegatedOutcome$1(_a) {
@@ -60528,7 +60573,7 @@ function getScaledEntries(_a) {
60528
60573
  .filter(function (scaledEntry) {
60529
60574
  var scaleValue = scaledEntry.scaleValue;
60530
60575
  // if a custom sort method is not provided, filter out entries with non-float values
60531
- if (!scaleSortMethod && scaleValue && typeof scaleValue !== 'number')
60576
+ if (!scaleSortMethod && (isNaN(scaleValue) || !parseFloat(scaleValue)))
60532
60577
  return false;
60533
60578
  return scaleValue;
60534
60579
  })
@@ -62368,13 +62413,21 @@ function generateDrawDefinition(params) {
62368
62413
  var participantIds_1 = entries_2 === null || entries_2 === void 0 ? void 0 : entries_2.map(extractAttributes('participantId'));
62369
62414
  var matchUpsCount_1 = entries_2 ? Math.floor(entries_2.length / 2) : 0;
62370
62415
  generateRange(1, params.roundsCount + 1).forEach(function () {
62416
+ var _a, _b, _c;
62371
62417
  if (params.automated) {
62418
+ var _d = (_a = params.drawMatic) !== null && _a !== void 0 ? _a : {}, restrictEntryStatus = _d.restrictEntryStatus, generateMatchUps = _d.generateMatchUps, addToStructure = _d.addToStructure, maxIterations = _d.maxIterations, structureId_1 = _d.structureId, matchUpIds = _d.matchUpIds, scaleName = _d.scaleName;
62372
62419
  drawMatic$1({
62373
- generateMatchUps: true,
62374
- eventType: matchUpType,
62375
62420
  tournamentRecord: tournamentRecord,
62376
62421
  participantIds: participantIds_1,
62377
62422
  drawDefinition: drawDefinition,
62423
+ eventType: (_c = (_b = params.drawMatic) === null || _b === void 0 ? void 0 : _b.eventType) !== null && _c !== void 0 ? _c : matchUpType,
62424
+ generateMatchUps: generateMatchUps !== null && generateMatchUps !== void 0 ? generateMatchUps : true,
62425
+ restrictEntryStatus: restrictEntryStatus,
62426
+ addToStructure: addToStructure,
62427
+ maxIterations: maxIterations,
62428
+ structureId: structureId_1,
62429
+ matchUpIds: matchUpIds,
62430
+ scaleName: scaleName,
62378
62431
  });
62379
62432
  }
62380
62433
  else {
@@ -62763,9 +62816,10 @@ var eventGovernor = {
62763
62816
  checkOutParticipant: checkOutParticipant,
62764
62817
  toggleParticipantCheckInState: toggleParticipantCheckInState$1,
62765
62818
  addDrawDefinitionTimeItem: addDrawDefinitionTimeItem,
62766
- generateDrawDefinition: generateDrawDefinition,
62767
- generateDrawStructuresAndLinks: generateDrawStructuresAndLinks,
62768
62819
  generateDrawTypeAndModifyDrawDefinition: generateDrawTypeAndModifyDrawDefinition,
62820
+ generateDrawStructuresAndLinks: generateDrawStructuresAndLinks,
62821
+ generateDrawMaticRound: generateDrawMaticRound,
62822
+ generateDrawDefinition: generateDrawDefinition,
62769
62823
  applyLineUps: applyLineUps,
62770
62824
  assignTieMatchUpParticipantId: assignTieMatchUpParticipantId,
62771
62825
  removeTieMatchUpParticipantId: removeTieMatchUpParticipantId,