tods-competition-factory 1.8.34 → 1.8.36
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 +26 -12
- package/dist/forge/generate.mjs.map +1 -1
- package/dist/forge/query.mjs +1 -2
- package/dist/forge/query.mjs.map +1 -1
- package/dist/index.mjs +91 -45
- package/dist/index.mjs.map +1 -1
- package/dist/tods-competition-factory.development.cjs.js +216 -150
- 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 +5 -5
package/dist/index.mjs
CHANGED
|
@@ -2404,7 +2404,7 @@ const matchUpFormatCode = {
|
|
|
2404
2404
|
};
|
|
2405
2405
|
|
|
2406
2406
|
function factoryVersion() {
|
|
2407
|
-
return "1.8.
|
|
2407
|
+
return "1.8.36";
|
|
2408
2408
|
}
|
|
2409
2409
|
|
|
2410
2410
|
function getObjectTieFormat(obj) {
|
|
@@ -15542,7 +15542,13 @@ const POLICY_SEEDING_USTA = {
|
|
|
15542
15542
|
validSeedPositions: { ignore: true },
|
|
15543
15543
|
duplicateSeedNumbers: true,
|
|
15544
15544
|
drawSizeProgression: true,
|
|
15545
|
-
seedingProfile: {
|
|
15545
|
+
seedingProfile: {
|
|
15546
|
+
drawTypes: {
|
|
15547
|
+
[ROUND_ROBIN_WITH_PLAYOFF]: { positioning: WATERFALL },
|
|
15548
|
+
[ROUND_ROBIN]: { positioning: WATERFALL }
|
|
15549
|
+
},
|
|
15550
|
+
positioning: SEPARATE
|
|
15551
|
+
},
|
|
15546
15552
|
policyName: "USTA SEEDING",
|
|
15547
15553
|
seedsCountThresholds: [
|
|
15548
15554
|
{ drawSize: 4, minimumParticipantCount: 3, seedsCount: 2 },
|
|
@@ -19573,6 +19579,15 @@ function tidyScore(params) {
|
|
|
19573
19579
|
};
|
|
19574
19580
|
}
|
|
19575
19581
|
|
|
19582
|
+
function capitalizeFirst(str) {
|
|
19583
|
+
return !isString(str) ? str : str.split(" ").map(
|
|
19584
|
+
(name) => name.split("").map((c, i) => i ? c.toLowerCase() : c.toUpperCase()).join("")
|
|
19585
|
+
).join(" ");
|
|
19586
|
+
}
|
|
19587
|
+
function constantToString(str) {
|
|
19588
|
+
return !isString(str) ? str : capitalizeFirst(str.replace(/_/g, " "));
|
|
19589
|
+
}
|
|
19590
|
+
|
|
19576
19591
|
const { FACTORY } = extensionConstants;
|
|
19577
19592
|
function updateFactoryExtension({ tournamentRecord, value }) {
|
|
19578
19593
|
const { extension } = findExtension({
|
|
@@ -23469,15 +23484,6 @@ function getNumericSeedValue(seedValue) {
|
|
|
23469
23484
|
return Infinity;
|
|
23470
23485
|
}
|
|
23471
23486
|
|
|
23472
|
-
function capitalizeFirst(str) {
|
|
23473
|
-
return !isString(str) ? str : str.split(" ").map(
|
|
23474
|
-
(name) => name.split("").map((c, i) => i ? c.toLowerCase() : c.toUpperCase()).join("")
|
|
23475
|
-
).join(" ");
|
|
23476
|
-
}
|
|
23477
|
-
function constantToString(str) {
|
|
23478
|
-
return !isString(str) ? str : capitalizeFirst(str.replace(/_/g, " "));
|
|
23479
|
-
}
|
|
23480
|
-
|
|
23481
23487
|
const structureTemplate = ({
|
|
23482
23488
|
finishingPosition = ROUND_OUTCOME,
|
|
23483
23489
|
qualifyingRoundNumber,
|
|
@@ -27542,12 +27548,11 @@ function getParticipantEntries(params) {
|
|
|
27542
27548
|
const targetParticipantIds = participantFilters?.participantIds;
|
|
27543
27549
|
const getRelevantParticipantIds = (participantId) => {
|
|
27544
27550
|
const relevantParticipantIds = [participantId];
|
|
27545
|
-
relevantParticipantIds.push(participantId);
|
|
27546
27551
|
participantMap[participantId]?.participant.individualParticipantIds?.forEach(
|
|
27547
27552
|
(individualParticiapntId) => relevantParticipantIds.push(individualParticiapntId)
|
|
27548
27553
|
);
|
|
27549
27554
|
return relevantParticipantIds.some(
|
|
27550
|
-
(
|
|
27555
|
+
(id) => !targetParticipantIds?.length || targetParticipantIds.includes(id)
|
|
27551
27556
|
) ? relevantParticipantIds : [];
|
|
27552
27557
|
};
|
|
27553
27558
|
const withOpts = {
|
|
@@ -41807,11 +41812,11 @@ function swapAssignedPositions({
|
|
|
41807
41812
|
);
|
|
41808
41813
|
const secondAssignment = candidatePositionAssignments.find(
|
|
41809
41814
|
(assignment) => assignment.drawPosition === secondPosition
|
|
41810
|
-
);
|
|
41815
|
+
) ?? {};
|
|
41811
41816
|
const updatedFirstAssignmentAttributes = {
|
|
41812
|
-
participantId: secondAssignment
|
|
41813
|
-
qualifier: secondAssignment
|
|
41814
|
-
bye: secondAssignment
|
|
41817
|
+
participantId: secondAssignment?.participantId,
|
|
41818
|
+
qualifier: secondAssignment?.qualifier,
|
|
41819
|
+
bye: secondAssignment?.bye
|
|
41815
41820
|
};
|
|
41816
41821
|
const updatedSecondAssignmentAttributes = {
|
|
41817
41822
|
participantId: firstAssignment.participantId,
|
|
@@ -41969,7 +41974,7 @@ function randomUnseededSeparation({
|
|
|
41969
41974
|
});
|
|
41970
41975
|
if (result.error)
|
|
41971
41976
|
return decorateResult({ result, stack });
|
|
41972
|
-
} else {
|
|
41977
|
+
} else if (assignment.participantId) {
|
|
41973
41978
|
const result = assignDrawPosition$1({
|
|
41974
41979
|
automaticPlacement: true,
|
|
41975
41980
|
inContextDrawMatchUps,
|
|
@@ -44555,7 +44560,7 @@ function removeStructure({
|
|
|
44555
44560
|
drawDefinition.links = drawDefinition.links?.filter(
|
|
44556
44561
|
(link) => link.source.structureId !== idBeingRemoved && link.target.structureId !== idBeingRemoved
|
|
44557
44562
|
) || [];
|
|
44558
|
-
if (!isMainStageSequence1 || idBeingRemoved !== structureId) {
|
|
44563
|
+
if (!isMainStageSequence1 || isMainStageSequence1 && qualifyingStructureIds.length || idBeingRemoved !== structureId) {
|
|
44559
44564
|
drawDefinition.structures = (drawDefinition.structures ?? []).filter(
|
|
44560
44565
|
(structure3) => {
|
|
44561
44566
|
if (idBeingRemoved && idBeingRemoved === structure3.structureId)
|
|
@@ -45922,7 +45927,7 @@ function addEventEntries(params) {
|
|
|
45922
45927
|
const genderEnforced = (enforceGender ?? matchUpActionsPolicy?.participants?.enforceGender) !== false;
|
|
45923
45928
|
const addedParticipantIdEntries = [];
|
|
45924
45929
|
const removedEntries = [];
|
|
45925
|
-
if (extensions && (!Array.isArray(extensions) || !extensions.every(isValidExtension)) || extension && !isValidExtension({ extension })) {
|
|
45930
|
+
if (extensions && (!Array.isArray(extensions) || !extensions.every((extension2) => isValidExtension({ extension: extension2 }))) || extension && !isValidExtension({ extension })) {
|
|
45926
45931
|
return decorateResult({
|
|
45927
45932
|
context: definedAttributes({ extension, extensions }),
|
|
45928
45933
|
result: { error: INVALID_VALUES },
|
|
@@ -45984,7 +45989,7 @@ function addEventEntries(params) {
|
|
|
45984
45989
|
if (entryStageSequence)
|
|
45985
45990
|
entry.entryStageSequence = entryStageSequence;
|
|
45986
45991
|
addedParticipantIdEntries.push(entry.participantId);
|
|
45987
|
-
event.entries.push(entry);
|
|
45992
|
+
event.entries && event.entries.push(entry);
|
|
45988
45993
|
}
|
|
45989
45994
|
});
|
|
45990
45995
|
if (drawId && !isUngrouped(entryStage)) {
|
|
@@ -46005,14 +46010,14 @@ function addEventEntries(params) {
|
|
|
46005
46010
|
info = result.error;
|
|
46006
46011
|
}
|
|
46007
46012
|
}
|
|
46008
|
-
if ([
|
|
46013
|
+
if (event.eventType && [TypeEnum.Doubles, TypeEnum.Team].includes(event.eventType)) {
|
|
46009
46014
|
const enteredParticipantIds = (event.entries || []).map(
|
|
46010
46015
|
(entry) => entry.participantId
|
|
46011
46016
|
);
|
|
46012
46017
|
const ungroupedIndividualParticipantIds = (event.entries || []).filter((entry) => isUngrouped(entry.entryStatus)).map((entry) => entry.participantId);
|
|
46013
46018
|
const tournamentParticipants = tournamentRecord?.participants || [];
|
|
46014
46019
|
const groupedIndividualParticipantIds = tournamentParticipants.filter(
|
|
46015
|
-
(participant) => enteredParticipantIds.includes(participant.participantId) && [PAIR, TEAM].includes(participant.participantType)
|
|
46020
|
+
(participant) => enteredParticipantIds.includes(participant.participantId) && participant.participantType && [PAIR, TEAM].includes(participant.participantType)
|
|
46016
46021
|
).map((participant) => participant.individualParticipantIds).flat(Infinity);
|
|
46017
46022
|
const ungroupedParticipantIdsToRemove = ungroupedIndividualParticipantIds.filter(
|
|
46018
46023
|
(participantId) => groupedIndividualParticipantIds.includes(participantId)
|
|
@@ -56245,7 +56250,8 @@ function deleteDrawDefinitions({
|
|
|
56245
56250
|
drawIds = [],
|
|
56246
56251
|
auditData,
|
|
56247
56252
|
eventId,
|
|
56248
|
-
event
|
|
56253
|
+
event,
|
|
56254
|
+
force
|
|
56249
56255
|
}) {
|
|
56250
56256
|
if (!tournamentRecord)
|
|
56251
56257
|
return { error: MISSING_TOURNAMENT_RECORD };
|
|
@@ -56291,9 +56297,18 @@ function deleteDrawDefinitions({
|
|
|
56291
56297
|
qualifier,
|
|
56292
56298
|
bye
|
|
56293
56299
|
}) => ({ bye, qualifier, drawPosition, participantId });
|
|
56300
|
+
const drawIdsWithScoresPresent = [];
|
|
56294
56301
|
const filteredDrawDefinitions = event.drawDefinitions.filter(
|
|
56295
56302
|
(drawDefinition) => {
|
|
56296
56303
|
if (drawIds.includes(drawDefinition.drawId)) {
|
|
56304
|
+
const matchUps = allDrawMatchUps$1({ event, drawDefinition })?.matchUps ?? [];
|
|
56305
|
+
const scoresPresent = matchUps.some(
|
|
56306
|
+
({ score }) => scoreHasValue({ score })
|
|
56307
|
+
);
|
|
56308
|
+
if (scoresPresent && !force) {
|
|
56309
|
+
drawIdsWithScoresPresent.push(drawDefinition.drawId);
|
|
56310
|
+
return true;
|
|
56311
|
+
}
|
|
56297
56312
|
const { drawId: drawId2, drawType, drawName } = drawDefinition;
|
|
56298
56313
|
const flight = flightProfile?.flights?.find(
|
|
56299
56314
|
(flight2) => flight2.drawId === drawDefinition.drawId
|
|
@@ -56353,12 +56368,18 @@ function deleteDrawDefinitions({
|
|
|
56353
56368
|
drawId: drawId2
|
|
56354
56369
|
})
|
|
56355
56370
|
);
|
|
56356
|
-
const { matchUps } = allDrawMatchUps$1({ event, drawDefinition });
|
|
56357
56371
|
matchUps?.forEach(({ matchUpId }) => matchUpIds.push(matchUpId));
|
|
56358
56372
|
}
|
|
56359
56373
|
return !drawIds.includes(drawDefinition.drawId);
|
|
56360
56374
|
}
|
|
56361
56375
|
);
|
|
56376
|
+
if (drawIdsWithScoresPresent.length && !force) {
|
|
56377
|
+
return decorateResult({
|
|
56378
|
+
context: { drawIdsWithScoresPresent },
|
|
56379
|
+
result: { error: SCORES_PRESENT },
|
|
56380
|
+
stack
|
|
56381
|
+
});
|
|
56382
|
+
}
|
|
56362
56383
|
event.drawDefinitions = filteredDrawDefinitions;
|
|
56363
56384
|
if (flightProfile) {
|
|
56364
56385
|
const extension = {
|
|
@@ -56580,24 +56601,39 @@ function addEventEntryPairs({
|
|
|
56580
56601
|
return { error: MISSING_EVENT };
|
|
56581
56602
|
if (event.eventType !== DOUBLES$1)
|
|
56582
56603
|
return { error: INVALID_EVENT_TYPE };
|
|
56583
|
-
const
|
|
56584
|
-
const
|
|
56585
|
-
const
|
|
56586
|
-
|
|
56587
|
-
|
|
56588
|
-
|
|
56589
|
-
|
|
56590
|
-
|
|
56591
|
-
|
|
56592
|
-
|
|
56604
|
+
const existingParticipantIdPairs = [];
|
|
56605
|
+
const genderMap = /* @__PURE__ */ new Map();
|
|
56606
|
+
for (const participant of tournamentRecord.participants ?? []) {
|
|
56607
|
+
const { participantType, participantId, person, individualParticipantIds } = participant;
|
|
56608
|
+
if (participantType === INDIVIDUAL && person?.sex) {
|
|
56609
|
+
genderMap.set(participantId, person.sex);
|
|
56610
|
+
} else if (participantType === PAIR && individualParticipantIds) {
|
|
56611
|
+
existingParticipantIdPairs.push(individualParticipantIds);
|
|
56612
|
+
}
|
|
56613
|
+
}
|
|
56614
|
+
const invalidParticipantIdPairs = participantIdPairs.filter((pair) => {
|
|
56615
|
+
if (pair.length !== 2)
|
|
56616
|
+
return true;
|
|
56617
|
+
if (!genderMap.has(pair[0]) || !genderMap.has(pair[1]))
|
|
56618
|
+
return true;
|
|
56619
|
+
if (!event.gender || event.gender === ANY)
|
|
56620
|
+
return false;
|
|
56621
|
+
const participantGenders = pair.map((id) => genderMap.get(id));
|
|
56622
|
+
let invalidParticiapntGenders = event.gender === MALE && (participantGenders[0] !== MALE || participantGenders[1] !== MALE) || event.gender === FEMALE && (participantGenders[0] !== FEMALE || participantGenders[1] !== FEMALE);
|
|
56623
|
+
if (event.gender === MIXED) {
|
|
56624
|
+
participantGenders.sort();
|
|
56625
|
+
if (participantGenders[0] !== FEMALE || participantGenders[1] !== MALE)
|
|
56626
|
+
invalidParticiapntGenders = true;
|
|
56627
|
+
}
|
|
56628
|
+
return invalidParticiapntGenders;
|
|
56629
|
+
});
|
|
56593
56630
|
if (invalidParticipantIdPairs.length)
|
|
56594
56631
|
return { error: INVALID_PARTICIPANT_IDS, invalidParticipantIdPairs };
|
|
56595
|
-
const existingParticipantIdPairs = tournamentParticipants.filter((participant) => participant.participantType === PAIR).map((participant) => participant.individualParticipantIds);
|
|
56596
56632
|
const provisionalParticipants = participantIdPairs.map(
|
|
56597
|
-
(
|
|
56633
|
+
(individualParticipantIds) => ({
|
|
56598
56634
|
participantId: uuids?.pop() ?? UUID(),
|
|
56599
56635
|
participantRole: COMPETITOR,
|
|
56600
|
-
individualParticipantIds
|
|
56636
|
+
individualParticipantIds,
|
|
56601
56637
|
participantType: PAIR
|
|
56602
56638
|
})
|
|
56603
56639
|
);
|
|
@@ -59365,11 +59401,9 @@ function generateDrawDefinition(params) {
|
|
|
59365
59401
|
ignoreAllowedDrawTypes,
|
|
59366
59402
|
voluntaryConsolation,
|
|
59367
59403
|
hydrateCollections,
|
|
59368
|
-
policyDefinitions,
|
|
59369
59404
|
ignoreStageSpace,
|
|
59370
59405
|
tournamentRecord,
|
|
59371
59406
|
qualifyingOnly,
|
|
59372
|
-
seedingProfile,
|
|
59373
59407
|
tieFormatName,
|
|
59374
59408
|
drawEntries,
|
|
59375
59409
|
addToEvent,
|
|
@@ -59380,8 +59414,19 @@ function generateDrawDefinition(params) {
|
|
|
59380
59414
|
tournamentRecord,
|
|
59381
59415
|
event
|
|
59382
59416
|
}).appliedPolicies ?? {};
|
|
59383
|
-
const
|
|
59417
|
+
const policyDefinitions = params.policyDefinitions ?? {};
|
|
59418
|
+
const drawTypeCoercion = params.drawTypeCoercion ?? policyDefinitions?.[POLICY_TYPE_DRAWS]?.drawTypeCoercion ?? appliedPolicies?.[POLICY_TYPE_DRAWS]?.drawTypeCoercion ?? true;
|
|
59384
59419
|
const drawType = drawTypeCoercion && params.drawSize === 2 && DrawTypeEnum.SingleElimination || params.drawType || DrawTypeEnum.SingleElimination;
|
|
59420
|
+
const seedingPolicy = policyDefinitions?.[POLICY_TYPE_SEEDING] ?? appliedPolicies?.[POLICY_TYPE_SEEDING];
|
|
59421
|
+
const seedingProfile = params.seedingProfile ?? seedingPolicy?.seedingProfile?.drawTypes?.[drawType] ?? seedingPolicy?.seedingProfile;
|
|
59422
|
+
if (params.seedingProfile) {
|
|
59423
|
+
if (!policyDefinitions[POLICY_TYPE_SEEDING]) {
|
|
59424
|
+
policyDefinitions[POLICY_TYPE_SEEDING] = {
|
|
59425
|
+
...POLICY_SEEDING_USTA[POLICY_TYPE_SEEDING]
|
|
59426
|
+
};
|
|
59427
|
+
}
|
|
59428
|
+
policyDefinitions[POLICY_TYPE_SEEDING].seedingProfile = seedingProfile;
|
|
59429
|
+
}
|
|
59385
59430
|
const { participants, participantMap } = getParticipants$1({
|
|
59386
59431
|
withIndividualParticipants: true,
|
|
59387
59432
|
tournamentRecord
|
|
@@ -59514,7 +59559,7 @@ function generateDrawDefinition(params) {
|
|
|
59514
59559
|
}
|
|
59515
59560
|
}
|
|
59516
59561
|
}
|
|
59517
|
-
if (!appliedPolicies[POLICY_TYPE_SEEDING]) {
|
|
59562
|
+
if (!appliedPolicies[POLICY_TYPE_SEEDING] && !policyDefinitions[POLICY_TYPE_SEEDING]) {
|
|
59518
59563
|
attachPolicies({ drawDefinition, policyDefinitions: POLICY_SEEDING_USTA });
|
|
59519
59564
|
Object.assign(appliedPolicies, POLICY_SEEDING_USTA);
|
|
59520
59565
|
}
|
|
@@ -64002,8 +64047,8 @@ function generateFlight({
|
|
|
64002
64047
|
const result2 = addEventEntries({
|
|
64003
64048
|
participantIds: drawParticipantIds,
|
|
64004
64049
|
autoEntryPositions,
|
|
64050
|
+
entryStage: stage,
|
|
64005
64051
|
tournamentRecord,
|
|
64006
|
-
stage,
|
|
64007
64052
|
event
|
|
64008
64053
|
});
|
|
64009
64054
|
if (result2.error)
|
|
@@ -64214,9 +64259,9 @@ function generateEventWithFlights(params) {
|
|
|
64214
64259
|
if (eventParticipantIds.length) {
|
|
64215
64260
|
const result = addEventEntries({
|
|
64216
64261
|
participantIds: eventParticipantIds,
|
|
64262
|
+
entryStage: StageTypeEnum.Main,
|
|
64217
64263
|
autoEntryPositions,
|
|
64218
64264
|
tournamentRecord,
|
|
64219
|
-
stage: MAIN,
|
|
64220
64265
|
event
|
|
64221
64266
|
});
|
|
64222
64267
|
if (result.error)
|
|
@@ -64455,7 +64500,7 @@ function generateEventWithDraw(params) {
|
|
|
64455
64500
|
qualifyingIndex + participantsCount2
|
|
64456
64501
|
);
|
|
64457
64502
|
const result2 = addEventEntries({
|
|
64458
|
-
entryStage:
|
|
64503
|
+
entryStage: StageTypeEnum.Qualifying,
|
|
64459
64504
|
entryStageSequence,
|
|
64460
64505
|
autoEntryPositions,
|
|
64461
64506
|
tournamentRecord,
|
|
@@ -65341,6 +65386,7 @@ const utilities = {
|
|
|
65341
65386
|
categoryCanContain,
|
|
65342
65387
|
chunkArray,
|
|
65343
65388
|
compareTieFormats,
|
|
65389
|
+
constantToString,
|
|
65344
65390
|
countValues,
|
|
65345
65391
|
createMap,
|
|
65346
65392
|
dateRange,
|