tods-competition-factory 1.6.26 → 1.6.27
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.d.ts +1 -0
- package/dist/forge/generate.mjs +34 -27
- package/dist/forge/generate.mjs.map +1 -1
- package/dist/forge/query.mjs +2 -1
- package/dist/forge/query.mjs.map +1 -1
- package/dist/forge/transform.mjs +28 -19
- package/dist/forge/transform.mjs.map +1 -1
- package/dist/index.mjs +56 -35
- package/dist/index.mjs.map +1 -1
- package/dist/tods-competition-factory.development.cjs.js +61 -35
- 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 +7 -7
package/dist/forge/generate.d.ts
CHANGED
|
@@ -1463,6 +1463,7 @@ type GenerateDrawDefinitionArgs = {
|
|
|
1463
1463
|
qualifyingProfiles?: any[];
|
|
1464
1464
|
qualifyingOnly?: boolean;
|
|
1465
1465
|
drawType?: DrawTypeEnum;
|
|
1466
|
+
enforceGender?: boolean;
|
|
1466
1467
|
matchUpFormat?: string;
|
|
1467
1468
|
matchUpType?: TypeEnum;
|
|
1468
1469
|
tieFormatName?: string;
|
package/dist/forge/generate.mjs
CHANGED
|
@@ -16224,6 +16224,7 @@ const matchUpFormatCode = {
|
|
|
16224
16224
|
};
|
|
16225
16225
|
|
|
16226
16226
|
function validateTieFormat(params) {
|
|
16227
|
+
const checkGender = !!(params?.enforceGender !== false && params?.gender);
|
|
16227
16228
|
const checkCollectionIds = params?.checkCollectionIds;
|
|
16228
16229
|
const tieFormat = params?.tieFormat;
|
|
16229
16230
|
const stack = "validateTieFormat";
|
|
@@ -16232,9 +16233,9 @@ function validateTieFormat(params) {
|
|
|
16232
16233
|
errors.push("tieFormat must be an object");
|
|
16233
16234
|
return decorateResult({
|
|
16234
16235
|
result: {
|
|
16236
|
+
context: { tieFormat, errors },
|
|
16235
16237
|
error: INVALID_TIE_FORMAT,
|
|
16236
|
-
stack
|
|
16237
|
-
context: { tieFormat, errors }
|
|
16238
|
+
stack
|
|
16238
16239
|
}
|
|
16239
16240
|
});
|
|
16240
16241
|
}
|
|
@@ -16242,9 +16243,9 @@ function validateTieFormat(params) {
|
|
|
16242
16243
|
errors.push("tieFormat.winCriteria must be an object");
|
|
16243
16244
|
return decorateResult({
|
|
16244
16245
|
result: {
|
|
16246
|
+
context: { tieFormat, errors },
|
|
16245
16247
|
error: INVALID_TIE_FORMAT,
|
|
16246
|
-
stack
|
|
16247
|
-
context: { tieFormat, errors }
|
|
16248
|
+
stack
|
|
16248
16249
|
}
|
|
16249
16250
|
});
|
|
16250
16251
|
}
|
|
@@ -16252,9 +16253,9 @@ function validateTieFormat(params) {
|
|
|
16252
16253
|
errors.push(mustBeAnArray("tieFormat.collectionDefinitions"));
|
|
16253
16254
|
return decorateResult({
|
|
16254
16255
|
result: {
|
|
16256
|
+
context: { tieFormat, errors },
|
|
16255
16257
|
error: INVALID_TIE_FORMAT,
|
|
16256
|
-
stack
|
|
16257
|
-
context: { tieFormat, errors }
|
|
16258
|
+
stack
|
|
16258
16259
|
}
|
|
16259
16260
|
});
|
|
16260
16261
|
}
|
|
@@ -16265,8 +16266,10 @@ function validateTieFormat(params) {
|
|
|
16265
16266
|
if ((setValue || scoreValue) && !collectionValue)
|
|
16266
16267
|
aggregateValueImperative = true;
|
|
16267
16268
|
const { valid: valid2, errors: collectionDefinitionErrors } = validateCollectionDefinition({
|
|
16269
|
+
referenceGender: params.gender,
|
|
16268
16270
|
collectionDefinition,
|
|
16269
|
-
checkCollectionIds
|
|
16271
|
+
checkCollectionIds,
|
|
16272
|
+
checkGender
|
|
16270
16273
|
});
|
|
16271
16274
|
if (valid2) {
|
|
16272
16275
|
return true;
|
|
@@ -16312,7 +16315,9 @@ function validateTieFormat(params) {
|
|
|
16312
16315
|
}
|
|
16313
16316
|
function validateCollectionDefinition({
|
|
16314
16317
|
collectionDefinition,
|
|
16315
|
-
checkCollectionIds
|
|
16318
|
+
checkCollectionIds,
|
|
16319
|
+
referenceGender,
|
|
16320
|
+
checkGender
|
|
16316
16321
|
}) {
|
|
16317
16322
|
const errors = [];
|
|
16318
16323
|
if (typeof collectionDefinition !== "object") {
|
|
@@ -16331,19 +16336,17 @@ function validateCollectionDefinition({
|
|
|
16331
16336
|
matchUpValue,
|
|
16332
16337
|
matchUpType,
|
|
16333
16338
|
scoreValue,
|
|
16334
|
-
setValue
|
|
16339
|
+
setValue,
|
|
16340
|
+
gender
|
|
16335
16341
|
} = collectionDefinition;
|
|
16336
16342
|
if (checkCollectionIds && typeof collectionId !== "string") {
|
|
16337
16343
|
errors.push(`collectionId is not type string: ${collectionId}`);
|
|
16338
|
-
return { errors };
|
|
16339
16344
|
}
|
|
16340
16345
|
if (typeof matchUpCount !== "number") {
|
|
16341
16346
|
errors.push(`matchUpCount is not type number: ${matchUpCount}`);
|
|
16342
|
-
return { errors };
|
|
16343
16347
|
}
|
|
16344
16348
|
if (matchUpType && ![TypeEnum.Singles, TypeEnum.Doubles].includes(matchUpType)) {
|
|
16345
16349
|
errors.push(`matchUpType must be SINGLES or DOUBLES: ${matchUpType}`);
|
|
16346
|
-
return { errors };
|
|
16347
16350
|
}
|
|
16348
16351
|
const valueDeclarations = [!!collectionValueProfiles?.length].concat(
|
|
16349
16352
|
[matchUpValue, collectionValue, scoreValue, setValue].map(
|
|
@@ -16354,15 +16357,12 @@ function validateCollectionDefinition({
|
|
|
16354
16357
|
errors.push(
|
|
16355
16358
|
"Missing value definition for matchUps: matchUpValue, collectionValue, or collectionValueProfiles"
|
|
16356
16359
|
);
|
|
16357
|
-
return { errors };
|
|
16358
16360
|
}
|
|
16359
16361
|
if (matchUpValue && typeof matchUpValue !== "number") {
|
|
16360
16362
|
errors.push(`matchUpValue is not type number: ${matchUpValue}`);
|
|
16361
|
-
return { errors };
|
|
16362
16363
|
}
|
|
16363
16364
|
if (collectionValue && typeof collectionValue !== "number") {
|
|
16364
16365
|
errors.push(`collectionValue is not type number: ${collectionValue}`);
|
|
16365
|
-
return { errors };
|
|
16366
16366
|
}
|
|
16367
16367
|
if (collectionValueProfiles) {
|
|
16368
16368
|
const result = validateCollectionValueProfile({
|
|
@@ -16371,17 +16371,19 @@ function validateCollectionDefinition({
|
|
|
16371
16371
|
});
|
|
16372
16372
|
if (result.errors) {
|
|
16373
16373
|
errors.push(...result.errors);
|
|
16374
|
-
return { errors };
|
|
16375
16374
|
}
|
|
16376
16375
|
}
|
|
16377
16376
|
if (collectionGroupNumber && typeof collectionGroupNumber !== "number") {
|
|
16378
|
-
errors.push(`
|
|
16379
|
-
return { errors };
|
|
16377
|
+
errors.push(`collectionGroupNumber is not type number: ${collectionValue}`);
|
|
16380
16378
|
}
|
|
16381
16379
|
if (matchUpFormat && !matchUpFormatCode.isValid(matchUpFormat)) {
|
|
16382
16380
|
errors.push(`Invalid matchUpFormat: ${matchUpFormat}`);
|
|
16383
|
-
return { errors };
|
|
16384
16381
|
}
|
|
16382
|
+
if (checkGender && referenceGender && gender && [GenderEnum.Male, GenderEnum.Female].includes(referenceGender) && referenceGender !== gender) {
|
|
16383
|
+
errors.push(`Invalid gender: ${gender}`);
|
|
16384
|
+
}
|
|
16385
|
+
if (errors.length)
|
|
16386
|
+
return { errors };
|
|
16385
16387
|
return { valid: true };
|
|
16386
16388
|
}
|
|
16387
16389
|
function checkTieFormat(tieFormat) {
|
|
@@ -20856,8 +20858,8 @@ function isUngrouped(entryStatus) {
|
|
|
20856
20858
|
}
|
|
20857
20859
|
|
|
20858
20860
|
function checkValidEntries({
|
|
20861
|
+
enforceGender = true,
|
|
20859
20862
|
participants,
|
|
20860
|
-
ignoreGender,
|
|
20861
20863
|
event
|
|
20862
20864
|
}) {
|
|
20863
20865
|
if (!participants)
|
|
@@ -20883,7 +20885,7 @@ function checkValidEntries({
|
|
|
20883
20885
|
const ungroupedParticipant = eventType && [TypeEnum.Doubles, TypeEnum.Team].includes(eventType) && participant.participantType === INDIVIDUAL && (isUngrouped(entryStatus) || entryStatus === WITHDRAWN);
|
|
20884
20886
|
const mismatch = participant.participantType !== participantType && !ungroupedParticipant;
|
|
20885
20887
|
const personGender = participant?.person?.sex;
|
|
20886
|
-
const wrongGender =
|
|
20888
|
+
const wrongGender = enforceGender && eventGender && eventType === TypeEnum.Singles && [GenderEnum.Male, GenderEnum.Female].includes(eventGender) && personGender !== eventGender;
|
|
20887
20889
|
return mismatch || wrongGender;
|
|
20888
20890
|
});
|
|
20889
20891
|
if (invalidEntries.length) {
|
|
@@ -22654,6 +22656,7 @@ function generateDrawDefinition(params) {
|
|
|
22654
22656
|
ignoreStageSpace,
|
|
22655
22657
|
tournamentRecord,
|
|
22656
22658
|
qualifyingOnly,
|
|
22659
|
+
enforceGender,
|
|
22657
22660
|
tieFormatName,
|
|
22658
22661
|
drawEntries,
|
|
22659
22662
|
addToEvent,
|
|
@@ -22664,7 +22667,7 @@ function generateDrawDefinition(params) {
|
|
|
22664
22667
|
tournamentRecord,
|
|
22665
22668
|
inContext: true
|
|
22666
22669
|
});
|
|
22667
|
-
const validEntriesResult = event && participants && checkValidEntries({ event, participants });
|
|
22670
|
+
const validEntriesResult = event && participants && checkValidEntries({ event, participants, enforceGender });
|
|
22668
22671
|
if (validEntriesResult?.error)
|
|
22669
22672
|
return decorateResult({ result: validEntriesResult, stack });
|
|
22670
22673
|
const allowedDrawTypes = !ignoreAllowedDrawTypes && tournamentRecord && getAllowedDrawTypes({
|
|
@@ -22700,11 +22703,6 @@ function generateDrawDefinition(params) {
|
|
|
22700
22703
|
(d) => d.drawId === params.drawId
|
|
22701
22704
|
) : void 0;
|
|
22702
22705
|
let { tieFormat, matchUpFormat } = params;
|
|
22703
|
-
if (tieFormat) {
|
|
22704
|
-
const result = validateTieFormat({ tieFormat });
|
|
22705
|
-
if (result.error)
|
|
22706
|
-
return decorateResult({ result, stack });
|
|
22707
|
-
}
|
|
22708
22706
|
if (matchUpType === TEAM$2 && eventType === TEAM$2) {
|
|
22709
22707
|
const existingMainTieFormat = existingDrawDefinition?.structures?.find(
|
|
22710
22708
|
({ stage }) => stage === MAIN
|
|
@@ -22724,6 +22722,15 @@ function generateDrawDefinition(params) {
|
|
|
22724
22722
|
matchUpFormat = FORMAT_STANDARD;
|
|
22725
22723
|
}
|
|
22726
22724
|
}
|
|
22725
|
+
if (tieFormat) {
|
|
22726
|
+
const result = validateTieFormat({
|
|
22727
|
+
gender: event?.gender,
|
|
22728
|
+
enforceGender,
|
|
22729
|
+
tieFormat
|
|
22730
|
+
});
|
|
22731
|
+
if (result.error)
|
|
22732
|
+
return decorateResult({ result, stack });
|
|
22733
|
+
}
|
|
22727
22734
|
const invalidDrawId = params.drawId && typeof params.drawId !== "string";
|
|
22728
22735
|
if (invalidDrawId)
|
|
22729
22736
|
return decorateResult({ result: { error: INVALID_VALUES }, stack });
|