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/transform.mjs
CHANGED
|
@@ -1648,9 +1648,7 @@ const setTypes = {
|
|
|
1648
1648
|
function stringify(matchUpFormatObject, preserveRedundant) {
|
|
1649
1649
|
if (typeof matchUpFormatObject !== "object")
|
|
1650
1650
|
return;
|
|
1651
|
-
if (matchUpFormatObject.
|
|
1652
|
-
return timedSetFormat(matchUpFormatObject);
|
|
1653
|
-
if (matchUpFormatObject.bestOf && matchUpFormatObject.setFormat)
|
|
1651
|
+
if ((matchUpFormatObject.bestOf || matchUpFormatObject.exactly) && matchUpFormatObject.setFormat)
|
|
1654
1652
|
return getSetFormat(matchUpFormatObject, preserveRedundant);
|
|
1655
1653
|
return void 0;
|
|
1656
1654
|
}
|
|
@@ -1666,11 +1664,13 @@ function timedSetFormat(matchUpFormatObject) {
|
|
|
1666
1664
|
return value;
|
|
1667
1665
|
}
|
|
1668
1666
|
function getSetFormat(matchUpFormatObject, preserveRedundant) {
|
|
1669
|
-
const bestOfValue = getNumber$1(matchUpFormatObject.bestOf);
|
|
1670
|
-
|
|
1667
|
+
const bestOfValue = getNumber$1(matchUpFormatObject.bestOf) || void 0;
|
|
1668
|
+
const exactly = getNumber$1(matchUpFormatObject.exactly) || void 0;
|
|
1669
|
+
const setLimit = bestOfValue || exactly;
|
|
1670
|
+
if (matchUpFormatObject.setFormat?.timed && matchUpFormatObject.simplified && setLimit === 1) {
|
|
1671
1671
|
return timedSetFormat(matchUpFormatObject.setFormat);
|
|
1672
1672
|
}
|
|
1673
|
-
const
|
|
1673
|
+
const setLimitCode = setLimit && `${SET}${setLimit}` || "";
|
|
1674
1674
|
const setCountValue = stringifySet(
|
|
1675
1675
|
matchUpFormatObject.setFormat,
|
|
1676
1676
|
preserveRedundant
|
|
@@ -1680,11 +1680,11 @@ function getSetFormat(matchUpFormatObject, preserveRedundant) {
|
|
|
1680
1680
|
matchUpFormatObject.finalSetFormat,
|
|
1681
1681
|
preserveRedundant
|
|
1682
1682
|
);
|
|
1683
|
-
const finalSetCode =
|
|
1683
|
+
const finalSetCode = setLimit && setLimit > 1 && finalSetCountValue && setCountValue !== finalSetCountValue && // don't include final set code if equivalent to other sets
|
|
1684
1684
|
`F:${finalSetCountValue}` || "";
|
|
1685
|
-
const valid =
|
|
1685
|
+
const valid = setLimitCode && setCountValue;
|
|
1686
1686
|
if (valid) {
|
|
1687
|
-
return [
|
|
1687
|
+
return [setLimitCode, setCode, finalSetCode].filter((f) => f).join("-");
|
|
1688
1688
|
}
|
|
1689
1689
|
return void 0;
|
|
1690
1690
|
}
|
|
@@ -1734,7 +1734,7 @@ function parse(matchUpFormatCode) {
|
|
|
1734
1734
|
setFormat,
|
|
1735
1735
|
bestOf: 1
|
|
1736
1736
|
};
|
|
1737
|
-
if (
|
|
1737
|
+
if (setFormat)
|
|
1738
1738
|
return parsedFormat;
|
|
1739
1739
|
}
|
|
1740
1740
|
if (type === SET)
|
|
@@ -1744,16 +1744,23 @@ function parse(matchUpFormatCode) {
|
|
|
1744
1744
|
}
|
|
1745
1745
|
function setsMatch(formatstring) {
|
|
1746
1746
|
const parts = formatstring.split("-");
|
|
1747
|
-
const
|
|
1747
|
+
const setsCount = getNumber(parts[0].slice(3));
|
|
1748
|
+
const bestOf = setsCount === 1 || setsCount % 2 !== 0 ? setsCount : void 0;
|
|
1749
|
+
const exactly = setsCount !== 1 && setsCount % 2 === 0 ? setsCount : void 0;
|
|
1748
1750
|
const setFormat = parts && parseSetFormat(parts[1]);
|
|
1749
1751
|
const finalSetFormat = parts && parseSetFormat(parts[2]);
|
|
1750
|
-
const
|
|
1752
|
+
const timed = setFormat && setFormat.timed || finalSetFormat && finalSetFormat.timed;
|
|
1753
|
+
const validSetsCount = bestOf && bestOf < 6 || timed && exactly;
|
|
1751
1754
|
const validFinalSet = !parts[2] || finalSetFormat;
|
|
1752
1755
|
const validSetsFormat = setFormat;
|
|
1753
|
-
const result = {
|
|
1756
|
+
const result = definedAttributes({
|
|
1757
|
+
setFormat,
|
|
1758
|
+
exactly,
|
|
1759
|
+
bestOf
|
|
1760
|
+
});
|
|
1754
1761
|
if (finalSetFormat)
|
|
1755
1762
|
result.finalSetFormat = finalSetFormat;
|
|
1756
|
-
if (
|
|
1763
|
+
if (validSetsCount && validSetsFormat && validFinalSet)
|
|
1757
1764
|
return result;
|
|
1758
1765
|
}
|
|
1759
1766
|
function parseSetFormat(formatstring) {
|
|
@@ -5482,10 +5489,10 @@ function getOrderedDrawPositions({
|
|
|
5482
5489
|
const pairedDrawPositions = targetRoundProfile?.pairedDrawPositions;
|
|
5483
5490
|
const displayOrder = pairedDrawPositions?.find(
|
|
5484
5491
|
(pair) => overlap(pair || [], drawPositions.filter(Boolean))
|
|
5485
|
-
)
|
|
5492
|
+
) ?? unassignedDrawPositions;
|
|
5486
5493
|
const isFeedRound = targetRoundProfile?.feedRound;
|
|
5487
5494
|
if (allNumeric$1(drawPositions)) {
|
|
5488
|
-
const orderedDrawPositions = drawPositions.sort(numericSort);
|
|
5495
|
+
const orderedDrawPositions = [...drawPositions].sort(numericSort);
|
|
5489
5496
|
return {
|
|
5490
5497
|
orderedDrawPositions: orderedDrawPositions.length === 2 ? orderedDrawPositions : displayOrder,
|
|
5491
5498
|
displayOrder: isFeedRound ? orderedDrawPositions : displayOrder
|
|
@@ -6208,7 +6215,7 @@ function getAllStructureMatchUps({
|
|
|
6208
6215
|
matchUp,
|
|
6209
6216
|
event: event2
|
|
6210
6217
|
}) {
|
|
6211
|
-
additionalContext = additionalContext
|
|
6218
|
+
additionalContext = additionalContext ?? {};
|
|
6212
6219
|
const tieFormat = resolveTieFormat({
|
|
6213
6220
|
drawDefinition,
|
|
6214
6221
|
structure,
|
|
@@ -6219,7 +6226,7 @@ function getAllStructureMatchUps({
|
|
|
6219
6226
|
const collectionDefinition = matchUp.collectionId && collectionDefinitions?.find(
|
|
6220
6227
|
(definition) => definition.collectionId === matchUp.collectionId
|
|
6221
6228
|
);
|
|
6222
|
-
const matchUpFormat = matchUp.collectionId ? collectionDefinition?.matchUpFormat : matchUp.matchUpFormat
|
|
6229
|
+
const matchUpFormat = matchUp.collectionId ? collectionDefinition?.matchUpFormat : matchUp.matchUpFormat ?? structure?.matchUpFormat ?? drawDefinition?.matchUpFormat ?? event2?.matchUpFormat;
|
|
6223
6230
|
const matchUpType = matchUp.matchUpType || collectionDefinition?.matchUpType || structure?.matchUpType || drawDefinition?.matchUpType || event2?.eventType !== TEAM$1 && event2?.eventType;
|
|
6224
6231
|
const matchUpStatus = isCollectionBye ? BYE : matchUp.matchUpStatus;
|
|
6225
6232
|
const { schedule, endDate } = getMatchUpScheduleDetails({
|
|
@@ -6234,7 +6241,7 @@ function getAllStructureMatchUps({
|
|
|
6234
6241
|
});
|
|
6235
6242
|
const drawPositions = tieDrawPositions ?? matchUp.drawPositions ?? [];
|
|
6236
6243
|
const { collectionPosition, collectionId, roundPosition } = matchUp;
|
|
6237
|
-
const roundNumber = matchUp.roundNumber
|
|
6244
|
+
const roundNumber = matchUp.roundNumber ?? additionalContext.roundNumber;
|
|
6238
6245
|
const drawPositionCollectionAssignment = collectionId ? getDrawPositionCollectionAssignment({
|
|
6239
6246
|
tournamentParticipants,
|
|
6240
6247
|
positionAssignments,
|
|
@@ -6260,7 +6267,7 @@ function getAllStructureMatchUps({
|
|
|
6260
6267
|
} : context?.category;
|
|
6261
6268
|
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;
|
|
6262
6269
|
const competitiveProfile = contextProfile?.withCompetitiveness && getMatchUpCompetitiveProfile({ ...contextContent, matchUp });
|
|
6263
|
-
const finishingPositionRange = matchUp.finishingPositionRange
|
|
6270
|
+
const finishingPositionRange = matchUp.finishingPositionRange ?? additionalContext.finishingPositionRange;
|
|
6264
6271
|
const onlyDefined = (obj) => definedAttributes(obj, void 0, true);
|
|
6265
6272
|
const matchUpWithContext = {
|
|
6266
6273
|
...onlyDefined(context),
|
|
@@ -6268,7 +6275,7 @@ function getAllStructureMatchUps({
|
|
|
6268
6275
|
matchUpFormat: matchUp.matchUpType === TEAM$1 ? void 0 : matchUpFormat,
|
|
6269
6276
|
tieFormat: matchUp.matchUpType !== TEAM$1 ? void 0 : tieFormat,
|
|
6270
6277
|
roundOfPlay: stage !== QUALIFYING && isConvertableInteger(initialRoundOfPlay2) && initialRoundOfPlay2 + (roundNumber || 0),
|
|
6271
|
-
endDate: matchUp.endDate
|
|
6278
|
+
endDate: matchUp.endDate ?? endDate,
|
|
6272
6279
|
gender: collectionDefinition?.gender,
|
|
6273
6280
|
discipline: event2?.discipline,
|
|
6274
6281
|
category: matchUpCategory,
|
|
@@ -7177,10 +7184,10 @@ function addUpcomingMatchUps({ drawDefinition, inContextDrawMatchUps }) {
|
|
|
7177
7184
|
if (structure?.finishingPosition === WIN_RATIO) {
|
|
7178
7185
|
const { roundNumber } = inContextMatchUp;
|
|
7179
7186
|
const nextRoundNumber = roundNumber && ensureInt(roundNumber) + 1;
|
|
7180
|
-
const matchUps = structure.matchUps
|
|
7187
|
+
const matchUps = structure.matchUps ?? [];
|
|
7181
7188
|
const { roundMatchUps } = getRoundMatchUps({ matchUps });
|
|
7182
7189
|
if (nextRoundNumber && roundMatchUps?.[nextRoundNumber]) {
|
|
7183
|
-
const sidesTo = drawPositions.sort().map((drawPosition, index) => {
|
|
7190
|
+
const sidesTo = [...drawPositions].sort(numericSort).map((drawPosition, index) => {
|
|
7184
7191
|
const nextRoundMatchUp = roundMatchUps[nextRoundNumber].find(
|
|
7185
7192
|
(matchUp) => matchUp.drawPositions?.includes(drawPosition)
|
|
7186
7193
|
);
|
|
@@ -15498,6 +15505,7 @@ function assignMatchUpCourt({
|
|
|
15498
15505
|
}
|
|
15499
15506
|
|
|
15500
15507
|
function addMatchUpScheduledTime$1(params) {
|
|
15508
|
+
const stack = "addMatchUpScheduledTime";
|
|
15501
15509
|
let matchUp = params.matchUp;
|
|
15502
15510
|
const {
|
|
15503
15511
|
removePriorValues,
|
|
@@ -15508,27 +15516,18 @@ function addMatchUpScheduledTime$1(params) {
|
|
|
15508
15516
|
matchUpId
|
|
15509
15517
|
} = params;
|
|
15510
15518
|
if (!matchUpId)
|
|
15511
|
-
return { error: MISSING_MATCHUP_ID };
|
|
15519
|
+
return decorateResult({ result: { error: MISSING_MATCHUP_ID }, stack });
|
|
15512
15520
|
if (!validTimeValue(scheduledTime))
|
|
15513
|
-
return { error: INVALID_TIME };
|
|
15521
|
+
return decorateResult({ result: { error: INVALID_TIME }, stack });
|
|
15514
15522
|
if (!matchUp) {
|
|
15515
15523
|
const result = findMatchUp({ drawDefinition, matchUpId });
|
|
15516
15524
|
if (result.error)
|
|
15517
|
-
return result;
|
|
15525
|
+
return decorateResult({ result, stack });
|
|
15518
15526
|
matchUp = result.matchUp;
|
|
15519
15527
|
}
|
|
15520
15528
|
const timeDate = extractDate(scheduledTime);
|
|
15521
|
-
const
|
|
15522
|
-
|
|
15523
|
-
const scheduledDate = scheduledMatchUpDate({ matchUp }).scheduledDate;
|
|
15524
|
-
if (scheduledDate && scheduledDate !== timeDate) {
|
|
15525
|
-
return decorateResult({
|
|
15526
|
-
info: `date in time: ${timeDate} does not corresponde to scheduledDate: ${scheduledDate}`,
|
|
15527
|
-
result: { error: INVALID_TIME },
|
|
15528
|
-
stack
|
|
15529
|
-
});
|
|
15530
|
-
}
|
|
15531
|
-
}
|
|
15529
|
+
const scheduledDate = scheduledMatchUpDate({ matchUp }).scheduledDate;
|
|
15530
|
+
const keepDate = timeDate && !scheduledDate;
|
|
15532
15531
|
const existingTimeModifiers = matchUpTimeModifiers({ matchUp }).timeModifiers || [];
|
|
15533
15532
|
if (existingTimeModifiers?.length) {
|
|
15534
15533
|
const result = addMatchUpTimeModifiers({
|
|
@@ -15541,9 +15540,9 @@ function addMatchUpScheduledTime$1(params) {
|
|
|
15541
15540
|
matchUp
|
|
15542
15541
|
});
|
|
15543
15542
|
if (result?.error)
|
|
15544
|
-
return result;
|
|
15543
|
+
return decorateResult({ result, stack });
|
|
15545
15544
|
}
|
|
15546
|
-
const militaryTime = convertTime(scheduledTime, true,
|
|
15545
|
+
const militaryTime = convertTime(scheduledTime, true, keepDate);
|
|
15547
15546
|
const itemValue = militaryTime;
|
|
15548
15547
|
const timeItem = {
|
|
15549
15548
|
itemType: SCHEDULED_TIME,
|
|
@@ -15568,14 +15567,19 @@ function addMatchUpTimeModifiers({
|
|
|
15568
15567
|
matchUpId,
|
|
15569
15568
|
matchUp
|
|
15570
15569
|
}) {
|
|
15570
|
+
const stack = "addMatchUpTimeModifiers";
|
|
15571
15571
|
if (!matchUpId)
|
|
15572
|
-
return { error: MISSING_MATCHUP_ID };
|
|
15572
|
+
return decorateResult({ result: { error: MISSING_MATCHUP_ID }, stack });
|
|
15573
15573
|
if (timeModifiers !== void 0 && !Array.isArray(timeModifiers))
|
|
15574
|
-
return {
|
|
15574
|
+
return decorateResult({
|
|
15575
|
+
info: mustBeAnArray("timeModifiers"),
|
|
15576
|
+
result: { error: INVALID_VALUES },
|
|
15577
|
+
stack
|
|
15578
|
+
});
|
|
15575
15579
|
if (!matchUp) {
|
|
15576
15580
|
const result = findMatchUp({ drawDefinition, matchUpId });
|
|
15577
15581
|
if (result.error)
|
|
15578
|
-
return result;
|
|
15582
|
+
return decorateResult({ result, stack });
|
|
15579
15583
|
matchUp = result.matchUp;
|
|
15580
15584
|
}
|
|
15581
15585
|
let existingTimeModifiers = matchUpTimeModifiers({ matchUp }).timeModifiers || [];
|
|
@@ -15600,7 +15604,7 @@ function addMatchUpTimeModifiers({
|
|
|
15600
15604
|
matchUpId
|
|
15601
15605
|
});
|
|
15602
15606
|
if (result.error)
|
|
15603
|
-
return result;
|
|
15607
|
+
return decorateResult({ result, stack });
|
|
15604
15608
|
}
|
|
15605
15609
|
const itemValue = !timeModifiers?.length ? void 0 : [...toBeAdded, ...existingTimeModifiers];
|
|
15606
15610
|
const timeItem = {
|
|
@@ -17141,7 +17145,8 @@ function bulkRescheduleMatchUps$1({
|
|
|
17141
17145
|
scheduledTime,
|
|
17142
17146
|
minutesChange
|
|
17143
17147
|
);
|
|
17144
|
-
|
|
17148
|
+
const timeStringDate = scheduledTimeDate && newScheduledDate || scheduledDate === scheduledTimeDate && scheduledTimeDate;
|
|
17149
|
+
newScheduledTime = timeStringDate ? `${timeStringDate}T${timeString}` : timeString;
|
|
17145
17150
|
}
|
|
17146
17151
|
}
|
|
17147
17152
|
if (doNotReschedule) {
|