tods-competition-factory 1.7.10 → 1.7.11
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 +15 -11
- package/dist/forge/generate.mjs.map +1 -1
- package/dist/forge/query.mjs +5 -2
- package/dist/forge/query.mjs.map +1 -1
- package/dist/index.mjs +51 -50
- package/dist/index.mjs.map +1 -1
- package/dist/tods-competition-factory.development.cjs.js +63 -54
- 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
|
@@ -333,7 +333,7 @@ const matchUpFormatCode = {
|
|
|
333
333
|
};
|
|
334
334
|
|
|
335
335
|
function factoryVersion() {
|
|
336
|
-
return "1.7.
|
|
336
|
+
return "1.7.11";
|
|
337
337
|
}
|
|
338
338
|
|
|
339
339
|
function getObjectTieFormat(obj) {
|
|
@@ -44424,6 +44424,16 @@ function generateAdHocMatchUps$1({
|
|
|
44424
44424
|
);
|
|
44425
44425
|
if (!structure)
|
|
44426
44426
|
return { error: STRUCTURE_NOT_FOUND };
|
|
44427
|
+
let structureHasRoundPositions;
|
|
44428
|
+
const existingMatchUps = structure.matchUps ?? [];
|
|
44429
|
+
const lastRoundNumber = existingMatchUps?.reduce(
|
|
44430
|
+
(roundNumber2, matchUp) => {
|
|
44431
|
+
if (matchUp.roundPosition)
|
|
44432
|
+
structureHasRoundPositions = true;
|
|
44433
|
+
return (matchUp?.roundNumber || 0) > roundNumber2 ? matchUp.roundNumber : roundNumber2;
|
|
44434
|
+
},
|
|
44435
|
+
0
|
|
44436
|
+
);
|
|
44427
44437
|
if (!matchUpsCount) {
|
|
44428
44438
|
const selectedEntries = drawDefinition?.entries?.filter((entry) => {
|
|
44429
44439
|
const entryStatus = entry.entryStatus;
|
|
@@ -44433,7 +44443,11 @@ function generateAdHocMatchUps$1({
|
|
|
44433
44443
|
if (newRound) {
|
|
44434
44444
|
matchUpsCount = roundMatchUpsCount;
|
|
44435
44445
|
} else {
|
|
44436
|
-
const
|
|
44446
|
+
const targetRoundNumber = roundNumber || lastRoundNumber || 1;
|
|
44447
|
+
const existingRoundMatchUps = structure.matchUps?.filter(
|
|
44448
|
+
(matchUp) => matchUp.roundNumber === targetRoundNumber
|
|
44449
|
+
)?.length || 0;
|
|
44450
|
+
const maxRemaining = roundMatchUpsCount - existingRoundMatchUps;
|
|
44437
44451
|
if (maxRemaining > 0)
|
|
44438
44452
|
matchUpsCount = maxRemaining;
|
|
44439
44453
|
}
|
|
@@ -44441,16 +44455,6 @@ function generateAdHocMatchUps$1({
|
|
|
44441
44455
|
if (participantIdPairings && !Array.isArray(participantIdPairings) || matchUpsCount && !isConvertableInteger(matchUpsCount) || matchUpIds && !Array.isArray(matchUpIds) || !participantIdPairings && !matchUpsCount) {
|
|
44442
44456
|
return { error: INVALID_VALUES, info: "matchUpsCount or pairings error" };
|
|
44443
44457
|
}
|
|
44444
|
-
let structureHasRoundPositions;
|
|
44445
|
-
const existingMatchUps = structure.matchUps ?? [];
|
|
44446
|
-
const lastRoundNumber = existingMatchUps?.reduce(
|
|
44447
|
-
(roundNumber2, matchUp) => {
|
|
44448
|
-
if (matchUp.roundPosition)
|
|
44449
|
-
structureHasRoundPositions = true;
|
|
44450
|
-
return (matchUp?.roundNumber || 0) > roundNumber2 ? matchUp.roundNumber : roundNumber2;
|
|
44451
|
-
},
|
|
44452
|
-
0
|
|
44453
|
-
);
|
|
44454
44458
|
if (structure.structures || structureHasRoundPositions || structure.finishingPosition === ROUND_OUTCOME) {
|
|
44455
44459
|
return { error: INVALID_STRUCTURE };
|
|
44456
44460
|
}
|
|
@@ -45081,9 +45085,12 @@ function setPositionAssignments$1({
|
|
|
45081
45085
|
return { ...SUCCESS };
|
|
45082
45086
|
}
|
|
45083
45087
|
|
|
45084
|
-
function getAssignedParticipantIds({
|
|
45088
|
+
function getAssignedParticipantIds({
|
|
45089
|
+
drawDefinition,
|
|
45090
|
+
stages
|
|
45091
|
+
}) {
|
|
45085
45092
|
const stageStructures = (drawDefinition?.structures || []).filter(
|
|
45086
|
-
(structure) => !stages?.length || stages.includes(structure.stage)
|
|
45093
|
+
(structure) => !stages?.length || structure.stage && stages.includes(structure.stage)
|
|
45087
45094
|
);
|
|
45088
45095
|
return stageStructures.map((structure) => {
|
|
45089
45096
|
const { positionAssignments } = getPositionAssignments$1({
|
|
@@ -45626,49 +45633,47 @@ function participantInFlightEntries({
|
|
|
45626
45633
|
|
|
45627
45634
|
function removeEventEntries({
|
|
45628
45635
|
autoEntryPositions = true,
|
|
45629
|
-
|
|
45630
|
-
|
|
45631
|
-
|
|
45636
|
+
participantIds = [],
|
|
45637
|
+
entryStatuses,
|
|
45638
|
+
stage,
|
|
45632
45639
|
event
|
|
45633
45640
|
}) {
|
|
45634
45641
|
const stack = "removeEventEntries";
|
|
45635
45642
|
if (!event?.eventId)
|
|
45636
45643
|
return { error: MISSING_EVENT };
|
|
45637
|
-
if (!Array.isArray(participantIds))
|
|
45638
|
-
return decorateResult({
|
|
45639
|
-
result: { error: MISSING_PARTICIPANT_IDS },
|
|
45640
|
-
stack
|
|
45641
|
-
});
|
|
45642
|
-
participantIds = participantIds?.filter(Boolean);
|
|
45643
|
-
if (!participantIds?.length)
|
|
45644
|
-
return decorateResult({
|
|
45645
|
-
result: { error: MISSING_PARTICIPANT_IDS },
|
|
45646
|
-
stack
|
|
45647
|
-
});
|
|
45648
|
-
const { eventId } = event;
|
|
45649
|
-
if (!tournamentParticipants) {
|
|
45650
|
-
tournamentParticipants = getTournamentParticipants({
|
|
45651
|
-
participantFilters: { participantIds },
|
|
45652
|
-
tournamentRecord,
|
|
45653
|
-
withEvents: true,
|
|
45654
|
-
withDraws: true
|
|
45655
|
-
}).tournamentParticipants;
|
|
45644
|
+
if (!Array.isArray(participantIds) || participantIds.some((participantId) => !isString(participantId))) {
|
|
45645
|
+
return decorateResult({ result: { error: INVALID_PARTICIPANT_ID }, stack });
|
|
45656
45646
|
}
|
|
45657
|
-
const
|
|
45658
|
-
|
|
45659
|
-
|
|
45660
|
-
|
|
45661
|
-
|
|
45662
|
-
|
|
45663
|
-
|
|
45664
|
-
).
|
|
45665
|
-
|
|
45666
|
-
if (
|
|
45647
|
+
const assignedParticipantIds = (event.drawDefinitions ?? []).flatMap(
|
|
45648
|
+
(drawDefinition) => getAssignedParticipantIds({ drawDefinition })
|
|
45649
|
+
);
|
|
45650
|
+
const statusParticipantIds = (entryStatuses?.length && event.entries?.filter(
|
|
45651
|
+
(entry) => entry.entryStatus && entryStatuses.includes(entry.entryStatus)
|
|
45652
|
+
) || []).map(extractAttributes("participantId")).filter((participantId) => !assignedParticipantIds.includes(participantId));
|
|
45653
|
+
const stageParticipantIds = (stage && event.entries?.filter(
|
|
45654
|
+
(entry) => entry.entryStage && entry.entryStage === stage
|
|
45655
|
+
) || []).map(extractAttributes("participantId")).filter((participantId) => !assignedParticipantIds.includes(participantId));
|
|
45656
|
+
if (participantIds.length) {
|
|
45657
|
+
participantIds = participantIds.filter(
|
|
45658
|
+
(participantId) => (!entryStatuses?.length || statusParticipantIds.includes(participantId)) && (!stage || stageParticipantIds.includes(participantId))
|
|
45659
|
+
);
|
|
45660
|
+
} else if (statusParticipantIds.length && stageParticipantIds.length) {
|
|
45661
|
+
participantIds = intersection(statusParticipantIds, stageParticipantIds);
|
|
45662
|
+
} else if (statusParticipantIds.length) {
|
|
45663
|
+
participantIds = statusParticipantIds;
|
|
45664
|
+
} else if (stageParticipantIds.length) {
|
|
45665
|
+
participantIds = stageParticipantIds;
|
|
45666
|
+
}
|
|
45667
|
+
if (participantIds?.length && assignedParticipantIds.some(
|
|
45668
|
+
(participantId) => participantIds.includes(participantId)
|
|
45669
|
+
)) {
|
|
45667
45670
|
return decorateResult({
|
|
45668
45671
|
result: { error: EXISTING_PARTICIPANT_DRAW_POSITION_ASSIGNMENT },
|
|
45669
45672
|
stack
|
|
45670
45673
|
});
|
|
45671
45674
|
}
|
|
45675
|
+
if (!participantIds?.length)
|
|
45676
|
+
return { ...SUCCESS, participantIdsRemoved: [] };
|
|
45672
45677
|
const participantIdsRemoved = [];
|
|
45673
45678
|
event.entries = (event.entries || []).filter((entry) => {
|
|
45674
45679
|
const keepEntry = !participantIds.includes(entry?.participantId);
|
|
@@ -45826,7 +45831,6 @@ function addEventEntries(params) {
|
|
|
45826
45831
|
participantIds: ungroupedParticipantIdsToRemove,
|
|
45827
45832
|
autoEntryPositions: false,
|
|
45828
45833
|
// because the method will be called below if necessary
|
|
45829
|
-
tournamentRecord,
|
|
45830
45834
|
event
|
|
45831
45835
|
});
|
|
45832
45836
|
}
|
|
@@ -46083,8 +46087,6 @@ function deleteParticipants(params) {
|
|
|
46083
46087
|
const mappedIndividualParticipantIdsToAdd = {};
|
|
46084
46088
|
for (const event of tournamentRecord.events || []) {
|
|
46085
46089
|
const result = removeEventEntries({
|
|
46086
|
-
tournamentParticipants,
|
|
46087
|
-
tournamentRecord,
|
|
46088
46090
|
participantIds,
|
|
46089
46091
|
event
|
|
46090
46092
|
});
|
|
@@ -46225,7 +46227,6 @@ function destroyGroupEntry({
|
|
|
46225
46227
|
);
|
|
46226
46228
|
let result = removeEventEntries({
|
|
46227
46229
|
participantIds: [participantId],
|
|
46228
|
-
tournamentRecord,
|
|
46229
46230
|
event
|
|
46230
46231
|
});
|
|
46231
46232
|
if (result.error)
|