tods-competition-factory 1.8.33 → 1.8.35
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 +22 -7
- package/dist/forge/generate.mjs.map +1 -1
- package/dist/forge/query.mjs +2 -2
- package/dist/forge/query.mjs.map +1 -1
- package/dist/forge/transform.mjs +2 -2
- package/dist/forge/transform.mjs.map +1 -1
- package/dist/index.mjs +86 -39
- package/dist/index.mjs.map +1 -1
- package/dist/tods-competition-factory.development.cjs.js +226 -159
- 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 +3 -3
package/dist/index.mjs
CHANGED
|
@@ -2404,7 +2404,7 @@ const matchUpFormatCode = {
|
|
|
2404
2404
|
};
|
|
2405
2405
|
|
|
2406
2406
|
function factoryVersion() {
|
|
2407
|
-
return "1.8.
|
|
2407
|
+
return "1.8.35";
|
|
2408
2408
|
}
|
|
2409
2409
|
|
|
2410
2410
|
function getObjectTieFormat(obj) {
|
|
@@ -8276,7 +8276,7 @@ function getAllStructureMatchUps({
|
|
|
8276
8276
|
const matchUpCategory = collectionDefinition?.category ? {
|
|
8277
8277
|
...context?.category || {},
|
|
8278
8278
|
...collectionDefinition.category
|
|
8279
|
-
} : context?.category;
|
|
8279
|
+
} : context?.category ?? event2?.category;
|
|
8280
8280
|
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;
|
|
8281
8281
|
const competitiveProfile = contextProfile?.withCompetitiveness && getMatchUpCompetitiveProfile({ ...contextContent, matchUp });
|
|
8282
8282
|
const finishingPositionRange = matchUp.finishingPositionRange ?? additionalContext.finishingPositionRange;
|
|
@@ -8286,9 +8286,9 @@ function getAllStructureMatchUps({
|
|
|
8286
8286
|
...onlyDefined({
|
|
8287
8287
|
matchUpFormat: matchUp.matchUpType === TEAM$1 ? void 0 : matchUpFormat,
|
|
8288
8288
|
tieFormat: matchUp.matchUpType !== TEAM$1 ? void 0 : tieFormat,
|
|
8289
|
+
gender: collectionDefinition?.gender ?? event2?.gender,
|
|
8289
8290
|
roundOfPlay: stage !== QUALIFYING && isConvertableInteger(initialRoundOfPlay2) && initialRoundOfPlay2 + (roundNumber || 0),
|
|
8290
8291
|
endDate: matchUp.endDate ?? endDate,
|
|
8291
|
-
gender: collectionDefinition?.gender,
|
|
8292
8292
|
discipline: event2?.discipline,
|
|
8293
8293
|
category: matchUpCategory,
|
|
8294
8294
|
finishingPositionRange,
|
|
@@ -15542,7 +15542,13 @@ const POLICY_SEEDING_USTA = {
|
|
|
15542
15542
|
validSeedPositions: { ignore: true },
|
|
15543
15543
|
duplicateSeedNumbers: true,
|
|
15544
15544
|
drawSizeProgression: true,
|
|
15545
|
-
seedingProfile: {
|
|
15545
|
+
seedingProfile: {
|
|
15546
|
+
drawTypes: {
|
|
15547
|
+
[ROUND_ROBIN_WITH_PLAYOFF]: { positioning: WATERFALL },
|
|
15548
|
+
[ROUND_ROBIN]: { positioning: WATERFALL }
|
|
15549
|
+
},
|
|
15550
|
+
positioning: SEPARATE
|
|
15551
|
+
},
|
|
15546
15552
|
policyName: "USTA SEEDING",
|
|
15547
15553
|
seedsCountThresholds: [
|
|
15548
15554
|
{ drawSize: 4, minimumParticipantCount: 3, seedsCount: 2 },
|
|
@@ -19573,6 +19579,15 @@ function tidyScore(params) {
|
|
|
19573
19579
|
};
|
|
19574
19580
|
}
|
|
19575
19581
|
|
|
19582
|
+
function capitalizeFirst(str) {
|
|
19583
|
+
return !isString(str) ? str : str.split(" ").map(
|
|
19584
|
+
(name) => name.split("").map((c, i) => i ? c.toLowerCase() : c.toUpperCase()).join("")
|
|
19585
|
+
).join(" ");
|
|
19586
|
+
}
|
|
19587
|
+
function constantToString(str) {
|
|
19588
|
+
return !isString(str) ? str : capitalizeFirst(str.replace(/_/g, " "));
|
|
19589
|
+
}
|
|
19590
|
+
|
|
19576
19591
|
const { FACTORY } = extensionConstants;
|
|
19577
19592
|
function updateFactoryExtension({ tournamentRecord, value }) {
|
|
19578
19593
|
const { extension } = findExtension({
|
|
@@ -23469,15 +23484,6 @@ function getNumericSeedValue(seedValue) {
|
|
|
23469
23484
|
return Infinity;
|
|
23470
23485
|
}
|
|
23471
23486
|
|
|
23472
|
-
function capitalizeFirst(str) {
|
|
23473
|
-
return !isString(str) ? str : str.split(" ").map(
|
|
23474
|
-
(name) => name.split("").map((c, i) => i ? c.toLowerCase() : c.toUpperCase()).join("")
|
|
23475
|
-
).join(" ");
|
|
23476
|
-
}
|
|
23477
|
-
function constantToString(str) {
|
|
23478
|
-
return !isString(str) ? str : capitalizeFirst(str.replace(/_/g, " "));
|
|
23479
|
-
}
|
|
23480
|
-
|
|
23481
23487
|
const structureTemplate = ({
|
|
23482
23488
|
finishingPosition = ROUND_OUTCOME,
|
|
23483
23489
|
qualifyingRoundNumber,
|
|
@@ -45922,7 +45928,7 @@ function addEventEntries(params) {
|
|
|
45922
45928
|
const genderEnforced = (enforceGender ?? matchUpActionsPolicy?.participants?.enforceGender) !== false;
|
|
45923
45929
|
const addedParticipantIdEntries = [];
|
|
45924
45930
|
const removedEntries = [];
|
|
45925
|
-
if (extensions && (!Array.isArray(extensions) || !extensions.every(isValidExtension)) || extension && !isValidExtension({ extension })) {
|
|
45931
|
+
if (extensions && (!Array.isArray(extensions) || !extensions.every((extension2) => isValidExtension({ extension: extension2 }))) || extension && !isValidExtension({ extension })) {
|
|
45926
45932
|
return decorateResult({
|
|
45927
45933
|
context: definedAttributes({ extension, extensions }),
|
|
45928
45934
|
result: { error: INVALID_VALUES },
|
|
@@ -45984,7 +45990,7 @@ function addEventEntries(params) {
|
|
|
45984
45990
|
if (entryStageSequence)
|
|
45985
45991
|
entry.entryStageSequence = entryStageSequence;
|
|
45986
45992
|
addedParticipantIdEntries.push(entry.participantId);
|
|
45987
|
-
event.entries.push(entry);
|
|
45993
|
+
event.entries && event.entries.push(entry);
|
|
45988
45994
|
}
|
|
45989
45995
|
});
|
|
45990
45996
|
if (drawId && !isUngrouped(entryStage)) {
|
|
@@ -46005,14 +46011,14 @@ function addEventEntries(params) {
|
|
|
46005
46011
|
info = result.error;
|
|
46006
46012
|
}
|
|
46007
46013
|
}
|
|
46008
|
-
if ([
|
|
46014
|
+
if (event.eventType && [TypeEnum.Doubles, TypeEnum.Team].includes(event.eventType)) {
|
|
46009
46015
|
const enteredParticipantIds = (event.entries || []).map(
|
|
46010
46016
|
(entry) => entry.participantId
|
|
46011
46017
|
);
|
|
46012
46018
|
const ungroupedIndividualParticipantIds = (event.entries || []).filter((entry) => isUngrouped(entry.entryStatus)).map((entry) => entry.participantId);
|
|
46013
46019
|
const tournamentParticipants = tournamentRecord?.participants || [];
|
|
46014
46020
|
const groupedIndividualParticipantIds = tournamentParticipants.filter(
|
|
46015
|
-
(participant) => enteredParticipantIds.includes(participant.participantId) && [PAIR, TEAM].includes(participant.participantType)
|
|
46021
|
+
(participant) => enteredParticipantIds.includes(participant.participantId) && participant.participantType && [PAIR, TEAM].includes(participant.participantType)
|
|
46016
46022
|
).map((participant) => participant.individualParticipantIds).flat(Infinity);
|
|
46017
46023
|
const ungroupedParticipantIdsToRemove = ungroupedIndividualParticipantIds.filter(
|
|
46018
46024
|
(participantId) => groupedIndividualParticipantIds.includes(participantId)
|
|
@@ -56245,7 +56251,8 @@ function deleteDrawDefinitions({
|
|
|
56245
56251
|
drawIds = [],
|
|
56246
56252
|
auditData,
|
|
56247
56253
|
eventId,
|
|
56248
|
-
event
|
|
56254
|
+
event,
|
|
56255
|
+
force
|
|
56249
56256
|
}) {
|
|
56250
56257
|
if (!tournamentRecord)
|
|
56251
56258
|
return { error: MISSING_TOURNAMENT_RECORD };
|
|
@@ -56291,9 +56298,18 @@ function deleteDrawDefinitions({
|
|
|
56291
56298
|
qualifier,
|
|
56292
56299
|
bye
|
|
56293
56300
|
}) => ({ bye, qualifier, drawPosition, participantId });
|
|
56301
|
+
const drawIdsWithScoresPresent = [];
|
|
56294
56302
|
const filteredDrawDefinitions = event.drawDefinitions.filter(
|
|
56295
56303
|
(drawDefinition) => {
|
|
56296
56304
|
if (drawIds.includes(drawDefinition.drawId)) {
|
|
56305
|
+
const matchUps = allDrawMatchUps$1({ event, drawDefinition })?.matchUps ?? [];
|
|
56306
|
+
const scoresPresent = matchUps.some(
|
|
56307
|
+
({ score }) => scoreHasValue({ score })
|
|
56308
|
+
);
|
|
56309
|
+
if (scoresPresent && !force) {
|
|
56310
|
+
drawIdsWithScoresPresent.push(drawDefinition.drawId);
|
|
56311
|
+
return true;
|
|
56312
|
+
}
|
|
56297
56313
|
const { drawId: drawId2, drawType, drawName } = drawDefinition;
|
|
56298
56314
|
const flight = flightProfile?.flights?.find(
|
|
56299
56315
|
(flight2) => flight2.drawId === drawDefinition.drawId
|
|
@@ -56353,12 +56369,18 @@ function deleteDrawDefinitions({
|
|
|
56353
56369
|
drawId: drawId2
|
|
56354
56370
|
})
|
|
56355
56371
|
);
|
|
56356
|
-
const { matchUps } = allDrawMatchUps$1({ event, drawDefinition });
|
|
56357
56372
|
matchUps?.forEach(({ matchUpId }) => matchUpIds.push(matchUpId));
|
|
56358
56373
|
}
|
|
56359
56374
|
return !drawIds.includes(drawDefinition.drawId);
|
|
56360
56375
|
}
|
|
56361
56376
|
);
|
|
56377
|
+
if (drawIdsWithScoresPresent.length && !force) {
|
|
56378
|
+
return decorateResult({
|
|
56379
|
+
context: { drawIdsWithScoresPresent },
|
|
56380
|
+
result: { error: SCORES_PRESENT },
|
|
56381
|
+
stack
|
|
56382
|
+
});
|
|
56383
|
+
}
|
|
56362
56384
|
event.drawDefinitions = filteredDrawDefinitions;
|
|
56363
56385
|
if (flightProfile) {
|
|
56364
56386
|
const extension = {
|
|
@@ -56580,24 +56602,39 @@ function addEventEntryPairs({
|
|
|
56580
56602
|
return { error: MISSING_EVENT };
|
|
56581
56603
|
if (event.eventType !== DOUBLES$1)
|
|
56582
56604
|
return { error: INVALID_EVENT_TYPE };
|
|
56583
|
-
const
|
|
56584
|
-
const
|
|
56585
|
-
const
|
|
56586
|
-
|
|
56587
|
-
|
|
56588
|
-
|
|
56589
|
-
|
|
56590
|
-
|
|
56591
|
-
|
|
56592
|
-
|
|
56605
|
+
const existingParticipantIdPairs = [];
|
|
56606
|
+
const genderMap = /* @__PURE__ */ new Map();
|
|
56607
|
+
for (const participant of tournamentRecord.participants ?? []) {
|
|
56608
|
+
const { participantType, participantId, person, individualParticipantIds } = participant;
|
|
56609
|
+
if (participantType === INDIVIDUAL && person?.sex) {
|
|
56610
|
+
genderMap.set(participantId, person.sex);
|
|
56611
|
+
} else if (participantType === PAIR && individualParticipantIds) {
|
|
56612
|
+
existingParticipantIdPairs.push(individualParticipantIds);
|
|
56613
|
+
}
|
|
56614
|
+
}
|
|
56615
|
+
const invalidParticipantIdPairs = participantIdPairs.filter((pair) => {
|
|
56616
|
+
if (pair.length !== 2)
|
|
56617
|
+
return true;
|
|
56618
|
+
if (!genderMap.has(pair[0]) || !genderMap.has(pair[1]))
|
|
56619
|
+
return true;
|
|
56620
|
+
if (!event.gender || event.gender === ANY)
|
|
56621
|
+
return false;
|
|
56622
|
+
const participantGenders = pair.map((id) => genderMap.get(id));
|
|
56623
|
+
let invalidParticiapntGenders = event.gender === MALE && (participantGenders[0] !== MALE || participantGenders[1] !== MALE) || event.gender === FEMALE && (participantGenders[0] !== FEMALE || participantGenders[1] !== FEMALE);
|
|
56624
|
+
if (event.gender === MIXED) {
|
|
56625
|
+
participantGenders.sort();
|
|
56626
|
+
if (participantGenders[0] !== FEMALE || participantGenders[1] !== MALE)
|
|
56627
|
+
invalidParticiapntGenders = true;
|
|
56628
|
+
}
|
|
56629
|
+
return invalidParticiapntGenders;
|
|
56630
|
+
});
|
|
56593
56631
|
if (invalidParticipantIdPairs.length)
|
|
56594
56632
|
return { error: INVALID_PARTICIPANT_IDS, invalidParticipantIdPairs };
|
|
56595
|
-
const existingParticipantIdPairs = tournamentParticipants.filter((participant) => participant.participantType === PAIR).map((participant) => participant.individualParticipantIds);
|
|
56596
56633
|
const provisionalParticipants = participantIdPairs.map(
|
|
56597
|
-
(
|
|
56634
|
+
(individualParticipantIds) => ({
|
|
56598
56635
|
participantId: uuids?.pop() ?? UUID(),
|
|
56599
56636
|
participantRole: COMPETITOR,
|
|
56600
|
-
individualParticipantIds
|
|
56637
|
+
individualParticipantIds,
|
|
56601
56638
|
participantType: PAIR
|
|
56602
56639
|
})
|
|
56603
56640
|
);
|
|
@@ -59365,11 +59402,9 @@ function generateDrawDefinition(params) {
|
|
|
59365
59402
|
ignoreAllowedDrawTypes,
|
|
59366
59403
|
voluntaryConsolation,
|
|
59367
59404
|
hydrateCollections,
|
|
59368
|
-
policyDefinitions,
|
|
59369
59405
|
ignoreStageSpace,
|
|
59370
59406
|
tournamentRecord,
|
|
59371
59407
|
qualifyingOnly,
|
|
59372
|
-
seedingProfile,
|
|
59373
59408
|
tieFormatName,
|
|
59374
59409
|
drawEntries,
|
|
59375
59410
|
addToEvent,
|
|
@@ -59380,8 +59415,19 @@ function generateDrawDefinition(params) {
|
|
|
59380
59415
|
tournamentRecord,
|
|
59381
59416
|
event
|
|
59382
59417
|
}).appliedPolicies ?? {};
|
|
59383
|
-
const
|
|
59418
|
+
const policyDefinitions = params.policyDefinitions ?? {};
|
|
59419
|
+
const drawTypeCoercion = params.drawTypeCoercion ?? policyDefinitions?.[POLICY_TYPE_DRAWS]?.drawTypeCoercion ?? appliedPolicies?.[POLICY_TYPE_DRAWS]?.drawTypeCoercion ?? true;
|
|
59384
59420
|
const drawType = drawTypeCoercion && params.drawSize === 2 && DrawTypeEnum.SingleElimination || params.drawType || DrawTypeEnum.SingleElimination;
|
|
59421
|
+
const seedingPolicy = policyDefinitions?.[POLICY_TYPE_SEEDING] ?? appliedPolicies?.[POLICY_TYPE_SEEDING];
|
|
59422
|
+
const seedingProfile = params.seedingProfile ?? seedingPolicy?.seedingProfile?.drawTypes?.[drawType] ?? seedingPolicy?.seedingProfile;
|
|
59423
|
+
if (params.seedingProfile) {
|
|
59424
|
+
if (!policyDefinitions[POLICY_TYPE_SEEDING]) {
|
|
59425
|
+
policyDefinitions[POLICY_TYPE_SEEDING] = {
|
|
59426
|
+
...POLICY_SEEDING_USTA[POLICY_TYPE_SEEDING]
|
|
59427
|
+
};
|
|
59428
|
+
}
|
|
59429
|
+
policyDefinitions[POLICY_TYPE_SEEDING].seedingProfile = seedingProfile;
|
|
59430
|
+
}
|
|
59385
59431
|
const { participants, participantMap } = getParticipants$1({
|
|
59386
59432
|
withIndividualParticipants: true,
|
|
59387
59433
|
tournamentRecord
|
|
@@ -59514,7 +59560,7 @@ function generateDrawDefinition(params) {
|
|
|
59514
59560
|
}
|
|
59515
59561
|
}
|
|
59516
59562
|
}
|
|
59517
|
-
if (!appliedPolicies[POLICY_TYPE_SEEDING]) {
|
|
59563
|
+
if (!appliedPolicies[POLICY_TYPE_SEEDING] && !policyDefinitions[POLICY_TYPE_SEEDING]) {
|
|
59518
59564
|
attachPolicies({ drawDefinition, policyDefinitions: POLICY_SEEDING_USTA });
|
|
59519
59565
|
Object.assign(appliedPolicies, POLICY_SEEDING_USTA);
|
|
59520
59566
|
}
|
|
@@ -64002,8 +64048,8 @@ function generateFlight({
|
|
|
64002
64048
|
const result2 = addEventEntries({
|
|
64003
64049
|
participantIds: drawParticipantIds,
|
|
64004
64050
|
autoEntryPositions,
|
|
64051
|
+
entryStage: stage,
|
|
64005
64052
|
tournamentRecord,
|
|
64006
|
-
stage,
|
|
64007
64053
|
event
|
|
64008
64054
|
});
|
|
64009
64055
|
if (result2.error)
|
|
@@ -64214,9 +64260,9 @@ function generateEventWithFlights(params) {
|
|
|
64214
64260
|
if (eventParticipantIds.length) {
|
|
64215
64261
|
const result = addEventEntries({
|
|
64216
64262
|
participantIds: eventParticipantIds,
|
|
64263
|
+
entryStage: StageTypeEnum.Main,
|
|
64217
64264
|
autoEntryPositions,
|
|
64218
64265
|
tournamentRecord,
|
|
64219
|
-
stage: MAIN,
|
|
64220
64266
|
event
|
|
64221
64267
|
});
|
|
64222
64268
|
if (result.error)
|
|
@@ -64455,7 +64501,7 @@ function generateEventWithDraw(params) {
|
|
|
64455
64501
|
qualifyingIndex + participantsCount2
|
|
64456
64502
|
);
|
|
64457
64503
|
const result2 = addEventEntries({
|
|
64458
|
-
entryStage:
|
|
64504
|
+
entryStage: StageTypeEnum.Qualifying,
|
|
64459
64505
|
entryStageSequence,
|
|
64460
64506
|
autoEntryPositions,
|
|
64461
64507
|
tournamentRecord,
|
|
@@ -65341,6 +65387,7 @@ const utilities = {
|
|
|
65341
65387
|
categoryCanContain,
|
|
65342
65388
|
chunkArray,
|
|
65343
65389
|
compareTieFormats,
|
|
65390
|
+
constantToString,
|
|
65344
65391
|
countValues,
|
|
65345
65392
|
createMap,
|
|
65346
65393
|
dateRange,
|