tods-competition-factory 2.0.50 → 2.0.52
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 +40 -20
- package/dist/tods-competition-factory.development.cjs.js +317 -146
- 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 +2 -2
|
@@ -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.52';
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
function isFunction(obj) {
|
|
@@ -1783,9 +1783,35 @@ function decorateResult({ context, result, stack, info }) {
|
|
|
1783
1783
|
return result ?? { success: true };
|
|
1784
1784
|
}
|
|
1785
1785
|
|
|
1786
|
+
const RESOURCE_SUB_TYPE = 'resourceSubType';
|
|
1787
|
+
const RESOURCE_TYPE = 'resourceType';
|
|
1788
|
+
const IDENTIFIER = 'identifier';
|
|
1789
|
+
|
|
1790
|
+
const SINGLES$1 = 'SINGLES';
|
|
1791
|
+
const SINGLES_EVENT = 'SINGLES';
|
|
1792
|
+
const DOUBLES$1 = 'DOUBLES';
|
|
1793
|
+
const DOUBLES_EVENT = 'DOUBLES';
|
|
1794
|
+
const TEAM$2 = 'TEAM';
|
|
1795
|
+
const TEAM_EVENT = 'TEAM';
|
|
1796
|
+
const AGE = 'AGE';
|
|
1797
|
+
const RATING$2 = 'RATING';
|
|
1798
|
+
const BOTH = 'BOTH';
|
|
1799
|
+
const eventConstants = {
|
|
1800
|
+
AGE,
|
|
1801
|
+
BOTH,
|
|
1802
|
+
DOUBLES: DOUBLES$1,
|
|
1803
|
+
DOUBLES_EVENT,
|
|
1804
|
+
RATING: RATING$2,
|
|
1805
|
+
SINGLES: SINGLES$1,
|
|
1806
|
+
SINGLES_EVENT,
|
|
1807
|
+
TEAM_EVENT,
|
|
1808
|
+
TEAM: TEAM$2,
|
|
1809
|
+
};
|
|
1810
|
+
|
|
1786
1811
|
const TOURNAMENT_RECORDS = 'tournamentRecords';
|
|
1787
1812
|
const POLICY_DEFINITIONS = 'policyDefinitions';
|
|
1788
1813
|
const TOURNAMENT_RECORD = 'tournamentRecord';
|
|
1814
|
+
const ONLINE_RESOURCE = 'onlineResource';
|
|
1789
1815
|
const DRAW_DEFINITION = 'drawDefinition';
|
|
1790
1816
|
const MATCHUP_FORMAT = 'matchUpFormat';
|
|
1791
1817
|
const PARTICIPANT_ID = 'participantId';
|
|
@@ -1798,6 +1824,7 @@ const MATCHUP_IDS = 'matchUpIds';
|
|
|
1798
1824
|
const POLICY_TYPE = 'policyType';
|
|
1799
1825
|
const STRUCTURES = 'structures';
|
|
1800
1826
|
const MATCHUP_ID = 'matchUpId';
|
|
1827
|
+
const EVENT_TYPE = 'eventType';
|
|
1801
1828
|
const IN_CONTEXT = 'inContext';
|
|
1802
1829
|
const STRUCTURE = 'structure';
|
|
1803
1830
|
const COURT_IDS = 'courtIds';
|
|
@@ -1825,6 +1852,10 @@ const OF_TYPE = '_ofType';
|
|
|
1825
1852
|
const ANY_OF = '_anyOf';
|
|
1826
1853
|
const ONE_OF = '_oneOf';
|
|
1827
1854
|
|
|
1855
|
+
const validators = {
|
|
1856
|
+
[EVENT_TYPE]: (value) => [SINGLES$1, DOUBLES$1, TEAM$2].includes(value),
|
|
1857
|
+
[ONLINE_RESOURCE]: (value) => intersection(Object.keys(value), [RESOURCE_SUB_TYPE, RESOURCE_TYPE, IDENTIFIER]).length === 3,
|
|
1858
|
+
};
|
|
1828
1859
|
const errors = {
|
|
1829
1860
|
[TOURNAMENT_RECORDS]: MISSING_TOURNAMENT_RECORDS,
|
|
1830
1861
|
[TOURNAMENT_RECORD]: MISSING_TOURNAMENT_RECORD,
|
|
@@ -1836,6 +1867,8 @@ const errors = {
|
|
|
1836
1867
|
[STRUCTURE_ID]: MISSING_STRUCTURE_ID,
|
|
1837
1868
|
[MATCHUP_IDS]: MISSING_MATCHUP_IDS,
|
|
1838
1869
|
[PARTICIPANT]: MISSING_PARTICIPANT,
|
|
1870
|
+
[ONLINE_RESOURCE]: INVALID_OBJECT,
|
|
1871
|
+
[EVENT_TYPE]: INVALID_EVENT_TYPE,
|
|
1839
1872
|
[STRUCTURES]: MISSING_STRUCTURES,
|
|
1840
1873
|
[MATCHUP_ID]: MISSING_MATCHUP_ID,
|
|
1841
1874
|
[STRUCTURE]: MISSING_STRUCTURE,
|
|
@@ -1853,6 +1886,7 @@ const paramTypes = {
|
|
|
1853
1886
|
[POLICY_DEFINITIONS]: OBJECT,
|
|
1854
1887
|
[TOURNAMENT_RECORD]: OBJECT,
|
|
1855
1888
|
[DRAW_DEFINITION]: OBJECT,
|
|
1889
|
+
[ONLINE_RESOURCE]: OBJECT,
|
|
1856
1890
|
[SCHEDULE_DATES]: ARRAY,
|
|
1857
1891
|
[PARTICIPANT]: OBJECT,
|
|
1858
1892
|
[MATCHUP_IDS]: ARRAY,
|
|
@@ -1923,7 +1957,9 @@ function findParamError(params, requiredParams) {
|
|
|
1923
1957
|
const faliedTypeCheck = params[param] !== undefined && !_validate && invalidType(params, param, _ofType);
|
|
1924
1958
|
const paramNotPresent = attrs[param] && [undefined, null].includes(params[param]);
|
|
1925
1959
|
const invalid = invalidValidationFunction || faliedTypeCheck || paramNotPresent;
|
|
1926
|
-
const hasError = invalid ||
|
|
1960
|
+
const hasError = invalid ||
|
|
1961
|
+
(_validate && params[param] !== undefined && !checkValidation(params[param], _validate)) ||
|
|
1962
|
+
(validators[param] && !validators[param](params[param]));
|
|
1927
1963
|
if (hasError) {
|
|
1928
1964
|
errorParam = param;
|
|
1929
1965
|
paramInfo = _info;
|
|
@@ -1947,27 +1983,6 @@ function checkValidation(value, validate) {
|
|
|
1947
1983
|
return true;
|
|
1948
1984
|
}
|
|
1949
1985
|
|
|
1950
|
-
const SINGLES$1 = 'SINGLES';
|
|
1951
|
-
const SINGLES_EVENT = 'SINGLES';
|
|
1952
|
-
const DOUBLES$1 = 'DOUBLES';
|
|
1953
|
-
const DOUBLES_EVENT = 'DOUBLES';
|
|
1954
|
-
const TEAM$2 = 'TEAM';
|
|
1955
|
-
const TEAM_EVENT = 'TEAM';
|
|
1956
|
-
const AGE = 'AGE';
|
|
1957
|
-
const RATING$2 = 'RATING';
|
|
1958
|
-
const BOTH = 'BOTH';
|
|
1959
|
-
const eventConstants = {
|
|
1960
|
-
AGE,
|
|
1961
|
-
BOTH,
|
|
1962
|
-
DOUBLES: DOUBLES$1,
|
|
1963
|
-
DOUBLES_EVENT,
|
|
1964
|
-
RATING: RATING$2,
|
|
1965
|
-
SINGLES: SINGLES$1,
|
|
1966
|
-
SINGLES_EVENT,
|
|
1967
|
-
TEAM_EVENT,
|
|
1968
|
-
TEAM: TEAM$2,
|
|
1969
|
-
};
|
|
1970
|
-
|
|
1971
1986
|
const DYNAMIC = 'DYNAMIC';
|
|
1972
1987
|
const RANKING$1 = 'RANKING';
|
|
1973
1988
|
const RATING$1 = 'RATING';
|
|
@@ -2710,8 +2725,8 @@ const APPLIED_POLICIES = 'appliedPolicies';
|
|
|
2710
2725
|
const CONTEXT = 'context';
|
|
2711
2726
|
const DELEGATED_OUTCOME = 'delegatedOutcome';
|
|
2712
2727
|
const DISABLED = 'disabled';
|
|
2713
|
-
const DISABLE_LINKS = 'disableLinks';
|
|
2714
2728
|
const DISABLE_AUTO_CALC = 'disableAutoCalc';
|
|
2729
|
+
const DISABLE_LINKS = 'disableLinks';
|
|
2715
2730
|
const DISPLAY = 'display';
|
|
2716
2731
|
const DRAW_DELETIONS = 'drawDeletions';
|
|
2717
2732
|
const DRAW_PROFILE = 'drawProfile';
|
|
@@ -2728,6 +2743,7 @@ const PARTICIPANT_REPRESENTATIVES = 'participantRepresentatives';
|
|
|
2728
2743
|
const PERSON_REQUESTS = 'personRequests';
|
|
2729
2744
|
const POSITION_ACTIONS = 'positionActions';
|
|
2730
2745
|
const RANKING_POINTS = 'rankingPoints';
|
|
2746
|
+
const REGISTRATION$1 = 'registration';
|
|
2731
2747
|
const ROUND_TARGET = 'roundTarget';
|
|
2732
2748
|
const SCHEDULE_LIMITS = 'scheduleLimits';
|
|
2733
2749
|
const SCHEDULE_TIMING = 'scheduleTiming';
|
|
@@ -2759,6 +2775,7 @@ const extensionConstants = {
|
|
|
2759
2775
|
PERSON_REQUESTS,
|
|
2760
2776
|
POSITION_ACTIONS,
|
|
2761
2777
|
RANKING_POINTS,
|
|
2778
|
+
REGISTRATION: REGISTRATION$1,
|
|
2762
2779
|
ROUND_TARGET,
|
|
2763
2780
|
SCHEDULE_LIMITS,
|
|
2764
2781
|
SCHEDULE_TIMING,
|
|
@@ -2772,9 +2789,11 @@ const extensionConstants = {
|
|
|
2772
2789
|
const internalExtensions = [
|
|
2773
2790
|
DELEGATED_OUTCOME,
|
|
2774
2791
|
DISABLED,
|
|
2792
|
+
DISABLE_AUTO_CALC,
|
|
2775
2793
|
DISABLE_LINKS,
|
|
2776
2794
|
FLIGHT_PROFILE,
|
|
2777
2795
|
LINEUPS,
|
|
2796
|
+
LINKED_TOURNAMENTS,
|
|
2778
2797
|
MATCHUP_HISTORY,
|
|
2779
2798
|
PARTICIPANT_REPRESENTATIVES,
|
|
2780
2799
|
PERSON_REQUESTS,
|
|
@@ -2784,6 +2803,7 @@ const internalExtensions = [
|
|
|
2784
2803
|
SCHEDULING_PROFILE,
|
|
2785
2804
|
SUB_ORDER,
|
|
2786
2805
|
TALLY,
|
|
2806
|
+
TIE_FORMAT_MODIFICATIONS,
|
|
2787
2807
|
];
|
|
2788
2808
|
|
|
2789
2809
|
function linkTournaments({ tournamentRecords }) {
|
|
@@ -26492,9 +26512,14 @@ function addParticipantScaleItem({ removePriorValues, participant, scaleItem })
|
|
|
26492
26512
|
return { ...SUCCESS, valueChanged, newValue: scaleItem.scaleValue };
|
|
26493
26513
|
}
|
|
26494
26514
|
|
|
26495
|
-
function addDynamicRatings(
|
|
26496
|
-
|
|
26497
|
-
|
|
26515
|
+
function addDynamicRatings(params) {
|
|
26516
|
+
const { tournamentRecord, modifiedScaleValues, removePriorValues } = params;
|
|
26517
|
+
const paramsCheck = checkRequiredParameters(params, [
|
|
26518
|
+
{ [TOURNAMENT_RECORD]: true },
|
|
26519
|
+
{ modifiedScaleValues: true, [OF_TYPE]: OBJECT },
|
|
26520
|
+
]);
|
|
26521
|
+
if (paramsCheck.error)
|
|
26522
|
+
return paramsCheck;
|
|
26498
26523
|
for (const participantId in modifiedScaleValues) {
|
|
26499
26524
|
const result = setParticipantScaleItem({
|
|
26500
26525
|
scaleItem: modifiedScaleValues[participantId],
|
|
@@ -26628,19 +26653,19 @@ function generateDynamicRatings(params) {
|
|
|
26628
26653
|
const ratingParameter = ratingsParameters[ratingType];
|
|
26629
26654
|
const { accessor } = ratingParameter;
|
|
26630
26655
|
const modifiedScaleValues = {};
|
|
26631
|
-
const matchUps = params.matchUps
|
|
26656
|
+
const matchUps = (params.matchUps ||
|
|
26632
26657
|
(refreshDynamic &&
|
|
26633
26658
|
allDrawMatchUps({
|
|
26634
26659
|
drawDefinition,
|
|
26635
26660
|
tournamentRecord,
|
|
26636
26661
|
inContext: true,
|
|
26637
26662
|
matchUpFilters: { matchUpStatuses: completedMatchUpStatuses },
|
|
26638
|
-
}))
|
|
26663
|
+
}).matchUps) ||
|
|
26639
26664
|
allTournamentMatchUps({
|
|
26640
26665
|
matchUpFilters: { matchUpIds, matchUpStatuses: completedMatchUpStatuses },
|
|
26641
26666
|
tournamentRecord,
|
|
26642
26667
|
inContext: true,
|
|
26643
|
-
}).matchUps ??
|
|
26668
|
+
}).matchUps) ??
|
|
26644
26669
|
[];
|
|
26645
26670
|
const dynamicScaleName = `${ratingType}.${DYNAMIC}`;
|
|
26646
26671
|
const outputScaleName = asDynamic ? dynamicScaleName : ratingType;
|
|
@@ -26670,7 +26695,7 @@ function generateDynamicRatings(params) {
|
|
|
26670
26695
|
.flat()
|
|
26671
26696
|
.map((participantId) => {
|
|
26672
26697
|
const existingModifiedScaleValue = modifiedScaleValues[participantId];
|
|
26673
|
-
const useDynamic = !refreshDynamic ||
|
|
26698
|
+
const useDynamic = !refreshDynamic || existingModifiedScaleValue;
|
|
26674
26699
|
const dynamicScaleItem = useDynamic
|
|
26675
26700
|
? getParticipantScaleItem({
|
|
26676
26701
|
scaleAttributes: dynamicScaleAttributes,
|
|
@@ -26998,7 +27023,8 @@ function getSideRatings({ tournamentParticipants, adHocRatings, eventType, scale
|
|
|
26998
27023
|
});
|
|
26999
27024
|
}
|
|
27000
27025
|
|
|
27001
|
-
function getPairings(
|
|
27026
|
+
function getPairings(params) {
|
|
27027
|
+
const { tournamentParticipants, adHocRatings = {}, possiblePairings, uniquePairings, maxIterations, minimizeDelta, deltaObjects, valueObjects, eventType, scaleName, salted, } = params;
|
|
27002
27028
|
uniquePairings.forEach((pairing) => {
|
|
27003
27029
|
const ratings = getSideRatings({
|
|
27004
27030
|
tournamentParticipants,
|
|
@@ -27030,7 +27056,7 @@ function getPairings({ tournamentParticipants, adHocRatings = {}, possiblePairin
|
|
|
27030
27056
|
deltaObjects,
|
|
27031
27057
|
valueObjects,
|
|
27032
27058
|
});
|
|
27033
|
-
const { participantIdPairings } = candidate;
|
|
27059
|
+
const { participantIdPairings } = minimizeDelta ? deltaCandidate : candidate;
|
|
27034
27060
|
return {
|
|
27035
27061
|
participantIdPairings,
|
|
27036
27062
|
candidatesCount,
|
|
@@ -27043,14 +27069,13 @@ function getPairings({ tournamentParticipants, adHocRatings = {}, possiblePairin
|
|
|
27043
27069
|
const ENCOUNTER_VALUE = 100;
|
|
27044
27070
|
const SAME_TEAM_VALUE = 100;
|
|
27045
27071
|
const MAX_ITERATIONS = 4000;
|
|
27046
|
-
function generateDrawMaticRound(
|
|
27072
|
+
function generateDrawMaticRound(params) {
|
|
27073
|
+
const { encounterValue = ENCOUNTER_VALUE, sameTeamValue = SAME_TEAM_VALUE, maxIterations = MAX_ITERATIONS, updateParticipantRatings, generateMatchUps = true, ignoreLastRoundNumber, iterationMatchUps, tournamentRecord, dynamicRatings, refreshDynamic, participantIds, drawDefinition, roundNumber, structureId, matchUpIds, eventType, scaleName, idPrefix, isMock, salted, event, } = params;
|
|
27047
27074
|
if (!drawDefinition)
|
|
27048
27075
|
return { error: MISSING_DRAW_DEFINITION };
|
|
27049
|
-
if (!structure && !structureId)
|
|
27076
|
+
if (!params.structure && !structureId)
|
|
27050
27077
|
return { error: STRUCTURE_NOT_FOUND };
|
|
27051
|
-
|
|
27052
|
-
structure = findStructure({ drawDefinition, structureId }).structure;
|
|
27053
|
-
}
|
|
27078
|
+
const structure = params.structure || findStructure({ drawDefinition, structureId }).structure;
|
|
27054
27079
|
if (!isObject(structure))
|
|
27055
27080
|
return { error: MISSING_STRUCTURE };
|
|
27056
27081
|
if (!participantIds?.length)
|
|
@@ -27067,7 +27092,7 @@ function generateDrawMaticRound({ encounterValue = ENCOUNTER_VALUE, sameTeamValu
|
|
|
27067
27092
|
?.filter(({ roundNumber }) => roundNumber === lastRoundNumber)
|
|
27068
27093
|
.map(({ matchUpId }) => matchUpId);
|
|
27069
27094
|
const result = generateDynamicRatings({
|
|
27070
|
-
ratingType: scaleName
|
|
27095
|
+
ratingType: scaleName ?? event?.category?.ratingType,
|
|
27071
27096
|
updateParticipantRatings,
|
|
27072
27097
|
tournamentRecord,
|
|
27073
27098
|
asDynamic: true,
|
|
@@ -27090,14 +27115,15 @@ function generateDrawMaticRound({ encounterValue = ENCOUNTER_VALUE, sameTeamValu
|
|
|
27090
27115
|
const { uniquePairings, possiblePairings, deltaObjects } = getPairingsData({
|
|
27091
27116
|
participantIds,
|
|
27092
27117
|
});
|
|
27093
|
-
const
|
|
27094
|
-
|
|
27118
|
+
const adHocRatings = Object.values(modifiedScaleValues).length ? modifiedScaleValues : params.adHocRatings;
|
|
27119
|
+
const paringParams = {
|
|
27095
27120
|
tournamentParticipants,
|
|
27096
27121
|
possiblePairings,
|
|
27097
|
-
drawDefinition,
|
|
27098
27122
|
participantIds,
|
|
27099
27123
|
uniquePairings,
|
|
27124
|
+
drawDefinition,
|
|
27100
27125
|
maxIterations,
|
|
27126
|
+
adHocRatings,
|
|
27101
27127
|
deltaObjects,
|
|
27102
27128
|
valueObjects,
|
|
27103
27129
|
eventType,
|
|
@@ -27105,7 +27131,7 @@ function generateDrawMaticRound({ encounterValue = ENCOUNTER_VALUE, sameTeamValu
|
|
|
27105
27131
|
structure,
|
|
27106
27132
|
salted,
|
|
27107
27133
|
};
|
|
27108
|
-
const { candidatesCount, participantIdPairings, iterations, candidate } = getPairings(
|
|
27134
|
+
const { candidatesCount, participantIdPairings, deltaCandidate, iterations, candidate } = getPairings(paringParams);
|
|
27109
27135
|
if (!candidatesCount)
|
|
27110
27136
|
return { error: NO_CANDIDATES };
|
|
27111
27137
|
let generatedRoundNumber;
|
|
@@ -27134,6 +27160,7 @@ function generateDrawMaticRound({ encounterValue = ENCOUNTER_VALUE, sameTeamValu
|
|
|
27134
27160
|
participantIdPairings,
|
|
27135
27161
|
modifiedScaleValues,
|
|
27136
27162
|
candidatesCount,
|
|
27163
|
+
deltaCandidate,
|
|
27137
27164
|
...SUCCESS,
|
|
27138
27165
|
iterations,
|
|
27139
27166
|
matchUps,
|
|
@@ -38134,17 +38161,19 @@ function modifyEventPublishStatus({ removePriorValues = true, status = PUBLIC, s
|
|
|
38134
38161
|
}
|
|
38135
38162
|
|
|
38136
38163
|
function publishEvent(params) {
|
|
38164
|
+
const paramsCheck = checkRequiredParameters(params, [
|
|
38165
|
+
{ [TOURNAMENT_RECORD]: true, [EVENT]: true },
|
|
38166
|
+
{ eventDataParams: false, [OF_TYPE]: OBJECT },
|
|
38167
|
+
]);
|
|
38168
|
+
if (paramsCheck.error)
|
|
38169
|
+
return paramsCheck;
|
|
38137
38170
|
const { includePositionAssignments, removePriorValues, tournamentRecord, status = PUBLIC, event, drawIdsToRemove, drawIdsToAdd, } = params;
|
|
38138
|
-
if (!tournamentRecord)
|
|
38139
|
-
return { error: MISSING_TOURNAMENT_RECORD };
|
|
38140
|
-
if (!event)
|
|
38141
|
-
return { error: MISSING_EVENT };
|
|
38142
38171
|
const { appliedPolicies } = getAppliedPolicies({ tournamentRecord, event });
|
|
38143
38172
|
const policyDefinitions = {
|
|
38144
38173
|
...appliedPolicies,
|
|
38145
38174
|
...params.policyDefinitions,
|
|
38146
38175
|
};
|
|
38147
|
-
const eventDrawIds = event
|
|
38176
|
+
const eventDrawIds = event?.drawDefinitions?.map(({ drawId }) => drawId) ?? [];
|
|
38148
38177
|
const keyedDrawIds = params.drawDetails ? Object.keys(params.drawDetails) : [];
|
|
38149
38178
|
const specifiedDrawIds = keyedDrawIds.length ? [] : params.drawIds;
|
|
38150
38179
|
const drawIdsToValidate = (drawIdsToAdd ?? []).concat(...(drawIdsToRemove ?? []), ...(specifiedDrawIds ?? []), ...keyedDrawIds);
|
|
@@ -38190,7 +38219,7 @@ function publishEvent(params) {
|
|
|
38190
38219
|
stageDetails,
|
|
38191
38220
|
};
|
|
38192
38221
|
if (structureIdsToAdd.length || structureIdsToRemove.length) {
|
|
38193
|
-
const drawStructureIds = (event
|
|
38222
|
+
const drawStructureIds = (event?.drawDefinitions?.find((drawDefinition) => drawDefinition.drawId === drawId)?.structures ?? []).map(({ structureId }) => structureId);
|
|
38194
38223
|
const structureIdsToValidate = (structureIdsToAdd ?? []).concat(structureIdsToRemove ?? []);
|
|
38195
38224
|
const invalidStructureIds = structureIdsToValidate.filter((structureId) => !drawStructureIds.includes(structureId));
|
|
38196
38225
|
if (invalidStructureIds.length) {
|
|
@@ -38210,7 +38239,7 @@ function publishEvent(params) {
|
|
|
38210
38239
|
}
|
|
38211
38240
|
drawDetails[drawId].structureDetails = structureDetails;
|
|
38212
38241
|
}
|
|
38213
|
-
const drawStages = (event
|
|
38242
|
+
const drawStages = (event?.drawDefinitions?.find((drawDefinition) => drawDefinition.drawId === drawId)?.structures ?? []).map(({ stage }) => stage);
|
|
38214
38243
|
if (stagesToAdd.length) {
|
|
38215
38244
|
for (const stage of stagesToAdd) {
|
|
38216
38245
|
stageDetails[stage] = { published: true };
|
|
@@ -38247,6 +38276,7 @@ function publishEvent(params) {
|
|
|
38247
38276
|
const eventData = notify || params.returnEventData
|
|
38248
38277
|
? getEventData({
|
|
38249
38278
|
includePositionAssignments,
|
|
38279
|
+
...params.eventDataParams,
|
|
38250
38280
|
usePublishState: true,
|
|
38251
38281
|
tournamentRecord,
|
|
38252
38282
|
policyDefinitions,
|
|
@@ -38429,6 +38459,7 @@ function deleteDrawDefinitions(params) {
|
|
|
38429
38459
|
addDrawDeletionTelemetry({ appliedPolicies, event, deletedDrawsDetail, auditData });
|
|
38430
38460
|
if (autoPublish && publishedDrawsDeleted) {
|
|
38431
38461
|
const result = publishEvent({
|
|
38462
|
+
...params.eventDataParams,
|
|
38432
38463
|
drawIdsToRemove: drawIds,
|
|
38433
38464
|
policyDefinitions,
|
|
38434
38465
|
tournamentRecord,
|
|
@@ -47564,8 +47595,8 @@ function nameMocks({ nameRoot = 'TEAM', count = 1 } = {}) {
|
|
|
47564
47595
|
}
|
|
47565
47596
|
|
|
47566
47597
|
function generateParticipants(params) {
|
|
47567
|
-
let {
|
|
47568
|
-
const { ratingsParameters: ratingsParameters$1 = ratingsParameters, valuesInstanceLimit, consideredDate, category, nationalityCodesCount, nationalityCodeType, nationalityCodes, participantsCount = 32, participantType, personIds, idPrefix, uuids, personExtensions, addressProps, gendersCount, matchUpType, personData, sex, inContext, withISO2, withIOC, scaleAllParticipants, } = params;
|
|
47598
|
+
let { scaledParticipantsCount, rankingRange, } = params;
|
|
47599
|
+
const { ratingsParameters: ratingsParameters$1 = ratingsParameters, valuesInstanceLimit, ratingsValues = [], consideredDate, categories, category, nationalityCodesCount, nationalityCodeType, nationalityCodes, participantsCount = 32, participantType, personIds, idPrefix, uuids, personExtensions, addressProps, gendersCount, matchUpType, personData, sex, inContext, withISO2, withIOC, scaleAllParticipants, } = params;
|
|
47569
47600
|
const doubles = participantType === PAIR || matchUpType === DOUBLES_MATCHUP;
|
|
47570
47601
|
const team = participantType === TEAM || matchUpType === TEAM;
|
|
47571
47602
|
if (rankingRange &&
|
|
@@ -47592,57 +47623,36 @@ function generateParticipants(params) {
|
|
|
47592
47623
|
if (result.error)
|
|
47593
47624
|
return result;
|
|
47594
47625
|
const { nationalityCodes: personNationalityCodes, persons: mockedPersons } = result;
|
|
47595
|
-
|
|
47596
|
-
|
|
47597
|
-
|
|
47598
|
-
|
|
47599
|
-
|
|
47600
|
-
|
|
47601
|
-
|
|
47602
|
-
|
|
47603
|
-
|
|
47604
|
-
|
|
47605
|
-
|
|
47606
|
-
|
|
47607
|
-
|
|
47608
|
-
|
|
47609
|
-
|
|
47610
|
-
|
|
47611
|
-
|
|
47612
|
-
|
|
47613
|
-
|
|
47614
|
-
|
|
47615
|
-
|
|
47616
|
-
|
|
47617
|
-
|
|
47618
|
-
|
|
47619
|
-
|
|
47620
|
-
|
|
47621
|
-
|
|
47622
|
-
}
|
|
47623
|
-
else {
|
|
47624
|
-
generatedAttributes[attribute] = attributeValue;
|
|
47625
|
-
}
|
|
47626
|
-
}
|
|
47627
|
-
return generatedAttributes;
|
|
47628
|
-
};
|
|
47629
|
-
const inverted = range[0] > range[1];
|
|
47630
|
-
const skew = inverted ? 2 : 0.5;
|
|
47631
|
-
const [min, max] = range.slice().sort();
|
|
47632
|
-
const generateRatings = () => generateRange(0, 2000)
|
|
47633
|
-
.map(() => skewedDistribution(min, max, skew, step, decimalsCount))
|
|
47634
|
-
.filter((rating) => (!ratingMax || rating <= ratingMax) && (!ratingMin || rating >= ratingMin))
|
|
47635
|
-
.slice(0, scaledParticipantsCount || randomInt(20, 30))
|
|
47636
|
-
.map((scaleValue) => {
|
|
47637
|
-
return !accessors
|
|
47638
|
-
? scaleValue
|
|
47639
|
-
: Object.assign({}, ...accessors.map((accessor) => ({ [accessor]: scaleValue })), getAttributes(attributes));
|
|
47626
|
+
const doublesRankings = {}, singlesRankings = {}, singlesRatings = {}, doublesRatings = {};
|
|
47627
|
+
const assignResult = (result) => {
|
|
47628
|
+
Object.assign(doublesRankings, result.doublesRankings);
|
|
47629
|
+
Object.assign(singlesRankings, result.singlesRankings);
|
|
47630
|
+
Object.assign(doublesRatings, result.doublesRatings);
|
|
47631
|
+
Object.assign(singlesRatings, result.singlesRatings);
|
|
47632
|
+
};
|
|
47633
|
+
if (isObject(category)) {
|
|
47634
|
+
const result = genRatings({
|
|
47635
|
+
scaledParticipantsCount,
|
|
47636
|
+
ratingsParameters: ratingsParameters$1,
|
|
47637
|
+
participantType,
|
|
47638
|
+
ratingsValues,
|
|
47639
|
+
rankingRange,
|
|
47640
|
+
category,
|
|
47641
|
+
});
|
|
47642
|
+
assignResult(result);
|
|
47643
|
+
}
|
|
47644
|
+
if (Array.isArray(categories)) {
|
|
47645
|
+
categories.forEach((category) => {
|
|
47646
|
+
const result = genRatings({
|
|
47647
|
+
scaledParticipantsCount,
|
|
47648
|
+
ratingsParameters: ratingsParameters$1,
|
|
47649
|
+
participantType,
|
|
47650
|
+
ratingsValues,
|
|
47651
|
+
rankingRange,
|
|
47652
|
+
category,
|
|
47640
47653
|
});
|
|
47641
|
-
|
|
47642
|
-
|
|
47643
|
-
doublesRatings = generateRatings();
|
|
47644
|
-
}
|
|
47645
|
-
}
|
|
47654
|
+
assignResult(result);
|
|
47655
|
+
});
|
|
47646
47656
|
}
|
|
47647
47657
|
const countryCodes = countries.filter((country) => nationalityCodeType === 'IOC' ? country.ioc || country.iso : country.iso);
|
|
47648
47658
|
function getMin(count) {
|
|
@@ -47767,9 +47777,10 @@ function generateParticipants(params) {
|
|
|
47767
47777
|
if (country?.label)
|
|
47768
47778
|
participant.person.countryName = country.label;
|
|
47769
47779
|
}
|
|
47770
|
-
|
|
47771
|
-
const
|
|
47772
|
-
const
|
|
47780
|
+
const processCategory = (category) => {
|
|
47781
|
+
const scaleName = category.categoryName || category.ratingType || category.ageCategoryCode;
|
|
47782
|
+
const singlesRanking = singlesRankings[scaleName]?.[participantIndex];
|
|
47783
|
+
const doublesRanking = doublesRankings[scaleName]?.[participantIndex];
|
|
47773
47784
|
addScaleItem({
|
|
47774
47785
|
scaleValue: singlesRanking,
|
|
47775
47786
|
eventType: SINGLES_EVENT,
|
|
@@ -47784,8 +47795,8 @@ function generateParticipants(params) {
|
|
|
47784
47795
|
participant,
|
|
47785
47796
|
category,
|
|
47786
47797
|
});
|
|
47787
|
-
const singlesRating = singlesRatings[participantIndex];
|
|
47788
|
-
const doublesRating = doublesRatings[participantIndex];
|
|
47798
|
+
const singlesRating = singlesRatings[scaleName]?.[participantIndex];
|
|
47799
|
+
const doublesRating = doublesRatings[scaleName]?.[participantIndex];
|
|
47789
47800
|
addScaleItem({
|
|
47790
47801
|
scaleValue: singlesRating,
|
|
47791
47802
|
eventType: SINGLES_EVENT,
|
|
@@ -47800,6 +47811,12 @@ function generateParticipants(params) {
|
|
|
47800
47811
|
participant,
|
|
47801
47812
|
category,
|
|
47802
47813
|
});
|
|
47814
|
+
};
|
|
47815
|
+
if (Array.isArray(categories)) {
|
|
47816
|
+
categories.forEach((category) => processCategory(category));
|
|
47817
|
+
}
|
|
47818
|
+
else if (category) {
|
|
47819
|
+
processCategory(category);
|
|
47803
47820
|
}
|
|
47804
47821
|
return participant;
|
|
47805
47822
|
}
|
|
@@ -47814,6 +47831,66 @@ function addScaleItem({ scaleValue: itemValue, participant, eventType, scaleType
|
|
|
47814
47831
|
participant.timeItems.push(timeItem);
|
|
47815
47832
|
}
|
|
47816
47833
|
}
|
|
47834
|
+
function genRatings(params) {
|
|
47835
|
+
const { category, scaledParticipantsCount, ratingsParameters, participantType, ratingsValues = [] } = params;
|
|
47836
|
+
const rankingRange = category.rankingRange || params.rankingRange || [1, 1000];
|
|
47837
|
+
const doublesRankings = {}, singlesRankings = {}, singlesRatings = {}, doublesRatings = {};
|
|
47838
|
+
const { categoryName, ageCategoryCode, ratingType } = category;
|
|
47839
|
+
const scaleName = category.categoryName || category.ratingType || category.ageCategoryCode;
|
|
47840
|
+
if ((categoryName || ageCategoryCode) && !ratingType) {
|
|
47841
|
+
const [start, end] = rankingRange || [];
|
|
47842
|
+
singlesRankings[scaleName] = shuffleArray(generateRange(start, end)).slice(0, scaledParticipantsCount || randomInt(20, 30));
|
|
47843
|
+
if ([PAIR, TEAM].includes(participantType)) {
|
|
47844
|
+
const [start, end] = rankingRange || [];
|
|
47845
|
+
doublesRankings[scaleName] = shuffleArray(generateRange(start, end)).slice(0, scaledParticipantsCount || randomInt(20, 30));
|
|
47846
|
+
}
|
|
47847
|
+
}
|
|
47848
|
+
if (ratingType && ratingsParameters[ratingType]) {
|
|
47849
|
+
const { ratingMax, ratingMin, ratingAttributes } = category;
|
|
47850
|
+
const ratingParameters = {
|
|
47851
|
+
...ratingsParameters[ratingType],
|
|
47852
|
+
...(ratingAttributes || {}),
|
|
47853
|
+
};
|
|
47854
|
+
const { attributes = {}, decimalsCount, accessors, range, step } = ratingParameters;
|
|
47855
|
+
const getAttributes = (attributes) => {
|
|
47856
|
+
const generatedAttributes = {};
|
|
47857
|
+
const attributeKeys = Object.keys(attributes || {});
|
|
47858
|
+
for (const attribute of attributeKeys) {
|
|
47859
|
+
const attributeValue = attributes[attribute];
|
|
47860
|
+
if (typeof attributeValue === 'object' && attributeValue.generator) {
|
|
47861
|
+
const { range } = attributeValue;
|
|
47862
|
+
const [min, max] = range.slice().sort();
|
|
47863
|
+
generatedAttributes[attribute] = randomInt(min, max);
|
|
47864
|
+
}
|
|
47865
|
+
else {
|
|
47866
|
+
generatedAttributes[attribute] = attributeValue;
|
|
47867
|
+
}
|
|
47868
|
+
}
|
|
47869
|
+
return generatedAttributes;
|
|
47870
|
+
};
|
|
47871
|
+
const inverted = range[0] > range[1];
|
|
47872
|
+
const skew = inverted ? 2 : 0.7;
|
|
47873
|
+
const [min, max] = range.slice().sort();
|
|
47874
|
+
const generateRatings = () => {
|
|
47875
|
+
const ratingsBucket = generateRange(0, 2000)
|
|
47876
|
+
.map(() => skewedDistribution(min, max, skew, step, decimalsCount));
|
|
47877
|
+
return ratingsBucket
|
|
47878
|
+
.filter((rating) => (!ratingMax || rating <= ratingMax) && (!ratingMin || rating >= ratingMin))
|
|
47879
|
+
.slice(0, scaledParticipantsCount || randomInt(20, 30))
|
|
47880
|
+
.map((scaleValue) => {
|
|
47881
|
+
return !accessors
|
|
47882
|
+
? scaleValue
|
|
47883
|
+
: Object.assign({}, ...accessors.map((accessor) => ({ [accessor]: scaleValue })), getAttributes(attributes));
|
|
47884
|
+
});
|
|
47885
|
+
};
|
|
47886
|
+
const generatedRatings = generateRatings();
|
|
47887
|
+
singlesRatings[scaleName] = [...ratingsValues, ...generatedRatings];
|
|
47888
|
+
if ([PAIR, TEAM].includes(participantType)) {
|
|
47889
|
+
doublesRatings[scaleName] = [...ratingsValues, ...generatedRatings];
|
|
47890
|
+
}
|
|
47891
|
+
}
|
|
47892
|
+
return { singlesRankings, doublesRankings, singlesRatings, doublesRatings };
|
|
47893
|
+
}
|
|
47817
47894
|
|
|
47818
47895
|
function processTieFormat(params) {
|
|
47819
47896
|
const { alternatesCount = 0, tieFormatName, drawSize } = params;
|
|
@@ -51053,6 +51130,25 @@ function scaledTeamAssignment({ clearExistingAssignments = true, individualParti
|
|
|
51053
51130
|
return { ...SUCCESS, scaledParticipants };
|
|
51054
51131
|
}
|
|
51055
51132
|
|
|
51133
|
+
function removeRatings(params) {
|
|
51134
|
+
const paramsCheck = checkRequiredParameters(params, [
|
|
51135
|
+
{ [TOURNAMENT_RECORD]: true, [EVENT_TYPE]: true },
|
|
51136
|
+
{ ratingType: false, [VALIDATE]: (value) => ratingsParameters[value] },
|
|
51137
|
+
]);
|
|
51138
|
+
if (paramsCheck.error)
|
|
51139
|
+
return paramsCheck;
|
|
51140
|
+
const dynamicScaleName = `${params.ratingType}.${DYNAMIC}`;
|
|
51141
|
+
const ratingType = params.asDynamic ? dynamicScaleName : params.ratingType;
|
|
51142
|
+
const itemType = [SCALE$1, RATING$1, params.eventType, ratingType].join('.');
|
|
51143
|
+
const participants = params.tournamentRecord.participants ?? [];
|
|
51144
|
+
for (const participant of participants) {
|
|
51145
|
+
if (participant.timeItems) {
|
|
51146
|
+
participant.timeItems = participant.timeItems.filter((timeItem) => timeItem.itemType !== itemType);
|
|
51147
|
+
}
|
|
51148
|
+
}
|
|
51149
|
+
return { ...SUCCESS };
|
|
51150
|
+
}
|
|
51151
|
+
|
|
51056
51152
|
function removePenalty(params) {
|
|
51057
51153
|
const { tournamentRecords } = params;
|
|
51058
51154
|
if (typeof tournamentRecords !== 'object' || !Object.keys(tournamentRecords).length)
|
|
@@ -51419,6 +51515,7 @@ var mutate$5 = {
|
|
|
51419
51515
|
removeParticipantIdsFromAllTeams: removeParticipantIdsFromAllTeams,
|
|
51420
51516
|
removePenalty: removePenalty,
|
|
51421
51517
|
removePersonRequests: removePersonRequests,
|
|
51518
|
+
removeRatings: removeRatings,
|
|
51422
51519
|
scaledTeamAssignment: scaledTeamAssignment,
|
|
51423
51520
|
setParticipantScaleItem: setParticipantScaleItem,
|
|
51424
51521
|
setParticipantScaleItems: setParticipantScaleItems
|
|
@@ -51464,6 +51561,7 @@ var index$8 = {
|
|
|
51464
51561
|
removeParticipantIdsFromAllTeams: removeParticipantIdsFromAllTeams,
|
|
51465
51562
|
removePenalty: removePenalty,
|
|
51466
51563
|
removePersonRequests: removePersonRequests,
|
|
51564
|
+
removeRatings: removeRatings,
|
|
51467
51565
|
scaledTeamAssignment: scaledTeamAssignment,
|
|
51468
51566
|
setParticipantScaleItem: setParticipantScaleItem,
|
|
51469
51567
|
setParticipantScaleItems: setParticipantScaleItems,
|
|
@@ -55313,23 +55411,80 @@ function setTournamentStatus({ tournamentRecord, status }) {
|
|
|
55313
55411
|
return { ...SUCCESS };
|
|
55314
55412
|
}
|
|
55315
55413
|
|
|
55316
|
-
function
|
|
55317
|
-
|
|
55318
|
-
|
|
55319
|
-
|
|
55320
|
-
|
|
55321
|
-
if (
|
|
55322
|
-
|
|
55323
|
-
result: { error:
|
|
55324
|
-
|
|
55414
|
+
function removeOnlineResource(params) {
|
|
55415
|
+
const paramsCheck = checkRequiredParameters(params, [{ tournamentRecord: true, onlineResource: true }]);
|
|
55416
|
+
if (paramsCheck.error)
|
|
55417
|
+
return paramsCheck;
|
|
55418
|
+
const { tournamentRecord, onlineResource, organisationId, participantId, personId, courtId, venueId } = params;
|
|
55419
|
+
if (organisationId) {
|
|
55420
|
+
if (tournamentRecord.parentOrganisation?.parentOrganisationId !== organisationId) {
|
|
55421
|
+
return decorateResult({ result: { error: NOT_FOUND } });
|
|
55422
|
+
}
|
|
55423
|
+
removeResource({ element: tournamentRecord.parentOrganisation, onlineResource });
|
|
55424
|
+
}
|
|
55425
|
+
else if (participantId || personId) {
|
|
55426
|
+
const participant = (tournamentRecord.participants ?? []).find((p) => (personId && p.person?.personId === personId) || p.participantId === participantId);
|
|
55427
|
+
if (!participant) {
|
|
55428
|
+
if (personId) {
|
|
55429
|
+
return decorateResult({ result: { error: NOT_FOUND } });
|
|
55430
|
+
}
|
|
55431
|
+
else {
|
|
55432
|
+
return decorateResult({ result: { error: PARTICIPANT_NOT_FOUND } });
|
|
55433
|
+
}
|
|
55434
|
+
}
|
|
55435
|
+
if (personId) {
|
|
55436
|
+
if (participant.person?.personId !== personId) {
|
|
55437
|
+
return decorateResult({ result: { error: INVALID_PARTICIPANT } });
|
|
55438
|
+
}
|
|
55439
|
+
removeResource({ element: participant.person, onlineResource });
|
|
55440
|
+
}
|
|
55441
|
+
else {
|
|
55442
|
+
removeResource({ element: participant, onlineResource });
|
|
55443
|
+
}
|
|
55444
|
+
}
|
|
55445
|
+
else if (courtId) {
|
|
55446
|
+
const court = (tournamentRecord.venues ?? [])
|
|
55447
|
+
.filter((v) => !venueId || v.venueId === venueId)
|
|
55448
|
+
.flatMap((v) => (v.courts ?? []).filter((c) => c.courtId === courtId))?.[0];
|
|
55449
|
+
if (!court)
|
|
55450
|
+
return decorateResult({ result: { error: COURT_NOT_FOUND } });
|
|
55451
|
+
removeResource({ element: court, onlineResource });
|
|
55452
|
+
}
|
|
55453
|
+
else if (venueId) {
|
|
55454
|
+
const venue = (tournamentRecord.venues ?? []).find((v) => v.venueId === venueId);
|
|
55455
|
+
if (!venue)
|
|
55456
|
+
return decorateResult({ result: { error: VENUE_NOT_FOUND } });
|
|
55457
|
+
removeResource({ element: venue, onlineResource });
|
|
55458
|
+
}
|
|
55459
|
+
else {
|
|
55460
|
+
removeResource({ element: tournamentRecord, onlineResource });
|
|
55461
|
+
addNotice({
|
|
55462
|
+
payload: {
|
|
55463
|
+
onlineResources: tournamentRecord.onlineResources,
|
|
55464
|
+
tournamentId: tournamentRecord.tournamentId,
|
|
55465
|
+
},
|
|
55466
|
+
topic: MODIFY_TOURNAMENT_DETAIL,
|
|
55325
55467
|
});
|
|
55468
|
+
}
|
|
55469
|
+
return { ...SUCCESS };
|
|
55470
|
+
}
|
|
55471
|
+
function removeResource({ element, onlineResource }) {
|
|
55472
|
+
const onlineResources = (element.onlineResources ?? []).filter((resource) => !(resource?.[RESOURCE_SUB_TYPE] === onlineResource[RESOURCE_SUB_TYPE] &&
|
|
55473
|
+
resource?.[RESOURCE_TYPE] === onlineResource[RESOURCE_TYPE] &&
|
|
55474
|
+
resource?.[IDENTIFIER] === onlineResource[IDENTIFIER]));
|
|
55475
|
+
element.onlineResources = onlineResources;
|
|
55476
|
+
}
|
|
55477
|
+
|
|
55478
|
+
function addOnlineResource(params) {
|
|
55479
|
+
const paramsCheck = checkRequiredParameters(params, [{ tournamentRecord: true, onlineResource: true }]);
|
|
55480
|
+
if (paramsCheck.error)
|
|
55481
|
+
return paramsCheck;
|
|
55482
|
+
const { tournamentRecord, onlineResource, organisationId, participantId, personId, courtId, venueId } = params;
|
|
55326
55483
|
if (organisationId) {
|
|
55327
55484
|
if (tournamentRecord.parentOrganisation?.parentOrganisationId !== organisationId) {
|
|
55328
55485
|
return decorateResult({ result: { error: NOT_FOUND } });
|
|
55329
55486
|
}
|
|
55330
|
-
|
|
55331
|
-
tournamentRecord.parentOrganisation.onlineResources = [];
|
|
55332
|
-
tournamentRecord.parentOrganisation.onlineResources.push(onlineResource);
|
|
55487
|
+
mergeResource({ element: tournamentRecord.parentOrganisation, onlineResource });
|
|
55333
55488
|
}
|
|
55334
55489
|
else if (participantId || personId) {
|
|
55335
55490
|
const participant = (tournamentRecord.participants ?? []).find((p) => (personId && p.person?.personId === personId) || p.participantId === participantId);
|
|
@@ -55345,14 +55500,10 @@ function addOnlineResource({ tournamentRecord, onlineResource, organisationId, p
|
|
|
55345
55500
|
if (participant.person?.personId !== personId) {
|
|
55346
55501
|
return decorateResult({ result: { error: INVALID_PARTICIPANT } });
|
|
55347
55502
|
}
|
|
55348
|
-
|
|
55349
|
-
participant.person.onlineResources = [];
|
|
55350
|
-
participant.person.onlineResources.push(onlineResource);
|
|
55503
|
+
mergeResource({ element: participant.person, onlineResource });
|
|
55351
55504
|
}
|
|
55352
55505
|
else {
|
|
55353
|
-
|
|
55354
|
-
participant.onlineResources = [];
|
|
55355
|
-
participant.onlineResources.push(onlineResource);
|
|
55506
|
+
mergeResource({ element: participant, onlineResource });
|
|
55356
55507
|
}
|
|
55357
55508
|
}
|
|
55358
55509
|
else if (courtId) {
|
|
@@ -55361,25 +55512,34 @@ function addOnlineResource({ tournamentRecord, onlineResource, organisationId, p
|
|
|
55361
55512
|
.flatMap((v) => (v.courts ?? []).filter((c) => c.courtId === courtId))?.[0];
|
|
55362
55513
|
if (!court)
|
|
55363
55514
|
return decorateResult({ result: { error: COURT_NOT_FOUND } });
|
|
55364
|
-
|
|
55365
|
-
court.onlineResources = [];
|
|
55366
|
-
court.onlineResources.push(onlineResource);
|
|
55515
|
+
mergeResource({ element: court, onlineResource });
|
|
55367
55516
|
}
|
|
55368
55517
|
else if (venueId) {
|
|
55369
55518
|
const venue = (tournamentRecord.venues ?? []).find((v) => v.venueId === venueId);
|
|
55370
55519
|
if (!venue)
|
|
55371
55520
|
return decorateResult({ result: { error: VENUE_NOT_FOUND } });
|
|
55372
|
-
|
|
55373
|
-
venue.onlineResources = [];
|
|
55374
|
-
venue.onlineResources.push(onlineResource);
|
|
55521
|
+
mergeResource({ element: venue, onlineResource });
|
|
55375
55522
|
}
|
|
55376
55523
|
else {
|
|
55377
|
-
|
|
55378
|
-
|
|
55379
|
-
|
|
55524
|
+
mergeResource({ element: tournamentRecord, onlineResource });
|
|
55525
|
+
addNotice({
|
|
55526
|
+
payload: {
|
|
55527
|
+
onlineResources: tournamentRecord.onlineResources,
|
|
55528
|
+
tournamentId: tournamentRecord.tournamentId,
|
|
55529
|
+
},
|
|
55530
|
+
topic: MODIFY_TOURNAMENT_DETAIL,
|
|
55531
|
+
});
|
|
55380
55532
|
}
|
|
55381
55533
|
return { ...SUCCESS };
|
|
55382
55534
|
}
|
|
55535
|
+
function mergeResource({ element, onlineResource }) {
|
|
55536
|
+
const onlineResources = (element.onlineResources ?? []).filter((resource) => resource?.[RESOURCE_SUB_TYPE] !== onlineResource[RESOURCE_SUB_TYPE] &&
|
|
55537
|
+
resource?.[RESOURCE_TYPE] !== onlineResource[RESOURCE_TYPE] &&
|
|
55538
|
+
resource?.[IDENTIFIER] !== onlineResource[IDENTIFIER]);
|
|
55539
|
+
onlineResources.push(onlineResource);
|
|
55540
|
+
element.onlineResources = onlineResources;
|
|
55541
|
+
return { ...SUCCESS };
|
|
55542
|
+
}
|
|
55383
55543
|
|
|
55384
55544
|
function setTournamentName({ tournamentRecord, promotionalName, tournamentName, formalName }) {
|
|
55385
55545
|
if (!tournamentRecord)
|
|
@@ -55591,6 +55751,7 @@ var mutate$1 = {
|
|
|
55591
55751
|
removeEventExtension: removeEventExtension,
|
|
55592
55752
|
removeExtension: removeExtension,
|
|
55593
55753
|
removeNotes: removeNotes,
|
|
55754
|
+
removeOnlineResource: removeOnlineResource,
|
|
55594
55755
|
removeParticipantExtension: removeParticipantExtension,
|
|
55595
55756
|
removeTournamentExtension: removeTournamentExtension,
|
|
55596
55757
|
setTournamentCategories: setTournamentCategories,
|
|
@@ -55634,6 +55795,7 @@ var index$3 = {
|
|
|
55634
55795
|
removeEventExtension: removeEventExtension,
|
|
55635
55796
|
removeExtension: removeExtension,
|
|
55636
55797
|
removeNotes: removeNotes,
|
|
55798
|
+
removeOnlineResource: removeOnlineResource,
|
|
55637
55799
|
removeParticipantExtension: removeParticipantExtension,
|
|
55638
55800
|
removeTournamentExtension: removeTournamentExtension,
|
|
55639
55801
|
setTournamentCategories: setTournamentCategories,
|
|
@@ -57404,26 +57566,35 @@ const mocksEngine = (() => {
|
|
|
57404
57566
|
governors.forEach((governor) => {
|
|
57405
57567
|
Object.keys(governor).forEach((method) => {
|
|
57406
57568
|
engine[method] = (params) => {
|
|
57407
|
-
|
|
57569
|
+
if (getDevContext()) {
|
|
57408
57570
|
const invocationResult = engineInvoke(governor[method], params);
|
|
57409
57571
|
if (!invocationResult?.error && params?.setState && invocationResult?.tournamentRecord) {
|
|
57410
57572
|
setState$1(invocationResult.tournamentRecord);
|
|
57411
57573
|
}
|
|
57412
57574
|
return invocationResult;
|
|
57413
57575
|
}
|
|
57414
|
-
|
|
57415
|
-
|
|
57416
|
-
|
|
57417
|
-
error
|
|
57576
|
+
else {
|
|
57577
|
+
try {
|
|
57578
|
+
const invocationResult = engineInvoke(governor[method], params);
|
|
57579
|
+
if (!invocationResult?.error && params?.setState && invocationResult?.tournamentRecord) {
|
|
57580
|
+
setState$1(invocationResult.tournamentRecord);
|
|
57581
|
+
}
|
|
57582
|
+
return invocationResult;
|
|
57418
57583
|
}
|
|
57419
|
-
|
|
57420
|
-
error
|
|
57584
|
+
catch (err) {
|
|
57585
|
+
let error;
|
|
57586
|
+
if (typeof err === 'string') {
|
|
57587
|
+
error = err.toUpperCase();
|
|
57588
|
+
}
|
|
57589
|
+
else if (err instanceof Error) {
|
|
57590
|
+
error = err.message;
|
|
57591
|
+
}
|
|
57592
|
+
console.log('ERROR', {
|
|
57593
|
+
params: JSON.stringify(params),
|
|
57594
|
+
method,
|
|
57595
|
+
error,
|
|
57596
|
+
});
|
|
57421
57597
|
}
|
|
57422
|
-
console.log('ERROR', {
|
|
57423
|
-
params: JSON.stringify(params),
|
|
57424
|
-
method,
|
|
57425
|
-
error,
|
|
57426
|
-
});
|
|
57427
57598
|
}
|
|
57428
57599
|
};
|
|
57429
57600
|
});
|