tods-competition-factory 1.7.12 → 1.7.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/forge/generate.mjs +11 -9
- package/dist/forge/generate.mjs.map +1 -1
- package/dist/forge/query.d.ts +2 -1
- package/dist/forge/query.mjs +8 -7
- package/dist/forge/query.mjs.map +1 -1
- package/dist/forge/transform.mjs +6 -5
- package/dist/forge/transform.mjs.map +1 -1
- package/dist/index.mjs +614 -321
- package/dist/index.mjs.map +1 -1
- package/dist/tods-competition-factory.development.cjs.js +619 -320
- 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 +4 -4
package/dist/index.mjs
CHANGED
|
@@ -333,7 +333,7 @@ const matchUpFormatCode = {
|
|
|
333
333
|
};
|
|
334
334
|
|
|
335
335
|
function factoryVersion() {
|
|
336
|
-
return "1.7.
|
|
336
|
+
return "1.7.14";
|
|
337
337
|
}
|
|
338
338
|
|
|
339
339
|
function getObjectTieFormat(obj) {
|
|
@@ -2426,8 +2426,9 @@ function decorateResult({
|
|
|
2426
2426
|
if (result && Array.isArray(result?.stack) && typeof stack === "string") {
|
|
2427
2427
|
result.stack.push(stack);
|
|
2428
2428
|
}
|
|
2429
|
-
if (
|
|
2430
|
-
result.
|
|
2429
|
+
if (result && info) {
|
|
2430
|
+
result.info = info;
|
|
2431
|
+
}
|
|
2431
2432
|
if (result && typeof context === "object" && Object.keys(context).length) {
|
|
2432
2433
|
Object.assign(result, definedAttributes(context));
|
|
2433
2434
|
}
|
|
@@ -2557,7 +2558,7 @@ function validateTieFormat(params) {
|
|
|
2557
2558
|
const tieFormat = params?.tieFormat;
|
|
2558
2559
|
const stack = "validateTieFormat";
|
|
2559
2560
|
const errors = [];
|
|
2560
|
-
if (typeof tieFormat !== "object") {
|
|
2561
|
+
if (!params || !tieFormat || typeof tieFormat !== "object") {
|
|
2561
2562
|
errors.push("tieFormat must be an object");
|
|
2562
2563
|
return decorateResult({
|
|
2563
2564
|
result: {
|
|
@@ -2695,7 +2696,7 @@ function validateCollectionDefinition({
|
|
|
2695
2696
|
errors.push(`collectionValue is not type number: ${collectionValue}`);
|
|
2696
2697
|
}
|
|
2697
2698
|
if (collectionValueProfiles) {
|
|
2698
|
-
const result =
|
|
2699
|
+
const result = validateCollectionValueProfiles({
|
|
2699
2700
|
collectionValueProfiles,
|
|
2700
2701
|
matchUpCount
|
|
2701
2702
|
});
|
|
@@ -2726,7 +2727,7 @@ function checkTieFormat(tieFormat) {
|
|
|
2726
2727
|
}
|
|
2727
2728
|
return { tieFormat };
|
|
2728
2729
|
}
|
|
2729
|
-
function
|
|
2730
|
+
function validateCollectionValueProfiles({
|
|
2730
2731
|
collectionValueProfiles,
|
|
2731
2732
|
matchUpCount
|
|
2732
2733
|
}) {
|
|
@@ -16570,6 +16571,10 @@ function proConflicts({
|
|
|
16570
16571
|
return { courtIssues, rowIssues };
|
|
16571
16572
|
}
|
|
16572
16573
|
|
|
16574
|
+
function stringSort(a, b) {
|
|
16575
|
+
return (a || "").localeCompare(b || "");
|
|
16576
|
+
}
|
|
16577
|
+
|
|
16573
16578
|
function getTieFormatDesc(tieFormat) {
|
|
16574
16579
|
if (!tieFormat)
|
|
16575
16580
|
return {};
|
|
@@ -16652,7 +16657,30 @@ function compareTieFormats({
|
|
|
16652
16657
|
ancestorDifferences.groupsCount = descendantDifferences.groupsCount ? -1 * descendantDifferences.groupsCount : 0;
|
|
16653
16658
|
const valueDifference = descendantDifferences.collectionsValue.totalValue - ancestorDifferences.collectionsValue.totalValue;
|
|
16654
16659
|
const matchUpCountDifference = descendantDifferences.collectionsValue.totalMatchUps - ancestorDifferences.collectionsValue.totalMatchUps;
|
|
16655
|
-
const
|
|
16660
|
+
const assignmentValuesCountDifference = ancestorDifferences.collectionsValue.assignmentValues.length !== descendantDifferences.collectionsValue.assignmentValues.length;
|
|
16661
|
+
const assignmentValuesDifference = ancestorDifferences.collectionsValue.assignmentValues.some(
|
|
16662
|
+
(assignment, i) => {
|
|
16663
|
+
const comparisonAssignment = descendantDifferences.collectionsValue.assignmentValues[i];
|
|
16664
|
+
if (!comparisonAssignment)
|
|
16665
|
+
return true;
|
|
16666
|
+
if (assignment.valueKey !== comparisonAssignment.valueKey)
|
|
16667
|
+
return true;
|
|
16668
|
+
if (assignment.value !== comparisonAssignment.value)
|
|
16669
|
+
return true;
|
|
16670
|
+
if (Array.isArray(assignment.value)) {
|
|
16671
|
+
return assignment.value.every(
|
|
16672
|
+
(value, i2) => comparisonAssignment.value[i2] === value
|
|
16673
|
+
);
|
|
16674
|
+
}
|
|
16675
|
+
return false;
|
|
16676
|
+
}
|
|
16677
|
+
);
|
|
16678
|
+
const different = nameDifference || orderDifference || ancestorDesc !== descendantDesc || assignmentValuesCountDifference || assignmentValuesDifference || valueDifference !== 0;
|
|
16679
|
+
const invalidValues = [
|
|
16680
|
+
...ancestorDifferences.collectionsValue.invalidValues,
|
|
16681
|
+
...descendantDifferences.collectionsValue.invalidValues
|
|
16682
|
+
];
|
|
16683
|
+
const invalid = invalidValues.length && invalidValues;
|
|
16656
16684
|
return {
|
|
16657
16685
|
matchUpFormatDifferences,
|
|
16658
16686
|
matchUpCountDifference,
|
|
@@ -16664,12 +16692,15 @@ function compareTieFormats({
|
|
|
16664
16692
|
descendantDesc,
|
|
16665
16693
|
ancestorDesc,
|
|
16666
16694
|
...SUCCESS,
|
|
16667
|
-
different
|
|
16695
|
+
different,
|
|
16696
|
+
invalid
|
|
16668
16697
|
};
|
|
16669
16698
|
}
|
|
16670
16699
|
function getCollectionsValue(definitions) {
|
|
16700
|
+
const invalidValues = [];
|
|
16701
|
+
const assignmentValues = [];
|
|
16671
16702
|
let totalMatchUps = 0;
|
|
16672
|
-
const collectionIds = Object.keys(definitions);
|
|
16703
|
+
const collectionIds = Object.keys(definitions).sort(stringSort);
|
|
16673
16704
|
const totalValue = collectionIds.reduce((total, collectionId) => {
|
|
16674
16705
|
const collectionDefinition = definitions[collectionId];
|
|
16675
16706
|
const {
|
|
@@ -16680,6 +16711,24 @@ function getCollectionsValue(definitions) {
|
|
|
16680
16711
|
scoreValue,
|
|
16681
16712
|
setValue
|
|
16682
16713
|
} = collectionDefinition;
|
|
16714
|
+
const valueAssignments = {
|
|
16715
|
+
collectionValueProfiles,
|
|
16716
|
+
collectionValue,
|
|
16717
|
+
matchUpValue,
|
|
16718
|
+
scoreValue,
|
|
16719
|
+
setValue
|
|
16720
|
+
};
|
|
16721
|
+
const valueKeys = Object.keys(valueAssignments).filter(
|
|
16722
|
+
(key) => ![void 0, null].includes(valueAssignments[key])
|
|
16723
|
+
);
|
|
16724
|
+
if (valueKeys.length !== 1) {
|
|
16725
|
+
invalidValues.push({ collectionId });
|
|
16726
|
+
}
|
|
16727
|
+
const valueKey = valueKeys[0];
|
|
16728
|
+
if (valueKey) {
|
|
16729
|
+
const value = valueKey === "collectionValueProfiles" ? Object.values(collectionValueProfiles) : valueAssignments[valueKey];
|
|
16730
|
+
assignmentValues.push({ valueKey, value });
|
|
16731
|
+
}
|
|
16683
16732
|
totalMatchUps += matchUpCount;
|
|
16684
16733
|
if (collectionValueProfiles)
|
|
16685
16734
|
return total + collectionValueProfiles.reduce(
|
|
@@ -16697,7 +16746,7 @@ function getCollectionsValue(definitions) {
|
|
|
16697
16746
|
}
|
|
16698
16747
|
return total;
|
|
16699
16748
|
}, 0);
|
|
16700
|
-
return { totalValue, totalMatchUps };
|
|
16749
|
+
return { totalValue, totalMatchUps, invalidValues, assignmentValues };
|
|
16701
16750
|
}
|
|
16702
16751
|
|
|
16703
16752
|
function dehydrateMatchUps({ tournamentRecord }) {
|
|
@@ -29569,6 +29618,7 @@ function getTieFormat$1({
|
|
|
29569
29618
|
// optional - if an eventId is present only return tieFormat for event
|
|
29570
29619
|
event
|
|
29571
29620
|
}) {
|
|
29621
|
+
const stack = "getTieFormat";
|
|
29572
29622
|
let tieFormat;
|
|
29573
29623
|
structureId = structure?.structureId ?? structureId;
|
|
29574
29624
|
matchUpId = matchUp?.matchUpId ?? matchUpId;
|
|
@@ -29584,6 +29634,9 @@ function getTieFormat$1({
|
|
|
29584
29634
|
});
|
|
29585
29635
|
if (result.error)
|
|
29586
29636
|
return result;
|
|
29637
|
+
if (result.matchUp?.matchUpType !== TEAM_MATCHUP) {
|
|
29638
|
+
return decorateResult({ result: { error: INVALID_MATCHUP }, stack });
|
|
29639
|
+
}
|
|
29587
29640
|
if (!structure)
|
|
29588
29641
|
structure = result.structure;
|
|
29589
29642
|
if (!matchUp)
|
|
@@ -29617,8 +29670,13 @@ function getTieFormat$1({
|
|
|
29617
29670
|
tieFormat = getObjectTieFormat(drawDefinition) || getObjectTieFormat(event);
|
|
29618
29671
|
}
|
|
29619
29672
|
if (!tieFormat)
|
|
29620
|
-
return decorateResult({ result: { error: MISSING_TIE_FORMAT } });
|
|
29621
|
-
return {
|
|
29673
|
+
return decorateResult({ result: { error: MISSING_TIE_FORMAT }, stack });
|
|
29674
|
+
return {
|
|
29675
|
+
...SUCCESS,
|
|
29676
|
+
structure,
|
|
29677
|
+
tieFormat,
|
|
29678
|
+
matchUp
|
|
29679
|
+
};
|
|
29622
29680
|
}
|
|
29623
29681
|
|
|
29624
29682
|
function tieFormatTelemetry({ drawDefinition, auditData }) {
|
|
@@ -29633,13 +29691,59 @@ function tieFormatTelemetry({ drawDefinition, auditData }) {
|
|
|
29633
29691
|
addExtension$1({ element: drawDefinition, extension: updatedExtension });
|
|
29634
29692
|
}
|
|
29635
29693
|
|
|
29694
|
+
function generateTieMatchUps({
|
|
29695
|
+
tieFormat,
|
|
29696
|
+
isMock,
|
|
29697
|
+
uuids
|
|
29698
|
+
}) {
|
|
29699
|
+
const { collectionDefinitions } = tieFormat ?? {};
|
|
29700
|
+
const tieMatchUps = (collectionDefinitions ?? []).map(
|
|
29701
|
+
(collectionDefinition) => generateCollectionMatchUps({ collectionDefinition, uuids, isMock })
|
|
29702
|
+
).filter(Boolean).flat();
|
|
29703
|
+
return { tieMatchUps };
|
|
29704
|
+
}
|
|
29705
|
+
function generateCollectionMatchUps({
|
|
29706
|
+
collectionPositionOffset = 0,
|
|
29707
|
+
collectionDefinition,
|
|
29708
|
+
matchUpsLimit,
|
|
29709
|
+
// internal use allows generation of missing matchUps on "reset"
|
|
29710
|
+
isMock,
|
|
29711
|
+
uuids
|
|
29712
|
+
}) {
|
|
29713
|
+
const { matchUpCount, matchUpType, collectionId, processCodes } = collectionDefinition || {};
|
|
29714
|
+
const numberToGenerate = matchUpsLimit ?? matchUpCount ?? 0;
|
|
29715
|
+
return generateRange(0, numberToGenerate).map((index) => {
|
|
29716
|
+
const collectionPosition = collectionPositionOffset + index + 1;
|
|
29717
|
+
return {
|
|
29718
|
+
sides: [{ sideNumber: 1 }, { sideNumber: 2 }],
|
|
29719
|
+
matchUpId: uuids?.pop() || UUID(),
|
|
29720
|
+
matchUpStatus: MatchUpStatusEnum.ToBePlayed,
|
|
29721
|
+
collectionPosition,
|
|
29722
|
+
collectionId,
|
|
29723
|
+
processCodes,
|
|
29724
|
+
matchUpType,
|
|
29725
|
+
isMock
|
|
29726
|
+
};
|
|
29727
|
+
});
|
|
29728
|
+
}
|
|
29729
|
+
|
|
29636
29730
|
function validUpdate({ matchUp, updateInProgressMatchUps }) {
|
|
29637
29731
|
return !matchUp.winningSide && ![completedMatchUpStatuses].includes(matchUp.matchUpStatus) && (updateInProgressMatchUps || matchUp.matchUpStatus !== IN_PROGRESS$1 && !scoreHasValue(matchUp));
|
|
29638
29732
|
}
|
|
29639
29733
|
|
|
29640
|
-
function
|
|
29641
|
-
const referenceKeys = Object.keys(
|
|
29642
|
-
|
|
29734
|
+
function checkStructureMatchUpCounts({ from, to }) {
|
|
29735
|
+
const referenceKeys = Object.keys(from);
|
|
29736
|
+
const sameKeys = intersection(referenceKeys, Object.keys(to)).length === referenceKeys.length;
|
|
29737
|
+
const differentMatchUpsCount = referenceKeys.filter(
|
|
29738
|
+
(collectionId) => from[collectionId] !== to[collectionId]
|
|
29739
|
+
);
|
|
29740
|
+
const matchUpsCountChanges = differentMatchUpsCount.map((collectionId) => ({
|
|
29741
|
+
countChange: to[collectionId] - from[collectionId],
|
|
29742
|
+
collectionId
|
|
29743
|
+
}));
|
|
29744
|
+
const sameMatchUpsCount = referenceKeys.every((key) => from[key] === to[key]);
|
|
29745
|
+
const equivalent = sameKeys && sameMatchUpsCount;
|
|
29746
|
+
return { equivalent, matchUpsCountChanges };
|
|
29643
29747
|
}
|
|
29644
29748
|
function updateTieFormat({
|
|
29645
29749
|
updateInProgressMatchUps,
|
|
@@ -29649,10 +29753,14 @@ function updateTieFormat({
|
|
|
29649
29753
|
tieFormat,
|
|
29650
29754
|
eventId,
|
|
29651
29755
|
matchUp,
|
|
29652
|
-
event
|
|
29756
|
+
event,
|
|
29757
|
+
uuids
|
|
29653
29758
|
}) {
|
|
29654
29759
|
const stack = "updateTieFormat";
|
|
29760
|
+
const tournamentId = tournamentRecord?.tournamentId;
|
|
29655
29761
|
let modifiedStructuresCount = 0;
|
|
29762
|
+
let modifiedMatchUpsCount = 0;
|
|
29763
|
+
let addedMatchUpsCount = 0;
|
|
29656
29764
|
let modifiedCount = 0;
|
|
29657
29765
|
const collectionMap = tieFormat?.collectionDefinitions.reduce(
|
|
29658
29766
|
(instanceMap, def) => {
|
|
@@ -29666,7 +29774,7 @@ function updateTieFormat({
|
|
|
29666
29774
|
instanceMap[def.collectionId] = (instanceMap[def.collectionId] || 0) + def.matchUpCount;
|
|
29667
29775
|
return instanceMap;
|
|
29668
29776
|
}, {});
|
|
29669
|
-
return
|
|
29777
|
+
return checkStructureMatchUpCounts({ from: cMap, to: collectionMap }).equivalent;
|
|
29670
29778
|
};
|
|
29671
29779
|
const drawDefaultTieFormat = getTieFormat$1({ drawDefinition })?.tieFormat;
|
|
29672
29780
|
const eventDefaultTieFormat = getTieFormat$1({ event })?.tieFormat;
|
|
@@ -29674,7 +29782,7 @@ function updateTieFormat({
|
|
|
29674
29782
|
for (const drawDefinition2 of event.drawDefinitions ?? []) {
|
|
29675
29783
|
processDrawDefinition({ drawDefinition: drawDefinition2 });
|
|
29676
29784
|
}
|
|
29677
|
-
event.tieFormat = tieFormat;
|
|
29785
|
+
event.tieFormat = copyTieFormat(tieFormat);
|
|
29678
29786
|
modifiedCount += 1;
|
|
29679
29787
|
} else if (matchUp) {
|
|
29680
29788
|
if (!matchUp.tieMatchUps) {
|
|
@@ -29683,9 +29791,17 @@ function updateTieFormat({
|
|
|
29683
29791
|
const matchUpMap = instanceCount(
|
|
29684
29792
|
matchUp.tieMatchUps?.map(({ collectionId }) => collectionId)
|
|
29685
29793
|
);
|
|
29686
|
-
|
|
29794
|
+
const check = checkStructureMatchUpCounts({
|
|
29795
|
+
to: collectionMap,
|
|
29796
|
+
from: matchUpMap
|
|
29797
|
+
});
|
|
29798
|
+
const { changes, changesArePossible, cannotChangeReaon } = getMatchUpChangesArePossible({
|
|
29799
|
+
matchUp,
|
|
29800
|
+
check
|
|
29801
|
+
});
|
|
29802
|
+
if (check.equivalent) {
|
|
29687
29803
|
if (validUpdate({ matchUp, updateInProgressMatchUps })) {
|
|
29688
|
-
matchUp.tieFormat = tieFormat;
|
|
29804
|
+
matchUp.tieFormat = copyTieFormat(tieFormat);
|
|
29689
29805
|
modifiedCount += 1;
|
|
29690
29806
|
} else {
|
|
29691
29807
|
return decorateResult({
|
|
@@ -29693,44 +29809,64 @@ function updateTieFormat({
|
|
|
29693
29809
|
info: "matchUp is IN_PROGRESS or COMPLETE"
|
|
29694
29810
|
});
|
|
29695
29811
|
}
|
|
29812
|
+
} else if (changesArePossible) {
|
|
29813
|
+
makeChanges({ tieFormat, matchUp, changes, uuids });
|
|
29696
29814
|
} else {
|
|
29697
29815
|
return decorateResult({
|
|
29698
29816
|
context: { collectionMap, matchUpMap },
|
|
29699
29817
|
result: { error: INVALID_TIE_FORMAT },
|
|
29700
|
-
info: "
|
|
29818
|
+
info: cannotChangeReaon || "specified changes not possible",
|
|
29701
29819
|
stack
|
|
29702
29820
|
});
|
|
29703
29821
|
}
|
|
29822
|
+
modifiedMatchUpsCount += 1;
|
|
29704
29823
|
modifyMatchUpNotice({
|
|
29705
|
-
tournamentId: tournamentRecord?.tournamentId,
|
|
29706
29824
|
eventId: event?.eventId,
|
|
29707
29825
|
context: stack,
|
|
29708
29826
|
drawDefinition,
|
|
29827
|
+
tournamentId,
|
|
29709
29828
|
matchUp
|
|
29710
29829
|
});
|
|
29711
29830
|
} else if (structure) {
|
|
29712
|
-
const inheritedTieFormat = drawDefaultTieFormat
|
|
29831
|
+
const inheritedTieFormat = drawDefaultTieFormat ?? eventDefaultTieFormat;
|
|
29713
29832
|
const modified = processStructure({
|
|
29714
29833
|
inheritedTieFormat,
|
|
29715
29834
|
structure
|
|
29716
|
-
})?.
|
|
29717
|
-
if (modified)
|
|
29718
|
-
|
|
29719
|
-
|
|
29720
|
-
|
|
29721
|
-
|
|
29835
|
+
})?.modifiedMatchUpsCount;
|
|
29836
|
+
if (modified) {
|
|
29837
|
+
modifiedMatchUpsCount += modified;
|
|
29838
|
+
modifiedStructuresCount += 1;
|
|
29839
|
+
modifiedCount += 1;
|
|
29840
|
+
}
|
|
29841
|
+
const different = !structure.tieFormat || compareTieFormats({
|
|
29842
|
+
ancestor: structure.tieFormat,
|
|
29843
|
+
descendant: tieFormat
|
|
29844
|
+
}).different;
|
|
29845
|
+
if (different) {
|
|
29846
|
+
structure.tieFormat = copyTieFormat(tieFormat);
|
|
29847
|
+
modifiedStructuresCount += 1;
|
|
29848
|
+
modifiedCount += 1;
|
|
29849
|
+
}
|
|
29850
|
+
(modified || different) && drawDefinition && modifyDrawNotice({
|
|
29722
29851
|
structureIds: [structure.structureId],
|
|
29723
29852
|
eventId: event?.eventId,
|
|
29724
29853
|
drawDefinition
|
|
29725
29854
|
});
|
|
29726
29855
|
} else if (drawDefinition) {
|
|
29727
29856
|
processDrawDefinition({ drawDefinition });
|
|
29728
|
-
drawDefinition.tieFormat = tieFormat;
|
|
29857
|
+
drawDefinition.tieFormat = copyTieFormat(tieFormat);
|
|
29729
29858
|
modifiedCount += 1;
|
|
29730
29859
|
} else {
|
|
29731
29860
|
return { error: MISSING_DRAW_DEFINITION };
|
|
29732
29861
|
}
|
|
29733
|
-
return {
|
|
29862
|
+
return {
|
|
29863
|
+
modifiedStructuresCount,
|
|
29864
|
+
modifiedMatchUpsCount,
|
|
29865
|
+
addedMatchUpsCount,
|
|
29866
|
+
modifiedCount,
|
|
29867
|
+
...SUCCESS,
|
|
29868
|
+
tieFormat
|
|
29869
|
+
};
|
|
29734
29870
|
function processDrawDefinition({ drawDefinition: drawDefinition2 }) {
|
|
29735
29871
|
const structures = drawDefinition2.structures || [];
|
|
29736
29872
|
const modifiedStructureIds = [];
|
|
@@ -29741,9 +29877,10 @@ function updateTieFormat({
|
|
|
29741
29877
|
const modifiedCount2 = processStructure({
|
|
29742
29878
|
inheritedTieFormat,
|
|
29743
29879
|
structure: structure2
|
|
29744
|
-
})?.
|
|
29880
|
+
})?.modifiedMatchUpsCount;
|
|
29745
29881
|
if (modifiedCount2) {
|
|
29746
|
-
modifiedStructuresCount +=
|
|
29882
|
+
modifiedStructuresCount += 1;
|
|
29883
|
+
modifiedMatchUpsCount += modifiedCount2;
|
|
29747
29884
|
const structureId = structure2.structureId;
|
|
29748
29885
|
modifiedStructureIds.push(structureId);
|
|
29749
29886
|
}
|
|
@@ -29756,32 +29893,49 @@ function updateTieFormat({
|
|
|
29756
29893
|
return modifiedStructureIds.length;
|
|
29757
29894
|
}
|
|
29758
29895
|
function processStructure({ inheritedTieFormat, structure: structure2 }) {
|
|
29759
|
-
let
|
|
29896
|
+
let modifiedMatchUpsCount2 = 0;
|
|
29760
29897
|
const structureMatchUps = getAllStructureMatchUps({
|
|
29761
29898
|
matchUpFilters: { matchUpTypes: [TEAM$2] },
|
|
29762
29899
|
structure: structure2
|
|
29763
29900
|
})?.matchUps || [];
|
|
29764
29901
|
for (const matchUp2 of structureMatchUps) {
|
|
29902
|
+
const validToUpdate = validUpdate({ matchUp: matchUp2, updateInProgressMatchUps });
|
|
29765
29903
|
let modified = false;
|
|
29766
29904
|
const tieMatchUpsMap = instanceCount(
|
|
29767
29905
|
matchUp2.tieMatchUps?.map(({ collectionId }) => collectionId)
|
|
29768
29906
|
);
|
|
29769
|
-
|
|
29770
|
-
|
|
29771
|
-
|
|
29772
|
-
|
|
29907
|
+
const check = checkStructureMatchUpCounts({
|
|
29908
|
+
from: tieMatchUpsMap,
|
|
29909
|
+
to: collectionMap
|
|
29910
|
+
});
|
|
29911
|
+
if (!check.equivalent) {
|
|
29912
|
+
const { changes, changesArePossible } = getMatchUpChangesArePossible({
|
|
29913
|
+
matchUp: matchUp2,
|
|
29914
|
+
check
|
|
29915
|
+
});
|
|
29916
|
+
if (changesArePossible && !matchUp2.tieFormat) {
|
|
29917
|
+
makeChanges({ changes, matchUp: matchUp2, tieFormat, uuids });
|
|
29918
|
+
} else if (inheritedTieFormat) {
|
|
29919
|
+
const different = !matchUp2.tieFormat || compareTieFormats({
|
|
29920
|
+
ancestor: inheritedTieFormat,
|
|
29921
|
+
descendant: matchUp2.tieFormat
|
|
29922
|
+
}).different;
|
|
29923
|
+
if (different) {
|
|
29924
|
+
matchUp2.tieFormat = inheritedTieFormat;
|
|
29925
|
+
modified = true;
|
|
29926
|
+
}
|
|
29773
29927
|
} else {
|
|
29774
29928
|
return decorateResult({
|
|
29775
29929
|
result: { error: MISSING_TIE_FORMAT },
|
|
29776
29930
|
stack
|
|
29777
29931
|
});
|
|
29778
29932
|
}
|
|
29779
|
-
} else if (matchUp2.tieFormat && matchingCollections(matchUp2) &&
|
|
29933
|
+
} else if (matchUp2.tieFormat && matchingCollections(matchUp2) && validToUpdate) {
|
|
29780
29934
|
matchUp2.tieFormat = copyTieFormat(tieFormat);
|
|
29781
29935
|
modified = true;
|
|
29782
29936
|
}
|
|
29783
29937
|
if (modified) {
|
|
29784
|
-
|
|
29938
|
+
modifiedMatchUpsCount2 += 1;
|
|
29785
29939
|
modifyMatchUpNotice({
|
|
29786
29940
|
tournamentId: tournamentRecord?.tournamentId,
|
|
29787
29941
|
drawDefinition,
|
|
@@ -29791,8 +29945,80 @@ function updateTieFormat({
|
|
|
29791
29945
|
});
|
|
29792
29946
|
}
|
|
29793
29947
|
}
|
|
29794
|
-
return {
|
|
29948
|
+
return { modifiedMatchUpsCount: modifiedMatchUpsCount2 };
|
|
29795
29949
|
}
|
|
29950
|
+
function makeChanges({ uuids: uuids2, matchUp: matchUp2, tieFormat: tieFormat2, changes }) {
|
|
29951
|
+
matchUp2.tieFormat = copyTieFormat(tieFormat2);
|
|
29952
|
+
const matchUpIdsRemoved = [];
|
|
29953
|
+
const matchUpsAdded = [];
|
|
29954
|
+
changes.forEach((change) => {
|
|
29955
|
+
if (change.countChange > 0) {
|
|
29956
|
+
const collectionPositionOffset = Math.max(
|
|
29957
|
+
0,
|
|
29958
|
+
...matchUp2.tieMatchUps.filter(
|
|
29959
|
+
(tieMatchUp) => tieMatchUp.collectionId === change.collectionId
|
|
29960
|
+
).map(extractAttributes("collectionPosition"))
|
|
29961
|
+
);
|
|
29962
|
+
const collectionDefinition = tieFormat2.collectionDefinitions.find(
|
|
29963
|
+
(def) => def.collectionId === change.collectionId
|
|
29964
|
+
);
|
|
29965
|
+
const newMatchUps = generateCollectionMatchUps({
|
|
29966
|
+
matchUpsLimit: change.countChange,
|
|
29967
|
+
collectionPositionOffset,
|
|
29968
|
+
collectionDefinition,
|
|
29969
|
+
uuids: uuids2
|
|
29970
|
+
});
|
|
29971
|
+
matchUpsAdded.push(...makeDeepCopy(newMatchUps, false, true));
|
|
29972
|
+
addedMatchUpsCount += matchUpsAdded.length;
|
|
29973
|
+
matchUp2.tieMatchUps.push(...newMatchUps);
|
|
29974
|
+
} else {
|
|
29975
|
+
const tieMatchUpIdsToRemove = change.toBePlayedTieMatchUpIds.slice(
|
|
29976
|
+
0,
|
|
29977
|
+
Math.abs(change.countChange)
|
|
29978
|
+
);
|
|
29979
|
+
console.log("remove", tieMatchUpIdsToRemove.length);
|
|
29980
|
+
matchUpIdsRemoved.push(...tieMatchUpIdsToRemove);
|
|
29981
|
+
matchUp2.tieMatchUps = matchUp2.tieMatchUps.filter(
|
|
29982
|
+
({ matchUpId }) => !tieMatchUpIdsToRemove.includes(matchUpId)
|
|
29983
|
+
);
|
|
29984
|
+
}
|
|
29985
|
+
});
|
|
29986
|
+
matchUpsAdded.length && addMatchUpsNotice({
|
|
29987
|
+
matchUps: matchUpsAdded,
|
|
29988
|
+
drawDefinition,
|
|
29989
|
+
tournamentId,
|
|
29990
|
+
eventId
|
|
29991
|
+
});
|
|
29992
|
+
matchUpIdsRemoved.length && deleteMatchUpsNotice({
|
|
29993
|
+
matchUpIds: matchUpIdsRemoved,
|
|
29994
|
+
action: "updateTieFormat",
|
|
29995
|
+
drawDefinition,
|
|
29996
|
+
tournamentId,
|
|
29997
|
+
eventId
|
|
29998
|
+
});
|
|
29999
|
+
return { matchUpIdsRemoved, matchUpsAdded };
|
|
30000
|
+
}
|
|
30001
|
+
}
|
|
30002
|
+
function getMatchUpChangesArePossible({ check, matchUp }) {
|
|
30003
|
+
let cannotChangeReaon = "";
|
|
30004
|
+
const changes = [];
|
|
30005
|
+
const changesArePossible = check.matchUpsCountChanges.every(
|
|
30006
|
+
({ collectionId, countChange }) => {
|
|
30007
|
+
const toBePlayedTieMatchUpIds = matchUp.tieMatchUps.filter(
|
|
30008
|
+
(tieMatchUp) => tieMatchUp.collectionId === collectionId && tieMatchUp.matchUpStatus === TO_BE_PLAYED
|
|
30009
|
+
).map(extractAttributes("matchUpId"));
|
|
30010
|
+
const possibleToChange = toBePlayedTieMatchUpIds.length + countChange >= 0 || countChange > 0;
|
|
30011
|
+
if (!possibleToChange && countChange < 0)
|
|
30012
|
+
cannotChangeReaon = "Insufficient TO_BE_PLAYED matchUps";
|
|
30013
|
+
changes.push({
|
|
30014
|
+
toBePlayedTieMatchUpIds,
|
|
30015
|
+
collectionId,
|
|
30016
|
+
countChange
|
|
30017
|
+
});
|
|
30018
|
+
return possibleToChange;
|
|
30019
|
+
}
|
|
30020
|
+
);
|
|
30021
|
+
return { changesArePossible, changes, cannotChangeReaon };
|
|
29796
30022
|
}
|
|
29797
30023
|
|
|
29798
30024
|
function modifyCollectionDefinition$1({
|
|
@@ -29800,9 +30026,9 @@ function modifyCollectionDefinition$1({
|
|
|
29800
30026
|
tournamentRecord,
|
|
29801
30027
|
collectionOrder,
|
|
29802
30028
|
collectionName,
|
|
30029
|
+
tieFormatName,
|
|
29803
30030
|
drawDefinition,
|
|
29804
30031
|
matchUpFormat,
|
|
29805
|
-
tieFormatName,
|
|
29806
30032
|
matchUpCount,
|
|
29807
30033
|
collectionId,
|
|
29808
30034
|
matchUpType,
|
|
@@ -29819,19 +30045,35 @@ function modifyCollectionDefinition$1({
|
|
|
29819
30045
|
scoreValue,
|
|
29820
30046
|
setValue
|
|
29821
30047
|
}) {
|
|
30048
|
+
const stack = "modifyCollectionDefinition";
|
|
29822
30049
|
if (matchUpFormat && !isValid(matchUpFormat)) {
|
|
29823
|
-
return {
|
|
30050
|
+
return decorateResult({
|
|
30051
|
+
result: { error: INVALID_VALUES },
|
|
30052
|
+
context: { matchUpFormat },
|
|
30053
|
+
stack
|
|
30054
|
+
});
|
|
29824
30055
|
}
|
|
29825
30056
|
if (collectionName && typeof collectionName !== "string") {
|
|
29826
|
-
return {
|
|
30057
|
+
return decorateResult({
|
|
30058
|
+
result: { error: INVALID_VALUES },
|
|
30059
|
+
context: { collectionName },
|
|
30060
|
+
stack
|
|
30061
|
+
});
|
|
29827
30062
|
}
|
|
29828
30063
|
if (gender && !Object.values(genderConstants).includes(gender)) {
|
|
29829
|
-
return {
|
|
30064
|
+
return decorateResult({
|
|
30065
|
+
result: { error: INVALID_VALUES },
|
|
30066
|
+
context: { gender },
|
|
30067
|
+
stack
|
|
30068
|
+
});
|
|
29830
30069
|
}
|
|
29831
30070
|
if (category && typeof category !== "object") {
|
|
29832
|
-
return {
|
|
30071
|
+
return decorateResult({
|
|
30072
|
+
result: { error: INVALID_VALUES },
|
|
30073
|
+
context: { category },
|
|
30074
|
+
stack
|
|
30075
|
+
});
|
|
29833
30076
|
}
|
|
29834
|
-
const stack = "modifyCollectionDefinition";
|
|
29835
30077
|
const valueAssignments = {
|
|
29836
30078
|
collectionValueProfiles,
|
|
29837
30079
|
collectionValue,
|
|
@@ -29839,14 +30081,12 @@ function modifyCollectionDefinition$1({
|
|
|
29839
30081
|
scoreValue,
|
|
29840
30082
|
setValue
|
|
29841
30083
|
};
|
|
29842
|
-
if (!Object.values(valueAssignments).filter(Boolean).length && !collectionOrder && !collectionName && !matchUpCount && !
|
|
30084
|
+
if (!Object.values(valueAssignments).filter(Boolean).length && !collectionOrder && !collectionName && !matchUpFormat && !matchUpCount && !matchUpType)
|
|
29843
30085
|
return decorateResult({ result: { error: MISSING_VALUE }, stack });
|
|
29844
30086
|
if (Object.values(valueAssignments).filter(Boolean).length > 1)
|
|
29845
30087
|
return decorateResult({
|
|
29846
|
-
|
|
29847
|
-
|
|
29848
|
-
error: INVALID_VALUES
|
|
29849
|
-
},
|
|
30088
|
+
info: "Only one value assignment allowed per collectionDefinition",
|
|
30089
|
+
result: { error: INVALID_VALUES },
|
|
29850
30090
|
stack
|
|
29851
30091
|
});
|
|
29852
30092
|
let result = getTieFormat$1({
|
|
@@ -29856,81 +30096,141 @@ function modifyCollectionDefinition$1({
|
|
|
29856
30096
|
eventId,
|
|
29857
30097
|
event
|
|
29858
30098
|
});
|
|
29859
|
-
if (result.error)
|
|
30099
|
+
if (result.error) {
|
|
29860
30100
|
return decorateResult({ result, stack });
|
|
30101
|
+
}
|
|
29861
30102
|
const { matchUp, structure, tieFormat: existingTieFormat } = result;
|
|
29862
30103
|
const tieFormat = copyTieFormat(existingTieFormat);
|
|
29863
|
-
const
|
|
29864
|
-
(
|
|
30104
|
+
const sourceCollectionDefinition = existingTieFormat?.collectionDefinitions.find(
|
|
30105
|
+
(collectionDefinition) => collectionDefinition.collectionId === collectionId
|
|
29865
30106
|
);
|
|
29866
|
-
|
|
29867
|
-
|
|
29868
|
-
|
|
29869
|
-
if (
|
|
29870
|
-
|
|
29871
|
-
|
|
29872
|
-
|
|
29873
|
-
|
|
29874
|
-
|
|
29875
|
-
|
|
29876
|
-
|
|
29877
|
-
|
|
29878
|
-
|
|
29879
|
-
|
|
29880
|
-
|
|
29881
|
-
|
|
29882
|
-
|
|
29883
|
-
|
|
30107
|
+
const targetCollectionDefinition = tieFormat?.collectionDefinitions.find(
|
|
30108
|
+
(collectionDefinition) => collectionDefinition.collectionId === collectionId
|
|
30109
|
+
);
|
|
30110
|
+
if (!sourceCollectionDefinition)
|
|
30111
|
+
return decorateResult({
|
|
30112
|
+
info: "source collectionDefinition",
|
|
30113
|
+
result: { error: NOT_FOUND },
|
|
30114
|
+
context: { collectionId },
|
|
30115
|
+
stack
|
|
30116
|
+
});
|
|
30117
|
+
const value = collectionValue ?? matchUpValue ?? scoreValue ?? setValue;
|
|
30118
|
+
if (collectionValueProfiles) {
|
|
30119
|
+
const result2 = validateCollectionValueProfiles({
|
|
30120
|
+
matchUpCount: matchUpCount ?? sourceCollectionDefinition?.matchUpCount,
|
|
30121
|
+
collectionValueProfiles
|
|
30122
|
+
});
|
|
30123
|
+
if (result2.errors) {
|
|
30124
|
+
return decorateResult({
|
|
30125
|
+
result: { error: INVALID_VALUES },
|
|
30126
|
+
info: result2.errors,
|
|
30127
|
+
stack
|
|
30128
|
+
});
|
|
29884
30129
|
}
|
|
29885
|
-
|
|
29886
|
-
|
|
29887
|
-
|
|
29888
|
-
|
|
29889
|
-
|
|
30130
|
+
} else if (value && !isConvertableInteger(value)) {
|
|
30131
|
+
return decorateResult({
|
|
30132
|
+
result: { error: INVALID_VALUES },
|
|
30133
|
+
info: "value is not an integer",
|
|
30134
|
+
context: { value },
|
|
30135
|
+
stack
|
|
30136
|
+
});
|
|
29890
30137
|
}
|
|
29891
|
-
|
|
29892
|
-
|
|
30138
|
+
const equivalentValueProfiles = (a, b) => intersection(Object.keys(a), Object.keys(b)).length === Object.keys(a).length && intersection(Object.values(a), Object.values(b)).length === Object.values(a).length;
|
|
30139
|
+
const valueProfileModified = collectionValueProfiles && (!sourceCollectionDefinition.collectionValueProfiles || !equivalentValueProfiles(
|
|
30140
|
+
sourceCollectionDefinition.collectionValueProfiles,
|
|
30141
|
+
collectionValueProfiles
|
|
30142
|
+
));
|
|
30143
|
+
const valueModified = isConvertableInteger(collectionValue) && sourceCollectionDefinition.collectionValue !== collectionValue || isConvertableInteger(matchUpValue) && sourceCollectionDefinition.matchUpValue !== matchUpValue || isConvertableInteger(scoreValue) && sourceCollectionDefinition.scoreValue !== scoreValue || isConvertableInteger(setValue) && sourceCollectionDefinition.setValue !== setValue || valueProfileModified;
|
|
30144
|
+
const modifications = [];
|
|
30145
|
+
if (valueModified) {
|
|
30146
|
+
targetCollectionDefinition.collectionValueProfiles = void 0;
|
|
30147
|
+
targetCollectionDefinition.collectionValue = void 0;
|
|
30148
|
+
targetCollectionDefinition.matchUpValue = void 0;
|
|
30149
|
+
targetCollectionDefinition.scoreValue = void 0;
|
|
30150
|
+
targetCollectionDefinition.setValue = void 0;
|
|
30151
|
+
Object.assign(targetCollectionDefinition, valueAssignments);
|
|
30152
|
+
modifications.push({
|
|
30153
|
+
collectionId,
|
|
30154
|
+
...definedAttributes(valueAssignments)
|
|
30155
|
+
});
|
|
30156
|
+
}
|
|
30157
|
+
if ((isConvertableInteger(scoreValue) || isConvertableInteger(setValue)) && targetCollectionDefinition.collectionGroupNumber) {
|
|
30158
|
+
const targetCollectionGroupNumber = targetCollectionDefinition.collectionGroupNumber;
|
|
29893
30159
|
tieFormat.collectionDefinitions = tieFormat.collectionDefinitions.map(
|
|
29894
|
-
(
|
|
29895
|
-
const { collectionGroupNumber, ...rest } =
|
|
30160
|
+
(collectionDefinition) => {
|
|
30161
|
+
const { collectionGroupNumber, ...rest } = collectionDefinition;
|
|
29896
30162
|
if (collectionGroupNumber === targetCollectionGroupNumber) {
|
|
29897
30163
|
return rest;
|
|
29898
30164
|
} else {
|
|
29899
|
-
return
|
|
30165
|
+
return collectionDefinition;
|
|
29900
30166
|
}
|
|
29901
30167
|
}
|
|
29902
30168
|
);
|
|
29903
30169
|
tieFormat.collectionGroups = tieFormat.collectionGroups.filter(
|
|
29904
30170
|
({ groupNumber }) => groupNumber !== targetCollectionGroupNumber
|
|
29905
30171
|
);
|
|
30172
|
+
modifications.push({
|
|
30173
|
+
collectionId,
|
|
30174
|
+
change: "collectionGroupNumber removed"
|
|
30175
|
+
});
|
|
29906
30176
|
}
|
|
29907
30177
|
const { aggregateValue, valueGoal } = calculateWinCriteria(tieFormat);
|
|
29908
|
-
|
|
29909
|
-
|
|
29910
|
-
|
|
29911
|
-
|
|
29912
|
-
|
|
29913
|
-
|
|
29914
|
-
|
|
29915
|
-
|
|
29916
|
-
|
|
29917
|
-
|
|
29918
|
-
|
|
29919
|
-
|
|
29920
|
-
|
|
29921
|
-
|
|
29922
|
-
|
|
29923
|
-
|
|
29924
|
-
|
|
29925
|
-
|
|
29926
|
-
|
|
29927
|
-
|
|
29928
|
-
|
|
29929
|
-
|
|
29930
|
-
|
|
30178
|
+
const winCriteria = definedAttributes({ aggregateValue, valueGoal });
|
|
30179
|
+
if (winCriteria.aggregateValue !== existingTieFormat?.winCriteria.aggregateValue || winCriteria.valueGoal !== existingTieFormat?.winCriteria.valueGoal) {
|
|
30180
|
+
tieFormat.winCriteria = winCriteria;
|
|
30181
|
+
modifications.push({ collectionId, winCriteria });
|
|
30182
|
+
}
|
|
30183
|
+
if (isConvertableInteger(collectionOrder) && sourceCollectionDefinition.collectionOrder !== collectionOrder) {
|
|
30184
|
+
targetCollectionDefinition.collectionOrder = collectionOrder;
|
|
30185
|
+
modifications.push({ collectionId, collectionOrder });
|
|
30186
|
+
}
|
|
30187
|
+
if (collectionName && sourceCollectionDefinition.collectionName !== collectionName) {
|
|
30188
|
+
targetCollectionDefinition.collectionName = collectionName;
|
|
30189
|
+
modifications.push({ collectionId, collectionName });
|
|
30190
|
+
}
|
|
30191
|
+
if (matchUpFormat && sourceCollectionDefinition.matchUpFormat !== matchUpFormat) {
|
|
30192
|
+
targetCollectionDefinition.matchUpFormat = matchUpFormat;
|
|
30193
|
+
modifications.push({ collectionId, matchUpFormat });
|
|
30194
|
+
}
|
|
30195
|
+
if (isConvertableInteger(matchUpCount) && sourceCollectionDefinition.matchUpCount !== matchUpCount) {
|
|
30196
|
+
targetCollectionDefinition.matchUpCount = matchUpCount;
|
|
30197
|
+
modifications.push({ collectionId, matchUpCount });
|
|
30198
|
+
}
|
|
30199
|
+
if (matchUpType && sourceCollectionDefinition.matchUpType !== matchUpType) {
|
|
30200
|
+
return decorateResult({
|
|
30201
|
+
result: { error: NOT_IMPLEMENTED },
|
|
30202
|
+
context: { matchUpType },
|
|
30203
|
+
stack
|
|
30204
|
+
});
|
|
30205
|
+
}
|
|
30206
|
+
if (category && sourceCollectionDefinition.category !== category) {
|
|
30207
|
+
targetCollectionDefinition.category = category;
|
|
30208
|
+
modifications.push({ collectionId, category });
|
|
30209
|
+
}
|
|
30210
|
+
if (gender && sourceCollectionDefinition.gender !== gender) {
|
|
30211
|
+
targetCollectionDefinition.gender = gender;
|
|
30212
|
+
modifications.push({ collectionId, gender });
|
|
30213
|
+
}
|
|
30214
|
+
const modifiedTieFormat = definedAttributes(tieFormat);
|
|
30215
|
+
result = validateTieFormat({ tieFormat: modifiedTieFormat });
|
|
30216
|
+
if (result.error) {
|
|
29931
30217
|
return decorateResult({ result, stack });
|
|
30218
|
+
}
|
|
30219
|
+
if (!modifications.length) {
|
|
30220
|
+
return decorateResult({ result: { ...SUCCESS, modifications } });
|
|
30221
|
+
}
|
|
30222
|
+
const changedTieFormatName = existingTieFormat?.tieFormatName !== tieFormatName;
|
|
30223
|
+
if (changedTieFormatName) {
|
|
30224
|
+
modifiedTieFormat.tieFormatName = tieFormatName;
|
|
30225
|
+
modifications.push({ tieFormatName });
|
|
30226
|
+
} else if (modifications.length) {
|
|
30227
|
+
delete modifiedTieFormat.tieFormatName;
|
|
30228
|
+
modifications.push(
|
|
30229
|
+
"tieFormatName removed: modifications without new tieFormatName"
|
|
30230
|
+
);
|
|
30231
|
+
}
|
|
29932
30232
|
result = updateTieFormat({
|
|
29933
|
-
tieFormat:
|
|
30233
|
+
tieFormat: modifiedTieFormat,
|
|
29934
30234
|
updateInProgressMatchUps,
|
|
29935
30235
|
tournamentRecord,
|
|
29936
30236
|
drawDefinition,
|
|
@@ -29943,8 +30243,8 @@ function modifyCollectionDefinition$1({
|
|
|
29943
30243
|
const { appliedPolicies } = getAppliedPolicies({ tournamentRecord });
|
|
29944
30244
|
if (appliedPolicies?.audit?.[TIE_FORMAT_MODIFICATIONS]) {
|
|
29945
30245
|
const auditData = definedAttributes({
|
|
30246
|
+
collectionDefinition: targetCollectionDefinition,
|
|
29946
30247
|
drawId: drawDefinition?.drawId,
|
|
29947
|
-
collectionDefinition,
|
|
29948
30248
|
action: stack,
|
|
29949
30249
|
structureId,
|
|
29950
30250
|
matchUpId,
|
|
@@ -29953,7 +30253,7 @@ function modifyCollectionDefinition$1({
|
|
|
29953
30253
|
tieFormatTelemetry({ drawDefinition, auditData });
|
|
29954
30254
|
}
|
|
29955
30255
|
}
|
|
29956
|
-
return decorateResult({ result, stack });
|
|
30256
|
+
return decorateResult({ result: { ...result, modifications }, stack });
|
|
29957
30257
|
}
|
|
29958
30258
|
|
|
29959
30259
|
function resolveTournamentRecord(params) {
|
|
@@ -30223,17 +30523,17 @@ function removeCollectionDefinition$1({
|
|
|
30223
30523
|
matchUps = getAllStructureMatchUps({
|
|
30224
30524
|
matchUpFilters: { matchUpTypes: [TEAM$2] },
|
|
30225
30525
|
structure
|
|
30226
|
-
})?.matchUps
|
|
30526
|
+
})?.matchUps ?? [];
|
|
30227
30527
|
} else if (drawDefinition) {
|
|
30228
30528
|
matchUps = allDrawMatchUps$1({
|
|
30229
30529
|
matchUpFilters: { matchUpTypes: [TEAM$2] },
|
|
30230
30530
|
drawDefinition
|
|
30231
|
-
})?.matchUps
|
|
30531
|
+
})?.matchUps ?? [];
|
|
30232
30532
|
} else if (event) {
|
|
30233
30533
|
matchUps = allEventMatchUps({
|
|
30234
30534
|
matchUpFilters: { matchUpTypes: [TEAM$2] },
|
|
30235
30535
|
drawDefinition
|
|
30236
|
-
})?.matchUps
|
|
30536
|
+
})?.matchUps ?? [];
|
|
30237
30537
|
}
|
|
30238
30538
|
const targetMatchUps = (matchUps || []).filter((matchUp2) => {
|
|
30239
30539
|
const collectionMatchUps = matchUp2.tieMatchUps?.filter(
|
|
@@ -30359,41 +30659,6 @@ function removeCollectionDefinition(params) {
|
|
|
30359
30659
|
return resolveTournamentRecord({ ...params, method: removeCollectionDefinition$1 });
|
|
30360
30660
|
}
|
|
30361
30661
|
|
|
30362
|
-
function generateTieMatchUps({
|
|
30363
|
-
tieFormat,
|
|
30364
|
-
isMock,
|
|
30365
|
-
uuids
|
|
30366
|
-
}) {
|
|
30367
|
-
const { collectionDefinitions } = tieFormat || {};
|
|
30368
|
-
const tieMatchUps = (collectionDefinitions || []).map(
|
|
30369
|
-
(collectionDefinition) => generateCollectionMatchUps({ collectionDefinition, uuids, isMock })
|
|
30370
|
-
).filter(Boolean).flat();
|
|
30371
|
-
return { tieMatchUps };
|
|
30372
|
-
}
|
|
30373
|
-
function generateCollectionMatchUps({
|
|
30374
|
-
collectionDefinition,
|
|
30375
|
-
matchUpsLimit,
|
|
30376
|
-
// internal use allows generation of missing matchUps on "reset"
|
|
30377
|
-
isMock,
|
|
30378
|
-
uuids
|
|
30379
|
-
}) {
|
|
30380
|
-
const { matchUpCount, matchUpType, collectionId, processCodes } = collectionDefinition || {};
|
|
30381
|
-
const numberToGenerate = matchUpsLimit || matchUpCount || 0;
|
|
30382
|
-
return generateRange(0, numberToGenerate).map((index) => {
|
|
30383
|
-
const collectionPosition = index + 1;
|
|
30384
|
-
return {
|
|
30385
|
-
sides: [{ sideNumber: 1 }, { sideNumber: 2 }],
|
|
30386
|
-
matchUpId: uuids?.pop() || UUID(),
|
|
30387
|
-
matchUpStatus: MatchUpStatusEnum.ToBePlayed,
|
|
30388
|
-
collectionPosition,
|
|
30389
|
-
collectionId,
|
|
30390
|
-
processCodes,
|
|
30391
|
-
matchUpType,
|
|
30392
|
-
isMock
|
|
30393
|
-
};
|
|
30394
|
-
});
|
|
30395
|
-
}
|
|
30396
|
-
|
|
30397
30662
|
function addCollectionDefinition$1({
|
|
30398
30663
|
updateInProgressMatchUps = true,
|
|
30399
30664
|
collectionDefinition,
|
|
@@ -30448,10 +30713,10 @@ function addCollectionDefinition$1({
|
|
|
30448
30713
|
({ collectionId }) => collectionId
|
|
30449
30714
|
);
|
|
30450
30715
|
if (collectionIds.includes(collectionDefinition.collectionId))
|
|
30451
|
-
return {
|
|
30452
|
-
collectionId: collectionDefinition.collectionId,
|
|
30453
|
-
error: DUPLICATE_VALUE
|
|
30454
|
-
};
|
|
30716
|
+
return decorateResult({
|
|
30717
|
+
context: { collectionId: collectionDefinition.collectionId },
|
|
30718
|
+
result: { error: DUPLICATE_VALUE }
|
|
30719
|
+
});
|
|
30455
30720
|
}
|
|
30456
30721
|
tieFormat.collectionDefinitions.push(collectionDefinition);
|
|
30457
30722
|
tieFormat.collectionDefinitions.sort((a, b) => (a.collectionOrder || 0) - (b.collectionOrder || 0)).forEach(
|
|
@@ -30524,7 +30789,10 @@ function addCollectionDefinition$1({
|
|
|
30524
30789
|
});
|
|
30525
30790
|
} else if (matchUpId && matchUp) {
|
|
30526
30791
|
if (!validUpdate({ matchUp, updateInProgressMatchUps }))
|
|
30527
|
-
return {
|
|
30792
|
+
return decorateResult({
|
|
30793
|
+
result: { error: CANNOT_MODIFY_TIEFORMAT },
|
|
30794
|
+
stack
|
|
30795
|
+
});
|
|
30528
30796
|
matchUp.tieFormat = prunedTieFormat;
|
|
30529
30797
|
const newMatchUps = generateCollectionMatchUps({
|
|
30530
30798
|
collectionDefinition,
|
|
@@ -30552,7 +30820,7 @@ function addCollectionDefinition$1({
|
|
|
30552
30820
|
structure: structure2,
|
|
30553
30821
|
uuids
|
|
30554
30822
|
});
|
|
30555
|
-
modifiedStructureIds.push(structureId);
|
|
30823
|
+
modifiedStructureIds.push(structure2.structureId);
|
|
30556
30824
|
addedMatchUps.push(...result2.newMatchUps);
|
|
30557
30825
|
targetMatchUps.push(...result2.targetMatchUps);
|
|
30558
30826
|
}
|
|
@@ -30579,10 +30847,10 @@ function addCollectionDefinition$1({
|
|
|
30579
30847
|
tieFormatTelemetry({ drawDefinition, auditData });
|
|
30580
30848
|
}
|
|
30581
30849
|
return {
|
|
30582
|
-
...SUCCESS,
|
|
30583
30850
|
tieFormat: prunedTieFormat,
|
|
30584
30851
|
targetMatchUps,
|
|
30585
|
-
addedMatchUps
|
|
30852
|
+
addedMatchUps,
|
|
30853
|
+
...SUCCESS
|
|
30586
30854
|
};
|
|
30587
30855
|
}
|
|
30588
30856
|
function updateStructureMatchUps({
|
|
@@ -30646,146 +30914,6 @@ function addCollectionDefinition(params) {
|
|
|
30646
30914
|
return resolveTournamentRecord({ ...params, method: addCollectionDefinition$1 });
|
|
30647
30915
|
}
|
|
30648
30916
|
|
|
30649
|
-
function publicFindMatchUp(params) {
|
|
30650
|
-
Object.assign(params, { inContext: true });
|
|
30651
|
-
const { matchUp, error } = findMatchUp(params);
|
|
30652
|
-
return { matchUp: makeDeepCopy(matchUp, true, true), error };
|
|
30653
|
-
}
|
|
30654
|
-
function findMatchUp({
|
|
30655
|
-
participantsProfile,
|
|
30656
|
-
afterRecoveryTimes,
|
|
30657
|
-
tournamentRecord,
|
|
30658
|
-
contextContent,
|
|
30659
|
-
contextProfile,
|
|
30660
|
-
drawDefinition,
|
|
30661
|
-
matchUpId,
|
|
30662
|
-
inContext,
|
|
30663
|
-
eventId,
|
|
30664
|
-
drawId,
|
|
30665
|
-
event
|
|
30666
|
-
}) {
|
|
30667
|
-
if (!tournamentRecord)
|
|
30668
|
-
return { error: MISSING_TOURNAMENT_RECORD };
|
|
30669
|
-
if (typeof matchUpId !== "string")
|
|
30670
|
-
return { error: MISSING_MATCHUP_ID };
|
|
30671
|
-
if (!drawDefinition || !event) {
|
|
30672
|
-
const matchUps = allTournamentMatchUps({ tournamentRecord }).matchUps || [];
|
|
30673
|
-
const inContextMatchUp = matchUps.find(
|
|
30674
|
-
(matchUp2) => matchUp2.matchUpId === matchUpId
|
|
30675
|
-
);
|
|
30676
|
-
if (!inContextMatchUp)
|
|
30677
|
-
return { error: MATCHUP_NOT_FOUND };
|
|
30678
|
-
({ eventId, drawId } = inContextMatchUp);
|
|
30679
|
-
({ event, drawDefinition } = findEvent({
|
|
30680
|
-
tournamentRecord,
|
|
30681
|
-
eventId,
|
|
30682
|
-
drawId
|
|
30683
|
-
}));
|
|
30684
|
-
}
|
|
30685
|
-
if (!drawDefinition)
|
|
30686
|
-
return { error: DRAW_DEFINITION_NOT_FOUND };
|
|
30687
|
-
if (contextProfile && !contextContent)
|
|
30688
|
-
contextContent = getContextContent({ tournamentRecord, contextProfile });
|
|
30689
|
-
const additionalContext = {
|
|
30690
|
-
surfaceCategory: event?.surfaceCategory || tournamentRecord.surfaceCategory,
|
|
30691
|
-
indoorOutDoor: event?.indoorOutdoor || tournamentRecord.indoorOutdoor,
|
|
30692
|
-
endDate: event?.endDate || tournamentRecord.endDate,
|
|
30693
|
-
tournamentId: tournamentRecord.tournamentId,
|
|
30694
|
-
eventId: eventId || event?.eventId,
|
|
30695
|
-
drawId
|
|
30696
|
-
};
|
|
30697
|
-
const { participants: tournamentParticipants = [] } = hydrateParticipants({
|
|
30698
|
-
participantsProfile,
|
|
30699
|
-
tournamentRecord,
|
|
30700
|
-
contextProfile,
|
|
30701
|
-
inContext
|
|
30702
|
-
});
|
|
30703
|
-
const { matchUp, structure } = findMatchUp$1({
|
|
30704
|
-
context: inContext ? additionalContext : void 0,
|
|
30705
|
-
tournamentParticipants,
|
|
30706
|
-
afterRecoveryTimes,
|
|
30707
|
-
contextContent,
|
|
30708
|
-
drawDefinition,
|
|
30709
|
-
contextProfile,
|
|
30710
|
-
matchUpId,
|
|
30711
|
-
inContext,
|
|
30712
|
-
event
|
|
30713
|
-
});
|
|
30714
|
-
return { matchUp, structure, drawDefinition };
|
|
30715
|
-
}
|
|
30716
|
-
|
|
30717
|
-
function getTieFormat({
|
|
30718
|
-
tournamentRecord,
|
|
30719
|
-
// passed in automatically by tournamentEngine
|
|
30720
|
-
drawDefinition,
|
|
30721
|
-
// passed in automatically by tournamentEngine when drawId provided
|
|
30722
|
-
structureId,
|
|
30723
|
-
// optional - if only the default matchUpFormat for a structure is required
|
|
30724
|
-
matchUpId,
|
|
30725
|
-
// id of matchUp for which the scoped matchUpFormat(s) are desired
|
|
30726
|
-
structure,
|
|
30727
|
-
// optional optimization - when structure already known
|
|
30728
|
-
eventId,
|
|
30729
|
-
// optional - if only the default matchUpFormat for an event is required
|
|
30730
|
-
drawId,
|
|
30731
|
-
// avoid brute force search for matchUp
|
|
30732
|
-
event
|
|
30733
|
-
// passed in automatically by tournamentEngine when drawId or eventId provided
|
|
30734
|
-
}) {
|
|
30735
|
-
if (!tournamentRecord)
|
|
30736
|
-
return { error: MISSING_TOURNAMENT_RECORD };
|
|
30737
|
-
if (!drawId && !event && !structureId && !matchUpId)
|
|
30738
|
-
return decorateResult({
|
|
30739
|
-
result: { error: MISSING_VALUE },
|
|
30740
|
-
stack: "getTieFormat"
|
|
30741
|
-
});
|
|
30742
|
-
if (eventId && !event) {
|
|
30743
|
-
event = tournamentRecord.events?.find((event2) => event2.eventId === eventId);
|
|
30744
|
-
}
|
|
30745
|
-
const matchUpResult = findMatchUp({
|
|
30746
|
-
tournamentRecord,
|
|
30747
|
-
drawDefinition,
|
|
30748
|
-
matchUpId,
|
|
30749
|
-
drawId,
|
|
30750
|
-
event
|
|
30751
|
-
});
|
|
30752
|
-
if (matchUpId && matchUpResult?.error) {
|
|
30753
|
-
return matchUpResult;
|
|
30754
|
-
} else if (!drawDefinition && matchUpResult?.drawDefinition) {
|
|
30755
|
-
drawDefinition = matchUpResult?.drawDefinition;
|
|
30756
|
-
}
|
|
30757
|
-
structure = structure ?? matchUpResult?.structure;
|
|
30758
|
-
if (!structure && structureId && !matchUpId) {
|
|
30759
|
-
if (!drawDefinition)
|
|
30760
|
-
return { error: MISSING_DRAW_ID };
|
|
30761
|
-
const structureResult = findStructure({ drawDefinition, structureId });
|
|
30762
|
-
if (structureResult.error)
|
|
30763
|
-
return structureResult;
|
|
30764
|
-
structure = structureResult.structure;
|
|
30765
|
-
}
|
|
30766
|
-
const structureDefaultTieFormat = (structure?.tieFormat || structure?.tieFormatId) && resolveTieFormat({ structure, drawDefinition, event })?.tieFormat;
|
|
30767
|
-
const drawDefaultTieFormat = (drawDefinition?.tieFormat || drawDefinition?.tieFormatId) && resolveTieFormat({
|
|
30768
|
-
drawDefinition,
|
|
30769
|
-
event
|
|
30770
|
-
})?.tieFormat;
|
|
30771
|
-
const eventDefaultTieFormat = resolveTieFormat({ event })?.tieFormat;
|
|
30772
|
-
const tieFormat = resolveTieFormat({
|
|
30773
|
-
matchUp: matchUpResult?.matchUp,
|
|
30774
|
-
drawDefinition,
|
|
30775
|
-
structure,
|
|
30776
|
-
event
|
|
30777
|
-
})?.tieFormat;
|
|
30778
|
-
return {
|
|
30779
|
-
...SUCCESS,
|
|
30780
|
-
matchUp: matchUpResult?.matchUp,
|
|
30781
|
-
structureDefaultTieFormat,
|
|
30782
|
-
eventDefaultTieFormat,
|
|
30783
|
-
drawDefaultTieFormat,
|
|
30784
|
-
tieFormat,
|
|
30785
|
-
structure
|
|
30786
|
-
};
|
|
30787
|
-
}
|
|
30788
|
-
|
|
30789
30917
|
function updateTargetTeamMatchUps({
|
|
30790
30918
|
updateInProgressMatchUps,
|
|
30791
30919
|
tournamentRecord,
|
|
@@ -30931,8 +31059,7 @@ function removeCollectionGroup$1({
|
|
|
30931
31059
|
if (isNaN(collectionGroupNumber))
|
|
30932
31060
|
return { error: INVALID_VALUES };
|
|
30933
31061
|
const stack = "removeCollectionGroup";
|
|
30934
|
-
let result = !matchUp ? getTieFormat({
|
|
30935
|
-
tournamentRecord,
|
|
31062
|
+
let result = !matchUp ? getTieFormat$1({
|
|
30936
31063
|
drawDefinition,
|
|
30937
31064
|
structureId,
|
|
30938
31065
|
matchUpId,
|
|
@@ -31100,8 +31227,13 @@ function modifyTieFormat$1({
|
|
|
31100
31227
|
event
|
|
31101
31228
|
}) {
|
|
31102
31229
|
const stack = "updateTieFormat";
|
|
31103
|
-
if (!validateTieFormat(modifiedTieFormat))
|
|
31104
|
-
return {
|
|
31230
|
+
if (!validateTieFormat({ tieFormat: modifiedTieFormat }).valid) {
|
|
31231
|
+
return decorateResult({
|
|
31232
|
+
result: { error: INVALID_TIE_FORMAT },
|
|
31233
|
+
info: "falied validation",
|
|
31234
|
+
stack
|
|
31235
|
+
});
|
|
31236
|
+
}
|
|
31105
31237
|
const result = getTieFormat$1({
|
|
31106
31238
|
drawDefinition,
|
|
31107
31239
|
structureId,
|
|
@@ -31113,40 +31245,51 @@ function modifyTieFormat$1({
|
|
|
31113
31245
|
return decorateResult({ result, stack });
|
|
31114
31246
|
const { matchUp, tieFormat: existingTieFormat } = result;
|
|
31115
31247
|
const tieFormat = copyTieFormat(existingTieFormat);
|
|
31248
|
+
const comparison = compareTieFormats({
|
|
31249
|
+
descendant: modifiedTieFormat,
|
|
31250
|
+
ancestor: tieFormat
|
|
31251
|
+
});
|
|
31252
|
+
if (comparison.invalid) {
|
|
31253
|
+
return decorateResult({
|
|
31254
|
+
context: { invalid: comparison.invalid },
|
|
31255
|
+
result: { error: INVALID_TIE_FORMAT }
|
|
31256
|
+
});
|
|
31257
|
+
}
|
|
31258
|
+
if (!comparison?.different) {
|
|
31259
|
+
return decorateResult({ result: { ...SUCCESS }, info: "Nothing to do" });
|
|
31260
|
+
}
|
|
31116
31261
|
const existingCollectionIds = tieFormat.collectionDefinitions.map(
|
|
31117
31262
|
({ collectionId }) => collectionId
|
|
31118
31263
|
);
|
|
31119
|
-
const
|
|
31120
|
-
|
|
31121
|
-
|
|
31122
|
-
modifiedTieFormat.collectionDefinitions.forEach((def) => {
|
|
31123
|
-
updatedCollectionIds.push(def.collectionId);
|
|
31124
|
-
if (modifiedTieFormat && existingCollectionIds.includes(def.collectionId)) {
|
|
31125
|
-
compareTieFormats({
|
|
31126
|
-
descendant: modifiedTieFormat,
|
|
31127
|
-
ancestor: tieFormat
|
|
31128
|
-
})?.different && modifiedCollectionDefinitions.push(def);
|
|
31129
|
-
} else {
|
|
31130
|
-
addedCollectionDefinitions.push(def);
|
|
31131
|
-
}
|
|
31132
|
-
});
|
|
31264
|
+
const updatedCollectionIds = modifiedTieFormat.collectionDefinitions.map(
|
|
31265
|
+
({ collectionId }) => collectionId
|
|
31266
|
+
);
|
|
31133
31267
|
const removedCollectionIds = existingCollectionIds.filter(
|
|
31134
31268
|
(collectionId) => !updatedCollectionIds.includes(collectionId)
|
|
31135
31269
|
);
|
|
31136
|
-
const
|
|
31270
|
+
const addedCollectionDefinitions = modifiedTieFormat.collectionDefinitions.filter(
|
|
31271
|
+
({ collectionId }) => !existingCollectionIds.includes(collectionId)
|
|
31272
|
+
);
|
|
31273
|
+
const addedCollectionIds = addedCollectionDefinitions.map(extractAttributes("collectionId"));
|
|
31274
|
+
const modifications = [];
|
|
31137
31275
|
let processedTieFormat;
|
|
31138
|
-
|
|
31276
|
+
const tieFormatName = modifiedTieFormat.tieFormatName;
|
|
31277
|
+
for (const collectionDefinition of modifiedTieFormat.collectionDefinitions) {
|
|
31278
|
+
if (addedCollectionIds.includes(collectionDefinition.collectionId))
|
|
31279
|
+
continue;
|
|
31139
31280
|
const result2 = modifyCollectionDefinition$1({
|
|
31140
31281
|
updateInProgressMatchUps,
|
|
31141
31282
|
...collectionDefinition,
|
|
31142
31283
|
tournamentRecord,
|
|
31143
|
-
drawDefinition,
|
|
31144
31284
|
tieFormatName,
|
|
31285
|
+
drawDefinition,
|
|
31145
31286
|
structureId,
|
|
31146
31287
|
matchUpId,
|
|
31147
31288
|
eventId,
|
|
31148
31289
|
event
|
|
31149
31290
|
});
|
|
31291
|
+
if (result2.modifications)
|
|
31292
|
+
modifications.push(...result2.modifications);
|
|
31150
31293
|
if (result2.error)
|
|
31151
31294
|
return decorateResult({ result: result2, stack });
|
|
31152
31295
|
if (result2.tieFormat)
|
|
@@ -31190,16 +31333,98 @@ function modifyTieFormat$1({
|
|
|
31190
31333
|
if (result2.tieFormat)
|
|
31191
31334
|
processedTieFormat = result2.tieFormat;
|
|
31192
31335
|
}
|
|
31336
|
+
const changedTieFormatName = existingTieFormat?.tieFormatName !== tieFormatName;
|
|
31337
|
+
if (changedTieFormatName) {
|
|
31338
|
+
processedTieFormat.tieFormatName = tieFormatName;
|
|
31339
|
+
modifications.push({ tieFormatName });
|
|
31340
|
+
} else if (modifications.length || addedCollectionIds.length || removedCollectionIds.length) {
|
|
31341
|
+
delete processedTieFormat.tieFormatName;
|
|
31342
|
+
modifications.push(
|
|
31343
|
+
"tieFormatName removed: modifications without new tieFormatName"
|
|
31344
|
+
);
|
|
31345
|
+
}
|
|
31193
31346
|
processedTieFormat.collectionDefinitions = processedTieFormat.collectionDefinitions.sort(
|
|
31194
31347
|
(a, b) => numericSortValue(a.collectionOrder) - numericSortValue(b.collectionOrder)
|
|
31195
31348
|
).map((def, i) => ({ ...def, collectionOrder: i + 1 }));
|
|
31196
|
-
return {
|
|
31349
|
+
return {
|
|
31350
|
+
processedTieFormat: copyTieFormat(processedTieFormat),
|
|
31351
|
+
modifications,
|
|
31352
|
+
...SUCCESS
|
|
31353
|
+
};
|
|
31197
31354
|
}
|
|
31198
31355
|
|
|
31199
31356
|
function modifyTieFormat(params) {
|
|
31200
31357
|
return resolveTournamentRecord({ ...params, method: modifyTieFormat$1 });
|
|
31201
31358
|
}
|
|
31202
31359
|
|
|
31360
|
+
function publicFindMatchUp(params) {
|
|
31361
|
+
Object.assign(params, { inContext: true });
|
|
31362
|
+
const { matchUp, error } = findMatchUp(params);
|
|
31363
|
+
return { matchUp: makeDeepCopy(matchUp, true, true), error };
|
|
31364
|
+
}
|
|
31365
|
+
function findMatchUp({
|
|
31366
|
+
participantsProfile,
|
|
31367
|
+
afterRecoveryTimes,
|
|
31368
|
+
tournamentRecord,
|
|
31369
|
+
contextContent,
|
|
31370
|
+
contextProfile,
|
|
31371
|
+
drawDefinition,
|
|
31372
|
+
matchUpId,
|
|
31373
|
+
inContext,
|
|
31374
|
+
eventId,
|
|
31375
|
+
drawId,
|
|
31376
|
+
event
|
|
31377
|
+
}) {
|
|
31378
|
+
if (!tournamentRecord)
|
|
31379
|
+
return { error: MISSING_TOURNAMENT_RECORD };
|
|
31380
|
+
if (typeof matchUpId !== "string")
|
|
31381
|
+
return { error: MISSING_MATCHUP_ID };
|
|
31382
|
+
if (!drawDefinition || !event) {
|
|
31383
|
+
const matchUps = allTournamentMatchUps({ tournamentRecord }).matchUps ?? [];
|
|
31384
|
+
const inContextMatchUp = matchUps.find(
|
|
31385
|
+
(matchUp2) => matchUp2.matchUpId === matchUpId
|
|
31386
|
+
);
|
|
31387
|
+
if (!inContextMatchUp)
|
|
31388
|
+
return { error: MATCHUP_NOT_FOUND };
|
|
31389
|
+
({ eventId, drawId } = inContextMatchUp);
|
|
31390
|
+
({ event, drawDefinition } = findEvent({
|
|
31391
|
+
tournamentRecord,
|
|
31392
|
+
eventId,
|
|
31393
|
+
drawId
|
|
31394
|
+
}));
|
|
31395
|
+
}
|
|
31396
|
+
if (!drawDefinition)
|
|
31397
|
+
return { error: DRAW_DEFINITION_NOT_FOUND };
|
|
31398
|
+
if (contextProfile && !contextContent)
|
|
31399
|
+
contextContent = getContextContent({ tournamentRecord, contextProfile });
|
|
31400
|
+
const additionalContext = {
|
|
31401
|
+
surfaceCategory: event?.surfaceCategory ?? tournamentRecord.surfaceCategory,
|
|
31402
|
+
indoorOutDoor: event?.indoorOutdoor ?? tournamentRecord.indoorOutdoor,
|
|
31403
|
+
endDate: event?.endDate ?? tournamentRecord.endDate,
|
|
31404
|
+
tournamentId: tournamentRecord.tournamentId,
|
|
31405
|
+
eventId: eventId ?? event?.eventId,
|
|
31406
|
+
drawId
|
|
31407
|
+
};
|
|
31408
|
+
const { participants: tournamentParticipants = [] } = hydrateParticipants({
|
|
31409
|
+
participantsProfile,
|
|
31410
|
+
tournamentRecord,
|
|
31411
|
+
contextProfile,
|
|
31412
|
+
inContext
|
|
31413
|
+
});
|
|
31414
|
+
const { matchUp, structure } = findMatchUp$1({
|
|
31415
|
+
context: inContext ? additionalContext : void 0,
|
|
31416
|
+
tournamentParticipants,
|
|
31417
|
+
afterRecoveryTimes,
|
|
31418
|
+
contextContent,
|
|
31419
|
+
drawDefinition,
|
|
31420
|
+
contextProfile,
|
|
31421
|
+
matchUpId,
|
|
31422
|
+
inContext,
|
|
31423
|
+
event
|
|
31424
|
+
});
|
|
31425
|
+
return { matchUp, structure, drawDefinition };
|
|
31426
|
+
}
|
|
31427
|
+
|
|
31203
31428
|
function resetTieFormat$1({
|
|
31204
31429
|
tournamentRecord,
|
|
31205
31430
|
drawDefinition,
|
|
@@ -46805,10 +47030,6 @@ function removeDelegatedOutcome$1({ drawDefinition, event, matchUpId }) {
|
|
|
46805
47030
|
});
|
|
46806
47031
|
}
|
|
46807
47032
|
|
|
46808
|
-
function stringSort(a, b) {
|
|
46809
|
-
return (a || "").localeCompare(b || "");
|
|
46810
|
-
}
|
|
46811
|
-
|
|
46812
47033
|
function generateCandidate({
|
|
46813
47034
|
maxIterations = 4e3,
|
|
46814
47035
|
// cap the processing intensity of the candidate generator
|
|
@@ -58966,6 +59187,78 @@ function getParticipantSignInStatus({
|
|
|
58966
59187
|
return timeItem && timeItem.itemValue === SIGNED_IN && SIGNED_IN;
|
|
58967
59188
|
}
|
|
58968
59189
|
|
|
59190
|
+
function getTieFormat({
|
|
59191
|
+
tournamentRecord,
|
|
59192
|
+
// passed in automatically by tournamentEngine
|
|
59193
|
+
drawDefinition,
|
|
59194
|
+
// passed in automatically by tournamentEngine when drawId provided
|
|
59195
|
+
structureId,
|
|
59196
|
+
// optional - if only the default matchUpFormat for a structure is required
|
|
59197
|
+
matchUpId,
|
|
59198
|
+
// id of matchUp for which the scoped matchUpFormat(s) are desired
|
|
59199
|
+
structure,
|
|
59200
|
+
// optional optimization - when structure already known
|
|
59201
|
+
eventId,
|
|
59202
|
+
// optional - if only the default matchUpFormat for an event is required
|
|
59203
|
+
drawId,
|
|
59204
|
+
// avoid brute force search for matchUp
|
|
59205
|
+
event
|
|
59206
|
+
// passed in automatically by tournamentEngine when drawId or eventId provided
|
|
59207
|
+
}) {
|
|
59208
|
+
if (!tournamentRecord)
|
|
59209
|
+
return { error: MISSING_TOURNAMENT_RECORD };
|
|
59210
|
+
if (!drawId && !event && !structureId && !matchUpId)
|
|
59211
|
+
return decorateResult({
|
|
59212
|
+
result: { error: MISSING_VALUE },
|
|
59213
|
+
stack: "getTieFormat"
|
|
59214
|
+
});
|
|
59215
|
+
if (eventId && !event) {
|
|
59216
|
+
event = tournamentRecord.events?.find((event2) => event2.eventId === eventId);
|
|
59217
|
+
}
|
|
59218
|
+
const matchUpResult = publicFindMatchUp({
|
|
59219
|
+
tournamentRecord,
|
|
59220
|
+
drawDefinition,
|
|
59221
|
+
matchUpId,
|
|
59222
|
+
drawId,
|
|
59223
|
+
event
|
|
59224
|
+
});
|
|
59225
|
+
if (matchUpId && matchUpResult?.error) {
|
|
59226
|
+
return matchUpResult;
|
|
59227
|
+
} else if (!drawDefinition && matchUpResult?.drawDefinition) {
|
|
59228
|
+
drawDefinition = matchUpResult?.drawDefinition;
|
|
59229
|
+
}
|
|
59230
|
+
structure = structure ?? matchUpResult?.structure;
|
|
59231
|
+
if (!structure && structureId && !matchUpId) {
|
|
59232
|
+
if (!drawDefinition)
|
|
59233
|
+
return { error: MISSING_DRAW_ID };
|
|
59234
|
+
const structureResult = findStructure({ drawDefinition, structureId });
|
|
59235
|
+
if (structureResult.error)
|
|
59236
|
+
return structureResult;
|
|
59237
|
+
structure = structureResult.structure;
|
|
59238
|
+
}
|
|
59239
|
+
const structureDefaultTieFormat = (structure?.tieFormat || structure?.tieFormatId) && resolveTieFormat({ structure, drawDefinition, event })?.tieFormat;
|
|
59240
|
+
const drawDefaultTieFormat = (drawDefinition?.tieFormat || drawDefinition?.tieFormatId) && resolveTieFormat({
|
|
59241
|
+
drawDefinition,
|
|
59242
|
+
event
|
|
59243
|
+
})?.tieFormat;
|
|
59244
|
+
const eventDefaultTieFormat = resolveTieFormat({ event })?.tieFormat;
|
|
59245
|
+
const tieFormat = resolveTieFormat({
|
|
59246
|
+
matchUp: matchUpResult?.matchUp,
|
|
59247
|
+
drawDefinition,
|
|
59248
|
+
structure,
|
|
59249
|
+
event
|
|
59250
|
+
})?.tieFormat;
|
|
59251
|
+
return {
|
|
59252
|
+
...SUCCESS,
|
|
59253
|
+
matchUp: matchUpResult?.matchUp,
|
|
59254
|
+
structureDefaultTieFormat: copyTieFormat(structureDefaultTieFormat),
|
|
59255
|
+
eventDefaultTieFormat: copyTieFormat(eventDefaultTieFormat),
|
|
59256
|
+
drawDefaultTieFormat: copyTieFormat(drawDefaultTieFormat),
|
|
59257
|
+
tieFormat: copyTieFormat(tieFormat),
|
|
59258
|
+
structure
|
|
59259
|
+
};
|
|
59260
|
+
}
|
|
59261
|
+
|
|
58969
59262
|
function getEventProperties({ tournamentRecord, event }) {
|
|
58970
59263
|
if (!tournamentRecord)
|
|
58971
59264
|
return { error: MISSING_TOURNAMENT_RECORD };
|