tods-competition-factory 1.7.9 → 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 +29 -21
- 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/forge/transform.mjs +14 -10
- package/dist/forge/transform.mjs.map +1 -1
- package/dist/index.mjs +68 -65
- package/dist/index.mjs.map +1 -1
- package/dist/tods-competition-factory.development.cjs.js +82 -71
- 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) {
|
|
@@ -3972,20 +3972,20 @@ function evaluateCollectionResult({
|
|
|
3972
3972
|
if (matchUp.winningSide)
|
|
3973
3973
|
sideWins[matchUp.winningSide - 1] += 1;
|
|
3974
3974
|
});
|
|
3975
|
-
if (matchUpValue) {
|
|
3975
|
+
if (isConvertableInteger(matchUpValue)) {
|
|
3976
3976
|
collectionMatchUps.forEach((matchUp) => {
|
|
3977
3977
|
if (matchUp.winningSide) {
|
|
3978
3978
|
sideMatchUpValues[matchUp.winningSide - 1] += matchUpValue;
|
|
3979
3979
|
}
|
|
3980
3980
|
});
|
|
3981
|
-
} else if (setValue) {
|
|
3981
|
+
} else if (isConvertableInteger(setValue)) {
|
|
3982
3982
|
collectionMatchUps.forEach((matchUp) => {
|
|
3983
3983
|
matchUp.score?.sets?.forEach((set) => {
|
|
3984
3984
|
if (set.winningSide)
|
|
3985
3985
|
sideMatchUpValues[set.winningSide - 1] += setValue;
|
|
3986
3986
|
});
|
|
3987
3987
|
});
|
|
3988
|
-
} else if (scoreValue) {
|
|
3988
|
+
} else if (isConvertableInteger(scoreValue)) {
|
|
3989
3989
|
collectionMatchUps.forEach((matchUp) => {
|
|
3990
3990
|
matchUp.score?.sets?.forEach((set) => {
|
|
3991
3991
|
const {
|
|
@@ -4012,15 +4012,17 @@ function evaluateCollectionResult({
|
|
|
4012
4012
|
collectionDefinition,
|
|
4013
4013
|
collectionPosition
|
|
4014
4014
|
});
|
|
4015
|
-
|
|
4015
|
+
if (isConvertableInteger(matchUpValue2)) {
|
|
4016
|
+
sideMatchUpValues[matchUp.winningSide - 1] += matchUpValue2;
|
|
4017
|
+
}
|
|
4016
4018
|
}
|
|
4017
4019
|
});
|
|
4018
4020
|
}
|
|
4019
|
-
if (collectionValue) {
|
|
4021
|
+
if (isConvertableInteger(collectionValue)) {
|
|
4020
4022
|
let collectionWinningSide;
|
|
4021
4023
|
if (winCriteria?.aggregateValue) {
|
|
4022
4024
|
if (allCollectionMatchUpsCompleted) {
|
|
4023
|
-
if ((matchUpValue || setValue || scoreValue) && sideMatchUpValues[0] !== sideMatchUpValues[1]) {
|
|
4025
|
+
if (isConvertableInteger(matchUpValue || setValue || scoreValue) && sideMatchUpValues[0] !== sideMatchUpValues[1]) {
|
|
4024
4026
|
collectionWinningSide = sideMatchUpValues[0] > sideMatchUpValues[1] ? 1 : 2;
|
|
4025
4027
|
} else if (sideWins[0] !== sideWins[1]) {
|
|
4026
4028
|
collectionWinningSide = sideWins[0] > sideWins[1] ? 1 : 2;
|
|
@@ -4056,7 +4058,7 @@ function evaluateCollectionResult({
|
|
|
4056
4058
|
}
|
|
4057
4059
|
if (!belongsToValueGroup) {
|
|
4058
4060
|
sideCollectionValues.forEach(
|
|
4059
|
-
(sideCollectionValue, i) => sideTieValues[i] += sideCollectionValue
|
|
4061
|
+
(sideCollectionValue, i) => sideTieValues[i] += sideCollectionValue || 0
|
|
4060
4062
|
);
|
|
4061
4063
|
} else {
|
|
4062
4064
|
groupValueGroups[collectionGroupNumber].sideWins[0] += sideWins[0] || 0;
|
|
@@ -8372,7 +8374,9 @@ function getGroupValueGroups({
|
|
|
8372
8374
|
}) {
|
|
8373
8375
|
const groupValueGroups = Object.assign(
|
|
8374
8376
|
{},
|
|
8375
|
-
...collectionGroups.filter(
|
|
8377
|
+
...collectionGroups.filter(
|
|
8378
|
+
(group) => isConvertableInteger(group?.groupValue) && group?.groupNumber
|
|
8379
|
+
).map((group) => ({
|
|
8376
8380
|
[group.groupNumber]: {
|
|
8377
8381
|
...group,
|
|
8378
8382
|
allGroupMatchUpsCompleted: true,
|
|
@@ -8449,11 +8453,11 @@ function generateTieMatchUpScore(params) {
|
|
|
8449
8453
|
}, void 0);
|
|
8450
8454
|
}
|
|
8451
8455
|
if (groupWinningSide) {
|
|
8452
|
-
sideTieValues[groupWinningSide - 1] += groupValue;
|
|
8456
|
+
sideTieValues[groupWinningSide - 1] += groupValue || 0;
|
|
8453
8457
|
}
|
|
8454
8458
|
}
|
|
8455
8459
|
const sideScores = sideTieValues.map(
|
|
8456
|
-
(sideTieValue, i) => sideTieValue + sideAdjustments[i]
|
|
8460
|
+
(sideTieValue, i) => (sideTieValue || 0) + sideAdjustments[i]
|
|
8457
8461
|
);
|
|
8458
8462
|
const set = {
|
|
8459
8463
|
side1Score: sideScores[0],
|
|
@@ -15120,20 +15124,18 @@ function calculateWinCriteria({
|
|
|
15120
15124
|
setValue
|
|
15121
15125
|
} = collectionDefinition;
|
|
15122
15126
|
const belongsToValueGroup = collectionGroupNumber && groupValueNumbers.includes(collectionGroupNumber);
|
|
15123
|
-
if (setValue || scoreValue) {
|
|
15127
|
+
if (isConvertableInteger(setValue || scoreValue)) {
|
|
15124
15128
|
aggregateValueImperative = true;
|
|
15125
15129
|
} else if (belongsToValueGroup) {
|
|
15126
15130
|
continue;
|
|
15127
|
-
} else if (collectionValue) {
|
|
15131
|
+
} else if (typeof collectionValue === "number" && isConvertableInteger(collectionValue)) {
|
|
15128
15132
|
valueTotal += collectionValue;
|
|
15129
15133
|
} else if (collectionValueProfiles?.length) {
|
|
15130
15134
|
for (const collectionValueProfile of collectionValueProfiles) {
|
|
15131
15135
|
valueTotal += collectionValueProfile.matchUpValue;
|
|
15132
15136
|
}
|
|
15133
|
-
} else if (matchUpValue) {
|
|
15137
|
+
} else if (typeof matchUpValue === "number" && isConvertableInteger(matchUpValue)) {
|
|
15134
15138
|
valueTotal += (matchUpCount || 0) * matchUpValue;
|
|
15135
|
-
} else {
|
|
15136
|
-
valueTotal += matchUpCount || 0;
|
|
15137
15139
|
}
|
|
15138
15140
|
}
|
|
15139
15141
|
for (const collectionGroup of collectionGroups) {
|
|
@@ -44422,6 +44424,16 @@ function generateAdHocMatchUps$1({
|
|
|
44422
44424
|
);
|
|
44423
44425
|
if (!structure)
|
|
44424
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
|
+
);
|
|
44425
44437
|
if (!matchUpsCount) {
|
|
44426
44438
|
const selectedEntries = drawDefinition?.entries?.filter((entry) => {
|
|
44427
44439
|
const entryStatus = entry.entryStatus;
|
|
@@ -44431,7 +44443,11 @@ function generateAdHocMatchUps$1({
|
|
|
44431
44443
|
if (newRound) {
|
|
44432
44444
|
matchUpsCount = roundMatchUpsCount;
|
|
44433
44445
|
} else {
|
|
44434
|
-
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;
|
|
44435
44451
|
if (maxRemaining > 0)
|
|
44436
44452
|
matchUpsCount = maxRemaining;
|
|
44437
44453
|
}
|
|
@@ -44439,16 +44455,6 @@ function generateAdHocMatchUps$1({
|
|
|
44439
44455
|
if (participantIdPairings && !Array.isArray(participantIdPairings) || matchUpsCount && !isConvertableInteger(matchUpsCount) || matchUpIds && !Array.isArray(matchUpIds) || !participantIdPairings && !matchUpsCount) {
|
|
44440
44456
|
return { error: INVALID_VALUES, info: "matchUpsCount or pairings error" };
|
|
44441
44457
|
}
|
|
44442
|
-
let structureHasRoundPositions;
|
|
44443
|
-
const existingMatchUps = structure.matchUps ?? [];
|
|
44444
|
-
const lastRoundNumber = existingMatchUps?.reduce(
|
|
44445
|
-
(roundNumber2, matchUp) => {
|
|
44446
|
-
if (matchUp.roundPosition)
|
|
44447
|
-
structureHasRoundPositions = true;
|
|
44448
|
-
return (matchUp?.roundNumber || 0) > roundNumber2 ? matchUp.roundNumber : roundNumber2;
|
|
44449
|
-
},
|
|
44450
|
-
0
|
|
44451
|
-
);
|
|
44452
44458
|
if (structure.structures || structureHasRoundPositions || structure.finishingPosition === ROUND_OUTCOME) {
|
|
44453
44459
|
return { error: INVALID_STRUCTURE };
|
|
44454
44460
|
}
|
|
@@ -45079,9 +45085,12 @@ function setPositionAssignments$1({
|
|
|
45079
45085
|
return { ...SUCCESS };
|
|
45080
45086
|
}
|
|
45081
45087
|
|
|
45082
|
-
function getAssignedParticipantIds({
|
|
45088
|
+
function getAssignedParticipantIds({
|
|
45089
|
+
drawDefinition,
|
|
45090
|
+
stages
|
|
45091
|
+
}) {
|
|
45083
45092
|
const stageStructures = (drawDefinition?.structures || []).filter(
|
|
45084
|
-
(structure) => !stages?.length || stages.includes(structure.stage)
|
|
45093
|
+
(structure) => !stages?.length || structure.stage && stages.includes(structure.stage)
|
|
45085
45094
|
);
|
|
45086
45095
|
return stageStructures.map((structure) => {
|
|
45087
45096
|
const { positionAssignments } = getPositionAssignments$1({
|
|
@@ -45624,49 +45633,47 @@ function participantInFlightEntries({
|
|
|
45624
45633
|
|
|
45625
45634
|
function removeEventEntries({
|
|
45626
45635
|
autoEntryPositions = true,
|
|
45627
|
-
|
|
45628
|
-
|
|
45629
|
-
|
|
45636
|
+
participantIds = [],
|
|
45637
|
+
entryStatuses,
|
|
45638
|
+
stage,
|
|
45630
45639
|
event
|
|
45631
45640
|
}) {
|
|
45632
45641
|
const stack = "removeEventEntries";
|
|
45633
45642
|
if (!event?.eventId)
|
|
45634
45643
|
return { error: MISSING_EVENT };
|
|
45635
|
-
if (!Array.isArray(participantIds))
|
|
45636
|
-
return decorateResult({
|
|
45637
|
-
result: { error: MISSING_PARTICIPANT_IDS },
|
|
45638
|
-
stack
|
|
45639
|
-
});
|
|
45640
|
-
participantIds = participantIds?.filter(Boolean);
|
|
45641
|
-
if (!participantIds?.length)
|
|
45642
|
-
return decorateResult({
|
|
45643
|
-
result: { error: MISSING_PARTICIPANT_IDS },
|
|
45644
|
-
stack
|
|
45645
|
-
});
|
|
45646
|
-
const { eventId } = event;
|
|
45647
|
-
if (!tournamentParticipants) {
|
|
45648
|
-
tournamentParticipants = getTournamentParticipants({
|
|
45649
|
-
participantFilters: { participantIds },
|
|
45650
|
-
tournamentRecord,
|
|
45651
|
-
withEvents: true,
|
|
45652
|
-
withDraws: true
|
|
45653
|
-
}).tournamentParticipants;
|
|
45644
|
+
if (!Array.isArray(participantIds) || participantIds.some((participantId) => !isString(participantId))) {
|
|
45645
|
+
return decorateResult({ result: { error: INVALID_PARTICIPANT_ID }, stack });
|
|
45654
45646
|
}
|
|
45655
|
-
const
|
|
45656
|
-
|
|
45657
|
-
|
|
45658
|
-
|
|
45659
|
-
|
|
45660
|
-
|
|
45661
|
-
|
|
45662
|
-
).
|
|
45663
|
-
|
|
45664
|
-
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
|
+
)) {
|
|
45665
45670
|
return decorateResult({
|
|
45666
45671
|
result: { error: EXISTING_PARTICIPANT_DRAW_POSITION_ASSIGNMENT },
|
|
45667
45672
|
stack
|
|
45668
45673
|
});
|
|
45669
45674
|
}
|
|
45675
|
+
if (!participantIds?.length)
|
|
45676
|
+
return { ...SUCCESS, participantIdsRemoved: [] };
|
|
45670
45677
|
const participantIdsRemoved = [];
|
|
45671
45678
|
event.entries = (event.entries || []).filter((entry) => {
|
|
45672
45679
|
const keepEntry = !participantIds.includes(entry?.participantId);
|
|
@@ -45824,7 +45831,6 @@ function addEventEntries(params) {
|
|
|
45824
45831
|
participantIds: ungroupedParticipantIdsToRemove,
|
|
45825
45832
|
autoEntryPositions: false,
|
|
45826
45833
|
// because the method will be called below if necessary
|
|
45827
|
-
tournamentRecord,
|
|
45828
45834
|
event
|
|
45829
45835
|
});
|
|
45830
45836
|
}
|
|
@@ -46081,8 +46087,6 @@ function deleteParticipants(params) {
|
|
|
46081
46087
|
const mappedIndividualParticipantIdsToAdd = {};
|
|
46082
46088
|
for (const event of tournamentRecord.events || []) {
|
|
46083
46089
|
const result = removeEventEntries({
|
|
46084
|
-
tournamentParticipants,
|
|
46085
|
-
tournamentRecord,
|
|
46086
46090
|
participantIds,
|
|
46087
46091
|
event
|
|
46088
46092
|
});
|
|
@@ -46223,7 +46227,6 @@ function destroyGroupEntry({
|
|
|
46223
46227
|
);
|
|
46224
46228
|
let result = removeEventEntries({
|
|
46225
46229
|
participantIds: [participantId],
|
|
46226
|
-
tournamentRecord,
|
|
46227
46230
|
event
|
|
46228
46231
|
});
|
|
46229
46232
|
if (result.error)
|