tods-competition-factory 0.76.0 → 0.77.0
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/tods-competition-factory.development.cjs.js +270 -241
- 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/dist/tods-competition-factory.production.esm.min.js +1 -1
- package/dist/tods-competition-factory.production.esm.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -249,7 +249,7 @@ const matchUpFormatCode = {
|
|
|
249
249
|
};
|
|
250
250
|
|
|
251
251
|
function factoryVersion() {
|
|
252
|
-
return '0.
|
|
252
|
+
return '0.77.0';
|
|
253
253
|
}
|
|
254
254
|
|
|
255
255
|
const FORMAT_STANDARD = 'SET3-S:6/TB7'; // Best of 3 Tiebreak Sets to 6
|
|
@@ -11813,7 +11813,7 @@ function getAllStructureMatchUps({
|
|
|
11813
11813
|
|
|
11814
11814
|
if (tournamentParticipants && matchUpWithContext.sides) {
|
|
11815
11815
|
matchUpWithContext.sides.filter(Boolean).forEach(side => {
|
|
11816
|
-
var _side$participant;
|
|
11816
|
+
var _side$participant, _side$participant$ind;
|
|
11817
11817
|
|
|
11818
11818
|
if (side.participantId) {
|
|
11819
11819
|
const participant = findParticipant({
|
|
@@ -11834,7 +11834,7 @@ function getAllStructureMatchUps({
|
|
|
11834
11834
|
}
|
|
11835
11835
|
}
|
|
11836
11836
|
|
|
11837
|
-
if (side !== null && side !== void 0 && (_side$participant = side.participant) !== null && _side$participant !== void 0 && _side$participant.individualParticipantIds) {
|
|
11837
|
+
if (side !== null && side !== void 0 && (_side$participant = side.participant) !== null && _side$participant !== void 0 && (_side$participant$ind = _side$participant.individualParticipantIds) !== null && _side$participant$ind !== void 0 && _side$participant$ind.length) {
|
|
11838
11838
|
const individualParticipants = side.participant.individualParticipantIds.map(participantId => {
|
|
11839
11839
|
return findParticipant({
|
|
11840
11840
|
policyDefinitions: appliedPolicies,
|
|
@@ -22077,7 +22077,8 @@ function addParticipant$1({
|
|
|
22077
22077
|
if (!participant.participantId) participant.participantId = UUID();
|
|
22078
22078
|
if (!tournamentRecord.participants) tournamentRecord.participants = [];
|
|
22079
22079
|
const {
|
|
22080
|
-
participantId
|
|
22080
|
+
participantId,
|
|
22081
|
+
individualParticipantIds
|
|
22081
22082
|
} = participant;
|
|
22082
22083
|
const idExists = tournamentRecord.participants.reduce((p, c) => c.participantId === participantId || p, false);
|
|
22083
22084
|
if (idExists) return {
|
|
@@ -22096,6 +22097,14 @@ function addParticipant$1({
|
|
|
22096
22097
|
};
|
|
22097
22098
|
const tournamentParticipants = tournamentRecord.participants || [];
|
|
22098
22099
|
const tournamentIndividualParticipantIds = tournamentParticipants.filter(tournamentParticipant => tournamentParticipant.participantType === INDIVIDUAL$1).map(individualParticipant => individualParticipant.participantId);
|
|
22100
|
+
if (participantType !== INDIVIDUAL$1 && participant.person) return {
|
|
22101
|
+
error: INVALID_VALUES,
|
|
22102
|
+
person: participant.person
|
|
22103
|
+
};
|
|
22104
|
+
if (individualParticipantIds && !Array.isArray(individualParticipantIds)) return {
|
|
22105
|
+
error: INVALID_VALUES,
|
|
22106
|
+
individualParticipantIds
|
|
22107
|
+
};
|
|
22099
22108
|
|
|
22100
22109
|
if (participantType === PAIR$1) {
|
|
22101
22110
|
if (participant.person) return {
|
|
@@ -22159,16 +22168,10 @@ function addParticipant$1({
|
|
|
22159
22168
|
participant.participantName = participantName;
|
|
22160
22169
|
participant.name = participantName; // backwards compatabilty
|
|
22161
22170
|
}
|
|
22162
|
-
} else {
|
|
22163
|
-
if (participant.
|
|
22164
|
-
error: INVALID_VALUES,
|
|
22165
|
-
person: participant.person
|
|
22166
|
-
};
|
|
22167
|
-
const {
|
|
22168
|
-
individualParticipantIds
|
|
22169
|
-
} = participant;
|
|
22171
|
+
} else if ([TEAM$1, GROUP].includes(participantType)) {
|
|
22172
|
+
if (!individualParticipantIds) participant.individualParticipantIds = [];
|
|
22170
22173
|
|
|
22171
|
-
if (individualParticipantIds
|
|
22174
|
+
if (individualParticipantIds.length) {
|
|
22172
22175
|
for (const individualParticipantId of individualParticipantIds) {
|
|
22173
22176
|
if (typeof individualParticipantId !== 'string') {
|
|
22174
22177
|
return {
|
|
@@ -22185,6 +22188,10 @@ function addParticipant$1({
|
|
|
22185
22188
|
}
|
|
22186
22189
|
}
|
|
22187
22190
|
}
|
|
22191
|
+
} else {
|
|
22192
|
+
return {
|
|
22193
|
+
error: INVALID_PARTICIPANT_TYPE
|
|
22194
|
+
};
|
|
22188
22195
|
}
|
|
22189
22196
|
|
|
22190
22197
|
tournamentRecord.participants.push(participant);
|
|
@@ -23386,7 +23393,9 @@ function getTournamentParticipants({
|
|
|
23386
23393
|
|
|
23387
23394
|
(_tournamentParticipan = tournamentParticipants) === null || _tournamentParticipan === void 0 ? void 0 : _tournamentParticipan.forEach(participant => {
|
|
23388
23395
|
if ([PAIR$1, TEAM$1, GROUP].includes(participant.participantType)) {
|
|
23389
|
-
|
|
23396
|
+
var _participant$individu;
|
|
23397
|
+
|
|
23398
|
+
participant.individualParticipants = (_participant$individu = participant.individualParticipantIds) === null || _participant$individu === void 0 ? void 0 : _participant$individu.map(participantId => {
|
|
23390
23399
|
const individualParticipant = tournamentRecord.participants.find(p => p.participantId === participantId);
|
|
23391
23400
|
return makeDeepCopy(individualParticipant, convertExtensions, true);
|
|
23392
23401
|
});
|
|
@@ -37497,7 +37506,7 @@ function getSideRatings({
|
|
|
37497
37506
|
var _tournamentParticipan;
|
|
37498
37507
|
|
|
37499
37508
|
const individualParticipantIds = tournamentParticipants === null || tournamentParticipants === void 0 ? void 0 : (_tournamentParticipan = tournamentParticipants.find(participant => participant.participantId === participantId)) === null || _tournamentParticipan === void 0 ? void 0 : _tournamentParticipan.individualParticipantIds;
|
|
37500
|
-
return !individualParticipantIds ? DEFAULT_RATING * 2 : individualParticipantIds.map(participantId => adHocRatings[participantId || DEFAULT_RATING]);
|
|
37509
|
+
return !individualParticipantIds ? DEFAULT_RATING * 2 : individualParticipantIds === null || individualParticipantIds === void 0 ? void 0 : individualParticipantIds.map(participantId => adHocRatings[participantId || DEFAULT_RATING]);
|
|
37501
37510
|
} else {
|
|
37502
37511
|
return adHocRatings[participantId] || DEFAULT_RATING;
|
|
37503
37512
|
}
|
|
@@ -44943,6 +44952,166 @@ function getScaledEntries({
|
|
|
44943
44952
|
}
|
|
44944
44953
|
}
|
|
44945
44954
|
|
|
44955
|
+
function prepareStage({
|
|
44956
|
+
inContextDrawMatchUps,
|
|
44957
|
+
matchUpsMap,
|
|
44958
|
+
participants,
|
|
44959
|
+
tournamentRecord,
|
|
44960
|
+
drawDefinition,
|
|
44961
|
+
automated,
|
|
44962
|
+
drawType,
|
|
44963
|
+
drawSize,
|
|
44964
|
+
entries,
|
|
44965
|
+
event,
|
|
44966
|
+
enforcePolicyLimits = true,
|
|
44967
|
+
seedAssignmentProfile,
|
|
44968
|
+
// mainly used by mocksEngine for scenario testing
|
|
44969
|
+
seedByRanking = true,
|
|
44970
|
+
seededParticipants,
|
|
44971
|
+
assignSeedsCount,
|
|
44972
|
+
// used for testing bye placement next to seeds
|
|
44973
|
+
seedingScaleName,
|
|
44974
|
+
seedsCount,
|
|
44975
|
+
stageSequence = 1,
|
|
44976
|
+
stage
|
|
44977
|
+
}) {
|
|
44978
|
+
const eventType = event === null || event === void 0 ? void 0 : event.eventType;
|
|
44979
|
+
const stageEntries = entries.filter(entry => (!entry.entryStage || entry.entryStage === stage) && STRUCTURE_SELECTED_STATUSES.includes(entry.entryStatus));
|
|
44980
|
+
if (seededParticipants) seedsCount = seededParticipants.length;
|
|
44981
|
+
if (seedsCount > drawSize) seedsCount = drawSize;
|
|
44982
|
+
if (seedsCount > stageEntries.length) seedsCount = stageEntries.length;
|
|
44983
|
+
const {
|
|
44984
|
+
structures
|
|
44985
|
+
} = getDrawStructures({
|
|
44986
|
+
drawDefinition,
|
|
44987
|
+
stageSequence,
|
|
44988
|
+
stage
|
|
44989
|
+
});
|
|
44990
|
+
const [structure] = structures;
|
|
44991
|
+
const {
|
|
44992
|
+
structureId
|
|
44993
|
+
} = structure || {};
|
|
44994
|
+
const {
|
|
44995
|
+
seedLimit
|
|
44996
|
+
} = initializeStructureSeedAssignments({
|
|
44997
|
+
participantCount: stageEntries.length,
|
|
44998
|
+
enforcePolicyLimits,
|
|
44999
|
+
tournamentRecord,
|
|
45000
|
+
drawDefinition,
|
|
45001
|
+
structureId,
|
|
45002
|
+
seedsCount,
|
|
45003
|
+
event
|
|
45004
|
+
});
|
|
45005
|
+
if (seedLimit && seedLimit < seedsCount) seedsCount = seedLimit;
|
|
45006
|
+
const enteredParticipantIds = entries.map(getParticipantId);
|
|
45007
|
+
|
|
45008
|
+
if (seededParticipants) {
|
|
45009
|
+
seededParticipants.filter(({
|
|
45010
|
+
participantId
|
|
45011
|
+
}) => enteredParticipantIds.includes(participantId)).filter(seededParticipant => !seededParticipant.seedNumber || seededParticipant.seedNumber <= seededParticipants.length).sort((a, b) => {
|
|
45012
|
+
if (a.seedNumber < b.seedNumber) return -1;
|
|
45013
|
+
if (a.seedNumber < b.seedNumber) return 1;
|
|
45014
|
+
return 0;
|
|
45015
|
+
}).forEach(seededParticipant => {
|
|
45016
|
+
const {
|
|
45017
|
+
participantId,
|
|
45018
|
+
seedNumber,
|
|
45019
|
+
seedValue
|
|
45020
|
+
} = seededParticipant;
|
|
45021
|
+
assignSeed({
|
|
45022
|
+
drawDefinition,
|
|
45023
|
+
participantId,
|
|
45024
|
+
structureId,
|
|
45025
|
+
seedNumber,
|
|
45026
|
+
seedValue
|
|
45027
|
+
});
|
|
45028
|
+
});
|
|
45029
|
+
} else if (event !== null && event !== void 0 && event.category || seedingScaleName) {
|
|
45030
|
+
var _scaledEntries, _scaledEntries2;
|
|
45031
|
+
|
|
45032
|
+
// if no seededParticipants have been defined, seed by seeding scale or ranking scale, if present
|
|
45033
|
+
const {
|
|
45034
|
+
categoryName,
|
|
45035
|
+
ageCategoryCode
|
|
45036
|
+
} = (event === null || event === void 0 ? void 0 : event.category) || {};
|
|
45037
|
+
const seedingScaleAttributes = {
|
|
45038
|
+
scaleType: SEEDING,
|
|
45039
|
+
scaleName: seedingScaleName || categoryName || ageCategoryCode,
|
|
45040
|
+
eventType
|
|
45041
|
+
};
|
|
45042
|
+
let {
|
|
45043
|
+
scaledEntries
|
|
45044
|
+
} = getScaledEntries({
|
|
45045
|
+
scaleAttributes: seedingScaleAttributes,
|
|
45046
|
+
tournamentRecord,
|
|
45047
|
+
entries,
|
|
45048
|
+
stage
|
|
45049
|
+
});
|
|
45050
|
+
|
|
45051
|
+
if (!((_scaledEntries = scaledEntries) !== null && _scaledEntries !== void 0 && _scaledEntries.length) && seedByRanking) {
|
|
45052
|
+
const rankingScaleAttributes = {
|
|
45053
|
+
scaleType: RANKING,
|
|
45054
|
+
scaleName: categoryName || ageCategoryCode,
|
|
45055
|
+
eventType
|
|
45056
|
+
};
|
|
45057
|
+
({
|
|
45058
|
+
scaledEntries
|
|
45059
|
+
} = getScaledEntries({
|
|
45060
|
+
scaleAttributes: rankingScaleAttributes,
|
|
45061
|
+
tournamentRecord,
|
|
45062
|
+
entries,
|
|
45063
|
+
stage
|
|
45064
|
+
}));
|
|
45065
|
+
}
|
|
45066
|
+
|
|
45067
|
+
const scaledEntriesCount = ((_scaledEntries2 = scaledEntries) === null || _scaledEntries2 === void 0 ? void 0 : _scaledEntries2.length) || 0;
|
|
45068
|
+
if (scaledEntriesCount < seedsCount) seedsCount = scaledEntriesCount;
|
|
45069
|
+
scaledEntries && scaledEntries.filter(({
|
|
45070
|
+
participantId
|
|
45071
|
+
}) => enteredParticipantIds.includes(participantId)).slice(0, assignSeedsCount || seedsCount).forEach((scaledEntry, index) => {
|
|
45072
|
+
const seedNumber = index + 1;
|
|
45073
|
+
const seedValue = (seedAssignmentProfile === null || seedAssignmentProfile === void 0 ? void 0 : seedAssignmentProfile[seedNumber]) || seedNumber; // ?? attach basis of seeding information to seedAssignment ??
|
|
45074
|
+
|
|
45075
|
+
const {
|
|
45076
|
+
participantId
|
|
45077
|
+
} = scaledEntry;
|
|
45078
|
+
assignSeed({
|
|
45079
|
+
drawDefinition,
|
|
45080
|
+
participantId,
|
|
45081
|
+
structureId,
|
|
45082
|
+
seedNumber,
|
|
45083
|
+
seedValue
|
|
45084
|
+
});
|
|
45085
|
+
});
|
|
45086
|
+
}
|
|
45087
|
+
|
|
45088
|
+
let conflicts = [];
|
|
45089
|
+
|
|
45090
|
+
if (automated !== false) {
|
|
45091
|
+
const seedsOnly = typeof automated === 'object' && automated.seedsOnly; // if { seedsOnly: true } then only seeds and an Byes releated to seeded positions are placed
|
|
45092
|
+
|
|
45093
|
+
({
|
|
45094
|
+
conflicts
|
|
45095
|
+
} = automatedPositioning$1({
|
|
45096
|
+
inContextDrawMatchUps,
|
|
45097
|
+
drawDefinition,
|
|
45098
|
+
participants,
|
|
45099
|
+
structureId,
|
|
45100
|
+
matchUpsMap,
|
|
45101
|
+
seedsOnly,
|
|
45102
|
+
drawType,
|
|
45103
|
+
event
|
|
45104
|
+
}));
|
|
45105
|
+
}
|
|
45106
|
+
|
|
45107
|
+
return {
|
|
45108
|
+
conflicts,
|
|
45109
|
+
structureId,
|
|
45110
|
+
seedsCount,
|
|
45111
|
+
stageEntries
|
|
45112
|
+
};
|
|
45113
|
+
}
|
|
45114
|
+
|
|
44946
45115
|
/**
|
|
44947
45116
|
* automated = true, // can be true/false or "truthy" { seedsOnly: true }
|
|
44948
45117
|
*/
|
|
@@ -44950,52 +45119,30 @@ function getScaledEntries({
|
|
|
44950
45119
|
function generateDrawDefinition(params) {
|
|
44951
45120
|
const {
|
|
44952
45121
|
drawType = SINGLE_ELIMINATION,
|
|
44953
|
-
enforcePolicyLimits = true,
|
|
44954
|
-
finishingPositionNaming,
|
|
44955
45122
|
ignoreAllowedDrawTypes,
|
|
44956
|
-
seedAssignmentProfile,
|
|
44957
|
-
// mainly used by mocksEngine for scenario testing
|
|
44958
|
-
playoffMatchUpFormat,
|
|
44959
|
-
seedByRanking = true,
|
|
44960
|
-
qualifyingProfiles,
|
|
44961
|
-
seededParticipants,
|
|
44962
45123
|
policyDefinitions,
|
|
44963
|
-
|
|
44964
|
-
assignSeedsCount,
|
|
44965
|
-
// used for testing bye placement next to seeds
|
|
44966
|
-
automated = true,
|
|
44967
|
-
seedingProfile,
|
|
45124
|
+
tournamentRecord,
|
|
44968
45125
|
tieFormatName,
|
|
44969
45126
|
drawEntries,
|
|
44970
|
-
feedPolicy,
|
|
44971
|
-
idPrefix,
|
|
44972
45127
|
drawId,
|
|
44973
|
-
isMock,
|
|
44974
|
-
uuids
|
|
44975
|
-
} = params;
|
|
44976
|
-
const {
|
|
44977
|
-
tournamentRecord,
|
|
44978
45128
|
event
|
|
44979
|
-
} = params;
|
|
44980
|
-
|
|
44981
|
-
|
|
44982
|
-
matchUpType,
|
|
44983
|
-
structureOptions
|
|
44984
|
-
} = params;
|
|
45129
|
+
} = params; // get participants both for entry validation and for automated placement
|
|
45130
|
+
// automated placement requires them to be "inContext" for avoidance policies to work
|
|
45131
|
+
|
|
44985
45132
|
const {
|
|
44986
45133
|
tournamentParticipants: participants
|
|
44987
45134
|
} = getTournamentParticipants({
|
|
44988
45135
|
tournamentRecord,
|
|
44989
45136
|
inContext: true
|
|
44990
|
-
});
|
|
44991
|
-
|
|
45137
|
+
}); // entries participantTypes must correspond with eventType
|
|
45138
|
+
// this is only possible if the event is provided
|
|
45139
|
+
|
|
45140
|
+
const validEntriesResult = event && participants && checkValidEntries({
|
|
44992
45141
|
event,
|
|
44993
45142
|
participants
|
|
44994
45143
|
});
|
|
44995
|
-
|
|
44996
|
-
|
|
44997
|
-
return validEntriesTest;
|
|
44998
|
-
}
|
|
45144
|
+
if (validEntriesResult !== null && validEntriesResult !== void 0 && validEntriesResult.error) return validEntriesResult; // if tournamentRecord is provided, and unless instructed to ignore valid types,
|
|
45145
|
+
// check for restrictions on allowed drawTypes
|
|
44999
45146
|
|
|
45000
45147
|
const allowedDrawTypes = !ignoreAllowedDrawTypes && tournamentRecord && getAllowedDrawTypes({
|
|
45001
45148
|
tournamentRecord,
|
|
@@ -45007,19 +45154,18 @@ function generateDrawDefinition(params) {
|
|
|
45007
45154
|
return {
|
|
45008
45155
|
error: INVALID_DRAW_TYPE
|
|
45009
45156
|
};
|
|
45010
|
-
}
|
|
45157
|
+
} // coersion of drawSize and seedsCount to integers
|
|
45158
|
+
|
|
45159
|
+
|
|
45160
|
+
let drawSize = typeof params.drawSize !== 'number' ? parseInt(params.drawSize || 32) : params.drawSize || 32;
|
|
45161
|
+
let seedsCount = typeof params.seedsCount !== 'number' ? parseInt(params.seedsCount || 0) : params.seedsCount || 0;
|
|
45162
|
+
const eventType = event === null || event === void 0 ? void 0 : event.eventType;
|
|
45163
|
+
const matchUpType = params.matchUpType || eventType; // drawDefinition cannot have both tieFormat and matchUpFormat
|
|
45011
45164
|
|
|
45012
45165
|
let {
|
|
45013
|
-
seedsCount,
|
|
45014
|
-
drawSize = 32,
|
|
45015
45166
|
tieFormat,
|
|
45016
45167
|
matchUpFormat
|
|
45017
|
-
} = params;
|
|
45018
|
-
|
|
45019
|
-
if (typeof drawSize !== 'number') drawSize = parseInt(drawSize);
|
|
45020
|
-
if (typeof seedsCount !== 'number') seedsCount = parseInt(seedsCount || 0);
|
|
45021
|
-
const eventType = event === null || event === void 0 ? void 0 : event.eventType;
|
|
45022
|
-
matchUpType = matchUpType || eventType;
|
|
45168
|
+
} = params;
|
|
45023
45169
|
|
|
45024
45170
|
if (matchUpType === TEAM$3 && eventType === TEAM$3) {
|
|
45025
45171
|
tieFormat = tieFormat || event !== null && event !== void 0 && event.tieFormat || tieFormatName ? typeof tieFormat === 'object' ? tieFormat : tieFormatName ? tieFormatDefaults({
|
|
@@ -45029,19 +45175,15 @@ function generateDrawDefinition(params) {
|
|
|
45029
45175
|
} else if (!matchUpFormat) {
|
|
45030
45176
|
tieFormat = undefined;
|
|
45031
45177
|
matchUpFormat = 'SET3-S:6/TB7';
|
|
45032
|
-
}
|
|
45178
|
+
} // ---------------------------------------------------------------------------
|
|
45179
|
+
// Begin construction of drawDefinition
|
|
45033
45180
|
|
|
45034
|
-
const entries = drawEntries || (event === null || event === void 0 ? void 0 : event.entries) || [];
|
|
45035
|
-
const stageEntries = entries.filter(entry => (!entry.entryStage || entry.entryStage === MAIN) && STRUCTURE_SELECTED_STATUSES.includes(entry.entryStatus)); // the reason for this needs to be clarified
|
|
45036
|
-
|
|
45037
|
-
if ([ROUND_ROBIN].includes(drawType)) {
|
|
45038
|
-
drawSize = stageEntries.length || drawSize;
|
|
45039
|
-
}
|
|
45040
45181
|
|
|
45041
45182
|
const drawDefinition = newDrawDefinition({
|
|
45042
45183
|
drawType,
|
|
45043
45184
|
drawId
|
|
45044
|
-
});
|
|
45185
|
+
}); // if there is a defined matchUpFormat/tieFormat only attach to drawDefinition...
|
|
45186
|
+
// ...when there is not an equivalent definition on the parent event
|
|
45045
45187
|
|
|
45046
45188
|
if (matchUpFormat || tieFormat) {
|
|
45047
45189
|
let equivalentInScope = matchUpFormat && (event === null || event === void 0 ? void 0 : event.matchUpFormat) === matchUpFormat || (event === null || event === void 0 ? void 0 : event.tieFormat) && tieFormat && JSON.stringify(event.tieFormat) === JSON.stringify(tieFormat); // if an equivalent matchUpFormat or tieFormat is attached to the event
|
|
@@ -45065,52 +45207,22 @@ function generateDrawDefinition(params) {
|
|
|
45065
45207
|
}
|
|
45066
45208
|
}
|
|
45067
45209
|
|
|
45068
|
-
|
|
45069
|
-
let result = generateDrawType({
|
|
45070
|
-
finishingPositionNaming,
|
|
45071
|
-
goesTo: params.goesTo,
|
|
45072
|
-
playoffMatchUpFormat,
|
|
45073
|
-
qualifyingProfiles,
|
|
45074
|
-
structureOptions,
|
|
45210
|
+
let drawTypeResult = generateDrawType({ ...params,
|
|
45075
45211
|
drawDefinition,
|
|
45076
|
-
seedingProfile,
|
|
45077
45212
|
matchUpFormat,
|
|
45078
45213
|
matchUpType,
|
|
45079
|
-
feedPolicy,
|
|
45080
45214
|
tieFormat,
|
|
45081
|
-
drawSize
|
|
45082
|
-
drawType,
|
|
45083
|
-
idPrefix,
|
|
45084
|
-
isMock,
|
|
45085
|
-
uuids
|
|
45086
|
-
});
|
|
45087
|
-
if (result.error) return result;
|
|
45088
|
-
const {
|
|
45089
|
-
matchUpsMap,
|
|
45090
|
-
inContextDrawMatchUps
|
|
45091
|
-
} = result;
|
|
45092
|
-
const {
|
|
45093
|
-
structures
|
|
45094
|
-
} = getDrawStructures({
|
|
45095
|
-
drawDefinition,
|
|
45096
|
-
stageSequence: 1,
|
|
45097
|
-
stage: MAIN
|
|
45215
|
+
drawSize
|
|
45098
45216
|
});
|
|
45099
|
-
|
|
45100
|
-
const {
|
|
45101
|
-
structureId
|
|
45102
|
-
} = structure || {};
|
|
45217
|
+
if (drawTypeResult.error) return drawTypeResult; // first attach any policyDefinitions which have been provided
|
|
45103
45218
|
|
|
45104
45219
|
if (typeof policyDefinitions === 'object') {
|
|
45105
|
-
|
|
45106
|
-
|
|
45107
|
-
|
|
45108
|
-
|
|
45109
|
-
|
|
45110
|
-
|
|
45111
|
-
});
|
|
45112
|
-
}
|
|
45113
|
-
}
|
|
45220
|
+
attachPolicies({
|
|
45221
|
+
policyDefinitions,
|
|
45222
|
+
drawDefinition
|
|
45223
|
+
});
|
|
45224
|
+
} // then check for a seedingPolicy at all levels
|
|
45225
|
+
|
|
45114
45226
|
|
|
45115
45227
|
const {
|
|
45116
45228
|
policyDefinitions: seedingPolicy
|
|
@@ -45119,9 +45231,10 @@ function generateDrawDefinition(params) {
|
|
|
45119
45231
|
tournamentRecord,
|
|
45120
45232
|
drawDefinition,
|
|
45121
45233
|
event
|
|
45122
|
-
}) || {};
|
|
45234
|
+
}) || {}; // if no seeding policy provided and none present at any other level, attach default
|
|
45235
|
+
// this needs to be attached for prepareStage => initializeSeedAssignments
|
|
45123
45236
|
|
|
45124
|
-
if (!(
|
|
45237
|
+
if (!(seedingPolicy !== null && seedingPolicy !== void 0 && seedingPolicy[POLICY_TYPE_SEEDING])) {
|
|
45125
45238
|
// if there is no seeding policy then use default seeing policy
|
|
45126
45239
|
attachPolicies({
|
|
45127
45240
|
drawDefinition,
|
|
@@ -45146,7 +45259,11 @@ function generateDrawDefinition(params) {
|
|
|
45146
45259
|
drawDefinition,
|
|
45147
45260
|
policyDefinitions: eventAvoidancePolicy
|
|
45148
45261
|
});
|
|
45149
|
-
}
|
|
45262
|
+
} // add all entries to the draw
|
|
45263
|
+
// TODO: if there are no qualifyingProfiles, skip adding qualifying entries
|
|
45264
|
+
|
|
45265
|
+
|
|
45266
|
+
const entries = drawEntries || (event === null || event === void 0 ? void 0 : event.entries) || [];
|
|
45150
45267
|
|
|
45151
45268
|
for (const entry of entries) {
|
|
45152
45269
|
// convenience: assume MAIN as entryStage if none provided
|
|
@@ -45161,153 +45278,56 @@ function generateDrawDefinition(params) {
|
|
|
45161
45278
|
// if entries are taken from event.entries assume stageSpace is not available
|
|
45162
45279
|
return result;
|
|
45163
45280
|
}
|
|
45164
|
-
}
|
|
45281
|
+
} // temporary until seeding is supported in LUCKY_DRAW
|
|
45165
45282
|
|
|
45166
|
-
|
|
45167
|
-
if (
|
|
45168
|
-
|
|
45169
|
-
|
|
45170
|
-
const {
|
|
45171
|
-
seedLimit
|
|
45172
|
-
} = initializeStructureSeedAssignments({
|
|
45173
|
-
participantCount: stageEntries.length,
|
|
45174
|
-
enforcePolicyLimits,
|
|
45175
|
-
tournamentRecord,
|
|
45283
|
+
|
|
45284
|
+
if (drawType === LUCKY_DRAW) seedsCount = 0;
|
|
45285
|
+
const structureResult = prepareStage({ ...drawTypeResult,
|
|
45286
|
+
...params,
|
|
45176
45287
|
drawDefinition,
|
|
45177
|
-
|
|
45288
|
+
participants,
|
|
45289
|
+
stage: MAIN,
|
|
45178
45290
|
seedsCount,
|
|
45179
|
-
|
|
45291
|
+
drawSize,
|
|
45292
|
+
entries
|
|
45180
45293
|
});
|
|
45181
|
-
if (seedLimit && seedLimit < seedsCount) seedsCount = seedLimit; // temporary until seeding is supported in LUCKY_DRAW
|
|
45182
45294
|
|
|
45183
|
-
if (
|
|
45295
|
+
if (params.qualifyingProfiles) {
|
|
45296
|
+
console.log(params.qualifyingProfiles);
|
|
45297
|
+
let stageSequence = 1;
|
|
45184
45298
|
|
|
45185
|
-
|
|
45186
|
-
seededParticipants.filter(({
|
|
45187
|
-
participantId
|
|
45188
|
-
}) => enteredParticipantIds.includes(participantId)).filter(seededParticipant => !seededParticipant.seedNumber || seededParticipant.seedNumber <= seededParticipants.length).sort((a, b) => {
|
|
45189
|
-
if (a.seedNumber < b.seedNumber) return -1;
|
|
45190
|
-
if (a.seedNumber < b.seedNumber) return 1;
|
|
45191
|
-
return 0;
|
|
45192
|
-
}).forEach(seededParticipant => {
|
|
45299
|
+
for (const qualifyingProfile of params.qualifyingProfiles) {
|
|
45193
45300
|
const {
|
|
45194
|
-
|
|
45195
|
-
|
|
45196
|
-
|
|
45197
|
-
} =
|
|
45198
|
-
|
|
45301
|
+
drawSize,
|
|
45302
|
+
qualifyingRoundNumber,
|
|
45303
|
+
qualifyingPositions
|
|
45304
|
+
} = qualifyingProfile;
|
|
45305
|
+
const qualifyingResult = prepareStage({ ...drawTypeResult,
|
|
45306
|
+
...params,
|
|
45307
|
+
qualifyingRoundNumber,
|
|
45308
|
+
qualifyingPositions,
|
|
45309
|
+
stage: QUALIFYING,
|
|
45199
45310
|
drawDefinition,
|
|
45200
|
-
|
|
45201
|
-
|
|
45202
|
-
|
|
45203
|
-
|
|
45204
|
-
});
|
|
45205
|
-
});
|
|
45206
|
-
} else if (event !== null && event !== void 0 && event.category || seedingScaleName) {
|
|
45207
|
-
var _scaledEntries, _scaledEntries2;
|
|
45208
|
-
|
|
45209
|
-
// if no seededParticipants have been defined, seed by seeding scale or ranking scale, if present
|
|
45210
|
-
const {
|
|
45211
|
-
categoryName,
|
|
45212
|
-
ageCategoryCode
|
|
45213
|
-
} = (event === null || event === void 0 ? void 0 : event.category) || {};
|
|
45214
|
-
const seedingScaleAttributes = {
|
|
45215
|
-
scaleType: SEEDING,
|
|
45216
|
-
scaleName: seedingScaleName || categoryName || ageCategoryCode,
|
|
45217
|
-
eventType
|
|
45218
|
-
};
|
|
45219
|
-
let {
|
|
45220
|
-
scaledEntries
|
|
45221
|
-
} = getScaledEntries({
|
|
45222
|
-
scaleAttributes: seedingScaleAttributes,
|
|
45223
|
-
tournamentRecord,
|
|
45224
|
-
stage: MAIN,
|
|
45225
|
-
entries
|
|
45226
|
-
});
|
|
45227
|
-
|
|
45228
|
-
if (!((_scaledEntries = scaledEntries) !== null && _scaledEntries !== void 0 && _scaledEntries.length) && seedByRanking) {
|
|
45229
|
-
const rankingScaleAttributes = {
|
|
45230
|
-
scaleType: RANKING,
|
|
45231
|
-
scaleName: categoryName || ageCategoryCode,
|
|
45232
|
-
eventType
|
|
45233
|
-
};
|
|
45234
|
-
({
|
|
45235
|
-
scaledEntries
|
|
45236
|
-
} = getScaledEntries({
|
|
45237
|
-
scaleAttributes: rankingScaleAttributes,
|
|
45238
|
-
tournamentRecord,
|
|
45239
|
-
stage: MAIN,
|
|
45311
|
+
stageSequence,
|
|
45312
|
+
seedsCount: 0,
|
|
45313
|
+
participants,
|
|
45314
|
+
drawSize,
|
|
45240
45315
|
entries
|
|
45241
|
-
}));
|
|
45242
|
-
}
|
|
45243
|
-
|
|
45244
|
-
const scaledEntriesCount = ((_scaledEntries2 = scaledEntries) === null || _scaledEntries2 === void 0 ? void 0 : _scaledEntries2.length) || 0;
|
|
45245
|
-
if (scaledEntriesCount < seedsCount) seedsCount = scaledEntriesCount;
|
|
45246
|
-
scaledEntries && scaledEntries.filter(({
|
|
45247
|
-
participantId
|
|
45248
|
-
}) => enteredParticipantIds.includes(participantId)).slice(0, assignSeedsCount || seedsCount).forEach((scaledEntry, index) => {
|
|
45249
|
-
const seedNumber = index + 1;
|
|
45250
|
-
const seedValue = (seedAssignmentProfile === null || seedAssignmentProfile === void 0 ? void 0 : seedAssignmentProfile[seedNumber]) || seedNumber; // ?? attach basis of seeding information to seedAssignment ??
|
|
45251
|
-
|
|
45252
|
-
const {
|
|
45253
|
-
participantId
|
|
45254
|
-
} = scaledEntry;
|
|
45255
|
-
assignSeed({
|
|
45256
|
-
drawDefinition,
|
|
45257
|
-
participantId,
|
|
45258
|
-
structureId,
|
|
45259
|
-
seedNumber,
|
|
45260
|
-
seedValue
|
|
45261
45316
|
});
|
|
45262
|
-
|
|
45263
|
-
|
|
45264
|
-
|
|
45265
|
-
|
|
45266
|
-
|
|
45267
|
-
if (automated !== false) {
|
|
45268
|
-
const seedsOnly = typeof automated === 'object' && automated.seedsOnly; // if { seedsOnly: true } then only seeds and an Byes releated to seeded positions are placed
|
|
45269
|
-
|
|
45270
|
-
({
|
|
45271
|
-
conflicts
|
|
45272
|
-
} = automatedPositioning$1({
|
|
45273
|
-
inContextDrawMatchUps,
|
|
45274
|
-
drawDefinition,
|
|
45275
|
-
participants,
|
|
45276
|
-
structureId,
|
|
45277
|
-
matchUpsMap,
|
|
45278
|
-
seedsOnly,
|
|
45279
|
-
drawType,
|
|
45280
|
-
event
|
|
45281
|
-
}));
|
|
45317
|
+
stageSequence += 1;
|
|
45318
|
+
console.log({
|
|
45319
|
+
qualifyingResult
|
|
45320
|
+
});
|
|
45321
|
+
}
|
|
45282
45322
|
}
|
|
45283
45323
|
|
|
45284
|
-
|
|
45285
|
-
|
|
45286
|
-
|
|
45287
|
-
|
|
45288
|
-
const drawDetails = {
|
|
45289
|
-
drawId: drawDefinition.drawId,
|
|
45290
|
-
category: event === null || event === void 0 ? void 0 : event.category,
|
|
45291
|
-
eventId: event === null || event === void 0 ? void 0 : event.eventId,
|
|
45292
|
-
seedingScaleName,
|
|
45293
|
-
matchUpType,
|
|
45294
|
-
seedsCount,
|
|
45295
|
-
automated,
|
|
45296
|
-
tieFormat,
|
|
45297
|
-
drawSize,
|
|
45298
|
-
drawType,
|
|
45299
|
-
drawName
|
|
45300
|
-
};
|
|
45301
|
-
addNotice({
|
|
45302
|
-
topic: AUDIT,
|
|
45303
|
-
payload: {
|
|
45304
|
-
action: 'generateDrawDefinition',
|
|
45305
|
-
payload: drawDetails
|
|
45306
|
-
}
|
|
45307
|
-
});
|
|
45308
|
-
return { ...SUCCESS,
|
|
45309
|
-
structureId,
|
|
45324
|
+
const conflicts = structureResult.conflicts;
|
|
45325
|
+
const structureId = structureResult.structureId;
|
|
45326
|
+
drawDefinition.drawName = params.drawName || drawType;
|
|
45327
|
+
return {
|
|
45310
45328
|
drawDefinition,
|
|
45329
|
+
structureId,
|
|
45330
|
+
...SUCCESS,
|
|
45311
45331
|
conflicts
|
|
45312
45332
|
};
|
|
45313
45333
|
}
|
|
@@ -52327,12 +52347,22 @@ function generateEventWithDraw({
|
|
|
52327
52347
|
stage
|
|
52328
52348
|
} = drawProfile;
|
|
52329
52349
|
const eventType = drawProfile.eventType || drawProfile.matchUpType || SINGLES;
|
|
52350
|
+
const participantType = eventType === DOUBLES ? PAIR$1 : INDIVIDUAL$1;
|
|
52330
52351
|
const tieFormat = typeof drawProfile.tieFormat === 'object' ? drawProfile.tieFormat : eventType === TEAM$1 ? tieFormatDefaults({
|
|
52331
52352
|
namedFormat: tieFormatName
|
|
52332
52353
|
}) : undefined;
|
|
52333
52354
|
const categoryName = (category === null || category === void 0 ? void 0 : category.categoryName) || (category === null || category === void 0 ? void 0 : category.ageCategoryCode) || (category === null || category === void 0 ? void 0 : category.ratingType);
|
|
52334
52355
|
let eventName = drawProfile.eventName || categoryName || `Generated ${eventType}`;
|
|
52335
52356
|
let targetParticipants = (tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.participants) || [];
|
|
52357
|
+
/*
|
|
52358
|
+
const qualifyingIndividualParticipantsCount =
|
|
52359
|
+
(params.qualifyingProfiles?.reduce(
|
|
52360
|
+
(count, profile) => count + profile.drawSize,
|
|
52361
|
+
0
|
|
52362
|
+
) || 0) * (participantType === DOUBLES ? 2 : 1);
|
|
52363
|
+
console.log({ qualifyingIndividualParticipantsCount });
|
|
52364
|
+
*/
|
|
52365
|
+
|
|
52336
52366
|
const participantsCount = !drawProfile.participantsCount || drawProfile.participantsCount > drawSize ? drawSize : drawProfile.participantsCount;
|
|
52337
52367
|
const eventId = UUID();
|
|
52338
52368
|
let event = {
|
|
@@ -52374,7 +52404,6 @@ function generateEventWithDraw({
|
|
|
52374
52404
|
}
|
|
52375
52405
|
|
|
52376
52406
|
const idPrefix = participantsProfile !== null && participantsProfile !== void 0 && participantsProfile.idPrefix ? `D-${drawIndex}-${participantsProfile === null || participantsProfile === void 0 ? void 0 : participantsProfile.idPrefix}` : undefined;
|
|
52377
|
-
const participantType = eventType === DOUBLES ? PAIR$1 : INDIVIDUAL$1;
|
|
52378
52407
|
const {
|
|
52379
52408
|
participants: unique
|
|
52380
52409
|
} = generateParticipants({ ...participantsProfile,
|