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/generate.mjs
CHANGED
|
@@ -4493,6 +4493,7 @@ function getSeeding({ seedAssignments, participantId }) {
|
|
|
4493
4493
|
);
|
|
4494
4494
|
}
|
|
4495
4495
|
|
|
4496
|
+
const ANY = "ANY";
|
|
4496
4497
|
const MIXED = "MIXED";
|
|
4497
4498
|
|
|
4498
4499
|
function getAllStructureMatchUps({
|
|
@@ -16478,24 +16479,29 @@ function ensureSideLineUps({
|
|
|
16478
16479
|
}
|
|
16479
16480
|
}
|
|
16480
16481
|
|
|
16481
|
-
|
|
16482
|
-
|
|
16483
|
-
|
|
16484
|
-
|
|
16485
|
-
}
|
|
16486
|
-
|
|
16487
|
-
|
|
16488
|
-
const valid = gender === referenceGender;
|
|
16489
|
-
return valid ? { valid: true } : decorateResult({
|
|
16482
|
+
const mixedGenderError = "MIXED events can not contain mixed singles or { gender: ANY } collections";
|
|
16483
|
+
const anyMixedError = "events with { gender: ANY } can not contain MIXED singles collections";
|
|
16484
|
+
function tieFormatGenderValidityCheck(params) {
|
|
16485
|
+
const stack = "tieFormatGenderValidityCheck";
|
|
16486
|
+
const { referenceGender, matchUpType, gender } = params;
|
|
16487
|
+
if (referenceGender && gender && [GenderEnum.Male, GenderEnum.Female].includes(referenceGender) && referenceGender !== gender)
|
|
16488
|
+
return decorateResult({
|
|
16490
16489
|
result: { valid: false, error: INVALID_GENDER },
|
|
16491
16490
|
context: { gender },
|
|
16492
16491
|
stack
|
|
16493
16492
|
});
|
|
16493
|
+
const eventType = params.eventType ?? params.referenceEvent?.eventType;
|
|
16494
|
+
if (referenceGender === MIXED && (eventType !== TEAM$2 || gender === ANY || gender === MIXED && matchUpType !== TypeEnum.Doubles)) {
|
|
16495
|
+
return decorateResult({
|
|
16496
|
+
result: { error: INVALID_GENDER, valid: false },
|
|
16497
|
+
info: mixedGenderError,
|
|
16498
|
+
stack
|
|
16499
|
+
});
|
|
16494
16500
|
}
|
|
16495
|
-
if (referenceGender ===
|
|
16501
|
+
if (referenceGender === ANY && gender === MIXED && matchUpType !== TypeEnum.Doubles)
|
|
16496
16502
|
return decorateResult({
|
|
16497
|
-
info: "MIXED events can only contain MIXED doubles collections",
|
|
16498
16503
|
result: { error: INVALID_GENDER, valid: false },
|
|
16504
|
+
info: anyMixedError,
|
|
16499
16505
|
stack
|
|
16500
16506
|
});
|
|
16501
16507
|
return { valid: true };
|
|
@@ -16840,6 +16846,7 @@ function validateTieFormat(params) {
|
|
|
16840
16846
|
const checkGender = !!(params?.enforceGender !== false && params?.gender);
|
|
16841
16847
|
const checkCollectionIds = params?.checkCollectionIds;
|
|
16842
16848
|
const tieFormat = params?.tieFormat;
|
|
16849
|
+
const event = params?.event;
|
|
16843
16850
|
const stack = "validateTieFormat";
|
|
16844
16851
|
const errors = [];
|
|
16845
16852
|
if (!params || !tieFormat || typeof tieFormat !== "object") {
|
|
@@ -16875,10 +16882,12 @@ function validateTieFormat(params) {
|
|
|
16875
16882
|
const { valid: valid2, errors: collectionDefinitionErrors } = validateCollectionDefinition({
|
|
16876
16883
|
referenceCategory: params.category,
|
|
16877
16884
|
referenceGender: params.gender,
|
|
16885
|
+
eventType: params.eventType,
|
|
16878
16886
|
collectionDefinition,
|
|
16879
16887
|
checkCollectionIds,
|
|
16880
16888
|
checkCategory,
|
|
16881
|
-
checkGender
|
|
16889
|
+
checkGender,
|
|
16890
|
+
event
|
|
16882
16891
|
});
|
|
16883
16892
|
if (valid2) {
|
|
16884
16893
|
return true;
|
|
@@ -16925,6 +16934,7 @@ function validateCollectionDefinition({
|
|
|
16925
16934
|
checkGender = true,
|
|
16926
16935
|
referenceCategory,
|
|
16927
16936
|
referenceGender,
|
|
16937
|
+
eventType,
|
|
16928
16938
|
event
|
|
16929
16939
|
}) {
|
|
16930
16940
|
referenceGender = referenceGender ?? event?.gender;
|
|
@@ -16991,7 +17001,8 @@ function validateCollectionDefinition({
|
|
|
16991
17001
|
errors.push(`Invalid matchUpFormat: ${matchUpFormat}`);
|
|
16992
17002
|
}
|
|
16993
17003
|
if (checkGender) {
|
|
16994
|
-
const result =
|
|
17004
|
+
const result = tieFormatGenderValidityCheck({
|
|
17005
|
+
eventType: eventType ?? event?.eventType,
|
|
16995
17006
|
referenceGender,
|
|
16996
17007
|
matchUpType,
|
|
16997
17008
|
gender
|
|
@@ -17023,8 +17034,15 @@ function validateCollectionDefinition({
|
|
|
17023
17034
|
});
|
|
17024
17035
|
return { valid: true };
|
|
17025
17036
|
}
|
|
17026
|
-
function checkTieFormat(
|
|
17027
|
-
|
|
17037
|
+
function checkTieFormat({
|
|
17038
|
+
tieFormat,
|
|
17039
|
+
eventType
|
|
17040
|
+
}) {
|
|
17041
|
+
const result = validateTieFormat({
|
|
17042
|
+
checkCollectionIds: false,
|
|
17043
|
+
eventType,
|
|
17044
|
+
tieFormat
|
|
17045
|
+
});
|
|
17028
17046
|
if (result.error)
|
|
17029
17047
|
return result;
|
|
17030
17048
|
for (const collectionDefinition of tieFormat.collectionDefinitions) {
|
|
@@ -17249,7 +17267,7 @@ function generateTieMatchUpScore(params) {
|
|
|
17249
17267
|
const tieFormat = resolveTieFormat({ matchUp, drawDefinition, structure, event })?.tieFormat || params?.tieFormat;
|
|
17250
17268
|
if (!tieFormat)
|
|
17251
17269
|
return { error: MISSING_TIE_FORMAT };
|
|
17252
|
-
const result = validateTieFormat({ tieFormat });
|
|
17270
|
+
const result = validateTieFormat({ tieFormat, eventType: event?.eventType });
|
|
17253
17271
|
if (result.error)
|
|
17254
17272
|
return result;
|
|
17255
17273
|
const collectionDefinitions = tieFormat?.collectionDefinitions || [];
|
|
@@ -20120,7 +20138,8 @@ function generateVoluntaryConsolation$1(params) {
|
|
|
20120
20138
|
return { error: INVALID_DRAW_SIZE };
|
|
20121
20139
|
let { tieFormat, matchUpType } = params;
|
|
20122
20140
|
if (tieFormat) {
|
|
20123
|
-
const
|
|
20141
|
+
const eventType = params.event?.eventType;
|
|
20142
|
+
const result2 = validateTieFormat({ tieFormat, eventType });
|
|
20124
20143
|
if (result2.error)
|
|
20125
20144
|
return result2;
|
|
20126
20145
|
}
|
|
@@ -21222,7 +21241,8 @@ function generateDrawTypeAndModifyDrawDefinition(params) {
|
|
|
21222
21241
|
const drawDefinition = modifyOriginal ? params.drawDefinition : makeDeepCopy(params.drawDefinition, false, true);
|
|
21223
21242
|
let { tieFormat, matchUpType } = params;
|
|
21224
21243
|
if (tieFormat) {
|
|
21225
|
-
const
|
|
21244
|
+
const eventType = params.event?.eventType;
|
|
21245
|
+
const result2 = validateTieFormat({ tieFormat, eventType });
|
|
21226
21246
|
if (result2.error)
|
|
21227
21247
|
return result2;
|
|
21228
21248
|
}
|
|
@@ -23127,9 +23147,9 @@ function getSeedsCount(params) {
|
|
|
23127
23147
|
}
|
|
23128
23148
|
}
|
|
23129
23149
|
const consideredParticipantCount = requireParticipantCount && participantsCount || drawSize;
|
|
23130
|
-
if (consideredParticipantCount > drawSize)
|
|
23150
|
+
if (consideredParticipantCount && consideredParticipantCount > drawSize)
|
|
23131
23151
|
return { error: PARTICIPANT_COUNT_EXCEEDS_DRAW_SIZE };
|
|
23132
|
-
const policy = policyDefinitions[POLICY_TYPE_SEEDING];
|
|
23152
|
+
const policy = policyDefinitions?.[POLICY_TYPE_SEEDING];
|
|
23133
23153
|
if (!policy)
|
|
23134
23154
|
return { error: INVALID_POLICY_DEFINITION };
|
|
23135
23155
|
const seedsCountThresholds = policy.seedsCountThresholds;
|
|
@@ -23141,7 +23161,7 @@ function getSeedsCount(params) {
|
|
|
23141
23161
|
return drawSizeProgression ? threshold.drawSize <= drawSize : drawSize === threshold.drawSize;
|
|
23142
23162
|
});
|
|
23143
23163
|
const seedsCount = relevantThresholds.reduce((seedsCount2, threshold) => {
|
|
23144
|
-
return participantsCount >= threshold.minimumParticipantCount ? threshold.seedsCount : seedsCount2;
|
|
23164
|
+
return participantsCount && participantsCount >= threshold.minimumParticipantCount ? threshold.seedsCount : seedsCount2;
|
|
23145
23165
|
}, 0);
|
|
23146
23166
|
return { seedsCount };
|
|
23147
23167
|
}
|
|
@@ -23707,7 +23727,8 @@ function generateDrawDefinition(params) {
|
|
|
23707
23727
|
const result = validateTieFormat({
|
|
23708
23728
|
gender: event?.gender,
|
|
23709
23729
|
enforceGender,
|
|
23710
|
-
tieFormat
|
|
23730
|
+
tieFormat,
|
|
23731
|
+
event
|
|
23711
23732
|
});
|
|
23712
23733
|
if (result.error)
|
|
23713
23734
|
return decorateResult({ result, stack });
|
|
@@ -23726,7 +23747,10 @@ function generateDrawDefinition(params) {
|
|
|
23726
23747
|
const equivalentInScope = matchUpFormat && event?.matchUpFormat === matchUpFormat || event?.tieFormat && tieFormat && JSON.stringify(event.tieFormat) === JSON.stringify(tieFormat);
|
|
23727
23748
|
if (!equivalentInScope) {
|
|
23728
23749
|
if (tieFormat) {
|
|
23729
|
-
const result = checkTieFormat(
|
|
23750
|
+
const result = checkTieFormat({
|
|
23751
|
+
eventType: event.eventType,
|
|
23752
|
+
tieFormat
|
|
23753
|
+
});
|
|
23730
23754
|
if (result.error)
|
|
23731
23755
|
return decorateResult({ result, stack });
|
|
23732
23756
|
drawDefinition.tieFormat = result.tieFormat ?? tieFormat;
|