tods-competition-factory 1.8.20 → 1.8.21

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.
@@ -2905,7 +2905,7 @@ var matchUpFormatCode = {
2905
2905
  };
2906
2906
 
2907
2907
  function factoryVersion() {
2908
- return '1.8.20';
2908
+ return '1.8.21';
2909
2909
  }
2910
2910
 
2911
2911
  function getObjectTieFormat(obj) {
@@ -6434,8 +6434,8 @@ function unlinkTournament(_a) {
6434
6434
  var _a;
6435
6435
  var tournamentRecord = tournamentRecords[currentTournamentId];
6436
6436
  var extension = findTournamentExtension({
6437
- tournamentRecord: tournamentRecord,
6438
6437
  name: LINKED_TOURNAMENTS,
6438
+ tournamentRecord: tournamentRecord,
6439
6439
  }).extension;
6440
6440
  // if there is no extension return { ...SUCCESS } because no links exist
6441
6441
  if (!extension)
@@ -9241,6 +9241,9 @@ var POLICY_ROUND_NAMING_DEFAULT = (_a$h = {},
9241
9241
  namingConventions: {
9242
9242
  round: 'Round',
9243
9243
  },
9244
+ qualifyingFinishMap: {
9245
+ 1: 'Final',
9246
+ },
9244
9247
  abbreviatedRoundNamingMap: {
9245
9248
  // key is matchUpsCount for the round
9246
9249
  1: 'F',
@@ -9255,6 +9258,7 @@ var POLICY_ROUND_NAMING_DEFAULT = (_a$h = {},
9255
9258
  affixes: {
9256
9259
  roundNumber: 'R',
9257
9260
  preFeedRound: 'Q',
9261
+ preQualifying: 'P',
9258
9262
  },
9259
9263
  stageConstants: (_b$4 = {},
9260
9264
  _b$4[MAIN] = '',
@@ -9266,33 +9270,61 @@ var POLICY_ROUND_NAMING_DEFAULT = (_a$h = {},
9266
9270
  _a$h);
9267
9271
 
9268
9272
  function getRoundContextProfile(_a) {
9269
- var roundNamingPolicy = _a.roundNamingPolicy, structure = _a.structure, matchUps = _a.matchUps;
9270
- var _b = getRoundMatchUps$1({ matchUps: matchUps }), roundProfile = _b.roundProfile, roundMatchUps = _b.roundMatchUps;
9273
+ var _b, _c, _d, _e;
9274
+ var roundNamingPolicy = _a.roundNamingPolicy, drawDefinition = _a.drawDefinition, structure = _a.structure, matchUps = _a.matchUps;
9275
+ var _f = getRoundMatchUps$1({ matchUps: matchUps }), roundProfile = _f.roundProfile, roundMatchUps = _f.roundMatchUps;
9271
9276
  var structureAbbreviation = structure.structureAbbreviation, stage = structure.stage;
9272
9277
  var isAdHocStructure = isAdHoc({ structure: structure });
9273
9278
  var isLuckyStructure = isLucky({ structure: structure });
9274
9279
  var isRoundRobin = structure.structures;
9275
9280
  var roundNamingProfile = {};
9276
9281
  var defaultRoundNamingPolicy = POLICY_ROUND_NAMING_DEFAULT[POLICY_TYPE_ROUND_NAMING];
9282
+ var isQualifying = structure.stage === QUALIFYING;
9283
+ var qualifyingFinishgMap = isQualifying &&
9284
+ ((roundNamingPolicy === null || roundNamingPolicy === void 0 ? void 0 : roundNamingPolicy.qualifyingFinishMap) ||
9285
+ (defaultRoundNamingPolicy === null || defaultRoundNamingPolicy === void 0 ? void 0 : defaultRoundNamingPolicy.qualifyingFinishMap) ||
9286
+ {});
9287
+ var qualifyingStageSequences = isQualifying
9288
+ ? Math.max.apply(Math, __spreadArray(__spreadArray([], __read(((_b = drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.structures) !== null && _b !== void 0 ? _b : [])
9289
+ .filter(function (structure) { return structure.stage === QUALIFYING; })
9290
+ .map(function (_a) {
9291
+ var stageSequence = _a.stageSequence;
9292
+ return stageSequence !== null && stageSequence !== void 0 ? stageSequence : 1;
9293
+ })), false), [0], false)) : 0;
9294
+ var preQualifyingSequence = qualifyingStageSequences
9295
+ ? qualifyingStageSequences - (structure.stageSequence || 1) || ''
9296
+ : '';
9297
+ var preQualifyingAffix = preQualifyingSequence
9298
+ ? ((_c = roundNamingPolicy === null || roundNamingPolicy === void 0 ? void 0 : roundNamingPolicy.affixes) === null || _c === void 0 ? void 0 : _c.preQualifying) ||
9299
+ defaultRoundNamingPolicy.affixes.preQualifying ||
9300
+ ''
9301
+ : '';
9277
9302
  var roundNamingMap = (roundNamingPolicy === null || roundNamingPolicy === void 0 ? void 0 : roundNamingPolicy.roundNamingMap) ||
9278
9303
  defaultRoundNamingPolicy.roundNamingMap ||
9279
9304
  {};
9280
9305
  var abbreviatedRoundNamingMap = (roundNamingPolicy === null || roundNamingPolicy === void 0 ? void 0 : roundNamingPolicy.abbreviatedRoundNamingMap) ||
9281
9306
  defaultRoundNamingPolicy.abbreviatedRoundNamingMap ||
9282
9307
  {};
9283
- var roundNamePrefix = (roundNamingPolicy === null || roundNamingPolicy === void 0 ? void 0 : roundNamingPolicy.affixes) || defaultRoundNamingPolicy.affixes;
9284
- var roundNumberAffix = roundNamePrefix.roundNumber || defaultRoundNamingPolicy.affixes.roundNumber;
9308
+ var preFeedAffix = ((_d = roundNamingPolicy === null || roundNamingPolicy === void 0 ? void 0 : roundNamingPolicy.affixes) === null || _d === void 0 ? void 0 : _d.preFeedRound) ||
9309
+ defaultRoundNamingPolicy.affixes.preFeedRound;
9310
+ var roundNumberAffix = ((_e = roundNamingPolicy === null || roundNamingPolicy === void 0 ? void 0 : roundNamingPolicy.affixes) === null || _e === void 0 ? void 0 : _e.roundNumber) ||
9311
+ defaultRoundNamingPolicy.affixes.roundNumber;
9285
9312
  var namingConventions = (roundNamingPolicy === null || roundNamingPolicy === void 0 ? void 0 : roundNamingPolicy.namingConventions) ||
9286
9313
  defaultRoundNamingPolicy.namingConventions;
9287
9314
  var roundNameFallback = namingConventions.round;
9288
- var stageInitial = stage && stage !== MAIN && stage[0];
9289
- var stageConstants = roundNamingPolicy === null || roundNamingPolicy === void 0 ? void 0 : roundNamingPolicy.stageConstants;
9290
- var stageConstant = (stage && (stageConstants === null || stageConstants === void 0 ? void 0 : stageConstants[stage])) || stageInitial;
9315
+ var stageInitial = stage && stage !== MAIN ? stage[0] : '';
9316
+ var stageConstants = (roundNamingPolicy === null || roundNamingPolicy === void 0 ? void 0 : roundNamingPolicy.stageConstants) ||
9317
+ defaultRoundNamingPolicy.stageConstants;
9318
+ var stageIndicator = (stage && (stageConstants === null || stageConstants === void 0 ? void 0 : stageConstants[stage])) || stageInitial;
9319
+ var stageConstant = "".concat(preQualifyingAffix).concat(stageIndicator).concat(preQualifyingSequence);
9291
9320
  var roundProfileKeys = roundProfile ? Object.keys(roundProfile) : [];
9321
+ var qualifyingAffix = isQualifying && (stageConstants === null || stageConstants === void 0 ? void 0 : stageConstants[QUALIFYING])
9322
+ ? "".concat(stageConstants === null || stageConstants === void 0 ? void 0 : stageConstants[QUALIFYING], "-")
9323
+ : '';
9292
9324
  if (isRoundRobin || isAdHocStructure || isLuckyStructure) {
9293
9325
  Object.assign.apply(Object, __spreadArray([roundNamingProfile], __read(roundProfileKeys.map(function (key) {
9294
9326
  var _a;
9295
- var roundName = "".concat(roundNameFallback, " ").concat(key);
9327
+ var roundName = "".concat(qualifyingAffix).concat(roundNameFallback, " ").concat(key);
9296
9328
  var abbreviatedRoundName = "".concat(roundNumberAffix).concat(key);
9297
9329
  return _a = {}, _a[key] = { roundName: roundName, abbreviatedRoundName: abbreviatedRoundName }, _a;
9298
9330
  })), false));
@@ -9304,9 +9336,11 @@ function getRoundContextProfile(_a) {
9304
9336
  return;
9305
9337
  var _b = roundProfile[round], matchUpsCount = _b.matchUpsCount, preFeedRound = _b.preFeedRound;
9306
9338
  var participantsCount = matchUpsCount * 2;
9307
- var sizedRoundName = roundNamingMap[matchUpsCount] ||
9308
- "".concat(roundNamePrefix.roundNumber).concat(participantsCount);
9309
- var suffix = preFeedRound ? "-".concat(roundNamePrefix.preFeedRound) : '';
9339
+ var sizedRoundName = (qualifyingFinishgMap === null || qualifyingFinishgMap === void 0 ? void 0 : qualifyingFinishgMap[roundProfile === null || roundProfile === void 0 ? void 0 : roundProfile[round].finishingRound]) ||
9340
+ (qualifyingFinishgMap && "".concat(roundNumberAffix).concat(participantsCount)) ||
9341
+ roundNamingMap[matchUpsCount] ||
9342
+ "".concat(roundNumberAffix).concat(participantsCount);
9343
+ var suffix = preFeedRound ? "-".concat(preFeedAffix) : '';
9310
9344
  var profileRoundName = "".concat(sizedRoundName).concat(suffix);
9311
9345
  var roundName = [
9312
9346
  stageConstant,
@@ -9316,7 +9350,7 @@ function getRoundContextProfile(_a) {
9316
9350
  .filter(Boolean)
9317
9351
  .join('-');
9318
9352
  var sizedAbbreviation = abbreviatedRoundNamingMap[matchUpsCount] ||
9319
- "".concat(roundNamePrefix.roundNumber).concat(participantsCount);
9353
+ "".concat(roundNumberAffix).concat(participantsCount);
9320
9354
  var profileAbbreviation = "".concat(sizedAbbreviation).concat(suffix);
9321
9355
  var abbreviatedRoundName = [
9322
9356
  stageConstant,
@@ -9514,6 +9548,7 @@ function getAllStructureMatchUps(_a) {
9514
9548
  var roundNamingPolicy = appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[POLICY_TYPE_ROUND_NAMING];
9515
9549
  var result = getRoundContextProfile({
9516
9550
  roundNamingPolicy: roundNamingPolicy,
9551
+ drawDefinition: drawDefinition,
9517
9552
  structure: structure,
9518
9553
  matchUps: matchUps,
9519
9554
  });
@@ -25071,16 +25106,6 @@ function scoreModification$1(params) {
25071
25106
  return decorateResult({ result: result, stack: stack });
25072
25107
  }
25073
25108
 
25074
- /**
25075
- *
25076
- * Finds all structureIds which are affected by an outcome change in a completed structure
25077
- * Is specific to Round Robins which direct participants by WIN_RATIO
25078
- *
25079
- * @param {object} drawDefinition
25080
- * @param {object} structure
25081
- * @param {object} matchUp
25082
- *
25083
- */
25084
25109
  function getAffectedTargetStructureIds(_a) {
25085
25110
  var _b, _c;
25086
25111
  var drawDefinition = _a.drawDefinition, structure = _a.structure, matchUp = _a.matchUp;
@@ -46856,7 +46881,7 @@ function generateVoluntaryConsolation$1(params) {
46856
46881
  // not for use when generating structures from qualifyingProfiles
46857
46882
  function generateQualifyingStructure$1(params) {
46858
46883
  var _a;
46859
- var _b, _c, _d;
46884
+ var _b, _c, _d, _e;
46860
46885
  if (!params.drawDefinition)
46861
46886
  return { error: MISSING_DRAW_DEFINITION };
46862
46887
  var stack = 'generateQualifyingStructure';
@@ -46895,7 +46920,7 @@ function generateQualifyingStructure$1(params) {
46895
46920
  var chainModified = void 0;
46896
46921
  while (!chainModified && nextStructureId_1) {
46897
46922
  targetStructure.stageSequence = nextStageSequence;
46898
- var targetTargetStructureId = (_c = (_b = drawDefinition.links.find(function (link) { return link.source.structureId === nextStructureId_1; })) === null || _b === void 0 ? void 0 : _b.target) === null || _c === void 0 ? void 0 : _c.structureId;
46923
+ var targetTargetStructureId = (_d = (_c = (_b = drawDefinition.links) === null || _b === void 0 ? void 0 : _b.find(function (link) { return link.source.structureId === nextStructureId_1; })) === null || _c === void 0 ? void 0 : _c.target) === null || _d === void 0 ? void 0 : _d.structureId;
46899
46924
  nextStructureId_1 = targetTargetStructureId;
46900
46925
  nextStageSequence += 1;
46901
46926
  if (!targetTargetStructureId) {
@@ -46928,7 +46953,7 @@ function generateQualifyingStructure$1(params) {
46928
46953
  ? "".concat(constantToString(QUALIFYING), " ").concat(roundTargetName).concat(stageSequenceName)
46929
46954
  : constantToString(QUALIFYING));
46930
46955
  if (drawType === ROUND_ROBIN) {
46931
- var _e = generateRoundRobin({
46956
+ var _f = generateRoundRobin({
46932
46957
  structureName: structureName || qualifyingStructureName,
46933
46958
  structureId: structureId || (uuids === null || uuids === void 0 ? void 0 : uuids.pop()),
46934
46959
  stage: QUALIFYING,
@@ -46941,7 +46966,7 @@ function generateQualifyingStructure$1(params) {
46941
46966
  drawSize: drawSize,
46942
46967
  isMock: isMock,
46943
46968
  uuids: uuids,
46944
- }), maxRoundNumber = _e.maxRoundNumber /*, groupSize*/, structures = _e.structures, groupCount = _e.groupCount;
46969
+ }), maxRoundNumber = _f.maxRoundNumber /*, groupSize*/, structures = _f.structures, groupCount = _f.groupCount;
46945
46970
  qualifiersCount = groupCount;
46946
46971
  roundLimit = maxRoundNumber;
46947
46972
  structure = structures[0];
@@ -46975,7 +47000,7 @@ function generateQualifyingStructure$1(params) {
46975
47000
  extension: { name: ROUND_TARGET, value: roundTarget },
46976
47001
  });
46977
47002
  }
46978
- qualifiersCount = (_d = matchUps === null || matchUps === void 0 ? void 0 : matchUps.filter(function (matchUp) { return matchUp.roundNumber === roundLimit; })) === null || _d === void 0 ? void 0 : _d.length;
47003
+ qualifiersCount = (_e = matchUps === null || matchUps === void 0 ? void 0 : matchUps.filter(function (matchUp) { return matchUp.roundNumber === roundLimit; })) === null || _e === void 0 ? void 0 : _e.length;
46979
47004
  }
46980
47005
  // order of operations is important here!! finalQualifier positions is not yet updated when this step occurs
46981
47006
  var linkType = drawType === ROUND_ROBIN ? LinkTypeEnum.Position : LinkTypeEnum.Winner;
@@ -52585,6 +52610,7 @@ var entryGovernor = {
52585
52610
 
52586
52611
  var linkGovernor = {
52587
52612
  generateQualifyingLink: generateQualifyingLink,
52613
+ getStructureLinks: getStructureLinks,
52588
52614
  };
52589
52615
 
52590
52616
  var definitionTemplate = function () { return ({
@@ -58566,8 +58592,8 @@ function analyzeDraws(_a) {
58566
58592
  return !inactiveStructure;
58567
58593
  }).length;
58568
58594
  var links = getStructureLinks({
58569
- drawDefinition: drawDefinition,
58570
58595
  structureId: mainStructure.structureId,
58596
+ drawDefinition: drawDefinition,
58571
58597
  }).links;
58572
58598
  var isMatchPlay = ensureInt(mainStructure.activeRounds[0]) === 1 &&
58573
58599
  mainStructure.activeRounds.length === 1 &&
@@ -64448,6 +64474,25 @@ function generateDrawDefinition(params) {
64448
64474
  return __assign(__assign({ existingDrawDefinition: !!existingDrawDefinition, qualifyingConflicts: qualifyingConflicts, positioningReports: positioningReports, drawDefinition: drawDefinition, structureId: structureId }, SUCCESS), { conflicts: conflicts });
64449
64475
  }
64450
64476
 
64477
+ function isValidForQualifying(_a) {
64478
+ var structureId = _a.structureId, drawDefinition = _a.drawDefinition;
64479
+ if (!drawDefinition)
64480
+ return { error: MISSING_DRAW_DEFINITION };
64481
+ if (!isString(structureId))
64482
+ return { error: INVALID_VALUES };
64483
+ var result = getStructureLinks({
64484
+ drawDefinition: drawDefinition,
64485
+ structureId: structureId,
64486
+ });
64487
+ if (result.error)
64488
+ return result;
64489
+ var targetFeedProfiles = result.links.target
64490
+ .flatMap(function (t) { return t.target.feedProfile; })
64491
+ .filter(Boolean);
64492
+ var valid = !!intersection([BOTTOM_UP, TOP_DOWN, RANDOM], targetFeedProfiles).length;
64493
+ return __assign(__assign({}, SUCCESS), { valid: valid });
64494
+ }
64495
+
64451
64496
  function renameStructures(params) {
64452
64497
  return renameStructures$1(params);
64453
64498
  }
@@ -64719,6 +64764,7 @@ var eventGovernor = {
64719
64764
  attachQualifyingStructure: attachQualifyingStructure,
64720
64765
  attachPlayoffStructures: attachPlayoffStructures,
64721
64766
  addQualifyingStructure: addQualifyingStructure,
64767
+ isValidForQualifying: isValidForQualifying,
64722
64768
  setStructureOrder: setStructureOrder,
64723
64769
  attachStructures: attachStructures,
64724
64770
  renameStructures: renameStructures,