tods-competition-factory 1.8.23 → 1.8.24

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/README.md CHANGED
@@ -39,7 +39,7 @@ By default a deep copy of documents are made as they are loaded into each state
39
39
  ## Other Utilities
40
40
 
41
41
  1. [**mocksEngine**](./overview/mocks-engine-overview) - generates complete tournament objects, or tournamentRecords, as well as mock persons, participants and matchUp outcomes.
42
- It is used extensively in the ~1850 tests that are run against the factory methods before every package release.
42
+ It is used extensively in the ~1900 tests that are run against the factory methods before every package release.
43
43
  2. [**scoreGovernor**](./scoreGovernor) - is a collection of scoring related utilities which provide analysis/validation or generate values, but do not make any mutations.
44
44
  3. [**matchUpFormatCode**](./codes/matchup-format) - is an ITF matchUp format code parser, stringifier, and validator.
45
45
  4. [**ageCategoryCode**](./codes/age-category) - is an ITF ageCategoryCode parser.
@@ -4305,7 +4305,8 @@ const POLICY_ROUND_NAMING_DEFAULT = {
4305
4305
  [POLICY_TYPE_ROUND_NAMING]: {
4306
4306
  policyName: "Round Naming Default",
4307
4307
  namingConventions: {
4308
- round: "Round"
4308
+ round: "Round",
4309
+ pre: "Pre"
4309
4310
  },
4310
4311
  qualifyingFinishMap: {
4311
4312
  1: "Final"
@@ -4349,12 +4350,11 @@ function getRoundContextProfile({
4349
4350
  const roundNamingProfile = {};
4350
4351
  const defaultRoundNamingPolicy = POLICY_ROUND_NAMING_DEFAULT[POLICY_TYPE_ROUND_NAMING];
4351
4352
  const isQualifying = structure.stage === QUALIFYING;
4352
- const qualifyingFinishgMap = isQualifying && (roundNamingPolicy?.qualifyingFinishMap || defaultRoundNamingPolicy?.qualifyingFinishMap || {});
4353
4353
  const qualifyingStageSequences = isQualifying ? Math.max(
4354
4354
  ...(drawDefinition?.structures ?? []).filter((structure2) => structure2.stage === QUALIFYING).map(({ stageSequence }) => stageSequence ?? 1),
4355
4355
  0
4356
4356
  ) : 0;
4357
- const preQualifyingSequence = qualifyingStageSequences ? qualifyingStageSequences - (structure.stageSequence ?? 1) || "" : "";
4357
+ const preQualifyingSequence = (structure.stageSequence ?? 1) < qualifyingStageSequences ? structure.stageSequence ?? 1 : "";
4358
4358
  const preQualifyingAffix = preQualifyingSequence ? roundNamingPolicy?.affixes?.preQualifying || defaultRoundNamingPolicy.affixes.preQualifying || "" : "";
4359
4359
  const roundNamingMap = roundNamingPolicy?.roundNamingMap || defaultRoundNamingPolicy.roundNamingMap || {};
4360
4360
  const abbreviatedRoundNamingMap = roundNamingPolicy?.abbreviatedRoundNamingMap || defaultRoundNamingPolicy.abbreviatedRoundNamingMap || {};
@@ -4378,6 +4378,7 @@ function getRoundContextProfile({
4378
4378
  })
4379
4379
  );
4380
4380
  } else {
4381
+ const qualifyingFinishgMap = isQualifying && (roundNamingPolicy?.qualifyingFinishMap || defaultRoundNamingPolicy?.qualifyingFinishMap || {});
4381
4382
  Object.assign(
4382
4383
  roundNamingProfile,
4383
4384
  ...roundProfileKeys.map((round) => {
@@ -13220,7 +13221,10 @@ function automatedPositioning$1({
13220
13221
  return { positionAssignments, conflicts, ...SUCCESS, positioningReport };
13221
13222
  }
13222
13223
 
13223
- function getPlayoffStructures({ drawDefinition, structureId }) {
13224
+ function getPlayoffStructures({
13225
+ drawDefinition,
13226
+ structureId
13227
+ }) {
13224
13228
  if (!drawDefinition)
13225
13229
  return { error: MISSING_DRAW_DEFINITION };
13226
13230
  const { structure } = findStructure({ drawDefinition, structureId });
@@ -15519,18 +15523,17 @@ function getTallyReport({ matchUps, order, report }) {
15519
15523
  readable.push(excluded);
15520
15524
  } else {
15521
15525
  const floatSort = (a, b) => parseFloat(step.reversed ? a : b) - parseFloat(step.reversed ? b : a);
15526
+ const participantsCount = step.groups ? Object.values(step.groups).flat(Infinity).length : step.participantIds?.length ?? 0;
15522
15527
  const getExplanation = (step2) => {
15523
- Object.keys(step2.groups).sort(floatSort).forEach((key) => {
15528
+ step2.groups && Object.keys(step2.groups).sort(floatSort).forEach((key) => {
15524
15529
  const participantNames = step2.groups[key].map((participantId) => participants[participantId]).join(", ");
15525
15530
  const explanation = `${key} ${step2.attribute}: ${participantNames}`;
15526
15531
  readable.push(explanation);
15527
15532
  });
15528
15533
  };
15529
15534
  const reversed = step.reversed ? " in reverse order" : "";
15530
- const participantsCount = Object.values(step.groups).flat(
15531
- Infinity
15532
- ).length;
15533
- const description = `Step ${i + 1}: ${participantsCount} particiants were grouped${reversed} by ${step.attribute}`;
15535
+ const action = step.groups ? "grouped" : "separated";
15536
+ const description = `Step ${i + 1}: ${participantsCount} particiants were ${action}${reversed} by ${step.attribute}`;
15534
15537
  readable.push(description);
15535
15538
  if (step.idsFilter) {
15536
15539
  const note = `${step.attribute} was calculated considering ONLY TIED PARTICIPANTS`;
@@ -15546,7 +15549,7 @@ function getTallyReport({ matchUps, order, report }) {
15546
15549
  const { participantId, resolved } = orderEntry;
15547
15550
  const pOrder = orderEntry.groupOrder || orderEntry.provisionalOrder;
15548
15551
  readable.push(
15549
- `${pOrder}: ${participants[participantId]} => resolved: ${resolved}`
15552
+ `${pOrder}: ${participants[participantId]} => resolved: ${!!resolved}`
15550
15553
  );
15551
15554
  });
15552
15555
  return readable.join("\r\n");
@@ -15635,7 +15638,7 @@ function getGroupOrder(params) {
15635
15638
  report.push({ attribute, groups: orderedTallyGroups });
15636
15639
  const groupOrder = Object.keys(orderedTallyGroups).map((key) => parseFloat(key)).sort((a, b) => b - a).map((key) => orderedTallyGroups[key]).map((participantIds) => {
15637
15640
  const result = groupSubSort({ participantIds, ...params });
15638
- report.push(result.report);
15641
+ report.push(...result.report || []);
15639
15642
  return result.order;
15640
15643
  }).flat(Infinity);
15641
15644
  let groupPosition = 1;
@@ -15727,7 +15730,7 @@ function processAttribute({
15727
15730
  tallyPolicy,
15728
15731
  matchUps
15729
15732
  });
15730
- report.push(result.report);
15733
+ report.push(...result.report || []);
15731
15734
  return result.order;
15732
15735
  }).flat(Infinity);
15733
15736
  }
@@ -15741,6 +15744,9 @@ function groupSubSort({
15741
15744
  tallyPolicy,
15742
15745
  matchUps
15743
15746
  }) {
15747
+ const excludedDirectives = [];
15748
+ const report = [];
15749
+ let result;
15744
15750
  if (participantIds?.length === 1) {
15745
15751
  const participantId = participantIds[0];
15746
15752
  return {
@@ -15749,13 +15755,13 @@ function groupSubSort({
15749
15755
  }
15750
15756
  if (participantIds?.length === 2 && (!tallyPolicy?.headToHead || !tallyPolicy.headToHead.disabled && !disableHeadToHead)) {
15751
15757
  const result2 = headToHeadWinner({ participantIds, participantResults });
15752
- if (result2)
15753
- return { order: [result2], headToHeadWinner: result2[0].participantId };
15758
+ if (result2) {
15759
+ const headToHeadWinner2 = result2[0].participantId;
15760
+ report.push({ attribute: "head2Head", participantIds, headToHeadWinner: headToHeadWinner2 });
15761
+ return { order: [result2], headToHeadWinner: headToHeadWinner2, report };
15762
+ }
15754
15763
  }
15755
15764
  const directives = tallyPolicy?.tallyDirectives || headToHeadTallyDirectives;
15756
- const excludedDirectives = [];
15757
- const report = [];
15758
- let result;
15759
15765
  const filteredDirectives = directives.filter((directive) => {
15760
15766
  const keepDirective = isNumeric(directive.maxParticipants) && participantIds?.length > directive.maxParticipants ? false : true;
15761
15767
  if (!keepDirective)
@@ -16119,8 +16125,10 @@ function modifyMatchUpScore({
16119
16125
  const matchUpFilters = isDualMatchUp ? { matchUpTypes: [TEAM$2] } : void 0;
16120
16126
  const { matchUps } = getAllStructureMatchUps({
16121
16127
  afterRecoveryTimes: false,
16128
+ tournamentRecord,
16122
16129
  inContext: true,
16123
16130
  matchUpFilters,
16131
+ drawDefinition,
16124
16132
  structure: structure2,
16125
16133
  event
16126
16134
  });