tods-competition-factory 1.6.27 → 1.6.29

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.27";
332
+ return "1.6.29";
333
333
  }
334
334
 
335
335
  function getObjectTieFormat(obj) {
@@ -40001,9 +40001,9 @@ function processPlayoffGroups({
40001
40001
  for (const playoffGroup of playoffGroups) {
40002
40002
  const finishingPositions = playoffGroup.finishingPositions;
40003
40003
  const positionsPlayedOff = positionRangeMap && finishingPositions.map((p) => positionRangeMap[p]?.finishingPositions).flat();
40004
- const playoffDrawType = playoffGroup.drawType || SINGLE_ELIMINATION;
40005
40004
  const participantsInDraw = groupCount * finishingPositions.length;
40006
40005
  const drawSize = nextPowerOf2(participantsInDraw);
40006
+ const playoffDrawType = drawSize === 2 && SINGLE_ELIMINATION || playoffGroup.drawType || SINGLE_ELIMINATION;
40007
40007
  if (positionsPlayedOff) {
40008
40008
  finishingPositionOffset = Math.min(...positionsPlayedOff) - 1;
40009
40009
  }
@@ -40570,9 +40570,9 @@ function getGenerators(params) {
40570
40570
  function generateDrawStructuresAndLinks$1(params) {
40571
40571
  const {
40572
40572
  enforceMinimumDrawSize = true,
40573
- overwriteExisting,
40574
- drawTypeCoercion,
40573
+ drawTypeCoercion = true,
40575
40574
  // coerce to SINGLE_ELIMINATION for drawSize: 2
40575
+ overwriteExisting,
40576
40576
  appliedPolicies,
40577
40577
  staggeredEntry,
40578
40578
  // optional - specifies main structure FEED_IN for drawTypes CURTIS_CONSOLATION, FEED_IN_CHAMPIONSHIPS, FMLC
@@ -40583,7 +40583,7 @@ function generateDrawStructuresAndLinks$1(params) {
40583
40583
  uuids
40584
40584
  } = params || {};
40585
40585
  const stack = "generateDrawStructuresAndLinks";
40586
- let drawType = params.drawType ?? SINGLE_ELIMINATION;
40586
+ let drawType = drawTypeCoercion && params.drawSize === 2 && DrawTypeEnum.SingleElimination || params.drawType || DrawTypeEnum.SingleElimination;
40587
40587
  const structures = [], links = [];
40588
40588
  const matchUpType = params?.matchUpType ?? SINGLES$1;
40589
40589
  const existingQualifyingStructures = drawDefinition?.structures?.filter(
@@ -54732,9 +54732,12 @@ function addEventEntryPairs({
54732
54732
 
54733
54733
  function checkValidEntries({
54734
54734
  enforceGender = true,
54735
+ consideredEntries,
54736
+ tournamentRecord,
54735
54737
  participants,
54736
54738
  event
54737
54739
  }) {
54740
+ participants = participants || tournamentRecord?.participants;
54738
54741
  if (!participants)
54739
54742
  return { error: MISSING_PARTICIPANTS };
54740
54743
  if (!Array.isArray(participants))
@@ -54745,7 +54748,7 @@ function checkValidEntries({
54745
54748
  const participantType = eventType === TEAM_EVENT && TEAM || eventType === DOUBLES_EVENT && PAIR || INDIVIDUAL;
54746
54749
  const entryStatusMap = Object.assign(
54747
54750
  {},
54748
- ...(event.entries || []).map((entry) => ({
54751
+ ...(consideredEntries || event.entries || []).map((entry) => ({
54749
54752
  [entry.participantId]: entry.entryStatus
54750
54753
  }))
54751
54754
  );
@@ -57338,9 +57341,9 @@ function prepareStage(params) {
57338
57341
  function generateDrawDefinition(params) {
57339
57342
  const stack = "generateDrawDefinition";
57340
57343
  const {
57341
- drawType = DrawTypeEnum.SingleElimination,
57342
57344
  considerEventEntries = true,
57343
57345
  // in the absence of drawSize and drawEntries, look to event.entries
57346
+ drawTypeCoercion = true,
57344
57347
  ignoreAllowedDrawTypes,
57345
57348
  voluntaryConsolation,
57346
57349
  hydrateCollections,
@@ -57348,20 +57351,22 @@ function generateDrawDefinition(params) {
57348
57351
  ignoreStageSpace,
57349
57352
  tournamentRecord,
57350
57353
  qualifyingOnly,
57351
- enforceGender,
57352
57354
  tieFormatName,
57353
57355
  drawEntries,
57354
57356
  addToEvent,
57355
57357
  placeByes,
57356
57358
  event
57357
57359
  } = params;
57360
+ const drawType = drawTypeCoercion && params.drawSize === 2 && DrawTypeEnum.SingleElimination || params.drawType || DrawTypeEnum.SingleElimination;
57358
57361
  const { tournamentParticipants: participants } = getTournamentParticipants({
57359
57362
  tournamentRecord,
57360
57363
  inContext: true
57361
57364
  });
57362
- const validEntriesResult = event && participants && checkValidEntries({ event, participants, enforceGender });
57363
- if (validEntriesResult?.error)
57364
- return decorateResult({ result: validEntriesResult, stack });
57365
+ const appliedPolicies = getAppliedPolicies({
57366
+ tournamentRecord,
57367
+ event
57368
+ }).appliedPolicies ?? {};
57369
+ const enforceGender = params.enforceGender ?? policyDefinitions?.[POLICY_TYPE_MATCHUP_ACTIONS]?.participants?.enforceGender ?? appliedPolicies?.[POLICY_TYPE_MATCHUP_ACTIONS]?.participants?.enforceGender;
57365
57370
  const allowedDrawTypes = !ignoreAllowedDrawTypes && tournamentRecord && getAllowedDrawTypes({
57366
57371
  tournamentRecord,
57367
57372
  categoryType: event?.category?.categoryType,
@@ -57374,6 +57379,14 @@ function generateDrawDefinition(params) {
57374
57379
  (entry) => entry.entryStatus && [...STRUCTURE_ENTERED_TYPES, QUALIFIER].includes(entry.entryStatus)
57375
57380
  ) ?? [];
57376
57381
  const consideredEntries = (qualifyingOnly && [] || drawEntries || (considerEventEntries ? eventEntries : [])).filter(({ entryStage }) => !entryStage || entryStage === MAIN);
57382
+ const validEntriesResult = event && participants && checkValidEntries({
57383
+ consideredEntries,
57384
+ enforceGender,
57385
+ participants,
57386
+ event
57387
+ });
57388
+ if (validEntriesResult?.error)
57389
+ return decorateResult({ result: validEntriesResult, stack });
57377
57390
  const derivedDrawSize = !params.drawSize && consideredEntries.length && ![
57378
57391
  AD_HOC,
57379
57392
  DOUBLE_ELIMINATION,
@@ -57455,10 +57468,6 @@ function generateDrawDefinition(params) {
57455
57468
  drawDefinition.matchUpType = matchUpType;
57456
57469
  }
57457
57470
  }
57458
- const appliedPolicies = getAppliedPolicies({
57459
- tournamentRecord,
57460
- event
57461
- }).appliedPolicies ?? {};
57462
57471
  if (policyDefinitions) {
57463
57472
  if (typeof policyDefinitions !== "object") {
57464
57473
  return decorateResult({