tods-competition-factory 1.8.19 → 1.8.20
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 +56 -9
- package/dist/forge/generate.mjs.map +1 -1
- package/dist/forge/query.d.ts +5 -1
- package/dist/forge/query.mjs +10 -2
- package/dist/forge/query.mjs.map +1 -1
- package/dist/forge/transform.mjs +1 -1
- package/dist/forge/transform.mjs.map +1 -1
- package/dist/index.mjs +64 -32
- package/dist/index.mjs.map +1 -1
- package/dist/tods-competition-factory.development.cjs.js +161 -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 +1 -1
package/dist/forge/generate.mjs
CHANGED
|
@@ -16752,8 +16752,8 @@ function validateCollectionDefinition({
|
|
|
16752
16752
|
if (checkGender && referenceGender && gender && [GenderEnum.Male, GenderEnum.Female].includes(referenceGender) && referenceGender !== gender) {
|
|
16753
16753
|
errors.push(`Invalid gender: ${gender}`);
|
|
16754
16754
|
return decorateResult({
|
|
16755
|
+
result: { error: INVALID_GENDER, errors },
|
|
16755
16756
|
context: { referenceGender, gender },
|
|
16756
|
-
result: { error: INVALID_GENDER },
|
|
16757
16757
|
stack
|
|
16758
16758
|
});
|
|
16759
16759
|
}
|
|
@@ -21397,25 +21397,65 @@ function isUngrouped(entryStatus) {
|
|
|
21397
21397
|
return [UNPAIRED, UNGROUPED].includes(entryStatus);
|
|
21398
21398
|
}
|
|
21399
21399
|
|
|
21400
|
+
const POLICY_MATCHUP_ACTIONS_DEFAULT = {
|
|
21401
|
+
[POLICY_TYPE_MATCHUP_ACTIONS]: {
|
|
21402
|
+
policyName: "matchUpActionsDefault",
|
|
21403
|
+
// matchUpActions will be selectively enabled for structures matching { stages: [], stageSequences: [] }
|
|
21404
|
+
// enabledStructures: [] => all structures are enabled
|
|
21405
|
+
enabledStructures: [
|
|
21406
|
+
{
|
|
21407
|
+
stages: [],
|
|
21408
|
+
// stages: [] => applies to all stages
|
|
21409
|
+
stageSequences: [],
|
|
21410
|
+
// stageSequences: [] => applies to all stageSequences
|
|
21411
|
+
enabledActions: [],
|
|
21412
|
+
disabledActions: []
|
|
21413
|
+
// disabledActions: [] => no actions are disabled
|
|
21414
|
+
}
|
|
21415
|
+
],
|
|
21416
|
+
participants: {
|
|
21417
|
+
enforceCategory: true,
|
|
21418
|
+
// validate collectionDefinition.category against event.category
|
|
21419
|
+
enforceGender: true
|
|
21420
|
+
// disallow placing FEMALEs in MALE events and vice versa
|
|
21421
|
+
},
|
|
21422
|
+
processCodes: {
|
|
21423
|
+
substitution: ["RANKING.IGNORE", "RATING.IGNORE"]
|
|
21424
|
+
},
|
|
21425
|
+
substituteAfterCompleted: false,
|
|
21426
|
+
substituteWithoutScore: false
|
|
21427
|
+
}
|
|
21428
|
+
};
|
|
21429
|
+
|
|
21400
21430
|
function checkValidEntries({
|
|
21401
|
-
enforceGender = true,
|
|
21402
21431
|
consideredEntries,
|
|
21432
|
+
policyDefinitions,
|
|
21403
21433
|
tournamentRecord,
|
|
21434
|
+
appliedPolicies,
|
|
21435
|
+
participantMap,
|
|
21436
|
+
enforceGender,
|
|
21404
21437
|
participants,
|
|
21405
21438
|
event
|
|
21406
21439
|
}) {
|
|
21407
|
-
|
|
21440
|
+
if ((!participants || !participantMap) && tournamentRecord) {
|
|
21441
|
+
({ participants, participantMap } = getParticipants({
|
|
21442
|
+
tournamentRecord
|
|
21443
|
+
}));
|
|
21444
|
+
}
|
|
21408
21445
|
if (!participants)
|
|
21409
21446
|
return { error: MISSING_PARTICIPANTS };
|
|
21410
21447
|
if (!Array.isArray(participants))
|
|
21411
21448
|
return { error: INVALID_VALUES };
|
|
21412
21449
|
if (!event)
|
|
21413
21450
|
return { error: MISSING_EVENT };
|
|
21451
|
+
const matchUpActionsPolicy = policyDefinitions?.[POLICY_TYPE_MATCHUP_ACTIONS] ?? appliedPolicies?.[POLICY_TYPE_MATCHUP_ACTIONS] ?? POLICY_MATCHUP_ACTIONS_DEFAULT[POLICY_TYPE_MATCHUP_ACTIONS];
|
|
21452
|
+
const genderEnforced = (enforceGender ?? matchUpActionsPolicy?.participants?.enforceGender) !== false;
|
|
21414
21453
|
const { eventType, gender: eventGender } = event;
|
|
21415
|
-
const
|
|
21454
|
+
const isDoubles = eventType === DOUBLES_EVENT;
|
|
21455
|
+
const participantType = eventType === TEAM_EVENT && TEAM || isDoubles && PAIR || INDIVIDUAL;
|
|
21416
21456
|
const entryStatusMap = Object.assign(
|
|
21417
21457
|
{},
|
|
21418
|
-
...(consideredEntries
|
|
21458
|
+
...(consideredEntries ?? event.entries ?? []).map((entry) => ({
|
|
21419
21459
|
[entry.participantId]: entry.entryStatus
|
|
21420
21460
|
}))
|
|
21421
21461
|
);
|
|
@@ -21427,9 +21467,14 @@ function checkValidEntries({
|
|
|
21427
21467
|
const entryStatus = entryStatusMap[participant.participantId];
|
|
21428
21468
|
const ungroupedParticipant = eventType && [TypeEnum.Doubles, TypeEnum.Team].includes(eventType) && participant.participantType === INDIVIDUAL && (isUngrouped(entryStatus) || entryStatus === WITHDRAWN);
|
|
21429
21469
|
const mismatch = participant.participantType !== participantType && !ungroupedParticipant;
|
|
21470
|
+
const pairGender = !mismatch && isDoubles && unique(
|
|
21471
|
+
participant?.individualParticipantIds?.map((id) => participantMap?.[id]?.participant?.person?.sex).filter(Boolean) ?? []
|
|
21472
|
+
);
|
|
21473
|
+
const validPairGender = !eventGender || !pairGender?.length || GenderEnum.Any === eventGender || [GenderEnum.Male, GenderEnum.Female].includes(eventGender) && pairGender[0] === eventGender || GenderEnum.Mixed === eventGender && (pairGender.length == 1 && participant.individualParticipantIds?.length === 1 || pairGender.length === 2);
|
|
21430
21474
|
const personGender = participant?.person?.sex;
|
|
21431
|
-
const
|
|
21432
|
-
|
|
21475
|
+
const validPersonGender = !participant?.person || !eventGender || [GenderEnum.Any, GenderEnum.Mixed].includes(eventGender) || [GenderEnum.Male, GenderEnum.Female].includes(eventGender) && personGender === eventGender;
|
|
21476
|
+
const validGender = !genderEnforced || validPairGender && validPersonGender;
|
|
21477
|
+
return mismatch || !validGender;
|
|
21433
21478
|
});
|
|
21434
21479
|
if (invalidEntries.length) {
|
|
21435
21480
|
const invalidParticipantIds = invalidEntries.map(
|
|
@@ -21437,7 +21482,7 @@ function checkValidEntries({
|
|
|
21437
21482
|
);
|
|
21438
21483
|
return { error: INVALID_ENTRIES, invalidParticipantIds };
|
|
21439
21484
|
}
|
|
21440
|
-
return { ...SUCCESS };
|
|
21485
|
+
return { ...SUCCESS, valid: true };
|
|
21441
21486
|
}
|
|
21442
21487
|
|
|
21443
21488
|
function getValidStage({ stage, drawDefinition }) {
|
|
@@ -23321,7 +23366,7 @@ function generateDrawDefinition(params) {
|
|
|
23321
23366
|
}).appliedPolicies ?? {};
|
|
23322
23367
|
const drawTypeCoercion = params.drawTypeCoercion ?? appliedPolicies?.[POLICY_TYPE_DRAWS]?.drawTypeCoercion ?? true;
|
|
23323
23368
|
const drawType = drawTypeCoercion && params.drawSize === 2 && DrawTypeEnum.SingleElimination || params.drawType || DrawTypeEnum.SingleElimination;
|
|
23324
|
-
const { participants } = getParticipants({
|
|
23369
|
+
const { participants, participantMap } = getParticipants({
|
|
23325
23370
|
withIndividualParticipants: true,
|
|
23326
23371
|
tournamentRecord
|
|
23327
23372
|
});
|
|
@@ -23340,6 +23385,8 @@ function generateDrawDefinition(params) {
|
|
|
23340
23385
|
const consideredEntries = (qualifyingOnly && [] || drawEntries || (considerEventEntries ? eventEntries : [])).filter(({ entryStage }) => !entryStage || entryStage === MAIN);
|
|
23341
23386
|
const validEntriesResult = event && participants && checkValidEntries({
|
|
23342
23387
|
consideredEntries,
|
|
23388
|
+
appliedPolicies,
|
|
23389
|
+
participantMap,
|
|
23343
23390
|
enforceGender,
|
|
23344
23391
|
participants,
|
|
23345
23392
|
event
|