tods-competition-factory 0.64.1 → 0.64.2
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/tods-competition-factory.development.cjs.js +343 -437
- 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/dist/tods-competition-factory.production.esm.min.js +1 -1
- package/dist/tods-competition-factory.production.esm.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -28040,7 +28040,7 @@ const scheduleGovernor$1 = {
|
|
|
28040
28040
|
};
|
|
28041
28041
|
|
|
28042
28042
|
function factoryVersion() {
|
|
28043
|
-
return '0.64.
|
|
28043
|
+
return '0.64.2';
|
|
28044
28044
|
}
|
|
28045
28045
|
|
|
28046
28046
|
function attachPolicies$2({
|
|
@@ -50402,6 +50402,258 @@ function addScaleItem({
|
|
|
50402
50402
|
}
|
|
50403
50403
|
}
|
|
50404
50404
|
|
|
50405
|
+
function processTieFormat({
|
|
50406
|
+
tieFormat,
|
|
50407
|
+
tieFormatName,
|
|
50408
|
+
drawSize,
|
|
50409
|
+
alternatesCount = 0
|
|
50410
|
+
}) {
|
|
50411
|
+
var _tieFormat, _tieFormat$collection;
|
|
50412
|
+
|
|
50413
|
+
let maxDoublesCount = 0,
|
|
50414
|
+
maxSinglesCount = 0;
|
|
50415
|
+
tieFormat = typeof tieFormat === 'object' ? tieFormat : tieFormatDefaults({
|
|
50416
|
+
namedFormat: tieFormatName
|
|
50417
|
+
});
|
|
50418
|
+
(_tieFormat = tieFormat) === null || _tieFormat === void 0 ? void 0 : (_tieFormat$collection = _tieFormat.collectionDefinitions) === null || _tieFormat$collection === void 0 ? void 0 : _tieFormat$collection.forEach(collectionDefinition => {
|
|
50419
|
+
// ensure every collectionDefinition has a collectionId
|
|
50420
|
+
if (!collectionDefinition.collectionId) collectionDefinition.collectionId = UUID();
|
|
50421
|
+
|
|
50422
|
+
if ((collectionDefinition === null || collectionDefinition === void 0 ? void 0 : collectionDefinition.matchUpType) === DOUBLES$1) {
|
|
50423
|
+
const doublesCount = collectionDefinition.matchUpCount;
|
|
50424
|
+
maxDoublesCount = Math.max(maxDoublesCount, doublesCount);
|
|
50425
|
+
}
|
|
50426
|
+
|
|
50427
|
+
if ((collectionDefinition === null || collectionDefinition === void 0 ? void 0 : collectionDefinition.matchUpType) === SINGLES$1) {
|
|
50428
|
+
const singlescount = collectionDefinition.matchUpCount;
|
|
50429
|
+
maxSinglesCount = Math.max(maxSinglesCount, singlescount);
|
|
50430
|
+
}
|
|
50431
|
+
});
|
|
50432
|
+
const teamSize = Math.max(maxSinglesCount, maxDoublesCount * 2);
|
|
50433
|
+
const maxDoublesDraw = maxDoublesCount * (drawSize + alternatesCount);
|
|
50434
|
+
const maxSinglesDraw = maxSinglesCount * (drawSize + alternatesCount);
|
|
50435
|
+
return {
|
|
50436
|
+
maxDoublesDraw,
|
|
50437
|
+
maxSinglesDraw,
|
|
50438
|
+
teamSize
|
|
50439
|
+
};
|
|
50440
|
+
}
|
|
50441
|
+
|
|
50442
|
+
function getParticipantsCount({
|
|
50443
|
+
participantsProfile,
|
|
50444
|
+
eventProfiles,
|
|
50445
|
+
drawProfiles
|
|
50446
|
+
}) {
|
|
50447
|
+
let {
|
|
50448
|
+
participantsCount,
|
|
50449
|
+
participantType = INDIVIDUAL$1
|
|
50450
|
+
} = participantsProfile || {};
|
|
50451
|
+
const specifiedParicipantsCount = participantsCount || 0; // capture this to ensure calculated participantsCount is not below
|
|
50452
|
+
|
|
50453
|
+
let largestDoublesDraw = 0,
|
|
50454
|
+
largestSinglesDraw = 0,
|
|
50455
|
+
largestTeamSize = 0,
|
|
50456
|
+
largestTeamDraw = 0,
|
|
50457
|
+
uniqueParticipantsCount = 0;
|
|
50458
|
+
|
|
50459
|
+
const processDrawProfile = ({
|
|
50460
|
+
alternatesCount = 0,
|
|
50461
|
+
uniqueParticipants,
|
|
50462
|
+
tieFormatName,
|
|
50463
|
+
drawSize = 0,
|
|
50464
|
+
eventType,
|
|
50465
|
+
tieFormat,
|
|
50466
|
+
category,
|
|
50467
|
+
gender,
|
|
50468
|
+
stage
|
|
50469
|
+
}) => {
|
|
50470
|
+
const isDoubles = eventType === DOUBLES;
|
|
50471
|
+
const isTeam = eventType === TEAM$2;
|
|
50472
|
+
const requiresUniqueParticipants = uniqueParticipants || stage === QUALIFYING || category || gender;
|
|
50473
|
+
|
|
50474
|
+
if (requiresUniqueParticipants) {
|
|
50475
|
+
if (isDoubles) {
|
|
50476
|
+
uniqueParticipantsCount += (drawSize + alternatesCount) * 2;
|
|
50477
|
+
} else {
|
|
50478
|
+
uniqueParticipantsCount += drawSize + alternatesCount;
|
|
50479
|
+
}
|
|
50480
|
+
} else {
|
|
50481
|
+
if (isTeam) {
|
|
50482
|
+
largestTeamDraw = Math.max(largestTeamDraw, drawSize + alternatesCount);
|
|
50483
|
+
tieFormat = typeof tieFormat === 'object' ? tieFormat : tieFormatDefaults({
|
|
50484
|
+
namedFormat: tieFormatName
|
|
50485
|
+
});
|
|
50486
|
+
const {
|
|
50487
|
+
teamSize,
|
|
50488
|
+
maxDoublesDraw,
|
|
50489
|
+
maxSinglesDraw
|
|
50490
|
+
} = processTieFormat({
|
|
50491
|
+
alternatesCount,
|
|
50492
|
+
tieFormatName,
|
|
50493
|
+
tieFormat,
|
|
50494
|
+
drawSize
|
|
50495
|
+
});
|
|
50496
|
+
largestTeamSize = Math.max(largestTeamSize, teamSize);
|
|
50497
|
+
largestDoublesDraw = Math.max(largestDoublesDraw, maxDoublesDraw);
|
|
50498
|
+
largestSinglesDraw = Math.max(largestSinglesDraw, maxSinglesDraw);
|
|
50499
|
+
}
|
|
50500
|
+
|
|
50501
|
+
if (isDoubles && drawSize + alternatesCount && drawSize + alternatesCount > largestDoublesDraw) {
|
|
50502
|
+
largestDoublesDraw = drawSize + alternatesCount;
|
|
50503
|
+
}
|
|
50504
|
+
|
|
50505
|
+
if (!isDoubles && !isTeam && drawSize && drawSize > largestSinglesDraw) {
|
|
50506
|
+
largestSinglesDraw = drawSize + alternatesCount;
|
|
50507
|
+
}
|
|
50508
|
+
}
|
|
50509
|
+
};
|
|
50510
|
+
|
|
50511
|
+
eventProfiles === null || eventProfiles === void 0 ? void 0 : eventProfiles.forEach(eventProfile => {
|
|
50512
|
+
const {
|
|
50513
|
+
tieFormatName: eventTieFormatName,
|
|
50514
|
+
tieFormat: eventTieFormat,
|
|
50515
|
+
drawProfiles,
|
|
50516
|
+
eventType,
|
|
50517
|
+
category,
|
|
50518
|
+
gender
|
|
50519
|
+
} = eventProfile;
|
|
50520
|
+
|
|
50521
|
+
if (drawProfiles) {
|
|
50522
|
+
for (const drawProfile of drawProfiles) {
|
|
50523
|
+
const {
|
|
50524
|
+
tieFormatName,
|
|
50525
|
+
tieFormat
|
|
50526
|
+
} = drawProfile;
|
|
50527
|
+
processDrawProfile({ ...drawProfile,
|
|
50528
|
+
tieFormatName: tieFormatName || eventTieFormatName,
|
|
50529
|
+
tieFormat: tieFormat || eventTieFormat,
|
|
50530
|
+
eventType,
|
|
50531
|
+
category,
|
|
50532
|
+
gender
|
|
50533
|
+
});
|
|
50534
|
+
}
|
|
50535
|
+
}
|
|
50536
|
+
});
|
|
50537
|
+
|
|
50538
|
+
if (drawProfiles) {
|
|
50539
|
+
for (const drawProfile of drawProfiles) {
|
|
50540
|
+
processDrawProfile(drawProfile);
|
|
50541
|
+
}
|
|
50542
|
+
}
|
|
50543
|
+
|
|
50544
|
+
const individualCompetitorsCount = Math.max(largestTeamDraw * largestTeamSize, largestDoublesDraw * 2, largestSinglesDraw);
|
|
50545
|
+
if (largestDoublesDraw) participantType = PAIR$1;
|
|
50546
|
+
if ((participantsCount || specifiedParicipantsCount) < individualCompetitorsCount) participantsCount = individualCompetitorsCount;
|
|
50547
|
+
|
|
50548
|
+
if (participantsCount && largestDoublesDraw && [PAIR$1, TEAM$2].includes(participantType)) {
|
|
50549
|
+
// if we are generating PAIRs or TEAMs...
|
|
50550
|
+
if (largestSinglesDraw && Math.floor(largestSinglesDraw / 2) > largestDoublesDraw) {
|
|
50551
|
+
// if the half the singles draw is still larger than doubles draw
|
|
50552
|
+
participantsCount = Math.floor(largestSinglesDraw / 2);
|
|
50553
|
+
} else if (!largestSinglesDraw || largestDoublesDraw * 2 >= largestSinglesDraw) {
|
|
50554
|
+
// otherwise participantsCount can be cut in half
|
|
50555
|
+
participantsCount = Math.ceil(participantsCount / 2);
|
|
50556
|
+
}
|
|
50557
|
+
} // if (participantsCount === undefined) participantsCount = 32;
|
|
50558
|
+
|
|
50559
|
+
|
|
50560
|
+
if (participantsCount === undefined) {
|
|
50561
|
+
participantsCount = !(eventProfiles !== null && eventProfiles !== void 0 && eventProfiles.length) && !(drawProfiles !== null && drawProfiles !== void 0 && drawProfiles.length) ? 32 : 0;
|
|
50562
|
+
}
|
|
50563
|
+
|
|
50564
|
+
if (participantsCount < specifiedParicipantsCount) participantsCount = specifiedParicipantsCount;
|
|
50565
|
+
return {
|
|
50566
|
+
largestTeamDraw,
|
|
50567
|
+
largestTeamSize,
|
|
50568
|
+
participantsCount,
|
|
50569
|
+
participantType,
|
|
50570
|
+
uniqueParticipantsCount
|
|
50571
|
+
};
|
|
50572
|
+
}
|
|
50573
|
+
|
|
50574
|
+
function addTournamentParticipants({
|
|
50575
|
+
participantsProfile,
|
|
50576
|
+
tournamentRecord,
|
|
50577
|
+
eventProfiles,
|
|
50578
|
+
drawProfiles,
|
|
50579
|
+
startDate,
|
|
50580
|
+
uuids
|
|
50581
|
+
}) {
|
|
50582
|
+
const {
|
|
50583
|
+
participantsCount,
|
|
50584
|
+
participantType,
|
|
50585
|
+
largestTeamDraw,
|
|
50586
|
+
largestTeamSize
|
|
50587
|
+
} = getParticipantsCount({
|
|
50588
|
+
participantsProfile,
|
|
50589
|
+
eventProfiles,
|
|
50590
|
+
drawProfiles
|
|
50591
|
+
});
|
|
50592
|
+
const {
|
|
50593
|
+
nationalityCodesCount,
|
|
50594
|
+
nationalityCodeType,
|
|
50595
|
+
valuesInstanceLimit,
|
|
50596
|
+
nationalityCodes,
|
|
50597
|
+
personExtensions,
|
|
50598
|
+
addressProps,
|
|
50599
|
+
personData,
|
|
50600
|
+
personIds,
|
|
50601
|
+
inContext,
|
|
50602
|
+
teamKey,
|
|
50603
|
+
sex
|
|
50604
|
+
} = participantsProfile || {};
|
|
50605
|
+
const {
|
|
50606
|
+
participants
|
|
50607
|
+
} = generateParticipants({
|
|
50608
|
+
consideredDate: startDate,
|
|
50609
|
+
valuesInstanceLimit,
|
|
50610
|
+
nationalityCodesCount,
|
|
50611
|
+
nationalityCodeType,
|
|
50612
|
+
nationalityCodes,
|
|
50613
|
+
personExtensions,
|
|
50614
|
+
addressProps,
|
|
50615
|
+
personData,
|
|
50616
|
+
sex,
|
|
50617
|
+
participantsCount,
|
|
50618
|
+
participantType,
|
|
50619
|
+
personIds,
|
|
50620
|
+
uuids,
|
|
50621
|
+
inContext
|
|
50622
|
+
});
|
|
50623
|
+
let result = addParticipants({
|
|
50624
|
+
tournamentRecord,
|
|
50625
|
+
participants
|
|
50626
|
+
});
|
|
50627
|
+
if (!result.success) return result;
|
|
50628
|
+
|
|
50629
|
+
if (teamKey) {
|
|
50630
|
+
const result = generateTeamsFromParticipantAttribute({
|
|
50631
|
+
tournamentRecord,
|
|
50632
|
+
...teamKey
|
|
50633
|
+
});
|
|
50634
|
+
if (result.error) return result;
|
|
50635
|
+
} // generate Team participants
|
|
50636
|
+
|
|
50637
|
+
|
|
50638
|
+
const allIndividualParticipantIds = participants.filter(({
|
|
50639
|
+
participantType
|
|
50640
|
+
}) => participantType === INDIVIDUAL$1).map(getParticipantId);
|
|
50641
|
+
const teamParticipants = generateRange(0, largestTeamDraw).map(teamIndex => {
|
|
50642
|
+
const individualParticipantIds = allIndividualParticipantIds.slice(teamIndex * largestTeamSize, (teamIndex + 1) * largestTeamSize);
|
|
50643
|
+
return {
|
|
50644
|
+
participantName: `Team ${teamIndex + 1}`,
|
|
50645
|
+
participantRole: COMPETITOR,
|
|
50646
|
+
participantType: TEAM$1,
|
|
50647
|
+
participantId: UUID(),
|
|
50648
|
+
individualParticipantIds
|
|
50649
|
+
};
|
|
50650
|
+
});
|
|
50651
|
+
return addParticipants({
|
|
50652
|
+
tournamentRecord,
|
|
50653
|
+
participants: teamParticipants
|
|
50654
|
+
});
|
|
50655
|
+
}
|
|
50656
|
+
|
|
50405
50657
|
function generateEventParticipants({
|
|
50406
50658
|
uniqueParticipantsCount,
|
|
50407
50659
|
participantsProfile,
|
|
@@ -50429,6 +50681,7 @@ function generateEventParticipants({
|
|
|
50429
50681
|
const mainParticipantsCount = uniqueParticipantsCount[MAIN] || 0;
|
|
50430
50682
|
const qualifyingParticipantsCount = uniqueParticipantsCount[QUALIFYING] || 0;
|
|
50431
50683
|
const participantsCount = mainParticipantsCount + qualifyingParticipantsCount;
|
|
50684
|
+
const sex = [MALE, FEMALE].includes(gender) ? gender : undefined;
|
|
50432
50685
|
const {
|
|
50433
50686
|
participants: uniqueFlightParticipants
|
|
50434
50687
|
} = generateParticipants({
|
|
@@ -50443,11 +50696,11 @@ function generateEventParticipants({
|
|
|
50443
50696
|
ratingsParameters,
|
|
50444
50697
|
nationalityCodes,
|
|
50445
50698
|
addressProps,
|
|
50446
|
-
sex: gender,
|
|
50447
50699
|
personIds,
|
|
50448
50700
|
inContext,
|
|
50449
50701
|
category,
|
|
50450
|
-
uuids
|
|
50702
|
+
uuids,
|
|
50703
|
+
sex
|
|
50451
50704
|
});
|
|
50452
50705
|
let result = addParticipants({
|
|
50453
50706
|
participants: uniqueFlightParticipants,
|
|
@@ -50630,56 +50883,22 @@ function modifyTournamentRecord({
|
|
|
50630
50883
|
};
|
|
50631
50884
|
const allUniqueParticipantIds = [];
|
|
50632
50885
|
const drawIds = [];
|
|
50886
|
+
eventProfiles === null || eventProfiles === void 0 ? void 0 : eventProfiles.forEach(eventProfile => {
|
|
50887
|
+
const event = tournamentRecord.events.find((event, index) => eventProfile.eventIndex !== undefined && index === eventProfile.eventIndex || eventProfile.eventName && event.eventName === eventProfile.eventName || eventProfile.eventId && event.eventId === eventProfile.eventId);
|
|
50633
50888
|
|
|
50634
|
-
|
|
50635
|
-
|
|
50636
|
-
nationalityCodesCount,
|
|
50637
|
-
nationalityCodeType,
|
|
50638
|
-
valuesInstanceLimit,
|
|
50639
|
-
participantsCount,
|
|
50640
|
-
nationalityCodes,
|
|
50641
|
-
personExtensions,
|
|
50642
|
-
participantType,
|
|
50643
|
-
addressProps,
|
|
50644
|
-
personData,
|
|
50645
|
-
personIds,
|
|
50646
|
-
inContext,
|
|
50647
|
-
teamKey,
|
|
50648
|
-
uuids,
|
|
50649
|
-
sex
|
|
50650
|
-
} = participantsProfile || {};
|
|
50651
|
-
const {
|
|
50652
|
-
participants
|
|
50653
|
-
} = generateParticipants({
|
|
50654
|
-
consideredDate: tournamentRecord.startDate,
|
|
50655
|
-
valuesInstanceLimit,
|
|
50656
|
-
nationalityCodesCount,
|
|
50657
|
-
nationalityCodeType,
|
|
50658
|
-
nationalityCodes,
|
|
50659
|
-
personExtensions,
|
|
50660
|
-
addressProps,
|
|
50661
|
-
personData,
|
|
50662
|
-
sex,
|
|
50663
|
-
participantsCount,
|
|
50664
|
-
participantType,
|
|
50665
|
-
personIds,
|
|
50666
|
-
uuids,
|
|
50667
|
-
inContext
|
|
50668
|
-
});
|
|
50669
|
-
let result = addParticipants({
|
|
50670
|
-
tournamentRecord,
|
|
50671
|
-
participants
|
|
50672
|
-
});
|
|
50673
|
-
if (result.error) return result;
|
|
50674
|
-
|
|
50675
|
-
if (teamKey) {
|
|
50676
|
-
const result = generateTeamsFromParticipantAttribute({
|
|
50677
|
-
tournamentRecord,
|
|
50678
|
-
...teamKey
|
|
50679
|
-
});
|
|
50680
|
-
if (result.error) return result;
|
|
50889
|
+
if (event !== null && event !== void 0 && event.gender) {
|
|
50890
|
+
eventProfile.gender = event.gender;
|
|
50681
50891
|
}
|
|
50682
|
-
}
|
|
50892
|
+
});
|
|
50893
|
+
const result = addTournamentParticipants({
|
|
50894
|
+
startDate: tournamentRecord.startDate,
|
|
50895
|
+
participantsProfile,
|
|
50896
|
+
tournamentRecord,
|
|
50897
|
+
eventProfiles,
|
|
50898
|
+
// drawProfiles,
|
|
50899
|
+
uuids
|
|
50900
|
+
});
|
|
50901
|
+
if (!result.success) return result;
|
|
50683
50902
|
|
|
50684
50903
|
if (eventProfiles) {
|
|
50685
50904
|
for (const eventProfile of eventProfiles) {
|
|
@@ -50865,12 +51084,6 @@ function generateSchedulingProfile({
|
|
|
50865
51084
|
};
|
|
50866
51085
|
}
|
|
50867
51086
|
|
|
50868
|
-
// import { addDrawDefinition } from '../../tournamentEngine/governors/eventGovernor/drawDefinitions/addDrawDefinition';
|
|
50869
|
-
// import {
|
|
50870
|
-
// MAIN,
|
|
50871
|
-
// ROUND_ROBIN_WITH_PLAYOFF,
|
|
50872
|
-
// } from '../../constants/drawDefinitionConstants';
|
|
50873
|
-
|
|
50874
51087
|
function generateEventWithFlights({
|
|
50875
51088
|
allUniqueParticipantIds,
|
|
50876
51089
|
matchUpStatusProfile,
|
|
@@ -50881,7 +51094,6 @@ function generateEventWithFlights({
|
|
|
50881
51094
|
ratingsParameters,
|
|
50882
51095
|
tournamentRecord,
|
|
50883
51096
|
eventProfile,
|
|
50884
|
-
// startDate,
|
|
50885
51097
|
uuids
|
|
50886
51098
|
}) {
|
|
50887
51099
|
let gender = eventProfile.gender;
|
|
@@ -50958,213 +51170,62 @@ function generateEventWithFlights({
|
|
|
50958
51170
|
const extensions = eventExtensions.filter(isValidExtension);
|
|
50959
51171
|
if (extensions !== null && extensions !== void 0 && extensions.length) Object.assign(newEvent, {
|
|
50960
51172
|
extensions
|
|
50961
|
-
});
|
|
50962
|
-
}
|
|
50963
|
-
|
|
50964
|
-
if (typeof policyDefinitions === 'object') {
|
|
50965
|
-
for (const policyType of Object.keys(policyDefinitions)) {
|
|
50966
|
-
attachEventPolicies({
|
|
50967
|
-
policyDefinitions: {
|
|
50968
|
-
[policyType]: policyDefinitions[policyType]
|
|
50969
|
-
},
|
|
50970
|
-
event: newEvent
|
|
50971
|
-
});
|
|
50972
|
-
}
|
|
50973
|
-
}
|
|
50974
|
-
|
|
50975
|
-
let result = addEvent({
|
|
50976
|
-
tournamentRecord,
|
|
50977
|
-
event: newEvent
|
|
50978
|
-
});
|
|
50979
|
-
if (result.error) return result;
|
|
50980
|
-
const {
|
|
50981
|
-
event
|
|
50982
|
-
} = result; // Generate Flights ---------------------------------------------------------
|
|
50983
|
-
|
|
50984
|
-
const {
|
|
50985
|
-
stageParticipants
|
|
50986
|
-
} = getStageParticipants({
|
|
50987
|
-
allUniqueParticipantIds,
|
|
50988
|
-
stageParticipantsCount,
|
|
50989
|
-
eventParticipantType,
|
|
50990
|
-
targetParticipants
|
|
50991
|
-
});
|
|
50992
|
-
result = generateFlights({
|
|
50993
|
-
uniqueDrawParticipants,
|
|
50994
|
-
autoEntryPositions,
|
|
50995
|
-
stageParticipants,
|
|
50996
|
-
tournamentRecord,
|
|
50997
|
-
drawProfiles,
|
|
50998
|
-
category,
|
|
50999
|
-
gender,
|
|
51000
|
-
event
|
|
51001
|
-
});
|
|
51002
|
-
if (result.error) return result;
|
|
51003
|
-
result = generateFlightDrawDefinitions({
|
|
51004
|
-
completeAllMatchUps,
|
|
51005
|
-
matchUpStatusProfile,
|
|
51006
|
-
randomWinningSide,
|
|
51007
|
-
tournamentRecord,
|
|
51008
|
-
drawProfiles,
|
|
51009
|
-
event
|
|
51010
|
-
});
|
|
51011
|
-
if (result.error) return result;
|
|
51012
|
-
const drawIds = result.drawIds;
|
|
51013
|
-
/*
|
|
51014
|
-
const drawIds = [];
|
|
51015
|
-
const { flightProfile } = getFlightProfile({ event });
|
|
51016
|
-
if (Array.isArray(flightProfile?.flights)) {
|
|
51017
|
-
for (const [index, flight] of flightProfile.flights.entries()) {
|
|
51018
|
-
const { drawId, stage, drawName, drawEntries } = flight;
|
|
51019
|
-
drawIds.push(flight.drawId);
|
|
51020
|
-
const drawProfile = drawProfiles[index];
|
|
51021
|
-
const { seedsCount, generate = true } = drawProfile || {};
|
|
51022
|
-
if (generate) {
|
|
51023
|
-
const drawParticipantIds = drawEntries
|
|
51024
|
-
.filter(hasParticipantId)
|
|
51025
|
-
.map(getParticipantId);
|
|
51026
|
-
const seedingScaleName = categoryName || eventName;
|
|
51027
|
-
if (
|
|
51028
|
-
tournamentRecord &&
|
|
51029
|
-
seedsCount &&
|
|
51030
|
-
seedsCount <= drawParticipantIds.length
|
|
51031
|
-
) {
|
|
51032
|
-
const scaleValues = generateRange(1, seedsCount + 1);
|
|
51033
|
-
scaleValues.forEach((scaleValue, index) => {
|
|
51034
|
-
let scaleItem = {
|
|
51035
|
-
scaleValue,
|
|
51036
|
-
scaleName: seedingScaleName,
|
|
51037
|
-
scaleType: SEEDING,
|
|
51038
|
-
eventType,
|
|
51039
|
-
scaleDate: startDate,
|
|
51040
|
-
};
|
|
51041
|
-
const participantId = drawParticipantIds[index];
|
|
51042
|
-
setParticipantScaleItem({
|
|
51043
|
-
tournamentRecord,
|
|
51044
|
-
participantId,
|
|
51045
|
-
scaleItem,
|
|
51046
|
-
});
|
|
51047
|
-
});
|
|
51048
|
-
}
|
|
51049
|
-
let result = generateDrawDefinition({
|
|
51050
|
-
...drawProfile,
|
|
51051
|
-
matchUpType: eventType,
|
|
51052
|
-
seedingScaleName,
|
|
51053
|
-
tournamentRecord,
|
|
51054
|
-
isMock: true,
|
|
51055
|
-
drawEntries,
|
|
51056
|
-
drawName,
|
|
51057
|
-
drawId,
|
|
51058
|
-
event,
|
|
51059
|
-
stage,
|
|
51060
|
-
});
|
|
51061
|
-
const { drawDefinition, error } = result;
|
|
51062
|
-
if (error) return { error };
|
|
51063
|
-
const drawExtensions = drawProfiles[index]?.drawExtensions;
|
|
51064
|
-
if (Array.isArray(drawExtensions)) {
|
|
51065
|
-
drawExtensions
|
|
51066
|
-
.filter(isValidExtension)
|
|
51067
|
-
.forEach((extension) =>
|
|
51068
|
-
addExtension({ element: drawDefinition, extension })
|
|
51069
|
-
);
|
|
51070
|
-
}
|
|
51071
|
-
result = addDrawDefinition({
|
|
51072
|
-
drawDefinition,
|
|
51073
|
-
event,
|
|
51074
|
-
});
|
|
51075
|
-
if (result.error) return result;
|
|
51076
|
-
if (drawProfile?.withPlayoffs) {
|
|
51077
|
-
const structureId = drawDefinition.structures[0].structureId;
|
|
51078
|
-
const result = addPlayoffStructures({
|
|
51079
|
-
idPrefix: drawProfile.idPrefix,
|
|
51080
|
-
...drawProfile.withPlayoffs,
|
|
51081
|
-
tournamentRecord,
|
|
51082
|
-
drawDefinition,
|
|
51083
|
-
isMock: true,
|
|
51084
|
-
structureId,
|
|
51085
|
-
event,
|
|
51086
|
-
});
|
|
51087
|
-
if (result?.error) return result;
|
|
51088
|
-
}
|
|
51089
|
-
// TODO: enable { outcomes: [] } in eventProfile: { drawProfiles }
|
|
51090
|
-
const manual = drawProfile?.automated === false;
|
|
51091
|
-
if (!manual && completeAllMatchUps) {
|
|
51092
|
-
const matchUpFormat = drawProfile?.matchUpFormat;
|
|
51093
|
-
const result = completeDrawMatchUps({
|
|
51094
|
-
matchUpStatusProfile,
|
|
51095
|
-
completeAllMatchUps,
|
|
51096
|
-
randomWinningSide,
|
|
51097
|
-
drawDefinition,
|
|
51098
|
-
matchUpFormat,
|
|
51099
|
-
});
|
|
51100
|
-
if (result.error) return result;
|
|
51101
|
-
if (drawProfile?.drawType === ROUND_ROBIN_WITH_PLAYOFF) {
|
|
51102
|
-
const mainStructure = drawDefinition.structures.find(
|
|
51103
|
-
(structure) => structure.stage === MAIN
|
|
51104
|
-
);
|
|
51105
|
-
let result = automatedPlayoffPositioning({
|
|
51106
|
-
structureId: mainStructure.structureId,
|
|
51107
|
-
tournamentRecord,
|
|
51108
|
-
drawDefinition,
|
|
51109
|
-
event,
|
|
51110
|
-
});
|
|
51111
|
-
if (result.error) return result;
|
|
51112
|
-
result = completeDrawMatchUps({
|
|
51113
|
-
completeAllMatchUps,
|
|
51114
|
-
matchUpStatusProfile,
|
|
51115
|
-
randomWinningSide,
|
|
51116
|
-
matchUpFormat,
|
|
51117
|
-
drawDefinition,
|
|
51118
|
-
});
|
|
51119
|
-
if (result.error) return result;
|
|
51120
|
-
}
|
|
51121
|
-
}
|
|
51122
|
-
}
|
|
51123
|
-
}
|
|
51173
|
+
});
|
|
51124
51174
|
}
|
|
51125
|
-
*/
|
|
51126
|
-
|
|
51127
|
-
return {
|
|
51128
|
-
drawIds,
|
|
51129
|
-
eventId,
|
|
51130
|
-
uniqueParticipantIds
|
|
51131
|
-
};
|
|
51132
|
-
}
|
|
51133
51175
|
|
|
51134
|
-
|
|
51135
|
-
|
|
51136
|
-
|
|
51137
|
-
|
|
51138
|
-
|
|
51139
|
-
}
|
|
51140
|
-
|
|
51176
|
+
if (typeof policyDefinitions === 'object') {
|
|
51177
|
+
for (const policyType of Object.keys(policyDefinitions)) {
|
|
51178
|
+
attachEventPolicies({
|
|
51179
|
+
policyDefinitions: {
|
|
51180
|
+
[policyType]: policyDefinitions[policyType]
|
|
51181
|
+
},
|
|
51182
|
+
event: newEvent
|
|
51183
|
+
});
|
|
51184
|
+
}
|
|
51185
|
+
}
|
|
51141
51186
|
|
|
51142
|
-
let
|
|
51143
|
-
|
|
51144
|
-
|
|
51145
|
-
namedFormat: tieFormatName
|
|
51187
|
+
let result = addEvent({
|
|
51188
|
+
tournamentRecord,
|
|
51189
|
+
event: newEvent
|
|
51146
51190
|
});
|
|
51147
|
-
|
|
51148
|
-
|
|
51149
|
-
|
|
51150
|
-
|
|
51151
|
-
if ((collectionDefinition === null || collectionDefinition === void 0 ? void 0 : collectionDefinition.matchUpType) === DOUBLES$1) {
|
|
51152
|
-
const doublesCount = collectionDefinition.matchUpCount;
|
|
51153
|
-
maxDoublesCount = Math.max(maxDoublesCount, doublesCount);
|
|
51154
|
-
}
|
|
51191
|
+
if (result.error) return result;
|
|
51192
|
+
const {
|
|
51193
|
+
event
|
|
51194
|
+
} = result; // Generate Flights ---------------------------------------------------------
|
|
51155
51195
|
|
|
51156
|
-
|
|
51157
|
-
|
|
51158
|
-
|
|
51159
|
-
|
|
51196
|
+
const {
|
|
51197
|
+
stageParticipants
|
|
51198
|
+
} = getStageParticipants({
|
|
51199
|
+
allUniqueParticipantIds,
|
|
51200
|
+
stageParticipantsCount,
|
|
51201
|
+
eventParticipantType,
|
|
51202
|
+
targetParticipants
|
|
51160
51203
|
});
|
|
51161
|
-
|
|
51162
|
-
|
|
51163
|
-
|
|
51204
|
+
result = generateFlights({
|
|
51205
|
+
uniqueDrawParticipants,
|
|
51206
|
+
autoEntryPositions,
|
|
51207
|
+
stageParticipants,
|
|
51208
|
+
tournamentRecord,
|
|
51209
|
+
drawProfiles,
|
|
51210
|
+
category,
|
|
51211
|
+
gender,
|
|
51212
|
+
event
|
|
51213
|
+
});
|
|
51214
|
+
if (result.error) return result;
|
|
51215
|
+
result = generateFlightDrawDefinitions({
|
|
51216
|
+
completeAllMatchUps,
|
|
51217
|
+
matchUpStatusProfile,
|
|
51218
|
+
randomWinningSide,
|
|
51219
|
+
tournamentRecord,
|
|
51220
|
+
drawProfiles,
|
|
51221
|
+
event
|
|
51222
|
+
});
|
|
51223
|
+
if (result.error) return result;
|
|
51224
|
+
const drawIds = result.drawIds;
|
|
51164
51225
|
return {
|
|
51165
|
-
|
|
51166
|
-
|
|
51167
|
-
|
|
51226
|
+
drawIds,
|
|
51227
|
+
eventId,
|
|
51228
|
+
uniqueParticipantIds
|
|
51168
51229
|
};
|
|
51169
51230
|
}
|
|
51170
51231
|
|
|
@@ -51279,7 +51340,7 @@ function generateEventWithDraw({
|
|
|
51279
51340
|
});
|
|
51280
51341
|
|
|
51281
51342
|
if (tournamentRecord) {
|
|
51282
|
-
|
|
51343
|
+
const result = addParticipants({
|
|
51283
51344
|
tournamentRecord,
|
|
51284
51345
|
participants: unique
|
|
51285
51346
|
});
|
|
@@ -51339,22 +51400,26 @@ function generateEventWithDraw({
|
|
|
51339
51400
|
participantId
|
|
51340
51401
|
}) => !allUniqueParticipantIds.includes(participantId));
|
|
51341
51402
|
const participantIds = consideredParticipants.slice(0, participantsCount).map(p => p.participantId);
|
|
51342
|
-
|
|
51343
|
-
|
|
51344
|
-
|
|
51345
|
-
|
|
51346
|
-
|
|
51347
|
-
|
|
51348
|
-
|
|
51349
|
-
|
|
51403
|
+
|
|
51404
|
+
if (participantIds !== null && participantIds !== void 0 && participantIds.length) {
|
|
51405
|
+
const result = addEventEntries({
|
|
51406
|
+
autoEntryPositions,
|
|
51407
|
+
entryStage: stage,
|
|
51408
|
+
tournamentRecord,
|
|
51409
|
+
participantIds,
|
|
51410
|
+
event
|
|
51411
|
+
});
|
|
51412
|
+
if (result.error) return result;
|
|
51413
|
+
} // alternates can still be taken from existing participants
|
|
51350
51414
|
// when unique participants are used for DIRECT_ACCEPTANCE entries
|
|
51351
51415
|
|
|
51416
|
+
|
|
51352
51417
|
const alternatesParticipantIds = excessParticipantAlternates && (tournamentRecord === null || tournamentRecord === void 0 ? void 0 : (_tournamentRecord$par = tournamentRecord.participants) === null || _tournamentRecord$par === void 0 ? void 0 : _tournamentRecord$par.filter(({
|
|
51353
51418
|
participantId
|
|
51354
51419
|
}) => !participantIds.includes(participantId)).filter(isEventParticipantType).filter(isEventGender).slice(0, alternatesCount || drawSize - participantsCount).map(p => p.participantId));
|
|
51355
51420
|
|
|
51356
51421
|
if (alternatesParticipantIds !== null && alternatesParticipantIds !== void 0 && alternatesParticipantIds.length) {
|
|
51357
|
-
result = addEventEntries({
|
|
51422
|
+
const result = addEventEntries({
|
|
51358
51423
|
participantIds: alternatesParticipantIds,
|
|
51359
51424
|
autoEntryPositions: false,
|
|
51360
51425
|
entryStatus: ALTERNATE,
|
|
@@ -51526,9 +51591,6 @@ function generateEventWithDraw({
|
|
|
51526
51591
|
}
|
|
51527
51592
|
}
|
|
51528
51593
|
|
|
51529
|
-
if (result.error) return {
|
|
51530
|
-
error: result.error
|
|
51531
|
-
};
|
|
51532
51594
|
return { ...SUCCESS,
|
|
51533
51595
|
event: definedAttributes(event),
|
|
51534
51596
|
uniqueParticipantIds,
|
|
@@ -51631,12 +51693,6 @@ function generateTournamentRecord({
|
|
|
51631
51693
|
goesTo,
|
|
51632
51694
|
uuids
|
|
51633
51695
|
} = {}) {
|
|
51634
|
-
let {
|
|
51635
|
-
participantsCount,
|
|
51636
|
-
participantType = INDIVIDUAL$1
|
|
51637
|
-
} = participantsProfile || {};
|
|
51638
|
-
const specifiedParicipantsCount = participantsCount || 0; // capture this to ensure calculated participantsCount is not below
|
|
51639
|
-
|
|
51640
51696
|
if (startDate && !isValidDateString(startDate) || endDate && !isValidDateString(endDate)) return {
|
|
51641
51697
|
error: INVALID_DATE
|
|
51642
51698
|
};
|
|
@@ -51678,165 +51734,13 @@ function generateTournamentRecord({
|
|
|
51678
51734
|
}
|
|
51679
51735
|
}
|
|
51680
51736
|
|
|
51681
|
-
|
|
51682
|
-
|
|
51683
|
-
largestTeamSize = 0,
|
|
51684
|
-
largestTeamDraw = 0;
|
|
51685
|
-
|
|
51686
|
-
const processDrawProfile = ({
|
|
51687
|
-
alternatesCount = 0,
|
|
51688
|
-
uniqueParticipants,
|
|
51689
|
-
tieFormatName,
|
|
51690
|
-
drawSize = 0,
|
|
51691
|
-
eventType,
|
|
51692
|
-
tieFormat,
|
|
51693
|
-
category,
|
|
51694
|
-
gender,
|
|
51695
|
-
stage
|
|
51696
|
-
}) => {
|
|
51697
|
-
const isDoubles = eventType === DOUBLES;
|
|
51698
|
-
const isTeam = eventType === TEAM$2;
|
|
51699
|
-
const requiresUniqueParticipants = uniqueParticipants || stage === QUALIFYING || category || gender;
|
|
51700
|
-
|
|
51701
|
-
if (isTeam && !requiresUniqueParticipants) {
|
|
51702
|
-
largestTeamDraw = Math.max(largestTeamDraw, drawSize + alternatesCount);
|
|
51703
|
-
tieFormat = typeof tieFormat === 'object' ? tieFormat : tieFormatDefaults({
|
|
51704
|
-
namedFormat: tieFormatName
|
|
51705
|
-
});
|
|
51706
|
-
const {
|
|
51707
|
-
teamSize,
|
|
51708
|
-
maxDoublesDraw,
|
|
51709
|
-
maxSinglesDraw
|
|
51710
|
-
} = processTieFormat({
|
|
51711
|
-
alternatesCount,
|
|
51712
|
-
tieFormatName,
|
|
51713
|
-
tieFormat,
|
|
51714
|
-
drawSize
|
|
51715
|
-
});
|
|
51716
|
-
largestTeamSize = Math.max(largestTeamSize, teamSize);
|
|
51717
|
-
largestDoublesDraw = Math.max(largestDoublesDraw, maxDoublesDraw);
|
|
51718
|
-
largestSinglesDraw = Math.max(largestSinglesDraw, maxSinglesDraw);
|
|
51719
|
-
}
|
|
51720
|
-
|
|
51721
|
-
if (isDoubles && drawSize + alternatesCount && drawSize + alternatesCount > largestDoublesDraw) {
|
|
51722
|
-
largestDoublesDraw = drawSize + alternatesCount;
|
|
51723
|
-
}
|
|
51724
|
-
|
|
51725
|
-
if (!isDoubles && !isTeam && drawSize && drawSize > largestSinglesDraw) {
|
|
51726
|
-
largestSinglesDraw = drawSize + alternatesCount;
|
|
51727
|
-
}
|
|
51728
|
-
};
|
|
51729
|
-
|
|
51730
|
-
eventProfiles === null || eventProfiles === void 0 ? void 0 : eventProfiles.forEach(eventProfile => {
|
|
51731
|
-
const {
|
|
51732
|
-
tieFormatName: eventTieFormatName,
|
|
51733
|
-
tieFormat: eventTieFormat,
|
|
51734
|
-
drawProfiles,
|
|
51735
|
-
eventType,
|
|
51736
|
-
category
|
|
51737
|
-
} = eventProfile;
|
|
51738
|
-
|
|
51739
|
-
if (drawProfiles) {
|
|
51740
|
-
for (const drawProfile of drawProfiles) {
|
|
51741
|
-
const {
|
|
51742
|
-
tieFormatName,
|
|
51743
|
-
tieFormat
|
|
51744
|
-
} = drawProfile;
|
|
51745
|
-
processDrawProfile({ ...drawProfile,
|
|
51746
|
-
tieFormatName: tieFormatName || eventTieFormatName,
|
|
51747
|
-
tieFormat: tieFormat || eventTieFormat,
|
|
51748
|
-
eventType,
|
|
51749
|
-
category
|
|
51750
|
-
});
|
|
51751
|
-
}
|
|
51752
|
-
}
|
|
51753
|
-
});
|
|
51754
|
-
|
|
51755
|
-
if (drawProfiles) {
|
|
51756
|
-
for (const drawProfile of drawProfiles) {
|
|
51757
|
-
processDrawProfile(drawProfile);
|
|
51758
|
-
}
|
|
51759
|
-
}
|
|
51760
|
-
|
|
51761
|
-
const individualCompetitorsCount = Math.max(largestTeamDraw * largestTeamSize, largestDoublesDraw * 2, largestSinglesDraw);
|
|
51762
|
-
if (largestDoublesDraw) participantType = PAIR$1;
|
|
51763
|
-
if ((participantsCount || specifiedParicipantsCount) < individualCompetitorsCount) participantsCount = individualCompetitorsCount;
|
|
51764
|
-
|
|
51765
|
-
if (participantsCount && largestDoublesDraw && [PAIR$1, TEAM$2].includes(participantType)) {
|
|
51766
|
-
// if we are generating PAIRs or TEAMs...
|
|
51767
|
-
if (largestSinglesDraw && Math.floor(largestSinglesDraw / 2) > largestDoublesDraw) {
|
|
51768
|
-
// if the half the singles draw is still larger than doubles draw
|
|
51769
|
-
participantsCount = Math.floor(largestSinglesDraw / 2);
|
|
51770
|
-
} else if (!largestSinglesDraw || largestDoublesDraw * 2 >= largestSinglesDraw) {
|
|
51771
|
-
// otherwise participantsCount can be cut in half
|
|
51772
|
-
participantsCount = Math.ceil(participantsCount / 2);
|
|
51773
|
-
}
|
|
51774
|
-
}
|
|
51775
|
-
|
|
51776
|
-
if (participantsCount === undefined) participantsCount = 32;
|
|
51777
|
-
if (participantsCount < specifiedParicipantsCount) participantsCount = specifiedParicipantsCount;
|
|
51778
|
-
const {
|
|
51779
|
-
nationalityCodesCount,
|
|
51780
|
-
nationalityCodeType,
|
|
51781
|
-
valuesInstanceLimit,
|
|
51782
|
-
nationalityCodes,
|
|
51783
|
-
personExtensions,
|
|
51784
|
-
addressProps,
|
|
51785
|
-
personData,
|
|
51786
|
-
personIds,
|
|
51787
|
-
inContext,
|
|
51788
|
-
teamKey,
|
|
51789
|
-
sex
|
|
51790
|
-
} = participantsProfile || {};
|
|
51791
|
-
const {
|
|
51792
|
-
participants
|
|
51793
|
-
} = generateParticipants({
|
|
51794
|
-
consideredDate: startDate,
|
|
51795
|
-
valuesInstanceLimit,
|
|
51796
|
-
nationalityCodesCount,
|
|
51797
|
-
nationalityCodeType,
|
|
51798
|
-
nationalityCodes,
|
|
51799
|
-
personExtensions,
|
|
51800
|
-
addressProps,
|
|
51801
|
-
personData,
|
|
51802
|
-
sex,
|
|
51803
|
-
participantsCount,
|
|
51804
|
-
participantType,
|
|
51805
|
-
personIds,
|
|
51806
|
-
uuids,
|
|
51807
|
-
inContext
|
|
51808
|
-
});
|
|
51809
|
-
let result = addParticipants({
|
|
51810
|
-
tournamentRecord,
|
|
51811
|
-
participants
|
|
51812
|
-
});
|
|
51813
|
-
if (!result.success) return result;
|
|
51814
|
-
|
|
51815
|
-
if (teamKey) {
|
|
51816
|
-
const result = generateTeamsFromParticipantAttribute({
|
|
51817
|
-
tournamentRecord,
|
|
51818
|
-
...teamKey
|
|
51819
|
-
});
|
|
51820
|
-
if (result.error) return result;
|
|
51821
|
-
} // generate Team participants
|
|
51822
|
-
|
|
51823
|
-
|
|
51824
|
-
const allIndividualParticipantIds = participants.filter(({
|
|
51825
|
-
participantType
|
|
51826
|
-
}) => participantType === INDIVIDUAL$1).map(getParticipantId);
|
|
51827
|
-
const teamParticipants = generateRange(0, largestTeamDraw).map(teamIndex => {
|
|
51828
|
-
const individualParticipantIds = allIndividualParticipantIds.slice(teamIndex * largestTeamSize, (teamIndex + 1) * largestTeamSize);
|
|
51829
|
-
return {
|
|
51830
|
-
participantName: `Team ${teamIndex + 1}`,
|
|
51831
|
-
participantRole: COMPETITOR,
|
|
51832
|
-
participantType: TEAM$2,
|
|
51833
|
-
participantId: UUID(),
|
|
51834
|
-
individualParticipantIds
|
|
51835
|
-
};
|
|
51836
|
-
});
|
|
51837
|
-
result = addParticipants({
|
|
51737
|
+
const result = addTournamentParticipants({
|
|
51738
|
+
participantsProfile,
|
|
51838
51739
|
tournamentRecord,
|
|
51839
|
-
|
|
51740
|
+
eventProfiles,
|
|
51741
|
+
drawProfiles,
|
|
51742
|
+
startDate,
|
|
51743
|
+
uuids
|
|
51840
51744
|
});
|
|
51841
51745
|
if (!result.success) return result;
|
|
51842
51746
|
const drawIds = [],
|
|
@@ -51862,7 +51766,8 @@ function generateTournamentRecord({
|
|
|
51862
51766
|
tournamentRecord,
|
|
51863
51767
|
drawProfile,
|
|
51864
51768
|
startDate,
|
|
51865
|
-
goesTo
|
|
51769
|
+
goesTo,
|
|
51770
|
+
uuids
|
|
51866
51771
|
});
|
|
51867
51772
|
if (error) return {
|
|
51868
51773
|
error
|
|
@@ -51895,7 +51800,8 @@ function generateTournamentRecord({
|
|
|
51895
51800
|
ratingsParameters: ratingsParameters$1,
|
|
51896
51801
|
tournamentRecord,
|
|
51897
51802
|
eventProfile,
|
|
51898
|
-
startDate
|
|
51803
|
+
startDate,
|
|
51804
|
+
uuids
|
|
51899
51805
|
});
|
|
51900
51806
|
if (error) return {
|
|
51901
51807
|
error
|