tods-competition-factory 1.7.11 → 1.7.13
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 +196 -101
- package/dist/index.mjs.map +1 -1
- package/dist/tods-competition-factory.development.cjs.js +226 -105
- package/dist/tods-competition-factory.development.cjs.js.map +1 -1
- package/dist/tods-competition-factory.production.cjs.min.js +1 -1
- package/dist/tods-competition-factory.production.cjs.min.js.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -333,7 +333,7 @@ const matchUpFormatCode = {
|
|
|
333
333
|
};
|
|
334
334
|
|
|
335
335
|
function factoryVersion() {
|
|
336
|
-
return "1.7.
|
|
336
|
+
return "1.7.13";
|
|
337
337
|
}
|
|
338
338
|
|
|
339
339
|
function getObjectTieFormat(obj) {
|
|
@@ -16620,7 +16620,6 @@ function compareTieFormats({
|
|
|
16620
16620
|
);
|
|
16621
16621
|
const nameDifference = !!(considerations?.collectionName && descendant.collectionDefinitions.map(({ collectionName }) => collectionName).join("|") !== ancestor.collectionDefinitions.map(({ collectionName }) => collectionName).join("|"));
|
|
16622
16622
|
const orderDifference = !!(considerations?.collectionOrder && descendant.collectionDefinitions.map(({ collectionOrder }) => collectionOrder).join("|") !== ancestor.collectionDefinitions.map(({ collectionOrder }) => collectionOrder).join("|"));
|
|
16623
|
-
const different = nameDifference || orderDifference || ancestorDesc !== descendantDesc;
|
|
16624
16623
|
const descendantCollectionDefinitions = Object.assign(
|
|
16625
16624
|
{},
|
|
16626
16625
|
...(descendant?.collectionDefinitions || []).map(
|
|
@@ -16644,17 +16643,16 @@ function compareTieFormats({
|
|
|
16644
16643
|
Object.keys(descendantCollectionDefinitions)
|
|
16645
16644
|
);
|
|
16646
16645
|
descendantDifferences.collectionsValue = getCollectionsValue(
|
|
16647
|
-
descendantCollectionDefinitions
|
|
16648
|
-
descendantDifferences
|
|
16646
|
+
descendantCollectionDefinitions
|
|
16649
16647
|
);
|
|
16650
16648
|
ancestorDifferences.collectionsValue = getCollectionsValue(
|
|
16651
|
-
ancestorCollectionDefinitions
|
|
16652
|
-
ancestorDifferences
|
|
16649
|
+
ancestorCollectionDefinitions
|
|
16653
16650
|
);
|
|
16654
16651
|
descendantDifferences.groupsCount = ancestor?.collectionGroups?.length ?? (0 - (descendant?.collectionGroups?.length ?? 0) || 0);
|
|
16655
16652
|
ancestorDifferences.groupsCount = descendantDifferences.groupsCount ? -1 * descendantDifferences.groupsCount : 0;
|
|
16656
16653
|
const valueDifference = descendantDifferences.collectionsValue.totalValue - ancestorDifferences.collectionsValue.totalValue;
|
|
16657
16654
|
const matchUpCountDifference = descendantDifferences.collectionsValue.totalMatchUps - ancestorDifferences.collectionsValue.totalMatchUps;
|
|
16655
|
+
const different = nameDifference || orderDifference || ancestorDesc !== descendantDesc || valueDifference !== 0;
|
|
16658
16656
|
return {
|
|
16659
16657
|
matchUpFormatDifferences,
|
|
16660
16658
|
matchUpCountDifference,
|
|
@@ -16669,15 +16667,18 @@ function compareTieFormats({
|
|
|
16669
16667
|
different
|
|
16670
16668
|
};
|
|
16671
16669
|
}
|
|
16672
|
-
function getCollectionsValue(definitions
|
|
16670
|
+
function getCollectionsValue(definitions) {
|
|
16673
16671
|
let totalMatchUps = 0;
|
|
16674
|
-
const
|
|
16672
|
+
const collectionIds = Object.keys(definitions);
|
|
16673
|
+
const totalValue = collectionIds.reduce((total, collectionId) => {
|
|
16675
16674
|
const collectionDefinition = definitions[collectionId];
|
|
16676
16675
|
const {
|
|
16677
16676
|
collectionValueProfiles,
|
|
16678
16677
|
collectionValue,
|
|
16679
16678
|
matchUpCount,
|
|
16680
|
-
matchUpValue
|
|
16679
|
+
matchUpValue,
|
|
16680
|
+
scoreValue,
|
|
16681
|
+
setValue
|
|
16681
16682
|
} = collectionDefinition;
|
|
16682
16683
|
totalMatchUps += matchUpCount;
|
|
16683
16684
|
if (collectionValueProfiles)
|
|
@@ -16685,9 +16686,16 @@ function getCollectionsValue(definitions, aggregator) {
|
|
|
16685
16686
|
(total2, profile) => total2 + profile.value,
|
|
16686
16687
|
0
|
|
16687
16688
|
);
|
|
16688
|
-
if (
|
|
16689
|
-
|
|
16690
|
-
|
|
16689
|
+
if (matchUpCount) {
|
|
16690
|
+
if (isConvertableInteger(matchUpValue))
|
|
16691
|
+
return total + matchUpValue * matchUpCount;
|
|
16692
|
+
if (isConvertableInteger(scoreValue))
|
|
16693
|
+
return total + scoreValue * matchUpCount;
|
|
16694
|
+
if (isConvertableInteger(setValue))
|
|
16695
|
+
return total + setValue * matchUpCount;
|
|
16696
|
+
return total + collectionValue;
|
|
16697
|
+
}
|
|
16698
|
+
return total;
|
|
16691
16699
|
}, 0);
|
|
16692
16700
|
return { totalValue, totalMatchUps };
|
|
16693
16701
|
}
|
|
@@ -29561,6 +29569,7 @@ function getTieFormat$1({
|
|
|
29561
29569
|
// optional - if an eventId is present only return tieFormat for event
|
|
29562
29570
|
event
|
|
29563
29571
|
}) {
|
|
29572
|
+
const stack = "getTieFormat";
|
|
29564
29573
|
let tieFormat;
|
|
29565
29574
|
structureId = structure?.structureId ?? structureId;
|
|
29566
29575
|
matchUpId = matchUp?.matchUpId ?? matchUpId;
|
|
@@ -29576,6 +29585,9 @@ function getTieFormat$1({
|
|
|
29576
29585
|
});
|
|
29577
29586
|
if (result.error)
|
|
29578
29587
|
return result;
|
|
29588
|
+
if (result.matchUp?.matchUpType !== TEAM_MATCHUP) {
|
|
29589
|
+
return decorateResult({ result: { error: INVALID_MATCHUP }, stack });
|
|
29590
|
+
}
|
|
29579
29591
|
if (!structure)
|
|
29580
29592
|
structure = result.structure;
|
|
29581
29593
|
if (!matchUp)
|
|
@@ -29609,7 +29621,7 @@ function getTieFormat$1({
|
|
|
29609
29621
|
tieFormat = getObjectTieFormat(drawDefinition) || getObjectTieFormat(event);
|
|
29610
29622
|
}
|
|
29611
29623
|
if (!tieFormat)
|
|
29612
|
-
return decorateResult({ result: { error: MISSING_TIE_FORMAT } });
|
|
29624
|
+
return decorateResult({ result: { error: MISSING_TIE_FORMAT }, stack });
|
|
29613
29625
|
return { ...SUCCESS, tieFormat, matchUp, structure };
|
|
29614
29626
|
}
|
|
29615
29627
|
|
|
@@ -29792,9 +29804,9 @@ function modifyCollectionDefinition$1({
|
|
|
29792
29804
|
tournamentRecord,
|
|
29793
29805
|
collectionOrder,
|
|
29794
29806
|
collectionName,
|
|
29807
|
+
tieFormatName,
|
|
29795
29808
|
drawDefinition,
|
|
29796
29809
|
matchUpFormat,
|
|
29797
|
-
tieFormatName,
|
|
29798
29810
|
matchUpCount,
|
|
29799
29811
|
collectionId,
|
|
29800
29812
|
matchUpType,
|
|
@@ -29811,19 +29823,35 @@ function modifyCollectionDefinition$1({
|
|
|
29811
29823
|
scoreValue,
|
|
29812
29824
|
setValue
|
|
29813
29825
|
}) {
|
|
29826
|
+
const stack = "modifyCollectionDefinition";
|
|
29814
29827
|
if (matchUpFormat && !isValid(matchUpFormat)) {
|
|
29815
|
-
return {
|
|
29828
|
+
return decorateResult({
|
|
29829
|
+
result: { error: INVALID_VALUES },
|
|
29830
|
+
context: { matchUpFormat },
|
|
29831
|
+
stack
|
|
29832
|
+
});
|
|
29816
29833
|
}
|
|
29817
29834
|
if (collectionName && typeof collectionName !== "string") {
|
|
29818
|
-
return {
|
|
29835
|
+
return decorateResult({
|
|
29836
|
+
result: { error: INVALID_VALUES },
|
|
29837
|
+
context: { collectionName },
|
|
29838
|
+
stack
|
|
29839
|
+
});
|
|
29819
29840
|
}
|
|
29820
29841
|
if (gender && !Object.values(genderConstants).includes(gender)) {
|
|
29821
|
-
return {
|
|
29842
|
+
return decorateResult({
|
|
29843
|
+
result: { error: INVALID_VALUES },
|
|
29844
|
+
context: { gender },
|
|
29845
|
+
stack
|
|
29846
|
+
});
|
|
29822
29847
|
}
|
|
29823
29848
|
if (category && typeof category !== "object") {
|
|
29824
|
-
return {
|
|
29849
|
+
return decorateResult({
|
|
29850
|
+
result: { error: INVALID_VALUES },
|
|
29851
|
+
context: { category },
|
|
29852
|
+
stack
|
|
29853
|
+
});
|
|
29825
29854
|
}
|
|
29826
|
-
const stack = "modifyCollectionDefinition";
|
|
29827
29855
|
const valueAssignments = {
|
|
29828
29856
|
collectionValueProfiles,
|
|
29829
29857
|
collectionValue,
|
|
@@ -29835,10 +29863,8 @@ function modifyCollectionDefinition$1({
|
|
|
29835
29863
|
return decorateResult({ result: { error: MISSING_VALUE }, stack });
|
|
29836
29864
|
if (Object.values(valueAssignments).filter(Boolean).length > 1)
|
|
29837
29865
|
return decorateResult({
|
|
29838
|
-
|
|
29839
|
-
|
|
29840
|
-
error: INVALID_VALUES
|
|
29841
|
-
},
|
|
29866
|
+
info: "Only one value assignment allowed per collectionDefinition",
|
|
29867
|
+
result: { error: INVALID_VALUES },
|
|
29842
29868
|
stack
|
|
29843
29869
|
});
|
|
29844
29870
|
let result = getTieFormat$1({
|
|
@@ -29848,79 +29874,137 @@ function modifyCollectionDefinition$1({
|
|
|
29848
29874
|
eventId,
|
|
29849
29875
|
event
|
|
29850
29876
|
});
|
|
29851
|
-
if (result.error)
|
|
29877
|
+
if (result.error) {
|
|
29852
29878
|
return decorateResult({ result, stack });
|
|
29879
|
+
}
|
|
29853
29880
|
const { matchUp, structure, tieFormat: existingTieFormat } = result;
|
|
29854
29881
|
const tieFormat = copyTieFormat(existingTieFormat);
|
|
29855
|
-
const
|
|
29856
|
-
(
|
|
29882
|
+
const sourceCollectionDefinition = existingTieFormat?.collectionDefinitions.find(
|
|
29883
|
+
(collectionDefinition) => collectionDefinition.collectionId === collectionId
|
|
29857
29884
|
);
|
|
29858
|
-
|
|
29885
|
+
const targetCollectionDefinition = tieFormat?.collectionDefinitions.find(
|
|
29886
|
+
(collectionDefinition) => collectionDefinition.collectionId === collectionId
|
|
29887
|
+
);
|
|
29888
|
+
if (!sourceCollectionDefinition)
|
|
29859
29889
|
return decorateResult({ result: { error: NOT_FOUND }, stack });
|
|
29860
|
-
const value = collectionValue
|
|
29861
|
-
if (
|
|
29862
|
-
|
|
29863
|
-
|
|
29864
|
-
|
|
29865
|
-
}
|
|
29866
|
-
|
|
29867
|
-
|
|
29868
|
-
|
|
29869
|
-
|
|
29870
|
-
|
|
29871
|
-
|
|
29872
|
-
result: { error: INVALID_VALUES, info: result2.errors },
|
|
29873
|
-
stack
|
|
29874
|
-
});
|
|
29875
|
-
}
|
|
29890
|
+
const value = collectionValue ?? matchUpValue ?? scoreValue ?? setValue;
|
|
29891
|
+
if (collectionValueProfiles) {
|
|
29892
|
+
const result2 = validateCollectionValueProfile({
|
|
29893
|
+
matchUpCount: matchUpCount || sourceCollectionDefinition?.matchUpCount,
|
|
29894
|
+
collectionValueProfiles
|
|
29895
|
+
});
|
|
29896
|
+
if (result2.errors) {
|
|
29897
|
+
return decorateResult({
|
|
29898
|
+
result: { error: INVALID_VALUES },
|
|
29899
|
+
info: result2.errors,
|
|
29900
|
+
stack
|
|
29901
|
+
});
|
|
29876
29902
|
}
|
|
29877
|
-
|
|
29878
|
-
|
|
29879
|
-
|
|
29880
|
-
|
|
29881
|
-
|
|
29903
|
+
} else if (value && !isConvertableInteger(value)) {
|
|
29904
|
+
return decorateResult({
|
|
29905
|
+
result: { error: INVALID_VALUES },
|
|
29906
|
+
info: "value is not an integer",
|
|
29907
|
+
context: { value },
|
|
29908
|
+
stack
|
|
29909
|
+
});
|
|
29910
|
+
}
|
|
29911
|
+
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;
|
|
29912
|
+
const valueProfileModified = collectionValueProfiles && (!sourceCollectionDefinition.collectionValueProfiles || !equivalentValueProfiles(
|
|
29913
|
+
sourceCollectionDefinition.collectionValueProfiles,
|
|
29914
|
+
collectionValueProfiles
|
|
29915
|
+
));
|
|
29916
|
+
const valueModified = isConvertableInteger(collectionValue) && sourceCollectionDefinition.collectionValue !== collectionValue || isConvertableInteger(matchUpValue) && sourceCollectionDefinition.matchUpValue !== matchUpValue || isConvertableInteger(scoreValue) && sourceCollectionDefinition.scoreValue !== scoreValue || isConvertableInteger(setValue) && sourceCollectionDefinition.setValue !== setValue || valueProfileModified;
|
|
29917
|
+
const modifications = [];
|
|
29918
|
+
if (valueModified) {
|
|
29919
|
+
targetCollectionDefinition.collectionValueProfiles = void 0;
|
|
29920
|
+
targetCollectionDefinition.collectionValue = void 0;
|
|
29921
|
+
targetCollectionDefinition.matchUpValue = void 0;
|
|
29922
|
+
targetCollectionDefinition.scoreValue = void 0;
|
|
29923
|
+
targetCollectionDefinition.setValue = void 0;
|
|
29924
|
+
Object.assign(targetCollectionDefinition, valueAssignments);
|
|
29925
|
+
modifications.push({
|
|
29926
|
+
collectionId,
|
|
29927
|
+
...definedAttributes(valueAssignments)
|
|
29928
|
+
});
|
|
29882
29929
|
}
|
|
29883
|
-
if ((scoreValue || setValue) &&
|
|
29884
|
-
const targetCollectionGroupNumber =
|
|
29930
|
+
if ((isConvertableInteger(scoreValue) || isConvertableInteger(setValue)) && targetCollectionDefinition.collectionGroupNumber) {
|
|
29931
|
+
const targetCollectionGroupNumber = targetCollectionDefinition.collectionGroupNumber;
|
|
29885
29932
|
tieFormat.collectionDefinitions = tieFormat.collectionDefinitions.map(
|
|
29886
|
-
(
|
|
29887
|
-
const { collectionGroupNumber, ...rest } =
|
|
29933
|
+
(collectionDefinition) => {
|
|
29934
|
+
const { collectionGroupNumber, ...rest } = collectionDefinition;
|
|
29888
29935
|
if (collectionGroupNumber === targetCollectionGroupNumber) {
|
|
29889
29936
|
return rest;
|
|
29890
29937
|
} else {
|
|
29891
|
-
return
|
|
29938
|
+
return collectionDefinition;
|
|
29892
29939
|
}
|
|
29893
29940
|
}
|
|
29894
29941
|
);
|
|
29895
29942
|
tieFormat.collectionGroups = tieFormat.collectionGroups.filter(
|
|
29896
29943
|
({ groupNumber }) => groupNumber !== targetCollectionGroupNumber
|
|
29897
29944
|
);
|
|
29945
|
+
modifications.push({
|
|
29946
|
+
collectionId,
|
|
29947
|
+
change: "collectionGroupNumber removed"
|
|
29948
|
+
});
|
|
29898
29949
|
}
|
|
29899
29950
|
const { aggregateValue, valueGoal } = calculateWinCriteria(tieFormat);
|
|
29900
|
-
|
|
29901
|
-
|
|
29902
|
-
|
|
29903
|
-
|
|
29904
|
-
|
|
29905
|
-
|
|
29906
|
-
|
|
29907
|
-
|
|
29908
|
-
|
|
29909
|
-
|
|
29910
|
-
|
|
29911
|
-
|
|
29912
|
-
|
|
29913
|
-
|
|
29914
|
-
|
|
29915
|
-
|
|
29916
|
-
|
|
29917
|
-
|
|
29918
|
-
|
|
29919
|
-
|
|
29951
|
+
const winCriteria = definedAttributes({ aggregateValue, valueGoal });
|
|
29952
|
+
if (winCriteria.aggregateValue !== existingTieFormat?.winCriteria.aggregateValue || winCriteria.valueGoal !== existingTieFormat?.winCriteria.valueGoal) {
|
|
29953
|
+
tieFormat.winCriteria = winCriteria;
|
|
29954
|
+
modifications.push({ collectionId, winCriteria });
|
|
29955
|
+
}
|
|
29956
|
+
if (isConvertableInteger(collectionOrder) && sourceCollectionDefinition.collectionOrder !== collectionOrder) {
|
|
29957
|
+
targetCollectionDefinition.collectionOrder = collectionOrder;
|
|
29958
|
+
modifications.push({ collectionId, collectionOrder });
|
|
29959
|
+
}
|
|
29960
|
+
if (collectionName && sourceCollectionDefinition.collectionName !== collectionName) {
|
|
29961
|
+
targetCollectionDefinition.collectionName = collectionName;
|
|
29962
|
+
modifications.push({ collectionId, collectionName });
|
|
29963
|
+
}
|
|
29964
|
+
if (matchUpFormat && sourceCollectionDefinition.matchUpFormat !== matchUpFormat) {
|
|
29965
|
+
targetCollectionDefinition.matchUpFormat = matchUpFormat;
|
|
29966
|
+
modifications.push({ collectionId, matchUpFormat });
|
|
29967
|
+
}
|
|
29968
|
+
if (isConvertableInteger(matchUpCount) && sourceCollectionDefinition.matchUpCount !== matchUpCount) {
|
|
29969
|
+
return decorateResult({
|
|
29970
|
+
result: { error: NOT_IMPLEMENTED },
|
|
29971
|
+
context: { matchUpCount },
|
|
29972
|
+
stack
|
|
29973
|
+
});
|
|
29974
|
+
}
|
|
29975
|
+
if (matchUpType && sourceCollectionDefinition.matchUpType !== matchUpType) {
|
|
29976
|
+
return decorateResult({
|
|
29977
|
+
result: { error: NOT_IMPLEMENTED },
|
|
29978
|
+
context: { matchUpType },
|
|
29979
|
+
stack
|
|
29980
|
+
});
|
|
29981
|
+
}
|
|
29982
|
+
if (category && sourceCollectionDefinition.category !== category) {
|
|
29983
|
+
targetCollectionDefinition.category = category;
|
|
29984
|
+
modifications.push({ collectionId, category });
|
|
29985
|
+
}
|
|
29986
|
+
if (gender && sourceCollectionDefinition.gender !== gender) {
|
|
29987
|
+
targetCollectionDefinition.gender = gender;
|
|
29988
|
+
modifications.push({ collectionId, gender });
|
|
29989
|
+
}
|
|
29920
29990
|
const prunedTieFormat = definedAttributes(tieFormat);
|
|
29921
29991
|
result = validateTieFormat({ tieFormat: prunedTieFormat });
|
|
29922
|
-
if (result.error)
|
|
29992
|
+
if (result.error) {
|
|
29923
29993
|
return decorateResult({ result, stack });
|
|
29994
|
+
}
|
|
29995
|
+
if (!modifications.length) {
|
|
29996
|
+
return decorateResult({ result: { ...SUCCESS, modifications } });
|
|
29997
|
+
}
|
|
29998
|
+
const changedTieFormatName = existingTieFormat?.tieFormatName !== tieFormatName;
|
|
29999
|
+
if (changedTieFormatName) {
|
|
30000
|
+
prunedTieFormat.tieFormatName = tieFormatName;
|
|
30001
|
+
modifications.push({ tieFormatName });
|
|
30002
|
+
} else if (modifications.length) {
|
|
30003
|
+
delete prunedTieFormat.tieFormatName;
|
|
30004
|
+
modifications.push(
|
|
30005
|
+
"tieFormatName removed: modifications without new tieFormatName"
|
|
30006
|
+
);
|
|
30007
|
+
}
|
|
29924
30008
|
result = updateTieFormat({
|
|
29925
30009
|
tieFormat: prunedTieFormat,
|
|
29926
30010
|
updateInProgressMatchUps,
|
|
@@ -29935,8 +30019,8 @@ function modifyCollectionDefinition$1({
|
|
|
29935
30019
|
const { appliedPolicies } = getAppliedPolicies({ tournamentRecord });
|
|
29936
30020
|
if (appliedPolicies?.audit?.[TIE_FORMAT_MODIFICATIONS]) {
|
|
29937
30021
|
const auditData = definedAttributes({
|
|
30022
|
+
collectionDefinition: targetCollectionDefinition,
|
|
29938
30023
|
drawId: drawDefinition?.drawId,
|
|
29939
|
-
collectionDefinition,
|
|
29940
30024
|
action: stack,
|
|
29941
30025
|
structureId,
|
|
29942
30026
|
matchUpId,
|
|
@@ -29945,7 +30029,7 @@ function modifyCollectionDefinition$1({
|
|
|
29945
30029
|
tieFormatTelemetry({ drawDefinition, auditData });
|
|
29946
30030
|
}
|
|
29947
30031
|
}
|
|
29948
|
-
return decorateResult({ result, stack });
|
|
30032
|
+
return decorateResult({ result: { ...result, modifications }, stack });
|
|
29949
30033
|
}
|
|
29950
30034
|
|
|
29951
30035
|
function resolveTournamentRecord(params) {
|
|
@@ -30440,10 +30524,10 @@ function addCollectionDefinition$1({
|
|
|
30440
30524
|
({ collectionId }) => collectionId
|
|
30441
30525
|
);
|
|
30442
30526
|
if (collectionIds.includes(collectionDefinition.collectionId))
|
|
30443
|
-
return {
|
|
30444
|
-
collectionId: collectionDefinition.collectionId,
|
|
30445
|
-
error: DUPLICATE_VALUE
|
|
30446
|
-
};
|
|
30527
|
+
return decorateResult({
|
|
30528
|
+
context: { collectionId: collectionDefinition.collectionId },
|
|
30529
|
+
result: { error: DUPLICATE_VALUE }
|
|
30530
|
+
});
|
|
30447
30531
|
}
|
|
30448
30532
|
tieFormat.collectionDefinitions.push(collectionDefinition);
|
|
30449
30533
|
tieFormat.collectionDefinitions.sort((a, b) => (a.collectionOrder || 0) - (b.collectionOrder || 0)).forEach(
|
|
@@ -30516,7 +30600,10 @@ function addCollectionDefinition$1({
|
|
|
30516
30600
|
});
|
|
30517
30601
|
} else if (matchUpId && matchUp) {
|
|
30518
30602
|
if (!validUpdate({ matchUp, updateInProgressMatchUps }))
|
|
30519
|
-
return {
|
|
30603
|
+
return decorateResult({
|
|
30604
|
+
result: { error: CANNOT_MODIFY_TIEFORMAT },
|
|
30605
|
+
stack
|
|
30606
|
+
});
|
|
30520
30607
|
matchUp.tieFormat = prunedTieFormat;
|
|
30521
30608
|
const newMatchUps = generateCollectionMatchUps({
|
|
30522
30609
|
collectionDefinition,
|
|
@@ -30571,10 +30658,10 @@ function addCollectionDefinition$1({
|
|
|
30571
30658
|
tieFormatTelemetry({ drawDefinition, auditData });
|
|
30572
30659
|
}
|
|
30573
30660
|
return {
|
|
30574
|
-
...SUCCESS,
|
|
30575
30661
|
tieFormat: prunedTieFormat,
|
|
30576
30662
|
targetMatchUps,
|
|
30577
|
-
addedMatchUps
|
|
30663
|
+
addedMatchUps,
|
|
30664
|
+
...SUCCESS
|
|
30578
30665
|
};
|
|
30579
30666
|
}
|
|
30580
30667
|
function updateStructureMatchUps({
|
|
@@ -31105,45 +31192,42 @@ function modifyTieFormat$1({
|
|
|
31105
31192
|
return decorateResult({ result, stack });
|
|
31106
31193
|
const { matchUp, tieFormat: existingTieFormat } = result;
|
|
31107
31194
|
const tieFormat = copyTieFormat(existingTieFormat);
|
|
31195
|
+
if (!compareTieFormats({ ancestor: tieFormat, descendant: modifiedTieFormat })?.different) {
|
|
31196
|
+
return { ...SUCCESS };
|
|
31197
|
+
}
|
|
31108
31198
|
const existingCollectionIds = tieFormat.collectionDefinitions.map(
|
|
31109
31199
|
({ collectionId }) => collectionId
|
|
31110
31200
|
);
|
|
31111
|
-
const
|
|
31112
|
-
|
|
31113
|
-
|
|
31114
|
-
modifiedTieFormat.collectionDefinitions.forEach((def) => {
|
|
31115
|
-
updatedCollectionIds.push(def.collectionId);
|
|
31116
|
-
if (modifiedTieFormat && existingCollectionIds.includes(def.collectionId)) {
|
|
31117
|
-
compareTieFormats({
|
|
31118
|
-
descendant: modifiedTieFormat,
|
|
31119
|
-
ancestor: tieFormat
|
|
31120
|
-
})?.different && modifiedCollectionDefinitions.push(def);
|
|
31121
|
-
} else {
|
|
31122
|
-
addedCollectionDefinitions.push(def);
|
|
31123
|
-
}
|
|
31124
|
-
});
|
|
31201
|
+
const updatedCollectionIds = modifiedTieFormat.collectionDefinitions.map(
|
|
31202
|
+
({ collectionId }) => collectionId
|
|
31203
|
+
);
|
|
31125
31204
|
const removedCollectionIds = existingCollectionIds.filter(
|
|
31126
31205
|
(collectionId) => !updatedCollectionIds.includes(collectionId)
|
|
31127
31206
|
);
|
|
31128
|
-
const
|
|
31207
|
+
const addedCollectionDefinitions = modifiedTieFormat.collectionDefinitions.filter(
|
|
31208
|
+
({ collectionId }) => !existingCollectionIds.includes(collectionId)
|
|
31209
|
+
);
|
|
31210
|
+
const modifications = [];
|
|
31129
31211
|
let processedTieFormat;
|
|
31130
|
-
for (const collectionDefinition of
|
|
31212
|
+
for (const collectionDefinition of modifiedTieFormat.collectionDefinitions) {
|
|
31131
31213
|
const result2 = modifyCollectionDefinition$1({
|
|
31132
31214
|
updateInProgressMatchUps,
|
|
31133
31215
|
...collectionDefinition,
|
|
31134
31216
|
tournamentRecord,
|
|
31135
31217
|
drawDefinition,
|
|
31136
|
-
tieFormatName,
|
|
31137
31218
|
structureId,
|
|
31138
31219
|
matchUpId,
|
|
31139
31220
|
eventId,
|
|
31140
31221
|
event
|
|
31141
31222
|
});
|
|
31223
|
+
if (result2.modifications)
|
|
31224
|
+
modifications.push(...result2.modifications);
|
|
31142
31225
|
if (result2.error)
|
|
31143
31226
|
return decorateResult({ result: result2, stack });
|
|
31144
31227
|
if (result2.tieFormat)
|
|
31145
31228
|
processedTieFormat = result2.tieFormat;
|
|
31146
31229
|
}
|
|
31230
|
+
const tieFormatName = modifiedTieFormat.tieFormatName;
|
|
31147
31231
|
for (const collectionDefinition of addedCollectionDefinitions) {
|
|
31148
31232
|
const result2 = addCollectionDefinition$1({
|
|
31149
31233
|
updateInProgressMatchUps,
|
|
@@ -31182,10 +31266,20 @@ function modifyTieFormat$1({
|
|
|
31182
31266
|
if (result2.tieFormat)
|
|
31183
31267
|
processedTieFormat = result2.tieFormat;
|
|
31184
31268
|
}
|
|
31269
|
+
const changedTieFormatName = existingTieFormat?.tieFormatName !== tieFormatName;
|
|
31270
|
+
if (changedTieFormatName) {
|
|
31271
|
+
processedTieFormat.tieFormatName = tieFormatName;
|
|
31272
|
+
modifications.push({ tieFormatName });
|
|
31273
|
+
} else if (modifications.length) {
|
|
31274
|
+
delete processedTieFormat.tieFormatName;
|
|
31275
|
+
modifications.push(
|
|
31276
|
+
"tieFormatName removed: modifications without new tieFormatName"
|
|
31277
|
+
);
|
|
31278
|
+
}
|
|
31185
31279
|
processedTieFormat.collectionDefinitions = processedTieFormat.collectionDefinitions.sort(
|
|
31186
31280
|
(a, b) => numericSortValue(a.collectionOrder) - numericSortValue(b.collectionOrder)
|
|
31187
31281
|
).map((def, i) => ({ ...def, collectionOrder: i + 1 }));
|
|
31188
|
-
return { ...SUCCESS, processedTieFormat };
|
|
31282
|
+
return { ...SUCCESS, processedTieFormat, modifications };
|
|
31189
31283
|
}
|
|
31190
31284
|
|
|
31191
31285
|
function modifyTieFormat(params) {
|
|
@@ -60246,6 +60340,7 @@ var lastNames = [
|
|
|
60246
60340
|
"Dallas",
|
|
60247
60341
|
"Diamond",
|
|
60248
60342
|
"Deckard",
|
|
60343
|
+
"Dunbar",
|
|
60249
60344
|
"Earhart",
|
|
60250
60345
|
"Eisenstein",
|
|
60251
60346
|
"Eldritch",
|