tods-competition-factory 1.8.2 → 1.8.3

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.
@@ -1278,16 +1278,16 @@ interface UnifiedVenueID {
1278
1278
 
1279
1279
  /**
1280
1280
  *
1281
- * @param {object} playoffAttributes - mapping of exitProfile to structure names, e.g. 0-1-1 for SOUTH
1281
+ * @param {object} playoffAttributes - mapping of exitProfile to structure names, e.g. 0-1-1 for South
1282
1282
  * @param {string} playoffStructureNameBase - Root word for default playoff naming, e.g. 'Playoff' for 'Playoff 3-4'
1283
- * @param {string} exitProfile - rounds at which a participant exited each structure, e.g. 0-1-1-1 for losing EAST, WEST, SOUTH
1283
+ * @param {string} exitProfile - rounds at which a participant exited each structure, e.g. 0-1-1-1 for losing East, West, South
1284
1284
  * @param {boolean} exitProfileLimit - limit playoff rounds generated by the attributes present in playoffAttributes
1285
1285
  * @param {number} finishingPositionOffset - amount by which to offset finishingPositions, e.g. 2 for playing off 3-4
1286
1286
  * @param {number} finishingPositionLimit - highest value of possible finishing Positions to play off
1287
1287
  * @param {object} finishingPositionNaming - map of { [finishingPositionRange]: customName }
1288
1288
  * @param {number} roundOffsetLimit - how many rounds to play off (# of additional matchUps per participant)
1289
1289
  * @param {number} roundOffset - used internally to track generated structures; saved in structure attributes;
1290
- * @param {number} stageSequence - what sequence within stage structures, e.g. WEST is stageSequence 2 in COMPASS
1290
+ * @param {number} stageSequence - what sequence within stage structures, e.g. West is stageSequence 2 in COMPASS
1291
1291
  * @param {string} stage - [QUALIFYING, MAIN, CONSOLATION, PLAY-OFF]
1292
1292
  *
1293
1293
  */
@@ -1368,6 +1368,12 @@ type RoundProfile = {
1368
1368
  roundName?: string;
1369
1369
  };
1370
1370
  };
1371
+ type PlayoffAttributes = {
1372
+ [key: string | number]: {
1373
+ name: string;
1374
+ abbreviation: string;
1375
+ };
1376
+ };
1371
1377
 
1372
1378
  type GenerateAndPopulateArgs = {
1373
1379
  addNameBaseToAttributeName?: boolean;
@@ -1484,6 +1490,7 @@ type GenerateDrawDefinitionArgs = {
1484
1490
  automated?: boolean | {
1485
1491
  seedsOnly: boolean;
1486
1492
  };
1493
+ playoffAttributes?: PlayoffAttributes;
1487
1494
  policyDefinitions?: PolicyDefinitions;
1488
1495
  voluntaryConsolation?: {
1489
1496
  structureAbbreviation?: string;
@@ -1505,6 +1512,7 @@ type GenerateDrawDefinitionArgs = {
1505
1512
  processCodes?: string[];
1506
1513
  matchUpFormat?: string;
1507
1514
  matchUpType?: TypeEnum;
1515
+ structureName?: string;
1508
1516
  tieFormatName?: string;
1509
1517
  tieFormat?: TieFormat;
1510
1518
  drawEntries?: Entry[];
@@ -3170,20 +3170,20 @@ const ROUND_ROBIN_WITH_PLAYOFF = "ROUND_ROBIN_WITH_PLAYOFF";
3170
3170
  const DECIDER = "DECIDER";
3171
3171
  const BACKDRAW = "BACKDRAW";
3172
3172
  const COMPASS_ATTRIBUTES = {
3173
- 0: { name: "EAST", abbreviation: "E" },
3174
- "0-1": { name: "WEST", abbreviation: "W" },
3175
- "0-2": { name: "NORTH", abbreviation: "N" },
3176
- "0-3": { name: "NORTHEAST", abbreviation: "NE" },
3177
- "0-1-1": { name: "SOUTH", abbreviation: "S" },
3178
- "0-1-2": { name: "SOUTHWEST", abbreviation: "SW" },
3179
- "0-2-1": { name: "NORTHWEST", abbreviation: "NW" },
3180
- "0-1-1-1": { name: "SOUTHEAST", abbreviation: "SE" }
3173
+ 0: { name: "East", abbreviation: "E" },
3174
+ "0-1": { name: "West", abbreviation: "W" },
3175
+ "0-2": { name: "North", abbreviation: "N" },
3176
+ "0-3": { name: "Northeast", abbreviation: "NE" },
3177
+ "0-1-1": { name: "South", abbreviation: "S" },
3178
+ "0-1-2": { name: "Southwest", abbreviation: "SW" },
3179
+ "0-2-1": { name: "Northwest", abbreviation: "NW" },
3180
+ "0-1-1-1": { name: "Southeast", abbreviation: "SE" }
3181
3181
  };
3182
3182
  const OLYMPIC_ATTRIBUTES = {
3183
- 0: { name: "EAST", abbreviation: "E" },
3184
- "0-1": { name: "WEST", abbreviation: "W" },
3185
- "0-2": { name: "NORTH", abbreviation: "N" },
3186
- "0-1-1": { name: "SOUTH", abbreviation: "S" }
3183
+ 0: { name: "East", abbreviation: "E" },
3184
+ "0-1": { name: "West", abbreviation: "W" },
3185
+ "0-2": { name: "North", abbreviation: "N" },
3186
+ "0-1-1": { name: "South", abbreviation: "S" }
3187
3187
  };
3188
3188
  const WIN_RATIO = "WIN_RATIO";
3189
3189
  const ROUND_OUTCOME = "ROUND_OUTCOME";
@@ -5037,6 +5037,7 @@ function groupRounds({ groupSize, drawPositionOffset }) {
5037
5037
 
5038
5038
  function generateRoundRobin({
5039
5039
  structureName = constantToString(MAIN),
5040
+ groupNameBase = "Group",
5040
5041
  stageSequence = 1,
5041
5042
  structureOptions,
5042
5043
  appliedPolicies,
@@ -5070,7 +5071,7 @@ function generateRoundRobin({
5070
5071
  ...matchUps.map(({ roundNumber }) => roundNumber)
5071
5072
  );
5072
5073
  return structureTemplate({
5073
- structureName: `Group ${structureOrder}`,
5074
+ structureName: `${groupNameBase} ${structureOrder}`,
5074
5075
  structureId: uuids?.pop(),
5075
5076
  structureType: ITEM,
5076
5077
  finishingPosition,
@@ -13964,6 +13965,7 @@ function treeMatchUps({
13964
13965
  function firstRoundLoserConsolation(params) {
13965
13966
  const {
13966
13967
  finishingPositionOffset = 0,
13968
+ playoffAttributes,
13967
13969
  stageSequence = 1,
13968
13970
  staggeredEntry,
13969
13971
  structureName,
@@ -13985,7 +13987,7 @@ function firstRoundLoserConsolation(params) {
13985
13987
  };
13986
13988
  const { matchUps } = staggeredEntry ? feedInMatchUps(mainParams) : treeMatchUps(mainParams);
13987
13989
  const mainStructure = structureTemplate({
13988
- structureName: structureName || constantToString(MAIN),
13990
+ structureName: structureName || playoffAttributes?.["0"]?.name || constantToString(MAIN),
13989
13991
  structureId: structureId || uuids?.pop(),
13990
13992
  stageSequence,
13991
13993
  matchUpType,
@@ -14004,7 +14006,7 @@ function firstRoundLoserConsolation(params) {
14004
14006
  isMock
14005
14007
  });
14006
14008
  const consolation = constantToString(CONSOLATION);
14007
- const consolationStructureName = params.consolationStructureName || (structureName ? `${structureName} ${consolation}` : consolation);
14009
+ const consolationStructureName = playoffAttributes?.["0-1"]?.name ?? params.consolationStructureName ?? (structureName ? `${structureName} ${consolation}` : consolation);
14008
14010
  const consolationStructure = structureTemplate({
14009
14011
  structureName: consolationStructureName,
14010
14012
  matchUps: consolationMatchUps,
@@ -14082,10 +14084,10 @@ function feedInLinks({
14082
14084
 
14083
14085
  function generateCurtisConsolation(params) {
14084
14086
  const {
14085
- structureName = constantToString(MAIN),
14086
14087
  playoffStructureNameBase,
14087
14088
  finishingPositionOffset,
14088
14089
  stageSequence = 1,
14090
+ playoffAttributes,
14089
14091
  structureNameMap,
14090
14092
  staggeredEntry,
14091
14093
  stage = MAIN,
@@ -14105,6 +14107,7 @@ function generateCurtisConsolation(params) {
14105
14107
  uuids
14106
14108
  };
14107
14109
  const { matchUps, roundsCount: mainDrawRoundsCount } = staggeredEntry ? feedInMatchUps(mainParams) : treeMatchUps(mainParams);
14110
+ const structureName = params.structureName ?? playoffAttributes?.["0"]?.name ?? constantToString(MAIN);
14108
14111
  const mainStructure = structureTemplate({
14109
14112
  structureId: structureId || uuids?.pop(),
14110
14113
  structureName,
@@ -14123,6 +14126,7 @@ function generateCurtisConsolation(params) {
14123
14126
  idPrefix: idPrefix && `${idPrefix}-c${index}`,
14124
14127
  structureId: uuids?.pop(),
14125
14128
  playoffStructureNameBase,
14129
+ playoffAttributes,
14126
14130
  structureNameMap,
14127
14131
  stageSequence: stageSequence2,
14128
14132
  roundOffset,
@@ -14151,7 +14155,7 @@ function generateCurtisConsolation(params) {
14151
14155
  matchUpType,
14152
14156
  isMock
14153
14157
  });
14154
- const defaultName = constantToString(PLAY_OFF);
14158
+ const defaultName = playoffAttributes?.["3-4"]?.name ?? constantToString(PLAY_OFF);
14155
14159
  const mappedStructureName = structureNameMap?.[defaultName] || defaultName;
14156
14160
  const structureName2 = playoffStructureNameBase ? `${playoffStructureNameBase} ${mappedStructureName}` : mappedStructureName;
14157
14161
  const playoffStructure = structureTemplate({
@@ -14183,6 +14187,7 @@ function generateCurtisConsolation(params) {
14183
14187
  function consolationFeedStructure({
14184
14188
  playoffStructureNameBase,
14185
14189
  stageSequence = 1,
14190
+ playoffAttributes,
14186
14191
  structureNameMap,
14187
14192
  roundOffset = 0,
14188
14193
  matchUpType,
@@ -14204,7 +14209,8 @@ function consolationFeedStructure({
14204
14209
  isMock,
14205
14210
  uuids
14206
14211
  });
14207
- const defaultName = `${constantToString(CONSOLATION)} ${index + 1}`;
14212
+ const indexedStructureName = index === 0 && playoffAttributes?.["0-1"]?.name || index === 1 && playoffAttributes?.["0-3"]?.name;
14213
+ const defaultName = indexedStructureName || `${constantToString(CONSOLATION)} ${index + 1}`;
14208
14214
  const mappedStructureName = structureNameMap?.[defaultName] || defaultName;
14209
14215
  const structureName = playoffStructureNameBase ? `${playoffStructureNameBase} ${mappedStructureName}` : mappedStructureName;
14210
14216
  const consolationStructure = structureTemplate({
@@ -14254,7 +14260,7 @@ function generatePlayoffStructures(params) {
14254
14260
  const finishingPositionRange = `${finishingPositionsFrom}-${finishingPositionsTo}`;
14255
14261
  const attributeProfile = playoffAttributes?.[exitProfile];
14256
14262
  const base = playoffStructureNameBase && `${playoffStructureNameBase} ` || "";
14257
- const customNaming = finishingPositionNaming?.[finishingPositionRange];
14263
+ const customNaming = playoffAttributes?.[finishingPositionRange] ?? finishingPositionNaming?.[finishingPositionRange];
14258
14264
  const structureName = customNaming?.name || attributeProfile?.name && (addNameBaseToAttributeName ? `${base}${attributeProfile?.name}` : attributeProfile.name) || `${base}${finishingPositionRange}`;
14259
14265
  const structureAbbreviation = customNaming?.abbreviation || attributeProfile?.abbreviation;
14260
14266
  const mainParams = {
@@ -14359,6 +14365,7 @@ function feedInChampionship(params) {
14359
14365
  const {
14360
14366
  finishingPositionOffset,
14361
14367
  stageSequence = 1,
14368
+ playoffAttributes,
14362
14369
  policyDefinitions,
14363
14370
  feedsFromFinal,
14364
14371
  staggeredEntry,
@@ -14386,7 +14393,7 @@ function feedInChampionship(params) {
14386
14393
  };
14387
14394
  const { matchUps } = staggeredEntry ? feedInMatchUps(mainParams) : treeMatchUps(mainParams);
14388
14395
  const mainStructure = structureTemplate({
14389
- structureName: structureName || constantToString(MAIN),
14396
+ structureName: structureName || playoffAttributes?.["0"]?.name || constantToString(MAIN),
14390
14397
  structureId: structureId || uuids?.pop(),
14391
14398
  stageSequence,
14392
14399
  matchUpType,
@@ -14411,7 +14418,7 @@ function feedInChampionship(params) {
14411
14418
  });
14412
14419
  if (drawSize > 2) {
14413
14420
  const consolationStructure = structureTemplate({
14414
- structureName: constantToString(CONSOLATION),
14421
+ structureName: playoffAttributes?.["0-1"]?.name ?? constantToString(CONSOLATION),
14415
14422
  matchUps: consolationMatchUps,
14416
14423
  structureId: uuids?.pop(),
14417
14424
  stage: CONSOLATION,
@@ -14436,10 +14443,9 @@ function feedInChampionship(params) {
14436
14443
  }
14437
14444
 
14438
14445
  function processPlayoffGroups({
14439
- compassAttributes = COMPASS_ATTRIBUTES,
14440
- olympicAttributes = OLYMPIC_ATTRIBUTES,
14441
14446
  requireSequential = true,
14442
14447
  playoffMatchUpFormat,
14448
+ playoffAttributes,
14443
14449
  sourceStructureId,
14444
14450
  policyDefinitions,
14445
14451
  stageSequence,
@@ -14488,6 +14494,8 @@ function processPlayoffGroups({
14488
14494
  if (positionsPlayedOff) {
14489
14495
  finishingPositionOffset = Math.min(...positionsPlayedOff) - 1;
14490
14496
  }
14497
+ const finishingPositionRange = positionsPlayedOff && `${Math.min(...positionsPlayedOff)}-${Math.max(...positionsPlayedOff)}`;
14498
+ const structureName = playoffGroup.structureName || finishingPositionRange && playoffGroup.playoffAttributes?.[finishingPositionRange]?.name || playoffGroup.playoffAttributes?.["0"]?.name;
14491
14499
  const playoffGroupParams = {
14492
14500
  addNameBaseToAttributeName: playoffGroup.addNameBaseToAttributeName,
14493
14501
  playoffStructureNameBase: playoffGroup.playoffStructureNameBase,
@@ -14496,8 +14504,8 @@ function processPlayoffGroups({
14496
14504
  structureId: playoffGroup.structureId ?? uuids?.pop(),
14497
14505
  playoffAttributes: playoffGroup.playoffAttributes,
14498
14506
  structureNameMap: playoffGroup.structureNameMap,
14499
- structureName: playoffGroup.structureName,
14500
- sequenceLimit: playoffGroup.sequenceLimit
14507
+ sequenceLimit: playoffGroup.sequenceLimit,
14508
+ structureName
14501
14509
  };
14502
14510
  const params = {
14503
14511
  ...playoffGroupParams,
@@ -14539,9 +14547,9 @@ function processPlayoffGroups({
14539
14547
  });
14540
14548
  const playoffStructure = structureTemplate({
14541
14549
  structureId: playoffGroup.structureId ?? uuids?.pop(),
14542
- structureName: playoffGroup.structureName,
14543
14550
  matchUpFormat: playoffMatchUpFormat,
14544
14551
  stage: PLAY_OFF,
14552
+ structureName,
14545
14553
  stageSequence,
14546
14554
  matchUps
14547
14555
  });
@@ -14558,8 +14566,8 @@ function processPlayoffGroups({
14558
14566
  finishingPositions
14559
14567
  });
14560
14568
  } else if ([COMPASS, OLYMPIC, PLAY_OFF].includes(playoffDrawType)) {
14561
- const { structureName } = playoffGroup;
14562
14569
  const params2 = {
14570
+ playoffAttributes: playoffGroup.playoffAttributes ?? playoffAttributes,
14563
14571
  structureId: playoffGroup.structureId ?? uuids?.pop(),
14564
14572
  playoffStructureNameBase: structureName,
14565
14573
  idPrefix: idPrefix && `${idPrefix}-po`,
@@ -14574,12 +14582,12 @@ function processPlayoffGroups({
14574
14582
  };
14575
14583
  if (playoffDrawType === COMPASS) {
14576
14584
  Object.assign(params2, {
14577
- playoffAttributes: compassAttributes,
14585
+ playoffAttributes: playoffGroup?.playoffAttributes ?? playoffAttributes ?? COMPASS_ATTRIBUTES,
14578
14586
  roundOffsetLimit: 3
14579
14587
  });
14580
14588
  } else if (playoffDrawType === OLYMPIC) {
14581
14589
  Object.assign(params2, {
14582
- playoffAttributes: olympicAttributes,
14590
+ playoffAttributes: playoffGroup?.playoffAttributes ?? playoffAttributes ?? OLYMPIC_ATTRIBUTES,
14583
14591
  roundOffsetLimit: 2
14584
14592
  });
14585
14593
  }
@@ -14615,11 +14623,11 @@ function processPlayoffGroups({
14615
14623
  const uuidsFMLC = [uuids?.pop(), uuids?.pop()];
14616
14624
  const params2 = {
14617
14625
  structureId: playoffGroup.structureId ?? uuids?.pop(),
14618
- structureName: playoffGroup.structureName,
14619
14626
  idPrefix: idPrefix && `${idPrefix}-po`,
14620
14627
  finishingPositionOffset,
14621
14628
  uuids: uuidsFMLC,
14622
14629
  stage: PLAY_OFF,
14630
+ structureName,
14623
14631
  matchUpType,
14624
14632
  feedPolicy,
14625
14633
  drawSize,
@@ -19369,10 +19377,8 @@ function luckyRoundProfiles(drawSize) {
19369
19377
 
19370
19378
  function getGenerators(params) {
19371
19379
  const {
19372
- compassAttributes = COMPASS_ATTRIBUTES,
19373
- olympicAttributes = OLYMPIC_ATTRIBUTES,
19380
+ playoffAttributes,
19374
19381
  stageSequence = 1,
19375
- structureName,
19376
19382
  structureId,
19377
19383
  stage = MAIN,
19378
19384
  matchUpType,
@@ -19382,13 +19388,13 @@ function getGenerators(params) {
19382
19388
  const { appliedPolicies } = getAppliedPolicies(params);
19383
19389
  const feedPolicy = params.policyDefinitions?.[POLICY_TYPE_FEED_IN] || appliedPolicies?.[POLICY_TYPE_FEED_IN];
19384
19390
  params.skipRounds = params.skipRounds || drawSize <= 4 && (feedPolicy?.feedMainFinal ? 0 : 1) || 0;
19385
- const main = constantToString(MAIN);
19391
+ const structureName = params.structureName ?? playoffAttributes?.["0"]?.name ?? constantToString(MAIN);
19386
19392
  const singleElimination = () => {
19387
19393
  const { matchUps } = treeMatchUps(params);
19388
19394
  const structure = structureTemplate({
19389
19395
  structureId: structureId || uuids?.pop(),
19390
- structureName: structureName || main,
19391
19396
  stageSequence,
19397
+ structureName,
19392
19398
  matchUpType,
19393
19399
  matchUps,
19394
19400
  stage
@@ -19399,9 +19405,9 @@ function getGenerators(params) {
19399
19405
  [AD_HOC]: () => {
19400
19406
  const structure = structureTemplate({
19401
19407
  structureId: structureId || uuids?.pop(),
19402
- structureName: structureName || main,
19403
19408
  finishingPosition: WIN_RATIO,
19404
19409
  stageSequence,
19410
+ structureName,
19405
19411
  matchUps: [],
19406
19412
  matchUpType,
19407
19413
  stage
@@ -19412,8 +19418,8 @@ function getGenerators(params) {
19412
19418
  const { matchUps } = luckyDraw(params);
19413
19419
  const structure = structureTemplate({
19414
19420
  structureId: structureId || uuids?.pop(),
19415
- structureName: structureName || main,
19416
19421
  stageSequence,
19422
+ structureName,
19417
19423
  matchUpType,
19418
19424
  matchUps,
19419
19425
  stage
@@ -19425,12 +19431,12 @@ function getGenerators(params) {
19425
19431
  [COMPASS]: () => generatePlayoffStructures({
19426
19432
  ...params,
19427
19433
  roundOffsetLimit: 3,
19428
- playoffAttributes: compassAttributes
19434
+ playoffAttributes: playoffAttributes ?? COMPASS_ATTRIBUTES
19429
19435
  }),
19430
19436
  [OLYMPIC]: () => generatePlayoffStructures({
19431
19437
  ...params,
19432
19438
  roundOffsetLimit: 2,
19433
- playoffAttributes: olympicAttributes
19439
+ playoffAttributes: playoffAttributes ?? OLYMPIC_ATTRIBUTES
19434
19440
  }),
19435
19441
  [PLAY_OFF]: () => {
19436
19442
  return generatePlayoffStructures(params);
@@ -19439,8 +19445,8 @@ function getGenerators(params) {
19439
19445
  const { matchUps } = feedInMatchUps({ drawSize, uuids, matchUpType });
19440
19446
  const structure = structureTemplate({
19441
19447
  structureId: structureId || uuids?.pop(),
19442
- structureName: structureName || main,
19443
19448
  stageSequence,
19449
+ structureName,
19444
19450
  matchUpType,
19445
19451
  stage: MAIN,
19446
19452
  matchUps
@@ -20217,7 +20223,9 @@ function generateQualifyingStructures({
20217
20223
  }
20218
20224
  const roundTargetName = qualifyingProfiles.length > 1 ? `${roundTarget}-` : "";
20219
20225
  const stageSequenceName = structureProfiles.length > 1 || roundTargetName ? stageSequence : "";
20220
- const qualifyingStructureName = structureName || (roundTargetName || stageSequenceName ? `${QUALIFYING} ${roundTargetName}${stageSequenceName}` : QUALIFYING);
20226
+ const qualifyingStructureName = structureName || (roundTargetName || stageSequenceName ? `${constantToString(
20227
+ QUALIFYING
20228
+ )} ${roundTargetName}${stageSequenceName}` : constantToString(QUALIFYING));
20221
20229
  if (drawType === ROUND_ROBIN) {
20222
20230
  const {
20223
20231
  structures: structures2,
@@ -20686,7 +20694,7 @@ function generateDrawTypeAndModifyDrawDefinition(params) {
20686
20694
  }
20687
20695
 
20688
20696
  function addVoluntaryConsolationStructure$1({
20689
- structureName = VOLUNTARY_CONSOLATION,
20697
+ structureName = constantToString(VOLUNTARY_CONSOLATION),
20690
20698
  structureAbbreviation,
20691
20699
  drawDefinition,
20692
20700
  matchUpType,