tods-competition-factory 1.6.27 → 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.
- package/README.md +3 -3
- package/dist/forge/generate.d.ts +2 -1
- package/dist/forge/generate.mjs +24 -14
- package/dist/forge/generate.mjs.map +1 -1
- package/dist/index.mjs +24 -15
- package/dist/index.mjs.map +1 -1
- package/dist/tods-competition-factory.development.cjs.js +95 -76
- package/dist/tods-competition-factory.development.cjs.js.map +1 -1
- package/dist/tods-competition-factory.production.cjs.min.js +1 -1
- package/dist/tods-competition-factory.production.cjs.min.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
[](https://www.npmjs.com/package/tods-competition-factory)
|
|
2
|
-
|
|
3
1
|
# Competition Factory
|
|
4
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/tods-competition-factory)
|
|
4
|
+
|
|
5
5
|
[Online Documentation with examples](https://courthive.github.io/tods-competition-factory/)
|
|
6
6
|
|
|
7
7
|
## Tournament Business Rules
|
|
@@ -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 ~
|
|
42
|
+
It is used extensively in the ~1850 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.
|
package/dist/forge/generate.d.ts
CHANGED
|
@@ -1458,9 +1458,10 @@ type GenerateDrawDefinitionArgs = {
|
|
|
1458
1458
|
considerEventEntries?: boolean;
|
|
1459
1459
|
hydrateCollections?: boolean;
|
|
1460
1460
|
tournamentRecord: Tournament;
|
|
1461
|
-
|
|
1461
|
+
drawTypeCoercion?: boolean;
|
|
1462
1462
|
ignoreStageSpace?: boolean;
|
|
1463
1463
|
qualifyingProfiles?: any[];
|
|
1464
|
+
drawMatic?: DrawMaticArgs;
|
|
1464
1465
|
qualifyingOnly?: boolean;
|
|
1465
1466
|
drawType?: DrawTypeEnum;
|
|
1466
1467
|
enforceGender?: boolean;
|
package/dist/forge/generate.mjs
CHANGED
|
@@ -1382,6 +1382,7 @@ function findPolicy({
|
|
|
1382
1382
|
|
|
1383
1383
|
const POLICY_TYPE_COMPETITIVE_BANDS = "competitiveBands";
|
|
1384
1384
|
const POLICY_TYPE_ROUND_ROBIN_TALLY = "roundRobinTally";
|
|
1385
|
+
const POLICY_TYPE_MATCHUP_ACTIONS = "matchUpActions";
|
|
1385
1386
|
const POLICY_TYPE_ROUND_NAMING = "roundNaming";
|
|
1386
1387
|
const POLICY_TYPE_PARTICIPANT = "participant";
|
|
1387
1388
|
const POLICY_TYPE_SCHEDULING = "scheduling";
|
|
@@ -14457,9 +14458,9 @@ function processPlayoffGroups({
|
|
|
14457
14458
|
for (const playoffGroup of playoffGroups) {
|
|
14458
14459
|
const finishingPositions = playoffGroup.finishingPositions;
|
|
14459
14460
|
const positionsPlayedOff = positionRangeMap && finishingPositions.map((p) => positionRangeMap[p]?.finishingPositions).flat();
|
|
14460
|
-
const playoffDrawType = playoffGroup.drawType || SINGLE_ELIMINATION;
|
|
14461
14461
|
const participantsInDraw = groupCount * finishingPositions.length;
|
|
14462
14462
|
const drawSize = nextPowerOf2(participantsInDraw);
|
|
14463
|
+
const playoffDrawType = drawSize === 2 && SINGLE_ELIMINATION || playoffGroup.drawType || SINGLE_ELIMINATION;
|
|
14463
14464
|
if (positionsPlayedOff) {
|
|
14464
14465
|
finishingPositionOffset = Math.min(...positionsPlayedOff) - 1;
|
|
14465
14466
|
}
|
|
@@ -20157,9 +20158,9 @@ function generateQualifyingStructures({
|
|
|
20157
20158
|
function generateDrawStructuresAndLinks(params) {
|
|
20158
20159
|
const {
|
|
20159
20160
|
enforceMinimumDrawSize = true,
|
|
20160
|
-
|
|
20161
|
-
drawTypeCoercion,
|
|
20161
|
+
drawTypeCoercion = true,
|
|
20162
20162
|
// coerce to SINGLE_ELIMINATION for drawSize: 2
|
|
20163
|
+
overwriteExisting,
|
|
20163
20164
|
appliedPolicies,
|
|
20164
20165
|
staggeredEntry,
|
|
20165
20166
|
// optional - specifies main structure FEED_IN for drawTypes CURTIS_CONSOLATION, FEED_IN_CHAMPIONSHIPS, FMLC
|
|
@@ -20170,7 +20171,7 @@ function generateDrawStructuresAndLinks(params) {
|
|
|
20170
20171
|
uuids
|
|
20171
20172
|
} = params || {};
|
|
20172
20173
|
const stack = "generateDrawStructuresAndLinks";
|
|
20173
|
-
let drawType = params.drawType
|
|
20174
|
+
let drawType = drawTypeCoercion && params.drawSize === 2 && DrawTypeEnum.SingleElimination || params.drawType || DrawTypeEnum.SingleElimination;
|
|
20174
20175
|
const structures = [], links = [];
|
|
20175
20176
|
const matchUpType = params?.matchUpType ?? SINGLES$1;
|
|
20176
20177
|
const existingQualifyingStructures = drawDefinition?.structures?.filter(
|
|
@@ -20859,9 +20860,12 @@ function isUngrouped(entryStatus) {
|
|
|
20859
20860
|
|
|
20860
20861
|
function checkValidEntries({
|
|
20861
20862
|
enforceGender = true,
|
|
20863
|
+
consideredEntries,
|
|
20864
|
+
tournamentRecord,
|
|
20862
20865
|
participants,
|
|
20863
20866
|
event
|
|
20864
20867
|
}) {
|
|
20868
|
+
participants = participants || tournamentRecord?.participants;
|
|
20865
20869
|
if (!participants)
|
|
20866
20870
|
return { error: MISSING_PARTICIPANTS };
|
|
20867
20871
|
if (!Array.isArray(participants))
|
|
@@ -20872,7 +20876,7 @@ function checkValidEntries({
|
|
|
20872
20876
|
const participantType = eventType === TEAM_EVENT && TEAM || eventType === DOUBLES_EVENT && PAIR || INDIVIDUAL;
|
|
20873
20877
|
const entryStatusMap = Object.assign(
|
|
20874
20878
|
{},
|
|
20875
|
-
...(event.entries || []).map((entry) => ({
|
|
20879
|
+
...(consideredEntries || event.entries || []).map((entry) => ({
|
|
20876
20880
|
[entry.participantId]: entry.entryStatus
|
|
20877
20881
|
}))
|
|
20878
20882
|
);
|
|
@@ -22646,9 +22650,9 @@ const POLICY_SEEDING_USTA = {
|
|
|
22646
22650
|
function generateDrawDefinition(params) {
|
|
22647
22651
|
const stack = "generateDrawDefinition";
|
|
22648
22652
|
const {
|
|
22649
|
-
drawType = DrawTypeEnum.SingleElimination,
|
|
22650
22653
|
considerEventEntries = true,
|
|
22651
22654
|
// in the absence of drawSize and drawEntries, look to event.entries
|
|
22655
|
+
drawTypeCoercion = true,
|
|
22652
22656
|
ignoreAllowedDrawTypes,
|
|
22653
22657
|
voluntaryConsolation,
|
|
22654
22658
|
hydrateCollections,
|
|
@@ -22656,20 +22660,22 @@ function generateDrawDefinition(params) {
|
|
|
22656
22660
|
ignoreStageSpace,
|
|
22657
22661
|
tournamentRecord,
|
|
22658
22662
|
qualifyingOnly,
|
|
22659
|
-
enforceGender,
|
|
22660
22663
|
tieFormatName,
|
|
22661
22664
|
drawEntries,
|
|
22662
22665
|
addToEvent,
|
|
22663
22666
|
placeByes,
|
|
22664
22667
|
event
|
|
22665
22668
|
} = params;
|
|
22669
|
+
const drawType = drawTypeCoercion && params.drawSize === 2 && DrawTypeEnum.SingleElimination || params.drawType || DrawTypeEnum.SingleElimination;
|
|
22666
22670
|
const { tournamentParticipants: participants } = getTournamentParticipants({
|
|
22667
22671
|
tournamentRecord,
|
|
22668
22672
|
inContext: true
|
|
22669
22673
|
});
|
|
22670
|
-
const
|
|
22671
|
-
|
|
22672
|
-
|
|
22674
|
+
const appliedPolicies = getAppliedPolicies({
|
|
22675
|
+
tournamentRecord,
|
|
22676
|
+
event
|
|
22677
|
+
}).appliedPolicies ?? {};
|
|
22678
|
+
const enforceGender = params.enforceGender ?? policyDefinitions?.[POLICY_TYPE_MATCHUP_ACTIONS]?.participants?.enforceGender ?? appliedPolicies?.[POLICY_TYPE_MATCHUP_ACTIONS]?.participants?.enforceGender;
|
|
22673
22679
|
const allowedDrawTypes = !ignoreAllowedDrawTypes && tournamentRecord && getAllowedDrawTypes({
|
|
22674
22680
|
tournamentRecord,
|
|
22675
22681
|
categoryType: event?.category?.categoryType,
|
|
@@ -22682,6 +22688,14 @@ function generateDrawDefinition(params) {
|
|
|
22682
22688
|
(entry) => entry.entryStatus && [...STRUCTURE_ENTERED_TYPES, QUALIFIER].includes(entry.entryStatus)
|
|
22683
22689
|
) ?? [];
|
|
22684
22690
|
const consideredEntries = (qualifyingOnly && [] || drawEntries || (considerEventEntries ? eventEntries : [])).filter(({ entryStage }) => !entryStage || entryStage === MAIN);
|
|
22691
|
+
const validEntriesResult = event && participants && checkValidEntries({
|
|
22692
|
+
consideredEntries,
|
|
22693
|
+
enforceGender,
|
|
22694
|
+
participants,
|
|
22695
|
+
event
|
|
22696
|
+
});
|
|
22697
|
+
if (validEntriesResult?.error)
|
|
22698
|
+
return decorateResult({ result: validEntriesResult, stack });
|
|
22685
22699
|
const derivedDrawSize = !params.drawSize && consideredEntries.length && ![
|
|
22686
22700
|
AD_HOC,
|
|
22687
22701
|
DOUBLE_ELIMINATION,
|
|
@@ -22763,10 +22777,6 @@ function generateDrawDefinition(params) {
|
|
|
22763
22777
|
drawDefinition.matchUpType = matchUpType;
|
|
22764
22778
|
}
|
|
22765
22779
|
}
|
|
22766
|
-
const appliedPolicies = getAppliedPolicies({
|
|
22767
|
-
tournamentRecord,
|
|
22768
|
-
event
|
|
22769
|
-
}).appliedPolicies ?? {};
|
|
22770
22780
|
if (policyDefinitions) {
|
|
22771
22781
|
if (typeof policyDefinitions !== "object") {
|
|
22772
22782
|
return decorateResult({
|