tods-competition-factory 1.7.13 → 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 +453 -246
- package/dist/index.mjs.map +1 -1
- package/dist/tods-competition-factory.development.cjs.js +439 -249
- 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
|
@@ -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) {
|
|
@@ -32036,7 +32080,7 @@ function getTieFormat$1(_a) {
|
|
|
32036
32080
|
}
|
|
32037
32081
|
if (!tieFormat)
|
|
32038
32082
|
return decorateResult({ result: { error: MISSING_TIE_FORMAT }, stack: stack });
|
|
32039
|
-
return __assign(__assign({}, SUCCESS), { tieFormat: tieFormat, matchUp: matchUp
|
|
32083
|
+
return __assign(__assign({}, SUCCESS), { structure: structure, tieFormat: tieFormat, matchUp: matchUp });
|
|
32040
32084
|
}
|
|
32041
32085
|
|
|
32042
32086
|
function tieFormatTelemetry(_a) {
|
|
@@ -32054,6 +32098,38 @@ function tieFormatTelemetry(_a) {
|
|
|
32054
32098
|
addExtension$1({ element: drawDefinition, extension: updatedExtension });
|
|
32055
32099
|
}
|
|
32056
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
|
+
|
|
32057
32133
|
function validUpdate(_a) {
|
|
32058
32134
|
var matchUp = _a.matchUp, updateInProgressMatchUps = _a.updateInProgressMatchUps;
|
|
32059
32135
|
return (!matchUp.winningSide &&
|
|
@@ -32063,17 +32139,29 @@ function validUpdate(_a) {
|
|
|
32063
32139
|
}
|
|
32064
32140
|
|
|
32065
32141
|
// used to determine that all collections have the same collectionIds
|
|
32066
|
-
function
|
|
32067
|
-
var
|
|
32068
|
-
|
|
32069
|
-
|
|
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 };
|
|
32070
32155
|
}
|
|
32071
32156
|
function updateTieFormat(_a) {
|
|
32072
32157
|
var e_1, _b;
|
|
32073
32158
|
var _c, _d, _e, _f, _g;
|
|
32074
|
-
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;
|
|
32075
32160
|
var stack = 'updateTieFormat';
|
|
32161
|
+
var tournamentId = tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.tournamentId;
|
|
32076
32162
|
var modifiedStructuresCount = 0;
|
|
32163
|
+
var modifiedMatchUpsCount = 0;
|
|
32164
|
+
var addedMatchUpsCount = 0;
|
|
32077
32165
|
var modifiedCount = 0;
|
|
32078
32166
|
var collectionMap = tieFormat === null || tieFormat === void 0 ? void 0 : tieFormat.collectionDefinitions.reduce(function (instanceMap, def) {
|
|
32079
32167
|
instanceMap[def.collectionId] =
|
|
@@ -32087,7 +32175,8 @@ function updateTieFormat(_a) {
|
|
|
32087
32175
|
(instanceMap[def.collectionId] || 0) + def.matchUpCount;
|
|
32088
32176
|
return instanceMap;
|
|
32089
32177
|
}, {});
|
|
32090
|
-
return
|
|
32178
|
+
return checkStructureMatchUpCounts({ from: cMap, to: collectionMap })
|
|
32179
|
+
.equivalent;
|
|
32091
32180
|
};
|
|
32092
32181
|
var drawDefaultTieFormat = (_c = getTieFormat$1({ drawDefinition: drawDefinition })) === null || _c === void 0 ? void 0 : _c.tieFormat;
|
|
32093
32182
|
var eventDefaultTieFormat = (_d = getTieFormat$1({ event: event })) === null || _d === void 0 ? void 0 : _d.tieFormat;
|
|
@@ -32105,7 +32194,7 @@ function updateTieFormat(_a) {
|
|
|
32105
32194
|
}
|
|
32106
32195
|
finally { if (e_1) throw e_1.error; }
|
|
32107
32196
|
}
|
|
32108
|
-
event.tieFormat = tieFormat;
|
|
32197
|
+
event.tieFormat = copyTieFormat(tieFormat);
|
|
32109
32198
|
modifiedCount += 1;
|
|
32110
32199
|
}
|
|
32111
32200
|
else if (matchUp) {
|
|
@@ -32117,9 +32206,17 @@ function updateTieFormat(_a) {
|
|
|
32117
32206
|
var collectionId = _a.collectionId;
|
|
32118
32207
|
return collectionId;
|
|
32119
32208
|
}));
|
|
32120
|
-
|
|
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) {
|
|
32121
32218
|
if (validUpdate({ matchUp: matchUp, updateInProgressMatchUps: updateInProgressMatchUps })) {
|
|
32122
|
-
matchUp.tieFormat = tieFormat;
|
|
32219
|
+
matchUp.tieFormat = copyTieFormat(tieFormat);
|
|
32123
32220
|
modifiedCount += 1;
|
|
32124
32221
|
}
|
|
32125
32222
|
else {
|
|
@@ -32129,19 +32226,23 @@ function updateTieFormat(_a) {
|
|
|
32129
32226
|
});
|
|
32130
32227
|
}
|
|
32131
32228
|
}
|
|
32229
|
+
else if (changesArePossible) {
|
|
32230
|
+
makeChanges({ tieFormat: tieFormat, matchUp: matchUp, changes: changes, uuids: uuids });
|
|
32231
|
+
}
|
|
32132
32232
|
else {
|
|
32133
32233
|
return decorateResult({
|
|
32134
32234
|
context: { collectionMap: collectionMap, matchUpMap: matchUpMap },
|
|
32135
32235
|
result: { error: INVALID_TIE_FORMAT },
|
|
32136
|
-
info: '
|
|
32236
|
+
info: cannotChangeReaon || 'specified changes not possible',
|
|
32137
32237
|
stack: stack,
|
|
32138
32238
|
});
|
|
32139
32239
|
}
|
|
32240
|
+
modifiedMatchUpsCount += 1;
|
|
32140
32241
|
modifyMatchUpNotice({
|
|
32141
|
-
tournamentId: tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.tournamentId,
|
|
32142
32242
|
eventId: event === null || event === void 0 ? void 0 : event.eventId,
|
|
32143
32243
|
context: stack,
|
|
32144
32244
|
drawDefinition: drawDefinition,
|
|
32245
|
+
tournamentId: tournamentId,
|
|
32145
32246
|
matchUp: matchUp,
|
|
32146
32247
|
});
|
|
32147
32248
|
}
|
|
@@ -32149,30 +32250,43 @@ function updateTieFormat(_a) {
|
|
|
32149
32250
|
// all TEAM matchUps within the structure have tieMatchUps which were created following a tieFormat which occurs higher in the hierarchy
|
|
32150
32251
|
// attaching a tieFormat to the structure must ensure that affected TEAM matchUps within the structure all have appropriate tieMatchUps
|
|
32151
32252
|
// therefore those that fail to match the modified tieFormat MUST have an appropriate tieFormat attached from higher in the hierarchy
|
|
32152
|
-
var inheritedTieFormat = drawDefaultTieFormat
|
|
32253
|
+
var inheritedTieFormat = drawDefaultTieFormat !== null && drawDefaultTieFormat !== void 0 ? drawDefaultTieFormat : eventDefaultTieFormat;
|
|
32153
32254
|
var modified = (_g = processStructure({
|
|
32154
32255
|
inheritedTieFormat: inheritedTieFormat,
|
|
32155
32256
|
structure: structure,
|
|
32156
|
-
})) === null || _g === void 0 ? void 0 : _g.
|
|
32157
|
-
if (modified)
|
|
32158
|
-
|
|
32159
|
-
|
|
32160
|
-
|
|
32161
|
-
|
|
32162
|
-
|
|
32163
|
-
|
|
32164
|
-
|
|
32165
|
-
|
|
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
|
+
});
|
|
32166
32280
|
}
|
|
32167
32281
|
else if (drawDefinition) {
|
|
32168
32282
|
processDrawDefinition({ drawDefinition: drawDefinition });
|
|
32169
|
-
drawDefinition.tieFormat = tieFormat;
|
|
32283
|
+
drawDefinition.tieFormat = copyTieFormat(tieFormat);
|
|
32170
32284
|
modifiedCount += 1;
|
|
32171
32285
|
}
|
|
32172
32286
|
else {
|
|
32173
32287
|
return { error: MISSING_DRAW_DEFINITION };
|
|
32174
32288
|
}
|
|
32175
|
-
return __assign(__assign({
|
|
32289
|
+
return __assign(__assign({ modifiedStructuresCount: modifiedStructuresCount, modifiedMatchUpsCount: modifiedMatchUpsCount, addedMatchUpsCount: addedMatchUpsCount, modifiedCount: modifiedCount }, SUCCESS), { tieFormat: tieFormat });
|
|
32176
32290
|
function processDrawDefinition(_a) {
|
|
32177
32291
|
var e_2, _b;
|
|
32178
32292
|
var _c;
|
|
@@ -32189,9 +32303,10 @@ function updateTieFormat(_a) {
|
|
|
32189
32303
|
var modifiedCount_1 = (_c = processStructure({
|
|
32190
32304
|
inheritedTieFormat: inheritedTieFormat,
|
|
32191
32305
|
structure: structure_1,
|
|
32192
|
-
})) === null || _c === void 0 ? void 0 : _c.
|
|
32306
|
+
})) === null || _c === void 0 ? void 0 : _c.modifiedMatchUpsCount;
|
|
32193
32307
|
if (modifiedCount_1) {
|
|
32194
|
-
modifiedStructuresCount +=
|
|
32308
|
+
modifiedStructuresCount += 1;
|
|
32309
|
+
modifiedMatchUpsCount += modifiedCount_1;
|
|
32195
32310
|
var structureId = structure_1.structureId;
|
|
32196
32311
|
modifiedStructureIds.push(structureId);
|
|
32197
32312
|
}
|
|
@@ -32215,7 +32330,7 @@ function updateTieFormat(_a) {
|
|
|
32215
32330
|
var e_3, _b;
|
|
32216
32331
|
var _c, _d;
|
|
32217
32332
|
var inheritedTieFormat = _a.inheritedTieFormat, structure = _a.structure;
|
|
32218
|
-
var
|
|
32333
|
+
var modifiedMatchUpsCount = 0;
|
|
32219
32334
|
var structureMatchUps = ((_c = getAllStructureMatchUps({
|
|
32220
32335
|
matchUpFilters: { matchUpTypes: [TEAM$2] },
|
|
32221
32336
|
structure: structure,
|
|
@@ -32223,15 +32338,34 @@ function updateTieFormat(_a) {
|
|
|
32223
32338
|
try {
|
|
32224
32339
|
for (var structureMatchUps_1 = __values(structureMatchUps), structureMatchUps_1_1 = structureMatchUps_1.next(); !structureMatchUps_1_1.done; structureMatchUps_1_1 = structureMatchUps_1.next()) {
|
|
32225
32340
|
var matchUp_1 = structureMatchUps_1_1.value;
|
|
32341
|
+
var validToUpdate = validUpdate({ matchUp: matchUp_1, updateInProgressMatchUps: updateInProgressMatchUps });
|
|
32226
32342
|
var modified = false;
|
|
32227
32343
|
var tieMatchUpsMap = instanceCount((_d = matchUp_1.tieMatchUps) === null || _d === void 0 ? void 0 : _d.map(function (_a) {
|
|
32228
32344
|
var collectionId = _a.collectionId;
|
|
32229
32345
|
return collectionId;
|
|
32230
32346
|
}));
|
|
32231
|
-
|
|
32232
|
-
|
|
32233
|
-
|
|
32234
|
-
|
|
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
|
+
}
|
|
32235
32369
|
}
|
|
32236
32370
|
else {
|
|
32237
32371
|
return decorateResult({
|
|
@@ -32242,12 +32376,12 @@ function updateTieFormat(_a) {
|
|
|
32242
32376
|
}
|
|
32243
32377
|
else if (matchUp_1.tieFormat &&
|
|
32244
32378
|
matchingCollections(matchUp_1) &&
|
|
32245
|
-
|
|
32379
|
+
validToUpdate) {
|
|
32246
32380
|
matchUp_1.tieFormat = copyTieFormat(tieFormat);
|
|
32247
32381
|
modified = true;
|
|
32248
32382
|
}
|
|
32249
32383
|
if (modified) {
|
|
32250
|
-
|
|
32384
|
+
modifiedMatchUpsCount += 1;
|
|
32251
32385
|
modifyMatchUpNotice({
|
|
32252
32386
|
tournamentId: tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.tournamentId,
|
|
32253
32387
|
drawDefinition: drawDefinition,
|
|
@@ -32265,11 +32399,83 @@ function updateTieFormat(_a) {
|
|
|
32265
32399
|
}
|
|
32266
32400
|
finally { if (e_3) throw e_3.error; }
|
|
32267
32401
|
}
|
|
32268
|
-
return {
|
|
32402
|
+
return { modifiedMatchUpsCount: modifiedMatchUpsCount };
|
|
32269
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 };
|
|
32270
32477
|
}
|
|
32271
32478
|
|
|
32272
|
-
// all child matchUps need to be checked for collectionAssignments / collectionPositions which need to be removed when collectionDefinition.collectionIds are removed
|
|
32273
32479
|
function modifyCollectionDefinition$1(_a) {
|
|
32274
32480
|
var _b, _c, _d;
|
|
32275
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,
|
|
@@ -32314,8 +32520,9 @@ function modifyCollectionDefinition$1(_a) {
|
|
|
32314
32520
|
if (!Object.values(valueAssignments).filter(Boolean).length &&
|
|
32315
32521
|
!collectionOrder &&
|
|
32316
32522
|
!collectionName &&
|
|
32523
|
+
!matchUpFormat &&
|
|
32317
32524
|
!matchUpCount &&
|
|
32318
|
-
!
|
|
32525
|
+
!matchUpType)
|
|
32319
32526
|
return decorateResult({ result: { error: MISSING_VALUE }, stack: stack });
|
|
32320
32527
|
if (Object.values(valueAssignments).filter(Boolean).length > 1)
|
|
32321
32528
|
return decorateResult({
|
|
@@ -32340,11 +32547,16 @@ function modifyCollectionDefinition$1(_a) {
|
|
|
32340
32547
|
});
|
|
32341
32548
|
var targetCollectionDefinition = tieFormat === null || tieFormat === void 0 ? void 0 : tieFormat.collectionDefinitions.find(function (collectionDefinition) { return collectionDefinition.collectionId === collectionId; });
|
|
32342
32549
|
if (!sourceCollectionDefinition)
|
|
32343
|
-
return decorateResult({
|
|
32550
|
+
return decorateResult({
|
|
32551
|
+
info: 'source collectionDefinition',
|
|
32552
|
+
result: { error: NOT_FOUND },
|
|
32553
|
+
context: { collectionId: collectionId },
|
|
32554
|
+
stack: stack,
|
|
32555
|
+
});
|
|
32344
32556
|
var value = (_c = (_b = collectionValue !== null && collectionValue !== void 0 ? collectionValue : matchUpValue) !== null && _b !== void 0 ? _b : scoreValue) !== null && _c !== void 0 ? _c : setValue;
|
|
32345
32557
|
if (collectionValueProfiles) {
|
|
32346
|
-
var result_1 =
|
|
32347
|
-
matchUpCount: matchUpCount
|
|
32558
|
+
var result_1 = validateCollectionValueProfiles({
|
|
32559
|
+
matchUpCount: matchUpCount !== null && matchUpCount !== void 0 ? matchUpCount : sourceCollectionDefinition === null || sourceCollectionDefinition === void 0 ? void 0 : sourceCollectionDefinition.matchUpCount,
|
|
32348
32560
|
collectionValueProfiles: collectionValueProfiles,
|
|
32349
32561
|
});
|
|
32350
32562
|
if (result_1.errors) {
|
|
@@ -32442,16 +32654,11 @@ function modifyCollectionDefinition$1(_a) {
|
|
|
32442
32654
|
}
|
|
32443
32655
|
if (isConvertableInteger(matchUpCount) &&
|
|
32444
32656
|
sourceCollectionDefinition.matchUpCount !== matchUpCount) {
|
|
32445
|
-
|
|
32446
|
-
|
|
32447
|
-
// modifications.push({ structureId, matchUpCount });
|
|
32448
|
-
return decorateResult({
|
|
32449
|
-
result: { error: NOT_IMPLEMENTED },
|
|
32450
|
-
context: { matchUpCount: matchUpCount },
|
|
32451
|
-
stack: stack,
|
|
32452
|
-
});
|
|
32657
|
+
targetCollectionDefinition.matchUpCount = matchUpCount;
|
|
32658
|
+
modifications.push({ collectionId: collectionId, matchUpCount: matchUpCount });
|
|
32453
32659
|
}
|
|
32454
32660
|
if (matchUpType && sourceCollectionDefinition.matchUpType !== matchUpType) {
|
|
32661
|
+
// TODO: updateTieFormat needs to support
|
|
32455
32662
|
// targetCollectionDefinition.matchUpType = matchUpType;
|
|
32456
32663
|
// modifications.push({ collectionId, matchUpType });
|
|
32457
32664
|
return decorateResult({
|
|
@@ -32469,8 +32676,8 @@ function modifyCollectionDefinition$1(_a) {
|
|
|
32469
32676
|
targetCollectionDefinition.gender = gender;
|
|
32470
32677
|
modifications.push({ collectionId: collectionId, gender: gender });
|
|
32471
32678
|
}
|
|
32472
|
-
var
|
|
32473
|
-
result = validateTieFormat({ tieFormat:
|
|
32679
|
+
var modifiedTieFormat = definedAttributes(tieFormat);
|
|
32680
|
+
result = validateTieFormat({ tieFormat: modifiedTieFormat });
|
|
32474
32681
|
if (result.error) {
|
|
32475
32682
|
return decorateResult({ result: result, stack: stack });
|
|
32476
32683
|
}
|
|
@@ -32482,15 +32689,15 @@ function modifyCollectionDefinition$1(_a) {
|
|
|
32482
32689
|
var changedTieFormatName = (existingTieFormat === null || existingTieFormat === void 0 ? void 0 : existingTieFormat.tieFormatName) !== tieFormatName;
|
|
32483
32690
|
// if tieFormat has changed, force renaming of the tieFormat
|
|
32484
32691
|
if (changedTieFormatName) {
|
|
32485
|
-
|
|
32692
|
+
modifiedTieFormat.tieFormatName = tieFormatName;
|
|
32486
32693
|
modifications.push({ tieFormatName: tieFormatName });
|
|
32487
32694
|
}
|
|
32488
32695
|
else if (modifications.length) {
|
|
32489
|
-
delete
|
|
32696
|
+
delete modifiedTieFormat.tieFormatName;
|
|
32490
32697
|
modifications.push('tieFormatName removed: modifications without new tieFormatName');
|
|
32491
32698
|
}
|
|
32492
32699
|
result = updateTieFormat({
|
|
32493
|
-
tieFormat:
|
|
32700
|
+
tieFormat: modifiedTieFormat,
|
|
32494
32701
|
updateInProgressMatchUps: updateInProgressMatchUps,
|
|
32495
32702
|
tournamentRecord: tournamentRecord,
|
|
32496
32703
|
drawDefinition: drawDefinition,
|
|
@@ -32745,8 +32952,8 @@ function orderCollectionDefinitions(params) {
|
|
|
32745
32952
|
// all child matchUps need to be checked for collectionAssignments which need to be removed when collectionDefinition.collectionIds are removed
|
|
32746
32953
|
function removeCollectionDefinition$1(_a) {
|
|
32747
32954
|
var e_1, _b, e_2, _c, e_3, _d;
|
|
32748
|
-
var _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
32749
|
-
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;
|
|
32750
32957
|
var stack = 'removeCollectionDefinition';
|
|
32751
32958
|
var result = !matchUp
|
|
32752
32959
|
? getTieFormat$1({
|
|
@@ -32784,7 +32991,7 @@ function removeCollectionDefinition$1(_a) {
|
|
|
32784
32991
|
}
|
|
32785
32992
|
// calculate new winCriteria for tieFormat
|
|
32786
32993
|
// if existing winCriteria is aggregateValue, retain
|
|
32787
|
-
var
|
|
32994
|
+
var _t = calculateWinCriteria(tieFormat), aggregateValue = _t.aggregateValue, valueGoal = _t.valueGoal;
|
|
32788
32995
|
tieFormat.winCriteria = definedAttributes({ aggregateValue: aggregateValue, valueGoal: valueGoal });
|
|
32789
32996
|
// if valueGoal has changed, force renaming of the tieFormat
|
|
32790
32997
|
var originalValueGoal = existingTieFormat === null || existingTieFormat === void 0 ? void 0 : existingTieFormat.winCriteria.valueGoal;
|
|
@@ -32805,24 +33012,24 @@ function removeCollectionDefinition$1(_a) {
|
|
|
32805
33012
|
}
|
|
32806
33013
|
else if (structureId && structure) {
|
|
32807
33014
|
matchUps =
|
|
32808
|
-
((_f = getAllStructureMatchUps({
|
|
33015
|
+
(_g = (_f = getAllStructureMatchUps({
|
|
32809
33016
|
matchUpFilters: { matchUpTypes: [TEAM$2] },
|
|
32810
33017
|
structure: structure,
|
|
32811
|
-
})) === null || _f === void 0 ? void 0 : _f.matchUps)
|
|
33018
|
+
})) === null || _f === void 0 ? void 0 : _f.matchUps) !== null && _g !== void 0 ? _g : [];
|
|
32812
33019
|
}
|
|
32813
33020
|
else if (drawDefinition) {
|
|
32814
33021
|
matchUps =
|
|
32815
|
-
((
|
|
33022
|
+
(_j = (_h = allDrawMatchUps$1({
|
|
32816
33023
|
matchUpFilters: { matchUpTypes: [TEAM$2] },
|
|
32817
33024
|
drawDefinition: drawDefinition,
|
|
32818
|
-
})) === null ||
|
|
33025
|
+
})) === null || _h === void 0 ? void 0 : _h.matchUps) !== null && _j !== void 0 ? _j : [];
|
|
32819
33026
|
}
|
|
32820
33027
|
else if (event) {
|
|
32821
33028
|
matchUps =
|
|
32822
|
-
((
|
|
33029
|
+
(_l = (_k = allEventMatchUps({
|
|
32823
33030
|
matchUpFilters: { matchUpTypes: [TEAM$2] },
|
|
32824
33031
|
drawDefinition: drawDefinition,
|
|
32825
|
-
})) === null ||
|
|
33032
|
+
})) === null || _k === void 0 ? void 0 : _k.matchUps) !== null && _l !== void 0 ? _l : [];
|
|
32826
33033
|
}
|
|
32827
33034
|
// all team matchUps in scope which are completed or which have a score should not be modified
|
|
32828
33035
|
// UNLESS all collectionMatchUps have no score
|
|
@@ -32848,10 +33055,10 @@ function removeCollectionDefinition$1(_a) {
|
|
|
32848
33055
|
return { error: NO_MODIFICATIONS_APPLIED };
|
|
32849
33056
|
}
|
|
32850
33057
|
if (matchUpId && matchUp && updateInProgressMatchUps) {
|
|
32851
|
-
var collectionMatchUps = (
|
|
33058
|
+
var collectionMatchUps = (_m = matchUp.tieMatchUps) === null || _m === void 0 ? void 0 : _m.filter(function (tieMatchUp) { return tieMatchUp.collectionId === collectionId; });
|
|
32852
33059
|
try {
|
|
32853
|
-
for (var
|
|
32854
|
-
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;
|
|
32855
33062
|
var result_1 = setMatchUpStatus$2({
|
|
32856
33063
|
matchUpId: collectionMatchUp.matchUpId,
|
|
32857
33064
|
tieMatchUpId: matchUp === null || matchUp === void 0 ? void 0 : matchUp.matchUpId,
|
|
@@ -32875,7 +33082,7 @@ function removeCollectionDefinition$1(_a) {
|
|
|
32875
33082
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
32876
33083
|
finally {
|
|
32877
33084
|
try {
|
|
32878
|
-
if (
|
|
33085
|
+
if (_v && !_v.done && (_b = _u.return)) _b.call(_u);
|
|
32879
33086
|
}
|
|
32880
33087
|
finally { if (e_1) throw e_1.error; }
|
|
32881
33088
|
}
|
|
@@ -32886,9 +33093,9 @@ function removeCollectionDefinition$1(_a) {
|
|
|
32886
33093
|
var matchUp_1 = targetMatchUps_1_1.value;
|
|
32887
33094
|
try {
|
|
32888
33095
|
// remove any collectionAssignments from LineUps that include collectionId
|
|
32889
|
-
for (var
|
|
32890
|
-
var side =
|
|
32891
|
-
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) {
|
|
32892
33099
|
var _a;
|
|
32893
33100
|
return ({
|
|
32894
33101
|
participantId: assignment.participantId,
|
|
@@ -32902,12 +33109,12 @@ function removeCollectionDefinition$1(_a) {
|
|
|
32902
33109
|
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
32903
33110
|
finally {
|
|
32904
33111
|
try {
|
|
32905
|
-
if (
|
|
33112
|
+
if (_x && !_x.done && (_d = _w.return)) _d.call(_w);
|
|
32906
33113
|
}
|
|
32907
33114
|
finally { if (e_3) throw e_3.error; }
|
|
32908
33115
|
}
|
|
32909
33116
|
// delete any tieMatchUps that contain collectionId
|
|
32910
|
-
matchUp_1.tieMatchUps = ((
|
|
33117
|
+
matchUp_1.tieMatchUps = ((_q = matchUp_1.tieMatchUps) !== null && _q !== void 0 ? _q : []).filter(function (matchUp) {
|
|
32911
33118
|
var deleteTarget = matchUp.collectionId === collectionId;
|
|
32912
33119
|
if (deleteTarget)
|
|
32913
33120
|
deletedMatchUpIds.push(matchUp.matchUpId);
|
|
@@ -32976,7 +33183,7 @@ function removeCollectionDefinition$1(_a) {
|
|
|
32976
33183
|
}
|
|
32977
33184
|
modifyDrawNotice({ drawDefinition: drawDefinition, eventId: event === null || event === void 0 ? void 0 : event.eventId });
|
|
32978
33185
|
var appliedPolicies = getAppliedPolicies({ tournamentRecord: tournamentRecord }).appliedPolicies;
|
|
32979
|
-
if ((
|
|
33186
|
+
if ((_r = appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies.audit) === null || _r === void 0 ? void 0 : _r[TIE_FORMAT_MODIFICATIONS]) {
|
|
32980
33187
|
var auditData = definedAttributes({
|
|
32981
33188
|
drawId: drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.drawId,
|
|
32982
33189
|
action: stack,
|
|
@@ -32994,37 +33201,6 @@ function removeCollectionDefinition(params) {
|
|
|
32994
33201
|
return resolveTournamentRecord(__assign(__assign({}, params), { method: removeCollectionDefinition$1 }));
|
|
32995
33202
|
}
|
|
32996
33203
|
|
|
32997
|
-
function generateTieMatchUps(_a) {
|
|
32998
|
-
var tieFormat = _a.tieFormat, isMock = _a.isMock, uuids = _a.uuids;
|
|
32999
|
-
var collectionDefinitions = (tieFormat || {}).collectionDefinitions;
|
|
33000
|
-
var tieMatchUps = (collectionDefinitions || [])
|
|
33001
|
-
.map(function (collectionDefinition) {
|
|
33002
|
-
return generateCollectionMatchUps({ collectionDefinition: collectionDefinition, uuids: uuids, isMock: isMock });
|
|
33003
|
-
})
|
|
33004
|
-
.filter(Boolean)
|
|
33005
|
-
.flat();
|
|
33006
|
-
return { tieMatchUps: tieMatchUps };
|
|
33007
|
-
}
|
|
33008
|
-
function generateCollectionMatchUps(_a) {
|
|
33009
|
-
var collectionDefinition = _a.collectionDefinition, matchUpsLimit = _a.matchUpsLimit, // internal use allows generation of missing matchUps on "reset"
|
|
33010
|
-
isMock = _a.isMock, uuids = _a.uuids;
|
|
33011
|
-
var _b = collectionDefinition || {}, matchUpCount = _b.matchUpCount, matchUpType = _b.matchUpType, collectionId = _b.collectionId, processCodes = _b.processCodes;
|
|
33012
|
-
var numberToGenerate = matchUpsLimit || matchUpCount || 0;
|
|
33013
|
-
return generateRange(0, numberToGenerate).map(function (index) {
|
|
33014
|
-
var collectionPosition = index + 1;
|
|
33015
|
-
return {
|
|
33016
|
-
sides: [{ sideNumber: 1 }, { sideNumber: 2 }],
|
|
33017
|
-
matchUpId: (uuids === null || uuids === void 0 ? void 0 : uuids.pop()) || UUID(),
|
|
33018
|
-
matchUpStatus: MatchUpStatusEnum.ToBePlayed,
|
|
33019
|
-
collectionPosition: collectionPosition,
|
|
33020
|
-
collectionId: collectionId,
|
|
33021
|
-
processCodes: processCodes,
|
|
33022
|
-
matchUpType: matchUpType,
|
|
33023
|
-
isMock: isMock,
|
|
33024
|
-
};
|
|
33025
|
-
});
|
|
33026
|
-
}
|
|
33027
|
-
|
|
33028
33204
|
function addCollectionDefinition$1(_a) {
|
|
33029
33205
|
var e_1, _b, e_2, _c, _d, e_3, _e;
|
|
33030
33206
|
var _f, _g, _h, _j, _k, _l, _m;
|
|
@@ -33214,7 +33390,7 @@ function addCollectionDefinition$1(_a) {
|
|
|
33214
33390
|
structure: structure_2,
|
|
33215
33391
|
uuids: uuids,
|
|
33216
33392
|
});
|
|
33217
|
-
modifiedStructureIds.push(structureId);
|
|
33393
|
+
modifiedStructureIds.push(structure_2.structureId);
|
|
33218
33394
|
addedMatchUps.push.apply(addedMatchUps, __spreadArray([], __read(result_3.newMatchUps), false));
|
|
33219
33395
|
targetMatchUps.push.apply(targetMatchUps, __spreadArray([], __read(result_3.targetMatchUps), false));
|
|
33220
33396
|
}
|
|
@@ -33314,122 +33490,6 @@ function addCollectionDefinition(params) {
|
|
|
33314
33490
|
return resolveTournamentRecord(__assign(__assign({}, params), { method: addCollectionDefinition$1 }));
|
|
33315
33491
|
}
|
|
33316
33492
|
|
|
33317
|
-
function publicFindMatchUp(params) {
|
|
33318
|
-
Object.assign(params, { inContext: true });
|
|
33319
|
-
var _a = findMatchUp(params), matchUp = _a.matchUp, error = _a.error;
|
|
33320
|
-
return { matchUp: makeDeepCopy(matchUp, true, true), error: error };
|
|
33321
|
-
}
|
|
33322
|
-
function findMatchUp(_a) {
|
|
33323
|
-
var _b;
|
|
33324
|
-
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;
|
|
33325
|
-
if (!tournamentRecord)
|
|
33326
|
-
return { error: MISSING_TOURNAMENT_RECORD };
|
|
33327
|
-
if (typeof matchUpId !== 'string')
|
|
33328
|
-
return { error: MISSING_MATCHUP_ID };
|
|
33329
|
-
if (!drawDefinition || !event) {
|
|
33330
|
-
var matchUps = allTournamentMatchUps({ tournamentRecord: tournamentRecord }).matchUps || [];
|
|
33331
|
-
var inContextMatchUp = matchUps.find(function (matchUp) { return matchUp.matchUpId === matchUpId; });
|
|
33332
|
-
if (!inContextMatchUp)
|
|
33333
|
-
return { error: MATCHUP_NOT_FOUND };
|
|
33334
|
-
// since drawEngineFindMatchUp is being used, additional context needs to be provided
|
|
33335
|
-
(eventId = inContextMatchUp.eventId, drawId = inContextMatchUp.drawId);
|
|
33336
|
-
(_b = findEvent({
|
|
33337
|
-
tournamentRecord: tournamentRecord,
|
|
33338
|
-
eventId: eventId,
|
|
33339
|
-
drawId: drawId,
|
|
33340
|
-
}), event = _b.event, drawDefinition = _b.drawDefinition);
|
|
33341
|
-
}
|
|
33342
|
-
if (!drawDefinition)
|
|
33343
|
-
return { error: DRAW_DEFINITION_NOT_FOUND };
|
|
33344
|
-
if (contextProfile && !contextContent)
|
|
33345
|
-
contextContent = getContextContent({ tournamentRecord: tournamentRecord, contextProfile: contextProfile });
|
|
33346
|
-
var additionalContext = {
|
|
33347
|
-
surfaceCategory: (event === null || event === void 0 ? void 0 : event.surfaceCategory) || tournamentRecord.surfaceCategory,
|
|
33348
|
-
indoorOutDoor: (event === null || event === void 0 ? void 0 : event.indoorOutdoor) || tournamentRecord.indoorOutdoor,
|
|
33349
|
-
endDate: (event === null || event === void 0 ? void 0 : event.endDate) || tournamentRecord.endDate,
|
|
33350
|
-
tournamentId: tournamentRecord.tournamentId,
|
|
33351
|
-
eventId: eventId || (event === null || event === void 0 ? void 0 : event.eventId),
|
|
33352
|
-
drawId: drawId,
|
|
33353
|
-
};
|
|
33354
|
-
var _c = hydrateParticipants({
|
|
33355
|
-
participantsProfile: participantsProfile,
|
|
33356
|
-
tournamentRecord: tournamentRecord,
|
|
33357
|
-
contextProfile: contextProfile,
|
|
33358
|
-
inContext: inContext,
|
|
33359
|
-
}).participants, tournamentParticipants = _c === void 0 ? [] : _c;
|
|
33360
|
-
var _d = findMatchUp$1({
|
|
33361
|
-
context: inContext ? additionalContext : undefined,
|
|
33362
|
-
tournamentParticipants: tournamentParticipants,
|
|
33363
|
-
afterRecoveryTimes: afterRecoveryTimes,
|
|
33364
|
-
contextContent: contextContent,
|
|
33365
|
-
drawDefinition: drawDefinition,
|
|
33366
|
-
contextProfile: contextProfile,
|
|
33367
|
-
matchUpId: matchUpId,
|
|
33368
|
-
inContext: inContext,
|
|
33369
|
-
event: event,
|
|
33370
|
-
}), matchUp = _d.matchUp, structure = _d.structure;
|
|
33371
|
-
return { matchUp: matchUp, structure: structure, drawDefinition: drawDefinition };
|
|
33372
|
-
}
|
|
33373
|
-
|
|
33374
|
-
function getTieFormat(_a) {
|
|
33375
|
-
var _b, _c, _d, _e, _f;
|
|
33376
|
-
var tournamentRecord = _a.tournamentRecord, // passed in automatically by tournamentEngine
|
|
33377
|
-
drawDefinition = _a.drawDefinition, // passed in automatically by tournamentEngine when drawId provided
|
|
33378
|
-
structureId = _a.structureId, // optional - if only the default matchUpFormat for a structure is required
|
|
33379
|
-
matchUpId = _a.matchUpId, // id of matchUp for which the scoped matchUpFormat(s) are desired
|
|
33380
|
-
structure = _a.structure, // optional optimization - when structure already known
|
|
33381
|
-
eventId = _a.eventId, // optional - if only the default matchUpFormat for an event is required
|
|
33382
|
-
drawId = _a.drawId, // avoid brute force search for matchUp
|
|
33383
|
-
event = _a.event;
|
|
33384
|
-
if (!tournamentRecord)
|
|
33385
|
-
return { error: MISSING_TOURNAMENT_RECORD };
|
|
33386
|
-
if (!drawId && !event && !structureId && !matchUpId)
|
|
33387
|
-
return decorateResult({
|
|
33388
|
-
result: { error: MISSING_VALUE },
|
|
33389
|
-
stack: 'getTieFormat',
|
|
33390
|
-
});
|
|
33391
|
-
if (eventId && !event) {
|
|
33392
|
-
event = (_b = tournamentRecord.events) === null || _b === void 0 ? void 0 : _b.find(function (event) { return event.eventId === eventId; });
|
|
33393
|
-
}
|
|
33394
|
-
var matchUpResult = findMatchUp({
|
|
33395
|
-
tournamentRecord: tournamentRecord,
|
|
33396
|
-
drawDefinition: drawDefinition,
|
|
33397
|
-
matchUpId: matchUpId,
|
|
33398
|
-
drawId: drawId,
|
|
33399
|
-
event: event,
|
|
33400
|
-
});
|
|
33401
|
-
if (matchUpId && (matchUpResult === null || matchUpResult === void 0 ? void 0 : matchUpResult.error)) {
|
|
33402
|
-
return matchUpResult;
|
|
33403
|
-
}
|
|
33404
|
-
else if (!drawDefinition && (matchUpResult === null || matchUpResult === void 0 ? void 0 : matchUpResult.drawDefinition)) {
|
|
33405
|
-
drawDefinition = matchUpResult === null || matchUpResult === void 0 ? void 0 : matchUpResult.drawDefinition;
|
|
33406
|
-
}
|
|
33407
|
-
structure = structure !== null && structure !== void 0 ? structure : matchUpResult === null || matchUpResult === void 0 ? void 0 : matchUpResult.structure;
|
|
33408
|
-
if (!structure && structureId && !matchUpId) {
|
|
33409
|
-
if (!drawDefinition)
|
|
33410
|
-
return { error: MISSING_DRAW_ID };
|
|
33411
|
-
var structureResult = findStructure({ drawDefinition: drawDefinition, structureId: structureId });
|
|
33412
|
-
if (structureResult.error)
|
|
33413
|
-
return structureResult;
|
|
33414
|
-
structure = structureResult.structure;
|
|
33415
|
-
}
|
|
33416
|
-
var structureDefaultTieFormat = ((structure === null || structure === void 0 ? void 0 : structure.tieFormat) || (structure === null || structure === void 0 ? void 0 : structure.tieFormatId)) &&
|
|
33417
|
-
((_c = resolveTieFormat({ structure: structure, drawDefinition: drawDefinition, event: event })) === null || _c === void 0 ? void 0 : _c.tieFormat);
|
|
33418
|
-
var drawDefaultTieFormat = ((drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.tieFormat) || (drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.tieFormatId)) &&
|
|
33419
|
-
((_d = resolveTieFormat({
|
|
33420
|
-
drawDefinition: drawDefinition,
|
|
33421
|
-
event: event,
|
|
33422
|
-
})) === null || _d === void 0 ? void 0 : _d.tieFormat);
|
|
33423
|
-
var eventDefaultTieFormat = (_e = resolveTieFormat({ event: event })) === null || _e === void 0 ? void 0 : _e.tieFormat;
|
|
33424
|
-
var tieFormat = (_f = resolveTieFormat({
|
|
33425
|
-
matchUp: matchUpResult === null || matchUpResult === void 0 ? void 0 : matchUpResult.matchUp,
|
|
33426
|
-
drawDefinition: drawDefinition,
|
|
33427
|
-
structure: structure,
|
|
33428
|
-
event: event,
|
|
33429
|
-
})) === null || _f === void 0 ? void 0 : _f.tieFormat;
|
|
33430
|
-
return __assign(__assign({}, SUCCESS), { matchUp: matchUpResult === null || matchUpResult === void 0 ? void 0 : matchUpResult.matchUp, structureDefaultTieFormat: structureDefaultTieFormat, eventDefaultTieFormat: eventDefaultTieFormat, drawDefaultTieFormat: drawDefaultTieFormat, tieFormat: tieFormat, structure: structure });
|
|
33431
|
-
}
|
|
33432
|
-
|
|
33433
33493
|
function updateTargetTeamMatchUps(_a) {
|
|
33434
33494
|
var e_1, _b;
|
|
33435
33495
|
var updateInProgressMatchUps = _a.updateInProgressMatchUps, tournamentRecord = _a.tournamentRecord, drawDefinition = _a.drawDefinition, targetMatchUps = _a.targetMatchUps, tieFormat = _a.tieFormat, event = _a.event;
|
|
@@ -33574,8 +33634,7 @@ function removeCollectionGroup$1(_a) {
|
|
|
33574
33634
|
return { error: INVALID_VALUES };
|
|
33575
33635
|
var stack = 'removeCollectionGroup';
|
|
33576
33636
|
var result = !matchUp
|
|
33577
|
-
? getTieFormat({
|
|
33578
|
-
tournamentRecord: tournamentRecord,
|
|
33637
|
+
? getTieFormat$1({
|
|
33579
33638
|
drawDefinition: drawDefinition,
|
|
33580
33639
|
structureId: structureId,
|
|
33581
33640
|
matchUpId: matchUpId,
|
|
@@ -33737,11 +33796,15 @@ function addCollectionGroup(params) {
|
|
|
33737
33796
|
|
|
33738
33797
|
function modifyTieFormat$1(_a) {
|
|
33739
33798
|
var e_1, _b, e_2, _c, e_3, _d;
|
|
33740
|
-
var _e;
|
|
33741
|
-
var _f = _a.updateInProgressMatchUps, updateInProgressMatchUps = _f === void 0 ? false : _f, 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;
|
|
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;
|
|
33742
33800
|
var stack = 'updateTieFormat';
|
|
33743
|
-
if (!validateTieFormat(modifiedTieFormat))
|
|
33744
|
-
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
|
+
}
|
|
33745
33808
|
var result = getTieFormat$1({
|
|
33746
33809
|
drawDefinition: drawDefinition,
|
|
33747
33810
|
structureId: structureId,
|
|
@@ -33753,8 +33816,18 @@ function modifyTieFormat$1(_a) {
|
|
|
33753
33816
|
return decorateResult({ result: result, stack: stack });
|
|
33754
33817
|
var matchUp = result.matchUp, existingTieFormat = result.tieFormat;
|
|
33755
33818
|
var tieFormat = copyTieFormat(existingTieFormat);
|
|
33756
|
-
|
|
33757
|
-
|
|
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' });
|
|
33758
33831
|
}
|
|
33759
33832
|
var existingCollectionIds = tieFormat.collectionDefinitions.map(function (_a) {
|
|
33760
33833
|
var collectionId = _a.collectionId;
|
|
@@ -33769,14 +33842,17 @@ function modifyTieFormat$1(_a) {
|
|
|
33769
33842
|
var collectionId = _a.collectionId;
|
|
33770
33843
|
return !existingCollectionIds.includes(collectionId);
|
|
33771
33844
|
});
|
|
33845
|
+
var addedCollectionIds = addedCollectionDefinitions.map(extractAttributes('collectionId'));
|
|
33772
33846
|
var modifications = [];
|
|
33773
33847
|
var processedTieFormat;
|
|
33848
|
+
var tieFormatName = modifiedTieFormat.tieFormatName;
|
|
33774
33849
|
try {
|
|
33775
|
-
// TODO: if matchUpCount is changing pre-check for cmopleted tieMatchUps
|
|
33776
33850
|
// TODO: if gender is changing pre-check for misgendered collectionAssignments
|
|
33777
|
-
for (var
|
|
33778
|
-
var collectionDefinition =
|
|
33779
|
-
|
|
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 }));
|
|
33780
33856
|
if (result_1.modifications)
|
|
33781
33857
|
modifications.push.apply(modifications, __spreadArray([], __read(result_1.modifications), false));
|
|
33782
33858
|
if (result_1.error)
|
|
@@ -33788,11 +33864,10 @@ function modifyTieFormat$1(_a) {
|
|
|
33788
33864
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
33789
33865
|
finally {
|
|
33790
33866
|
try {
|
|
33791
|
-
if (
|
|
33867
|
+
if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
|
|
33792
33868
|
}
|
|
33793
33869
|
finally { if (e_1) throw e_1.error; }
|
|
33794
33870
|
}
|
|
33795
|
-
var tieFormatName = modifiedTieFormat.tieFormatName;
|
|
33796
33871
|
try {
|
|
33797
33872
|
for (var addedCollectionDefinitions_1 = __values(addedCollectionDefinitions), addedCollectionDefinitions_1_1 = addedCollectionDefinitions_1.next(); !addedCollectionDefinitions_1_1.done; addedCollectionDefinitions_1_1 = addedCollectionDefinitions_1.next()) {
|
|
33798
33873
|
var collectionDefinition = addedCollectionDefinitions_1_1.value;
|
|
@@ -33857,7 +33932,9 @@ function modifyTieFormat$1(_a) {
|
|
|
33857
33932
|
processedTieFormat.tieFormatName = tieFormatName;
|
|
33858
33933
|
modifications.push({ tieFormatName: tieFormatName });
|
|
33859
33934
|
}
|
|
33860
|
-
else if (modifications.length
|
|
33935
|
+
else if (modifications.length ||
|
|
33936
|
+
addedCollectionIds.length ||
|
|
33937
|
+
removedCollectionIds.length) {
|
|
33861
33938
|
delete processedTieFormat.tieFormatName;
|
|
33862
33939
|
modifications.push('tieFormatName removed: modifications without new tieFormatName');
|
|
33863
33940
|
}
|
|
@@ -33868,13 +33945,71 @@ function modifyTieFormat$1(_a) {
|
|
|
33868
33945
|
numericSortValue(b.collectionOrder);
|
|
33869
33946
|
})
|
|
33870
33947
|
.map(function (def, i) { return (__assign(__assign({}, def), { collectionOrder: i + 1 })); });
|
|
33871
|
-
return __assign(
|
|
33948
|
+
return __assign({ processedTieFormat: copyTieFormat(processedTieFormat), modifications: modifications }, SUCCESS);
|
|
33872
33949
|
}
|
|
33873
33950
|
|
|
33874
33951
|
function modifyTieFormat(params) {
|
|
33875
33952
|
return resolveTournamentRecord(__assign(__assign({}, params), { method: modifyTieFormat$1 }));
|
|
33876
33953
|
}
|
|
33877
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
|
+
|
|
33878
34013
|
function resetTieFormat$1(_a) {
|
|
33879
34014
|
var e_1, _b, e_2, _c;
|
|
33880
34015
|
var _d;
|
|
@@ -50721,10 +50856,6 @@ function removeDelegatedOutcome$1(_a) {
|
|
|
50721
50856
|
});
|
|
50722
50857
|
}
|
|
50723
50858
|
|
|
50724
|
-
function stringSort(a, b) {
|
|
50725
|
-
return (a || '').localeCompare(b || '');
|
|
50726
|
-
}
|
|
50727
|
-
|
|
50728
50859
|
function generateCandidate(_a) {
|
|
50729
50860
|
var _b = _a.maxIterations, maxIterations = _b === void 0 ? 4000 : _b, // cap the processing intensity of the candidate generator
|
|
50730
50861
|
valueSortedPairings = _a.valueSortedPairings, // pairings sorted by value from low to high
|
|
@@ -64066,6 +64197,65 @@ function getParticipantSignInStatus(_a) {
|
|
|
64066
64197
|
return timeItem && timeItem.itemValue === SIGNED_IN && SIGNED_IN;
|
|
64067
64198
|
}
|
|
64068
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
|
+
|
|
64069
64259
|
function getEventProperties(_a) {
|
|
64070
64260
|
var _b, _c;
|
|
64071
64261
|
var tournamentRecord = _a.tournamentRecord, event = _a.event;
|