tods-competition-factory 1.8.4 → 1.8.6
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 +32 -25
- package/dist/forge/generate.mjs.map +1 -1
- package/dist/forge/query.d.ts +2 -1
- package/dist/forge/query.mjs +30 -23
- package/dist/forge/query.mjs.map +1 -1
- package/dist/forge/transform.mjs +49 -44
- package/dist/forge/transform.mjs.map +1 -1
- package/dist/index.mjs +443 -438
- package/dist/index.mjs.map +1 -1
- package/dist/tods-competition-factory.development.cjs.js +633 -630
- 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/forge/generate.mjs
CHANGED
|
@@ -2788,7 +2788,7 @@ function parse(matchUpFormatCode) {
|
|
|
2788
2788
|
setFormat,
|
|
2789
2789
|
bestOf: 1
|
|
2790
2790
|
};
|
|
2791
|
-
if (
|
|
2791
|
+
if (setFormat)
|
|
2792
2792
|
return parsedFormat;
|
|
2793
2793
|
}
|
|
2794
2794
|
if (type === SET)
|
|
@@ -2798,16 +2798,23 @@ function parse(matchUpFormatCode) {
|
|
|
2798
2798
|
}
|
|
2799
2799
|
function setsMatch(formatstring) {
|
|
2800
2800
|
const parts = formatstring.split("-");
|
|
2801
|
-
const
|
|
2801
|
+
const setsCount = getNumber$1(parts[0].slice(3));
|
|
2802
|
+
const bestOf = setsCount === 1 || setsCount % 2 !== 0 ? setsCount : void 0;
|
|
2803
|
+
const exactly = setsCount !== 1 && setsCount % 2 === 0 ? setsCount : void 0;
|
|
2802
2804
|
const setFormat = parts && parseSetFormat(parts[1]);
|
|
2803
2805
|
const finalSetFormat = parts && parseSetFormat(parts[2]);
|
|
2804
|
-
const
|
|
2806
|
+
const timed = setFormat && setFormat.timed || finalSetFormat && finalSetFormat.timed;
|
|
2807
|
+
const validSetsCount = bestOf && bestOf < 6 || timed && exactly;
|
|
2805
2808
|
const validFinalSet = !parts[2] || finalSetFormat;
|
|
2806
2809
|
const validSetsFormat = setFormat;
|
|
2807
|
-
const result = {
|
|
2810
|
+
const result = definedAttributes({
|
|
2811
|
+
setFormat,
|
|
2812
|
+
exactly,
|
|
2813
|
+
bestOf
|
|
2814
|
+
});
|
|
2808
2815
|
if (finalSetFormat)
|
|
2809
2816
|
result.finalSetFormat = finalSetFormat;
|
|
2810
|
-
if (
|
|
2817
|
+
if (validSetsCount && validSetsFormat && validFinalSet)
|
|
2811
2818
|
return result;
|
|
2812
2819
|
}
|
|
2813
2820
|
function parseSetFormat(formatstring) {
|
|
@@ -3922,10 +3929,10 @@ function getOrderedDrawPositions({
|
|
|
3922
3929
|
const pairedDrawPositions = targetRoundProfile?.pairedDrawPositions;
|
|
3923
3930
|
const displayOrder = pairedDrawPositions?.find(
|
|
3924
3931
|
(pair) => overlap(pair || [], drawPositions.filter(Boolean))
|
|
3925
|
-
)
|
|
3932
|
+
) ?? unassignedDrawPositions;
|
|
3926
3933
|
const isFeedRound = targetRoundProfile?.feedRound;
|
|
3927
3934
|
if (allNumeric$1(drawPositions)) {
|
|
3928
|
-
const orderedDrawPositions = drawPositions.sort(numericSort);
|
|
3935
|
+
const orderedDrawPositions = [...drawPositions].sort(numericSort);
|
|
3929
3936
|
return {
|
|
3930
3937
|
orderedDrawPositions: orderedDrawPositions.length === 2 ? orderedDrawPositions : displayOrder,
|
|
3931
3938
|
displayOrder: isFeedRound ? orderedDrawPositions : displayOrder
|
|
@@ -4648,7 +4655,7 @@ function getAllStructureMatchUps({
|
|
|
4648
4655
|
matchUp,
|
|
4649
4656
|
event: event2
|
|
4650
4657
|
}) {
|
|
4651
|
-
additionalContext = additionalContext
|
|
4658
|
+
additionalContext = additionalContext ?? {};
|
|
4652
4659
|
const tieFormat = resolveTieFormat({
|
|
4653
4660
|
drawDefinition,
|
|
4654
4661
|
structure,
|
|
@@ -4659,7 +4666,7 @@ function getAllStructureMatchUps({
|
|
|
4659
4666
|
const collectionDefinition = matchUp.collectionId && collectionDefinitions?.find(
|
|
4660
4667
|
(definition) => definition.collectionId === matchUp.collectionId
|
|
4661
4668
|
);
|
|
4662
|
-
const matchUpFormat = matchUp.collectionId ? collectionDefinition?.matchUpFormat : matchUp.matchUpFormat
|
|
4669
|
+
const matchUpFormat = matchUp.collectionId ? collectionDefinition?.matchUpFormat : matchUp.matchUpFormat ?? structure?.matchUpFormat ?? drawDefinition?.matchUpFormat ?? event2?.matchUpFormat;
|
|
4663
4670
|
const matchUpType = matchUp.matchUpType || collectionDefinition?.matchUpType || structure?.matchUpType || drawDefinition?.matchUpType || event2?.eventType !== TEAM$1 && event2?.eventType;
|
|
4664
4671
|
const matchUpStatus = isCollectionBye ? BYE : matchUp.matchUpStatus;
|
|
4665
4672
|
const { schedule, endDate } = getMatchUpScheduleDetails({
|
|
@@ -4674,7 +4681,7 @@ function getAllStructureMatchUps({
|
|
|
4674
4681
|
});
|
|
4675
4682
|
const drawPositions = tieDrawPositions ?? matchUp.drawPositions ?? [];
|
|
4676
4683
|
const { collectionPosition, collectionId, roundPosition } = matchUp;
|
|
4677
|
-
const roundNumber = matchUp.roundNumber
|
|
4684
|
+
const roundNumber = matchUp.roundNumber ?? additionalContext.roundNumber;
|
|
4678
4685
|
const drawPositionCollectionAssignment = collectionId ? getDrawPositionCollectionAssignment({
|
|
4679
4686
|
tournamentParticipants,
|
|
4680
4687
|
positionAssignments,
|
|
@@ -4700,7 +4707,7 @@ function getAllStructureMatchUps({
|
|
|
4700
4707
|
} : context?.category;
|
|
4701
4708
|
const processCodes = matchUp.processCodes?.length && matchUp.processCodes || collectionDefinition?.processCodes?.length && collectionDefinition?.processCodes || structure?.processCodes?.length && structure?.processCodes || drawDefinition?.processCodes?.length && drawDefinition?.processCodes || event2?.processCodes?.length && event2?.processCodes || tournamentRecord?.processCodes;
|
|
4702
4709
|
const competitiveProfile = contextProfile?.withCompetitiveness && getMatchUpCompetitiveProfile({ ...contextContent, matchUp });
|
|
4703
|
-
const finishingPositionRange = matchUp.finishingPositionRange
|
|
4710
|
+
const finishingPositionRange = matchUp.finishingPositionRange ?? additionalContext.finishingPositionRange;
|
|
4704
4711
|
const onlyDefined = (obj) => definedAttributes(obj, void 0, true);
|
|
4705
4712
|
const matchUpWithContext = {
|
|
4706
4713
|
...onlyDefined(context),
|
|
@@ -4708,7 +4715,7 @@ function getAllStructureMatchUps({
|
|
|
4708
4715
|
matchUpFormat: matchUp.matchUpType === TEAM$1 ? void 0 : matchUpFormat,
|
|
4709
4716
|
tieFormat: matchUp.matchUpType !== TEAM$1 ? void 0 : tieFormat,
|
|
4710
4717
|
roundOfPlay: stage !== QUALIFYING && isConvertableInteger(initialRoundOfPlay2) && initialRoundOfPlay2 + (roundNumber || 0),
|
|
4711
|
-
endDate: matchUp.endDate
|
|
4718
|
+
endDate: matchUp.endDate ?? endDate,
|
|
4712
4719
|
gender: collectionDefinition?.gender,
|
|
4713
4720
|
discipline: event2?.discipline,
|
|
4714
4721
|
category: matchUpCategory,
|
|
@@ -5028,7 +5035,7 @@ function getRoundRobinGroupMatchUps({ drawPositions }) {
|
|
|
5028
5035
|
return { groupMatchUps, uniqueMatchUpGroupings };
|
|
5029
5036
|
}
|
|
5030
5037
|
function drawPositionsHash(drawPositions) {
|
|
5031
|
-
return drawPositions.sort(numericSort).join("|");
|
|
5038
|
+
return [...drawPositions].sort(numericSort).join("|");
|
|
5032
5039
|
}
|
|
5033
5040
|
function groupRounds({ groupSize, drawPositionOffset }) {
|
|
5034
5041
|
const numArr = (count) => [...Array(count)].map((_, i) => i);
|
|
@@ -5054,7 +5061,7 @@ function groupRounds({ groupSize, drawPositionOffset }) {
|
|
|
5054
5061
|
aRow = [aHead, bUp, ...aRow].filter(Boolean);
|
|
5055
5062
|
bRow = [...bRow, aDown].filter(Boolean);
|
|
5056
5063
|
const sum = (x) => x[0].reduce((a, b) => a + b);
|
|
5057
|
-
return rounds.reverse().sort((a, b) => sum(a) - sum(b)).map(
|
|
5064
|
+
return [...rounds].reverse().sort((a, b) => sum(a) - sum(b)).map(
|
|
5058
5065
|
(round) => round.filter(
|
|
5059
5066
|
(groupPositions2) => groupPositions2.every((position) => position <= groupSize)
|
|
5060
5067
|
).map((groupPositions2) => {
|
|
@@ -8139,10 +8146,10 @@ function addUpcomingMatchUps({ drawDefinition, inContextDrawMatchUps }) {
|
|
|
8139
8146
|
if (structure?.finishingPosition === WIN_RATIO) {
|
|
8140
8147
|
const { roundNumber } = inContextMatchUp;
|
|
8141
8148
|
const nextRoundNumber = roundNumber && ensureInt(roundNumber) + 1;
|
|
8142
|
-
const matchUps = structure.matchUps
|
|
8149
|
+
const matchUps = structure.matchUps ?? [];
|
|
8143
8150
|
const { roundMatchUps } = getRoundMatchUps({ matchUps });
|
|
8144
8151
|
if (nextRoundNumber && roundMatchUps?.[nextRoundNumber]) {
|
|
8145
|
-
const sidesTo = drawPositions.sort().map((drawPosition, index) => {
|
|
8152
|
+
const sidesTo = [...drawPositions].sort(numericSort).map((drawPosition, index) => {
|
|
8146
8153
|
const nextRoundMatchUp = roundMatchUps[nextRoundNumber].find(
|
|
8147
8154
|
(matchUp) => matchUp.drawPositions?.includes(drawPosition)
|
|
8148
8155
|
);
|
|
@@ -16409,9 +16416,7 @@ function categoryCanContain({
|
|
|
16409
16416
|
function stringify(matchUpFormatObject, preserveRedundant) {
|
|
16410
16417
|
if (typeof matchUpFormatObject !== "object")
|
|
16411
16418
|
return;
|
|
16412
|
-
if (matchUpFormatObject.
|
|
16413
|
-
return timedSetFormat(matchUpFormatObject);
|
|
16414
|
-
if (matchUpFormatObject.bestOf && matchUpFormatObject.setFormat)
|
|
16419
|
+
if ((matchUpFormatObject.bestOf || matchUpFormatObject.exactly) && matchUpFormatObject.setFormat)
|
|
16415
16420
|
return getSetFormat(matchUpFormatObject, preserveRedundant);
|
|
16416
16421
|
return void 0;
|
|
16417
16422
|
}
|
|
@@ -16427,11 +16432,13 @@ function timedSetFormat(matchUpFormatObject) {
|
|
|
16427
16432
|
return value;
|
|
16428
16433
|
}
|
|
16429
16434
|
function getSetFormat(matchUpFormatObject, preserveRedundant) {
|
|
16430
|
-
const bestOfValue = getNumber(matchUpFormatObject.bestOf);
|
|
16431
|
-
|
|
16435
|
+
const bestOfValue = getNumber(matchUpFormatObject.bestOf) || void 0;
|
|
16436
|
+
const exactly = getNumber(matchUpFormatObject.exactly) || void 0;
|
|
16437
|
+
const setLimit = bestOfValue || exactly;
|
|
16438
|
+
if (matchUpFormatObject.setFormat?.timed && matchUpFormatObject.simplified && setLimit === 1) {
|
|
16432
16439
|
return timedSetFormat(matchUpFormatObject.setFormat);
|
|
16433
16440
|
}
|
|
16434
|
-
const
|
|
16441
|
+
const setLimitCode = setLimit && `${SET}${setLimit}` || "";
|
|
16435
16442
|
const setCountValue = stringifySet(
|
|
16436
16443
|
matchUpFormatObject.setFormat,
|
|
16437
16444
|
preserveRedundant
|
|
@@ -16441,11 +16448,11 @@ function getSetFormat(matchUpFormatObject, preserveRedundant) {
|
|
|
16441
16448
|
matchUpFormatObject.finalSetFormat,
|
|
16442
16449
|
preserveRedundant
|
|
16443
16450
|
);
|
|
16444
|
-
const finalSetCode =
|
|
16451
|
+
const finalSetCode = setLimit && setLimit > 1 && finalSetCountValue && setCountValue !== finalSetCountValue && // don't include final set code if equivalent to other sets
|
|
16445
16452
|
`F:${finalSetCountValue}` || "";
|
|
16446
|
-
const valid =
|
|
16453
|
+
const valid = setLimitCode && setCountValue;
|
|
16447
16454
|
if (valid) {
|
|
16448
|
-
return [
|
|
16455
|
+
return [setLimitCode, setCode, finalSetCode].filter((f) => f).join("-");
|
|
16449
16456
|
}
|
|
16450
16457
|
return void 0;
|
|
16451
16458
|
}
|