tods-competition-factory 1.6.28 → 1.6.30
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 +43 -14
- package/dist/forge/generate.mjs.map +1 -1
- package/dist/forge/query.mjs +22 -1
- package/dist/forge/query.mjs.map +1 -1
- package/dist/forge/transform.mjs +22 -1
- package/dist/forge/transform.mjs.map +1 -1
- package/dist/forge/utilities.mjs.map +1 -1
- package/dist/index.mjs +161 -154
- package/dist/index.mjs.map +1 -1
- package/dist/tods-competition-factory.development.cjs.js +251 -244
- 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
|
@@ -750,7 +750,8 @@ var syncGlobalState$1 = {
|
|
|
750
750
|
setSubscriptions,
|
|
751
751
|
setTournamentId,
|
|
752
752
|
setTournamentRecord,
|
|
753
|
-
setTournamentRecords
|
|
753
|
+
setTournamentRecords,
|
|
754
|
+
handleCaughtError
|
|
754
755
|
};
|
|
755
756
|
function disableNotifications$1() {
|
|
756
757
|
syncGlobalState.disableNotifications = true;
|
|
@@ -856,6 +857,26 @@ function callListener({ topic, notices }) {
|
|
|
856
857
|
method(notices);
|
|
857
858
|
}
|
|
858
859
|
}
|
|
860
|
+
function handleCaughtError({
|
|
861
|
+
engineName,
|
|
862
|
+
methodName,
|
|
863
|
+
params,
|
|
864
|
+
err
|
|
865
|
+
}) {
|
|
866
|
+
let error;
|
|
867
|
+
if (typeof err === "string") {
|
|
868
|
+
error = err.toUpperCase();
|
|
869
|
+
} else if (err instanceof Error) {
|
|
870
|
+
error = err.message;
|
|
871
|
+
}
|
|
872
|
+
console.log("ERROR", {
|
|
873
|
+
tournamentId: getTournamentId(),
|
|
874
|
+
params: JSON.stringify(params),
|
|
875
|
+
engine: engineName,
|
|
876
|
+
methodName,
|
|
877
|
+
error
|
|
878
|
+
});
|
|
879
|
+
}
|
|
859
880
|
|
|
860
881
|
const globalState = {
|
|
861
882
|
tournamentFactoryVersion: "0.0.0",
|
|
@@ -14458,9 +14479,9 @@ function processPlayoffGroups({
|
|
|
14458
14479
|
for (const playoffGroup of playoffGroups) {
|
|
14459
14480
|
const finishingPositions = playoffGroup.finishingPositions;
|
|
14460
14481
|
const positionsPlayedOff = positionRangeMap && finishingPositions.map((p) => positionRangeMap[p]?.finishingPositions).flat();
|
|
14461
|
-
const playoffDrawType = playoffGroup.drawType || SINGLE_ELIMINATION;
|
|
14462
14482
|
const participantsInDraw = groupCount * finishingPositions.length;
|
|
14463
14483
|
const drawSize = nextPowerOf2(participantsInDraw);
|
|
14484
|
+
const playoffDrawType = drawSize === 2 && SINGLE_ELIMINATION || playoffGroup.drawType || SINGLE_ELIMINATION;
|
|
14464
14485
|
if (positionsPlayedOff) {
|
|
14465
14486
|
finishingPositionOffset = Math.min(...positionsPlayedOff) - 1;
|
|
14466
14487
|
}
|
|
@@ -20159,8 +20180,6 @@ function generateDrawStructuresAndLinks(params) {
|
|
|
20159
20180
|
const {
|
|
20160
20181
|
enforceMinimumDrawSize = true,
|
|
20161
20182
|
overwriteExisting,
|
|
20162
|
-
drawTypeCoercion,
|
|
20163
|
-
// coerce to SINGLE_ELIMINATION for drawSize: 2
|
|
20164
20183
|
appliedPolicies,
|
|
20165
20184
|
staggeredEntry,
|
|
20166
20185
|
// optional - specifies main structure FEED_IN for drawTypes CURTIS_CONSOLATION, FEED_IN_CHAMPIONSHIPS, FMLC
|
|
@@ -20170,8 +20189,9 @@ function generateDrawStructuresAndLinks(params) {
|
|
|
20170
20189
|
isMock,
|
|
20171
20190
|
uuids
|
|
20172
20191
|
} = params || {};
|
|
20192
|
+
const drawTypeCoercion = params.drawTypeCoercion ?? appliedPolicies?.[POLICY_TYPE_DRAWS]?.drawTypeCoercion ?? true;
|
|
20173
20193
|
const stack = "generateDrawStructuresAndLinks";
|
|
20174
|
-
let drawType = params.drawType
|
|
20194
|
+
let drawType = drawTypeCoercion && params.drawSize === 2 && DrawTypeEnum.SingleElimination || params.drawType || DrawTypeEnum.SingleElimination;
|
|
20175
20195
|
const structures = [], links = [];
|
|
20176
20196
|
const matchUpType = params?.matchUpType ?? SINGLES$1;
|
|
20177
20197
|
const existingQualifyingStructures = drawDefinition?.structures?.filter(
|
|
@@ -20860,9 +20880,12 @@ function isUngrouped(entryStatus) {
|
|
|
20860
20880
|
|
|
20861
20881
|
function checkValidEntries({
|
|
20862
20882
|
enforceGender = true,
|
|
20883
|
+
consideredEntries,
|
|
20884
|
+
tournamentRecord,
|
|
20863
20885
|
participants,
|
|
20864
20886
|
event
|
|
20865
20887
|
}) {
|
|
20888
|
+
participants = participants || tournamentRecord?.participants;
|
|
20866
20889
|
if (!participants)
|
|
20867
20890
|
return { error: MISSING_PARTICIPANTS };
|
|
20868
20891
|
if (!Array.isArray(participants))
|
|
@@ -20873,7 +20896,7 @@ function checkValidEntries({
|
|
|
20873
20896
|
const participantType = eventType === TEAM_EVENT && TEAM || eventType === DOUBLES_EVENT && PAIR || INDIVIDUAL;
|
|
20874
20897
|
const entryStatusMap = Object.assign(
|
|
20875
20898
|
{},
|
|
20876
|
-
...(event.entries || []).map((entry) => ({
|
|
20899
|
+
...(consideredEntries || event.entries || []).map((entry) => ({
|
|
20877
20900
|
[entry.participantId]: entry.entryStatus
|
|
20878
20901
|
}))
|
|
20879
20902
|
);
|
|
@@ -22647,7 +22670,6 @@ const POLICY_SEEDING_USTA = {
|
|
|
22647
22670
|
function generateDrawDefinition(params) {
|
|
22648
22671
|
const stack = "generateDrawDefinition";
|
|
22649
22672
|
const {
|
|
22650
|
-
drawType = DrawTypeEnum.SingleElimination,
|
|
22651
22673
|
considerEventEntries = true,
|
|
22652
22674
|
// in the absence of drawSize and drawEntries, look to event.entries
|
|
22653
22675
|
ignoreAllowedDrawTypes,
|
|
@@ -22663,18 +22685,17 @@ function generateDrawDefinition(params) {
|
|
|
22663
22685
|
placeByes,
|
|
22664
22686
|
event
|
|
22665
22687
|
} = params;
|
|
22666
|
-
const { tournamentParticipants: participants } = getTournamentParticipants({
|
|
22667
|
-
tournamentRecord,
|
|
22668
|
-
inContext: true
|
|
22669
|
-
});
|
|
22670
22688
|
const appliedPolicies = getAppliedPolicies({
|
|
22671
22689
|
tournamentRecord,
|
|
22672
22690
|
event
|
|
22673
22691
|
}).appliedPolicies ?? {};
|
|
22692
|
+
const drawTypeCoercion = params.drawTypeCoercion ?? appliedPolicies?.[POLICY_TYPE_DRAWS]?.drawTypeCoercion ?? true;
|
|
22693
|
+
const drawType = drawTypeCoercion && params.drawSize === 2 && DrawTypeEnum.SingleElimination || params.drawType || DrawTypeEnum.SingleElimination;
|
|
22694
|
+
const { tournamentParticipants: participants } = getTournamentParticipants({
|
|
22695
|
+
tournamentRecord,
|
|
22696
|
+
inContext: true
|
|
22697
|
+
});
|
|
22674
22698
|
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
22699
|
const allowedDrawTypes = !ignoreAllowedDrawTypes && tournamentRecord && getAllowedDrawTypes({
|
|
22679
22700
|
tournamentRecord,
|
|
22680
22701
|
categoryType: event?.category?.categoryType,
|
|
@@ -22687,6 +22708,14 @@ function generateDrawDefinition(params) {
|
|
|
22687
22708
|
(entry) => entry.entryStatus && [...STRUCTURE_ENTERED_TYPES, QUALIFIER].includes(entry.entryStatus)
|
|
22688
22709
|
) ?? [];
|
|
22689
22710
|
const consideredEntries = (qualifyingOnly && [] || drawEntries || (considerEventEntries ? eventEntries : [])).filter(({ entryStage }) => !entryStage || entryStage === MAIN);
|
|
22711
|
+
const validEntriesResult = event && participants && checkValidEntries({
|
|
22712
|
+
consideredEntries,
|
|
22713
|
+
enforceGender,
|
|
22714
|
+
participants,
|
|
22715
|
+
event
|
|
22716
|
+
});
|
|
22717
|
+
if (validEntriesResult?.error)
|
|
22718
|
+
return decorateResult({ result: validEntriesResult, stack });
|
|
22690
22719
|
const derivedDrawSize = !params.drawSize && consideredEntries.length && ![
|
|
22691
22720
|
AD_HOC,
|
|
22692
22721
|
DOUBLE_ELIMINATION,
|