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.
package/dist/index.mjs CHANGED
@@ -333,7 +333,7 @@ const matchUpFormatCode = {
333
333
  };
334
334
 
335
335
  function factoryVersion() {
336
- return "1.8.2";
336
+ return "1.8.3";
337
337
  }
338
338
 
339
339
  function getObjectTieFormat(obj) {
@@ -6441,20 +6441,20 @@ const ROUND_ROBIN_WITH_PLAYOFF = "ROUND_ROBIN_WITH_PLAYOFF";
6441
6441
  const DECIDER = "DECIDER";
6442
6442
  const BACKDRAW = "BACKDRAW";
6443
6443
  const COMPASS_ATTRIBUTES = {
6444
- 0: { name: "EAST", abbreviation: "E" },
6445
- "0-1": { name: "WEST", abbreviation: "W" },
6446
- "0-2": { name: "NORTH", abbreviation: "N" },
6447
- "0-3": { name: "NORTHEAST", abbreviation: "NE" },
6448
- "0-1-1": { name: "SOUTH", abbreviation: "S" },
6449
- "0-1-2": { name: "SOUTHWEST", abbreviation: "SW" },
6450
- "0-2-1": { name: "NORTHWEST", abbreviation: "NW" },
6451
- "0-1-1-1": { name: "SOUTHEAST", abbreviation: "SE" }
6444
+ 0: { name: "East", abbreviation: "E" },
6445
+ "0-1": { name: "West", abbreviation: "W" },
6446
+ "0-2": { name: "North", abbreviation: "N" },
6447
+ "0-3": { name: "Northeast", abbreviation: "NE" },
6448
+ "0-1-1": { name: "South", abbreviation: "S" },
6449
+ "0-1-2": { name: "Southwest", abbreviation: "SW" },
6450
+ "0-2-1": { name: "Northwest", abbreviation: "NW" },
6451
+ "0-1-1-1": { name: "Southeast", abbreviation: "SE" }
6452
6452
  };
6453
6453
  const OLYMPIC_ATTRIBUTES = {
6454
- 0: { name: "EAST", abbreviation: "E" },
6455
- "0-1": { name: "WEST", abbreviation: "W" },
6456
- "0-2": { name: "NORTH", abbreviation: "N" },
6457
- "0-1-1": { name: "SOUTH", abbreviation: "S" }
6454
+ 0: { name: "East", abbreviation: "E" },
6455
+ "0-1": { name: "West", abbreviation: "W" },
6456
+ "0-2": { name: "North", abbreviation: "N" },
6457
+ "0-1-1": { name: "South", abbreviation: "S" }
6458
6458
  };
6459
6459
  const WIN_RATIO = "WIN_RATIO";
6460
6460
  const ROUND_OUTCOME = "ROUND_OUTCOME";
@@ -23110,6 +23110,7 @@ const structureTemplate = ({
23110
23110
 
23111
23111
  function generateRoundRobin({
23112
23112
  structureName = constantToString(MAIN),
23113
+ groupNameBase = "Group",
23113
23114
  stageSequence = 1,
23114
23115
  structureOptions,
23115
23116
  appliedPolicies,
@@ -23143,7 +23144,7 @@ function generateRoundRobin({
23143
23144
  ...matchUps.map(({ roundNumber }) => roundNumber)
23144
23145
  );
23145
23146
  return structureTemplate({
23146
- structureName: `Group ${structureOrder}`,
23147
+ structureName: `${groupNameBase} ${structureOrder}`,
23147
23148
  structureId: uuids?.pop(),
23148
23149
  structureType: ITEM,
23149
23150
  finishingPosition,
@@ -39230,7 +39231,7 @@ function competitionEngineAsync(test) {
39230
39231
  }
39231
39232
 
39232
39233
  function addVoluntaryConsolationStructure$1({
39233
- structureName = VOLUNTARY_CONSOLATION,
39234
+ structureName = constantToString(VOLUNTARY_CONSOLATION),
39234
39235
  structureAbbreviation,
39235
39236
  drawDefinition,
39236
39237
  matchUpType,
@@ -39458,7 +39459,9 @@ function generateQualifyingStructures({
39458
39459
  }
39459
39460
  const roundTargetName = qualifyingProfiles.length > 1 ? `${roundTarget}-` : "";
39460
39461
  const stageSequenceName = structureProfiles.length > 1 || roundTargetName ? stageSequence : "";
39461
- const qualifyingStructureName = structureName || (roundTargetName || stageSequenceName ? `${QUALIFYING} ${roundTargetName}${stageSequenceName}` : QUALIFYING);
39462
+ const qualifyingStructureName = structureName || (roundTargetName || stageSequenceName ? `${constantToString(
39463
+ QUALIFYING
39464
+ )} ${roundTargetName}${stageSequenceName}` : constantToString(QUALIFYING));
39462
39465
  if (drawType === ROUND_ROBIN) {
39463
39466
  const {
39464
39467
  structures: structures2,
@@ -40104,6 +40107,7 @@ function roundMatchCounts({ drawSize }) {
40104
40107
  function firstRoundLoserConsolation(params) {
40105
40108
  const {
40106
40109
  finishingPositionOffset = 0,
40110
+ playoffAttributes,
40107
40111
  stageSequence = 1,
40108
40112
  staggeredEntry,
40109
40113
  structureName,
@@ -40125,7 +40129,7 @@ function firstRoundLoserConsolation(params) {
40125
40129
  };
40126
40130
  const { matchUps } = staggeredEntry ? feedInMatchUps(mainParams) : treeMatchUps(mainParams);
40127
40131
  const mainStructure = structureTemplate({
40128
- structureName: structureName || constantToString(MAIN),
40132
+ structureName: structureName || playoffAttributes?.["0"]?.name || constantToString(MAIN),
40129
40133
  structureId: structureId || uuids?.pop(),
40130
40134
  stageSequence,
40131
40135
  matchUpType,
@@ -40144,7 +40148,7 @@ function firstRoundLoserConsolation(params) {
40144
40148
  isMock
40145
40149
  });
40146
40150
  const consolation = constantToString(CONSOLATION);
40147
- const consolationStructureName = params.consolationStructureName || (structureName ? `${structureName} ${consolation}` : consolation);
40151
+ const consolationStructureName = playoffAttributes?.["0-1"]?.name ?? params.consolationStructureName ?? (structureName ? `${structureName} ${consolation}` : consolation);
40148
40152
  const consolationStructure = structureTemplate({
40149
40153
  structureName: consolationStructureName,
40150
40154
  matchUps: consolationMatchUps,
@@ -40222,10 +40226,10 @@ function feedInLinks({
40222
40226
 
40223
40227
  function generateCurtisConsolation(params) {
40224
40228
  const {
40225
- structureName = constantToString(MAIN),
40226
40229
  playoffStructureNameBase,
40227
40230
  finishingPositionOffset,
40228
40231
  stageSequence = 1,
40232
+ playoffAttributes,
40229
40233
  structureNameMap,
40230
40234
  staggeredEntry,
40231
40235
  stage = MAIN,
@@ -40245,6 +40249,7 @@ function generateCurtisConsolation(params) {
40245
40249
  uuids
40246
40250
  };
40247
40251
  const { matchUps, roundsCount: mainDrawRoundsCount } = staggeredEntry ? feedInMatchUps(mainParams) : treeMatchUps(mainParams);
40252
+ const structureName = params.structureName ?? playoffAttributes?.["0"]?.name ?? constantToString(MAIN);
40248
40253
  const mainStructure = structureTemplate({
40249
40254
  structureId: structureId || uuids?.pop(),
40250
40255
  structureName,
@@ -40263,6 +40268,7 @@ function generateCurtisConsolation(params) {
40263
40268
  idPrefix: idPrefix && `${idPrefix}-c${index}`,
40264
40269
  structureId: uuids?.pop(),
40265
40270
  playoffStructureNameBase,
40271
+ playoffAttributes,
40266
40272
  structureNameMap,
40267
40273
  stageSequence: stageSequence2,
40268
40274
  roundOffset,
@@ -40291,7 +40297,7 @@ function generateCurtisConsolation(params) {
40291
40297
  matchUpType,
40292
40298
  isMock
40293
40299
  });
40294
- const defaultName = constantToString(PLAY_OFF);
40300
+ const defaultName = playoffAttributes?.["3-4"]?.name ?? constantToString(PLAY_OFF);
40295
40301
  const mappedStructureName = structureNameMap?.[defaultName] || defaultName;
40296
40302
  const structureName2 = playoffStructureNameBase ? `${playoffStructureNameBase} ${mappedStructureName}` : mappedStructureName;
40297
40303
  const playoffStructure = structureTemplate({
@@ -40323,6 +40329,7 @@ function generateCurtisConsolation(params) {
40323
40329
  function consolationFeedStructure({
40324
40330
  playoffStructureNameBase,
40325
40331
  stageSequence = 1,
40332
+ playoffAttributes,
40326
40333
  structureNameMap,
40327
40334
  roundOffset = 0,
40328
40335
  matchUpType,
@@ -40344,7 +40351,8 @@ function consolationFeedStructure({
40344
40351
  isMock,
40345
40352
  uuids
40346
40353
  });
40347
- const defaultName = `${constantToString(CONSOLATION)} ${index + 1}`;
40354
+ const indexedStructureName = index === 0 && playoffAttributes?.["0-1"]?.name || index === 1 && playoffAttributes?.["0-3"]?.name;
40355
+ const defaultName = indexedStructureName || `${constantToString(CONSOLATION)} ${index + 1}`;
40348
40356
  const mappedStructureName = structureNameMap?.[defaultName] || defaultName;
40349
40357
  const structureName = playoffStructureNameBase ? `${playoffStructureNameBase} ${mappedStructureName}` : mappedStructureName;
40350
40358
  const consolationStructure = structureTemplate({
@@ -40394,7 +40402,7 @@ function generatePlayoffStructures(params) {
40394
40402
  const finishingPositionRange = `${finishingPositionsFrom}-${finishingPositionsTo}`;
40395
40403
  const attributeProfile = playoffAttributes?.[exitProfile];
40396
40404
  const base = playoffStructureNameBase && `${playoffStructureNameBase} ` || "";
40397
- const customNaming = finishingPositionNaming?.[finishingPositionRange];
40405
+ const customNaming = playoffAttributes?.[finishingPositionRange] ?? finishingPositionNaming?.[finishingPositionRange];
40398
40406
  const structureName = customNaming?.name || attributeProfile?.name && (addNameBaseToAttributeName ? `${base}${attributeProfile?.name}` : attributeProfile.name) || `${base}${finishingPositionRange}`;
40399
40407
  const structureAbbreviation = customNaming?.abbreviation || attributeProfile?.abbreviation;
40400
40408
  const mainParams = {
@@ -40499,6 +40507,7 @@ function feedInChampionship(params) {
40499
40507
  const {
40500
40508
  finishingPositionOffset,
40501
40509
  stageSequence = 1,
40510
+ playoffAttributes,
40502
40511
  policyDefinitions,
40503
40512
  feedsFromFinal,
40504
40513
  staggeredEntry,
@@ -40526,7 +40535,7 @@ function feedInChampionship(params) {
40526
40535
  };
40527
40536
  const { matchUps } = staggeredEntry ? feedInMatchUps(mainParams) : treeMatchUps(mainParams);
40528
40537
  const mainStructure = structureTemplate({
40529
- structureName: structureName || constantToString(MAIN),
40538
+ structureName: structureName || playoffAttributes?.["0"]?.name || constantToString(MAIN),
40530
40539
  structureId: structureId || uuids?.pop(),
40531
40540
  stageSequence,
40532
40541
  matchUpType,
@@ -40551,7 +40560,7 @@ function feedInChampionship(params) {
40551
40560
  });
40552
40561
  if (drawSize > 2) {
40553
40562
  const consolationStructure = structureTemplate({
40554
- structureName: constantToString(CONSOLATION),
40563
+ structureName: playoffAttributes?.["0-1"]?.name ?? constantToString(CONSOLATION),
40555
40564
  matchUps: consolationMatchUps,
40556
40565
  structureId: uuids?.pop(),
40557
40566
  stage: CONSOLATION,
@@ -40576,10 +40585,9 @@ function feedInChampionship(params) {
40576
40585
  }
40577
40586
 
40578
40587
  function processPlayoffGroups({
40579
- compassAttributes = COMPASS_ATTRIBUTES,
40580
- olympicAttributes = OLYMPIC_ATTRIBUTES,
40581
40588
  requireSequential = true,
40582
40589
  playoffMatchUpFormat,
40590
+ playoffAttributes,
40583
40591
  sourceStructureId,
40584
40592
  policyDefinitions,
40585
40593
  stageSequence,
@@ -40628,6 +40636,8 @@ function processPlayoffGroups({
40628
40636
  if (positionsPlayedOff) {
40629
40637
  finishingPositionOffset = Math.min(...positionsPlayedOff) - 1;
40630
40638
  }
40639
+ const finishingPositionRange = positionsPlayedOff && `${Math.min(...positionsPlayedOff)}-${Math.max(...positionsPlayedOff)}`;
40640
+ const structureName = playoffGroup.structureName || finishingPositionRange && playoffGroup.playoffAttributes?.[finishingPositionRange]?.name || playoffGroup.playoffAttributes?.["0"]?.name;
40631
40641
  const playoffGroupParams = {
40632
40642
  addNameBaseToAttributeName: playoffGroup.addNameBaseToAttributeName,
40633
40643
  playoffStructureNameBase: playoffGroup.playoffStructureNameBase,
@@ -40636,8 +40646,8 @@ function processPlayoffGroups({
40636
40646
  structureId: playoffGroup.structureId ?? uuids?.pop(),
40637
40647
  playoffAttributes: playoffGroup.playoffAttributes,
40638
40648
  structureNameMap: playoffGroup.structureNameMap,
40639
- structureName: playoffGroup.structureName,
40640
- sequenceLimit: playoffGroup.sequenceLimit
40649
+ sequenceLimit: playoffGroup.sequenceLimit,
40650
+ structureName
40641
40651
  };
40642
40652
  const params = {
40643
40653
  ...playoffGroupParams,
@@ -40679,9 +40689,9 @@ function processPlayoffGroups({
40679
40689
  });
40680
40690
  const playoffStructure = structureTemplate({
40681
40691
  structureId: playoffGroup.structureId ?? uuids?.pop(),
40682
- structureName: playoffGroup.structureName,
40683
40692
  matchUpFormat: playoffMatchUpFormat,
40684
40693
  stage: PLAY_OFF,
40694
+ structureName,
40685
40695
  stageSequence,
40686
40696
  matchUps
40687
40697
  });
@@ -40698,8 +40708,8 @@ function processPlayoffGroups({
40698
40708
  finishingPositions
40699
40709
  });
40700
40710
  } else if ([COMPASS, OLYMPIC, PLAY_OFF].includes(playoffDrawType)) {
40701
- const { structureName } = playoffGroup;
40702
40711
  const params2 = {
40712
+ playoffAttributes: playoffGroup.playoffAttributes ?? playoffAttributes,
40703
40713
  structureId: playoffGroup.structureId ?? uuids?.pop(),
40704
40714
  playoffStructureNameBase: structureName,
40705
40715
  idPrefix: idPrefix && `${idPrefix}-po`,
@@ -40714,12 +40724,12 @@ function processPlayoffGroups({
40714
40724
  };
40715
40725
  if (playoffDrawType === COMPASS) {
40716
40726
  Object.assign(params2, {
40717
- playoffAttributes: compassAttributes,
40727
+ playoffAttributes: playoffGroup?.playoffAttributes ?? playoffAttributes ?? COMPASS_ATTRIBUTES,
40718
40728
  roundOffsetLimit: 3
40719
40729
  });
40720
40730
  } else if (playoffDrawType === OLYMPIC) {
40721
40731
  Object.assign(params2, {
40722
- playoffAttributes: olympicAttributes,
40732
+ playoffAttributes: playoffGroup?.playoffAttributes ?? playoffAttributes ?? OLYMPIC_ATTRIBUTES,
40723
40733
  roundOffsetLimit: 2
40724
40734
  });
40725
40735
  }
@@ -40755,11 +40765,11 @@ function processPlayoffGroups({
40755
40765
  const uuidsFMLC = [uuids?.pop(), uuids?.pop()];
40756
40766
  const params2 = {
40757
40767
  structureId: playoffGroup.structureId ?? uuids?.pop(),
40758
- structureName: playoffGroup.structureName,
40759
40768
  idPrefix: idPrefix && `${idPrefix}-po`,
40760
40769
  finishingPositionOffset,
40761
40770
  uuids: uuidsFMLC,
40762
40771
  stage: PLAY_OFF,
40772
+ structureName,
40763
40773
  matchUpType,
40764
40774
  feedPolicy,
40765
40775
  drawSize,
@@ -41111,10 +41121,8 @@ function luckyRoundProfiles(drawSize) {
41111
41121
 
41112
41122
  function getGenerators(params) {
41113
41123
  const {
41114
- compassAttributes = COMPASS_ATTRIBUTES,
41115
- olympicAttributes = OLYMPIC_ATTRIBUTES,
41124
+ playoffAttributes,
41116
41125
  stageSequence = 1,
41117
- structureName,
41118
41126
  structureId,
41119
41127
  stage = MAIN,
41120
41128
  matchUpType,
@@ -41124,13 +41132,13 @@ function getGenerators(params) {
41124
41132
  const { appliedPolicies } = getAppliedPolicies(params);
41125
41133
  const feedPolicy = params.policyDefinitions?.[POLICY_TYPE_FEED_IN] || appliedPolicies?.[POLICY_TYPE_FEED_IN];
41126
41134
  params.skipRounds = params.skipRounds || drawSize <= 4 && (feedPolicy?.feedMainFinal ? 0 : 1) || 0;
41127
- const main = constantToString(MAIN);
41135
+ const structureName = params.structureName ?? playoffAttributes?.["0"]?.name ?? constantToString(MAIN);
41128
41136
  const singleElimination = () => {
41129
41137
  const { matchUps } = treeMatchUps(params);
41130
41138
  const structure = structureTemplate({
41131
41139
  structureId: structureId || uuids?.pop(),
41132
- structureName: structureName || main,
41133
41140
  stageSequence,
41141
+ structureName,
41134
41142
  matchUpType,
41135
41143
  matchUps,
41136
41144
  stage
@@ -41141,9 +41149,9 @@ function getGenerators(params) {
41141
41149
  [AD_HOC]: () => {
41142
41150
  const structure = structureTemplate({
41143
41151
  structureId: structureId || uuids?.pop(),
41144
- structureName: structureName || main,
41145
41152
  finishingPosition: WIN_RATIO,
41146
41153
  stageSequence,
41154
+ structureName,
41147
41155
  matchUps: [],
41148
41156
  matchUpType,
41149
41157
  stage
@@ -41154,8 +41162,8 @@ function getGenerators(params) {
41154
41162
  const { matchUps } = luckyDraw(params);
41155
41163
  const structure = structureTemplate({
41156
41164
  structureId: structureId || uuids?.pop(),
41157
- structureName: structureName || main,
41158
41165
  stageSequence,
41166
+ structureName,
41159
41167
  matchUpType,
41160
41168
  matchUps,
41161
41169
  stage
@@ -41167,12 +41175,12 @@ function getGenerators(params) {
41167
41175
  [COMPASS]: () => generatePlayoffStructures({
41168
41176
  ...params,
41169
41177
  roundOffsetLimit: 3,
41170
- playoffAttributes: compassAttributes
41178
+ playoffAttributes: playoffAttributes ?? COMPASS_ATTRIBUTES
41171
41179
  }),
41172
41180
  [OLYMPIC]: () => generatePlayoffStructures({
41173
41181
  ...params,
41174
41182
  roundOffsetLimit: 2,
41175
- playoffAttributes: olympicAttributes
41183
+ playoffAttributes: playoffAttributes ?? OLYMPIC_ATTRIBUTES
41176
41184
  }),
41177
41185
  [PLAY_OFF]: () => {
41178
41186
  return generatePlayoffStructures(params);
@@ -41181,8 +41189,8 @@ function getGenerators(params) {
41181
41189
  const { matchUps } = feedInMatchUps({ drawSize, uuids, matchUpType });
41182
41190
  const structure = structureTemplate({
41183
41191
  structureId: structureId || uuids?.pop(),
41184
- structureName: structureName || main,
41185
41192
  stageSequence,
41193
+ structureName,
41186
41194
  matchUpType,
41187
41195
  stage: MAIN,
41188
41196
  matchUps
@@ -44221,7 +44229,7 @@ function generateQualifyingStructure$1(params) {
44221
44229
  }
44222
44230
  const roundTargetName = roundTarget ? `${roundTarget}-` : "";
44223
44231
  const stageSequenceName = `${stageSequence}`;
44224
- const qualifyingStructureName = structureName || (roundTargetName || stageSequenceName ? `${QUALIFYING} ${roundTargetName}${stageSequenceName}` : QUALIFYING);
44232
+ const qualifyingStructureName = structureName || (roundTargetName || stageSequenceName ? `${constantToString(QUALIFYING)} ${roundTargetName}${stageSequenceName}` : constantToString(QUALIFYING));
44225
44233
  if (drawType === ROUND_ROBIN) {
44226
44234
  const { maxRoundNumber, structures, groupCount } = generateRoundRobin({
44227
44235
  structureName: structureName || qualifyingStructureName,