tods-competition-factory 1.6.22 → 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.
package/dist/index.mjs CHANGED
@@ -329,7 +329,7 @@ const matchUpFormatCode = {
329
329
  };
330
330
 
331
331
  function factoryVersion() {
332
- return "1.6.22";
332
+ return "1.6.23";
333
333
  }
334
334
 
335
335
  function getObjectTieFormat(obj) {
@@ -9144,25 +9144,25 @@ function targetByRoundOutcome({
9144
9144
  matchUp,
9145
9145
  targetLinks: { loserTargetLink, winnerTargetLink, byeTargetLink },
9146
9146
  targetMatchUps: {
9147
- byeMatchUp,
9148
- loserMatchUp,
9149
- winnerMatchUp,
9150
- byeTargetDrawPosition,
9151
- loserTargetDrawPosition,
9152
- winnerTargetDrawPosition,
9153
- byeMatchUpDrawPositionIndex,
9147
+ winnerMatchUpDrawPositionIndex,
9154
9148
  loserMatchUpDrawPositionIndex,
9155
- winnerMatchUpDrawPositionIndex
9149
+ byeMatchUpDrawPositionIndex,
9150
+ winnerTargetDrawPosition,
9151
+ loserTargetDrawPosition,
9152
+ byeTargetDrawPosition,
9153
+ winnerMatchUp,
9154
+ loserMatchUp,
9155
+ byeMatchUp
9156
9156
  },
9157
9157
  targetMatchUpIds: !!(winnerMatchUpId || loserMatchUpId)
9158
9158
  });
9159
9159
  }
9160
9160
  function targetByWinRatio({ matchUp }) {
9161
9161
  return {
9162
- matchUp,
9163
9162
  targetLinks: { loserTargetLink: void 0, winnerTargetLink: void 0 },
9164
9163
  // returned for testing
9165
- targetMatchUps: { loserMatchUp: void 0, winnerMatchUp: void 0 }
9164
+ targetMatchUps: { loserMatchUp: void 0, winnerMatchUp: void 0 },
9165
+ matchUp
9166
9166
  };
9167
9167
  }
9168
9168
 
@@ -41522,6 +41522,36 @@ function generateAndPopulatePlayoffStructures(params) {
41522
41522
  if (result.error)
41523
41523
  console.log(result.error);
41524
41524
  });
41525
+ const byeMatchUps = inContextDrawMatchUps?.filter(
41526
+ (matchUp) => matchUp.matchUpStatus === BYE && matchUp.structureId === sourceStructureId
41527
+ );
41528
+ byeMatchUps?.forEach((matchUp) => {
41529
+ const { matchUpId } = matchUp;
41530
+ const targetData = positionTargets({
41531
+ inContextDrawMatchUps,
41532
+ drawDefinition,
41533
+ matchUpId
41534
+ });
41535
+ const {
41536
+ targetLinks: { loserTargetLink },
41537
+ targetMatchUps: {
41538
+ loserMatchUpDrawPositionIndex,
41539
+ // only present when positionTargets found without loserMatchUpId
41540
+ loserMatchUp
41541
+ }
41542
+ } = targetData;
41543
+ const targetStructureId = loserTargetLink.target.structureId;
41544
+ const targetDrawPosition = loserMatchUp.drawPositions[loserMatchUpDrawPositionIndex];
41545
+ const result = assignDrawPositionBye$1({
41546
+ drawPosition: targetDrawPosition,
41547
+ structureId: targetStructureId,
41548
+ tournamentRecord,
41549
+ drawDefinition,
41550
+ event
41551
+ });
41552
+ if (result.error)
41553
+ console.log(result.error);
41554
+ });
41525
41555
  const matchUpModifications = [];
41526
41556
  const goesToMap = addGoesTo({
41527
41557
  inContextDrawMatchUps,
@@ -42140,7 +42170,7 @@ function attachStructures$1({
42140
42170
  if (!drawDefinition)
42141
42171
  return { error: MISSING_DRAW_DEFINITION };
42142
42172
  if (!Array.isArray(structures) || !Array.isArray(links))
42143
- return { error: INVALID_VALUES };
42173
+ return decorateResult({ result: { error: INVALID_VALUES } });
42144
42174
  const stack = "attachStructures";
42145
42175
  const linkHash = (link) => [
42146
42176
  link.source.structureId,
@@ -44918,10 +44948,19 @@ function generateDrawMaticRound({
44918
44948
  eventType,
44919
44949
  structure
44920
44950
  }) {
44951
+ if (!drawDefinition)
44952
+ return { error: MISSING_DRAW_DEFINITION };
44953
+ if (!structure && !structureId)
44954
+ return { error: STRUCTURE_NOT_FOUND };
44955
+ if (!structure) {
44956
+ structure = findStructure({ drawDefinition, structureId }).structure;
44957
+ }
44958
+ if (!isObject(structure))
44959
+ return { error: MISSING_STRUCTURE };
44921
44960
  if (!participantIds?.length) {
44922
44961
  return { error: MISSING_PARTICIPANT_IDS };
44923
44962
  }
44924
- const { encounters } = getEncounters({ matchUps: structure.matchUps });
44963
+ const { encounters } = getEncounters({ matchUps: structure?.matchUps ?? [] });
44925
44964
  const valueObjects = {};
44926
44965
  for (const pairing of encounters) {
44927
44966
  if (!valueObjects[pairing])
@@ -44964,12 +45003,12 @@ function generateDrawMaticRound({
44964
45003
  let matchUps;
44965
45004
  if (generateMatchUps) {
44966
45005
  const result = generateAdHocMatchUps$1({
45006
+ structureId: structure?.structureId,
44967
45007
  participantIdPairings,
44968
45008
  tournamentRecord,
44969
45009
  addToStructure,
44970
45010
  newRound: true,
44971
45011
  drawDefinition,
44972
- structureId,
44973
45012
  matchUpIds
44974
45013
  });
44975
45014
  if (result.error)
@@ -45101,6 +45140,7 @@ function drawMatic$1({
45101
45140
  addToStructure,
45102
45141
  participantIds,
45103
45142
  drawDefinition,
45143
+ scaleAccessor,
45104
45144
  maxIterations,
45105
45145
  structureId,
45106
45146
  matchUpIds,
@@ -45148,6 +45188,7 @@ function drawMatic$1({
45148
45188
  const structureIsAdHoc = isAdHoc({ drawDefinition, structure });
45149
45189
  if (!structureIsAdHoc)
45150
45190
  return { error: INVALID_DRAW_DEFINITION };
45191
+ tournamentParticipants = tournamentParticipants ?? tournamentRecord.participants ?? [];
45151
45192
  const adHocRatings = {};
45152
45193
  for (const participantId of participantIds ?? []) {
45153
45194
  const participant = tournamentParticipants?.find(
@@ -45155,7 +45196,12 @@ function drawMatic$1({
45155
45196
  );
45156
45197
  let scaleValue = getScaleValue({ eventType, participant });
45157
45198
  if (!scaleValue && scaleName) {
45158
- scaleValue = getScaleValue({ scaleName, eventType, participant });
45199
+ scaleValue = getScaleValue({
45200
+ scaleAccessor,
45201
+ participant,
45202
+ scaleName,
45203
+ eventType
45204
+ });
45159
45205
  }
45160
45206
  if (scaleValue)
45161
45207
  adHocRatings[participantId] = scaleValue;
@@ -45169,13 +45215,17 @@ function drawMatic$1({
45169
45215
  drawDefinition,
45170
45216
  maxIterations,
45171
45217
  adHocRatings,
45172
- structureId,
45173
45218
  matchUpIds,
45174
45219
  structure,
45175
45220
  eventType
45176
45221
  });
45177
45222
  }
45178
- function getScaleValue({ scaleName = "dynamic", eventType, participant }) {
45223
+ function getScaleValue({
45224
+ eventType = TypeEnum.Singles,
45225
+ scaleName = "dynamic",
45226
+ scaleAccessor,
45227
+ participant
45228
+ }) {
45179
45229
  const scaleAttributes = {
45180
45230
  eventType: eventType || TypeEnum.Singles,
45181
45231
  scaleType: RATING$2,
@@ -45185,7 +45235,8 @@ function getScaleValue({ scaleName = "dynamic", eventType, participant }) {
45185
45235
  scaleAttributes,
45186
45236
  participant
45187
45237
  });
45188
- return result?.scaleItem?.scaleValue;
45238
+ const scaleValue = result?.scaleItem?.scaleValue;
45239
+ return scaleAccessor && isObject(scaleValue) ? scaleValue[scaleAccessor] : scaleValue;
45189
45240
  }
45190
45241
 
45191
45242
  function setDelegatedOutcome$1({
@@ -57478,12 +57529,28 @@ function generateDrawDefinition(params) {
57478
57529
  const matchUpsCount = entries2 ? Math.floor(entries2.length / 2) : 0;
57479
57530
  generateRange(1, params.roundsCount + 1).forEach(() => {
57480
57531
  if (params.automated) {
57532
+ const {
57533
+ restrictEntryStatus,
57534
+ generateMatchUps,
57535
+ addToStructure,
57536
+ maxIterations,
57537
+ structureId: structureId2,
57538
+ matchUpIds,
57539
+ scaleName
57540
+ } = params.drawMatic ?? {};
57481
57541
  drawMatic$1({
57482
- generateMatchUps: true,
57483
- eventType: matchUpType,
57484
57542
  tournamentRecord,
57485
57543
  participantIds,
57486
- drawDefinition
57544
+ drawDefinition,
57545
+ eventType: params.drawMatic?.eventType ?? matchUpType,
57546
+ generateMatchUps: generateMatchUps ?? true,
57547
+ restrictEntryStatus,
57548
+ addToStructure,
57549
+ maxIterations,
57550
+ structureId: structureId2,
57551
+ matchUpIds,
57552
+ scaleName
57553
+ // custom rating name to seed dynamic ratings
57487
57554
  });
57488
57555
  } else {
57489
57556
  generateAdHocMatchUps$1({
@@ -57831,9 +57898,10 @@ const eventGovernor = {
57831
57898
  checkOutParticipant,
57832
57899
  toggleParticipantCheckInState: toggleParticipantCheckInState$1,
57833
57900
  addDrawDefinitionTimeItem,
57834
- generateDrawDefinition,
57835
- generateDrawStructuresAndLinks,
57836
57901
  generateDrawTypeAndModifyDrawDefinition,
57902
+ generateDrawStructuresAndLinks,
57903
+ generateDrawMaticRound,
57904
+ generateDrawDefinition,
57837
57905
  applyLineUps,
57838
57906
  assignTieMatchUpParticipantId,
57839
57907
  removeTieMatchUpParticipantId,