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
|
@@ -362,7 +362,7 @@ var matchUpFormatCode = {
|
|
|
362
362
|
};
|
|
363
363
|
|
|
364
364
|
function factoryVersion() {
|
|
365
|
-
return '1.7.
|
|
365
|
+
return '1.7.14';
|
|
366
366
|
}
|
|
367
367
|
|
|
368
368
|
/******************************************************************************
|
|
@@ -2947,8 +2947,9 @@ function decorateResult(_a) {
|
|
|
2947
2947
|
if (result && Array.isArray(result === null || result === void 0 ? void 0 : result.stack) && typeof stack === 'string') {
|
|
2948
2948
|
result.stack.push(stack);
|
|
2949
2949
|
}
|
|
2950
|
-
if (
|
|
2951
|
-
result.
|
|
2950
|
+
if (result && info) {
|
|
2951
|
+
result.info = info;
|
|
2952
|
+
}
|
|
2952
2953
|
if (result && typeof context === 'object' && Object.keys(context).length) {
|
|
2953
2954
|
Object.assign(result, definedAttributes(context));
|
|
2954
2955
|
}
|
|
@@ -3525,7 +3526,7 @@ function validateTieFormat(params) {
|
|
|
3525
3526
|
var tieFormat = params === null || params === void 0 ? void 0 : params.tieFormat;
|
|
3526
3527
|
var stack = 'validateTieFormat';
|
|
3527
3528
|
var errors = [];
|
|
3528
|
-
if (typeof tieFormat !== 'object') {
|
|
3529
|
+
if (!params || !tieFormat || typeof tieFormat !== 'object') {
|
|
3529
3530
|
errors.push('tieFormat must be an object');
|
|
3530
3531
|
return decorateResult({
|
|
3531
3532
|
result: {
|
|
@@ -3644,7 +3645,7 @@ function validateCollectionDefinition(_a) {
|
|
|
3644
3645
|
errors.push("collectionValue is not type number: ".concat(collectionValue));
|
|
3645
3646
|
}
|
|
3646
3647
|
if (collectionValueProfiles) {
|
|
3647
|
-
var result =
|
|
3648
|
+
var result = validateCollectionValueProfiles({
|
|
3648
3649
|
collectionValueProfiles: collectionValueProfiles,
|
|
3649
3650
|
matchUpCount: matchUpCount,
|
|
3650
3651
|
});
|
|
@@ -3691,7 +3692,7 @@ function checkTieFormat(tieFormat) {
|
|
|
3691
3692
|
}
|
|
3692
3693
|
return { tieFormat: tieFormat };
|
|
3693
3694
|
}
|
|
3694
|
-
function
|
|
3695
|
+
function validateCollectionValueProfiles(_a) {
|
|
3695
3696
|
var e_2, _b;
|
|
3696
3697
|
var collectionValueProfiles = _a.collectionValueProfiles, matchUpCount = _a.matchUpCount;
|
|
3697
3698
|
var errors = [];
|
|
@@ -18178,6 +18179,10 @@ function proConflicts(_a) {
|
|
|
18178
18179
|
return { courtIssues: courtIssues, rowIssues: rowIssues };
|
|
18179
18180
|
}
|
|
18180
18181
|
|
|
18182
|
+
function stringSort(a, b) {
|
|
18183
|
+
return (a || '').localeCompare(b || '');
|
|
18184
|
+
}
|
|
18185
|
+
|
|
18181
18186
|
function getTieFormatDesc(tieFormat) {
|
|
18182
18187
|
var _a;
|
|
18183
18188
|
if (!tieFormat)
|
|
@@ -18266,18 +18271,57 @@ function compareTieFormats(_a) {
|
|
|
18266
18271
|
ancestorDifferences.collectionsValue.totalValue;
|
|
18267
18272
|
var matchUpCountDifference = descendantDifferences.collectionsValue.totalMatchUps -
|
|
18268
18273
|
ancestorDifferences.collectionsValue.totalMatchUps;
|
|
18274
|
+
var assignmentValuesCountDifference = ancestorDifferences.collectionsValue.assignmentValues.length !==
|
|
18275
|
+
descendantDifferences.collectionsValue.assignmentValues.length;
|
|
18276
|
+
var assignmentValuesDifference = ancestorDifferences.collectionsValue.assignmentValues.some(function (assignment, i) {
|
|
18277
|
+
var comparisonAssignment = descendantDifferences.collectionsValue.assignmentValues[i];
|
|
18278
|
+
if (!comparisonAssignment)
|
|
18279
|
+
return true;
|
|
18280
|
+
if (assignment.valueKey !== comparisonAssignment.valueKey)
|
|
18281
|
+
return true;
|
|
18282
|
+
if (assignment.value !== comparisonAssignment.value)
|
|
18283
|
+
return true;
|
|
18284
|
+
if (Array.isArray(assignment.value)) {
|
|
18285
|
+
return assignment.value.every(function (value, i) { return comparisonAssignment.value[i] === value; });
|
|
18286
|
+
}
|
|
18287
|
+
return false;
|
|
18288
|
+
});
|
|
18269
18289
|
var different = nameDifference ||
|
|
18270
18290
|
orderDifference ||
|
|
18271
18291
|
ancestorDesc !== descendantDesc ||
|
|
18292
|
+
assignmentValuesCountDifference ||
|
|
18293
|
+
assignmentValuesDifference ||
|
|
18272
18294
|
valueDifference !== 0;
|
|
18273
|
-
|
|
18295
|
+
var invalidValues = __spreadArray(__spreadArray([], __read(ancestorDifferences.collectionsValue.invalidValues), false), __read(descendantDifferences.collectionsValue.invalidValues), false);
|
|
18296
|
+
var invalid = invalidValues.length && invalidValues;
|
|
18297
|
+
return __assign(__assign({ matchUpFormatDifferences: matchUpFormatDifferences, matchUpCountDifference: matchUpCountDifference, descendantDifferences: descendantDifferences, ancestorDifferences: ancestorDifferences, orderDifference: orderDifference, valueDifference: valueDifference, nameDifference: nameDifference, descendantDesc: descendantDesc, ancestorDesc: ancestorDesc }, SUCCESS), { different: different, invalid: invalid });
|
|
18274
18298
|
}
|
|
18275
18299
|
function getCollectionsValue(definitions) {
|
|
18300
|
+
var invalidValues = [];
|
|
18301
|
+
var assignmentValues = [];
|
|
18276
18302
|
var totalMatchUps = 0;
|
|
18277
|
-
var collectionIds = Object.keys(definitions);
|
|
18303
|
+
var collectionIds = Object.keys(definitions).sort(stringSort);
|
|
18278
18304
|
var totalValue = collectionIds.reduce(function (total, collectionId) {
|
|
18279
18305
|
var collectionDefinition = definitions[collectionId];
|
|
18280
18306
|
var collectionValueProfiles = collectionDefinition.collectionValueProfiles, collectionValue = collectionDefinition.collectionValue, matchUpCount = collectionDefinition.matchUpCount, matchUpValue = collectionDefinition.matchUpValue, scoreValue = collectionDefinition.scoreValue, setValue = collectionDefinition.setValue;
|
|
18307
|
+
var valueAssignments = {
|
|
18308
|
+
collectionValueProfiles: collectionValueProfiles,
|
|
18309
|
+
collectionValue: collectionValue,
|
|
18310
|
+
matchUpValue: matchUpValue,
|
|
18311
|
+
scoreValue: scoreValue,
|
|
18312
|
+
setValue: setValue,
|
|
18313
|
+
};
|
|
18314
|
+
var valueKeys = Object.keys(valueAssignments).filter(function (key) { return ![undefined, null].includes(valueAssignments[key]); });
|
|
18315
|
+
if (valueKeys.length !== 1) {
|
|
18316
|
+
invalidValues.push({ collectionId: collectionId });
|
|
18317
|
+
}
|
|
18318
|
+
var valueKey = valueKeys[0];
|
|
18319
|
+
if (valueKey) {
|
|
18320
|
+
var value = valueKey === 'collectionValueProfiles'
|
|
18321
|
+
? Object.values(collectionValueProfiles)
|
|
18322
|
+
: valueAssignments[valueKey];
|
|
18323
|
+
assignmentValues.push({ valueKey: valueKey, value: value });
|
|
18324
|
+
}
|
|
18281
18325
|
totalMatchUps += matchUpCount;
|
|
18282
18326
|
if (collectionValueProfiles)
|
|
18283
18327
|
return (total +
|
|
@@ -18293,7 +18337,7 @@ function getCollectionsValue(definitions) {
|
|
|
18293
18337
|
}
|
|
18294
18338
|
return total;
|
|
18295
18339
|
}, 0);
|
|
18296
|
-
return { totalValue: totalValue, totalMatchUps: totalMatchUps };
|
|
18340
|
+
return { totalValue: totalValue, totalMatchUps: totalMatchUps, invalidValues: invalidValues, assignmentValues: assignmentValues };
|
|
18297
18341
|
}
|
|
18298
18342
|
|
|
18299
18343
|
function dehydrateMatchUps(_a) {
|
|
@@ -31969,9 +32013,10 @@ function getCompetitionPenalties(_a) {
|
|
|
31969
32013
|
}
|
|
31970
32014
|
|
|
31971
32015
|
function getTieFormat$1(_a) {
|
|
31972
|
-
var _b, _c;
|
|
32016
|
+
var _b, _c, _d;
|
|
31973
32017
|
var drawDefinition = _a.drawDefinition, structureId = _a.structureId, matchUpId = _a.matchUpId, structure = _a.structure, matchUp = _a.matchUp, eventId = _a.eventId, // optional - if an eventId is present only return tieFormat for event
|
|
31974
32018
|
event = _a.event;
|
|
32019
|
+
var stack = 'getTieFormat';
|
|
31975
32020
|
var tieFormat;
|
|
31976
32021
|
structureId = (_b = structure === null || structure === void 0 ? void 0 : structure.structureId) !== null && _b !== void 0 ? _b : structureId;
|
|
31977
32022
|
matchUpId = (_c = matchUp === null || matchUp === void 0 ? void 0 : matchUp.matchUpId) !== null && _c !== void 0 ? _c : matchUpId;
|
|
@@ -31989,6 +32034,9 @@ function getTieFormat$1(_a) {
|
|
|
31989
32034
|
});
|
|
31990
32035
|
if (result.error)
|
|
31991
32036
|
return result;
|
|
32037
|
+
if (((_d = result.matchUp) === null || _d === void 0 ? void 0 : _d.matchUpType) !== TEAM_MATCHUP) {
|
|
32038
|
+
return decorateResult({ result: { error: INVALID_MATCHUP }, stack: stack });
|
|
32039
|
+
}
|
|
31992
32040
|
if (!structure)
|
|
31993
32041
|
structure = result.structure;
|
|
31994
32042
|
if (!matchUp)
|
|
@@ -32031,8 +32079,8 @@ function getTieFormat$1(_a) {
|
|
|
32031
32079
|
tieFormat = getObjectTieFormat(drawDefinition) || getObjectTieFormat(event);
|
|
32032
32080
|
}
|
|
32033
32081
|
if (!tieFormat)
|
|
32034
|
-
return decorateResult({ result: { error: MISSING_TIE_FORMAT } });
|
|
32035
|
-
return __assign(__assign({}, SUCCESS), { tieFormat: tieFormat, matchUp: matchUp
|
|
32082
|
+
return decorateResult({ result: { error: MISSING_TIE_FORMAT }, stack: stack });
|
|
32083
|
+
return __assign(__assign({}, SUCCESS), { structure: structure, tieFormat: tieFormat, matchUp: matchUp });
|
|
32036
32084
|
}
|
|
32037
32085
|
|
|
32038
32086
|
function tieFormatTelemetry(_a) {
|
|
@@ -32050,6 +32098,38 @@ function tieFormatTelemetry(_a) {
|
|
|
32050
32098
|
addExtension$1({ element: drawDefinition, extension: updatedExtension });
|
|
32051
32099
|
}
|
|
32052
32100
|
|
|
32101
|
+
function generateTieMatchUps(_a) {
|
|
32102
|
+
var tieFormat = _a.tieFormat, isMock = _a.isMock, uuids = _a.uuids;
|
|
32103
|
+
var collectionDefinitions = (tieFormat !== null && tieFormat !== void 0 ? tieFormat : {}).collectionDefinitions;
|
|
32104
|
+
var tieMatchUps = (collectionDefinitions !== null && collectionDefinitions !== void 0 ? collectionDefinitions : [])
|
|
32105
|
+
.map(function (collectionDefinition) {
|
|
32106
|
+
return generateCollectionMatchUps({ collectionDefinition: collectionDefinition, uuids: uuids, isMock: isMock });
|
|
32107
|
+
})
|
|
32108
|
+
.filter(Boolean)
|
|
32109
|
+
.flat();
|
|
32110
|
+
return { tieMatchUps: tieMatchUps };
|
|
32111
|
+
}
|
|
32112
|
+
function generateCollectionMatchUps(_a) {
|
|
32113
|
+
var _b;
|
|
32114
|
+
var _c = _a.collectionPositionOffset, collectionPositionOffset = _c === void 0 ? 0 : _c, collectionDefinition = _a.collectionDefinition, matchUpsLimit = _a.matchUpsLimit, // internal use allows generation of missing matchUps on "reset"
|
|
32115
|
+
isMock = _a.isMock, uuids = _a.uuids;
|
|
32116
|
+
var _d = collectionDefinition || {}, matchUpCount = _d.matchUpCount, matchUpType = _d.matchUpType, collectionId = _d.collectionId, processCodes = _d.processCodes;
|
|
32117
|
+
var numberToGenerate = (_b = matchUpsLimit !== null && matchUpsLimit !== void 0 ? matchUpsLimit : matchUpCount) !== null && _b !== void 0 ? _b : 0;
|
|
32118
|
+
return generateRange(0, numberToGenerate).map(function (index) {
|
|
32119
|
+
var collectionPosition = collectionPositionOffset + index + 1;
|
|
32120
|
+
return {
|
|
32121
|
+
sides: [{ sideNumber: 1 }, { sideNumber: 2 }],
|
|
32122
|
+
matchUpId: (uuids === null || uuids === void 0 ? void 0 : uuids.pop()) || UUID(),
|
|
32123
|
+
matchUpStatus: MatchUpStatusEnum.ToBePlayed,
|
|
32124
|
+
collectionPosition: collectionPosition,
|
|
32125
|
+
collectionId: collectionId,
|
|
32126
|
+
processCodes: processCodes,
|
|
32127
|
+
matchUpType: matchUpType,
|
|
32128
|
+
isMock: isMock,
|
|
32129
|
+
};
|
|
32130
|
+
});
|
|
32131
|
+
}
|
|
32132
|
+
|
|
32053
32133
|
function validUpdate(_a) {
|
|
32054
32134
|
var matchUp = _a.matchUp, updateInProgressMatchUps = _a.updateInProgressMatchUps;
|
|
32055
32135
|
return (!matchUp.winningSide &&
|
|
@@ -32059,17 +32139,29 @@ function validUpdate(_a) {
|
|
|
32059
32139
|
}
|
|
32060
32140
|
|
|
32061
32141
|
// used to determine that all collections have the same collectionIds
|
|
32062
|
-
function
|
|
32063
|
-
var
|
|
32064
|
-
|
|
32065
|
-
|
|
32142
|
+
function checkStructureMatchUpCounts(_a) {
|
|
32143
|
+
var from = _a.from, to = _a.to;
|
|
32144
|
+
var referenceKeys = Object.keys(from);
|
|
32145
|
+
var sameKeys = intersection(referenceKeys, Object.keys(to)).length ===
|
|
32146
|
+
referenceKeys.length;
|
|
32147
|
+
var differentMatchUpsCount = referenceKeys.filter(function (collectionId) { return from[collectionId] !== to[collectionId]; });
|
|
32148
|
+
var matchUpsCountChanges = differentMatchUpsCount.map(function (collectionId) { return ({
|
|
32149
|
+
countChange: to[collectionId] - from[collectionId],
|
|
32150
|
+
collectionId: collectionId,
|
|
32151
|
+
}); });
|
|
32152
|
+
var sameMatchUpsCount = referenceKeys.every(function (key) { return from[key] === to[key]; });
|
|
32153
|
+
var equivalent = sameKeys && sameMatchUpsCount;
|
|
32154
|
+
return { equivalent: equivalent, matchUpsCountChanges: matchUpsCountChanges };
|
|
32066
32155
|
}
|
|
32067
32156
|
function updateTieFormat(_a) {
|
|
32068
32157
|
var e_1, _b;
|
|
32069
32158
|
var _c, _d, _e, _f, _g;
|
|
32070
|
-
var updateInProgressMatchUps = _a.updateInProgressMatchUps, tournamentRecord = _a.tournamentRecord, drawDefinition = _a.drawDefinition, structure = _a.structure, tieFormat = _a.tieFormat, eventId = _a.eventId, matchUp = _a.matchUp, event = _a.event;
|
|
32159
|
+
var updateInProgressMatchUps = _a.updateInProgressMatchUps, tournamentRecord = _a.tournamentRecord, drawDefinition = _a.drawDefinition, structure = _a.structure, tieFormat = _a.tieFormat, eventId = _a.eventId, matchUp = _a.matchUp, event = _a.event, uuids = _a.uuids;
|
|
32071
32160
|
var stack = 'updateTieFormat';
|
|
32161
|
+
var tournamentId = tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.tournamentId;
|
|
32072
32162
|
var modifiedStructuresCount = 0;
|
|
32163
|
+
var modifiedMatchUpsCount = 0;
|
|
32164
|
+
var addedMatchUpsCount = 0;
|
|
32073
32165
|
var modifiedCount = 0;
|
|
32074
32166
|
var collectionMap = tieFormat === null || tieFormat === void 0 ? void 0 : tieFormat.collectionDefinitions.reduce(function (instanceMap, def) {
|
|
32075
32167
|
instanceMap[def.collectionId] =
|
|
@@ -32083,7 +32175,8 @@ function updateTieFormat(_a) {
|
|
|
32083
32175
|
(instanceMap[def.collectionId] || 0) + def.matchUpCount;
|
|
32084
32176
|
return instanceMap;
|
|
32085
32177
|
}, {});
|
|
32086
|
-
return
|
|
32178
|
+
return checkStructureMatchUpCounts({ from: cMap, to: collectionMap })
|
|
32179
|
+
.equivalent;
|
|
32087
32180
|
};
|
|
32088
32181
|
var drawDefaultTieFormat = (_c = getTieFormat$1({ drawDefinition: drawDefinition })) === null || _c === void 0 ? void 0 : _c.tieFormat;
|
|
32089
32182
|
var eventDefaultTieFormat = (_d = getTieFormat$1({ event: event })) === null || _d === void 0 ? void 0 : _d.tieFormat;
|
|
@@ -32101,7 +32194,7 @@ function updateTieFormat(_a) {
|
|
|
32101
32194
|
}
|
|
32102
32195
|
finally { if (e_1) throw e_1.error; }
|
|
32103
32196
|
}
|
|
32104
|
-
event.tieFormat = tieFormat;
|
|
32197
|
+
event.tieFormat = copyTieFormat(tieFormat);
|
|
32105
32198
|
modifiedCount += 1;
|
|
32106
32199
|
}
|
|
32107
32200
|
else if (matchUp) {
|
|
@@ -32113,9 +32206,17 @@ function updateTieFormat(_a) {
|
|
|
32113
32206
|
var collectionId = _a.collectionId;
|
|
32114
32207
|
return collectionId;
|
|
32115
32208
|
}));
|
|
32116
|
-
|
|
32209
|
+
var check = checkStructureMatchUpCounts({
|
|
32210
|
+
to: collectionMap,
|
|
32211
|
+
from: matchUpMap,
|
|
32212
|
+
});
|
|
32213
|
+
var _k = getMatchUpChangesArePossible({
|
|
32214
|
+
matchUp: matchUp,
|
|
32215
|
+
check: check,
|
|
32216
|
+
}), changes = _k.changes, changesArePossible = _k.changesArePossible, cannotChangeReaon = _k.cannotChangeReaon;
|
|
32217
|
+
if (check.equivalent) {
|
|
32117
32218
|
if (validUpdate({ matchUp: matchUp, updateInProgressMatchUps: updateInProgressMatchUps })) {
|
|
32118
|
-
matchUp.tieFormat = tieFormat;
|
|
32219
|
+
matchUp.tieFormat = copyTieFormat(tieFormat);
|
|
32119
32220
|
modifiedCount += 1;
|
|
32120
32221
|
}
|
|
32121
32222
|
else {
|
|
@@ -32125,19 +32226,23 @@ function updateTieFormat(_a) {
|
|
|
32125
32226
|
});
|
|
32126
32227
|
}
|
|
32127
32228
|
}
|
|
32229
|
+
else if (changesArePossible) {
|
|
32230
|
+
makeChanges({ tieFormat: tieFormat, matchUp: matchUp, changes: changes, uuids: uuids });
|
|
32231
|
+
}
|
|
32128
32232
|
else {
|
|
32129
32233
|
return decorateResult({
|
|
32130
32234
|
context: { collectionMap: collectionMap, matchUpMap: matchUpMap },
|
|
32131
32235
|
result: { error: INVALID_TIE_FORMAT },
|
|
32132
|
-
info: '
|
|
32236
|
+
info: cannotChangeReaon || 'specified changes not possible',
|
|
32133
32237
|
stack: stack,
|
|
32134
32238
|
});
|
|
32135
32239
|
}
|
|
32240
|
+
modifiedMatchUpsCount += 1;
|
|
32136
32241
|
modifyMatchUpNotice({
|
|
32137
|
-
tournamentId: tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.tournamentId,
|
|
32138
32242
|
eventId: event === null || event === void 0 ? void 0 : event.eventId,
|
|
32139
32243
|
context: stack,
|
|
32140
32244
|
drawDefinition: drawDefinition,
|
|
32245
|
+
tournamentId: tournamentId,
|
|
32141
32246
|
matchUp: matchUp,
|
|
32142
32247
|
});
|
|
32143
32248
|
}
|
|
@@ -32145,30 +32250,43 @@ function updateTieFormat(_a) {
|
|
|
32145
32250
|
// all TEAM matchUps within the structure have tieMatchUps which were created following a tieFormat which occurs higher in the hierarchy
|
|
32146
32251
|
// attaching a tieFormat to the structure must ensure that affected TEAM matchUps within the structure all have appropriate tieMatchUps
|
|
32147
32252
|
// therefore those that fail to match the modified tieFormat MUST have an appropriate tieFormat attached from higher in the hierarchy
|
|
32148
|
-
var inheritedTieFormat = drawDefaultTieFormat
|
|
32253
|
+
var inheritedTieFormat = drawDefaultTieFormat !== null && drawDefaultTieFormat !== void 0 ? drawDefaultTieFormat : eventDefaultTieFormat;
|
|
32149
32254
|
var modified = (_g = processStructure({
|
|
32150
32255
|
inheritedTieFormat: inheritedTieFormat,
|
|
32151
32256
|
structure: structure,
|
|
32152
|
-
})) === null || _g === void 0 ? void 0 : _g.
|
|
32153
|
-
if (modified)
|
|
32154
|
-
|
|
32155
|
-
|
|
32156
|
-
|
|
32157
|
-
|
|
32158
|
-
|
|
32159
|
-
|
|
32160
|
-
|
|
32161
|
-
|
|
32257
|
+
})) === null || _g === void 0 ? void 0 : _g.modifiedMatchUpsCount;
|
|
32258
|
+
if (modified) {
|
|
32259
|
+
modifiedMatchUpsCount += modified;
|
|
32260
|
+
modifiedStructuresCount += 1;
|
|
32261
|
+
modifiedCount += 1;
|
|
32262
|
+
}
|
|
32263
|
+
var different = !structure.tieFormat ||
|
|
32264
|
+
compareTieFormats({
|
|
32265
|
+
ancestor: structure.tieFormat,
|
|
32266
|
+
descendant: tieFormat,
|
|
32267
|
+
}).different;
|
|
32268
|
+
if (different) {
|
|
32269
|
+
structure.tieFormat = copyTieFormat(tieFormat);
|
|
32270
|
+
modifiedStructuresCount += 1;
|
|
32271
|
+
modifiedCount += 1;
|
|
32272
|
+
}
|
|
32273
|
+
(modified || different) &&
|
|
32274
|
+
drawDefinition &&
|
|
32275
|
+
modifyDrawNotice({
|
|
32276
|
+
structureIds: [structure.structureId],
|
|
32277
|
+
eventId: event === null || event === void 0 ? void 0 : event.eventId,
|
|
32278
|
+
drawDefinition: drawDefinition,
|
|
32279
|
+
});
|
|
32162
32280
|
}
|
|
32163
32281
|
else if (drawDefinition) {
|
|
32164
32282
|
processDrawDefinition({ drawDefinition: drawDefinition });
|
|
32165
|
-
drawDefinition.tieFormat = tieFormat;
|
|
32283
|
+
drawDefinition.tieFormat = copyTieFormat(tieFormat);
|
|
32166
32284
|
modifiedCount += 1;
|
|
32167
32285
|
}
|
|
32168
32286
|
else {
|
|
32169
32287
|
return { error: MISSING_DRAW_DEFINITION };
|
|
32170
32288
|
}
|
|
32171
|
-
return __assign(__assign({
|
|
32289
|
+
return __assign(__assign({ modifiedStructuresCount: modifiedStructuresCount, modifiedMatchUpsCount: modifiedMatchUpsCount, addedMatchUpsCount: addedMatchUpsCount, modifiedCount: modifiedCount }, SUCCESS), { tieFormat: tieFormat });
|
|
32172
32290
|
function processDrawDefinition(_a) {
|
|
32173
32291
|
var e_2, _b;
|
|
32174
32292
|
var _c;
|
|
@@ -32185,9 +32303,10 @@ function updateTieFormat(_a) {
|
|
|
32185
32303
|
var modifiedCount_1 = (_c = processStructure({
|
|
32186
32304
|
inheritedTieFormat: inheritedTieFormat,
|
|
32187
32305
|
structure: structure_1,
|
|
32188
|
-
})) === null || _c === void 0 ? void 0 : _c.
|
|
32306
|
+
})) === null || _c === void 0 ? void 0 : _c.modifiedMatchUpsCount;
|
|
32189
32307
|
if (modifiedCount_1) {
|
|
32190
|
-
modifiedStructuresCount +=
|
|
32308
|
+
modifiedStructuresCount += 1;
|
|
32309
|
+
modifiedMatchUpsCount += modifiedCount_1;
|
|
32191
32310
|
var structureId = structure_1.structureId;
|
|
32192
32311
|
modifiedStructureIds.push(structureId);
|
|
32193
32312
|
}
|
|
@@ -32211,7 +32330,7 @@ function updateTieFormat(_a) {
|
|
|
32211
32330
|
var e_3, _b;
|
|
32212
32331
|
var _c, _d;
|
|
32213
32332
|
var inheritedTieFormat = _a.inheritedTieFormat, structure = _a.structure;
|
|
32214
|
-
var
|
|
32333
|
+
var modifiedMatchUpsCount = 0;
|
|
32215
32334
|
var structureMatchUps = ((_c = getAllStructureMatchUps({
|
|
32216
32335
|
matchUpFilters: { matchUpTypes: [TEAM$2] },
|
|
32217
32336
|
structure: structure,
|
|
@@ -32219,15 +32338,34 @@ function updateTieFormat(_a) {
|
|
|
32219
32338
|
try {
|
|
32220
32339
|
for (var structureMatchUps_1 = __values(structureMatchUps), structureMatchUps_1_1 = structureMatchUps_1.next(); !structureMatchUps_1_1.done; structureMatchUps_1_1 = structureMatchUps_1.next()) {
|
|
32221
32340
|
var matchUp_1 = structureMatchUps_1_1.value;
|
|
32341
|
+
var validToUpdate = validUpdate({ matchUp: matchUp_1, updateInProgressMatchUps: updateInProgressMatchUps });
|
|
32222
32342
|
var modified = false;
|
|
32223
32343
|
var tieMatchUpsMap = instanceCount((_d = matchUp_1.tieMatchUps) === null || _d === void 0 ? void 0 : _d.map(function (_a) {
|
|
32224
32344
|
var collectionId = _a.collectionId;
|
|
32225
32345
|
return collectionId;
|
|
32226
32346
|
}));
|
|
32227
|
-
|
|
32228
|
-
|
|
32229
|
-
|
|
32230
|
-
|
|
32347
|
+
var check = checkStructureMatchUpCounts({
|
|
32348
|
+
from: tieMatchUpsMap,
|
|
32349
|
+
to: collectionMap,
|
|
32350
|
+
});
|
|
32351
|
+
if (!check.equivalent) {
|
|
32352
|
+
var _e = getMatchUpChangesArePossible({
|
|
32353
|
+
matchUp: matchUp_1,
|
|
32354
|
+
check: check,
|
|
32355
|
+
}), changes = _e.changes, changesArePossible = _e.changesArePossible;
|
|
32356
|
+
if (changesArePossible && !matchUp_1.tieFormat) {
|
|
32357
|
+
makeChanges({ changes: changes, matchUp: matchUp_1, tieFormat: tieFormat, uuids: uuids });
|
|
32358
|
+
}
|
|
32359
|
+
else if (inheritedTieFormat) {
|
|
32360
|
+
var different = !matchUp_1.tieFormat ||
|
|
32361
|
+
compareTieFormats({
|
|
32362
|
+
ancestor: inheritedTieFormat,
|
|
32363
|
+
descendant: matchUp_1.tieFormat,
|
|
32364
|
+
}).different;
|
|
32365
|
+
if (different) {
|
|
32366
|
+
matchUp_1.tieFormat = inheritedTieFormat;
|
|
32367
|
+
modified = true;
|
|
32368
|
+
}
|
|
32231
32369
|
}
|
|
32232
32370
|
else {
|
|
32233
32371
|
return decorateResult({
|
|
@@ -32238,12 +32376,12 @@ function updateTieFormat(_a) {
|
|
|
32238
32376
|
}
|
|
32239
32377
|
else if (matchUp_1.tieFormat &&
|
|
32240
32378
|
matchingCollections(matchUp_1) &&
|
|
32241
|
-
|
|
32379
|
+
validToUpdate) {
|
|
32242
32380
|
matchUp_1.tieFormat = copyTieFormat(tieFormat);
|
|
32243
32381
|
modified = true;
|
|
32244
32382
|
}
|
|
32245
32383
|
if (modified) {
|
|
32246
|
-
|
|
32384
|
+
modifiedMatchUpsCount += 1;
|
|
32247
32385
|
modifyMatchUpNotice({
|
|
32248
32386
|
tournamentId: tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.tournamentId,
|
|
32249
32387
|
drawDefinition: drawDefinition,
|
|
@@ -32261,29 +32399,117 @@ function updateTieFormat(_a) {
|
|
|
32261
32399
|
}
|
|
32262
32400
|
finally { if (e_3) throw e_3.error; }
|
|
32263
32401
|
}
|
|
32264
|
-
return {
|
|
32402
|
+
return { modifiedMatchUpsCount: modifiedMatchUpsCount };
|
|
32265
32403
|
}
|
|
32404
|
+
function makeChanges(_a) {
|
|
32405
|
+
var uuids = _a.uuids, matchUp = _a.matchUp, tieFormat = _a.tieFormat, changes = _a.changes;
|
|
32406
|
+
matchUp.tieFormat = copyTieFormat(tieFormat);
|
|
32407
|
+
var matchUpIdsRemoved = [];
|
|
32408
|
+
var matchUpsAdded = [];
|
|
32409
|
+
changes.forEach(function (change) {
|
|
32410
|
+
var _a;
|
|
32411
|
+
if (change.countChange > 0) {
|
|
32412
|
+
var collectionPositionOffset = Math.max.apply(Math, __spreadArray([0], __read(matchUp.tieMatchUps
|
|
32413
|
+
.filter(function (tieMatchUp) { return tieMatchUp.collectionId === change.collectionId; })
|
|
32414
|
+
.map(extractAttributes('collectionPosition'))), false));
|
|
32415
|
+
var collectionDefinition = tieFormat.collectionDefinitions.find(function (def) { return def.collectionId === change.collectionId; });
|
|
32416
|
+
var newMatchUps = generateCollectionMatchUps({
|
|
32417
|
+
matchUpsLimit: change.countChange,
|
|
32418
|
+
collectionPositionOffset: collectionPositionOffset,
|
|
32419
|
+
collectionDefinition: collectionDefinition,
|
|
32420
|
+
uuids: uuids,
|
|
32421
|
+
});
|
|
32422
|
+
matchUpsAdded.push.apply(matchUpsAdded, __spreadArray([], __read(makeDeepCopy(newMatchUps, false, true)), false));
|
|
32423
|
+
addedMatchUpsCount += matchUpsAdded.length;
|
|
32424
|
+
(_a = matchUp.tieMatchUps).push.apply(_a, __spreadArray([], __read(newMatchUps), false));
|
|
32425
|
+
}
|
|
32426
|
+
else {
|
|
32427
|
+
var tieMatchUpIdsToRemove_1 = change.toBePlayedTieMatchUpIds.slice(0, Math.abs(change.countChange));
|
|
32428
|
+
console.log('remove', tieMatchUpIdsToRemove_1.length);
|
|
32429
|
+
matchUpIdsRemoved.push.apply(matchUpIdsRemoved, __spreadArray([], __read(tieMatchUpIdsToRemove_1), false));
|
|
32430
|
+
matchUp.tieMatchUps = matchUp.tieMatchUps.filter(function (_a) {
|
|
32431
|
+
var matchUpId = _a.matchUpId;
|
|
32432
|
+
return !tieMatchUpIdsToRemove_1.includes(matchUpId);
|
|
32433
|
+
});
|
|
32434
|
+
}
|
|
32435
|
+
});
|
|
32436
|
+
matchUpsAdded.length &&
|
|
32437
|
+
addMatchUpsNotice({
|
|
32438
|
+
matchUps: matchUpsAdded,
|
|
32439
|
+
drawDefinition: drawDefinition,
|
|
32440
|
+
tournamentId: tournamentId,
|
|
32441
|
+
eventId: eventId,
|
|
32442
|
+
});
|
|
32443
|
+
matchUpIdsRemoved.length &&
|
|
32444
|
+
deleteMatchUpsNotice({
|
|
32445
|
+
matchUpIds: matchUpIdsRemoved,
|
|
32446
|
+
action: 'updateTieFormat',
|
|
32447
|
+
drawDefinition: drawDefinition,
|
|
32448
|
+
tournamentId: tournamentId,
|
|
32449
|
+
eventId: eventId,
|
|
32450
|
+
});
|
|
32451
|
+
return { matchUpIdsRemoved: matchUpIdsRemoved, matchUpsAdded: matchUpsAdded };
|
|
32452
|
+
}
|
|
32453
|
+
}
|
|
32454
|
+
function getMatchUpChangesArePossible(_a) {
|
|
32455
|
+
var check = _a.check, matchUp = _a.matchUp;
|
|
32456
|
+
var cannotChangeReaon = '';
|
|
32457
|
+
var changes = [];
|
|
32458
|
+
var changesArePossible = check.matchUpsCountChanges.every(function (_a) {
|
|
32459
|
+
var collectionId = _a.collectionId, countChange = _a.countChange;
|
|
32460
|
+
var toBePlayedTieMatchUpIds = matchUp.tieMatchUps
|
|
32461
|
+
.filter(function (tieMatchUp) {
|
|
32462
|
+
return tieMatchUp.collectionId === collectionId &&
|
|
32463
|
+
tieMatchUp.matchUpStatus === TO_BE_PLAYED;
|
|
32464
|
+
})
|
|
32465
|
+
.map(extractAttributes('matchUpId'));
|
|
32466
|
+
var possibleToChange = toBePlayedTieMatchUpIds.length + countChange >= 0 || countChange > 0;
|
|
32467
|
+
if (!possibleToChange && countChange < 0)
|
|
32468
|
+
cannotChangeReaon = 'Insufficient TO_BE_PLAYED matchUps';
|
|
32469
|
+
changes.push({
|
|
32470
|
+
toBePlayedTieMatchUpIds: toBePlayedTieMatchUpIds,
|
|
32471
|
+
collectionId: collectionId,
|
|
32472
|
+
countChange: countChange,
|
|
32473
|
+
});
|
|
32474
|
+
return possibleToChange;
|
|
32475
|
+
});
|
|
32476
|
+
return { changesArePossible: changesArePossible, changes: changes, cannotChangeReaon: cannotChangeReaon };
|
|
32266
32477
|
}
|
|
32267
32478
|
|
|
32268
|
-
// all child matchUps need to be checked for collectionAssignments / collectionPositions which need to be removed when collectionDefinition.collectionIds are removed
|
|
32269
32479
|
function modifyCollectionDefinition$1(_a) {
|
|
32270
|
-
var _b;
|
|
32271
|
-
var
|
|
32480
|
+
var _b, _c, _d;
|
|
32481
|
+
var _e = _a.updateInProgressMatchUps, updateInProgressMatchUps = _e === void 0 ? false : _e, tournamentRecord = _a.tournamentRecord, collectionOrder = _a.collectionOrder, collectionName = _a.collectionName, tieFormatName = _a.tieFormatName, drawDefinition = _a.drawDefinition, matchUpFormat = _a.matchUpFormat, matchUpCount = _a.matchUpCount, collectionId = _a.collectionId, matchUpType = _a.matchUpType, structureId = _a.structureId, matchUpId = _a.matchUpId, category = _a.category, eventId = _a.eventId, gender = _a.gender, event = _a.event,
|
|
32272
32482
|
// value assignment, only one is allowed to have a value
|
|
32273
32483
|
collectionValueProfiles = _a.collectionValueProfiles, collectionValue = _a.collectionValue, matchUpValue = _a.matchUpValue, scoreValue = _a.scoreValue, setValue = _a.setValue;
|
|
32484
|
+
var stack = 'modifyCollectionDefinition';
|
|
32274
32485
|
if (matchUpFormat && !isValid(matchUpFormat)) {
|
|
32275
|
-
return {
|
|
32486
|
+
return decorateResult({
|
|
32487
|
+
result: { error: INVALID_VALUES },
|
|
32488
|
+
context: { matchUpFormat: matchUpFormat },
|
|
32489
|
+
stack: stack,
|
|
32490
|
+
});
|
|
32276
32491
|
}
|
|
32277
32492
|
if (collectionName && typeof collectionName !== 'string') {
|
|
32278
|
-
return {
|
|
32493
|
+
return decorateResult({
|
|
32494
|
+
result: { error: INVALID_VALUES },
|
|
32495
|
+
context: { collectionName: collectionName },
|
|
32496
|
+
stack: stack,
|
|
32497
|
+
});
|
|
32279
32498
|
}
|
|
32280
32499
|
if (gender && !Object.values(genderConstants).includes(gender)) {
|
|
32281
|
-
return {
|
|
32500
|
+
return decorateResult({
|
|
32501
|
+
result: { error: INVALID_VALUES },
|
|
32502
|
+
context: { gender: gender },
|
|
32503
|
+
stack: stack,
|
|
32504
|
+
});
|
|
32282
32505
|
}
|
|
32283
32506
|
if (category && typeof category !== 'object') {
|
|
32284
|
-
return {
|
|
32507
|
+
return decorateResult({
|
|
32508
|
+
result: { error: INVALID_VALUES },
|
|
32509
|
+
context: { category: category },
|
|
32510
|
+
stack: stack,
|
|
32511
|
+
});
|
|
32285
32512
|
}
|
|
32286
|
-
var stack = 'modifyCollectionDefinition';
|
|
32287
32513
|
var valueAssignments = {
|
|
32288
32514
|
collectionValueProfiles: collectionValueProfiles,
|
|
32289
32515
|
collectionValue: collectionValue,
|
|
@@ -32294,15 +32520,14 @@ function modifyCollectionDefinition$1(_a) {
|
|
|
32294
32520
|
if (!Object.values(valueAssignments).filter(Boolean).length &&
|
|
32295
32521
|
!collectionOrder &&
|
|
32296
32522
|
!collectionName &&
|
|
32523
|
+
!matchUpFormat &&
|
|
32297
32524
|
!matchUpCount &&
|
|
32298
|
-
!
|
|
32525
|
+
!matchUpType)
|
|
32299
32526
|
return decorateResult({ result: { error: MISSING_VALUE }, stack: stack });
|
|
32300
32527
|
if (Object.values(valueAssignments).filter(Boolean).length > 1)
|
|
32301
32528
|
return decorateResult({
|
|
32302
|
-
|
|
32303
|
-
|
|
32304
|
-
error: INVALID_VALUES,
|
|
32305
|
-
},
|
|
32529
|
+
info: 'Only one value assignment allowed per collectionDefinition',
|
|
32530
|
+
result: { error: INVALID_VALUES },
|
|
32306
32531
|
stack: stack,
|
|
32307
32532
|
});
|
|
32308
32533
|
var result = getTieFormat$1({
|
|
@@ -32312,42 +32537,78 @@ function modifyCollectionDefinition$1(_a) {
|
|
|
32312
32537
|
eventId: eventId,
|
|
32313
32538
|
event: event,
|
|
32314
32539
|
});
|
|
32315
|
-
if (result.error)
|
|
32540
|
+
if (result.error) {
|
|
32316
32541
|
return decorateResult({ result: result, stack: stack });
|
|
32542
|
+
}
|
|
32317
32543
|
var matchUp = result.matchUp, structure = result.structure, existingTieFormat = result.tieFormat;
|
|
32318
32544
|
var tieFormat = copyTieFormat(existingTieFormat);
|
|
32319
|
-
var
|
|
32320
|
-
|
|
32321
|
-
|
|
32322
|
-
var
|
|
32323
|
-
if (
|
|
32324
|
-
|
|
32325
|
-
|
|
32326
|
-
|
|
32327
|
-
|
|
32328
|
-
|
|
32329
|
-
|
|
32330
|
-
|
|
32331
|
-
|
|
32545
|
+
var sourceCollectionDefinition = existingTieFormat === null || existingTieFormat === void 0 ? void 0 : existingTieFormat.collectionDefinitions.find(function (collectionDefinition) {
|
|
32546
|
+
return collectionDefinition.collectionId === collectionId;
|
|
32547
|
+
});
|
|
32548
|
+
var targetCollectionDefinition = tieFormat === null || tieFormat === void 0 ? void 0 : tieFormat.collectionDefinitions.find(function (collectionDefinition) { return collectionDefinition.collectionId === collectionId; });
|
|
32549
|
+
if (!sourceCollectionDefinition)
|
|
32550
|
+
return decorateResult({
|
|
32551
|
+
info: 'source collectionDefinition',
|
|
32552
|
+
result: { error: NOT_FOUND },
|
|
32553
|
+
context: { collectionId: collectionId },
|
|
32554
|
+
stack: stack,
|
|
32555
|
+
});
|
|
32556
|
+
var value = (_c = (_b = collectionValue !== null && collectionValue !== void 0 ? collectionValue : matchUpValue) !== null && _b !== void 0 ? _b : scoreValue) !== null && _c !== void 0 ? _c : setValue;
|
|
32557
|
+
if (collectionValueProfiles) {
|
|
32558
|
+
var result_1 = validateCollectionValueProfiles({
|
|
32559
|
+
matchUpCount: matchUpCount !== null && matchUpCount !== void 0 ? matchUpCount : sourceCollectionDefinition === null || sourceCollectionDefinition === void 0 ? void 0 : sourceCollectionDefinition.matchUpCount,
|
|
32560
|
+
collectionValueProfiles: collectionValueProfiles,
|
|
32561
|
+
});
|
|
32562
|
+
if (result_1.errors) {
|
|
32563
|
+
return decorateResult({
|
|
32564
|
+
result: { error: INVALID_VALUES },
|
|
32565
|
+
info: result_1.errors,
|
|
32566
|
+
stack: stack,
|
|
32332
32567
|
});
|
|
32333
|
-
if (result_1.errors) {
|
|
32334
|
-
return decorateResult({
|
|
32335
|
-
result: { error: INVALID_VALUES, info: result_1.errors },
|
|
32336
|
-
stack: stack,
|
|
32337
|
-
});
|
|
32338
|
-
}
|
|
32339
32568
|
}
|
|
32569
|
+
}
|
|
32570
|
+
else if (value && !isConvertableInteger(value)) {
|
|
32571
|
+
return decorateResult({
|
|
32572
|
+
result: { error: INVALID_VALUES },
|
|
32573
|
+
info: 'value is not an integer',
|
|
32574
|
+
context: { value: value },
|
|
32575
|
+
stack: stack,
|
|
32576
|
+
});
|
|
32577
|
+
}
|
|
32578
|
+
var equivalentValueProfiles = function (a, b) {
|
|
32579
|
+
return intersection(Object.keys(a), Object.keys(b)).length ===
|
|
32580
|
+
Object.keys(a).length &&
|
|
32581
|
+
intersection(Object.values(a), Object.values(b)).length ===
|
|
32582
|
+
Object.values(a).length;
|
|
32583
|
+
};
|
|
32584
|
+
var valueProfileModified = collectionValueProfiles &&
|
|
32585
|
+
(!sourceCollectionDefinition.collectionValueProfiles ||
|
|
32586
|
+
!equivalentValueProfiles(sourceCollectionDefinition.collectionValueProfiles, collectionValueProfiles));
|
|
32587
|
+
var valueModified = (isConvertableInteger(collectionValue) &&
|
|
32588
|
+
sourceCollectionDefinition.collectionValue !== collectionValue) ||
|
|
32589
|
+
(isConvertableInteger(matchUpValue) &&
|
|
32590
|
+
sourceCollectionDefinition.matchUpValue !== matchUpValue) ||
|
|
32591
|
+
(isConvertableInteger(scoreValue) &&
|
|
32592
|
+
sourceCollectionDefinition.scoreValue !== scoreValue) ||
|
|
32593
|
+
(isConvertableInteger(setValue) &&
|
|
32594
|
+
sourceCollectionDefinition.setValue !== setValue) ||
|
|
32595
|
+
valueProfileModified;
|
|
32596
|
+
var modifications = [];
|
|
32597
|
+
if (valueModified) {
|
|
32340
32598
|
// cleanup any previously existing value assignment
|
|
32341
|
-
|
|
32342
|
-
|
|
32343
|
-
|
|
32344
|
-
|
|
32599
|
+
targetCollectionDefinition.collectionValueProfiles = undefined;
|
|
32600
|
+
targetCollectionDefinition.collectionValue = undefined;
|
|
32601
|
+
targetCollectionDefinition.matchUpValue = undefined;
|
|
32602
|
+
targetCollectionDefinition.scoreValue = undefined;
|
|
32603
|
+
targetCollectionDefinition.setValue = undefined;
|
|
32345
32604
|
// add new value assignment
|
|
32346
|
-
Object.assign(
|
|
32605
|
+
Object.assign(targetCollectionDefinition, valueAssignments);
|
|
32606
|
+
modifications.push(__assign({ collectionId: collectionId }, definedAttributes(valueAssignments)));
|
|
32347
32607
|
}
|
|
32348
32608
|
// must remove all collectionGroups which contain the collection which has been modified
|
|
32349
|
-
if ((scoreValue || setValue) &&
|
|
32350
|
-
|
|
32609
|
+
if ((isConvertableInteger(scoreValue) || isConvertableInteger(setValue)) &&
|
|
32610
|
+
targetCollectionDefinition.collectionGroupNumber) {
|
|
32611
|
+
var targetCollectionGroupNumber_1 = targetCollectionDefinition.collectionGroupNumber;
|
|
32351
32612
|
tieFormat.collectionDefinitions = tieFormat.collectionDefinitions.map(function (collectionDefinition) {
|
|
32352
32613
|
var collectionGroupNumber = collectionDefinition.collectionGroupNumber, rest = __rest(collectionDefinition, ["collectionGroupNumber"]);
|
|
32353
32614
|
if (collectionGroupNumber === targetCollectionGroupNumber_1) {
|
|
@@ -32361,39 +32622,82 @@ function modifyCollectionDefinition$1(_a) {
|
|
|
32361
32622
|
var groupNumber = _a.groupNumber;
|
|
32362
32623
|
return groupNumber !== targetCollectionGroupNumber_1;
|
|
32363
32624
|
});
|
|
32625
|
+
modifications.push({
|
|
32626
|
+
collectionId: collectionId,
|
|
32627
|
+
change: 'collectionGroupNumber removed',
|
|
32628
|
+
});
|
|
32364
32629
|
}
|
|
32365
32630
|
// calculate new winCriteria for tieFormat
|
|
32366
32631
|
// if existing winCriteria is aggregateValue, retain
|
|
32367
|
-
var
|
|
32368
|
-
|
|
32369
|
-
|
|
32370
|
-
|
|
32371
|
-
|
|
32372
|
-
|
|
32373
|
-
(
|
|
32374
|
-
|
|
32375
|
-
|
|
32376
|
-
|
|
32377
|
-
|
|
32378
|
-
|
|
32379
|
-
|
|
32380
|
-
if (collectionName
|
|
32381
|
-
|
|
32382
|
-
|
|
32383
|
-
|
|
32384
|
-
|
|
32385
|
-
if (
|
|
32386
|
-
|
|
32387
|
-
|
|
32388
|
-
|
|
32389
|
-
|
|
32390
|
-
|
|
32391
|
-
|
|
32392
|
-
|
|
32393
|
-
|
|
32632
|
+
var _f = calculateWinCriteria(tieFormat), aggregateValue = _f.aggregateValue, valueGoal = _f.valueGoal;
|
|
32633
|
+
var winCriteria = definedAttributes({ aggregateValue: aggregateValue, valueGoal: valueGoal });
|
|
32634
|
+
if (winCriteria.aggregateValue !==
|
|
32635
|
+
(existingTieFormat === null || existingTieFormat === void 0 ? void 0 : existingTieFormat.winCriteria.aggregateValue) ||
|
|
32636
|
+
winCriteria.valueGoal !== (existingTieFormat === null || existingTieFormat === void 0 ? void 0 : existingTieFormat.winCriteria.valueGoal)) {
|
|
32637
|
+
tieFormat.winCriteria = winCriteria;
|
|
32638
|
+
modifications.push({ collectionId: collectionId, winCriteria: winCriteria });
|
|
32639
|
+
}
|
|
32640
|
+
if (isConvertableInteger(collectionOrder) &&
|
|
32641
|
+
sourceCollectionDefinition.collectionOrder !== collectionOrder) {
|
|
32642
|
+
targetCollectionDefinition.collectionOrder = collectionOrder;
|
|
32643
|
+
modifications.push({ collectionId: collectionId, collectionOrder: collectionOrder });
|
|
32644
|
+
}
|
|
32645
|
+
if (collectionName &&
|
|
32646
|
+
sourceCollectionDefinition.collectionName !== collectionName) {
|
|
32647
|
+
targetCollectionDefinition.collectionName = collectionName;
|
|
32648
|
+
modifications.push({ collectionId: collectionId, collectionName: collectionName });
|
|
32649
|
+
}
|
|
32650
|
+
if (matchUpFormat &&
|
|
32651
|
+
sourceCollectionDefinition.matchUpFormat !== matchUpFormat) {
|
|
32652
|
+
targetCollectionDefinition.matchUpFormat = matchUpFormat;
|
|
32653
|
+
modifications.push({ collectionId: collectionId, matchUpFormat: matchUpFormat });
|
|
32654
|
+
}
|
|
32655
|
+
if (isConvertableInteger(matchUpCount) &&
|
|
32656
|
+
sourceCollectionDefinition.matchUpCount !== matchUpCount) {
|
|
32657
|
+
targetCollectionDefinition.matchUpCount = matchUpCount;
|
|
32658
|
+
modifications.push({ collectionId: collectionId, matchUpCount: matchUpCount });
|
|
32659
|
+
}
|
|
32660
|
+
if (matchUpType && sourceCollectionDefinition.matchUpType !== matchUpType) {
|
|
32661
|
+
// TODO: updateTieFormat needs to support
|
|
32662
|
+
// targetCollectionDefinition.matchUpType = matchUpType;
|
|
32663
|
+
// modifications.push({ collectionId, matchUpType });
|
|
32664
|
+
return decorateResult({
|
|
32665
|
+
result: { error: NOT_IMPLEMENTED },
|
|
32666
|
+
context: { matchUpType: matchUpType },
|
|
32667
|
+
stack: stack,
|
|
32668
|
+
});
|
|
32669
|
+
}
|
|
32670
|
+
if (category && sourceCollectionDefinition.category !== category) {
|
|
32671
|
+
targetCollectionDefinition.category = category;
|
|
32672
|
+
modifications.push({ collectionId: collectionId, category: category });
|
|
32673
|
+
}
|
|
32674
|
+
if (gender && sourceCollectionDefinition.gender !== gender) {
|
|
32675
|
+
// TODO: remove all inappropriately gendered participants
|
|
32676
|
+
targetCollectionDefinition.gender = gender;
|
|
32677
|
+
modifications.push({ collectionId: collectionId, gender: gender });
|
|
32678
|
+
}
|
|
32679
|
+
var modifiedTieFormat = definedAttributes(tieFormat);
|
|
32680
|
+
result = validateTieFormat({ tieFormat: modifiedTieFormat });
|
|
32681
|
+
if (result.error) {
|
|
32394
32682
|
return decorateResult({ result: result, stack: stack });
|
|
32683
|
+
}
|
|
32684
|
+
if (!modifications.length) {
|
|
32685
|
+
return decorateResult({ result: __assign(__assign({}, SUCCESS), { modifications: modifications }) });
|
|
32686
|
+
}
|
|
32687
|
+
// Note: this logic needs to exist both here and in `modifyTieFormat`
|
|
32688
|
+
// it is duplicated because this method can be called independently
|
|
32689
|
+
var changedTieFormatName = (existingTieFormat === null || existingTieFormat === void 0 ? void 0 : existingTieFormat.tieFormatName) !== tieFormatName;
|
|
32690
|
+
// if tieFormat has changed, force renaming of the tieFormat
|
|
32691
|
+
if (changedTieFormatName) {
|
|
32692
|
+
modifiedTieFormat.tieFormatName = tieFormatName;
|
|
32693
|
+
modifications.push({ tieFormatName: tieFormatName });
|
|
32694
|
+
}
|
|
32695
|
+
else if (modifications.length) {
|
|
32696
|
+
delete modifiedTieFormat.tieFormatName;
|
|
32697
|
+
modifications.push('tieFormatName removed: modifications without new tieFormatName');
|
|
32698
|
+
}
|
|
32395
32699
|
result = updateTieFormat({
|
|
32396
|
-
tieFormat:
|
|
32700
|
+
tieFormat: modifiedTieFormat,
|
|
32397
32701
|
updateInProgressMatchUps: updateInProgressMatchUps,
|
|
32398
32702
|
tournamentRecord: tournamentRecord,
|
|
32399
32703
|
drawDefinition: drawDefinition,
|
|
@@ -32404,10 +32708,10 @@ function modifyCollectionDefinition$1(_a) {
|
|
|
32404
32708
|
});
|
|
32405
32709
|
if (!result.error) {
|
|
32406
32710
|
var appliedPolicies = getAppliedPolicies({ tournamentRecord: tournamentRecord }).appliedPolicies;
|
|
32407
|
-
if ((
|
|
32711
|
+
if ((_d = appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies.audit) === null || _d === void 0 ? void 0 : _d[TIE_FORMAT_MODIFICATIONS]) {
|
|
32408
32712
|
var auditData = definedAttributes({
|
|
32713
|
+
collectionDefinition: targetCollectionDefinition,
|
|
32409
32714
|
drawId: drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.drawId,
|
|
32410
|
-
collectionDefinition: collectionDefinition,
|
|
32411
32715
|
action: stack,
|
|
32412
32716
|
structureId: structureId,
|
|
32413
32717
|
matchUpId: matchUpId,
|
|
@@ -32416,7 +32720,7 @@ function modifyCollectionDefinition$1(_a) {
|
|
|
32416
32720
|
tieFormatTelemetry({ drawDefinition: drawDefinition, auditData: auditData });
|
|
32417
32721
|
}
|
|
32418
32722
|
}
|
|
32419
|
-
return decorateResult({ result: result, stack: stack });
|
|
32723
|
+
return decorateResult({ result: __assign(__assign({}, result), { modifications: modifications }), stack: stack });
|
|
32420
32724
|
}
|
|
32421
32725
|
|
|
32422
32726
|
function resolveTournamentRecord(params) {
|
|
@@ -32648,8 +32952,8 @@ function orderCollectionDefinitions(params) {
|
|
|
32648
32952
|
// all child matchUps need to be checked for collectionAssignments which need to be removed when collectionDefinition.collectionIds are removed
|
|
32649
32953
|
function removeCollectionDefinition$1(_a) {
|
|
32650
32954
|
var e_1, _b, e_2, _c, e_3, _d;
|
|
32651
|
-
var _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
32652
|
-
var
|
|
32955
|
+
var _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
32956
|
+
var _s = _a.updateInProgressMatchUps, updateInProgressMatchUps = _s === void 0 ? true : _s, tieFormatComparison = _a.tieFormatComparison, tournamentRecord = _a.tournamentRecord, drawDefinition = _a.drawDefinition, tieFormatName = _a.tieFormatName, collectionId = _a.collectionId, structureId = _a.structureId, matchUpId = _a.matchUpId, eventId = _a.eventId, matchUp = _a.matchUp, event = _a.event;
|
|
32653
32957
|
var stack = 'removeCollectionDefinition';
|
|
32654
32958
|
var result = !matchUp
|
|
32655
32959
|
? getTieFormat$1({
|
|
@@ -32687,7 +32991,7 @@ function removeCollectionDefinition$1(_a) {
|
|
|
32687
32991
|
}
|
|
32688
32992
|
// calculate new winCriteria for tieFormat
|
|
32689
32993
|
// if existing winCriteria is aggregateValue, retain
|
|
32690
|
-
var
|
|
32994
|
+
var _t = calculateWinCriteria(tieFormat), aggregateValue = _t.aggregateValue, valueGoal = _t.valueGoal;
|
|
32691
32995
|
tieFormat.winCriteria = definedAttributes({ aggregateValue: aggregateValue, valueGoal: valueGoal });
|
|
32692
32996
|
// if valueGoal has changed, force renaming of the tieFormat
|
|
32693
32997
|
var originalValueGoal = existingTieFormat === null || existingTieFormat === void 0 ? void 0 : existingTieFormat.winCriteria.valueGoal;
|
|
@@ -32708,24 +33012,24 @@ function removeCollectionDefinition$1(_a) {
|
|
|
32708
33012
|
}
|
|
32709
33013
|
else if (structureId && structure) {
|
|
32710
33014
|
matchUps =
|
|
32711
|
-
((_f = getAllStructureMatchUps({
|
|
33015
|
+
(_g = (_f = getAllStructureMatchUps({
|
|
32712
33016
|
matchUpFilters: { matchUpTypes: [TEAM$2] },
|
|
32713
33017
|
structure: structure,
|
|
32714
|
-
})) === null || _f === void 0 ? void 0 : _f.matchUps)
|
|
33018
|
+
})) === null || _f === void 0 ? void 0 : _f.matchUps) !== null && _g !== void 0 ? _g : [];
|
|
32715
33019
|
}
|
|
32716
33020
|
else if (drawDefinition) {
|
|
32717
33021
|
matchUps =
|
|
32718
|
-
((
|
|
33022
|
+
(_j = (_h = allDrawMatchUps$1({
|
|
32719
33023
|
matchUpFilters: { matchUpTypes: [TEAM$2] },
|
|
32720
33024
|
drawDefinition: drawDefinition,
|
|
32721
|
-
})) === null ||
|
|
33025
|
+
})) === null || _h === void 0 ? void 0 : _h.matchUps) !== null && _j !== void 0 ? _j : [];
|
|
32722
33026
|
}
|
|
32723
33027
|
else if (event) {
|
|
32724
33028
|
matchUps =
|
|
32725
|
-
((
|
|
33029
|
+
(_l = (_k = allEventMatchUps({
|
|
32726
33030
|
matchUpFilters: { matchUpTypes: [TEAM$2] },
|
|
32727
33031
|
drawDefinition: drawDefinition,
|
|
32728
|
-
})) === null ||
|
|
33032
|
+
})) === null || _k === void 0 ? void 0 : _k.matchUps) !== null && _l !== void 0 ? _l : [];
|
|
32729
33033
|
}
|
|
32730
33034
|
// all team matchUps in scope which are completed or which have a score should not be modified
|
|
32731
33035
|
// UNLESS all collectionMatchUps have no score
|
|
@@ -32751,10 +33055,10 @@ function removeCollectionDefinition$1(_a) {
|
|
|
32751
33055
|
return { error: NO_MODIFICATIONS_APPLIED };
|
|
32752
33056
|
}
|
|
32753
33057
|
if (matchUpId && matchUp && updateInProgressMatchUps) {
|
|
32754
|
-
var collectionMatchUps = (
|
|
33058
|
+
var collectionMatchUps = (_m = matchUp.tieMatchUps) === null || _m === void 0 ? void 0 : _m.filter(function (tieMatchUp) { return tieMatchUp.collectionId === collectionId; });
|
|
32755
33059
|
try {
|
|
32756
|
-
for (var
|
|
32757
|
-
var collectionMatchUp =
|
|
33060
|
+
for (var _u = __values(collectionMatchUps !== null && collectionMatchUps !== void 0 ? collectionMatchUps : []), _v = _u.next(); !_v.done; _v = _u.next()) {
|
|
33061
|
+
var collectionMatchUp = _v.value;
|
|
32758
33062
|
var result_1 = setMatchUpStatus$2({
|
|
32759
33063
|
matchUpId: collectionMatchUp.matchUpId,
|
|
32760
33064
|
tieMatchUpId: matchUp === null || matchUp === void 0 ? void 0 : matchUp.matchUpId,
|
|
@@ -32778,7 +33082,7 @@ function removeCollectionDefinition$1(_a) {
|
|
|
32778
33082
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
32779
33083
|
finally {
|
|
32780
33084
|
try {
|
|
32781
|
-
if (
|
|
33085
|
+
if (_v && !_v.done && (_b = _u.return)) _b.call(_u);
|
|
32782
33086
|
}
|
|
32783
33087
|
finally { if (e_1) throw e_1.error; }
|
|
32784
33088
|
}
|
|
@@ -32789,9 +33093,9 @@ function removeCollectionDefinition$1(_a) {
|
|
|
32789
33093
|
var matchUp_1 = targetMatchUps_1_1.value;
|
|
32790
33094
|
try {
|
|
32791
33095
|
// remove any collectionAssignments from LineUps that include collectionId
|
|
32792
|
-
for (var
|
|
32793
|
-
var side =
|
|
32794
|
-
side.lineUp = ((
|
|
33096
|
+
for (var _w = (e_3 = void 0, __values((_o = matchUp_1 === null || matchUp_1 === void 0 ? void 0 : matchUp_1.sides) !== null && _o !== void 0 ? _o : [])), _x = _w.next(); !_x.done; _x = _w.next()) {
|
|
33097
|
+
var side = _x.value;
|
|
33098
|
+
side.lineUp = ((_p = side.lineUp) !== null && _p !== void 0 ? _p : []).map(function (assignment) {
|
|
32795
33099
|
var _a;
|
|
32796
33100
|
return ({
|
|
32797
33101
|
participantId: assignment.participantId,
|
|
@@ -32805,12 +33109,12 @@ function removeCollectionDefinition$1(_a) {
|
|
|
32805
33109
|
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
32806
33110
|
finally {
|
|
32807
33111
|
try {
|
|
32808
|
-
if (
|
|
33112
|
+
if (_x && !_x.done && (_d = _w.return)) _d.call(_w);
|
|
32809
33113
|
}
|
|
32810
33114
|
finally { if (e_3) throw e_3.error; }
|
|
32811
33115
|
}
|
|
32812
33116
|
// delete any tieMatchUps that contain collectionId
|
|
32813
|
-
matchUp_1.tieMatchUps = ((
|
|
33117
|
+
matchUp_1.tieMatchUps = ((_q = matchUp_1.tieMatchUps) !== null && _q !== void 0 ? _q : []).filter(function (matchUp) {
|
|
32814
33118
|
var deleteTarget = matchUp.collectionId === collectionId;
|
|
32815
33119
|
if (deleteTarget)
|
|
32816
33120
|
deletedMatchUpIds.push(matchUp.matchUpId);
|
|
@@ -32879,7 +33183,7 @@ function removeCollectionDefinition$1(_a) {
|
|
|
32879
33183
|
}
|
|
32880
33184
|
modifyDrawNotice({ drawDefinition: drawDefinition, eventId: event === null || event === void 0 ? void 0 : event.eventId });
|
|
32881
33185
|
var appliedPolicies = getAppliedPolicies({ tournamentRecord: tournamentRecord }).appliedPolicies;
|
|
32882
|
-
if ((
|
|
33186
|
+
if ((_r = appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies.audit) === null || _r === void 0 ? void 0 : _r[TIE_FORMAT_MODIFICATIONS]) {
|
|
32883
33187
|
var auditData = definedAttributes({
|
|
32884
33188
|
drawId: drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.drawId,
|
|
32885
33189
|
action: stack,
|
|
@@ -32897,37 +33201,6 @@ function removeCollectionDefinition(params) {
|
|
|
32897
33201
|
return resolveTournamentRecord(__assign(__assign({}, params), { method: removeCollectionDefinition$1 }));
|
|
32898
33202
|
}
|
|
32899
33203
|
|
|
32900
|
-
function generateTieMatchUps(_a) {
|
|
32901
|
-
var tieFormat = _a.tieFormat, isMock = _a.isMock, uuids = _a.uuids;
|
|
32902
|
-
var collectionDefinitions = (tieFormat || {}).collectionDefinitions;
|
|
32903
|
-
var tieMatchUps = (collectionDefinitions || [])
|
|
32904
|
-
.map(function (collectionDefinition) {
|
|
32905
|
-
return generateCollectionMatchUps({ collectionDefinition: collectionDefinition, uuids: uuids, isMock: isMock });
|
|
32906
|
-
})
|
|
32907
|
-
.filter(Boolean)
|
|
32908
|
-
.flat();
|
|
32909
|
-
return { tieMatchUps: tieMatchUps };
|
|
32910
|
-
}
|
|
32911
|
-
function generateCollectionMatchUps(_a) {
|
|
32912
|
-
var collectionDefinition = _a.collectionDefinition, matchUpsLimit = _a.matchUpsLimit, // internal use allows generation of missing matchUps on "reset"
|
|
32913
|
-
isMock = _a.isMock, uuids = _a.uuids;
|
|
32914
|
-
var _b = collectionDefinition || {}, matchUpCount = _b.matchUpCount, matchUpType = _b.matchUpType, collectionId = _b.collectionId, processCodes = _b.processCodes;
|
|
32915
|
-
var numberToGenerate = matchUpsLimit || matchUpCount || 0;
|
|
32916
|
-
return generateRange(0, numberToGenerate).map(function (index) {
|
|
32917
|
-
var collectionPosition = index + 1;
|
|
32918
|
-
return {
|
|
32919
|
-
sides: [{ sideNumber: 1 }, { sideNumber: 2 }],
|
|
32920
|
-
matchUpId: (uuids === null || uuids === void 0 ? void 0 : uuids.pop()) || UUID(),
|
|
32921
|
-
matchUpStatus: MatchUpStatusEnum.ToBePlayed,
|
|
32922
|
-
collectionPosition: collectionPosition,
|
|
32923
|
-
collectionId: collectionId,
|
|
32924
|
-
processCodes: processCodes,
|
|
32925
|
-
matchUpType: matchUpType,
|
|
32926
|
-
isMock: isMock,
|
|
32927
|
-
};
|
|
32928
|
-
});
|
|
32929
|
-
}
|
|
32930
|
-
|
|
32931
33204
|
function addCollectionDefinition$1(_a) {
|
|
32932
33205
|
var e_1, _b, e_2, _c, _d, e_3, _e;
|
|
32933
33206
|
var _f, _g, _h, _j, _k, _l, _m;
|
|
@@ -32976,10 +33249,10 @@ function addCollectionDefinition$1(_a) {
|
|
|
32976
33249
|
return collectionId;
|
|
32977
33250
|
});
|
|
32978
33251
|
if (collectionIds.includes(collectionDefinition.collectionId))
|
|
32979
|
-
return {
|
|
32980
|
-
collectionId: collectionDefinition.collectionId,
|
|
32981
|
-
error: DUPLICATE_VALUE,
|
|
32982
|
-
};
|
|
33252
|
+
return decorateResult({
|
|
33253
|
+
context: { collectionId: collectionDefinition.collectionId },
|
|
33254
|
+
result: { error: DUPLICATE_VALUE },
|
|
33255
|
+
});
|
|
32983
33256
|
}
|
|
32984
33257
|
tieFormat.collectionDefinitions.push(collectionDefinition);
|
|
32985
33258
|
tieFormat.collectionDefinitions
|
|
@@ -33082,7 +33355,10 @@ function addCollectionDefinition$1(_a) {
|
|
|
33082
33355
|
}
|
|
33083
33356
|
else if (matchUpId && matchUp) {
|
|
33084
33357
|
if (!validUpdate({ matchUp: matchUp, updateInProgressMatchUps: updateInProgressMatchUps }))
|
|
33085
|
-
return {
|
|
33358
|
+
return decorateResult({
|
|
33359
|
+
result: { error: CANNOT_MODIFY_TIEFORMAT },
|
|
33360
|
+
stack: stack,
|
|
33361
|
+
});
|
|
33086
33362
|
matchUp.tieFormat = prunedTieFormat;
|
|
33087
33363
|
var newMatchUps = generateCollectionMatchUps({
|
|
33088
33364
|
collectionDefinition: collectionDefinition,
|
|
@@ -33114,7 +33390,7 @@ function addCollectionDefinition$1(_a) {
|
|
|
33114
33390
|
structure: structure_2,
|
|
33115
33391
|
uuids: uuids,
|
|
33116
33392
|
});
|
|
33117
|
-
modifiedStructureIds.push(structureId);
|
|
33393
|
+
modifiedStructureIds.push(structure_2.structureId);
|
|
33118
33394
|
addedMatchUps.push.apply(addedMatchUps, __spreadArray([], __read(result_3.newMatchUps), false));
|
|
33119
33395
|
targetMatchUps.push.apply(targetMatchUps, __spreadArray([], __read(result_3.targetMatchUps), false));
|
|
33120
33396
|
}
|
|
@@ -33149,7 +33425,7 @@ function addCollectionDefinition$1(_a) {
|
|
|
33149
33425
|
});
|
|
33150
33426
|
tieFormatTelemetry({ drawDefinition: drawDefinition, auditData: auditData });
|
|
33151
33427
|
}
|
|
33152
|
-
return __assign(
|
|
33428
|
+
return __assign({ tieFormat: prunedTieFormat, targetMatchUps: targetMatchUps, addedMatchUps: addedMatchUps }, SUCCESS);
|
|
33153
33429
|
}
|
|
33154
33430
|
function updateStructureMatchUps(_a) {
|
|
33155
33431
|
var e_4, _b, _c;
|
|
@@ -33214,122 +33490,6 @@ function addCollectionDefinition(params) {
|
|
|
33214
33490
|
return resolveTournamentRecord(__assign(__assign({}, params), { method: addCollectionDefinition$1 }));
|
|
33215
33491
|
}
|
|
33216
33492
|
|
|
33217
|
-
function publicFindMatchUp(params) {
|
|
33218
|
-
Object.assign(params, { inContext: true });
|
|
33219
|
-
var _a = findMatchUp(params), matchUp = _a.matchUp, error = _a.error;
|
|
33220
|
-
return { matchUp: makeDeepCopy(matchUp, true, true), error: error };
|
|
33221
|
-
}
|
|
33222
|
-
function findMatchUp(_a) {
|
|
33223
|
-
var _b;
|
|
33224
|
-
var participantsProfile = _a.participantsProfile, afterRecoveryTimes = _a.afterRecoveryTimes, tournamentRecord = _a.tournamentRecord, contextContent = _a.contextContent, contextProfile = _a.contextProfile, drawDefinition = _a.drawDefinition, matchUpId = _a.matchUpId, inContext = _a.inContext, eventId = _a.eventId, drawId = _a.drawId, event = _a.event;
|
|
33225
|
-
if (!tournamentRecord)
|
|
33226
|
-
return { error: MISSING_TOURNAMENT_RECORD };
|
|
33227
|
-
if (typeof matchUpId !== 'string')
|
|
33228
|
-
return { error: MISSING_MATCHUP_ID };
|
|
33229
|
-
if (!drawDefinition || !event) {
|
|
33230
|
-
var matchUps = allTournamentMatchUps({ tournamentRecord: tournamentRecord }).matchUps || [];
|
|
33231
|
-
var inContextMatchUp = matchUps.find(function (matchUp) { return matchUp.matchUpId === matchUpId; });
|
|
33232
|
-
if (!inContextMatchUp)
|
|
33233
|
-
return { error: MATCHUP_NOT_FOUND };
|
|
33234
|
-
// since drawEngineFindMatchUp is being used, additional context needs to be provided
|
|
33235
|
-
(eventId = inContextMatchUp.eventId, drawId = inContextMatchUp.drawId);
|
|
33236
|
-
(_b = findEvent({
|
|
33237
|
-
tournamentRecord: tournamentRecord,
|
|
33238
|
-
eventId: eventId,
|
|
33239
|
-
drawId: drawId,
|
|
33240
|
-
}), event = _b.event, drawDefinition = _b.drawDefinition);
|
|
33241
|
-
}
|
|
33242
|
-
if (!drawDefinition)
|
|
33243
|
-
return { error: DRAW_DEFINITION_NOT_FOUND };
|
|
33244
|
-
if (contextProfile && !contextContent)
|
|
33245
|
-
contextContent = getContextContent({ tournamentRecord: tournamentRecord, contextProfile: contextProfile });
|
|
33246
|
-
var additionalContext = {
|
|
33247
|
-
surfaceCategory: (event === null || event === void 0 ? void 0 : event.surfaceCategory) || tournamentRecord.surfaceCategory,
|
|
33248
|
-
indoorOutDoor: (event === null || event === void 0 ? void 0 : event.indoorOutdoor) || tournamentRecord.indoorOutdoor,
|
|
33249
|
-
endDate: (event === null || event === void 0 ? void 0 : event.endDate) || tournamentRecord.endDate,
|
|
33250
|
-
tournamentId: tournamentRecord.tournamentId,
|
|
33251
|
-
eventId: eventId || (event === null || event === void 0 ? void 0 : event.eventId),
|
|
33252
|
-
drawId: drawId,
|
|
33253
|
-
};
|
|
33254
|
-
var _c = hydrateParticipants({
|
|
33255
|
-
participantsProfile: participantsProfile,
|
|
33256
|
-
tournamentRecord: tournamentRecord,
|
|
33257
|
-
contextProfile: contextProfile,
|
|
33258
|
-
inContext: inContext,
|
|
33259
|
-
}).participants, tournamentParticipants = _c === void 0 ? [] : _c;
|
|
33260
|
-
var _d = findMatchUp$1({
|
|
33261
|
-
context: inContext ? additionalContext : undefined,
|
|
33262
|
-
tournamentParticipants: tournamentParticipants,
|
|
33263
|
-
afterRecoveryTimes: afterRecoveryTimes,
|
|
33264
|
-
contextContent: contextContent,
|
|
33265
|
-
drawDefinition: drawDefinition,
|
|
33266
|
-
contextProfile: contextProfile,
|
|
33267
|
-
matchUpId: matchUpId,
|
|
33268
|
-
inContext: inContext,
|
|
33269
|
-
event: event,
|
|
33270
|
-
}), matchUp = _d.matchUp, structure = _d.structure;
|
|
33271
|
-
return { matchUp: matchUp, structure: structure, drawDefinition: drawDefinition };
|
|
33272
|
-
}
|
|
33273
|
-
|
|
33274
|
-
function getTieFormat(_a) {
|
|
33275
|
-
var _b, _c, _d, _e, _f;
|
|
33276
|
-
var tournamentRecord = _a.tournamentRecord, // passed in automatically by tournamentEngine
|
|
33277
|
-
drawDefinition = _a.drawDefinition, // passed in automatically by tournamentEngine when drawId provided
|
|
33278
|
-
structureId = _a.structureId, // optional - if only the default matchUpFormat for a structure is required
|
|
33279
|
-
matchUpId = _a.matchUpId, // id of matchUp for which the scoped matchUpFormat(s) are desired
|
|
33280
|
-
structure = _a.structure, // optional optimization - when structure already known
|
|
33281
|
-
eventId = _a.eventId, // optional - if only the default matchUpFormat for an event is required
|
|
33282
|
-
drawId = _a.drawId, // avoid brute force search for matchUp
|
|
33283
|
-
event = _a.event;
|
|
33284
|
-
if (!tournamentRecord)
|
|
33285
|
-
return { error: MISSING_TOURNAMENT_RECORD };
|
|
33286
|
-
if (!drawId && !event && !structureId && !matchUpId)
|
|
33287
|
-
return decorateResult({
|
|
33288
|
-
result: { error: MISSING_VALUE },
|
|
33289
|
-
stack: 'getTieFormat',
|
|
33290
|
-
});
|
|
33291
|
-
if (eventId && !event) {
|
|
33292
|
-
event = (_b = tournamentRecord.events) === null || _b === void 0 ? void 0 : _b.find(function (event) { return event.eventId === eventId; });
|
|
33293
|
-
}
|
|
33294
|
-
var matchUpResult = findMatchUp({
|
|
33295
|
-
tournamentRecord: tournamentRecord,
|
|
33296
|
-
drawDefinition: drawDefinition,
|
|
33297
|
-
matchUpId: matchUpId,
|
|
33298
|
-
drawId: drawId,
|
|
33299
|
-
event: event,
|
|
33300
|
-
});
|
|
33301
|
-
if (matchUpId && (matchUpResult === null || matchUpResult === void 0 ? void 0 : matchUpResult.error)) {
|
|
33302
|
-
return matchUpResult;
|
|
33303
|
-
}
|
|
33304
|
-
else if (!drawDefinition && (matchUpResult === null || matchUpResult === void 0 ? void 0 : matchUpResult.drawDefinition)) {
|
|
33305
|
-
drawDefinition = matchUpResult === null || matchUpResult === void 0 ? void 0 : matchUpResult.drawDefinition;
|
|
33306
|
-
}
|
|
33307
|
-
structure = structure !== null && structure !== void 0 ? structure : matchUpResult === null || matchUpResult === void 0 ? void 0 : matchUpResult.structure;
|
|
33308
|
-
if (!structure && structureId && !matchUpId) {
|
|
33309
|
-
if (!drawDefinition)
|
|
33310
|
-
return { error: MISSING_DRAW_ID };
|
|
33311
|
-
var structureResult = findStructure({ drawDefinition: drawDefinition, structureId: structureId });
|
|
33312
|
-
if (structureResult.error)
|
|
33313
|
-
return structureResult;
|
|
33314
|
-
structure = structureResult.structure;
|
|
33315
|
-
}
|
|
33316
|
-
var structureDefaultTieFormat = ((structure === null || structure === void 0 ? void 0 : structure.tieFormat) || (structure === null || structure === void 0 ? void 0 : structure.tieFormatId)) &&
|
|
33317
|
-
((_c = resolveTieFormat({ structure: structure, drawDefinition: drawDefinition, event: event })) === null || _c === void 0 ? void 0 : _c.tieFormat);
|
|
33318
|
-
var drawDefaultTieFormat = ((drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.tieFormat) || (drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.tieFormatId)) &&
|
|
33319
|
-
((_d = resolveTieFormat({
|
|
33320
|
-
drawDefinition: drawDefinition,
|
|
33321
|
-
event: event,
|
|
33322
|
-
})) === null || _d === void 0 ? void 0 : _d.tieFormat);
|
|
33323
|
-
var eventDefaultTieFormat = (_e = resolveTieFormat({ event: event })) === null || _e === void 0 ? void 0 : _e.tieFormat;
|
|
33324
|
-
var tieFormat = (_f = resolveTieFormat({
|
|
33325
|
-
matchUp: matchUpResult === null || matchUpResult === void 0 ? void 0 : matchUpResult.matchUp,
|
|
33326
|
-
drawDefinition: drawDefinition,
|
|
33327
|
-
structure: structure,
|
|
33328
|
-
event: event,
|
|
33329
|
-
})) === null || _f === void 0 ? void 0 : _f.tieFormat;
|
|
33330
|
-
return __assign(__assign({}, SUCCESS), { matchUp: matchUpResult === null || matchUpResult === void 0 ? void 0 : matchUpResult.matchUp, structureDefaultTieFormat: structureDefaultTieFormat, eventDefaultTieFormat: eventDefaultTieFormat, drawDefaultTieFormat: drawDefaultTieFormat, tieFormat: tieFormat, structure: structure });
|
|
33331
|
-
}
|
|
33332
|
-
|
|
33333
33493
|
function updateTargetTeamMatchUps(_a) {
|
|
33334
33494
|
var e_1, _b;
|
|
33335
33495
|
var updateInProgressMatchUps = _a.updateInProgressMatchUps, tournamentRecord = _a.tournamentRecord, drawDefinition = _a.drawDefinition, targetMatchUps = _a.targetMatchUps, tieFormat = _a.tieFormat, event = _a.event;
|
|
@@ -33474,8 +33634,7 @@ function removeCollectionGroup$1(_a) {
|
|
|
33474
33634
|
return { error: INVALID_VALUES };
|
|
33475
33635
|
var stack = 'removeCollectionGroup';
|
|
33476
33636
|
var result = !matchUp
|
|
33477
|
-
? getTieFormat({
|
|
33478
|
-
tournamentRecord: tournamentRecord,
|
|
33637
|
+
? getTieFormat$1({
|
|
33479
33638
|
drawDefinition: drawDefinition,
|
|
33480
33639
|
structureId: structureId,
|
|
33481
33640
|
matchUpId: matchUpId,
|
|
@@ -33639,8 +33798,13 @@ function modifyTieFormat$1(_a) {
|
|
|
33639
33798
|
var e_1, _b, e_2, _c, e_3, _d;
|
|
33640
33799
|
var _e = _a.updateInProgressMatchUps, updateInProgressMatchUps = _e === void 0 ? false : _e, tieFormatComparison = _a.tieFormatComparison, modifiedTieFormat = _a.modifiedTieFormat, tournamentRecord = _a.tournamentRecord, drawDefinition = _a.drawDefinition, structureId = _a.structureId, matchUpId = _a.matchUpId, eventId = _a.eventId, uuids = _a.uuids, event = _a.event;
|
|
33641
33800
|
var stack = 'updateTieFormat';
|
|
33642
|
-
if (!validateTieFormat(modifiedTieFormat))
|
|
33643
|
-
return {
|
|
33801
|
+
if (!validateTieFormat({ tieFormat: modifiedTieFormat }).valid) {
|
|
33802
|
+
return decorateResult({
|
|
33803
|
+
result: { error: INVALID_TIE_FORMAT },
|
|
33804
|
+
info: 'falied validation',
|
|
33805
|
+
stack: stack,
|
|
33806
|
+
});
|
|
33807
|
+
}
|
|
33644
33808
|
var result = getTieFormat$1({
|
|
33645
33809
|
drawDefinition: drawDefinition,
|
|
33646
33810
|
structureId: structureId,
|
|
@@ -33652,35 +33816,45 @@ function modifyTieFormat$1(_a) {
|
|
|
33652
33816
|
return decorateResult({ result: result, stack: stack });
|
|
33653
33817
|
var matchUp = result.matchUp, existingTieFormat = result.tieFormat;
|
|
33654
33818
|
var tieFormat = copyTieFormat(existingTieFormat);
|
|
33819
|
+
var comparison = compareTieFormats({
|
|
33820
|
+
descendant: modifiedTieFormat,
|
|
33821
|
+
ancestor: tieFormat,
|
|
33822
|
+
});
|
|
33823
|
+
if (comparison.invalid) {
|
|
33824
|
+
return decorateResult({
|
|
33825
|
+
context: { invalid: comparison.invalid },
|
|
33826
|
+
result: { error: INVALID_TIE_FORMAT },
|
|
33827
|
+
});
|
|
33828
|
+
}
|
|
33829
|
+
if (!(comparison === null || comparison === void 0 ? void 0 : comparison.different)) {
|
|
33830
|
+
return decorateResult({ result: __assign({}, SUCCESS), info: 'Nothing to do' });
|
|
33831
|
+
}
|
|
33655
33832
|
var existingCollectionIds = tieFormat.collectionDefinitions.map(function (_a) {
|
|
33656
33833
|
var collectionId = _a.collectionId;
|
|
33657
33834
|
return collectionId;
|
|
33658
33835
|
});
|
|
33659
|
-
var
|
|
33660
|
-
|
|
33661
|
-
|
|
33662
|
-
modifiedTieFormat.collectionDefinitions.forEach(function (def) {
|
|
33663
|
-
var _a;
|
|
33664
|
-
updatedCollectionIds.push(def.collectionId);
|
|
33665
|
-
if (modifiedTieFormat && existingCollectionIds.includes(def.collectionId)) {
|
|
33666
|
-
((_a = compareTieFormats({
|
|
33667
|
-
descendant: modifiedTieFormat,
|
|
33668
|
-
ancestor: tieFormat,
|
|
33669
|
-
})) === null || _a === void 0 ? void 0 : _a.different) && modifiedCollectionDefinitions.push(def);
|
|
33670
|
-
}
|
|
33671
|
-
else {
|
|
33672
|
-
addedCollectionDefinitions.push(def);
|
|
33673
|
-
}
|
|
33836
|
+
var updatedCollectionIds = modifiedTieFormat.collectionDefinitions.map(function (_a) {
|
|
33837
|
+
var collectionId = _a.collectionId;
|
|
33838
|
+
return collectionId;
|
|
33674
33839
|
});
|
|
33675
33840
|
var removedCollectionIds = existingCollectionIds.filter(function (collectionId) { return !updatedCollectionIds.includes(collectionId); });
|
|
33676
|
-
var
|
|
33841
|
+
var addedCollectionDefinitions = modifiedTieFormat.collectionDefinitions.filter(function (_a) {
|
|
33842
|
+
var collectionId = _a.collectionId;
|
|
33843
|
+
return !existingCollectionIds.includes(collectionId);
|
|
33844
|
+
});
|
|
33845
|
+
var addedCollectionIds = addedCollectionDefinitions.map(extractAttributes('collectionId'));
|
|
33846
|
+
var modifications = [];
|
|
33677
33847
|
var processedTieFormat;
|
|
33848
|
+
var tieFormatName = modifiedTieFormat.tieFormatName;
|
|
33678
33849
|
try {
|
|
33679
|
-
// TODO: if matchUpCount is changing pre-check for cmopleted tieMatchUps
|
|
33680
33850
|
// TODO: if gender is changing pre-check for misgendered collectionAssignments
|
|
33681
|
-
for (var
|
|
33682
|
-
var collectionDefinition =
|
|
33683
|
-
|
|
33851
|
+
for (var _f = __values(modifiedTieFormat.collectionDefinitions), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
33852
|
+
var collectionDefinition = _g.value;
|
|
33853
|
+
if (addedCollectionIds.includes(collectionDefinition.collectionId))
|
|
33854
|
+
continue;
|
|
33855
|
+
var result_1 = modifyCollectionDefinition$1(__assign(__assign({ updateInProgressMatchUps: updateInProgressMatchUps }, collectionDefinition), { tournamentRecord: tournamentRecord, tieFormatName: tieFormatName, drawDefinition: drawDefinition, structureId: structureId, matchUpId: matchUpId, eventId: eventId, event: event }));
|
|
33856
|
+
if (result_1.modifications)
|
|
33857
|
+
modifications.push.apply(modifications, __spreadArray([], __read(result_1.modifications), false));
|
|
33684
33858
|
if (result_1.error)
|
|
33685
33859
|
return decorateResult({ result: result_1, stack: stack });
|
|
33686
33860
|
if (result_1.tieFormat)
|
|
@@ -33690,7 +33864,7 @@ function modifyTieFormat$1(_a) {
|
|
|
33690
33864
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
33691
33865
|
finally {
|
|
33692
33866
|
try {
|
|
33693
|
-
if (
|
|
33867
|
+
if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
|
|
33694
33868
|
}
|
|
33695
33869
|
finally { if (e_1) throw e_1.error; }
|
|
33696
33870
|
}
|
|
@@ -33752,6 +33926,18 @@ function modifyTieFormat$1(_a) {
|
|
|
33752
33926
|
}
|
|
33753
33927
|
finally { if (e_3) throw e_3.error; }
|
|
33754
33928
|
}
|
|
33929
|
+
var changedTieFormatName = (existingTieFormat === null || existingTieFormat === void 0 ? void 0 : existingTieFormat.tieFormatName) !== tieFormatName;
|
|
33930
|
+
// if tieFormat has changed, force renaming of the tieFormat
|
|
33931
|
+
if (changedTieFormatName) {
|
|
33932
|
+
processedTieFormat.tieFormatName = tieFormatName;
|
|
33933
|
+
modifications.push({ tieFormatName: tieFormatName });
|
|
33934
|
+
}
|
|
33935
|
+
else if (modifications.length ||
|
|
33936
|
+
addedCollectionIds.length ||
|
|
33937
|
+
removedCollectionIds.length) {
|
|
33938
|
+
delete processedTieFormat.tieFormatName;
|
|
33939
|
+
modifications.push('tieFormatName removed: modifications without new tieFormatName');
|
|
33940
|
+
}
|
|
33755
33941
|
processedTieFormat.collectionDefinitions =
|
|
33756
33942
|
processedTieFormat.collectionDefinitions
|
|
33757
33943
|
.sort(function (a, b) {
|
|
@@ -33759,13 +33945,71 @@ function modifyTieFormat$1(_a) {
|
|
|
33759
33945
|
numericSortValue(b.collectionOrder);
|
|
33760
33946
|
})
|
|
33761
33947
|
.map(function (def, i) { return (__assign(__assign({}, def), { collectionOrder: i + 1 })); });
|
|
33762
|
-
return __assign(
|
|
33948
|
+
return __assign({ processedTieFormat: copyTieFormat(processedTieFormat), modifications: modifications }, SUCCESS);
|
|
33763
33949
|
}
|
|
33764
33950
|
|
|
33765
33951
|
function modifyTieFormat(params) {
|
|
33766
33952
|
return resolveTournamentRecord(__assign(__assign({}, params), { method: modifyTieFormat$1 }));
|
|
33767
33953
|
}
|
|
33768
33954
|
|
|
33955
|
+
function publicFindMatchUp(params) {
|
|
33956
|
+
Object.assign(params, { inContext: true });
|
|
33957
|
+
var _a = findMatchUp(params), matchUp = _a.matchUp, error = _a.error;
|
|
33958
|
+
return { matchUp: makeDeepCopy(matchUp, true, true), error: error };
|
|
33959
|
+
}
|
|
33960
|
+
function findMatchUp(_a) {
|
|
33961
|
+
var _b;
|
|
33962
|
+
var _c, _d, _e, _f;
|
|
33963
|
+
var participantsProfile = _a.participantsProfile, afterRecoveryTimes = _a.afterRecoveryTimes, tournamentRecord = _a.tournamentRecord, contextContent = _a.contextContent, contextProfile = _a.contextProfile, drawDefinition = _a.drawDefinition, matchUpId = _a.matchUpId, inContext = _a.inContext, eventId = _a.eventId, drawId = _a.drawId, event = _a.event;
|
|
33964
|
+
if (!tournamentRecord)
|
|
33965
|
+
return { error: MISSING_TOURNAMENT_RECORD };
|
|
33966
|
+
if (typeof matchUpId !== 'string')
|
|
33967
|
+
return { error: MISSING_MATCHUP_ID };
|
|
33968
|
+
if (!drawDefinition || !event) {
|
|
33969
|
+
var matchUps = (_c = allTournamentMatchUps({ tournamentRecord: tournamentRecord }).matchUps) !== null && _c !== void 0 ? _c : [];
|
|
33970
|
+
var inContextMatchUp = matchUps.find(function (matchUp) { return matchUp.matchUpId === matchUpId; });
|
|
33971
|
+
if (!inContextMatchUp)
|
|
33972
|
+
return { error: MATCHUP_NOT_FOUND };
|
|
33973
|
+
// since drawEngineFindMatchUp is being used, additional context needs to be provided
|
|
33974
|
+
(eventId = inContextMatchUp.eventId, drawId = inContextMatchUp.drawId);
|
|
33975
|
+
(_b = findEvent({
|
|
33976
|
+
tournamentRecord: tournamentRecord,
|
|
33977
|
+
eventId: eventId,
|
|
33978
|
+
drawId: drawId,
|
|
33979
|
+
}), event = _b.event, drawDefinition = _b.drawDefinition);
|
|
33980
|
+
}
|
|
33981
|
+
if (!drawDefinition)
|
|
33982
|
+
return { error: DRAW_DEFINITION_NOT_FOUND };
|
|
33983
|
+
if (contextProfile && !contextContent)
|
|
33984
|
+
contextContent = getContextContent({ tournamentRecord: tournamentRecord, contextProfile: contextProfile });
|
|
33985
|
+
var additionalContext = {
|
|
33986
|
+
surfaceCategory: (_d = event === null || event === void 0 ? void 0 : event.surfaceCategory) !== null && _d !== void 0 ? _d : tournamentRecord.surfaceCategory,
|
|
33987
|
+
indoorOutDoor: (_e = event === null || event === void 0 ? void 0 : event.indoorOutdoor) !== null && _e !== void 0 ? _e : tournamentRecord.indoorOutdoor,
|
|
33988
|
+
endDate: (_f = event === null || event === void 0 ? void 0 : event.endDate) !== null && _f !== void 0 ? _f : tournamentRecord.endDate,
|
|
33989
|
+
tournamentId: tournamentRecord.tournamentId,
|
|
33990
|
+
eventId: eventId !== null && eventId !== void 0 ? eventId : event === null || event === void 0 ? void 0 : event.eventId,
|
|
33991
|
+
drawId: drawId,
|
|
33992
|
+
};
|
|
33993
|
+
var _g = hydrateParticipants({
|
|
33994
|
+
participantsProfile: participantsProfile,
|
|
33995
|
+
tournamentRecord: tournamentRecord,
|
|
33996
|
+
contextProfile: contextProfile,
|
|
33997
|
+
inContext: inContext,
|
|
33998
|
+
}).participants, tournamentParticipants = _g === void 0 ? [] : _g;
|
|
33999
|
+
var _h = findMatchUp$1({
|
|
34000
|
+
context: inContext ? additionalContext : undefined,
|
|
34001
|
+
tournamentParticipants: tournamentParticipants,
|
|
34002
|
+
afterRecoveryTimes: afterRecoveryTimes,
|
|
34003
|
+
contextContent: contextContent,
|
|
34004
|
+
drawDefinition: drawDefinition,
|
|
34005
|
+
contextProfile: contextProfile,
|
|
34006
|
+
matchUpId: matchUpId,
|
|
34007
|
+
inContext: inContext,
|
|
34008
|
+
event: event,
|
|
34009
|
+
}), matchUp = _h.matchUp, structure = _h.structure;
|
|
34010
|
+
return { matchUp: matchUp, structure: structure, drawDefinition: drawDefinition };
|
|
34011
|
+
}
|
|
34012
|
+
|
|
33769
34013
|
function resetTieFormat$1(_a) {
|
|
33770
34014
|
var e_1, _b, e_2, _c;
|
|
33771
34015
|
var _d;
|
|
@@ -50612,10 +50856,6 @@ function removeDelegatedOutcome$1(_a) {
|
|
|
50612
50856
|
});
|
|
50613
50857
|
}
|
|
50614
50858
|
|
|
50615
|
-
function stringSort(a, b) {
|
|
50616
|
-
return (a || '').localeCompare(b || '');
|
|
50617
|
-
}
|
|
50618
|
-
|
|
50619
50859
|
function generateCandidate(_a) {
|
|
50620
50860
|
var _b = _a.maxIterations, maxIterations = _b === void 0 ? 4000 : _b, // cap the processing intensity of the candidate generator
|
|
50621
50861
|
valueSortedPairings = _a.valueSortedPairings, // pairings sorted by value from low to high
|
|
@@ -63957,6 +64197,65 @@ function getParticipantSignInStatus(_a) {
|
|
|
63957
64197
|
return timeItem && timeItem.itemValue === SIGNED_IN && SIGNED_IN;
|
|
63958
64198
|
}
|
|
63959
64199
|
|
|
64200
|
+
function getTieFormat(_a) {
|
|
64201
|
+
var _b, _c, _d, _e, _f;
|
|
64202
|
+
var tournamentRecord = _a.tournamentRecord, // passed in automatically by tournamentEngine
|
|
64203
|
+
drawDefinition = _a.drawDefinition, // passed in automatically by tournamentEngine when drawId provided
|
|
64204
|
+
structureId = _a.structureId, // optional - if only the default matchUpFormat for a structure is required
|
|
64205
|
+
matchUpId = _a.matchUpId, // id of matchUp for which the scoped matchUpFormat(s) are desired
|
|
64206
|
+
structure = _a.structure, // optional optimization - when structure already known
|
|
64207
|
+
eventId = _a.eventId, // optional - if only the default matchUpFormat for an event is required
|
|
64208
|
+
drawId = _a.drawId, // avoid brute force search for matchUp
|
|
64209
|
+
event = _a.event;
|
|
64210
|
+
if (!tournamentRecord)
|
|
64211
|
+
return { error: MISSING_TOURNAMENT_RECORD };
|
|
64212
|
+
if (!drawId && !event && !structureId && !matchUpId)
|
|
64213
|
+
return decorateResult({
|
|
64214
|
+
result: { error: MISSING_VALUE },
|
|
64215
|
+
stack: 'getTieFormat',
|
|
64216
|
+
});
|
|
64217
|
+
if (eventId && !event) {
|
|
64218
|
+
event = (_b = tournamentRecord.events) === null || _b === void 0 ? void 0 : _b.find(function (event) { return event.eventId === eventId; });
|
|
64219
|
+
}
|
|
64220
|
+
var matchUpResult = publicFindMatchUp({
|
|
64221
|
+
tournamentRecord: tournamentRecord,
|
|
64222
|
+
drawDefinition: drawDefinition,
|
|
64223
|
+
matchUpId: matchUpId,
|
|
64224
|
+
drawId: drawId,
|
|
64225
|
+
event: event,
|
|
64226
|
+
});
|
|
64227
|
+
if (matchUpId && (matchUpResult === null || matchUpResult === void 0 ? void 0 : matchUpResult.error)) {
|
|
64228
|
+
return matchUpResult;
|
|
64229
|
+
}
|
|
64230
|
+
else if (!drawDefinition && (matchUpResult === null || matchUpResult === void 0 ? void 0 : matchUpResult.drawDefinition)) {
|
|
64231
|
+
drawDefinition = matchUpResult === null || matchUpResult === void 0 ? void 0 : matchUpResult.drawDefinition;
|
|
64232
|
+
}
|
|
64233
|
+
structure = structure !== null && structure !== void 0 ? structure : matchUpResult === null || matchUpResult === void 0 ? void 0 : matchUpResult.structure;
|
|
64234
|
+
if (!structure && structureId && !matchUpId) {
|
|
64235
|
+
if (!drawDefinition)
|
|
64236
|
+
return { error: MISSING_DRAW_ID };
|
|
64237
|
+
var structureResult = findStructure({ drawDefinition: drawDefinition, structureId: structureId });
|
|
64238
|
+
if (structureResult.error)
|
|
64239
|
+
return structureResult;
|
|
64240
|
+
structure = structureResult.structure;
|
|
64241
|
+
}
|
|
64242
|
+
var structureDefaultTieFormat = ((structure === null || structure === void 0 ? void 0 : structure.tieFormat) || (structure === null || structure === void 0 ? void 0 : structure.tieFormatId)) &&
|
|
64243
|
+
((_c = resolveTieFormat({ structure: structure, drawDefinition: drawDefinition, event: event })) === null || _c === void 0 ? void 0 : _c.tieFormat);
|
|
64244
|
+
var drawDefaultTieFormat = ((drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.tieFormat) || (drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.tieFormatId)) &&
|
|
64245
|
+
((_d = resolveTieFormat({
|
|
64246
|
+
drawDefinition: drawDefinition,
|
|
64247
|
+
event: event,
|
|
64248
|
+
})) === null || _d === void 0 ? void 0 : _d.tieFormat);
|
|
64249
|
+
var eventDefaultTieFormat = (_e = resolveTieFormat({ event: event })) === null || _e === void 0 ? void 0 : _e.tieFormat;
|
|
64250
|
+
var tieFormat = (_f = resolveTieFormat({
|
|
64251
|
+
matchUp: matchUpResult === null || matchUpResult === void 0 ? void 0 : matchUpResult.matchUp,
|
|
64252
|
+
drawDefinition: drawDefinition,
|
|
64253
|
+
structure: structure,
|
|
64254
|
+
event: event,
|
|
64255
|
+
})) === null || _f === void 0 ? void 0 : _f.tieFormat;
|
|
64256
|
+
return __assign(__assign({}, SUCCESS), { matchUp: matchUpResult === null || matchUpResult === void 0 ? void 0 : matchUpResult.matchUp, structureDefaultTieFormat: copyTieFormat(structureDefaultTieFormat), eventDefaultTieFormat: copyTieFormat(eventDefaultTieFormat), drawDefaultTieFormat: copyTieFormat(drawDefaultTieFormat), tieFormat: copyTieFormat(tieFormat), structure: structure });
|
|
64257
|
+
}
|
|
64258
|
+
|
|
63960
64259
|
function getEventProperties(_a) {
|
|
63961
64260
|
var _b, _c;
|
|
63962
64261
|
var tournamentRecord = _a.tournamentRecord, event = _a.event;
|