tods-competition-factory 0.96.0 → 0.98.2
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/tods-competition-factory.development.cjs.js +129 -80
- 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/dist/tods-competition-factory.production.esm.min.js +1 -1
- package/dist/tods-competition-factory.production.esm.min.js.map +1 -1
- package/package.json +4 -4
|
@@ -249,7 +249,7 @@ const matchUpFormatCode = {
|
|
|
249
249
|
};
|
|
250
250
|
|
|
251
251
|
function factoryVersion() {
|
|
252
|
-
return '0.
|
|
252
|
+
return '0.98.2';
|
|
253
253
|
}
|
|
254
254
|
|
|
255
255
|
const FORMAT_STANDARD = 'SET3-S:6/TB7'; // Best of 3 Tiebreak Sets to 6
|
|
@@ -3920,8 +3920,9 @@ function generateTieMatchUpScore({
|
|
|
3920
3920
|
sideWins: [0, 0],
|
|
3921
3921
|
values: [0, 0]
|
|
3922
3922
|
}
|
|
3923
|
-
})));
|
|
3924
|
-
|
|
3923
|
+
}))); // must be coerced to numbers
|
|
3924
|
+
|
|
3925
|
+
const groupValueNumbers = Object.keys(groupValueGroups).map(num => parseInt(num));
|
|
3925
3926
|
|
|
3926
3927
|
for (const collectionDefinition of collectionDefinitions) {
|
|
3927
3928
|
const collectionMatchUps = tieMatchUps.filter(matchUp => matchUp.collectionId === collectionDefinition.collectionId); // keep track of the values derived from matchUps
|
|
@@ -20739,8 +20740,10 @@ function swapWinnerLoser(params) {
|
|
|
20739
20740
|
function setMatchUpStatus$2(params) {
|
|
20740
20741
|
var _inContextMatchUp$dra, _matchUp$sides;
|
|
20741
20742
|
|
|
20742
|
-
//
|
|
20743
|
+
// always clear score if DOUBLE_WALKOVER or WALKOVER
|
|
20744
|
+
if ([WALKOVER$1, DOUBLE_WALKOVER].includes(params.matchUpStatus)) params.score = undefined; // matchUpStatus in params is the new status
|
|
20743
20745
|
// winningSide in params is new winningSide
|
|
20746
|
+
|
|
20744
20747
|
const {
|
|
20745
20748
|
allowChangePropagation = undefined,
|
|
20746
20749
|
// factory default
|
|
@@ -33557,7 +33560,6 @@ function generateVoluntaryConsolationStructure$1({
|
|
|
33557
33560
|
drawSize,
|
|
33558
33561
|
event
|
|
33559
33562
|
}) {
|
|
33560
|
-
const stage = VOLUNTARY_CONSOLATION;
|
|
33561
33563
|
if (!drawDefinition) return {
|
|
33562
33564
|
error: MISSING_DRAW_DEFINITION
|
|
33563
33565
|
};
|
|
@@ -33568,13 +33570,14 @@ function generateVoluntaryConsolationStructure$1({
|
|
|
33568
33570
|
matchUpType,
|
|
33569
33571
|
drawSize
|
|
33570
33572
|
});
|
|
33573
|
+
const stage = VOLUNTARY_CONSOLATION;
|
|
33571
33574
|
const structure = structureTemplate({
|
|
33572
|
-
stage,
|
|
33573
|
-
matchUps,
|
|
33574
|
-
matchUpType,
|
|
33575
|
-
structureName,
|
|
33576
33575
|
structureAbbreviation,
|
|
33577
|
-
|
|
33576
|
+
structureName,
|
|
33577
|
+
structureId,
|
|
33578
|
+
matchUpType,
|
|
33579
|
+
matchUps,
|
|
33580
|
+
stage
|
|
33578
33581
|
});
|
|
33579
33582
|
drawDefinition.structures.push(structure);
|
|
33580
33583
|
|
|
@@ -47200,6 +47203,94 @@ function generateVoluntaryConsolationStructure(params) {
|
|
|
47200
47203
|
});
|
|
47201
47204
|
}
|
|
47202
47205
|
|
|
47206
|
+
/**
|
|
47207
|
+
*
|
|
47208
|
+
* @param {object} orderedDrawIdsMap - required - mapping of ALL present drawIds => { [drawId]: drawOrder }
|
|
47209
|
+
*/
|
|
47210
|
+
|
|
47211
|
+
function updateDrawIdsOrder({
|
|
47212
|
+
event,
|
|
47213
|
+
orderedDrawIdsMap
|
|
47214
|
+
}) {
|
|
47215
|
+
var _event$drawDefinition, _flightProfile$flight;
|
|
47216
|
+
|
|
47217
|
+
if (typeof event !== 'object') return {
|
|
47218
|
+
error: MISSING_EVENT
|
|
47219
|
+
};
|
|
47220
|
+
if (!orderedDrawIdsMap) return {
|
|
47221
|
+
error: MISSING_VALUE,
|
|
47222
|
+
message: 'Missing drawIdsOrderMap'
|
|
47223
|
+
};
|
|
47224
|
+
if (typeof orderedDrawIdsMap !== 'object') return {
|
|
47225
|
+
error: INVALID_VALUES,
|
|
47226
|
+
message: 'orderedDrawIdsMap must be an object'
|
|
47227
|
+
};
|
|
47228
|
+
const drawOrders = Object.values(orderedDrawIdsMap);
|
|
47229
|
+
const validDrawOrders = drawOrders.every(drawOrder => !isNaN(drawOrder));
|
|
47230
|
+
if (!validDrawOrders) return {
|
|
47231
|
+
error: INVALID_VALUES,
|
|
47232
|
+
message: 'drawOrder must be numeric'
|
|
47233
|
+
};
|
|
47234
|
+
if (unique(drawOrders).length !== drawOrders.length) return {
|
|
47235
|
+
error: INVALID_VALUES,
|
|
47236
|
+
message: 'drawOrder values must be unique'
|
|
47237
|
+
};
|
|
47238
|
+
|
|
47239
|
+
if ((_event$drawDefinition = event.drawDefinitions) !== null && _event$drawDefinition !== void 0 && _event$drawDefinition.length) {
|
|
47240
|
+
const drawIds = (event.drawDefinitions || []).map(({
|
|
47241
|
+
drawId
|
|
47242
|
+
}) => drawId);
|
|
47243
|
+
const orderedDrawIds = Object.keys(orderedDrawIdsMap);
|
|
47244
|
+
if (intersection(drawIds, orderedDrawIds).length !== drawIds.length) return {
|
|
47245
|
+
error: INVALID_VALUES,
|
|
47246
|
+
message: 'Missing drawIds'
|
|
47247
|
+
};
|
|
47248
|
+
event.drawDefinitions.forEach(drawDefinition => {
|
|
47249
|
+
drawDefinition.drawOrder = orderedDrawIdsMap[drawDefinition.drawId];
|
|
47250
|
+
});
|
|
47251
|
+
}
|
|
47252
|
+
|
|
47253
|
+
const {
|
|
47254
|
+
flightProfile
|
|
47255
|
+
} = getFlightProfile({
|
|
47256
|
+
event
|
|
47257
|
+
});
|
|
47258
|
+
flightProfile === null || flightProfile === void 0 ? void 0 : (_flightProfile$flight = flightProfile.flights) === null || _flightProfile$flight === void 0 ? void 0 : _flightProfile$flight.forEach(flight => {
|
|
47259
|
+
flight.flightNumber = orderedDrawIdsMap[flight.drawId];
|
|
47260
|
+
});
|
|
47261
|
+
return SUCCESS;
|
|
47262
|
+
}
|
|
47263
|
+
|
|
47264
|
+
function refreshEventDrawOrder({
|
|
47265
|
+
tournamentRecord,
|
|
47266
|
+
event
|
|
47267
|
+
}) {
|
|
47268
|
+
var _event$drawDefinition;
|
|
47269
|
+
|
|
47270
|
+
if (!tournamentRecord) return {
|
|
47271
|
+
error: MISSING_TOURNAMENT_RECORD
|
|
47272
|
+
};
|
|
47273
|
+
if (!event) return {
|
|
47274
|
+
error: MISSING_EVENT
|
|
47275
|
+
};
|
|
47276
|
+
const {
|
|
47277
|
+
flightProfile
|
|
47278
|
+
} = getFlightProfile({
|
|
47279
|
+
event
|
|
47280
|
+
}); // if there is a flightProfile, derive order from that, otherwise use drawDefinitions array
|
|
47281
|
+
|
|
47282
|
+
const orderedDrawIdsMap = flightProfile !== null && flightProfile !== void 0 && flightProfile.flights ? Object.assign({}, ...flightProfile.flights.sort((a, b) => a.flightNumber - b.flightNumber).map((flight, i) => ({
|
|
47283
|
+
[flight.drawId]: i + 1
|
|
47284
|
+
}))) : (_event$drawDefinition = event.drawDefinitions) !== null && _event$drawDefinition !== void 0 && _event$drawDefinition.length ? Object.assign({}, ...event.drawDefinitions.sort((a, b) => a.drawOrder - b.drawOrder).map((drawDefinition, i) => ({
|
|
47285
|
+
[drawDefinition.drawId]: i + 1
|
|
47286
|
+
}))) : undefined;
|
|
47287
|
+
return orderedDrawIdsMap ? updateDrawIdsOrder({
|
|
47288
|
+
event,
|
|
47289
|
+
orderedDrawIdsMap
|
|
47290
|
+
}) : { ...SUCCESS
|
|
47291
|
+
};
|
|
47292
|
+
}
|
|
47293
|
+
|
|
47203
47294
|
function deleteFlightAndFlightDraw({
|
|
47204
47295
|
tournamentRecord,
|
|
47205
47296
|
event,
|
|
@@ -47247,7 +47338,10 @@ function deleteFlightAndFlightDraw({
|
|
|
47247
47338
|
drawIds: [drawId],
|
|
47248
47339
|
auditData
|
|
47249
47340
|
});
|
|
47250
|
-
return
|
|
47341
|
+
return refreshEventDrawOrder({
|
|
47342
|
+
tournamentRecord,
|
|
47343
|
+
event
|
|
47344
|
+
});
|
|
47251
47345
|
}
|
|
47252
47346
|
|
|
47253
47347
|
function generateAdHocMatchUps(params) {
|
|
@@ -47636,64 +47730,6 @@ function pruneDrawDefinition({
|
|
|
47636
47730
|
};
|
|
47637
47731
|
}
|
|
47638
47732
|
|
|
47639
|
-
/**
|
|
47640
|
-
*
|
|
47641
|
-
* @param {object} orderedDrawIdsMap - required - mapping of ALL present drawIds => { [drawId]: drawOrder }
|
|
47642
|
-
*/
|
|
47643
|
-
|
|
47644
|
-
function updateDrawIdsOrder({
|
|
47645
|
-
event,
|
|
47646
|
-
orderedDrawIdsMap
|
|
47647
|
-
}) {
|
|
47648
|
-
var _event$drawDefinition, _flightProfile$flight;
|
|
47649
|
-
|
|
47650
|
-
if (typeof event !== 'object') return {
|
|
47651
|
-
error: MISSING_EVENT
|
|
47652
|
-
};
|
|
47653
|
-
if (!orderedDrawIdsMap) return {
|
|
47654
|
-
error: MISSING_VALUE,
|
|
47655
|
-
message: 'Missing drawIdsOrderMap'
|
|
47656
|
-
};
|
|
47657
|
-
if (typeof orderedDrawIdsMap !== 'object') return {
|
|
47658
|
-
error: INVALID_VALUES,
|
|
47659
|
-
message: 'orderedDrawIdsMap must be an object'
|
|
47660
|
-
};
|
|
47661
|
-
const drawOrders = Object.values(orderedDrawIdsMap);
|
|
47662
|
-
const validDrawOrders = drawOrders.every(drawOrder => !isNaN(drawOrder));
|
|
47663
|
-
if (!validDrawOrders) return {
|
|
47664
|
-
error: INVALID_VALUES,
|
|
47665
|
-
message: 'drawOrder must be numeric'
|
|
47666
|
-
};
|
|
47667
|
-
if (unique(drawOrders).length !== drawOrders.length) return {
|
|
47668
|
-
error: INVALID_VALUES,
|
|
47669
|
-
message: 'drawOrder values must be unique'
|
|
47670
|
-
};
|
|
47671
|
-
|
|
47672
|
-
if ((_event$drawDefinition = event.drawDefinitions) !== null && _event$drawDefinition !== void 0 && _event$drawDefinition.length) {
|
|
47673
|
-
const drawIds = (event.drawDefinitions || []).map(({
|
|
47674
|
-
drawId
|
|
47675
|
-
}) => drawId);
|
|
47676
|
-
const orderedDrawIds = Object.keys(orderedDrawIdsMap);
|
|
47677
|
-
if (intersection(drawIds, orderedDrawIds).length !== drawIds.length) return {
|
|
47678
|
-
error: INVALID_VALUES,
|
|
47679
|
-
message: 'Missing drawIds'
|
|
47680
|
-
};
|
|
47681
|
-
event.drawDefinitions.forEach(drawDefinition => {
|
|
47682
|
-
drawDefinition.drawOrder = orderedDrawIdsMap[drawDefinition.drawId];
|
|
47683
|
-
});
|
|
47684
|
-
}
|
|
47685
|
-
|
|
47686
|
-
const {
|
|
47687
|
-
flightProfile
|
|
47688
|
-
} = getFlightProfile({
|
|
47689
|
-
event
|
|
47690
|
-
});
|
|
47691
|
-
flightProfile === null || flightProfile === void 0 ? void 0 : (_flightProfile$flight = flightProfile.flights) === null || _flightProfile$flight === void 0 ? void 0 : _flightProfile$flight.forEach(flight => {
|
|
47692
|
-
flight.flightNumber = orderedDrawIdsMap[flight.drawId];
|
|
47693
|
-
});
|
|
47694
|
-
return SUCCESS;
|
|
47695
|
-
}
|
|
47696
|
-
|
|
47697
47733
|
function setOrderOfFinish(params) {
|
|
47698
47734
|
return setOrderOfFinish$1(params);
|
|
47699
47735
|
}
|
|
@@ -48084,6 +48120,7 @@ const eventGovernor = {
|
|
|
48084
48120
|
deleteFlightProfileAndFlightDraws,
|
|
48085
48121
|
deleteFlightAndFlightDraw,
|
|
48086
48122
|
generateFlightProfile,
|
|
48123
|
+
refreshEventDrawOrder,
|
|
48087
48124
|
attachFlightProfile,
|
|
48088
48125
|
resetDrawDefinition,
|
|
48089
48126
|
pruneDrawDefinition,
|
|
@@ -53179,33 +53216,45 @@ function genParticipantId({
|
|
|
53179
53216
|
}
|
|
53180
53217
|
|
|
53181
53218
|
function processTieFormat({
|
|
53182
|
-
|
|
53219
|
+
alternatesCount = 0,
|
|
53183
53220
|
tieFormatName,
|
|
53184
|
-
|
|
53185
|
-
|
|
53221
|
+
tieFormat,
|
|
53222
|
+
drawSize
|
|
53186
53223
|
}) {
|
|
53187
53224
|
var _tieFormat, _tieFormat$collection;
|
|
53188
53225
|
|
|
53189
53226
|
let maxDoublesCount = 0,
|
|
53190
53227
|
maxSinglesCount = 0;
|
|
53228
|
+
let singlesMatchUpTotal = 0,
|
|
53229
|
+
doublesMatchUpTotal = 0;
|
|
53230
|
+
let categories = 0;
|
|
53191
53231
|
tieFormat = typeof tieFormat === 'object' ? tieFormat : tieFormatDefaults({
|
|
53192
53232
|
namedFormat: tieFormatName
|
|
53193
53233
|
});
|
|
53194
|
-
(_tieFormat = tieFormat) === null || _tieFormat === void 0 ? void 0 : (_tieFormat$collection = _tieFormat.collectionDefinitions) === null || _tieFormat$collection === void 0 ? void 0 : _tieFormat$collection.forEach(collectionDefinition => {
|
|
53195
|
-
|
|
53196
|
-
|
|
53234
|
+
(_tieFormat = tieFormat) === null || _tieFormat === void 0 ? void 0 : (_tieFormat$collection = _tieFormat.collectionDefinitions) === null || _tieFormat$collection === void 0 ? void 0 : _tieFormat$collection.filter(Boolean).forEach(collectionDefinition => {
|
|
53235
|
+
const {
|
|
53236
|
+
category,
|
|
53237
|
+
collectionId,
|
|
53238
|
+
matchUpType,
|
|
53239
|
+
matchUpCount
|
|
53240
|
+
} = collectionDefinition;
|
|
53241
|
+
if (category) categories += 1; // ensure every collectionDefinition has a collectionId
|
|
53242
|
+
|
|
53243
|
+
if (!collectionId) collectionDefinition.collectionId = UUID();
|
|
53197
53244
|
|
|
53198
|
-
if (
|
|
53199
|
-
const doublesCount =
|
|
53245
|
+
if (matchUpType === DOUBLES$1) {
|
|
53246
|
+
const doublesCount = matchUpCount;
|
|
53247
|
+
doublesMatchUpTotal += matchUpCount;
|
|
53200
53248
|
maxDoublesCount = Math.max(maxDoublesCount, doublesCount);
|
|
53201
53249
|
}
|
|
53202
53250
|
|
|
53203
|
-
if (
|
|
53204
|
-
const singlescount =
|
|
53251
|
+
if (matchUpType === SINGLES$1) {
|
|
53252
|
+
const singlescount = matchUpCount;
|
|
53253
|
+
singlesMatchUpTotal += matchUpCount;
|
|
53205
53254
|
maxSinglesCount = Math.max(maxSinglesCount, singlescount);
|
|
53206
53255
|
}
|
|
53207
53256
|
});
|
|
53208
|
-
const teamSize = Math.max(maxSinglesCount, maxDoublesCount * 2);
|
|
53257
|
+
const teamSize = categories ? Math.max(singlesMatchUpTotal, doublesMatchUpTotal * 2) : Math.max(maxSinglesCount, maxDoublesCount * 2);
|
|
53209
53258
|
const maxDoublesDraw = maxDoublesCount * (drawSize + alternatesCount);
|
|
53210
53259
|
const maxSinglesDraw = maxSinglesCount * (drawSize + alternatesCount);
|
|
53211
53260
|
return {
|