tods-competition-factory 2.0.13 → 2.0.14
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/index.mjs +6 -6
- package/dist/tods-competition-factory.d.ts +65 -71
- package/dist/tods-competition-factory.development.cjs.js +281 -262
- 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 +5 -5
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
function factoryVersion() {
|
|
6
|
-
return '2.0.
|
|
6
|
+
return '2.0.14';
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
const SUCCESS = { success: true };
|
|
@@ -3239,11 +3239,11 @@ function getMinFinishingPositionRange(structure) {
|
|
|
3239
3239
|
}, undefined);
|
|
3240
3240
|
}
|
|
3241
3241
|
|
|
3242
|
-
function findStructure(
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3242
|
+
function findStructure(params) {
|
|
3243
|
+
const paramsCheck = checkRequiredParameters(params, [{ [DRAW_DEFINITION]: true, [STRUCTURE_ID]: true }]);
|
|
3244
|
+
if (paramsCheck.error)
|
|
3245
|
+
return paramsCheck;
|
|
3246
|
+
const { drawDefinition, structureId } = params;
|
|
3247
3247
|
const { structures } = getDrawStructures({ drawDefinition });
|
|
3248
3248
|
const allStructures = structures
|
|
3249
3249
|
?.map((structure) => {
|
|
@@ -5127,6 +5127,20 @@ function getCheckedInParticipantIds({ matchUp }) {
|
|
|
5127
5127
|
};
|
|
5128
5128
|
}
|
|
5129
5129
|
|
|
5130
|
+
const matchUpEventTypeMap = {
|
|
5131
|
+
[SINGLES]: [SINGLES, 'S'],
|
|
5132
|
+
[DOUBLES]: [DOUBLES, 'D'],
|
|
5133
|
+
[TEAM$1]: [TEAM$1, 'T'],
|
|
5134
|
+
S: [SINGLES, 'S'],
|
|
5135
|
+
D: [DOUBLES, 'D'],
|
|
5136
|
+
T: [TEAM$1, 'T'],
|
|
5137
|
+
};
|
|
5138
|
+
|
|
5139
|
+
const isMatchUpEventType = (type) => (params) => {
|
|
5140
|
+
const matchUpEventType = (isObject(params) && params?.matchUpType) || (isString(params) && params);
|
|
5141
|
+
return matchUpEventType && matchUpEventTypeMap[type].includes(matchUpEventType);
|
|
5142
|
+
};
|
|
5143
|
+
|
|
5130
5144
|
function findMatchupFormatAverageTimes(params) {
|
|
5131
5145
|
const { matchUpAverageTimes, matchUpFormat } = params || {};
|
|
5132
5146
|
const codeMatches = matchUpAverageTimes
|
|
@@ -5317,7 +5331,7 @@ function matchUpFormatTimes({ timingDetails, eventType }) {
|
|
|
5317
5331
|
const recoveryKeys = Object.keys(recoveryTimes?.minutes || {});
|
|
5318
5332
|
const recoveryMinutes = recoveryTimes?.minutes &&
|
|
5319
5333
|
((recoveryKeys?.includes(eventType) && recoveryTimes.minutes[eventType]) || recoveryTimes.minutes.default);
|
|
5320
|
-
const formatChangeKey = eventType
|
|
5334
|
+
const formatChangeKey = isMatchUpEventType(SINGLES_EVENT)(eventType) ? SINGLES_DOUBLES : DOUBLES_SINGLES;
|
|
5321
5335
|
const typeChangeRecoveryMinutes = recoveryTimes?.minutes &&
|
|
5322
5336
|
((recoveryKeys?.includes(formatChangeKey) && recoveryTimes.minutes[formatChangeKey]) || recoveryMinutes);
|
|
5323
5337
|
return { averageMinutes, recoveryMinutes, typeChangeRecoveryMinutes };
|
|
@@ -6601,10 +6615,9 @@ function isAdHoc({ structure }) {
|
|
|
6601
6615
|
const matchUps = structure.matchUps || (structure.roundMatchUps && Object.values(structure.roundMatchUps).flat());
|
|
6602
6616
|
const hasRoundPosition = !!matchUps?.find((matchUp) => matchUp?.roundPosition);
|
|
6603
6617
|
const hasDrawPosition = !!matchUps?.find((matchUp) => matchUp?.drawPositions?.length);
|
|
6604
|
-
|
|
6618
|
+
return (!structure?.structures &&
|
|
6605
6619
|
structure?.stage !== VOLUNTARY_CONSOLATION &&
|
|
6606
|
-
(!matchUps.length || (!hasRoundPosition && !hasDrawPosition));
|
|
6607
|
-
return adHoc;
|
|
6620
|
+
(!matchUps.length || (!hasRoundPosition && !hasDrawPosition)));
|
|
6608
6621
|
}
|
|
6609
6622
|
|
|
6610
6623
|
const POLICY_ROUND_NAMING_DEFAULT = {
|
|
@@ -6722,6 +6735,12 @@ function getMatchUpType(params) {
|
|
|
6722
6735
|
return { matchUpType };
|
|
6723
6736
|
}
|
|
6724
6737
|
|
|
6738
|
+
function includesMatchUpEventType(types, matchUpEventType) {
|
|
6739
|
+
if (!Array.isArray(types) || !isString(matchUpEventType))
|
|
6740
|
+
return false;
|
|
6741
|
+
return intersection(types, matchUpEventTypeMap[matchUpEventType]).length;
|
|
6742
|
+
}
|
|
6743
|
+
|
|
6725
6744
|
function filterMatchUps(params) {
|
|
6726
6745
|
const { matchUps, isCollectionMatchUp, excludeMatchUpStatuses, matchUpStatuses, hasWinningSide, matchUpFormats, roundPositions, matchUpFormat, collectionIds, isMatchUpTie, roundNumbers, matchUpIds, roundNames, stageSequences, scheduledDates, scheduledDate, participantIds, processContext, tournamentIds, matchUpTypes, structureIds, readyToScore, courtIds, eventIds, venueIds, drawIds, stages, filterMatchUpIds = true, filterMatchUpTypes = true, } = params;
|
|
6727
6746
|
const targetParticipantIds = Array.isArray(participantIds) ? participantIds.filter(Boolean) : [];
|
|
@@ -6750,7 +6769,7 @@ function filterMatchUps(params) {
|
|
|
6750
6769
|
const targetDrawIds = Array.isArray(drawIds) ? drawIds.filter(Boolean) : [];
|
|
6751
6770
|
const targetStructureIds = Array.isArray(structureIds) ? structureIds.filter(Boolean) : [];
|
|
6752
6771
|
return matchUps.filter((matchUp) => {
|
|
6753
|
-
if (readyToScore && matchUp
|
|
6772
|
+
if (readyToScore && !isMatchUpEventType(TEAM_MATCHUP)(matchUp) && !matchUp.readyToScore)
|
|
6754
6773
|
return false;
|
|
6755
6774
|
if (matchUp.winningSide && hasWinningSide && ![1, 2].includes(matchUp.winningSide))
|
|
6756
6775
|
return false;
|
|
@@ -6801,7 +6820,8 @@ function filterMatchUps(params) {
|
|
|
6801
6820
|
if (targetMatchUpIds.length && !targetMatchUpIds.includes(matchUp.matchUpId)) {
|
|
6802
6821
|
return false;
|
|
6803
6822
|
}
|
|
6804
|
-
if (targetMatchUpTypes.length &&
|
|
6823
|
+
if (targetMatchUpTypes.length &&
|
|
6824
|
+
(!matchUp.matchUpType || !includesMatchUpEventType(targetMatchUpTypes, matchUp.matchUpType))) {
|
|
6805
6825
|
return false;
|
|
6806
6826
|
}
|
|
6807
6827
|
if (targetMatchUpFormats.length &&
|
|
@@ -7319,7 +7339,7 @@ function getAllStructureMatchUps({ scheduleVisibilityFilters, tournamentAppliedP
|
|
|
7319
7339
|
matchUpWithContext.matchUpType !== TEAM$2;
|
|
7320
7340
|
if (inferGender) {
|
|
7321
7341
|
const sideGenders = matchUpWithContext.sides.map((side) => {
|
|
7322
|
-
if (matchUpWithContext.matchUpType
|
|
7342
|
+
if (isMatchUpEventType(SINGLES)(matchUpWithContext.matchUpType))
|
|
7323
7343
|
return side.participant?.person?.sex;
|
|
7324
7344
|
if (side.participant?.individualParticipants?.length === 2) {
|
|
7325
7345
|
const pairGenders = unique(side.participant.individualParticipants.map((participant) => participant.person?.sex)).filter(Boolean);
|
|
@@ -11389,6 +11409,11 @@ function getTournamentPublishStatus({ tournamentRecord, status = PUBLIC }) {
|
|
|
11389
11409
|
})?.timeItem?.itemValue?.[status];
|
|
11390
11410
|
}
|
|
11391
11411
|
|
|
11412
|
+
function isValidTournamentRecord(tournamentRecord) {
|
|
11413
|
+
const { tournamentId } = tournamentRecord ?? {};
|
|
11414
|
+
return !!tournamentId;
|
|
11415
|
+
}
|
|
11416
|
+
|
|
11392
11417
|
function getEventPublishStatus({ event, status = PUBLIC }) {
|
|
11393
11418
|
const itemType = `${PUBLISH}.${STATUS$1}`;
|
|
11394
11419
|
return getEventTimeItem({
|
|
@@ -11402,29 +11427,28 @@ function getDrawPublishStatus({ drawDetails, drawId }) {
|
|
|
11402
11427
|
return details?.published;
|
|
11403
11428
|
}
|
|
11404
11429
|
|
|
11405
|
-
function getPublishState(
|
|
11406
|
-
|
|
11430
|
+
function getPublishState(params) {
|
|
11431
|
+
const { tournamentRecord, drawDefinition, eventIds, eventId, drawIds, drawId, event } = params ?? {};
|
|
11432
|
+
if (tournamentRecord && !isValidTournamentRecord(tournamentRecord))
|
|
11433
|
+
return { error: INVALID_VALUES };
|
|
11434
|
+
if (eventId && !event)
|
|
11407
11435
|
return { error: EVENT_NOT_FOUND };
|
|
11408
|
-
|
|
11409
|
-
else if (Array.isArray(eventIds) && eventIds?.length) {
|
|
11436
|
+
if (Array.isArray(eventIds) && eventIds?.length) {
|
|
11410
11437
|
const publishState = {};
|
|
11411
11438
|
for (const eventId of eventIds) {
|
|
11412
11439
|
if (!isString(eventId))
|
|
11413
11440
|
return { error: INVALID_VALUES };
|
|
11414
|
-
const event = findEvent({ tournamentRecord, eventId });
|
|
11441
|
+
const event = findEvent({ tournamentRecord, eventId })?.event;
|
|
11415
11442
|
if (!event)
|
|
11416
11443
|
return { error: EVENT_NOT_FOUND };
|
|
11417
11444
|
const pubStatus = getPubStatus({ event });
|
|
11418
|
-
if (pubStatus.error)
|
|
11419
|
-
return pubStatus;
|
|
11420
11445
|
publishState[eventId] = pubStatus;
|
|
11421
11446
|
}
|
|
11422
11447
|
return { ...SUCCESS, publishState };
|
|
11423
11448
|
}
|
|
11424
|
-
|
|
11449
|
+
if (event) {
|
|
11425
11450
|
const pubStatus = getPubStatus({ event });
|
|
11426
|
-
|
|
11427
|
-
return pubStatus;
|
|
11451
|
+
let publishState = {};
|
|
11428
11452
|
if (drawId) {
|
|
11429
11453
|
if (!drawDefinition)
|
|
11430
11454
|
return { error: DRAW_DEFINITION_NOT_FOUND };
|
|
@@ -11439,47 +11463,38 @@ function getPublishState({ tournamentRecord, drawDefinition, eventIds, eventId,
|
|
|
11439
11463
|
};
|
|
11440
11464
|
}
|
|
11441
11465
|
else if (Array.isArray(drawIds) && drawIds?.length) {
|
|
11442
|
-
const
|
|
11466
|
+
const eventDrawIds = event.drawDefinitions?.map(getDrawId) || [];
|
|
11443
11467
|
for (const drawId of drawIds) {
|
|
11444
11468
|
if (!isString(drawId))
|
|
11445
11469
|
return { error: INVALID_VALUES };
|
|
11470
|
+
if (!eventDrawIds.includes(drawId))
|
|
11471
|
+
return { error: DRAW_DEFINITION_NOT_FOUND };
|
|
11446
11472
|
publishState[drawId] = {
|
|
11447
11473
|
status: {
|
|
11448
11474
|
published: !!pubStatus.status.publishedDrawIds.includes(drawId),
|
|
11449
11475
|
drawDetail: pubStatus.status.drawDetails?.[drawId],
|
|
11450
11476
|
},
|
|
11451
11477
|
};
|
|
11452
|
-
return { ...SUCCESS, publishState };
|
|
11453
11478
|
}
|
|
11454
11479
|
}
|
|
11455
11480
|
else {
|
|
11456
|
-
|
|
11481
|
+
publishState = pubStatus;
|
|
11457
11482
|
}
|
|
11483
|
+
return { ...SUCCESS, publishState };
|
|
11458
11484
|
}
|
|
11459
|
-
|
|
11460
|
-
|
|
11461
|
-
|
|
11462
|
-
|
|
11463
|
-
const
|
|
11464
|
-
|
|
11465
|
-
|
|
11466
|
-
|
|
11467
|
-
|
|
11468
|
-
|
|
11469
|
-
if (pubStatus.error)
|
|
11470
|
-
return pubStatus;
|
|
11471
|
-
for (const { drawId } of event.drawDefinitions ?? []) {
|
|
11472
|
-
if (!isString(drawId))
|
|
11473
|
-
return { error: INVALID_VALUES };
|
|
11474
|
-
const published = pubStatus.publishState?.publishedDrawIds?.includes(drawId);
|
|
11475
|
-
if (published) {
|
|
11476
|
-
publishState[drawId] = { status: { published } };
|
|
11477
|
-
}
|
|
11478
|
-
}
|
|
11485
|
+
const publishState = {};
|
|
11486
|
+
const pubStatus = getTournamentPublishStatus({ tournamentRecord });
|
|
11487
|
+
publishState.tournament = pubStatus;
|
|
11488
|
+
for (const event of tournamentRecord?.events ?? []) {
|
|
11489
|
+
const pubStatus = getPubStatus({ event });
|
|
11490
|
+
publishState[event.eventId] = pubStatus;
|
|
11491
|
+
for (const { drawId } of event.drawDefinitions ?? []) {
|
|
11492
|
+
const published = pubStatus.status?.publishedDrawIds?.includes(drawId);
|
|
11493
|
+
if (published)
|
|
11494
|
+
publishState[drawId] = { status: { published } };
|
|
11479
11495
|
}
|
|
11480
|
-
return { ...SUCCESS, publishState };
|
|
11481
11496
|
}
|
|
11482
|
-
return {
|
|
11497
|
+
return { ...SUCCESS, publishState };
|
|
11483
11498
|
}
|
|
11484
11499
|
function getPubStatus({ event }) {
|
|
11485
11500
|
const eventPubStatus = getEventPublishStatus({ event });
|
|
@@ -11501,12 +11516,13 @@ function getPubStatus({ event }) {
|
|
|
11501
11516
|
};
|
|
11502
11517
|
}
|
|
11503
11518
|
}
|
|
11504
|
-
const publishedDrawIds = (drawDetails &&
|
|
11505
|
-
|
|
11506
|
-
|
|
11519
|
+
const publishedDrawIds = (drawDetails &&
|
|
11520
|
+
Object.keys(drawDetails).length &&
|
|
11521
|
+
Object.keys(drawDetails).filter((drawId) => getDrawPublishStatus({ drawDetails, drawId }))) ||
|
|
11522
|
+
eventPubStatus.drawIds;
|
|
11507
11523
|
return {
|
|
11508
11524
|
status: {
|
|
11509
|
-
published: publishedDrawIds.length > 0,
|
|
11525
|
+
published: publishedDrawIds && publishedDrawIds.length > 0,
|
|
11510
11526
|
publishedDrawIds,
|
|
11511
11527
|
publishedSeeding,
|
|
11512
11528
|
drawDetails,
|
|
@@ -12276,7 +12292,7 @@ function filterParticipants({ participantFilters = {}, tournamentRecord, partici
|
|
|
12276
12292
|
.filter((event) => eventIds.includes(event.eventId))
|
|
12277
12293
|
.map((event) => {
|
|
12278
12294
|
const enteredParticipantIds = (event.entries || []).map((entry) => entry.participantId);
|
|
12279
|
-
if (
|
|
12295
|
+
if (isMatchUpEventType(SINGLES$1)(event.eventType))
|
|
12280
12296
|
return enteredParticipantIds;
|
|
12281
12297
|
const individualParticipantIds = (tournamentRecord?.participants ?? [])
|
|
12282
12298
|
.filter((participant) => enteredParticipantIds.includes(participant.participantId))
|
|
@@ -12880,7 +12896,9 @@ function addEventEntries(params) {
|
|
|
12880
12896
|
?.filter((participant) => {
|
|
12881
12897
|
if (!participantIds.includes(participant.participantId))
|
|
12882
12898
|
return false;
|
|
12883
|
-
const validSingles = event.eventType
|
|
12899
|
+
const validSingles = isMatchUpEventType(SINGLES)(event.eventType) &&
|
|
12900
|
+
participant.participantType === INDIVIDUAL &&
|
|
12901
|
+
!isUngrouped(entryStatus);
|
|
12884
12902
|
const validDoubles = event.eventType === DOUBLES && participant.participantType === PAIR;
|
|
12885
12903
|
if (validSingles &&
|
|
12886
12904
|
(!event.gender ||
|
|
@@ -19621,11 +19639,11 @@ function getParticipantResults({ participantIds, matchUpFormat, tallyPolicy, per
|
|
|
19621
19639
|
checkInitializeParticipant(participantResults, tieLosingParticipantId);
|
|
19622
19640
|
participantResults[tieWinningParticipantId].tieMatchUpsWon += 1;
|
|
19623
19641
|
participantResults[tieLosingParticipantId].tieMatchUpsLost += 1;
|
|
19624
|
-
if (tieMatchUp.matchUpType
|
|
19642
|
+
if (isMatchUpEventType(SINGLES)(tieMatchUp.matchUpType)) {
|
|
19625
19643
|
participantResults[tieWinningParticipantId].tieSinglesWon += 1;
|
|
19626
19644
|
participantResults[tieLosingParticipantId].tieSinglesLost += 1;
|
|
19627
19645
|
}
|
|
19628
|
-
else if (tieMatchUp.matchUpType
|
|
19646
|
+
else if (isMatchUpEventType(DOUBLES)(tieMatchUp.matchUpType)) {
|
|
19629
19647
|
participantResults[tieWinningParticipantId].tieDoublesWon += 1;
|
|
19630
19648
|
participantResults[tieLosingParticipantId].tieDoublesLost += 1;
|
|
19631
19649
|
}
|
|
@@ -19655,8 +19673,8 @@ function getParticipantResults({ participantIds, matchUpFormat, tallyPolicy, per
|
|
|
19655
19673
|
perPlayer = 0;
|
|
19656
19674
|
for (const tieMatchUp of tieMatchUps) {
|
|
19657
19675
|
const { matchUpType } = tieMatchUp;
|
|
19658
|
-
const isDoubles = matchUpType
|
|
19659
|
-
const isSingles = matchUpType
|
|
19676
|
+
const isDoubles = isMatchUpEventType(DOUBLES)(matchUpType);
|
|
19677
|
+
const isSingles = isMatchUpEventType(SINGLES)(matchUpType);
|
|
19660
19678
|
if (tieMatchUp.winningSide) {
|
|
19661
19679
|
if (tieMatchUp.winningSide === winningSide) {
|
|
19662
19680
|
if (winningParticipantId) {
|
|
@@ -20792,6 +20810,102 @@ function tieFormatGenderValidityCheck(params) {
|
|
|
20792
20810
|
return { valid: true };
|
|
20793
20811
|
}
|
|
20794
20812
|
|
|
20813
|
+
function stringify(matchUpFormatObject, preserveRedundant) {
|
|
20814
|
+
if ((matchUpFormatObject?.bestOf || matchUpFormatObject?.exactly) && matchUpFormatObject?.setFormat) {
|
|
20815
|
+
return getSetFormat(matchUpFormatObject, preserveRedundant);
|
|
20816
|
+
}
|
|
20817
|
+
return undefined;
|
|
20818
|
+
}
|
|
20819
|
+
function getNumber(formatstring) {
|
|
20820
|
+
return !isNaN(Number(formatstring)) && Number(formatstring);
|
|
20821
|
+
}
|
|
20822
|
+
function timedSetFormat(matchUpFormatObject) {
|
|
20823
|
+
let value = `T${matchUpFormatObject.minutes}`;
|
|
20824
|
+
if (matchUpFormatObject.based)
|
|
20825
|
+
value += matchUpFormatObject.based;
|
|
20826
|
+
if (matchUpFormatObject.modifier)
|
|
20827
|
+
value += `@${matchUpFormatObject.modifier}`;
|
|
20828
|
+
return value;
|
|
20829
|
+
}
|
|
20830
|
+
function getSetFormat(matchUpFormatObject, preserveRedundant) {
|
|
20831
|
+
const bestOfValue = getNumber(matchUpFormatObject.bestOf) || undefined;
|
|
20832
|
+
const exactly = getNumber(matchUpFormatObject.exactly) || undefined;
|
|
20833
|
+
const setLimit = bestOfValue || exactly;
|
|
20834
|
+
if (matchUpFormatObject.setFormat?.timed && matchUpFormatObject.simplified && setLimit === 1) {
|
|
20835
|
+
return timedSetFormat(matchUpFormatObject.setFormat);
|
|
20836
|
+
}
|
|
20837
|
+
const setLimitCode = (setLimit && `${SET}${setLimit}`) || '';
|
|
20838
|
+
const setCountValue = stringifySet(matchUpFormatObject.setFormat, preserveRedundant);
|
|
20839
|
+
const setCode = (setCountValue && `S:${setCountValue}`) || '';
|
|
20840
|
+
const finalSetCountValue = stringifySet(matchUpFormatObject.finalSetFormat, preserveRedundant);
|
|
20841
|
+
const finalSetCode = (setLimit &&
|
|
20842
|
+
setLimit > 1 &&
|
|
20843
|
+
finalSetCountValue &&
|
|
20844
|
+
setCountValue !== finalSetCountValue &&
|
|
20845
|
+
`F:${finalSetCountValue}`) ||
|
|
20846
|
+
'';
|
|
20847
|
+
const valid = setLimitCode && setCountValue;
|
|
20848
|
+
if (valid) {
|
|
20849
|
+
return [setLimitCode, setCode, finalSetCode].filter((f) => f).join('-');
|
|
20850
|
+
}
|
|
20851
|
+
return undefined;
|
|
20852
|
+
}
|
|
20853
|
+
function stringifySet(setObject, preserveRedundant) {
|
|
20854
|
+
if (typeof setObject === 'object' && Object.keys(setObject).length) {
|
|
20855
|
+
if (setObject.timed)
|
|
20856
|
+
return timedSetFormat(setObject);
|
|
20857
|
+
if (setObject.tiebreakSet)
|
|
20858
|
+
return tiebreakFormat(setObject.tiebreakSet);
|
|
20859
|
+
const setToValue = getNumber(setObject.setTo);
|
|
20860
|
+
if (setToValue) {
|
|
20861
|
+
const NoAD = (setObject.NoAD && NOAD) || '';
|
|
20862
|
+
const setTiebreakValue = tiebreakFormat(setObject.tiebreakFormat);
|
|
20863
|
+
const setTiebreakCode = (setTiebreakValue && `/${setTiebreakValue}`) || '';
|
|
20864
|
+
const tiebreakAtValue = getNumber(setObject.tiebreakAt);
|
|
20865
|
+
const tiebreakAtCode = (tiebreakAtValue && (tiebreakAtValue !== setToValue || preserveRedundant) && `@${tiebreakAtValue}`) || '';
|
|
20866
|
+
if (setTiebreakValue !== false) {
|
|
20867
|
+
return `${setToValue}${NoAD}${setTiebreakCode}${tiebreakAtCode}`;
|
|
20868
|
+
}
|
|
20869
|
+
}
|
|
20870
|
+
}
|
|
20871
|
+
return undefined;
|
|
20872
|
+
}
|
|
20873
|
+
function tiebreakFormat(tieobject) {
|
|
20874
|
+
if (tieobject) {
|
|
20875
|
+
if (typeof tieobject === 'object' && !tieobject.tiebreakTo) {
|
|
20876
|
+
return '';
|
|
20877
|
+
}
|
|
20878
|
+
else if (typeof tieobject === 'object' && getNumber(tieobject.tiebreakTo)) {
|
|
20879
|
+
let value = `TB${tieobject.tiebreakTo}${tieobject.NoAD ? NOAD : ''}`;
|
|
20880
|
+
if (tieobject.modifier)
|
|
20881
|
+
value += `@${tieobject.modifier}`;
|
|
20882
|
+
return value;
|
|
20883
|
+
}
|
|
20884
|
+
else {
|
|
20885
|
+
return false;
|
|
20886
|
+
}
|
|
20887
|
+
}
|
|
20888
|
+
return undefined;
|
|
20889
|
+
}
|
|
20890
|
+
|
|
20891
|
+
function isValidMatchUpFormat({ matchUpFormat }) {
|
|
20892
|
+
if (typeof matchUpFormat !== 'string')
|
|
20893
|
+
return false;
|
|
20894
|
+
const parsedFormat = parse(matchUpFormat);
|
|
20895
|
+
const setParts = matchUpFormat.match(/-S:([1-9])+\/TB([0-9]{1,2})@?([1-9]?)*/);
|
|
20896
|
+
const setsTo = setParts?.[1];
|
|
20897
|
+
const tiebreakTo = setParts?.[2];
|
|
20898
|
+
const tiebreakAt = setParts?.[3];
|
|
20899
|
+
const finalSetParts = matchUpFormat.match(/-F:([1-9])+\/TB([0-9]{1,2})@?([1-9]?)*/);
|
|
20900
|
+
const finalSetTo = finalSetParts?.[1];
|
|
20901
|
+
const finalSetTiebreakTo = finalSetParts?.[2];
|
|
20902
|
+
const finalTiebreakAt = finalSetParts?.[3];
|
|
20903
|
+
const preserveRedundant = !!((setParts && tiebreakTo && setsTo === tiebreakAt) ||
|
|
20904
|
+
(finalSetParts && finalSetTiebreakTo && finalSetTo === finalTiebreakAt));
|
|
20905
|
+
const stringified = stringify(parsedFormat, preserveRedundant);
|
|
20906
|
+
return stringified === matchUpFormat;
|
|
20907
|
+
}
|
|
20908
|
+
|
|
20795
20909
|
const typeMatch = (arr, type) => arr.filter(Boolean).every((i) => typeof i === type);
|
|
20796
20910
|
const allNumeric = (arr) => arr.filter(Boolean).every(isNumeric);
|
|
20797
20911
|
function getCategoryAgeDetails(params) {
|
|
@@ -21038,102 +21152,6 @@ function categoryCanContain({ childCategory, withDetails, category }) {
|
|
|
21038
21152
|
return result;
|
|
21039
21153
|
}
|
|
21040
21154
|
|
|
21041
|
-
function stringify(matchUpFormatObject, preserveRedundant) {
|
|
21042
|
-
if ((matchUpFormatObject?.bestOf || matchUpFormatObject?.exactly) && matchUpFormatObject?.setFormat) {
|
|
21043
|
-
return getSetFormat(matchUpFormatObject, preserveRedundant);
|
|
21044
|
-
}
|
|
21045
|
-
return undefined;
|
|
21046
|
-
}
|
|
21047
|
-
function getNumber(formatstring) {
|
|
21048
|
-
return !isNaN(Number(formatstring)) && Number(formatstring);
|
|
21049
|
-
}
|
|
21050
|
-
function timedSetFormat(matchUpFormatObject) {
|
|
21051
|
-
let value = `T${matchUpFormatObject.minutes}`;
|
|
21052
|
-
if (matchUpFormatObject.based)
|
|
21053
|
-
value += matchUpFormatObject.based;
|
|
21054
|
-
if (matchUpFormatObject.modifier)
|
|
21055
|
-
value += `@${matchUpFormatObject.modifier}`;
|
|
21056
|
-
return value;
|
|
21057
|
-
}
|
|
21058
|
-
function getSetFormat(matchUpFormatObject, preserveRedundant) {
|
|
21059
|
-
const bestOfValue = getNumber(matchUpFormatObject.bestOf) || undefined;
|
|
21060
|
-
const exactly = getNumber(matchUpFormatObject.exactly) || undefined;
|
|
21061
|
-
const setLimit = bestOfValue || exactly;
|
|
21062
|
-
if (matchUpFormatObject.setFormat?.timed && matchUpFormatObject.simplified && setLimit === 1) {
|
|
21063
|
-
return timedSetFormat(matchUpFormatObject.setFormat);
|
|
21064
|
-
}
|
|
21065
|
-
const setLimitCode = (setLimit && `${SET}${setLimit}`) || '';
|
|
21066
|
-
const setCountValue = stringifySet(matchUpFormatObject.setFormat, preserveRedundant);
|
|
21067
|
-
const setCode = (setCountValue && `S:${setCountValue}`) || '';
|
|
21068
|
-
const finalSetCountValue = stringifySet(matchUpFormatObject.finalSetFormat, preserveRedundant);
|
|
21069
|
-
const finalSetCode = (setLimit &&
|
|
21070
|
-
setLimit > 1 &&
|
|
21071
|
-
finalSetCountValue &&
|
|
21072
|
-
setCountValue !== finalSetCountValue &&
|
|
21073
|
-
`F:${finalSetCountValue}`) ||
|
|
21074
|
-
'';
|
|
21075
|
-
const valid = setLimitCode && setCountValue;
|
|
21076
|
-
if (valid) {
|
|
21077
|
-
return [setLimitCode, setCode, finalSetCode].filter((f) => f).join('-');
|
|
21078
|
-
}
|
|
21079
|
-
return undefined;
|
|
21080
|
-
}
|
|
21081
|
-
function stringifySet(setObject, preserveRedundant) {
|
|
21082
|
-
if (typeof setObject === 'object' && Object.keys(setObject).length) {
|
|
21083
|
-
if (setObject.timed)
|
|
21084
|
-
return timedSetFormat(setObject);
|
|
21085
|
-
if (setObject.tiebreakSet)
|
|
21086
|
-
return tiebreakFormat(setObject.tiebreakSet);
|
|
21087
|
-
const setToValue = getNumber(setObject.setTo);
|
|
21088
|
-
if (setToValue) {
|
|
21089
|
-
const NoAD = (setObject.NoAD && NOAD) || '';
|
|
21090
|
-
const setTiebreakValue = tiebreakFormat(setObject.tiebreakFormat);
|
|
21091
|
-
const setTiebreakCode = (setTiebreakValue && `/${setTiebreakValue}`) || '';
|
|
21092
|
-
const tiebreakAtValue = getNumber(setObject.tiebreakAt);
|
|
21093
|
-
const tiebreakAtCode = (tiebreakAtValue && (tiebreakAtValue !== setToValue || preserveRedundant) && `@${tiebreakAtValue}`) || '';
|
|
21094
|
-
if (setTiebreakValue !== false) {
|
|
21095
|
-
return `${setToValue}${NoAD}${setTiebreakCode}${tiebreakAtCode}`;
|
|
21096
|
-
}
|
|
21097
|
-
}
|
|
21098
|
-
}
|
|
21099
|
-
return undefined;
|
|
21100
|
-
}
|
|
21101
|
-
function tiebreakFormat(tieobject) {
|
|
21102
|
-
if (tieobject) {
|
|
21103
|
-
if (typeof tieobject === 'object' && !tieobject.tiebreakTo) {
|
|
21104
|
-
return '';
|
|
21105
|
-
}
|
|
21106
|
-
else if (typeof tieobject === 'object' && getNumber(tieobject.tiebreakTo)) {
|
|
21107
|
-
let value = `TB${tieobject.tiebreakTo}${tieobject.NoAD ? NOAD : ''}`;
|
|
21108
|
-
if (tieobject.modifier)
|
|
21109
|
-
value += `@${tieobject.modifier}`;
|
|
21110
|
-
return value;
|
|
21111
|
-
}
|
|
21112
|
-
else {
|
|
21113
|
-
return false;
|
|
21114
|
-
}
|
|
21115
|
-
}
|
|
21116
|
-
return undefined;
|
|
21117
|
-
}
|
|
21118
|
-
|
|
21119
|
-
function isValidMatchUpFormat({ matchUpFormat }) {
|
|
21120
|
-
if (typeof matchUpFormat !== 'string')
|
|
21121
|
-
return false;
|
|
21122
|
-
const parsedFormat = parse(matchUpFormat);
|
|
21123
|
-
const setParts = matchUpFormat.match(/-S:([1-9])+\/TB([0-9]{1,2})@?([1-9]?)*/);
|
|
21124
|
-
const setsTo = setParts?.[1];
|
|
21125
|
-
const tiebreakTo = setParts?.[2];
|
|
21126
|
-
const tiebreakAt = setParts?.[3];
|
|
21127
|
-
const finalSetParts = matchUpFormat.match(/-F:([1-9])+\/TB([0-9]{1,2})@?([1-9]?)*/);
|
|
21128
|
-
const finalSetTo = finalSetParts?.[1];
|
|
21129
|
-
const finalSetTiebreakTo = finalSetParts?.[2];
|
|
21130
|
-
const finalTiebreakAt = finalSetParts?.[3];
|
|
21131
|
-
const preserveRedundant = !!((setParts && tiebreakTo && setsTo === tiebreakAt) ||
|
|
21132
|
-
(finalSetParts && finalSetTiebreakTo && finalSetTo === finalTiebreakAt));
|
|
21133
|
-
const stringified = stringify(parsedFormat, preserveRedundant);
|
|
21134
|
-
return stringified === matchUpFormat;
|
|
21135
|
-
}
|
|
21136
|
-
|
|
21137
21155
|
function validateCollectionDefinition({ checkCategory = true, collectionDefinition, checkCollectionIds, checkGender = true, referenceCategory, referenceGender, event, }) {
|
|
21138
21156
|
referenceGender = referenceGender ?? event?.gender;
|
|
21139
21157
|
const stack = 'validateCollectionDefinition';
|
|
@@ -21149,7 +21167,7 @@ function validateCollectionDefinition({ checkCategory = true, collectionDefiniti
|
|
|
21149
21167
|
if (typeof matchUpCount !== 'number') {
|
|
21150
21168
|
errors.push(`matchUpCount is not type number: ${matchUpCount}`);
|
|
21151
21169
|
}
|
|
21152
|
-
if (matchUpType && ![SINGLES, DOUBLES]
|
|
21170
|
+
if (matchUpType && !includesMatchUpEventType([SINGLES, DOUBLES], matchUpType)) {
|
|
21153
21171
|
errors.push(`matchUpType must be SINGLES or DOUBLES: ${matchUpType}`);
|
|
21154
21172
|
}
|
|
21155
21173
|
const valueDeclarations = [!!collectionValueProfiles?.length]
|
|
@@ -24191,11 +24209,11 @@ function collectionMatchUpActions({ specifiedPolicyDefinitions, inContextDrawMat
|
|
|
24191
24209
|
sideNumber: i + 1,
|
|
24192
24210
|
}));
|
|
24193
24211
|
const assignmentAvailable = (sideNumber &&
|
|
24194
|
-
((matchUpType
|
|
24195
|
-
(matchUpType
|
|
24212
|
+
((isMatchUpEventType(SINGLES_MATCHUP)(matchUpType) && !existingParticipantIds?.length) ||
|
|
24213
|
+
(isMatchUpEventType(DOUBLES_MATCHUP)(matchUpType) && (existingParticipantIds?.length ?? 0) < 2))) ||
|
|
24196
24214
|
(!sideNumber &&
|
|
24197
|
-
((matchUpType
|
|
24198
|
-
(matchUpType
|
|
24215
|
+
((isMatchUpEventType(SINGLES_MATCHUP)(matchUpType) && (existingParticipantIds?.length ?? 0) < 2) ||
|
|
24216
|
+
(isMatchUpEventType(DOUBLES_MATCHUP)(matchUpType) && (existingParticipantIds?.length ?? 0) < 4)));
|
|
24199
24217
|
const availableIds = availableParticipantIds?.filter((id) => !allParticipantIds?.includes(id));
|
|
24200
24218
|
const available = availableParticipants?.filter(({ participantId }) => availableIds.includes(participantId));
|
|
24201
24219
|
if (assignmentAvailable && availableIds?.length) {
|
|
@@ -28768,7 +28786,7 @@ function getPredictiveAccuracy(params) {
|
|
|
28768
28786
|
ascending,
|
|
28769
28787
|
scaleName,
|
|
28770
28788
|
});
|
|
28771
|
-
const marginCalc = !zoneDoubling || matchUpType
|
|
28789
|
+
const marginCalc = !zoneDoubling || isMatchUpEventType(SINGLES)(matchUpType) ? zoneMargin : (zoneMargin || 0) * 2;
|
|
28772
28790
|
const zoneData = zoneMargin
|
|
28773
28791
|
? relevantMatchUps
|
|
28774
28792
|
.map(({ competitiveProfile, matchUpType, score, sides }) => {
|
|
@@ -35540,22 +35558,22 @@ function setMatchUpMatchUpFormat(params) {
|
|
|
35540
35558
|
});
|
|
35541
35559
|
if (result.error)
|
|
35542
35560
|
return result;
|
|
35543
|
-
if (!result.matchUp)
|
|
35544
|
-
return { error: MATCHUP_NOT_FOUND };
|
|
35545
35561
|
const matchUp = result.matchUp;
|
|
35546
35562
|
if (matchUp?.matchUpType === TEAM$2)
|
|
35547
35563
|
return {
|
|
35548
|
-
error: INVALID_MATCHUP,
|
|
35549
35564
|
info: 'Cannot set matchUpFormat when { matchUpType: TEAM }',
|
|
35565
|
+
error: INVALID_MATCHUP,
|
|
35550
35566
|
};
|
|
35551
|
-
matchUp
|
|
35552
|
-
|
|
35553
|
-
|
|
35554
|
-
|
|
35555
|
-
|
|
35556
|
-
|
|
35557
|
-
|
|
35558
|
-
|
|
35567
|
+
if (matchUp) {
|
|
35568
|
+
matchUp.matchUpFormat = matchUpFormat;
|
|
35569
|
+
modifyMatchUpNotice({
|
|
35570
|
+
tournamentId: tournamentRecord?.tournamentId,
|
|
35571
|
+
eventId: event?.eventId,
|
|
35572
|
+
context: stack,
|
|
35573
|
+
drawDefinition,
|
|
35574
|
+
matchUp,
|
|
35575
|
+
});
|
|
35576
|
+
}
|
|
35559
35577
|
}
|
|
35560
35578
|
else if (Array.isArray(structureIds)) {
|
|
35561
35579
|
if (event?.eventType === TEAM$2)
|
|
@@ -35564,12 +35582,8 @@ function setMatchUpMatchUpFormat(params) {
|
|
|
35564
35582
|
const result = findStructure({ drawDefinition, structureId });
|
|
35565
35583
|
if (result.error)
|
|
35566
35584
|
return result;
|
|
35567
|
-
if (
|
|
35568
|
-
return { error: STRUCTURE_NOT_FOUND };
|
|
35569
|
-
}
|
|
35570
|
-
else {
|
|
35585
|
+
if (result.structure)
|
|
35571
35586
|
result.structure.matchUpFormat = matchUpFormat;
|
|
35572
|
-
}
|
|
35573
35587
|
}
|
|
35574
35588
|
}
|
|
35575
35589
|
else if (structureId) {
|
|
@@ -35578,12 +35592,8 @@ function setMatchUpMatchUpFormat(params) {
|
|
|
35578
35592
|
const result = findStructure({ drawDefinition, structureId });
|
|
35579
35593
|
if (result.error)
|
|
35580
35594
|
return result;
|
|
35581
|
-
if (
|
|
35582
|
-
return { error: STRUCTURE_NOT_FOUND };
|
|
35583
|
-
}
|
|
35584
|
-
else {
|
|
35595
|
+
if (result.structure)
|
|
35585
35596
|
result.structure.matchUpFormat = matchUpFormat;
|
|
35586
|
-
}
|
|
35587
35597
|
}
|
|
35588
35598
|
else if (drawDefinition) {
|
|
35589
35599
|
drawDefinition.matchUpFormat = matchUpFormat;
|
|
@@ -38690,7 +38700,7 @@ function generateLineUps(params) {
|
|
|
38690
38700
|
for (const collectionDefinition of collectionDefinitions) {
|
|
38691
38701
|
const collectionParticipantIds = [];
|
|
38692
38702
|
const { collectionId, matchUpCount, matchUpType, gender } = collectionDefinition;
|
|
38693
|
-
const singlesMatchUp = matchUpType
|
|
38703
|
+
const singlesMatchUp = isMatchUpEventType(SINGLES_MATCHUP)(matchUpType);
|
|
38694
38704
|
generateRange(0, matchUpCount).forEach((i) => {
|
|
38695
38705
|
const typeSort = singlesMatchUp ? singlesSort : doublesSort ?? [];
|
|
38696
38706
|
const collectionPosition = i + 1;
|
|
@@ -39409,7 +39419,7 @@ function getTieMatchUpContext({ tournamentRecord, drawDefinition, tieMatchUpId,
|
|
|
39409
39419
|
if (!inContextTieMatchUp)
|
|
39410
39420
|
return { error: MATCHUP_NOT_FOUND };
|
|
39411
39421
|
const { collectionPosition, drawPositions, collectionId, matchUpTieId, matchUpType } = inContextTieMatchUp;
|
|
39412
|
-
if (matchUpType && ![SINGLES, DOUBLES]
|
|
39422
|
+
if (matchUpType && !includesMatchUpEventType([SINGLES, DOUBLES], matchUpType))
|
|
39413
39423
|
return { error: INVALID_MATCHUP };
|
|
39414
39424
|
const { positionAssignments } = getPositionAssignments$1({ structure });
|
|
39415
39425
|
const relevantAssignments = positionAssignments?.filter((assignment) => drawPositions?.includes(assignment.drawPosition));
|
|
@@ -39957,7 +39967,7 @@ function assignTieMatchUpParticipantId(params) {
|
|
|
39957
39967
|
return { error: INVALID_PARTICIPANT, info: 'Gender mismatch' };
|
|
39958
39968
|
}
|
|
39959
39969
|
const { individualParticipantIds, participantType } = participantToAssign;
|
|
39960
|
-
if (matchUpType
|
|
39970
|
+
if (isMatchUpEventType(SINGLES)(matchUpType) && participantType !== INDIVIDUAL) {
|
|
39961
39971
|
return { error: INVALID_PARTICIPANT_TYPE };
|
|
39962
39972
|
}
|
|
39963
39973
|
const relevantParticipantIds = participantType === INDIVIDUAL ? [participantId] : individualParticipantIds;
|
|
@@ -42780,22 +42790,23 @@ function disableTieAutoCalc({ drawDefinition, matchUpId, event }) {
|
|
|
42780
42790
|
|
|
42781
42791
|
function setMatchUpFormat(params) {
|
|
42782
42792
|
const stack = 'setMatchUpFormat';
|
|
42793
|
+
const paramsCheck = checkRequiredParameters(params, [
|
|
42794
|
+
{ tournamentRecord: true },
|
|
42795
|
+
{
|
|
42796
|
+
[VALIDATE]: (value) => isValidMatchUpFormat({ matchUpFormat: value }),
|
|
42797
|
+
[INVALID]: UNRECOGNIZED_MATCHUP_FORMAT,
|
|
42798
|
+
matchUpFormat: true,
|
|
42799
|
+
},
|
|
42800
|
+
]);
|
|
42801
|
+
if (paramsCheck.error)
|
|
42802
|
+
return decorateResult({ result: paramsCheck, stack });
|
|
42783
42803
|
const { tournamentRecord, drawDefinition, scheduledDates, stageSequences, matchUpFormat, structureId, eventType, matchUpId, eventId, stages, drawId, event, force, } = params;
|
|
42784
|
-
if (!tournamentRecord)
|
|
42785
|
-
return { error: MISSING_TOURNAMENT_RECORD };
|
|
42786
|
-
if (!matchUpFormat)
|
|
42787
|
-
return { error: MISSING_MATCHUP_FORMAT };
|
|
42788
|
-
if (matchUpFormat && !isValidMatchUpFormat({ matchUpFormat }))
|
|
42789
|
-
return decorateResult({
|
|
42790
|
-
result: { error: UNRECOGNIZED_MATCHUP_FORMAT, matchUpFormat },
|
|
42791
|
-
stack,
|
|
42792
|
-
});
|
|
42793
42804
|
if (scheduledDates && !Array.isArray(scheduledDates))
|
|
42794
42805
|
return decorateResult({
|
|
42795
42806
|
result: { error: INVALID_VALUES, scheduledDates },
|
|
42796
42807
|
stack,
|
|
42797
42808
|
});
|
|
42798
|
-
if (eventType && ![SINGLES$1, DOUBLES$1]
|
|
42809
|
+
if (eventType && !includesMatchUpEventType([SINGLES$1, DOUBLES$1], eventType))
|
|
42799
42810
|
return decorateResult({ result: { error: INVALID_EVENT_TYPE }, stack });
|
|
42800
42811
|
let modificationsCount = 0;
|
|
42801
42812
|
const structureIds = params.structureIds || (structureId && [structureId].filter(Boolean)) || [];
|
|
@@ -42867,7 +42878,7 @@ function setMatchUpFormat(params) {
|
|
|
42867
42878
|
}
|
|
42868
42879
|
return modifiedStructureIds;
|
|
42869
42880
|
};
|
|
42870
|
-
for (const event of tournamentRecord
|
|
42881
|
+
for (const event of tournamentRecord?.events || []) {
|
|
42871
42882
|
if ((eventIds?.length && !eventIds.includes(event.eventId)) ||
|
|
42872
42883
|
(eventType && eventType !== event.eventType) ||
|
|
42873
42884
|
eventType === TEAM$2) {
|
|
@@ -43317,7 +43328,7 @@ function applyLineUps({ tournamentRecord, drawDefinition, matchUpId, lineUps, ev
|
|
|
43317
43328
|
collectionParticipantIds[aggregator] = [];
|
|
43318
43329
|
}
|
|
43319
43330
|
const participantsCount = collectionParticipantIds[aggregator].length;
|
|
43320
|
-
if ((collectionDefinition.matchUpType
|
|
43331
|
+
if ((isMatchUpEventType(SINGLES)(collectionDefinition.matchUpType) && participantsCount) ||
|
|
43321
43332
|
(collectionDefinition.matchUpType === DOUBLES && participantsCount > 1)) {
|
|
43322
43333
|
return {
|
|
43323
43334
|
info: 'Excessive collectionPosition assignments',
|
|
@@ -44339,8 +44350,8 @@ function checkRecoveryTime({ individualParticipantProfiles, matchUpNotBeforeTime
|
|
|
44339
44350
|
}
|
|
44340
44351
|
|
|
44341
44352
|
function checkDailyLimits({ individualParticipantProfiles, matchUpPotentialParticipantIds, matchUpDailyLimits = {}, matchUp, }) {
|
|
44342
|
-
const { matchUpId, matchUpType } = matchUp;
|
|
44343
44353
|
const { enteredIndividualParticipantIds } = getIndividualParticipantIds(matchUp);
|
|
44354
|
+
const { matchUpId, matchUpType } = matchUp;
|
|
44344
44355
|
const potentialParticipantIds = ((matchUp.roundPosition && matchUpPotentialParticipantIds[matchUpId]) || []).flat();
|
|
44345
44356
|
const relevantParticipantIds = unique(enteredIndividualParticipantIds.concat(...potentialParticipantIds));
|
|
44346
44357
|
relevantParticipantIds.forEach((participantId) => {
|
|
@@ -46514,12 +46525,12 @@ function processTieFormat({ alternatesCount = 0, tieFormatName, tieFormat, drawS
|
|
|
46514
46525
|
}
|
|
46515
46526
|
if (!collectionId)
|
|
46516
46527
|
collectionDefinition.collectionId = UUID();
|
|
46517
|
-
if (
|
|
46528
|
+
if (isMatchUpEventType(DOUBLES)(matchUpType)) {
|
|
46518
46529
|
const doublesCount = matchUpCount;
|
|
46519
46530
|
doublesMatchUpTotal += matchUpCount;
|
|
46520
46531
|
maxDoublesCount = Math.max(maxDoublesCount, doublesCount);
|
|
46521
46532
|
}
|
|
46522
|
-
if (
|
|
46533
|
+
if (isMatchUpEventType(SINGLES)(matchUpType)) {
|
|
46523
46534
|
const singlescount = matchUpCount;
|
|
46524
46535
|
singlesMatchUpTotal += matchUpCount;
|
|
46525
46536
|
maxSinglesCount = Math.max(maxSinglesCount, singlescount);
|
|
@@ -47470,8 +47481,8 @@ function completeDrawMatchUps(params) {
|
|
|
47470
47481
|
tournamentRecord,
|
|
47471
47482
|
});
|
|
47472
47483
|
const assignParticipants = (dualMatchUp) => {
|
|
47473
|
-
const singlesMatchUps = dualMatchUp.tieMatchUps.filter((
|
|
47474
|
-
const doublesMatchUps = dualMatchUp.tieMatchUps.filter((
|
|
47484
|
+
const singlesMatchUps = dualMatchUp.tieMatchUps.filter(isMatchUpEventType(SINGLES));
|
|
47485
|
+
const doublesMatchUps = dualMatchUp.tieMatchUps.filter(isMatchUpEventType(DOUBLES));
|
|
47475
47486
|
singlesMatchUps.forEach((singlesMatchUp, i) => {
|
|
47476
47487
|
const tieMatchUpId = singlesMatchUp.matchUpId;
|
|
47477
47488
|
singlesMatchUp.sides.forEach((side) => {
|
|
@@ -47757,7 +47768,9 @@ function generateFlightDrawDefinitions({ matchUpStatusProfile, completeAllMatchU
|
|
|
47757
47768
|
function generateEventParticipants(params) {
|
|
47758
47769
|
const { participantsProfile = {}, uniqueParticipantsCount, ratingsParameters, tournamentRecord, eventProfile, eventIndex, event, uuids, } = params;
|
|
47759
47770
|
const { category, gender, eventType } = event;
|
|
47760
|
-
const eventParticipantType = (
|
|
47771
|
+
const eventParticipantType = (isMatchUpEventType(SINGLES$1)(eventType) && INDIVIDUAL) ||
|
|
47772
|
+
(isMatchUpEventType(DOUBLES$1)(eventType) && PAIR) ||
|
|
47773
|
+
eventType;
|
|
47761
47774
|
const mainParticipantsCount = uniqueParticipantsCount[MAIN] || 0;
|
|
47762
47775
|
const qualifyingParticipantsCount = uniqueParticipantsCount[QUALIFYING] || 0;
|
|
47763
47776
|
const participantsCount = eventProfile.drawProfiles?.length
|
|
@@ -47873,7 +47886,9 @@ function generateEventWithFlights(params) {
|
|
|
47873
47886
|
category,
|
|
47874
47887
|
gender,
|
|
47875
47888
|
});
|
|
47876
|
-
const eventParticipantType = (
|
|
47889
|
+
const eventParticipantType = (isMatchUpEventType(SINGLES$1)(eventType) && INDIVIDUAL) ||
|
|
47890
|
+
(isMatchUpEventType(DOUBLES$1)(eventType) && PAIR) ||
|
|
47891
|
+
eventType;
|
|
47877
47892
|
const { uniqueDrawParticipants = [], uniqueParticipantIds = [] } = uniqueParticipantStages
|
|
47878
47893
|
? generateEventParticipants({
|
|
47879
47894
|
event: { eventType, category, gender },
|
|
@@ -48233,9 +48248,9 @@ function generateEventWithDraw(params) {
|
|
|
48233
48248
|
}
|
|
48234
48249
|
const isEventParticipantType = (participant) => {
|
|
48235
48250
|
const { participantType } = participant;
|
|
48236
|
-
if (
|
|
48251
|
+
if (isMatchUpEventType(SINGLES$1)(eventType) && participantType === INDIVIDUAL)
|
|
48237
48252
|
return true;
|
|
48238
|
-
if (
|
|
48253
|
+
if (isMatchUpEventType(DOUBLES$1)(eventType) && participantType === PAIR)
|
|
48239
48254
|
return true;
|
|
48240
48255
|
return eventType === TEAM && participantType === TEAM;
|
|
48241
48256
|
};
|
|
@@ -48987,7 +49002,9 @@ function modifyTournamentRecord(params) {
|
|
|
48987
49002
|
else {
|
|
48988
49003
|
const { gender, category, eventType } = event;
|
|
48989
49004
|
const { drawProfiles, publish } = eventProfile;
|
|
48990
|
-
const eventParticipantType = (
|
|
49005
|
+
const eventParticipantType = (isMatchUpEventType(SINGLES$1)(eventType) && INDIVIDUAL) ||
|
|
49006
|
+
(isMatchUpEventType(DOUBLES$1)(eventType) && PAIR) ||
|
|
49007
|
+
eventType;
|
|
48991
49008
|
if (drawProfiles) {
|
|
48992
49009
|
const { stageParticipantsCount, uniqueParticipantsCount, uniqueParticipantStages } = getStageParticipantsCount({
|
|
48993
49010
|
drawProfiles,
|
|
@@ -54947,9 +54964,11 @@ function venueModify({ tournamentRecord, modifications, venueId, force }) {
|
|
|
54947
54964
|
validReplacementAttributes.forEach((attribute) => Object.assign(venue, { [attribute]: modifications[attribute] }));
|
|
54948
54965
|
const existingCourtIds = venue?.courts?.map((court) => court.courtId) ?? [];
|
|
54949
54966
|
const courtIdsToModify = modifications.courts?.map((court) => court.courtId) || [];
|
|
54950
|
-
const courtIdsToDelete = courtIdsToModify.length
|
|
54967
|
+
const courtIdsToDelete = courtIdsToModify.length
|
|
54968
|
+
? existingCourtIds.filter((courtId) => !courtIdsToModify.includes(courtId))
|
|
54969
|
+
: modifications?.courts && existingCourtIds;
|
|
54951
54970
|
const matchUpsWithCourtId = [];
|
|
54952
|
-
if (courtIdsToDelete
|
|
54971
|
+
if (courtIdsToDelete?.length) {
|
|
54953
54972
|
const courtsToDelete = venue?.courts?.filter((court) => courtIdsToDelete.includes(court.courtId));
|
|
54954
54973
|
const scheduleDeletionsCount = courtsToDelete
|
|
54955
54974
|
?.map((court) => {
|
|
@@ -55372,60 +55391,6 @@ var index$1 = {
|
|
|
55372
55391
|
|
|
55373
55392
|
const forge = {};
|
|
55374
55393
|
|
|
55375
|
-
function notifySubscribers(params) {
|
|
55376
|
-
const { mutationStatus, tournamentId, directives, timeStamp } = params || {};
|
|
55377
|
-
const { topics } = getTopics();
|
|
55378
|
-
for (const topic of [...topics].sort(topicSort)) {
|
|
55379
|
-
const notices = getNotices({ topic });
|
|
55380
|
-
if (notices)
|
|
55381
|
-
callListener({ topic, notices });
|
|
55382
|
-
}
|
|
55383
|
-
if (mutationStatus && timeStamp && topics.includes(MUTATIONS)) {
|
|
55384
|
-
callListener({
|
|
55385
|
-
notices: [{ tournamentId, directives, timeStamp }],
|
|
55386
|
-
topic: MUTATIONS,
|
|
55387
|
-
});
|
|
55388
|
-
}
|
|
55389
|
-
}
|
|
55390
|
-
async function notifySubscribersAsync(params) {
|
|
55391
|
-
const { mutationStatus, tournamentId, directives, timeStamp } = params || {};
|
|
55392
|
-
const { topics } = getTopics();
|
|
55393
|
-
for (const topic of [...topics].sort(topicSort)) {
|
|
55394
|
-
const notices = getNotices({ topic });
|
|
55395
|
-
if (notices)
|
|
55396
|
-
await callListener({ topic, notices });
|
|
55397
|
-
}
|
|
55398
|
-
if (mutationStatus && timeStamp && topics.includes(MUTATIONS)) {
|
|
55399
|
-
callListener({
|
|
55400
|
-
notices: [{ tournamentId, directives, timeStamp }],
|
|
55401
|
-
topic: MUTATIONS,
|
|
55402
|
-
});
|
|
55403
|
-
}
|
|
55404
|
-
}
|
|
55405
|
-
const topicValues = {
|
|
55406
|
-
[UNPUBLISH_EVENT_SEEDING]: 5,
|
|
55407
|
-
[UNPUBLISH_EVENT]: 5,
|
|
55408
|
-
[UNPUBLISH_ORDER_OF_PLAY]: 5,
|
|
55409
|
-
[MODIFY_SEED_ASSIGNMENTS]: 5,
|
|
55410
|
-
[MODIFY_POSITION_ASSIGNMENTS]: 5,
|
|
55411
|
-
[MODIFY_DRAW_DEFINITION]: 5,
|
|
55412
|
-
[MODIFY_DRAW_ENTRIES]: 5,
|
|
55413
|
-
[MODIFY_EVENT_ENTRIES]: 5,
|
|
55414
|
-
[MODIFY_MATCHUP]: 1,
|
|
55415
|
-
[UPDATE_INCONTEXT_MATCHUP]: 1,
|
|
55416
|
-
[MODIFY_PARTICIPANTS]: 5,
|
|
55417
|
-
[MODIFY_VENUE]: 5,
|
|
55418
|
-
[DELETED_MATCHUP_IDS]: 4,
|
|
55419
|
-
[DELETE_PARTICIPANTS]: 4,
|
|
55420
|
-
[DELETE_VENUE]: 4,
|
|
55421
|
-
[DELETED_DRAW_IDS]: 4,
|
|
55422
|
-
[ADD_MATCHUPS]: 3,
|
|
55423
|
-
[ADD_DRAW_DEFINITION]: 2,
|
|
55424
|
-
};
|
|
55425
|
-
function topicSort(a, b) {
|
|
55426
|
-
return (topicValues[b] || 0) - (topicValues[a] || 0);
|
|
55427
|
-
}
|
|
55428
|
-
|
|
55429
55394
|
const { FACTORY } = extensionConstants;
|
|
55430
55395
|
function updateFactoryExtension({ tournamentRecord, value }) {
|
|
55431
55396
|
const { extension } = findExtension({
|
|
@@ -55591,6 +55556,60 @@ function invoke({ tournamentRecords, tournamentRecord, params, methodName, metho
|
|
|
55591
55556
|
}
|
|
55592
55557
|
}
|
|
55593
55558
|
|
|
55559
|
+
function notifySubscribers(params) {
|
|
55560
|
+
const { mutationStatus, tournamentId, directives, timeStamp } = params || {};
|
|
55561
|
+
const { topics } = getTopics();
|
|
55562
|
+
for (const topic of [...topics].sort(topicSort)) {
|
|
55563
|
+
const notices = getNotices({ topic });
|
|
55564
|
+
if (notices)
|
|
55565
|
+
callListener({ topic, notices });
|
|
55566
|
+
}
|
|
55567
|
+
if (mutationStatus && timeStamp && topics.includes(MUTATIONS)) {
|
|
55568
|
+
callListener({
|
|
55569
|
+
notices: [{ tournamentId, directives, timeStamp }],
|
|
55570
|
+
topic: MUTATIONS,
|
|
55571
|
+
});
|
|
55572
|
+
}
|
|
55573
|
+
}
|
|
55574
|
+
async function notifySubscribersAsync(params) {
|
|
55575
|
+
const { mutationStatus, tournamentId, directives, timeStamp } = params || {};
|
|
55576
|
+
const { topics } = getTopics();
|
|
55577
|
+
for (const topic of [...topics].sort(topicSort)) {
|
|
55578
|
+
const notices = getNotices({ topic });
|
|
55579
|
+
if (notices)
|
|
55580
|
+
await callListener({ topic, notices });
|
|
55581
|
+
}
|
|
55582
|
+
if (mutationStatus && timeStamp && topics.includes(MUTATIONS)) {
|
|
55583
|
+
callListener({
|
|
55584
|
+
notices: [{ tournamentId, directives, timeStamp }],
|
|
55585
|
+
topic: MUTATIONS,
|
|
55586
|
+
});
|
|
55587
|
+
}
|
|
55588
|
+
}
|
|
55589
|
+
const topicValues = {
|
|
55590
|
+
[UNPUBLISH_EVENT_SEEDING]: 5,
|
|
55591
|
+
[UNPUBLISH_EVENT]: 5,
|
|
55592
|
+
[UNPUBLISH_ORDER_OF_PLAY]: 5,
|
|
55593
|
+
[MODIFY_SEED_ASSIGNMENTS]: 5,
|
|
55594
|
+
[MODIFY_POSITION_ASSIGNMENTS]: 5,
|
|
55595
|
+
[MODIFY_DRAW_DEFINITION]: 5,
|
|
55596
|
+
[MODIFY_DRAW_ENTRIES]: 5,
|
|
55597
|
+
[MODIFY_EVENT_ENTRIES]: 5,
|
|
55598
|
+
[MODIFY_MATCHUP]: 1,
|
|
55599
|
+
[UPDATE_INCONTEXT_MATCHUP]: 1,
|
|
55600
|
+
[MODIFY_PARTICIPANTS]: 5,
|
|
55601
|
+
[MODIFY_VENUE]: 5,
|
|
55602
|
+
[DELETED_MATCHUP_IDS]: 4,
|
|
55603
|
+
[DELETE_PARTICIPANTS]: 4,
|
|
55604
|
+
[DELETE_VENUE]: 4,
|
|
55605
|
+
[DELETED_DRAW_IDS]: 4,
|
|
55606
|
+
[ADD_MATCHUPS]: 3,
|
|
55607
|
+
[ADD_DRAW_DEFINITION]: 2,
|
|
55608
|
+
};
|
|
55609
|
+
function topicSort(a, b) {
|
|
55610
|
+
return (topicValues[b] || 0) - (topicValues[a] || 0);
|
|
55611
|
+
}
|
|
55612
|
+
|
|
55594
55613
|
function getState$1({ convertExtensions, removeExtensions }) {
|
|
55595
55614
|
const tournamentRecords = getTournamentRecords();
|
|
55596
55615
|
const tournamentId = getTournamentId();
|