tods-competition-factory 1.6.28 → 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.
@@ -362,7 +362,7 @@ var matchUpFormatCode = {
362
362
  };
363
363
 
364
364
  function factoryVersion() {
365
- return '1.6.28';
365
+ return '1.6.29';
366
366
  }
367
367
 
368
368
  /******************************************************************************
@@ -43348,9 +43348,11 @@ function processPlayoffGroups(_a) {
43348
43348
  finishingPositions
43349
43349
  .map(function (p) { var _a; return (_a = positionRangeMap[p]) === null || _a === void 0 ? void 0 : _a.finishingPositions; })
43350
43350
  .flat();
43351
- var playoffDrawType = playoffGroup.drawType || SINGLE_ELIMINATION;
43352
43351
  var participantsInDraw = groupCount * finishingPositions.length;
43353
43352
  var drawSize = nextPowerOf2(participantsInDraw);
43353
+ var playoffDrawType = (drawSize === 2 && SINGLE_ELIMINATION) ||
43354
+ playoffGroup.drawType ||
43355
+ SINGLE_ELIMINATION;
43354
43356
  if (positionsPlayedOff) {
43355
43357
  finishingPositionOffset = Math.min.apply(Math, __spreadArray([], __read(positionsPlayedOff), false)) - 1;
43356
43358
  }
@@ -43933,15 +43935,19 @@ function getGenerators(params) {
43933
43935
 
43934
43936
  function generateDrawStructuresAndLinks$1(params) {
43935
43937
  var e_1, _a, e_2, _b;
43936
- var _c, _d, _e, _f, _g, _h, _j;
43937
- var _k = params || {}, _l = _k.enforceMinimumDrawSize, enforceMinimumDrawSize = _l === void 0 ? true : _l, overwriteExisting = _k.overwriteExisting, drawTypeCoercion = _k.drawTypeCoercion, // coerce to SINGLE_ELIMINATION for drawSize: 2
43938
- appliedPolicies = _k.appliedPolicies, staggeredEntry = _k.staggeredEntry, // optional - specifies main structure FEED_IN for drawTypes CURTIS_CONSOLATION, FEED_IN_CHAMPIONSHIPS, FMLC
43939
- drawDefinition = _k.drawDefinition, tieFormat = _k.tieFormat, drawSize = _k.drawSize, isMock = _k.isMock, uuids = _k.uuids;
43938
+ var _c, _d, _e, _f, _g, _h;
43939
+ var _j = params || {}, _k = _j.enforceMinimumDrawSize, enforceMinimumDrawSize = _k === void 0 ? true : _k, _l = _j.drawTypeCoercion, drawTypeCoercion = _l === void 0 ? true : _l, // coerce to SINGLE_ELIMINATION for drawSize: 2
43940
+ overwriteExisting = _j.overwriteExisting, appliedPolicies = _j.appliedPolicies, staggeredEntry = _j.staggeredEntry, // optional - specifies main structure FEED_IN for drawTypes CURTIS_CONSOLATION, FEED_IN_CHAMPIONSHIPS, FMLC
43941
+ drawDefinition = _j.drawDefinition, tieFormat = _j.tieFormat, drawSize = _j.drawSize, isMock = _j.isMock, uuids = _j.uuids;
43940
43942
  var stack = 'generateDrawStructuresAndLinks';
43941
- var drawType = (_c = params.drawType) !== null && _c !== void 0 ? _c : SINGLE_ELIMINATION;
43943
+ var drawType = (drawTypeCoercion &&
43944
+ params.drawSize === 2 &&
43945
+ DrawTypeEnum.SingleElimination) ||
43946
+ params.drawType ||
43947
+ DrawTypeEnum.SingleElimination;
43942
43948
  var structures = [], links = [];
43943
- var matchUpType = (_d = params === null || params === void 0 ? void 0 : params.matchUpType) !== null && _d !== void 0 ? _d : SINGLES$1;
43944
- var existingQualifyingStructures = (_e = drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.structures) === null || _e === void 0 ? void 0 : _e.filter(function (_a) {
43949
+ var matchUpType = (_c = params === null || params === void 0 ? void 0 : params.matchUpType) !== null && _c !== void 0 ? _c : SINGLES$1;
43950
+ var existingQualifyingStructures = (_d = drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.structures) === null || _d === void 0 ? void 0 : _d.filter(function (_a) {
43945
43951
  var stage = _a.stage;
43946
43952
  return stage === QUALIFYING;
43947
43953
  });
@@ -43952,11 +43958,11 @@ function generateDrawStructuresAndLinks$1(params) {
43952
43958
  var structureId = _a.structureId;
43953
43959
  return structureId;
43954
43960
  });
43955
- var existingMainStructure = (_f = drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.structures) === null || _f === void 0 ? void 0 : _f.find(function (_a) {
43961
+ var existingMainStructure = (_e = drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.structures) === null || _e === void 0 ? void 0 : _e.find(function (_a) {
43956
43962
  var stage = _a.stage, stageSequence = _a.stageSequence;
43957
43963
  return stage === MAIN && stageSequence === 1;
43958
43964
  });
43959
- var existingQualifyingLinks = (_g = drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.links) === null || _g === void 0 ? void 0 : _g.filter(function (link) {
43965
+ var existingQualifyingLinks = (_f = drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.links) === null || _f === void 0 ? void 0 : _f.filter(function (link) {
43960
43966
  return link.target.structureId === (existingMainStructure === null || existingMainStructure === void 0 ? void 0 : existingMainStructure.structureId) &&
43961
43967
  (existingQualifyingStructureIds === null || existingQualifyingStructureIds === void 0 ? void 0 : existingQualifyingStructureIds.includes(link.source.structureId));
43962
43968
  });
@@ -43991,7 +43997,7 @@ function generateDrawStructuresAndLinks$1(params) {
43991
43997
  var structure = existingQualifyingStructures === null || existingQualifyingStructures === void 0 ? void 0 : existingQualifyingStructures.find(function (structure) { return structure.structureId === qualifyingStructureId; });
43992
43998
  return getQualifiersCount(link, structure);
43993
43999
  }).filter(Boolean).reduce(function (a, b) { return a + b; }, 0);
43994
- var mainStructureIsPlaceholder = !!(existingMainStructure && !((_h = existingMainStructure === null || existingMainStructure === void 0 ? void 0 : existingMainStructure.matchUps) === null || _h === void 0 ? void 0 : _h.length));
44000
+ var mainStructureIsPlaceholder = !!(existingMainStructure && !((_g = existingMainStructure === null || existingMainStructure === void 0 ? void 0 : existingMainStructure.matchUps) === null || _g === void 0 ? void 0 : _g.length));
43995
44001
  if ((existingQualifyingStructures === null || existingQualifyingStructures === void 0 ? void 0 : existingQualifyingStructures.length) && !mainStructureIsPlaceholder) {
43996
44002
  return { error: EXISTING_STAGE };
43997
44003
  }
@@ -44116,14 +44122,14 @@ function generateDrawStructuresAndLinks$1(params) {
44116
44122
  var qualifyingDetail = _q.value;
44117
44123
  var qualifyingRoundNumber = qualifyingDetail.finalQualifyingRoundNumber, qualifyingStructureId = qualifyingDetail.finalQualifyingStructureId, targetEntryRound = qualifyingDetail.roundTarget, finishingPositions = qualifyingDetail.finishingPositions, linkType = qualifyingDetail.linkType;
44118
44124
  var link = mainStructure &&
44119
- ((_j = generateQualifyingLink({
44125
+ ((_h = generateQualifyingLink({
44120
44126
  targetStructureId: mainStructure.structureId,
44121
44127
  sourceStructureId: qualifyingStructureId,
44122
44128
  sourceRoundNumber: qualifyingRoundNumber,
44123
44129
  finishingPositions: finishingPositions,
44124
44130
  targetEntryRound: targetEntryRound,
44125
44131
  linkType: linkType,
44126
- })) === null || _j === void 0 ? void 0 : _j.link);
44132
+ })) === null || _h === void 0 ? void 0 : _h.link);
44127
44133
  if (link === null || link === void 0 ? void 0 : link.error)
44128
44134
  return link;
44129
44135
  if (link) {
@@ -59356,7 +59362,8 @@ function addEventEntryPairs(_a) {
59356
59362
  }
59357
59363
 
59358
59364
  function checkValidEntries(_a) {
59359
- var _b = _a.enforceGender, enforceGender = _b === void 0 ? true : _b, participants = _a.participants, event = _a.event;
59365
+ var _b = _a.enforceGender, enforceGender = _b === void 0 ? true : _b, consideredEntries = _a.consideredEntries, tournamentRecord = _a.tournamentRecord, participants = _a.participants, event = _a.event;
59366
+ participants = participants || (tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.participants);
59360
59367
  if (!participants)
59361
59368
  return { error: MISSING_PARTICIPANTS };
59362
59369
  if (!Array.isArray(participants))
@@ -59367,7 +59374,7 @@ function checkValidEntries(_a) {
59367
59374
  var participantType = (eventType === TEAM_EVENT && TEAM) ||
59368
59375
  (eventType === DOUBLES_EVENT && PAIR) ||
59369
59376
  INDIVIDUAL;
59370
- var entryStatusMap = Object.assign.apply(Object, __spreadArray([{}], __read((event.entries || []).map(function (entry) {
59377
+ var entryStatusMap = Object.assign.apply(Object, __spreadArray([{}], __read((consideredEntries || event.entries || []).map(function (entry) {
59371
59378
  var _a;
59372
59379
  return (_a = {},
59373
59380
  _a[entry.participantId] = entry.entryStatus,
@@ -62181,8 +62188,14 @@ function generateDrawDefinition(params) {
62181
62188
  var e_1, _a, e_2, _b, e_3, _c, e_4, _d, _e, e_5, _f, e_6, _g, _h;
62182
62189
  var _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21;
62183
62190
  var stack = 'generateDrawDefinition';
62184
- var _22 = params.drawType, drawType = _22 === void 0 ? DrawTypeEnum.SingleElimination : _22, _23 = params.considerEventEntries, considerEventEntries = _23 === void 0 ? true : _23, // in the absence of drawSize and drawEntries, look to event.entries
62185
- ignoreAllowedDrawTypes = params.ignoreAllowedDrawTypes, voluntaryConsolation = params.voluntaryConsolation, hydrateCollections = params.hydrateCollections, policyDefinitions = params.policyDefinitions, ignoreStageSpace = params.ignoreStageSpace, tournamentRecord = params.tournamentRecord, qualifyingOnly = params.qualifyingOnly, tieFormatName = params.tieFormatName, drawEntries = params.drawEntries, addToEvent = params.addToEvent, placeByes = params.placeByes, event = params.event;
62191
+ var _22 = params.considerEventEntries, considerEventEntries = _22 === void 0 ? true : _22, // in the absence of drawSize and drawEntries, look to event.entries
62192
+ _23 = params.drawTypeCoercion, // in the absence of drawSize and drawEntries, look to event.entries
62193
+ drawTypeCoercion = _23 === void 0 ? true : _23, ignoreAllowedDrawTypes = params.ignoreAllowedDrawTypes, voluntaryConsolation = params.voluntaryConsolation, hydrateCollections = params.hydrateCollections, policyDefinitions = params.policyDefinitions, ignoreStageSpace = params.ignoreStageSpace, tournamentRecord = params.tournamentRecord, qualifyingOnly = params.qualifyingOnly, tieFormatName = params.tieFormatName, drawEntries = params.drawEntries, addToEvent = params.addToEvent, placeByes = params.placeByes, event = params.event;
62194
+ var drawType = (drawTypeCoercion &&
62195
+ params.drawSize === 2 &&
62196
+ DrawTypeEnum.SingleElimination) ||
62197
+ params.drawType ||
62198
+ DrawTypeEnum.SingleElimination;
62186
62199
  // get participants both for entry validation and for automated placement
62187
62200
  // automated placement requires them to be "inContext" for avoidance policies to work
62188
62201
  var participants = getTournamentParticipants({
@@ -62194,13 +62207,6 @@ function generateDrawDefinition(params) {
62194
62207
  event: event,
62195
62208
  }).appliedPolicies) !== null && _j !== void 0 ? _j : {};
62196
62209
  var enforceGender = (_o = (_k = params.enforceGender) !== null && _k !== void 0 ? _k : (_m = (_l = policyDefinitions === null || policyDefinitions === void 0 ? void 0 : policyDefinitions[POLICY_TYPE_MATCHUP_ACTIONS]) === null || _l === void 0 ? void 0 : _l.participants) === null || _m === void 0 ? void 0 : _m.enforceGender) !== null && _o !== void 0 ? _o : (_q = (_p = appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[POLICY_TYPE_MATCHUP_ACTIONS]) === null || _p === void 0 ? void 0 : _p.participants) === null || _q === void 0 ? void 0 : _q.enforceGender;
62197
- // entries participantTypes must correspond with eventType
62198
- // this is only possible if the event is provided
62199
- var validEntriesResult = event &&
62200
- participants &&
62201
- checkValidEntries({ event: event, participants: participants, enforceGender: enforceGender });
62202
- if (validEntriesResult === null || validEntriesResult === void 0 ? void 0 : validEntriesResult.error)
62203
- return decorateResult({ result: validEntriesResult, stack: stack });
62204
62210
  // if tournamentRecord is provided, and unless instructed to ignore valid types,
62205
62211
  // check for restrictions on allowed drawTypes
62206
62212
  var allowedDrawTypes = !ignoreAllowedDrawTypes &&
@@ -62223,6 +62229,18 @@ function generateDrawDefinition(params) {
62223
62229
  var entryStage = _a.entryStage;
62224
62230
  return !entryStage || entryStage === MAIN;
62225
62231
  });
62232
+ // entries participantTypes must correspond with eventType
62233
+ // this is only possible if the event is provided
62234
+ var validEntriesResult = event &&
62235
+ participants &&
62236
+ checkValidEntries({
62237
+ consideredEntries: consideredEntries,
62238
+ enforceGender: enforceGender,
62239
+ participants: participants,
62240
+ event: event,
62241
+ });
62242
+ if (validEntriesResult === null || validEntriesResult === void 0 ? void 0 : validEntriesResult.error)
62243
+ return decorateResult({ result: validEntriesResult, stack: stack });
62226
62244
  var derivedDrawSize = !params.drawSize &&
62227
62245
  consideredEntries.length &&
62228
62246
  ![