tods-competition-factory 1.8.19 → 1.8.21
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/forge/generate.mjs +82 -19
- package/dist/forge/generate.mjs.map +1 -1
- package/dist/forge/query.d.ts +9 -4
- package/dist/forge/query.mjs +36 -12
- package/dist/forge/query.mjs.map +1 -1
- package/dist/forge/transform.mjs +29 -13
- package/dist/forge/transform.mjs.map +1 -1
- package/dist/index.mjs +117 -48
- package/dist/index.mjs.map +1 -1
- package/dist/tods-competition-factory.development.cjs.js +236 -174
- 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/dist/index.mjs
CHANGED
|
@@ -2382,7 +2382,7 @@ const matchUpFormatCode = {
|
|
|
2382
2382
|
};
|
|
2383
2383
|
|
|
2384
2384
|
function factoryVersion() {
|
|
2385
|
-
return "1.8.
|
|
2385
|
+
return "1.8.21";
|
|
2386
2386
|
}
|
|
2387
2387
|
|
|
2388
2388
|
function getObjectTieFormat(obj) {
|
|
@@ -2971,8 +2971,8 @@ function validateCollectionDefinition({
|
|
|
2971
2971
|
if (checkGender && referenceGender && gender && [GenderEnum.Male, GenderEnum.Female].includes(referenceGender) && referenceGender !== gender) {
|
|
2972
2972
|
errors.push(`Invalid gender: ${gender}`);
|
|
2973
2973
|
return decorateResult({
|
|
2974
|
+
result: { error: INVALID_GENDER, errors },
|
|
2974
2975
|
context: { referenceGender, gender },
|
|
2975
|
-
result: { error: INVALID_GENDER },
|
|
2976
2976
|
stack
|
|
2977
2977
|
});
|
|
2978
2978
|
}
|
|
@@ -5260,8 +5260,8 @@ function unlinkTournament({
|
|
|
5260
5260
|
tournamentIds.every((currentTournamentId) => {
|
|
5261
5261
|
const tournamentRecord = tournamentRecords[currentTournamentId];
|
|
5262
5262
|
const { extension } = findTournamentExtension({
|
|
5263
|
-
|
|
5264
|
-
|
|
5263
|
+
name: LINKED_TOURNAMENTS,
|
|
5264
|
+
tournamentRecord
|
|
5265
5265
|
});
|
|
5266
5266
|
if (!extension)
|
|
5267
5267
|
return true;
|
|
@@ -7778,6 +7778,9 @@ const POLICY_ROUND_NAMING_DEFAULT = {
|
|
|
7778
7778
|
namingConventions: {
|
|
7779
7779
|
round: "Round"
|
|
7780
7780
|
},
|
|
7781
|
+
qualifyingFinishMap: {
|
|
7782
|
+
1: "Final"
|
|
7783
|
+
},
|
|
7781
7784
|
abbreviatedRoundNamingMap: {
|
|
7782
7785
|
// key is matchUpsCount for the round
|
|
7783
7786
|
1: "F",
|
|
@@ -7791,7 +7794,8 @@ const POLICY_ROUND_NAMING_DEFAULT = {
|
|
|
7791
7794
|
},
|
|
7792
7795
|
affixes: {
|
|
7793
7796
|
roundNumber: "R",
|
|
7794
|
-
preFeedRound: "Q"
|
|
7797
|
+
preFeedRound: "Q",
|
|
7798
|
+
preQualifying: "P"
|
|
7795
7799
|
},
|
|
7796
7800
|
stageConstants: {
|
|
7797
7801
|
[MAIN]: "",
|
|
@@ -7804,6 +7808,7 @@ const POLICY_ROUND_NAMING_DEFAULT = {
|
|
|
7804
7808
|
|
|
7805
7809
|
function getRoundContextProfile({
|
|
7806
7810
|
roundNamingPolicy,
|
|
7811
|
+
drawDefinition,
|
|
7807
7812
|
structure,
|
|
7808
7813
|
matchUps
|
|
7809
7814
|
}) {
|
|
@@ -7814,21 +7819,31 @@ function getRoundContextProfile({
|
|
|
7814
7819
|
const isRoundRobin = structure.structures;
|
|
7815
7820
|
const roundNamingProfile = {};
|
|
7816
7821
|
const defaultRoundNamingPolicy = POLICY_ROUND_NAMING_DEFAULT[POLICY_TYPE_ROUND_NAMING];
|
|
7822
|
+
const isQualifying = structure.stage === QUALIFYING;
|
|
7823
|
+
const qualifyingFinishgMap = isQualifying && (roundNamingPolicy?.qualifyingFinishMap || defaultRoundNamingPolicy?.qualifyingFinishMap || {});
|
|
7824
|
+
const qualifyingStageSequences = isQualifying ? Math.max(
|
|
7825
|
+
...(drawDefinition?.structures ?? []).filter((structure2) => structure2.stage === QUALIFYING).map(({ stageSequence }) => stageSequence ?? 1),
|
|
7826
|
+
0
|
|
7827
|
+
) : 0;
|
|
7828
|
+
const preQualifyingSequence = qualifyingStageSequences ? qualifyingStageSequences - (structure.stageSequence || 1) || "" : "";
|
|
7829
|
+
const preQualifyingAffix = preQualifyingSequence ? roundNamingPolicy?.affixes?.preQualifying || defaultRoundNamingPolicy.affixes.preQualifying || "" : "";
|
|
7817
7830
|
const roundNamingMap = roundNamingPolicy?.roundNamingMap || defaultRoundNamingPolicy.roundNamingMap || {};
|
|
7818
7831
|
const abbreviatedRoundNamingMap = roundNamingPolicy?.abbreviatedRoundNamingMap || defaultRoundNamingPolicy.abbreviatedRoundNamingMap || {};
|
|
7819
|
-
const
|
|
7820
|
-
const roundNumberAffix =
|
|
7832
|
+
const preFeedAffix = roundNamingPolicy?.affixes?.preFeedRound || defaultRoundNamingPolicy.affixes.preFeedRound;
|
|
7833
|
+
const roundNumberAffix = roundNamingPolicy?.affixes?.roundNumber || defaultRoundNamingPolicy.affixes.roundNumber;
|
|
7821
7834
|
const namingConventions = roundNamingPolicy?.namingConventions || defaultRoundNamingPolicy.namingConventions;
|
|
7822
7835
|
const roundNameFallback = namingConventions.round;
|
|
7823
|
-
const stageInitial = stage && stage !== MAIN
|
|
7824
|
-
const stageConstants = roundNamingPolicy?.stageConstants;
|
|
7825
|
-
const
|
|
7836
|
+
const stageInitial = stage && stage !== MAIN ? stage[0] : "";
|
|
7837
|
+
const stageConstants = roundNamingPolicy?.stageConstants || defaultRoundNamingPolicy.stageConstants;
|
|
7838
|
+
const stageIndicator = stage && stageConstants?.[stage] || stageInitial;
|
|
7839
|
+
const stageConstant = `${preQualifyingAffix}${stageIndicator}${preQualifyingSequence}`;
|
|
7826
7840
|
const roundProfileKeys = roundProfile ? Object.keys(roundProfile) : [];
|
|
7841
|
+
const qualifyingAffix = isQualifying && stageConstants?.[QUALIFYING] ? `${stageConstants?.[QUALIFYING]}-` : "";
|
|
7827
7842
|
if (isRoundRobin || isAdHocStructure || isLuckyStructure) {
|
|
7828
7843
|
Object.assign(
|
|
7829
7844
|
roundNamingProfile,
|
|
7830
7845
|
...roundProfileKeys.map((key) => {
|
|
7831
|
-
const roundName = `${roundNameFallback} ${key}`;
|
|
7846
|
+
const roundName = `${qualifyingAffix}${roundNameFallback} ${key}`;
|
|
7832
7847
|
const abbreviatedRoundName = `${roundNumberAffix}${key}`;
|
|
7833
7848
|
return { [key]: { roundName, abbreviatedRoundName } };
|
|
7834
7849
|
})
|
|
@@ -7841,15 +7856,15 @@ function getRoundContextProfile({
|
|
|
7841
7856
|
return;
|
|
7842
7857
|
const { matchUpsCount, preFeedRound } = roundProfile[round];
|
|
7843
7858
|
const participantsCount = matchUpsCount * 2;
|
|
7844
|
-
const sizedRoundName = roundNamingMap[matchUpsCount] || `${
|
|
7845
|
-
const suffix = preFeedRound ? `-${
|
|
7859
|
+
const sizedRoundName = qualifyingFinishgMap?.[roundProfile?.[round].finishingRound] || qualifyingFinishgMap && `${roundNumberAffix}${participantsCount}` || roundNamingMap[matchUpsCount] || `${roundNumberAffix}${participantsCount}`;
|
|
7860
|
+
const suffix = preFeedRound ? `-${preFeedAffix}` : "";
|
|
7846
7861
|
const profileRoundName = `${sizedRoundName}${suffix}`;
|
|
7847
7862
|
const roundName = [
|
|
7848
7863
|
stageConstant,
|
|
7849
7864
|
structureAbbreviation,
|
|
7850
7865
|
profileRoundName
|
|
7851
7866
|
].filter(Boolean).join("-");
|
|
7852
|
-
const sizedAbbreviation = abbreviatedRoundNamingMap[matchUpsCount] || `${
|
|
7867
|
+
const sizedAbbreviation = abbreviatedRoundNamingMap[matchUpsCount] || `${roundNumberAffix}${participantsCount}`;
|
|
7853
7868
|
const profileAbbreviation = `${sizedAbbreviation}${suffix}`;
|
|
7854
7869
|
const abbreviatedRoundName = [
|
|
7855
7870
|
stageConstant,
|
|
@@ -8033,6 +8048,7 @@ function getAllStructureMatchUps({
|
|
|
8033
8048
|
const roundNamingPolicy = appliedPolicies?.[POLICY_TYPE_ROUND_NAMING];
|
|
8034
8049
|
const result = getRoundContextProfile({
|
|
8035
8050
|
roundNamingPolicy,
|
|
8051
|
+
drawDefinition,
|
|
8036
8052
|
structure,
|
|
8037
8053
|
matchUps
|
|
8038
8054
|
});
|
|
@@ -29485,6 +29501,7 @@ function addCollectionDefinition$1({
|
|
|
29485
29501
|
collectionDefinition,
|
|
29486
29502
|
referenceCategory,
|
|
29487
29503
|
tournamentRecord,
|
|
29504
|
+
policyDefinitions,
|
|
29488
29505
|
enforceCategory,
|
|
29489
29506
|
referenceGender,
|
|
29490
29507
|
drawDefinition,
|
|
@@ -29503,11 +29520,11 @@ function addCollectionDefinition$1({
|
|
|
29503
29520
|
drawDefinition,
|
|
29504
29521
|
event
|
|
29505
29522
|
}).appliedPolicies ?? {};
|
|
29506
|
-
const matchUpActionsPolicy = appliedPolicies?.[POLICY_TYPE_MATCHUP_ACTIONS];
|
|
29523
|
+
const matchUpActionsPolicy = policyDefinitions?.[POLICY_TYPE_MATCHUP_ACTIONS] ?? appliedPolicies?.[POLICY_TYPE_MATCHUP_ACTIONS];
|
|
29507
29524
|
enforceCategory = enforceCategory ?? matchUpActionsPolicy?.participants?.enforceCategory;
|
|
29508
|
-
|
|
29525
|
+
const genderEnforced = (enforceGender ?? matchUpActionsPolicy?.participants?.enforceGender) !== false;
|
|
29509
29526
|
const checkCategory = !!((referenceCategory ?? event?.category) && enforceCategory !== false);
|
|
29510
|
-
const checkGender = !!((referenceGender ?? event?.gender) &&
|
|
29527
|
+
const checkGender = !!((referenceGender ?? event?.gender) && genderEnforced);
|
|
29511
29528
|
const validationResult = validateCollectionDefinition({
|
|
29512
29529
|
referenceCategory: referenceCategory ?? event?.category,
|
|
29513
29530
|
collectionDefinition,
|
|
@@ -36308,6 +36325,7 @@ function matchUpActions$2({
|
|
|
36308
36325
|
inContextDrawMatchUps,
|
|
36309
36326
|
tournamentRecord,
|
|
36310
36327
|
drawDefinition,
|
|
36328
|
+
enforceGender,
|
|
36311
36329
|
participantId,
|
|
36312
36330
|
matchUpsMap,
|
|
36313
36331
|
sideNumber,
|
|
@@ -36339,8 +36357,8 @@ function matchUpActions$2({
|
|
|
36339
36357
|
event
|
|
36340
36358
|
}).appliedPolicies ?? {};
|
|
36341
36359
|
Object.assign(appliedPolicies, specifiedPolicyDefinitions ?? {});
|
|
36342
|
-
const isAdHocMatchUp = isAdHoc({ drawDefinition, structure });
|
|
36343
36360
|
const matchUpActionsPolicy = appliedPolicies?.[POLICY_TYPE_MATCHUP_ACTIONS] ?? POLICY_MATCHUP_ACTIONS_DEFAULT[POLICY_TYPE_MATCHUP_ACTIONS];
|
|
36361
|
+
const isAdHocMatchUp = isAdHoc({ drawDefinition, structure });
|
|
36344
36362
|
const { enabledStructures } = getEnabledStructures({
|
|
36345
36363
|
actionType: MATCHUP_ACTION,
|
|
36346
36364
|
appliedPolicies,
|
|
@@ -36554,7 +36572,8 @@ function matchUpActions$2({
|
|
|
36554
36572
|
);
|
|
36555
36573
|
const assignedGender = inContextMatchUp.gender === MIXED && inContextMatchUp.sideNumber && inContextMatchUp.sides?.filter((side2) => side2.particiapntId).length === 1 && firstFoundSide?.participant?.person?.sex;
|
|
36556
36574
|
const matchUpType = inContextMatchUp.matchUpType;
|
|
36557
|
-
const
|
|
36575
|
+
const genderEnforced = (enforceGender ?? matchUpActionsPolicy?.participants?.enforceGender) !== false;
|
|
36576
|
+
const gender = genderEnforced ? inContextMatchUp.gender : void 0;
|
|
36558
36577
|
const allParticipants = inContextMatchUp.sides?.flatMap(
|
|
36559
36578
|
(side2) => side2.participant?.individualParticipants || side2.participant
|
|
36560
36579
|
).filter(Boolean);
|
|
@@ -36684,6 +36703,7 @@ function matchUpActions$1({
|
|
|
36684
36703
|
policyDefinitions,
|
|
36685
36704
|
tournamentRecord,
|
|
36686
36705
|
drawDefinition,
|
|
36706
|
+
enforceGender,
|
|
36687
36707
|
participantId,
|
|
36688
36708
|
sideNumber,
|
|
36689
36709
|
matchUpId,
|
|
@@ -36718,6 +36738,7 @@ function matchUpActions$1({
|
|
|
36718
36738
|
tournamentParticipants: tournamentRecord.participants,
|
|
36719
36739
|
policyDefinitions,
|
|
36720
36740
|
drawDefinition,
|
|
36741
|
+
enforceGender,
|
|
36721
36742
|
participantId,
|
|
36722
36743
|
sideNumber,
|
|
36723
36744
|
matchUpId,
|
|
@@ -36731,6 +36752,8 @@ function matchUpActions$1({
|
|
|
36731
36752
|
function matchUpActions(params) {
|
|
36732
36753
|
const {
|
|
36733
36754
|
tournamentRecords,
|
|
36755
|
+
policyDefinitions,
|
|
36756
|
+
enforceGender,
|
|
36734
36757
|
participantId,
|
|
36735
36758
|
tournamentId,
|
|
36736
36759
|
sideNumber,
|
|
@@ -36752,7 +36775,9 @@ function matchUpActions(params) {
|
|
|
36752
36775
|
return result;
|
|
36753
36776
|
return matchUpActions$1({
|
|
36754
36777
|
drawDefinition: result.drawDefinition,
|
|
36778
|
+
policyDefinitions,
|
|
36755
36779
|
tournamentRecord,
|
|
36780
|
+
enforceGender,
|
|
36756
36781
|
participantId,
|
|
36757
36782
|
sideNumber,
|
|
36758
36783
|
matchUpId,
|
|
@@ -43405,7 +43430,7 @@ function generateQualifyingStructure$1(params) {
|
|
|
43405
43430
|
let chainModified;
|
|
43406
43431
|
while (!chainModified && nextStructureId) {
|
|
43407
43432
|
targetStructure.stageSequence = nextStageSequence;
|
|
43408
|
-
const targetTargetStructureId = drawDefinition.links
|
|
43433
|
+
const targetTargetStructureId = drawDefinition.links?.find(
|
|
43409
43434
|
(link2) => link2.source.structureId === nextStructureId
|
|
43410
43435
|
)?.target?.structureId;
|
|
43411
43436
|
nextStructureId = targetTargetStructureId;
|
|
@@ -45417,9 +45442,10 @@ function addEventEntries(params) {
|
|
|
45417
45442
|
const {
|
|
45418
45443
|
entryStatus = DIRECT_ACCEPTANCE,
|
|
45419
45444
|
autoEntryPositions = true,
|
|
45445
|
+
enforceGender = true,
|
|
45420
45446
|
participantIds = [],
|
|
45421
45447
|
entryStageSequence,
|
|
45422
|
-
|
|
45448
|
+
policyDefinitions,
|
|
45423
45449
|
entryStage = MAIN,
|
|
45424
45450
|
tournamentRecord,
|
|
45425
45451
|
ignoreStageSpace,
|
|
@@ -45441,6 +45467,9 @@ function addEventEntries(params) {
|
|
|
45441
45467
|
}
|
|
45442
45468
|
if (!event?.eventId)
|
|
45443
45469
|
return { error: EVENT_NOT_FOUND };
|
|
45470
|
+
const appliedPolicies = getAppliedPolicies({ tournamentRecord, event }).appliedPolicies ?? {};
|
|
45471
|
+
const matchUpActionsPolicy = policyDefinitions?.[POLICY_TYPE_MATCHUP_ACTIONS] ?? appliedPolicies?.[POLICY_TYPE_MATCHUP_ACTIONS] ?? POLICY_MATCHUP_ACTIONS_DEFAULT[POLICY_TYPE_MATCHUP_ACTIONS];
|
|
45472
|
+
const genderEnforced = (enforceGender ?? matchUpActionsPolicy?.participants?.enforceGender) !== false;
|
|
45444
45473
|
const addedParticipantIdEntries = [];
|
|
45445
45474
|
const removedEntries = [];
|
|
45446
45475
|
if (extensions && (!Array.isArray(extensions) || !extensions.every(isValidExtension)) || extension && !isValidExtension({ extension })) {
|
|
@@ -45452,14 +45481,14 @@ function addEventEntries(params) {
|
|
|
45452
45481
|
});
|
|
45453
45482
|
}
|
|
45454
45483
|
const checkTypedParticipants = !!tournamentRecord;
|
|
45455
|
-
const
|
|
45484
|
+
const mismatchedGender = [];
|
|
45456
45485
|
let info;
|
|
45457
45486
|
const typedParticipantIds = tournamentRecord?.participants?.filter((participant) => {
|
|
45458
45487
|
if (!participantIds.includes(participant.participantId))
|
|
45459
45488
|
return false;
|
|
45460
45489
|
const validSingles = event.eventType === SINGLES$1 && participant.participantType === INDIVIDUAL && !isUngrouped(entryStatus);
|
|
45461
45490
|
const validDoubles = event.eventType === DOUBLES$1 && participant.participantType === PAIR;
|
|
45462
|
-
if (validSingles && (!event.gender ||
|
|
45491
|
+
if (validSingles && (!event.gender || !genderEnforced || [MIXED, ANY].includes(event.gender) || event.gender === participant.person?.sex)) {
|
|
45463
45492
|
return true;
|
|
45464
45493
|
}
|
|
45465
45494
|
if (validDoubles && !isUngrouped(entryStatus)) {
|
|
@@ -45468,8 +45497,8 @@ function addEventEntries(params) {
|
|
|
45468
45497
|
if (event.eventType === DOUBLES$1 && participant.participantType === INDIVIDUAL && isUngrouped(entryStatus)) {
|
|
45469
45498
|
return true;
|
|
45470
45499
|
}
|
|
45471
|
-
if (validSingles && event.gender &&
|
|
45472
|
-
|
|
45500
|
+
if (validSingles && event.gender && genderEnforced && ![MIXED, ANY].includes(event.gender) && event.gender !== participant.person?.sex) {
|
|
45501
|
+
mismatchedGender.push({
|
|
45473
45502
|
participantId: participant.participantId,
|
|
45474
45503
|
sex: participant.person?.sex
|
|
45475
45504
|
});
|
|
@@ -45551,7 +45580,7 @@ function addEventEntries(params) {
|
|
|
45551
45580
|
const invalidParticipantIds = validParticipantIds.length !== participantIds.length;
|
|
45552
45581
|
if (invalidParticipantIds)
|
|
45553
45582
|
return decorateResult({
|
|
45554
|
-
context: {
|
|
45583
|
+
context: { mismatchedGender, gender: event.gender },
|
|
45555
45584
|
result: { error: INVALID_PARTICIPANT_IDS },
|
|
45556
45585
|
stack
|
|
45557
45586
|
});
|
|
@@ -48550,7 +48579,8 @@ const entryGovernor = {
|
|
|
48550
48579
|
};
|
|
48551
48580
|
|
|
48552
48581
|
const linkGovernor = {
|
|
48553
|
-
generateQualifyingLink
|
|
48582
|
+
generateQualifyingLink,
|
|
48583
|
+
getStructureLinks
|
|
48554
48584
|
};
|
|
48555
48585
|
|
|
48556
48586
|
const definitionTemplate = () => ({
|
|
@@ -52892,7 +52922,7 @@ function assignTieMatchUpParticipantId(params) {
|
|
|
52892
52922
|
if (allTieIndividualParticipantIds?.includes(participantId)) {
|
|
52893
52923
|
return decorateResult({ result: { ...SUCCESS }, stack });
|
|
52894
52924
|
}
|
|
52895
|
-
teamParticipantId = teamParticipantId
|
|
52925
|
+
teamParticipantId = teamParticipantId ?? (params.sideNumber ? inContextDualMatchUp?.sides?.find(
|
|
52896
52926
|
(side) => side.sideNumber === params.sideNumber
|
|
52897
52927
|
)?.participantId : void 0);
|
|
52898
52928
|
const participantToAssign = getParticipants$1({
|
|
@@ -52907,8 +52937,9 @@ function assignTieMatchUpParticipantId(params) {
|
|
|
52907
52937
|
drawDefinition,
|
|
52908
52938
|
event
|
|
52909
52939
|
});
|
|
52910
|
-
const matchUpActionsPolicy = params.policyDefinitions?.[POLICY_TYPE_MATCHUP_ACTIONS]
|
|
52911
|
-
|
|
52940
|
+
const matchUpActionsPolicy = params.policyDefinitions?.[POLICY_TYPE_MATCHUP_ACTIONS] ?? appliedPolicies?.[POLICY_TYPE_MATCHUP_ACTIONS] ?? POLICY_MATCHUP_ACTIONS_DEFAULT[POLICY_TYPE_MATCHUP_ACTIONS];
|
|
52941
|
+
const genderEnforced = (params.enforceGender ?? matchUpActionsPolicy?.participants?.enforceGender) !== false;
|
|
52942
|
+
if (genderEnforced && [MALE, FEMALE].includes(inContextTieMatchUp?.gender) && inContextTieMatchUp?.gender !== participantToAssign.person?.sex) {
|
|
52912
52943
|
return { error: INVALID_PARTICIPANT, info: "Gender mismatch" };
|
|
52913
52944
|
}
|
|
52914
52945
|
const { individualParticipantIds, participantType } = participantToAssign;
|
|
@@ -52935,7 +52966,7 @@ function assignTieMatchUpParticipantId(params) {
|
|
|
52935
52966
|
const teamSide = inContextTieMatchUp?.sides?.find(
|
|
52936
52967
|
(side) => side.drawPosition === teamDrawPosition
|
|
52937
52968
|
);
|
|
52938
|
-
const sideNumber = params.sideNumber
|
|
52969
|
+
const sideNumber = params.sideNumber ?? teamSide?.sideNumber;
|
|
52939
52970
|
if (!tieFormat) {
|
|
52940
52971
|
return { error: MISSING_TIE_FORMAT };
|
|
52941
52972
|
}
|
|
@@ -54033,8 +54064,8 @@ function analyzeDraws({ tournamentRecord }) {
|
|
|
54033
54064
|
({ inactiveStructure }) => !inactiveStructure
|
|
54034
54065
|
).length;
|
|
54035
54066
|
const { links } = getStructureLinks({
|
|
54036
|
-
|
|
54037
|
-
|
|
54067
|
+
structureId: mainStructure.structureId,
|
|
54068
|
+
drawDefinition
|
|
54038
54069
|
});
|
|
54039
54070
|
const isMatchPlay = ensureInt(mainStructure.activeRounds[0]) === 1 && mainStructure.activeRounds.length === 1 && activeStructuresCount === 1;
|
|
54040
54071
|
const inactiveDraw = structuresData?.every(
|
|
@@ -55384,11 +55415,12 @@ function replaceTieMatchUpParticipantId(params) {
|
|
|
55384
55415
|
drawDefinition,
|
|
55385
55416
|
event
|
|
55386
55417
|
});
|
|
55387
|
-
const matchUpActionsPolicy = appliedPolicies?.[POLICY_TYPE_MATCHUP_ACTIONS]
|
|
55418
|
+
const matchUpActionsPolicy = params.policyDefinitions?.[POLICY_TYPE_MATCHUP_ACTIONS] ?? appliedPolicies?.[POLICY_TYPE_MATCHUP_ACTIONS] ?? POLICY_MATCHUP_ACTIONS_DEFAULT[POLICY_TYPE_MATCHUP_ACTIONS];
|
|
55388
55419
|
const newParticipant = targetParticipants.find(
|
|
55389
55420
|
({ participantId }) => participantId === newParticipantId
|
|
55390
55421
|
);
|
|
55391
|
-
|
|
55422
|
+
const genderEnforced = (params.enforceGender ?? matchUpActionsPolicy?.participants?.enforceGender) !== false;
|
|
55423
|
+
if (genderEnforced && [MALE, FEMALE].includes(inContextTieMatchUp?.gender) && inContextTieMatchUp?.gender !== newParticipant?.person?.sex) {
|
|
55392
55424
|
return { error: INVALID_PARTICIPANT, info: "Gender mismatch" };
|
|
55393
55425
|
}
|
|
55394
55426
|
const substitutionProcessCodes = matchUpActionsPolicy?.processCodes?.substitution;
|
|
@@ -55457,16 +55489,16 @@ function replaceTieMatchUpParticipantId(params) {
|
|
|
55457
55489
|
const assignment = { collectionId, collectionPosition };
|
|
55458
55490
|
if (substitution) {
|
|
55459
55491
|
assignment.previousParticipantId = existingParticipantId;
|
|
55460
|
-
assignment.substitutionOrder = (substitutionOrder
|
|
55492
|
+
assignment.substitutionOrder = (substitutionOrder ?? 0) + 1;
|
|
55461
55493
|
}
|
|
55462
55494
|
modifiedCompetitor.collectionAssignments.push(assignment);
|
|
55463
55495
|
}
|
|
55464
55496
|
return modifiedCompetitor;
|
|
55465
|
-
})
|
|
55497
|
+
}) ?? [];
|
|
55466
55498
|
if (!newParticipantIdInLineUp) {
|
|
55467
55499
|
const collectionAssignment = { collectionId, collectionPosition };
|
|
55468
55500
|
if (substitution) {
|
|
55469
|
-
collectionAssignment.substitutionOrder = (substitutionOrder
|
|
55501
|
+
collectionAssignment.substitutionOrder = (substitutionOrder ?? 0) + 1;
|
|
55470
55502
|
collectionAssignment.previousParticipantId = existingParticipantId;
|
|
55471
55503
|
}
|
|
55472
55504
|
const assignment = {
|
|
@@ -55538,7 +55570,7 @@ function replaceTieMatchUpParticipantId(params) {
|
|
|
55538
55570
|
}
|
|
55539
55571
|
if (substitution || side.substitutions?.length === 1) {
|
|
55540
55572
|
if (substitution) {
|
|
55541
|
-
const processCodes = tieMatchUp?.processCodes
|
|
55573
|
+
const processCodes = tieMatchUp?.processCodes ?? [];
|
|
55542
55574
|
if (substitutionProcessCodes)
|
|
55543
55575
|
processCodes.push(...substitutionProcessCodes);
|
|
55544
55576
|
if (tieMatchUp)
|
|
@@ -55584,7 +55616,7 @@ function removeTieMatchUpParticipantId(params) {
|
|
|
55584
55616
|
drawDefinition,
|
|
55585
55617
|
event
|
|
55586
55618
|
});
|
|
55587
|
-
const matchUpActionsPolicy = appliedPolicies?.[POLICY_TYPE_MATCHUP_ACTIONS]
|
|
55619
|
+
const matchUpActionsPolicy = params.policyDefinitions?.[POLICY_TYPE_MATCHUP_ACTIONS] ?? appliedPolicies?.[POLICY_TYPE_MATCHUP_ACTIONS] ?? POLICY_MATCHUP_ACTIONS_DEFAULT[POLICY_TYPE_MATCHUP_ACTIONS];
|
|
55588
55620
|
const substitutionProcessCodes = matchUpActionsPolicy?.processCodes?.substitution;
|
|
55589
55621
|
const {
|
|
55590
55622
|
inContextDualMatchUp,
|
|
@@ -56208,24 +56240,34 @@ function addEventEntryPairs({
|
|
|
56208
56240
|
}
|
|
56209
56241
|
|
|
56210
56242
|
function checkValidEntries({
|
|
56211
|
-
enforceGender = true,
|
|
56212
56243
|
consideredEntries,
|
|
56244
|
+
policyDefinitions,
|
|
56213
56245
|
tournamentRecord,
|
|
56246
|
+
appliedPolicies,
|
|
56247
|
+
participantMap,
|
|
56248
|
+
enforceGender,
|
|
56214
56249
|
participants,
|
|
56215
56250
|
event
|
|
56216
56251
|
}) {
|
|
56217
|
-
|
|
56252
|
+
if ((!participants || !participantMap) && tournamentRecord) {
|
|
56253
|
+
({ participants, participantMap } = getParticipants$1({
|
|
56254
|
+
tournamentRecord
|
|
56255
|
+
}));
|
|
56256
|
+
}
|
|
56218
56257
|
if (!participants)
|
|
56219
56258
|
return { error: MISSING_PARTICIPANTS };
|
|
56220
56259
|
if (!Array.isArray(participants))
|
|
56221
56260
|
return { error: INVALID_VALUES };
|
|
56222
56261
|
if (!event)
|
|
56223
56262
|
return { error: MISSING_EVENT };
|
|
56263
|
+
const matchUpActionsPolicy = policyDefinitions?.[POLICY_TYPE_MATCHUP_ACTIONS] ?? appliedPolicies?.[POLICY_TYPE_MATCHUP_ACTIONS] ?? POLICY_MATCHUP_ACTIONS_DEFAULT[POLICY_TYPE_MATCHUP_ACTIONS];
|
|
56264
|
+
const genderEnforced = (enforceGender ?? matchUpActionsPolicy?.participants?.enforceGender) !== false;
|
|
56224
56265
|
const { eventType, gender: eventGender } = event;
|
|
56225
|
-
const
|
|
56266
|
+
const isDoubles = eventType === DOUBLES_EVENT;
|
|
56267
|
+
const participantType = eventType === TEAM_EVENT && TEAM || isDoubles && PAIR || INDIVIDUAL;
|
|
56226
56268
|
const entryStatusMap = Object.assign(
|
|
56227
56269
|
{},
|
|
56228
|
-
...(consideredEntries
|
|
56270
|
+
...(consideredEntries ?? event.entries ?? []).map((entry) => ({
|
|
56229
56271
|
[entry.participantId]: entry.entryStatus
|
|
56230
56272
|
}))
|
|
56231
56273
|
);
|
|
@@ -56237,9 +56279,14 @@ function checkValidEntries({
|
|
|
56237
56279
|
const entryStatus = entryStatusMap[participant.participantId];
|
|
56238
56280
|
const ungroupedParticipant = eventType && [TypeEnum.Doubles, TypeEnum.Team].includes(eventType) && participant.participantType === INDIVIDUAL && (isUngrouped(entryStatus) || entryStatus === WITHDRAWN);
|
|
56239
56281
|
const mismatch = participant.participantType !== participantType && !ungroupedParticipant;
|
|
56282
|
+
const pairGender = !mismatch && isDoubles && unique(
|
|
56283
|
+
participant?.individualParticipantIds?.map((id) => participantMap?.[id]?.participant?.person?.sex).filter(Boolean) ?? []
|
|
56284
|
+
);
|
|
56285
|
+
const validPairGender = !eventGender || !pairGender?.length || GenderEnum.Any === eventGender || [GenderEnum.Male, GenderEnum.Female].includes(eventGender) && pairGender[0] === eventGender || GenderEnum.Mixed === eventGender && (pairGender.length == 1 && participant.individualParticipantIds?.length === 1 || pairGender.length === 2);
|
|
56240
56286
|
const personGender = participant?.person?.sex;
|
|
56241
|
-
const
|
|
56242
|
-
|
|
56287
|
+
const validPersonGender = !participant?.person || !eventGender || [GenderEnum.Any, GenderEnum.Mixed].includes(eventGender) || [GenderEnum.Male, GenderEnum.Female].includes(eventGender) && personGender === eventGender;
|
|
56288
|
+
const validGender = !genderEnforced || validPairGender && validPersonGender;
|
|
56289
|
+
return mismatch || !validGender;
|
|
56243
56290
|
});
|
|
56244
56291
|
if (invalidEntries.length) {
|
|
56245
56292
|
const invalidParticipantIds = invalidEntries.map(
|
|
@@ -56247,7 +56294,7 @@ function checkValidEntries({
|
|
|
56247
56294
|
);
|
|
56248
56295
|
return { error: INVALID_ENTRIES, invalidParticipantIds };
|
|
56249
56296
|
}
|
|
56250
|
-
return { ...SUCCESS };
|
|
56297
|
+
return { ...SUCCESS, valid: true };
|
|
56251
56298
|
}
|
|
56252
56299
|
|
|
56253
56300
|
function assignSeedPositions(params) {
|
|
@@ -58927,7 +58974,7 @@ function generateDrawDefinition(params) {
|
|
|
58927
58974
|
}).appliedPolicies ?? {};
|
|
58928
58975
|
const drawTypeCoercion = params.drawTypeCoercion ?? appliedPolicies?.[POLICY_TYPE_DRAWS]?.drawTypeCoercion ?? true;
|
|
58929
58976
|
const drawType = drawTypeCoercion && params.drawSize === 2 && DrawTypeEnum.SingleElimination || params.drawType || DrawTypeEnum.SingleElimination;
|
|
58930
|
-
const { participants } = getParticipants$1({
|
|
58977
|
+
const { participants, participantMap } = getParticipants$1({
|
|
58931
58978
|
withIndividualParticipants: true,
|
|
58932
58979
|
tournamentRecord
|
|
58933
58980
|
});
|
|
@@ -58946,6 +58993,8 @@ function generateDrawDefinition(params) {
|
|
|
58946
58993
|
const consideredEntries = (qualifyingOnly && [] || drawEntries || (considerEventEntries ? eventEntries : [])).filter(({ entryStage }) => !entryStage || entryStage === MAIN);
|
|
58947
58994
|
const validEntriesResult = event && participants && checkValidEntries({
|
|
58948
58995
|
consideredEntries,
|
|
58996
|
+
appliedPolicies,
|
|
58997
|
+
participantMap,
|
|
58949
58998
|
enforceGender,
|
|
58950
58999
|
participants,
|
|
58951
59000
|
event
|
|
@@ -59369,6 +59418,25 @@ function generateDrawDefinition(params) {
|
|
|
59369
59418
|
};
|
|
59370
59419
|
}
|
|
59371
59420
|
|
|
59421
|
+
function isValidForQualifying({ structureId, drawDefinition }) {
|
|
59422
|
+
if (!drawDefinition)
|
|
59423
|
+
return { error: MISSING_DRAW_DEFINITION };
|
|
59424
|
+
if (!isString(structureId))
|
|
59425
|
+
return { error: INVALID_VALUES };
|
|
59426
|
+
const result = getStructureLinks({
|
|
59427
|
+
drawDefinition,
|
|
59428
|
+
structureId
|
|
59429
|
+
});
|
|
59430
|
+
if (result.error)
|
|
59431
|
+
return result;
|
|
59432
|
+
const targetFeedProfiles = result.links.target.flatMap((t) => t.target.feedProfile).filter(Boolean);
|
|
59433
|
+
const valid = !!intersection(
|
|
59434
|
+
[BOTTOM_UP, TOP_DOWN, RANDOM],
|
|
59435
|
+
targetFeedProfiles
|
|
59436
|
+
).length;
|
|
59437
|
+
return { ...SUCCESS, valid };
|
|
59438
|
+
}
|
|
59439
|
+
|
|
59372
59440
|
function renameStructures(params) {
|
|
59373
59441
|
return renameStructures$1(params);
|
|
59374
59442
|
}
|
|
@@ -59566,6 +59634,7 @@ const eventGovernor = {
|
|
|
59566
59634
|
attachQualifyingStructure,
|
|
59567
59635
|
attachPlayoffStructures,
|
|
59568
59636
|
addQualifyingStructure,
|
|
59637
|
+
isValidForQualifying,
|
|
59569
59638
|
setStructureOrder,
|
|
59570
59639
|
attachStructures,
|
|
59571
59640
|
renameStructures,
|