tods-competition-factory 1.6.28 → 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 +18 -9
- package/dist/forge/generate.mjs.map +1 -1
- package/dist/index.mjs +19 -10
- package/dist/index.mjs.map +1 -1
- package/dist/tods-competition-factory.development.cjs.js +43 -25
- 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 +1 -1
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
|
@@ -14458,9 +14458,9 @@ function processPlayoffGroups({
|
|
|
14458
14458
|
for (const playoffGroup of playoffGroups) {
|
|
14459
14459
|
const finishingPositions = playoffGroup.finishingPositions;
|
|
14460
14460
|
const positionsPlayedOff = positionRangeMap && finishingPositions.map((p) => positionRangeMap[p]?.finishingPositions).flat();
|
|
14461
|
-
const playoffDrawType = playoffGroup.drawType || SINGLE_ELIMINATION;
|
|
14462
14461
|
const participantsInDraw = groupCount * finishingPositions.length;
|
|
14463
14462
|
const drawSize = nextPowerOf2(participantsInDraw);
|
|
14463
|
+
const playoffDrawType = drawSize === 2 && SINGLE_ELIMINATION || playoffGroup.drawType || SINGLE_ELIMINATION;
|
|
14464
14464
|
if (positionsPlayedOff) {
|
|
14465
14465
|
finishingPositionOffset = Math.min(...positionsPlayedOff) - 1;
|
|
14466
14466
|
}
|
|
@@ -20158,9 +20158,9 @@ function generateQualifyingStructures({
|
|
|
20158
20158
|
function generateDrawStructuresAndLinks(params) {
|
|
20159
20159
|
const {
|
|
20160
20160
|
enforceMinimumDrawSize = true,
|
|
20161
|
-
|
|
20162
|
-
drawTypeCoercion,
|
|
20161
|
+
drawTypeCoercion = true,
|
|
20163
20162
|
// coerce to SINGLE_ELIMINATION for drawSize: 2
|
|
20163
|
+
overwriteExisting,
|
|
20164
20164
|
appliedPolicies,
|
|
20165
20165
|
staggeredEntry,
|
|
20166
20166
|
// optional - specifies main structure FEED_IN for drawTypes CURTIS_CONSOLATION, FEED_IN_CHAMPIONSHIPS, FMLC
|
|
@@ -20171,7 +20171,7 @@ function generateDrawStructuresAndLinks(params) {
|
|
|
20171
20171
|
uuids
|
|
20172
20172
|
} = params || {};
|
|
20173
20173
|
const stack = "generateDrawStructuresAndLinks";
|
|
20174
|
-
let drawType = params.drawType
|
|
20174
|
+
let drawType = drawTypeCoercion && params.drawSize === 2 && DrawTypeEnum.SingleElimination || params.drawType || DrawTypeEnum.SingleElimination;
|
|
20175
20175
|
const structures = [], links = [];
|
|
20176
20176
|
const matchUpType = params?.matchUpType ?? SINGLES$1;
|
|
20177
20177
|
const existingQualifyingStructures = drawDefinition?.structures?.filter(
|
|
@@ -20860,9 +20860,12 @@ function isUngrouped(entryStatus) {
|
|
|
20860
20860
|
|
|
20861
20861
|
function checkValidEntries({
|
|
20862
20862
|
enforceGender = true,
|
|
20863
|
+
consideredEntries,
|
|
20864
|
+
tournamentRecord,
|
|
20863
20865
|
participants,
|
|
20864
20866
|
event
|
|
20865
20867
|
}) {
|
|
20868
|
+
participants = participants || tournamentRecord?.participants;
|
|
20866
20869
|
if (!participants)
|
|
20867
20870
|
return { error: MISSING_PARTICIPANTS };
|
|
20868
20871
|
if (!Array.isArray(participants))
|
|
@@ -20873,7 +20876,7 @@ function checkValidEntries({
|
|
|
20873
20876
|
const participantType = eventType === TEAM_EVENT && TEAM || eventType === DOUBLES_EVENT && PAIR || INDIVIDUAL;
|
|
20874
20877
|
const entryStatusMap = Object.assign(
|
|
20875
20878
|
{},
|
|
20876
|
-
...(event.entries || []).map((entry) => ({
|
|
20879
|
+
...(consideredEntries || event.entries || []).map((entry) => ({
|
|
20877
20880
|
[entry.participantId]: entry.entryStatus
|
|
20878
20881
|
}))
|
|
20879
20882
|
);
|
|
@@ -22647,9 +22650,9 @@ const POLICY_SEEDING_USTA = {
|
|
|
22647
22650
|
function generateDrawDefinition(params) {
|
|
22648
22651
|
const stack = "generateDrawDefinition";
|
|
22649
22652
|
const {
|
|
22650
|
-
drawType = DrawTypeEnum.SingleElimination,
|
|
22651
22653
|
considerEventEntries = true,
|
|
22652
22654
|
// in the absence of drawSize and drawEntries, look to event.entries
|
|
22655
|
+
drawTypeCoercion = true,
|
|
22653
22656
|
ignoreAllowedDrawTypes,
|
|
22654
22657
|
voluntaryConsolation,
|
|
22655
22658
|
hydrateCollections,
|
|
@@ -22663,6 +22666,7 @@ function generateDrawDefinition(params) {
|
|
|
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
|
|
@@ -22672,9 +22676,6 @@ function generateDrawDefinition(params) {
|
|
|
22672
22676
|
event
|
|
22673
22677
|
}).appliedPolicies ?? {};
|
|
22674
22678
|
const enforceGender = params.enforceGender ?? policyDefinitions?.[POLICY_TYPE_MATCHUP_ACTIONS]?.participants?.enforceGender ?? appliedPolicies?.[POLICY_TYPE_MATCHUP_ACTIONS]?.participants?.enforceGender;
|
|
22675
|
-
const validEntriesResult = event && participants && checkValidEntries({ event, participants, enforceGender });
|
|
22676
|
-
if (validEntriesResult?.error)
|
|
22677
|
-
return decorateResult({ result: validEntriesResult, stack });
|
|
22678
22679
|
const allowedDrawTypes = !ignoreAllowedDrawTypes && tournamentRecord && getAllowedDrawTypes({
|
|
22679
22680
|
tournamentRecord,
|
|
22680
22681
|
categoryType: event?.category?.categoryType,
|
|
@@ -22687,6 +22688,14 @@ function generateDrawDefinition(params) {
|
|
|
22687
22688
|
(entry) => entry.entryStatus && [...STRUCTURE_ENTERED_TYPES, QUALIFIER].includes(entry.entryStatus)
|
|
22688
22689
|
) ?? [];
|
|
22689
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 });
|
|
22690
22699
|
const derivedDrawSize = !params.drawSize && consideredEntries.length && ![
|
|
22691
22700
|
AD_HOC,
|
|
22692
22701
|
DOUBLE_ELIMINATION,
|