tods-competition-factory 1.8.43 → 1.8.45
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 +47 -23
- package/dist/forge/generate.mjs.map +1 -1
- package/dist/forge/query.d.ts +12 -11
- package/dist/forge/query.mjs +3 -3
- package/dist/forge/query.mjs.map +1 -1
- package/dist/forge/transform.mjs +32 -21
- package/dist/forge/transform.mjs.map +1 -1
- package/dist/index.mjs +134 -98
- package/dist/index.mjs.map +1 -1
- package/dist/tods-competition-factory.development.cjs.js +163 -145
- 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 +6 -6
package/dist/forge/transform.mjs
CHANGED
|
@@ -1423,6 +1423,14 @@ function removeTournamentExtension(params) {
|
|
|
1423
1423
|
});
|
|
1424
1424
|
}
|
|
1425
1425
|
|
|
1426
|
+
const ANY = "ANY";
|
|
1427
|
+
const MIXED = "MIXED";
|
|
1428
|
+
|
|
1429
|
+
const SINGLES = "SINGLES";
|
|
1430
|
+
const DOUBLES = "DOUBLES";
|
|
1431
|
+
const TEAM_MATCHUP = "TEAM";
|
|
1432
|
+
const TEAM$2 = "TEAM";
|
|
1433
|
+
|
|
1426
1434
|
var EntryStatusEnum = /* @__PURE__ */ ((EntryStatusEnum2) => {
|
|
1427
1435
|
EntryStatusEnum2["Alternate"] = "ALTERNATE";
|
|
1428
1436
|
EntryStatusEnum2["Confirmed"] = "CONFIRMED";
|
|
@@ -1480,26 +1488,29 @@ var ParticipantTypeEnum = /* @__PURE__ */ ((ParticipantTypeEnum2) => {
|
|
|
1480
1488
|
return ParticipantTypeEnum2;
|
|
1481
1489
|
})(ParticipantTypeEnum || {});
|
|
1482
1490
|
|
|
1483
|
-
const
|
|
1484
|
-
|
|
1485
|
-
function
|
|
1486
|
-
|
|
1487
|
-
matchUpType,
|
|
1488
|
-
gender
|
|
1489
|
-
|
|
1490
|
-
const stack = "genderValidityCheck";
|
|
1491
|
-
if (referenceGender && gender && [GenderEnum.Male, GenderEnum.Female].includes(referenceGender)) {
|
|
1492
|
-
const valid = gender === referenceGender;
|
|
1493
|
-
return valid ? { valid: true } : decorateResult({
|
|
1491
|
+
const mixedGenderError = "MIXED events can not contain mixed singles or { gender: ANY } collections";
|
|
1492
|
+
const anyMixedError = "events with { gender: ANY } can not contain MIXED singles collections";
|
|
1493
|
+
function tieFormatGenderValidityCheck(params) {
|
|
1494
|
+
const stack = "tieFormatGenderValidityCheck";
|
|
1495
|
+
const { referenceGender, matchUpType, gender } = params;
|
|
1496
|
+
if (referenceGender && gender && [GenderEnum.Male, GenderEnum.Female].includes(referenceGender) && referenceGender !== gender)
|
|
1497
|
+
return decorateResult({
|
|
1494
1498
|
result: { valid: false, error: INVALID_GENDER },
|
|
1495
1499
|
context: { gender },
|
|
1496
1500
|
stack
|
|
1497
1501
|
});
|
|
1502
|
+
const eventType = params.eventType ?? params.referenceEvent?.eventType;
|
|
1503
|
+
if (referenceGender === MIXED && (eventType !== TEAM$2 || gender === ANY || gender === MIXED && matchUpType !== TypeEnum.Doubles)) {
|
|
1504
|
+
return decorateResult({
|
|
1505
|
+
result: { error: INVALID_GENDER, valid: false },
|
|
1506
|
+
info: mixedGenderError,
|
|
1507
|
+
stack
|
|
1508
|
+
});
|
|
1498
1509
|
}
|
|
1499
|
-
if (referenceGender ===
|
|
1510
|
+
if (referenceGender === ANY && gender === MIXED && matchUpType !== TypeEnum.Doubles)
|
|
1500
1511
|
return decorateResult({
|
|
1501
|
-
info: "MIXED events can only contain MIXED doubles collections",
|
|
1502
1512
|
result: { error: INVALID_GENDER, valid: false },
|
|
1513
|
+
info: anyMixedError,
|
|
1503
1514
|
stack
|
|
1504
1515
|
});
|
|
1505
1516
|
return { valid: true };
|
|
@@ -1994,6 +2005,7 @@ function validateTieFormat(params) {
|
|
|
1994
2005
|
const checkGender = !!(params?.enforceGender !== false && params?.gender);
|
|
1995
2006
|
const checkCollectionIds = params?.checkCollectionIds;
|
|
1996
2007
|
const tieFormat = params?.tieFormat;
|
|
2008
|
+
const event = params?.event;
|
|
1997
2009
|
const stack = "validateTieFormat";
|
|
1998
2010
|
const errors = [];
|
|
1999
2011
|
if (!params || !tieFormat || typeof tieFormat !== "object") {
|
|
@@ -2029,10 +2041,12 @@ function validateTieFormat(params) {
|
|
|
2029
2041
|
const { valid: valid2, errors: collectionDefinitionErrors } = validateCollectionDefinition({
|
|
2030
2042
|
referenceCategory: params.category,
|
|
2031
2043
|
referenceGender: params.gender,
|
|
2044
|
+
eventType: params.eventType,
|
|
2032
2045
|
collectionDefinition,
|
|
2033
2046
|
checkCollectionIds,
|
|
2034
2047
|
checkCategory,
|
|
2035
|
-
checkGender
|
|
2048
|
+
checkGender,
|
|
2049
|
+
event
|
|
2036
2050
|
});
|
|
2037
2051
|
if (valid2) {
|
|
2038
2052
|
return true;
|
|
@@ -2079,6 +2093,7 @@ function validateCollectionDefinition({
|
|
|
2079
2093
|
checkGender = true,
|
|
2080
2094
|
referenceCategory,
|
|
2081
2095
|
referenceGender,
|
|
2096
|
+
eventType,
|
|
2082
2097
|
event
|
|
2083
2098
|
}) {
|
|
2084
2099
|
referenceGender = referenceGender ?? event?.gender;
|
|
@@ -2145,7 +2160,8 @@ function validateCollectionDefinition({
|
|
|
2145
2160
|
errors.push(`Invalid matchUpFormat: ${matchUpFormat}`);
|
|
2146
2161
|
}
|
|
2147
2162
|
if (checkGender) {
|
|
2148
|
-
const result =
|
|
2163
|
+
const result = tieFormatGenderValidityCheck({
|
|
2164
|
+
eventType: eventType ?? event?.eventType,
|
|
2149
2165
|
referenceGender,
|
|
2150
2166
|
matchUpType,
|
|
2151
2167
|
gender
|
|
@@ -2535,11 +2551,6 @@ function calculatePercentages({
|
|
|
2535
2551
|
});
|
|
2536
2552
|
}
|
|
2537
2553
|
|
|
2538
|
-
const SINGLES = "SINGLES";
|
|
2539
|
-
const DOUBLES = "DOUBLES";
|
|
2540
|
-
const TEAM_MATCHUP = "TEAM";
|
|
2541
|
-
const TEAM$2 = "TEAM";
|
|
2542
|
-
|
|
2543
2554
|
function getParticipantResults({
|
|
2544
2555
|
participantIds,
|
|
2545
2556
|
matchUpFormat,
|
|
@@ -6683,7 +6694,7 @@ function generateTieMatchUpScore(params) {
|
|
|
6683
6694
|
const tieFormat = resolveTieFormat({ matchUp, drawDefinition, structure, event })?.tieFormat || params?.tieFormat;
|
|
6684
6695
|
if (!tieFormat)
|
|
6685
6696
|
return { error: MISSING_TIE_FORMAT };
|
|
6686
|
-
const result = validateTieFormat({ tieFormat });
|
|
6697
|
+
const result = validateTieFormat({ tieFormat, eventType: event?.eventType });
|
|
6687
6698
|
if (result.error)
|
|
6688
6699
|
return result;
|
|
6689
6700
|
const collectionDefinitions = tieFormat?.collectionDefinitions || [];
|