tods-competition-factory 2.0.0-alpha.0 → 2.0.0-beta.0
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/README.md +2 -14
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/tods-competition-factory.d.ts +371 -153
- package/dist/tods-competition-factory.development.cjs.js +1554 -1317
- 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 +10 -7
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
function factoryVersion() {
|
|
6
|
-
return '2.0.0-
|
|
6
|
+
return '2.0.0-beta.0';
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
/******************************************************************************
|
|
@@ -1651,6 +1651,67 @@ function getDevContext(contextCriteria) {
|
|
|
1651
1651
|
return (Object.keys(contextCriteria).every(function (key) { var _a; return ((_a = globalState.devContext) === null || _a === void 0 ? void 0 : _a[key]) === contextCriteria[key]; }) && globalState.devContext);
|
|
1652
1652
|
}
|
|
1653
1653
|
}
|
|
1654
|
+
function timeKeeper(action, timer) {
|
|
1655
|
+
var _a, _b, _c, _d;
|
|
1656
|
+
if (action === void 0) { action = 'reset'; }
|
|
1657
|
+
if (timer === void 0) { timer = 'default'; }
|
|
1658
|
+
var timeNow = Date.now();
|
|
1659
|
+
if (action === 'report') {
|
|
1660
|
+
if (timer === 'allTimers') {
|
|
1661
|
+
var timers = Object.keys(globalState.timers);
|
|
1662
|
+
return timers
|
|
1663
|
+
.filter(function (timer) { return timer !== 'default' || globalState.timers[timer].startTime; })
|
|
1664
|
+
.map(function (timer) {
|
|
1665
|
+
var _a;
|
|
1666
|
+
var currentTimer = globalState.timers[timer];
|
|
1667
|
+
var elapsedPeriod = currentTimer.state === 'stopped'
|
|
1668
|
+
? 0
|
|
1669
|
+
: (timeNow - ((_a = currentTimer === null || currentTimer === void 0 ? void 0 : currentTimer.startTime) !== null && _a !== void 0 ? _a : 0)) / 1000;
|
|
1670
|
+
var elapsedTime = currentTimer.elapsedTime + elapsedPeriod;
|
|
1671
|
+
return {
|
|
1672
|
+
state: globalState.timers[timer].state,
|
|
1673
|
+
elapsedTime: elapsedTime.toFixed(2),
|
|
1674
|
+
timer: timer,
|
|
1675
|
+
};
|
|
1676
|
+
});
|
|
1677
|
+
}
|
|
1678
|
+
else {
|
|
1679
|
+
var elapsedPeriod = globalState.timers[timer].state === 'stopped'
|
|
1680
|
+
? 0
|
|
1681
|
+
: (timeNow - ((_b = (_a = globalState.timers[timer]) === null || _a === void 0 ? void 0 : _a.startTime) !== null && _b !== void 0 ? _b : 0)) / 1000;
|
|
1682
|
+
var elapsedTime = globalState.timers[timer].elapsedTime + elapsedPeriod;
|
|
1683
|
+
return {
|
|
1684
|
+
state: globalState.timers[timer].state,
|
|
1685
|
+
elapsedTime: elapsedTime.toFixed(2),
|
|
1686
|
+
timer: timer,
|
|
1687
|
+
};
|
|
1688
|
+
}
|
|
1689
|
+
}
|
|
1690
|
+
if (!globalState.timers[timer] || action === 'reset') {
|
|
1691
|
+
if (timer === 'allTimers') {
|
|
1692
|
+
globalState.timers = { default: { elapsedTime: 0 } };
|
|
1693
|
+
return true;
|
|
1694
|
+
}
|
|
1695
|
+
else {
|
|
1696
|
+
globalState.timers[timer] = {
|
|
1697
|
+
startTime: timeNow,
|
|
1698
|
+
state: 'active',
|
|
1699
|
+
elapsedTime: 0,
|
|
1700
|
+
};
|
|
1701
|
+
}
|
|
1702
|
+
}
|
|
1703
|
+
if (!globalState.timers[timer].elapsedTime)
|
|
1704
|
+
globalState.timers[timer].elapsedTime = 0;
|
|
1705
|
+
action === 'stop' &&
|
|
1706
|
+
globalState.timers[timer].state !== 'stopped' &&
|
|
1707
|
+
(globalState.timers[timer].state = 'stopped') &&
|
|
1708
|
+
(globalState.timers[timer].elapsedTime +=
|
|
1709
|
+
(timeNow - ((_d = (_c = globalState.timers[timer]) === null || _c === void 0 ? void 0 : _c.startTime) !== null && _d !== void 0 ? _d : 0)) / 1000);
|
|
1710
|
+
action === 'start' &&
|
|
1711
|
+
(globalState.timers[timer].startTime = timeNow) &&
|
|
1712
|
+
(globalState.timers[timer].state = 'active');
|
|
1713
|
+
return globalState.timers[timer];
|
|
1714
|
+
}
|
|
1654
1715
|
function setGlobalLog(loggingFx) {
|
|
1655
1716
|
if (typeof loggingFx === 'function') {
|
|
1656
1717
|
globalState.globalLog = loggingFx;
|
|
@@ -1781,6 +1842,40 @@ function globalLog$1(engine, log) {
|
|
|
1781
1842
|
}
|
|
1782
1843
|
}
|
|
1783
1844
|
|
|
1845
|
+
var globalState$1 = {
|
|
1846
|
+
__proto__: null,
|
|
1847
|
+
addNotice: addNotice,
|
|
1848
|
+
callListener: callListener,
|
|
1849
|
+
createInstanceState: createInstanceState,
|
|
1850
|
+
cycleMutationStatus: cycleMutationStatus,
|
|
1851
|
+
deepCopyEnabled: deepCopyEnabled,
|
|
1852
|
+
deleteNotice: deleteNotice,
|
|
1853
|
+
deleteNotices: deleteNotices,
|
|
1854
|
+
disableNotifications: disableNotifications,
|
|
1855
|
+
enableNotifications: enableNotifications,
|
|
1856
|
+
getDevContext: getDevContext,
|
|
1857
|
+
getMethods: getMethods,
|
|
1858
|
+
getNotices: getNotices,
|
|
1859
|
+
getProvider: getProvider,
|
|
1860
|
+
getTopics: getTopics,
|
|
1861
|
+
getTournamentId: getTournamentId,
|
|
1862
|
+
getTournamentRecord: getTournamentRecord,
|
|
1863
|
+
getTournamentRecords: getTournamentRecords,
|
|
1864
|
+
globalLog: globalLog$1,
|
|
1865
|
+
handleCaughtError: handleCaughtError,
|
|
1866
|
+
removeTournamentRecord: removeTournamentRecord,
|
|
1867
|
+
setDeepCopy: setDeepCopy,
|
|
1868
|
+
setDevContext: setDevContext,
|
|
1869
|
+
setGlobalLog: setGlobalLog,
|
|
1870
|
+
setMethods: setMethods,
|
|
1871
|
+
setStateProvider: setStateProvider,
|
|
1872
|
+
setSubscriptions: setSubscriptions,
|
|
1873
|
+
setTournamentId: setTournamentId,
|
|
1874
|
+
setTournamentRecord: setTournamentRecord$1,
|
|
1875
|
+
setTournamentRecords: setTournamentRecords,
|
|
1876
|
+
timeKeeper: timeKeeper
|
|
1877
|
+
};
|
|
1878
|
+
|
|
1784
1879
|
function getDefinedKeys(obj, ignoreValues, ignoreEmptyArrays) {
|
|
1785
1880
|
return Object.keys(obj).filter(function (key) {
|
|
1786
1881
|
return !ignoreValues.includes(obj[key]) &&
|
|
@@ -13156,31 +13251,135 @@ function getDrawPublishStatus(_a) {
|
|
|
13156
13251
|
return details === null || details === void 0 ? void 0 : details.published;
|
|
13157
13252
|
}
|
|
13158
13253
|
|
|
13159
|
-
function
|
|
13254
|
+
function getPublishState(_a) {
|
|
13255
|
+
var e_1, _b, e_2, _c, e_3, _d, e_4, _e;
|
|
13256
|
+
var tournamentRecord = _a.tournamentRecord, eventIds = _a.eventIds, drawIds = _a.drawIds, drawId = _a.drawId, event = _a.event;
|
|
13257
|
+
if (Array.isArray(eventIds) && (eventIds === null || eventIds === void 0 ? void 0 : eventIds.length)) {
|
|
13258
|
+
var publishState = {};
|
|
13259
|
+
try {
|
|
13260
|
+
for (var eventIds_1 = __values(eventIds), eventIds_1_1 = eventIds_1.next(); !eventIds_1_1.done; eventIds_1_1 = eventIds_1.next()) {
|
|
13261
|
+
var eventId = eventIds_1_1.value;
|
|
13262
|
+
if (!isString(eventId))
|
|
13263
|
+
return { error: INVALID_VALUES };
|
|
13264
|
+
var event_1 = findEvent({ tournamentRecord: tournamentRecord, eventId: eventId });
|
|
13265
|
+
if (!event_1)
|
|
13266
|
+
return { error: EVENT_NOT_FOUND };
|
|
13267
|
+
var pubStatus = getPubStatus({ event: event_1 });
|
|
13268
|
+
if (pubStatus.error)
|
|
13269
|
+
return pubStatus;
|
|
13270
|
+
publishState[eventId] = pubStatus;
|
|
13271
|
+
}
|
|
13272
|
+
}
|
|
13273
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
13274
|
+
finally {
|
|
13275
|
+
try {
|
|
13276
|
+
if (eventIds_1_1 && !eventIds_1_1.done && (_b = eventIds_1.return)) _b.call(eventIds_1);
|
|
13277
|
+
}
|
|
13278
|
+
finally { if (e_1) throw e_1.error; }
|
|
13279
|
+
}
|
|
13280
|
+
return __assign(__assign({}, SUCCESS), { publishState: publishState });
|
|
13281
|
+
}
|
|
13282
|
+
else if (!event &&
|
|
13283
|
+
(tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.events) &&
|
|
13284
|
+
Array.isArray(drawIds) &&
|
|
13285
|
+
drawIds.length) {
|
|
13286
|
+
var publishState = {};
|
|
13287
|
+
try {
|
|
13288
|
+
for (var _f = __values(tournamentRecord.events), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
13289
|
+
var event_2 = _g.value;
|
|
13290
|
+
var pubStatus = getPubStatus({ event: event_2 });
|
|
13291
|
+
if (pubStatus.error)
|
|
13292
|
+
return pubStatus;
|
|
13293
|
+
try {
|
|
13294
|
+
for (var drawIds_1 = (e_3 = void 0, __values(drawIds)), drawIds_1_1 = drawIds_1.next(); !drawIds_1_1.done; drawIds_1_1 = drawIds_1.next()) {
|
|
13295
|
+
var drawId_1 = drawIds_1_1.value;
|
|
13296
|
+
if (!isString(drawId_1))
|
|
13297
|
+
return { error: INVALID_VALUES };
|
|
13298
|
+
var published = pubStatus.publishState.publishedDrawIds.includes(drawId_1);
|
|
13299
|
+
if (published)
|
|
13300
|
+
publishState[drawId_1] = { published: published };
|
|
13301
|
+
}
|
|
13302
|
+
}
|
|
13303
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
13304
|
+
finally {
|
|
13305
|
+
try {
|
|
13306
|
+
if (drawIds_1_1 && !drawIds_1_1.done && (_d = drawIds_1.return)) _d.call(drawIds_1);
|
|
13307
|
+
}
|
|
13308
|
+
finally { if (e_3) throw e_3.error; }
|
|
13309
|
+
}
|
|
13310
|
+
}
|
|
13311
|
+
}
|
|
13312
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
13313
|
+
finally {
|
|
13314
|
+
try {
|
|
13315
|
+
if (_g && !_g.done && (_c = _f.return)) _c.call(_f);
|
|
13316
|
+
}
|
|
13317
|
+
finally { if (e_2) throw e_2.error; }
|
|
13318
|
+
}
|
|
13319
|
+
return __assign(__assign({}, SUCCESS), { publishState: publishState });
|
|
13320
|
+
}
|
|
13321
|
+
else if (event) {
|
|
13322
|
+
var pubStatus = getPubStatus({ event: event });
|
|
13323
|
+
if (pubStatus.error)
|
|
13324
|
+
return pubStatus;
|
|
13325
|
+
if (drawId) {
|
|
13326
|
+
return {
|
|
13327
|
+
publishState: __assign({ published: pubStatus.publishState.publishedDrawIds.includes(drawId) }, SUCCESS),
|
|
13328
|
+
};
|
|
13329
|
+
}
|
|
13330
|
+
else if (Array.isArray(drawIds) && (drawIds === null || drawIds === void 0 ? void 0 : drawIds.length)) {
|
|
13331
|
+
var publishState = {};
|
|
13332
|
+
try {
|
|
13333
|
+
for (var drawIds_2 = __values(drawIds), drawIds_2_1 = drawIds_2.next(); !drawIds_2_1.done; drawIds_2_1 = drawIds_2.next()) {
|
|
13334
|
+
var drawId_2 = drawIds_2_1.value;
|
|
13335
|
+
if (!isString(drawId_2))
|
|
13336
|
+
return { error: INVALID_VALUES };
|
|
13337
|
+
publishState[drawId_2] = {
|
|
13338
|
+
published: pubStatus.publishState.publishedDrawIds.includes(drawId_2),
|
|
13339
|
+
};
|
|
13340
|
+
return __assign(__assign({}, SUCCESS), { publishState: publishState });
|
|
13341
|
+
}
|
|
13342
|
+
}
|
|
13343
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
13344
|
+
finally {
|
|
13345
|
+
try {
|
|
13346
|
+
if (drawIds_2_1 && !drawIds_2_1.done && (_e = drawIds_2.return)) _e.call(drawIds_2);
|
|
13347
|
+
}
|
|
13348
|
+
finally { if (e_4) throw e_4.error; }
|
|
13349
|
+
}
|
|
13350
|
+
}
|
|
13351
|
+
else {
|
|
13352
|
+
return pubStatus;
|
|
13353
|
+
}
|
|
13354
|
+
}
|
|
13355
|
+
return { error: INVALID_VALUES };
|
|
13356
|
+
}
|
|
13357
|
+
function getPubStatus(_a) {
|
|
13160
13358
|
var event = _a.event;
|
|
13161
13359
|
var eventPubStatus = getEventPublishStatus({ event: event });
|
|
13162
|
-
if (eventPubStatus)
|
|
13163
|
-
|
|
13164
|
-
|
|
13165
|
-
|
|
13166
|
-
|
|
13167
|
-
|
|
13168
|
-
|
|
13169
|
-
|
|
13170
|
-
|
|
13171
|
-
|
|
13172
|
-
|
|
13173
|
-
|
|
13174
|
-
|
|
13175
|
-
})
|
|
13176
|
-
|
|
13177
|
-
|
|
13178
|
-
|
|
13360
|
+
if (!eventPubStatus)
|
|
13361
|
+
return { error: EVENT_NOT_FOUND };
|
|
13362
|
+
var publishedSeeding = {
|
|
13363
|
+
published: undefined, // seeding can be present for all entries in an event when no flights have been defined
|
|
13364
|
+
seedingScaleNames: [],
|
|
13365
|
+
drawIds: [], // seeding can be specific to drawIds
|
|
13366
|
+
};
|
|
13367
|
+
if (eventPubStatus.seeding) {
|
|
13368
|
+
Object.assign(publishedSeeding, eventPubStatus.seeding);
|
|
13369
|
+
}
|
|
13370
|
+
var drawDetails = eventPubStatus.drawDetails;
|
|
13371
|
+
var publishedDrawIds = (drawDetails &&
|
|
13372
|
+
Object.keys(drawDetails).filter(function (drawId) {
|
|
13373
|
+
return getDrawPublishStatus({ drawDetails: drawDetails, drawId: drawId });
|
|
13374
|
+
})) ||
|
|
13375
|
+
eventPubStatus.drawIds ||
|
|
13376
|
+
[];
|
|
13377
|
+
return __assign({ publishState: {
|
|
13378
|
+
published: publishedDrawIds.length > 0,
|
|
13179
13379
|
publishedDrawIds: publishedDrawIds,
|
|
13180
13380
|
publishedSeeding: publishedSeeding,
|
|
13181
|
-
|
|
13182
|
-
|
|
13183
|
-
return undefined;
|
|
13381
|
+
drawDetails: drawDetails,
|
|
13382
|
+
} }, SUCCESS);
|
|
13184
13383
|
}
|
|
13185
13384
|
|
|
13186
13385
|
function processEventEntry(_a) {
|
|
@@ -13544,10 +13743,10 @@ function getParticipantEntries(params) {
|
|
|
13544
13743
|
var _r = event_1.drawDefinitions, drawDefinitions = _r === void 0 ? [] : _r, _s = event_1.extensions, extensions = _s === void 0 ? [] : _s, eventType = event_1.eventType, eventName = event_1.eventName, category = event_1.category, entries = event_1.entries, eventId = event_1.eventId, gender = event_1.gender;
|
|
13545
13744
|
var flightProfile = getFlightProfile({ event: event_1 }).flightProfile;
|
|
13546
13745
|
var flights = (_c = flightProfile === null || flightProfile === void 0 ? void 0 : flightProfile.flights) !== null && _c !== void 0 ? _c : [];
|
|
13547
|
-
var publishStatuses =
|
|
13548
|
-
var publishedSeeding = publishStatuses === null || publishStatuses === void 0 ? void 0 : publishStatuses.publishedSeeding;
|
|
13746
|
+
var publishStatuses = getPublishState({ event: event_1 }).publishState;
|
|
13549
13747
|
if (publishStatuses)
|
|
13550
13748
|
eventsPublishStatuses[eventId] = publishStatuses;
|
|
13749
|
+
var publishedSeeding = publishStatuses === null || publishStatuses === void 0 ? void 0 : publishStatuses.publishedSeeding;
|
|
13551
13750
|
if (withEvents || withSeeding || withRankingProfile) {
|
|
13552
13751
|
var extensionConversions = convertExtensions
|
|
13553
13752
|
? Object.assign.apply(Object, __spreadArray([{}], __read(extensionsToAttributes(extensions)), false)) : {};
|
|
@@ -16854,6 +17053,7 @@ function getEventData(params) {
|
|
|
16854
17053
|
var eventId = event.eventId;
|
|
16855
17054
|
var tournamentId = tournamentRecord.tournamentId, endDate = tournamentRecord.endDate;
|
|
16856
17055
|
var publishStatus = getEventPublishStatus({ event: event, status: status });
|
|
17056
|
+
var publishState = getPublishState({ event: event }).publishState;
|
|
16857
17057
|
var tournamentParticipants = getParticipants(__assign(__assign({ withGroupings: true, withEvents: false, withDraws: false }, participantsProfile), { // order is important!!
|
|
16858
17058
|
tournamentRecord: tournamentRecord })).participants;
|
|
16859
17059
|
var stageFilter = function (_a) {
|
|
@@ -16988,6 +17188,7 @@ function getEventData(params) {
|
|
|
16988
17188
|
eventInfo: eventInfo,
|
|
16989
17189
|
drawsData: drawsData,
|
|
16990
17190
|
};
|
|
17191
|
+
eventData.eventInfo.publishState = publishState;
|
|
16991
17192
|
eventData.eventInfo.publish = publishStatus;
|
|
16992
17193
|
return __assign(__assign({}, SUCCESS), { eventData: eventData });
|
|
16993
17194
|
}
|
|
@@ -17020,7 +17221,13 @@ function publishEvent(params) {
|
|
|
17020
17221
|
});
|
|
17021
17222
|
}
|
|
17022
17223
|
var pubStatus = getEventPublishStatus({ event: event, status: status });
|
|
17023
|
-
|
|
17224
|
+
// filter out any drawIds that do not have corresponding drawDefinitions not in the event
|
|
17225
|
+
var drawDetails = Object.keys((pubStatus === null || pubStatus === void 0 ? void 0 : pubStatus.drawDetails) || {})
|
|
17226
|
+
.filter(function (drawId) { return eventDrawIds.includes(drawId); })
|
|
17227
|
+
.reduce(function (details, drawId) {
|
|
17228
|
+
details[drawId] = pubStatus.drawDetails[drawId];
|
|
17229
|
+
return details;
|
|
17230
|
+
}, {});
|
|
17024
17231
|
var _loop_1 = function (drawId) {
|
|
17025
17232
|
var e_2, _r, e_3, _s, e_4, _t, e_5, _u, e_6, _v;
|
|
17026
17233
|
if (!drawIdsToValidate.length || drawIdsToValidate.includes(drawId)) {
|
|
@@ -21670,8 +21877,8 @@ function categoryCanContain(_a) {
|
|
|
21670
21877
|
categoryDetails.ageMinDate &&
|
|
21671
21878
|
new Date(childCategoryDetails.ageMaxDate) <
|
|
21672
21879
|
new Date(categoryDetails.ageMinDate);
|
|
21673
|
-
var ratingComparison = category.ratingType &&
|
|
21674
|
-
childCategory.ratingType &&
|
|
21880
|
+
var ratingComparison = (category === null || category === void 0 ? void 0 : category.ratingType) &&
|
|
21881
|
+
(childCategory === null || childCategory === void 0 ? void 0 : childCategory.ratingType) &&
|
|
21675
21882
|
category.ratingType === childCategory.ratingType;
|
|
21676
21883
|
var invalidRatingRange = ratingComparison &&
|
|
21677
21884
|
((category.ratingMin &&
|
|
@@ -21686,8 +21893,8 @@ function categoryCanContain(_a) {
|
|
|
21686
21893
|
(category.ratingMax &&
|
|
21687
21894
|
childCategory.ratingMin &&
|
|
21688
21895
|
childCategory.ratingMin > category.ratingMax));
|
|
21689
|
-
var invalidBallType = category.ballType &&
|
|
21690
|
-
childCategory.ballType &&
|
|
21896
|
+
var invalidBallType = (category === null || category === void 0 ? void 0 : category.ballType) &&
|
|
21897
|
+
(childCategory === null || childCategory === void 0 ? void 0 : childCategory.ballType) &&
|
|
21691
21898
|
category.ballType !== childCategory.ballType;
|
|
21692
21899
|
var valid = !invalidRatingRange &&
|
|
21693
21900
|
!invalidAgeMinDate &&
|
|
@@ -26743,7 +26950,7 @@ function tallyParticipantResults(_a) {
|
|
|
26743
26950
|
var completedTieMatchUps = matchUps.every(function (_a) {
|
|
26744
26951
|
var matchUpType = _a.matchUpType, tieMatchUps = _a.tieMatchUps;
|
|
26745
26952
|
return matchUpType === TEAM$1 &&
|
|
26746
|
-
tieMatchUps.every(function (matchUp) { return checkMatchUpIsComplete({ matchUp: matchUp }); });
|
|
26953
|
+
(tieMatchUps === null || tieMatchUps === void 0 ? void 0 : tieMatchUps.every(function (matchUp) { return checkMatchUpIsComplete({ matchUp: matchUp }); }));
|
|
26747
26954
|
});
|
|
26748
26955
|
var tallyPolicy = policyDefinitions === null || policyDefinitions === void 0 ? void 0 : policyDefinitions[POLICY_TYPE_ROUND_ROBIN_TALLY];
|
|
26749
26956
|
var consideredMatchUps = matchUps.filter(function (matchUp) {
|
|
@@ -36121,49 +36328,6 @@ function removeAdHocRound(_a) {
|
|
|
36121
36328
|
return __assign({ deletedMatchUpsCount: deletedMatchUpIds.length, roundRemoved: roundRemoved }, SUCCESS);
|
|
36122
36329
|
}
|
|
36123
36330
|
|
|
36124
|
-
function addAdHocMatchUps(_a) {
|
|
36125
|
-
var _b;
|
|
36126
|
-
var _c, _d, _e, _f, _g, _h, _j;
|
|
36127
|
-
var tournamentRecord = _a.tournamentRecord, drawDefinition = _a.drawDefinition, structureId = _a.structureId, matchUps = _a.matchUps;
|
|
36128
|
-
if (typeof drawDefinition !== 'object')
|
|
36129
|
-
return { error: MISSING_DRAW_DEFINITION };
|
|
36130
|
-
if (!structureId && ((_c = drawDefinition.structures) === null || _c === void 0 ? void 0 : _c.length) === 1)
|
|
36131
|
-
structureId = (_e = (_d = drawDefinition.structures) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.structureId;
|
|
36132
|
-
if (typeof structureId !== 'string')
|
|
36133
|
-
return { error: MISSING_STRUCTURE_ID };
|
|
36134
|
-
if (!validMatchUps(matchUps))
|
|
36135
|
-
return { error: INVALID_VALUES, info: mustBeAnArray('matchUps') };
|
|
36136
|
-
var structure = (_f = drawDefinition.structures) === null || _f === void 0 ? void 0 : _f.find(function (structure) { return structure.structureId === structureId; });
|
|
36137
|
-
if (!structure)
|
|
36138
|
-
return { error: STRUCTURE_NOT_FOUND };
|
|
36139
|
-
var existingMatchUps = structure === null || structure === void 0 ? void 0 : structure.matchUps;
|
|
36140
|
-
var structureHasRoundPositions = existingMatchUps.find(function (matchUp) { return !!matchUp.roundPosition; });
|
|
36141
|
-
if (structure.structures ||
|
|
36142
|
-
structureHasRoundPositions ||
|
|
36143
|
-
structure.finishingPosition === ROUND_OUTCOME) {
|
|
36144
|
-
return { error: INVALID_STRUCTURE };
|
|
36145
|
-
}
|
|
36146
|
-
var existingMatchUpIds = (_j = (_h = (_g = allTournamentMatchUps({
|
|
36147
|
-
tournamentRecord: tournamentRecord,
|
|
36148
|
-
inContext: false,
|
|
36149
|
-
})) === null || _g === void 0 ? void 0 : _g.matchUps) === null || _h === void 0 ? void 0 : _h.map(getMatchUpId)) !== null && _j !== void 0 ? _j : [];
|
|
36150
|
-
var newMatchUpIds = matchUps.map(getMatchUpId);
|
|
36151
|
-
if (overlap(existingMatchUpIds, newMatchUpIds)) {
|
|
36152
|
-
return {
|
|
36153
|
-
error: EXISTING_MATCHUP_ID,
|
|
36154
|
-
info: 'One or more matchUpIds already present in tournamentRecord',
|
|
36155
|
-
};
|
|
36156
|
-
}
|
|
36157
|
-
(_b = structure.matchUps).push.apply(_b, __spreadArray([], __read(matchUps), false));
|
|
36158
|
-
addMatchUpsNotice({
|
|
36159
|
-
tournamentId: tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.tournamentId,
|
|
36160
|
-
drawDefinition: drawDefinition,
|
|
36161
|
-
matchUps: matchUps,
|
|
36162
|
-
});
|
|
36163
|
-
modifyDrawNotice({ drawDefinition: drawDefinition, structureIds: [structureId] });
|
|
36164
|
-
return __assign({}, SUCCESS);
|
|
36165
|
-
}
|
|
36166
|
-
|
|
36167
36331
|
function aggregateTieFormats(_a) {
|
|
36168
36332
|
var e_1, _b;
|
|
36169
36333
|
var _c, _d, _e, _f, _g;
|
|
@@ -37057,867 +37221,286 @@ function modifyEventEntries(_a) {
|
|
|
37057
37221
|
return __assign({}, SUCCESS);
|
|
37058
37222
|
}
|
|
37059
37223
|
|
|
37060
|
-
function
|
|
37061
|
-
var _b;
|
|
37062
|
-
var
|
|
37063
|
-
|
|
37064
|
-
|
|
37065
|
-
|
|
37066
|
-
|
|
37067
|
-
|
|
37068
|
-
|
|
37069
|
-
if
|
|
37070
|
-
|
|
37071
|
-
if (
|
|
37072
|
-
return
|
|
37073
|
-
|
|
37074
|
-
|
|
37224
|
+
function generateAdHocMatchUps(_a) {
|
|
37225
|
+
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
37226
|
+
var participantIdPairings = _a.participantIdPairings, _q = _a.matchUpIds, matchUpIds = _q === void 0 ? [] : _q, drawDefinition = _a.drawDefinition, matchUpsCount = _a.matchUpsCount, roundNumber = _a.roundNumber, structureId = _a.structureId, newRound = _a.newRound, isMock = _a.isMock, event = _a.event;
|
|
37227
|
+
if (typeof drawDefinition !== 'object')
|
|
37228
|
+
return { error: MISSING_DRAW_DEFINITION };
|
|
37229
|
+
if (!structureId && ((_b = drawDefinition.structures) === null || _b === void 0 ? void 0 : _b.length) === 1)
|
|
37230
|
+
structureId = (_d = (_c = drawDefinition.structures) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.structureId;
|
|
37231
|
+
if (typeof structureId !== 'string')
|
|
37232
|
+
return { error: MISSING_STRUCTURE_ID };
|
|
37233
|
+
// if drawDefinition and structureId are provided it is possible to infer roundNumber
|
|
37234
|
+
var structure = (_e = drawDefinition.structures) === null || _e === void 0 ? void 0 : _e.find(function (structure) { return structure.structureId === structureId; });
|
|
37235
|
+
if (!structure)
|
|
37236
|
+
return { error: STRUCTURE_NOT_FOUND };
|
|
37237
|
+
var structureHasRoundPositions;
|
|
37238
|
+
var existingMatchUps = (_f = structure.matchUps) !== null && _f !== void 0 ? _f : [];
|
|
37239
|
+
var lastRoundNumber = existingMatchUps === null || existingMatchUps === void 0 ? void 0 : existingMatchUps.reduce(function (roundNumber, matchUp) {
|
|
37240
|
+
if (matchUp.roundPosition)
|
|
37241
|
+
structureHasRoundPositions = true;
|
|
37242
|
+
return ((matchUp === null || matchUp === void 0 ? void 0 : matchUp.roundNumber) || 0) > roundNumber
|
|
37243
|
+
? matchUp.roundNumber
|
|
37244
|
+
: roundNumber;
|
|
37245
|
+
}, 0);
|
|
37246
|
+
if (!matchUpsCount) {
|
|
37247
|
+
var selectedEntries = (_h = (_g = drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.entries) === null || _g === void 0 ? void 0 : _g.filter(function (entry) {
|
|
37248
|
+
var entryStatus = entry.entryStatus;
|
|
37249
|
+
return STRUCTURE_SELECTED_STATUSES.includes(entryStatus);
|
|
37250
|
+
})) !== null && _h !== void 0 ? _h : [];
|
|
37251
|
+
var roundMatchUpsCount = Math.floor((selectedEntries === null || selectedEntries === void 0 ? void 0 : selectedEntries.length) / 2) || 1;
|
|
37252
|
+
if (newRound) {
|
|
37253
|
+
matchUpsCount = roundMatchUpsCount;
|
|
37254
|
+
}
|
|
37255
|
+
else {
|
|
37256
|
+
var targetRoundNumber_1 = (_j = roundNumber !== null && roundNumber !== void 0 ? roundNumber : lastRoundNumber) !== null && _j !== void 0 ? _j : 1;
|
|
37257
|
+
var existingRoundMatchUps = (_m = (_l = (_k = structure.matchUps) === null || _k === void 0 ? void 0 : _k.filter(function (matchUp) { return matchUp.roundNumber === targetRoundNumber_1; })) === null || _l === void 0 ? void 0 : _l.length) !== null && _m !== void 0 ? _m : 0;
|
|
37258
|
+
var maxRemaining = roundMatchUpsCount - existingRoundMatchUps;
|
|
37259
|
+
if (maxRemaining > 0)
|
|
37260
|
+
matchUpsCount = maxRemaining;
|
|
37261
|
+
}
|
|
37262
|
+
}
|
|
37263
|
+
if ((participantIdPairings && !Array.isArray(participantIdPairings)) ||
|
|
37264
|
+
(matchUpsCount && !isConvertableInteger(matchUpsCount)) ||
|
|
37265
|
+
(matchUpIds && !Array.isArray(matchUpIds)) ||
|
|
37266
|
+
(!participantIdPairings && !matchUpsCount)) {
|
|
37267
|
+
return { error: INVALID_VALUES, info: 'matchUpsCount or pairings error' };
|
|
37268
|
+
}
|
|
37269
|
+
// structure must not be a container of other structures
|
|
37270
|
+
// structure must not contain matchUps with roundPosition
|
|
37271
|
+
// structure must not determine finishingPosition by ROUND_OUTCOME
|
|
37272
|
+
if (structure.structures ||
|
|
37273
|
+
structureHasRoundPositions ||
|
|
37274
|
+
structure.finishingPosition === ROUND_OUTCOME) {
|
|
37275
|
+
return { error: INVALID_STRUCTURE };
|
|
37276
|
+
}
|
|
37277
|
+
if (roundNumber && roundNumber - 1 > (lastRoundNumber || 0))
|
|
37278
|
+
return { error: INVALID_VALUES, info: 'roundNumber error' };
|
|
37279
|
+
var nextRoundNumber = roundNumber !== null && roundNumber !== void 0 ? roundNumber : ((newRound && (lastRoundNumber !== null && lastRoundNumber !== void 0 ? lastRoundNumber : 0) + 1) || lastRoundNumber || 1);
|
|
37280
|
+
participantIdPairings =
|
|
37281
|
+
participantIdPairings !== null && participantIdPairings !== void 0 ? participantIdPairings : generateRange(0, matchUpsCount).map(function () { return ({
|
|
37282
|
+
participantIds: [undefined, undefined],
|
|
37283
|
+
}); });
|
|
37284
|
+
var matchUps = participantIdPairings === null || participantIdPairings === void 0 ? void 0 : participantIdPairings.map(function (pairing) {
|
|
37285
|
+
var _a, _b;
|
|
37286
|
+
var idStack = (_a = pairing === null || pairing === void 0 ? void 0 : pairing.participantIds) !== null && _a !== void 0 ? _a : [undefined, undefined];
|
|
37287
|
+
// ensure there are always 2 sides in generated matchUps
|
|
37288
|
+
idStack.push.apply(idStack, [undefined, undefined]);
|
|
37289
|
+
var participantIds = idStack.slice(0, 2);
|
|
37290
|
+
var sides = participantIds.map(function (participantId, i) {
|
|
37291
|
+
return definedAttributes({
|
|
37292
|
+
sideNumber: i + 1,
|
|
37293
|
+
participantId: participantId,
|
|
37294
|
+
});
|
|
37075
37295
|
});
|
|
37076
|
-
|
|
37077
|
-
|
|
37078
|
-
|
|
37079
|
-
|
|
37080
|
-
|
|
37081
|
-
|
|
37296
|
+
return {
|
|
37297
|
+
matchUpId: (_b = matchUpIds.pop()) !== null && _b !== void 0 ? _b : UUID(),
|
|
37298
|
+
roundNumber: nextRoundNumber,
|
|
37299
|
+
matchUpStatus: TO_BE_PLAYED,
|
|
37300
|
+
sides: sides,
|
|
37301
|
+
};
|
|
37302
|
+
});
|
|
37303
|
+
if (matchUps === null || matchUps === void 0 ? void 0 : matchUps.length) {
|
|
37304
|
+
var tieFormat_1 = (_o = resolveTieFormat({ drawDefinition: drawDefinition, event: event })) === null || _o === void 0 ? void 0 : _o.tieFormat;
|
|
37305
|
+
if (tieFormat_1) {
|
|
37306
|
+
matchUps.forEach(function (matchUp) {
|
|
37307
|
+
var tieMatchUps = generateTieMatchUps({ tieFormat: tieFormat_1, isMock: isMock }).tieMatchUps;
|
|
37308
|
+
Object.assign(matchUp, { tieMatchUps: tieMatchUps, matchUpType: TEAM$1 });
|
|
37309
|
+
});
|
|
37310
|
+
}
|
|
37311
|
+
}
|
|
37312
|
+
return __assign({ matchUpsCount: (_p = matchUps === null || matchUps === void 0 ? void 0 : matchUps.length) !== null && _p !== void 0 ? _p : 0, matchUps: matchUps }, SUCCESS);
|
|
37082
37313
|
}
|
|
37083
37314
|
|
|
37084
|
-
|
|
37085
|
-
|
|
37086
|
-
|
|
37087
|
-
|
|
37088
|
-
|
|
37089
|
-
|
|
37090
|
-
|
|
37091
|
-
|
|
37092
|
-
var
|
|
37093
|
-
var
|
|
37094
|
-
|
|
37095
|
-
|
|
37096
|
-
|
|
37097
|
-
|
|
37098
|
-
|
|
37099
|
-
|
|
37100
|
-
|
|
37101
|
-
|
|
37102
|
-
|
|
37103
|
-
|
|
37104
|
-
|
|
37105
|
-
|
|
37106
|
-
|
|
37107
|
-
|
|
37315
|
+
function generateCandidate(_a) {
|
|
37316
|
+
var _b = _a.maxIterations, maxIterations = _b === void 0 ? 4000 : _b, // cap the processing intensity of the candidate generator
|
|
37317
|
+
valueSortedPairings = _a.valueSortedPairings, // pairings sorted by value from low to high
|
|
37318
|
+
pairingValues = _a.pairingValues, valueObjects = _a.valueObjects, deltaObjects = _a.deltaObjects;
|
|
37319
|
+
var pairingValueMap = Object.assign.apply(Object, __spreadArray([{}], __read(valueSortedPairings.map(function (rm) {
|
|
37320
|
+
var _a;
|
|
37321
|
+
return (_a = {}, _a[rm.pairing] = rm.value, _a);
|
|
37322
|
+
})), false));
|
|
37323
|
+
var actors = Object.keys(pairingValues);
|
|
37324
|
+
var proposedCandidates = [];
|
|
37325
|
+
// generate an initial candidate value with no stipulated pairings
|
|
37326
|
+
var initialProposal = roundCandidate({
|
|
37327
|
+
actorsCount: actors.length,
|
|
37328
|
+
valueSortedPairings: valueSortedPairings,
|
|
37329
|
+
pairingValueMap: pairingValueMap,
|
|
37330
|
+
deltaObjects: deltaObjects,
|
|
37331
|
+
valueObjects: valueObjects,
|
|
37332
|
+
});
|
|
37333
|
+
var candidateHashes = [candidateHash(initialProposal)];
|
|
37334
|
+
proposedCandidates.push(initialProposal);
|
|
37335
|
+
var lowCandidateValue = initialProposal.value;
|
|
37336
|
+
var deltaCandidate = initialProposal;
|
|
37337
|
+
// iterations is the number of loops over valueSortedPairings
|
|
37338
|
+
var candidatesCount = 0;
|
|
37339
|
+
var iterations = 0;
|
|
37340
|
+
var opponentCount = actors.length;
|
|
37341
|
+
var calculatedIterations;
|
|
37342
|
+
// calculate the number of opponents to consider for each participantId
|
|
37343
|
+
do {
|
|
37344
|
+
opponentCount -= 1;
|
|
37345
|
+
calculatedIterations = actors.length * pairingValues[actors[0]].length;
|
|
37346
|
+
} while (calculatedIterations > maxIterations && opponentCount > 5);
|
|
37347
|
+
// keep track of proposed pairings
|
|
37348
|
+
var stipulatedPairs = [];
|
|
37349
|
+
// for each actor generate a roundCandidate using opponentCount of pairing values
|
|
37350
|
+
actors.forEach(function (actor) {
|
|
37351
|
+
var participantIdPairings = pairingValues[actor];
|
|
37352
|
+
// opponentCount limits the number of opponents to consider
|
|
37353
|
+
participantIdPairings.slice(0, opponentCount).forEach(function (pairing) {
|
|
37354
|
+
iterations += 1;
|
|
37355
|
+
var stipulatedPair = pairingHash(actor, pairing.opponent);
|
|
37356
|
+
if (!stipulatedPairs.includes(stipulatedPair)) {
|
|
37357
|
+
var proposed = roundCandidate({
|
|
37358
|
+
// each roundCandidate starts with stipulated pairings
|
|
37359
|
+
stipulated: [[actor, pairing.opponent]],
|
|
37360
|
+
actorsCount: actors.length,
|
|
37361
|
+
valueSortedPairings: valueSortedPairings,
|
|
37362
|
+
pairingValueMap: pairingValueMap,
|
|
37363
|
+
deltaObjects: deltaObjects,
|
|
37364
|
+
valueObjects: valueObjects,
|
|
37365
|
+
});
|
|
37366
|
+
// ensure no duplicate candidates are considered
|
|
37367
|
+
if (!candidateHashes.includes(candidateHash(proposed))) {
|
|
37368
|
+
candidateHashes.push(candidateHash(proposed));
|
|
37369
|
+
proposedCandidates.push(proposed);
|
|
37370
|
+
var maxDelta = proposed.maxDelta, value = proposed.value;
|
|
37371
|
+
if (maxDelta < deltaCandidate.maxDelta)
|
|
37372
|
+
deltaCandidate = proposed;
|
|
37373
|
+
if (value < lowCandidateValue ||
|
|
37374
|
+
(value === lowCandidateValue && Math.round(Math.random())) // randomize if equivalent values
|
|
37375
|
+
) {
|
|
37376
|
+
lowCandidateValue = value;
|
|
37377
|
+
}
|
|
37378
|
+
stipulatedPairs.push(stipulatedPair);
|
|
37379
|
+
candidatesCount += 1;
|
|
37380
|
+
}
|
|
37381
|
+
}
|
|
37382
|
+
});
|
|
37383
|
+
proposedCandidates = proposedCandidates.filter(function (proposed) { return Math.abs(proposed.value - lowCandidateValue) < 5; });
|
|
37384
|
+
});
|
|
37385
|
+
proposedCandidates.sort(function (a, b) { return a.maxDiff - b.maxDiff; });
|
|
37386
|
+
var candidate = randomPop(proposedCandidates);
|
|
37387
|
+
return {
|
|
37388
|
+
candidatesCount: candidatesCount,
|
|
37389
|
+
deltaCandidate: deltaCandidate,
|
|
37390
|
+
maxIterations: maxIterations,
|
|
37391
|
+
iterations: iterations,
|
|
37392
|
+
candidate: candidate,
|
|
37393
|
+
};
|
|
37394
|
+
}
|
|
37395
|
+
function candidateHash(candidate) {
|
|
37396
|
+
return candidate.participantIdPairings
|
|
37397
|
+
.map(function (_a) {
|
|
37398
|
+
var participantIds = _a.participantIds;
|
|
37399
|
+
return participantIds.sort().join('|');
|
|
37400
|
+
})
|
|
37401
|
+
.sort()
|
|
37402
|
+
.join('/');
|
|
37403
|
+
}
|
|
37404
|
+
function roundCandidate(_a) {
|
|
37405
|
+
var valueSortedPairings = _a.valueSortedPairings, _b = _a.stipulated, stipulated = _b === void 0 ? [] : _b, pairingValueMap = _a.pairingValueMap, deltaObjects = _a.deltaObjects, valueObjects = _a.valueObjects, actorsCount = _a.actorsCount;
|
|
37406
|
+
// roundPlayers starts with the stipulated pairing
|
|
37407
|
+
var roundPlayers = [].concat.apply([], __spreadArray([], __read(stipulated), false));
|
|
37408
|
+
// aggregates the pairings generated for a roundCandidate
|
|
37409
|
+
var participantIdPairings = [];
|
|
37410
|
+
// candidateValue is the sum of all participantIdPairings in a roundCandidate
|
|
37411
|
+
// the winning candidate has the LOWEST total value
|
|
37412
|
+
var candidateValue = 0;
|
|
37413
|
+
// candidateValue is initialized with any stipulated pairings
|
|
37414
|
+
stipulated.filter(Boolean).forEach(function (participantIds) {
|
|
37415
|
+
var _a = __read(participantIds, 2), p1 = _a[0], p2 = _a[1];
|
|
37416
|
+
var pairing = pairingHash(p1, p2);
|
|
37417
|
+
var value = pairingValueMap[pairing];
|
|
37418
|
+
participantIdPairings.push({ participantIds: participantIds, value: value });
|
|
37419
|
+
candidateValue += pairingValueMap[pairing];
|
|
37420
|
+
});
|
|
37421
|
+
// valueSortedPairings is an array sorted from lowest value to highest value
|
|
37422
|
+
// introduce random shuffling of chunks of valueSortedPairings
|
|
37423
|
+
var consideredPairings = chunkArray(valueSortedPairings, actorsCount)
|
|
37424
|
+
.map(function (pairings) {
|
|
37425
|
+
return shuffleArray(pairings).map(function (pairing) { return (__assign(__assign({}, pairing), { value: pairing.value + Math.random() * Math.round(Math.random()) })); });
|
|
37426
|
+
})
|
|
37427
|
+
.flat();
|
|
37428
|
+
// go through the valueSortedPairings (of all possible unique pairings)
|
|
37429
|
+
consideredPairings.forEach(function (rankedPairing) {
|
|
37430
|
+
var participantIds = rankedPairing.pairing.split('|');
|
|
37431
|
+
var opponentExists = participantIds.reduce(function (p, c) { return roundPlayers.includes(c) || p; }, false);
|
|
37432
|
+
if (!opponentExists) {
|
|
37433
|
+
roundPlayers.push.apply(roundPlayers, __spreadArray([], __read(participantIds), false));
|
|
37434
|
+
var value = rankedPairing.value;
|
|
37435
|
+
candidateValue += value;
|
|
37436
|
+
participantIdPairings.push({ participantIds: participantIds, value: value });
|
|
37108
37437
|
}
|
|
37109
37438
|
});
|
|
37110
|
-
|
|
37439
|
+
// sort the candidate's proposed pairings by value
|
|
37440
|
+
participantIdPairings.sort(function (a, b) { return a.value - b.value; });
|
|
37441
|
+
// determine the greatest delta in the candidate's pairings
|
|
37442
|
+
var maxDelta = participantIdPairings.reduce(function (p, c) {
|
|
37443
|
+
var _a = __read(c.participantIds, 2), p1 = _a[0], p2 = _a[1];
|
|
37444
|
+
var hash = pairingHash(p1, p2);
|
|
37445
|
+
var delta = deltaObjects[hash];
|
|
37446
|
+
return delta > p ? delta : p;
|
|
37447
|
+
}, 0);
|
|
37448
|
+
// determine the greatest delta in the candidate's pairings
|
|
37449
|
+
var maxDiff = participantIdPairings.reduce(function (p, c) {
|
|
37450
|
+
var _a = __read(c.participantIds, 2), p1 = _a[0], p2 = _a[1];
|
|
37451
|
+
var hash = pairingHash(p1, p2);
|
|
37452
|
+
var diff = valueObjects[hash];
|
|
37453
|
+
return diff > p ? diff : p;
|
|
37454
|
+
}, 0);
|
|
37455
|
+
return { value: candidateValue, participantIdPairings: participantIdPairings, maxDelta: maxDelta, maxDiff: maxDiff };
|
|
37456
|
+
}
|
|
37457
|
+
function pairingHash(id1, id2) {
|
|
37458
|
+
return [id1, id2].sort(stringSort).join('|');
|
|
37111
37459
|
}
|
|
37112
37460
|
|
|
37113
|
-
|
|
37114
|
-
|
|
37115
|
-
|
|
37116
|
-
|
|
37117
|
-
|
|
37118
|
-
|
|
37119
|
-
|
|
37120
|
-
|
|
37121
|
-
|
|
37122
|
-
|
|
37123
|
-
var _b;
|
|
37124
|
-
var tournamentRecord = _a.tournamentRecord, scaleAttributes = _a.scaleAttributes, drawDefinition = _a.drawDefinition, entryStatuses = _a.entryStatuses, drawId = _a.drawId, event = _a.event, stage = _a.stage;
|
|
37125
|
-
if (!event)
|
|
37126
|
-
return { error: MISSING_EVENT };
|
|
37127
|
-
if (entryStatuses && !Array.isArray(entryStatuses))
|
|
37128
|
-
return decorateResult({
|
|
37129
|
-
result: { error: INVALID_VALUES },
|
|
37130
|
-
info: mustBeAnArray('entryStatus'),
|
|
37131
|
-
stack: 'removeScaleValues',
|
|
37461
|
+
function getPairingsData(_a) {
|
|
37462
|
+
var participantIds = _a.participantIds;
|
|
37463
|
+
var possiblePairings = {};
|
|
37464
|
+
var uniquePairings = [];
|
|
37465
|
+
participantIds.forEach(function (participantId) {
|
|
37466
|
+
possiblePairings[participantId] = participantIds.filter(function (id) { return id !== participantId; });
|
|
37467
|
+
possiblePairings[participantId].forEach(function (id) {
|
|
37468
|
+
var pairing = pairingHash(id, participantId);
|
|
37469
|
+
if (!uniquePairings.includes(pairing))
|
|
37470
|
+
uniquePairings.push(pairing);
|
|
37132
37471
|
});
|
|
37133
|
-
|
|
37134
|
-
|
|
37135
|
-
var
|
|
37136
|
-
|
|
37137
|
-
|
|
37138
|
-
|
|
37472
|
+
});
|
|
37473
|
+
var deltaObjects = Object.assign.apply(Object, __spreadArray([{}], __read(uniquePairings.map(function (pairing) {
|
|
37474
|
+
var _a;
|
|
37475
|
+
return (_a = {}, _a[pairing] = 0, _a);
|
|
37476
|
+
})), false));
|
|
37477
|
+
return { uniquePairings: uniquePairings, possiblePairings: possiblePairings, deltaObjects: deltaObjects };
|
|
37478
|
+
}
|
|
37479
|
+
|
|
37480
|
+
function getEncounters(_a) {
|
|
37481
|
+
var e_1, _b;
|
|
37482
|
+
var matchUps = _a.matchUps;
|
|
37483
|
+
var encounters = [];
|
|
37484
|
+
try {
|
|
37485
|
+
for (var matchUps_1 = __values(matchUps), matchUps_1_1 = matchUps_1.next(); !matchUps_1_1.done; matchUps_1_1 = matchUps_1.next()) {
|
|
37486
|
+
var matchUp = matchUps_1_1.value;
|
|
37487
|
+
var participantIds = matchUp.sides.map(extractAttributes('participantId'));
|
|
37488
|
+
if (participantIds.length === 2) {
|
|
37489
|
+
var _c = __read(participantIds, 2), p1 = _c[0], p2 = _c[1];
|
|
37490
|
+
var pairing = pairingHash(p1, p2);
|
|
37491
|
+
if (!encounters.includes(pairing))
|
|
37492
|
+
encounters.push(pairing);
|
|
37493
|
+
}
|
|
37139
37494
|
}
|
|
37140
|
-
|
|
37141
|
-
|
|
37495
|
+
}
|
|
37496
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
37497
|
+
finally {
|
|
37498
|
+
try {
|
|
37499
|
+
if (matchUps_1_1 && !matchUps_1_1.done && (_b = matchUps_1.return)) _b.call(matchUps_1);
|
|
37142
37500
|
}
|
|
37501
|
+
finally { if (e_1) throw e_1.error; }
|
|
37143
37502
|
}
|
|
37144
|
-
|
|
37145
|
-
return (!stage || !entry.entryStage || entry.entryStage === stage) &&
|
|
37146
|
-
(!entryStatuses || entryStatuses.includes(entry.entryStatus));
|
|
37147
|
-
});
|
|
37148
|
-
var participantIds = stageEntries.map(getParticipantId);
|
|
37149
|
-
return removeParticipantsScaleItems({
|
|
37150
|
-
tournamentRecord: tournamentRecord,
|
|
37151
|
-
scaleAttributes: scaleAttributes,
|
|
37152
|
-
participantIds: participantIds,
|
|
37153
|
-
});
|
|
37154
|
-
}
|
|
37155
|
-
|
|
37156
|
-
function applyLineUps(_a) {
|
|
37157
|
-
var e_1, _b, e_2, _c, e_3, _d, e_4, _e;
|
|
37158
|
-
var _f, _g, _h, _j;
|
|
37159
|
-
var tournamentRecord = _a.tournamentRecord, drawDefinition = _a.drawDefinition, matchUpId = _a.matchUpId, lineUps = _a.lineUps, event = _a.event;
|
|
37160
|
-
if (!tournamentRecord)
|
|
37161
|
-
return { error: MISSING_TOURNAMENT_RECORD };
|
|
37162
|
-
if (!drawDefinition)
|
|
37163
|
-
return { error: DRAW_DEFINITION_NOT_FOUND };
|
|
37164
|
-
if (typeof matchUpId !== 'string')
|
|
37165
|
-
return { error: INVALID_MATCHUP };
|
|
37166
|
-
if (!Array.isArray(lineUps))
|
|
37167
|
-
return { error: INVALID_VALUES, lineUps: lineUps };
|
|
37168
|
-
var stack = 'applyLineUps';
|
|
37169
|
-
var tournamentParticipants = tournamentRecord.participants || [];
|
|
37170
|
-
var result = findDrawMatchUp({
|
|
37171
|
-
tournamentParticipants: tournamentParticipants,
|
|
37172
|
-
inContext: true,
|
|
37173
|
-
drawDefinition: drawDefinition,
|
|
37174
|
-
matchUpId: matchUpId,
|
|
37175
|
-
});
|
|
37176
|
-
if (result.error)
|
|
37177
|
-
return result;
|
|
37178
|
-
if (!result.matchUp)
|
|
37179
|
-
return { error: MATCHUP_NOT_FOUND };
|
|
37180
|
-
var inContextMatchUp = result.matchUp, structure = result.structure;
|
|
37181
|
-
var drawPositions = inContextMatchUp.drawPositions, matchUpType = inContextMatchUp.matchUpType;
|
|
37182
|
-
if (matchUpType !== TEAM$1)
|
|
37183
|
-
return { error: INVALID_MATCHUP };
|
|
37184
|
-
if (!(drawPositions === null || drawPositions === void 0 ? void 0 : drawPositions.length))
|
|
37185
|
-
return { error: MISSING_DRAW_POSITIONS };
|
|
37186
|
-
var tieFormat = (_f = resolveTieFormat({
|
|
37187
|
-
matchUp: inContextMatchUp,
|
|
37188
|
-
drawDefinition: drawDefinition,
|
|
37189
|
-
structure: structure,
|
|
37190
|
-
event: event,
|
|
37191
|
-
})) === null || _f === void 0 ? void 0 : _f.tieFormat;
|
|
37192
|
-
// verify integrity of lineUps...
|
|
37193
|
-
// 1. all participantIds must be valid individualParticipantIds
|
|
37194
|
-
// 2. there should be at most one participantId for a given collectionPosition in singles
|
|
37195
|
-
// 3. there should be at most two participantIds for a given collectionPosition in doubles
|
|
37196
|
-
var sideAssignments = {};
|
|
37197
|
-
try {
|
|
37198
|
-
for (var lineUps_1 = __values(lineUps), lineUps_1_1 = lineUps_1.next(); !lineUps_1_1.done; lineUps_1_1 = lineUps_1.next()) {
|
|
37199
|
-
var lineUp = lineUps_1_1.value;
|
|
37200
|
-
if (!Array.isArray(lineUp))
|
|
37201
|
-
return { error: INVALID_VALUES, lineUp: lineUp };
|
|
37202
|
-
// maintain mapping of collectionId|collectionPosition to the participantIds assigned
|
|
37203
|
-
var collectionParticipantIds = {};
|
|
37204
|
-
var sideNumbers = [];
|
|
37205
|
-
var _loop_1 = function (lineUpAssignment) {
|
|
37206
|
-
var e_5, _m;
|
|
37207
|
-
if (typeof lineUpAssignment !== 'object')
|
|
37208
|
-
return { value: { error: INVALID_VALUES, lineUpAssignment: lineUpAssignment } };
|
|
37209
|
-
var participantId = lineUpAssignment.participantId, _o = lineUpAssignment.collectionAssignments, collectionAssignments = _o === void 0 ? [] : _o;
|
|
37210
|
-
if (!Array.isArray(collectionAssignments))
|
|
37211
|
-
return { value: { error: INVALID_VALUES, collectionAssignments: collectionAssignments } };
|
|
37212
|
-
var participant = tournamentParticipants.find(function (participant) { return participant.participantId === participantId; });
|
|
37213
|
-
if (!participant)
|
|
37214
|
-
return { value: { error: PARTICIPANT_NOT_FOUND } };
|
|
37215
|
-
if (participant.participantType !== INDIVIDUAL)
|
|
37216
|
-
return { value: { error: INVALID_PARTICIPANT_TYPE } };
|
|
37217
|
-
var sideNumber_1 = (_h = (_g = inContextMatchUp.sides) === null || _g === void 0 ? void 0 : _g.find(function (side) { var _a, _b; return (_b = (_a = side.participant) === null || _a === void 0 ? void 0 : _a.individualParticipantIds) === null || _b === void 0 ? void 0 : _b.includes(participantId); })) === null || _h === void 0 ? void 0 : _h.sideNumber;
|
|
37218
|
-
if (sideNumber_1)
|
|
37219
|
-
sideNumbers.push(sideNumber_1);
|
|
37220
|
-
var _loop_3 = function (collectionAssignment) {
|
|
37221
|
-
if (typeof collectionAssignment !== 'object')
|
|
37222
|
-
return { value: { error: INVALID_VALUES, collectionAssignment: collectionAssignment } };
|
|
37223
|
-
var collectionId = collectionAssignment.collectionId, collectionPosition = collectionAssignment.collectionPosition;
|
|
37224
|
-
var collectionDefinition = (_j = tieFormat === null || tieFormat === void 0 ? void 0 : tieFormat.collectionDefinitions) === null || _j === void 0 ? void 0 : _j.find(function (collectionDefinition) {
|
|
37225
|
-
return collectionDefinition.collectionId === collectionId;
|
|
37226
|
-
});
|
|
37227
|
-
// all collectionIds in the lineUp must be present in the tieFormat collectionDefinitions
|
|
37228
|
-
if (!collectionDefinition)
|
|
37229
|
-
return { value: { error: INVALID_VALUES, collectionId: collectionId } };
|
|
37230
|
-
var aggregator = "".concat(collectionId, "-").concat(collectionPosition);
|
|
37231
|
-
if (!collectionParticipantIds[aggregator]) {
|
|
37232
|
-
collectionParticipantIds[aggregator] = [];
|
|
37233
|
-
}
|
|
37234
|
-
var participantsCount = collectionParticipantIds[aggregator].length;
|
|
37235
|
-
if ((collectionDefinition.matchUpType === SINGLES && participantsCount) ||
|
|
37236
|
-
(collectionDefinition.matchUpType === DOUBLES &&
|
|
37237
|
-
participantsCount > 1)) {
|
|
37238
|
-
return { value: {
|
|
37239
|
-
info: 'Excessive collectionPosition assignments',
|
|
37240
|
-
error: INVALID_VALUES,
|
|
37241
|
-
} };
|
|
37242
|
-
}
|
|
37243
|
-
collectionParticipantIds[aggregator].push(participantId);
|
|
37244
|
-
};
|
|
37245
|
-
try {
|
|
37246
|
-
for (var collectionAssignments_1 = (e_5 = void 0, __values(collectionAssignments)), collectionAssignments_1_1 = collectionAssignments_1.next(); !collectionAssignments_1_1.done; collectionAssignments_1_1 = collectionAssignments_1.next()) {
|
|
37247
|
-
var collectionAssignment = collectionAssignments_1_1.value;
|
|
37248
|
-
var state_2 = _loop_3(collectionAssignment);
|
|
37249
|
-
if (typeof state_2 === "object")
|
|
37250
|
-
return state_2;
|
|
37251
|
-
}
|
|
37252
|
-
}
|
|
37253
|
-
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
37254
|
-
finally {
|
|
37255
|
-
try {
|
|
37256
|
-
if (collectionAssignments_1_1 && !collectionAssignments_1_1.done && (_m = collectionAssignments_1.return)) _m.call(collectionAssignments_1);
|
|
37257
|
-
}
|
|
37258
|
-
finally { if (e_5) throw e_5.error; }
|
|
37259
|
-
}
|
|
37260
|
-
};
|
|
37261
|
-
try {
|
|
37262
|
-
for (var lineUp_1 = (e_2 = void 0, __values(lineUp)), lineUp_1_1 = lineUp_1.next(); !lineUp_1_1.done; lineUp_1_1 = lineUp_1.next()) {
|
|
37263
|
-
var lineUpAssignment = lineUp_1_1.value;
|
|
37264
|
-
var state_1 = _loop_1(lineUpAssignment);
|
|
37265
|
-
if (typeof state_1 === "object")
|
|
37266
|
-
return state_1.value;
|
|
37267
|
-
}
|
|
37268
|
-
}
|
|
37269
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
37270
|
-
finally {
|
|
37271
|
-
try {
|
|
37272
|
-
if (lineUp_1_1 && !lineUp_1_1.done && (_c = lineUp_1.return)) _c.call(lineUp_1);
|
|
37273
|
-
}
|
|
37274
|
-
finally { if (e_2) throw e_2.error; }
|
|
37275
|
-
}
|
|
37276
|
-
// ensure that doubles pair participants exist, otherwise create
|
|
37277
|
-
var collectionParticipantIdPairs = Object.values(collectionParticipantIds);
|
|
37278
|
-
try {
|
|
37279
|
-
for (var collectionParticipantIdPairs_1 = (e_3 = void 0, __values(collectionParticipantIdPairs)), collectionParticipantIdPairs_1_1 = collectionParticipantIdPairs_1.next(); !collectionParticipantIdPairs_1_1.done; collectionParticipantIdPairs_1_1 = collectionParticipantIdPairs_1.next()) {
|
|
37280
|
-
var participantIds = collectionParticipantIdPairs_1_1.value;
|
|
37281
|
-
if (participantIds.length === 2) {
|
|
37282
|
-
var pairedParticipant = getPairedParticipant({
|
|
37283
|
-
tournamentParticipants: tournamentParticipants,
|
|
37284
|
-
participantIds: participantIds,
|
|
37285
|
-
}).participant;
|
|
37286
|
-
if (!pairedParticipant) {
|
|
37287
|
-
// create pair participant
|
|
37288
|
-
var newPairParticipant = {
|
|
37289
|
-
participantType: PAIR,
|
|
37290
|
-
participantRole: COMPETITOR,
|
|
37291
|
-
individualParticipantIds: participantIds,
|
|
37292
|
-
};
|
|
37293
|
-
var result_1 = addParticipant({
|
|
37294
|
-
participant: newPairParticipant,
|
|
37295
|
-
pairOverride: true,
|
|
37296
|
-
tournamentRecord: tournamentRecord,
|
|
37297
|
-
});
|
|
37298
|
-
if (result_1.error)
|
|
37299
|
-
return result_1;
|
|
37300
|
-
}
|
|
37301
|
-
}
|
|
37302
|
-
}
|
|
37303
|
-
}
|
|
37304
|
-
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
37305
|
-
finally {
|
|
37306
|
-
try {
|
|
37307
|
-
if (collectionParticipantIdPairs_1_1 && !collectionParticipantIdPairs_1_1.done && (_d = collectionParticipantIdPairs_1.return)) _d.call(collectionParticipantIdPairs_1);
|
|
37308
|
-
}
|
|
37309
|
-
finally { if (e_3) throw e_3.error; }
|
|
37310
|
-
}
|
|
37311
|
-
// determine sideNumber based on instances of participants appearing in team participants assigned to sides
|
|
37312
|
-
// allows for some team members to be "borrowed"
|
|
37313
|
-
var instances = instanceCount(sideNumbers);
|
|
37314
|
-
var sideNumber = ((instances[1] || 0) > (instances[2] || 0) && 1) ||
|
|
37315
|
-
((instances[2] || 0) > (instances[1] || 0) && 2) ||
|
|
37316
|
-
undefined;
|
|
37317
|
-
// if side not previously assigned, map sideNumber to lineUp
|
|
37318
|
-
var sideAssignmentKeys = Object.keys(sideAssignments).map(function (key) {
|
|
37319
|
-
return parseInt(key);
|
|
37320
|
-
});
|
|
37321
|
-
if (sideNumber && !sideAssignmentKeys.includes(sideNumber)) {
|
|
37322
|
-
sideAssignments[sideNumber] = lineUp;
|
|
37323
|
-
}
|
|
37324
|
-
}
|
|
37325
|
-
}
|
|
37326
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
37327
|
-
finally {
|
|
37328
|
-
try {
|
|
37329
|
-
if (lineUps_1_1 && !lineUps_1_1.done && (_b = lineUps_1.return)) _b.call(lineUps_1);
|
|
37330
|
-
}
|
|
37331
|
-
finally { if (e_1) throw e_1.error; }
|
|
37332
|
-
}
|
|
37333
|
-
if (!Object.keys(sideAssignments).length)
|
|
37334
|
-
return { error: VALUE_UNCHANGED };
|
|
37335
|
-
result = findDrawMatchUp({ drawDefinition: drawDefinition, matchUpId: matchUpId });
|
|
37336
|
-
if (result.error)
|
|
37337
|
-
return result;
|
|
37338
|
-
if (!result.matchUp)
|
|
37339
|
-
return { error: MATCHUP_NOT_FOUND };
|
|
37340
|
-
var matchUp = result.matchUp;
|
|
37341
|
-
if (!matchUp.sides)
|
|
37342
|
-
matchUp.sides = [];
|
|
37343
|
-
var _loop_2 = function (sideNumber) {
|
|
37344
|
-
var side = matchUp.sides.find(function (side) { return side.sideNumber === sideNumber; });
|
|
37345
|
-
var assignment = sideAssignments[sideNumber];
|
|
37346
|
-
if (!assignment) {
|
|
37347
|
-
return "continue";
|
|
37348
|
-
}
|
|
37349
|
-
else if (!side) {
|
|
37350
|
-
matchUp.sides.push({ lineUp: assignment, sideNumber: sideNumber });
|
|
37351
|
-
}
|
|
37352
|
-
else {
|
|
37353
|
-
side.lineUp = assignment;
|
|
37354
|
-
}
|
|
37355
|
-
};
|
|
37356
|
-
try {
|
|
37357
|
-
for (var _k = __values([1, 2]), _l = _k.next(); !_l.done; _l = _k.next()) {
|
|
37358
|
-
var sideNumber = _l.value;
|
|
37359
|
-
_loop_2(sideNumber);
|
|
37360
|
-
}
|
|
37361
|
-
}
|
|
37362
|
-
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
37363
|
-
finally {
|
|
37364
|
-
try {
|
|
37365
|
-
if (_l && !_l.done && (_e = _k.return)) _e.call(_k);
|
|
37366
|
-
}
|
|
37367
|
-
finally { if (e_4) throw e_4.error; }
|
|
37368
|
-
}
|
|
37369
|
-
modifyMatchUpNotice({
|
|
37370
|
-
tournamentId: tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.tournamentId,
|
|
37371
|
-
context: stack,
|
|
37372
|
-
drawDefinition: drawDefinition,
|
|
37373
|
-
matchUp: matchUp,
|
|
37374
|
-
});
|
|
37375
|
-
return __assign({}, SUCCESS);
|
|
37376
|
-
}
|
|
37377
|
-
|
|
37378
|
-
function resetTieFormat(params) {
|
|
37379
|
-
var _a, _b, e_1, _c, e_2, _d;
|
|
37380
|
-
var _e, _f, _g;
|
|
37381
|
-
var stack = 'resetTieFormat';
|
|
37382
|
-
var drawDefinition = params.drawDefinition, event = params.event, uuids = params.uuids;
|
|
37383
|
-
var paramCheck = checkRequiredParameters(params, [(_a = {}, _a[TOURNAMENT_RECORD] = true, _a[MATCHUP_ID] = true, _a)], stack);
|
|
37384
|
-
if (paramCheck.error)
|
|
37385
|
-
return paramCheck;
|
|
37386
|
-
var resolutions = resolveFromParameters(params, [(_b = {}, _b[PARAM] = MATCHUP, _b)]);
|
|
37387
|
-
if (resolutions[ERROR])
|
|
37388
|
-
return resolutions;
|
|
37389
|
-
var tournamentId = (_e = params.tournamentRecord) === null || _e === void 0 ? void 0 : _e.tournamentId;
|
|
37390
|
-
var _h = (_f = resolutions === null || resolutions === void 0 ? void 0 : resolutions.matchUp) !== null && _f !== void 0 ? _f : {}, matchUp = _h.matchUp, structure = _h.structure;
|
|
37391
|
-
if (!(matchUp === null || matchUp === void 0 ? void 0 : matchUp.tieMatchUps))
|
|
37392
|
-
return decorateResult({
|
|
37393
|
-
result: { error: INVALID_MATCHUP },
|
|
37394
|
-
info: 'Must be a TEAM matchUp',
|
|
37395
|
-
stack: stack,
|
|
37396
|
-
});
|
|
37397
|
-
// if there is no tieFormat there is nothing to do
|
|
37398
|
-
if (!matchUp.tieFormat)
|
|
37399
|
-
return __assign({}, SUCCESS);
|
|
37400
|
-
var tieFormat = (_g = resolveTieFormat({
|
|
37401
|
-
structure: structure,
|
|
37402
|
-
drawDefinition: drawDefinition,
|
|
37403
|
-
event: event,
|
|
37404
|
-
})) === null || _g === void 0 ? void 0 : _g.tieFormat;
|
|
37405
|
-
if (!tieFormat)
|
|
37406
|
-
return decorateResult({
|
|
37407
|
-
result: { error: NOT_FOUND },
|
|
37408
|
-
info: 'No inherited tieFormat',
|
|
37409
|
-
stack: stack,
|
|
37410
|
-
});
|
|
37411
|
-
var deletedMatchUpIds = [];
|
|
37412
|
-
var collectionIds = [];
|
|
37413
|
-
var tieMatchUps = [];
|
|
37414
|
-
var newMatchUps = [];
|
|
37415
|
-
var _loop_1 = function (collectionDefinition) {
|
|
37416
|
-
// delete any matchUp.tieMatchUps that are not found in the ancestor tieFormat collectionDefinitions
|
|
37417
|
-
var matchUpCount = collectionDefinition.matchUpCount, collectionId = collectionDefinition.collectionId;
|
|
37418
|
-
collectionIds.push(collectionId);
|
|
37419
|
-
var existingCollectionMatchUps = (matchUp.tieMatchUps || []).filter(function (matchUp) { return matchUp.collectionId === collectionId; });
|
|
37420
|
-
if (existingCollectionMatchUps.length > matchUpCount) {
|
|
37421
|
-
// sort by matchUpStatus to prioritize active or completed matchUpsA
|
|
37422
|
-
existingCollectionMatchUps.sort(function (a, b) {
|
|
37423
|
-
return (a.matchUpStatus === TO_BE_PLAYED ? 1 : 0) -
|
|
37424
|
-
(b.matchUpStatus === TO_BE_PLAYED ? 1 : 0);
|
|
37425
|
-
});
|
|
37426
|
-
tieMatchUps.push.apply(tieMatchUps, __spreadArray([], __read(existingCollectionMatchUps.slice(0, matchUpCount)), false));
|
|
37427
|
-
deletedMatchUpIds.push.apply(deletedMatchUpIds, __spreadArray([], __read(existingCollectionMatchUps.slice(3).map(getMatchUpId)), false));
|
|
37428
|
-
}
|
|
37429
|
-
else {
|
|
37430
|
-
tieMatchUps.push.apply(tieMatchUps, __spreadArray([], __read(existingCollectionMatchUps), false));
|
|
37431
|
-
if (existingCollectionMatchUps.length < matchUpCount) {
|
|
37432
|
-
var matchUpsLimit = matchUpCount - existingCollectionMatchUps.length;
|
|
37433
|
-
var matchUps = generateCollectionMatchUps({
|
|
37434
|
-
collectionDefinition: collectionDefinition,
|
|
37435
|
-
matchUpsLimit: matchUpsLimit,
|
|
37436
|
-
uuids: uuids,
|
|
37437
|
-
});
|
|
37438
|
-
newMatchUps.push.apply(newMatchUps, __spreadArray([], __read(matchUps), false));
|
|
37439
|
-
}
|
|
37440
|
-
}
|
|
37441
|
-
};
|
|
37442
|
-
try {
|
|
37443
|
-
for (var _j = __values(tieFormat.collectionDefinitions), _k = _j.next(); !_k.done; _k = _j.next()) {
|
|
37444
|
-
var collectionDefinition = _k.value;
|
|
37445
|
-
_loop_1(collectionDefinition);
|
|
37446
|
-
}
|
|
37447
|
-
}
|
|
37448
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
37449
|
-
finally {
|
|
37450
|
-
try {
|
|
37451
|
-
if (_k && !_k.done && (_c = _j.return)) _c.call(_j);
|
|
37452
|
-
}
|
|
37453
|
-
finally { if (e_1) throw e_1.error; }
|
|
37454
|
-
}
|
|
37455
|
-
try {
|
|
37456
|
-
for (var _l = __values((matchUp === null || matchUp === void 0 ? void 0 : matchUp.tieMatchUps) || []), _m = _l.next(); !_m.done; _m = _l.next()) {
|
|
37457
|
-
var tieMatchUp = _m.value;
|
|
37458
|
-
if (tieMatchUp.collectionId &&
|
|
37459
|
-
!collectionIds.includes(tieMatchUp.collectionId))
|
|
37460
|
-
deletedMatchUpIds.push(tieMatchUp.matchUpId);
|
|
37461
|
-
}
|
|
37462
|
-
}
|
|
37463
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
37464
|
-
finally {
|
|
37465
|
-
try {
|
|
37466
|
-
if (_m && !_m.done && (_d = _l.return)) _d.call(_l);
|
|
37467
|
-
}
|
|
37468
|
-
finally { if (e_2) throw e_2.error; }
|
|
37469
|
-
}
|
|
37470
|
-
if (newMatchUps.length) {
|
|
37471
|
-
tieMatchUps.push.apply(tieMatchUps, __spreadArray([], __read(newMatchUps), false));
|
|
37472
|
-
addMatchUpsNotice({
|
|
37473
|
-
eventId: event === null || event === void 0 ? void 0 : event.eventId,
|
|
37474
|
-
matchUps: newMatchUps,
|
|
37475
|
-
drawDefinition: drawDefinition,
|
|
37476
|
-
tournamentId: tournamentId,
|
|
37477
|
-
});
|
|
37478
|
-
}
|
|
37479
|
-
if (deletedMatchUpIds.length) {
|
|
37480
|
-
deleteMatchUpsNotice({
|
|
37481
|
-
matchUpIds: deletedMatchUpIds,
|
|
37482
|
-
eventId: event === null || event === void 0 ? void 0 : event.eventId,
|
|
37483
|
-
drawDefinition: drawDefinition,
|
|
37484
|
-
tournamentId: tournamentId,
|
|
37485
|
-
});
|
|
37486
|
-
}
|
|
37487
|
-
if (matchUp) {
|
|
37488
|
-
matchUp.tieMatchUps = tieMatchUps;
|
|
37489
|
-
matchUp.tieFormatId = undefined;
|
|
37490
|
-
matchUp.tieFormat = undefined;
|
|
37491
|
-
modifyMatchUpNotice({
|
|
37492
|
-
structureId: structure === null || structure === void 0 ? void 0 : structure.structureId,
|
|
37493
|
-
eventId: event === null || event === void 0 ? void 0 : event.eventId,
|
|
37494
|
-
context: stack,
|
|
37495
|
-
drawDefinition: drawDefinition,
|
|
37496
|
-
tournamentId: tournamentId,
|
|
37497
|
-
matchUp: matchUp,
|
|
37498
|
-
});
|
|
37499
|
-
}
|
|
37500
|
-
return __assign(__assign({}, SUCCESS), { newMatchUps: newMatchUps, deletedMatchUpIds: deletedMatchUpIds });
|
|
37501
|
-
}
|
|
37502
|
-
|
|
37503
|
-
function resetScorecard(params) {
|
|
37504
|
-
var e_1, _a;
|
|
37505
|
-
var _b, _c;
|
|
37506
|
-
var tournamentRecord = params.tournamentRecord, drawDefinition = params.drawDefinition, matchUpId = params.matchUpId, event = params.event;
|
|
37507
|
-
var stack = 'resetScorecard';
|
|
37508
|
-
// Check for missing parameters ---------------------------------------------
|
|
37509
|
-
if (!drawDefinition)
|
|
37510
|
-
return decorateResult({
|
|
37511
|
-
result: { error: MISSING_DRAW_DEFINITION },
|
|
37512
|
-
stack: stack,
|
|
37513
|
-
});
|
|
37514
|
-
if (!matchUpId)
|
|
37515
|
-
return decorateResult({ result: { error: MISSING_MATCHUP_ID }, stack: stack });
|
|
37516
|
-
if (!isString(matchUpId))
|
|
37517
|
-
return decorateResult({
|
|
37518
|
-
result: { error: INVALID_VALUES, matchUpId: matchUpId },
|
|
37519
|
-
stack: stack,
|
|
37520
|
-
});
|
|
37521
|
-
// Get map of all drawMatchUps and inContextDrawMatchUPs ---------------------
|
|
37522
|
-
var matchUpsMap = getMatchUpsMap({ drawDefinition: drawDefinition });
|
|
37523
|
-
var inContextDrawMatchUps = getAllDrawMatchUps({
|
|
37524
|
-
nextMatchUps: true,
|
|
37525
|
-
inContext: true,
|
|
37526
|
-
drawDefinition: drawDefinition,
|
|
37527
|
-
matchUpsMap: matchUpsMap,
|
|
37528
|
-
}).matchUps;
|
|
37529
|
-
// Find target matchUp ------------------------------------------------------
|
|
37530
|
-
var matchUp = matchUpsMap.drawMatchUps.find(function (matchUp) { return matchUp.matchUpId === matchUpId; });
|
|
37531
|
-
var inContextMatchUp = inContextDrawMatchUps === null || inContextDrawMatchUps === void 0 ? void 0 : inContextDrawMatchUps.find(function (matchUp) { return matchUp.matchUpId === matchUpId; });
|
|
37532
|
-
if (!matchUp || !inContextDrawMatchUps)
|
|
37533
|
-
return { error: MATCHUP_NOT_FOUND };
|
|
37534
|
-
// only accept matchUpType: TEAM
|
|
37535
|
-
if (matchUp.matchUpType !== TEAM_EVENT)
|
|
37536
|
-
return { error: INVALID_MATCHUP };
|
|
37537
|
-
// Get winner/loser position targets ----------------------------------------
|
|
37538
|
-
var targetData = positionTargets({
|
|
37539
|
-
inContextDrawMatchUps: inContextDrawMatchUps,
|
|
37540
|
-
drawDefinition: drawDefinition,
|
|
37541
|
-
matchUpId: matchUpId,
|
|
37542
|
-
});
|
|
37543
|
-
var structureId = inContextMatchUp === null || inContextMatchUp === void 0 ? void 0 : inContextMatchUp.structureId;
|
|
37544
|
-
var structure = findStructure({ drawDefinition: drawDefinition, structureId: structureId }).structure;
|
|
37545
|
-
Object.assign(params, {
|
|
37546
|
-
inContextDrawMatchUps: inContextDrawMatchUps,
|
|
37547
|
-
inContextMatchUp: inContextMatchUp,
|
|
37548
|
-
matchUpsMap: matchUpsMap,
|
|
37549
|
-
targetData: targetData,
|
|
37550
|
-
structure: structure,
|
|
37551
|
-
matchUp: matchUp,
|
|
37552
|
-
});
|
|
37553
|
-
// with propagating winningSide changes, activeDownstream only applies to eventType: TEAM
|
|
37554
|
-
var activeDownstream = isActiveDownstream(params);
|
|
37555
|
-
if (activeDownstream)
|
|
37556
|
-
return { error: CANNOT_CHANGE_WINNING_SIDE };
|
|
37557
|
-
if ((_b = matchUp.tieMatchUps) === null || _b === void 0 ? void 0 : _b.length) {
|
|
37558
|
-
try {
|
|
37559
|
-
for (var _d = __values(matchUp.tieMatchUps), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
37560
|
-
var tieMatchUp = _e.value;
|
|
37561
|
-
var result_1 = setMatchUpState({
|
|
37562
|
-
matchUpId: tieMatchUp.matchUpId,
|
|
37563
|
-
matchUpTieId: matchUpId,
|
|
37564
|
-
winningSide: undefined,
|
|
37565
|
-
removeScore: true,
|
|
37566
|
-
tournamentRecord: tournamentRecord,
|
|
37567
|
-
drawDefinition: drawDefinition,
|
|
37568
|
-
event: event,
|
|
37569
|
-
});
|
|
37570
|
-
if (result_1.error)
|
|
37571
|
-
return decorateResult({ result: result_1, stack: stack });
|
|
37572
|
-
}
|
|
37573
|
-
}
|
|
37574
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
37575
|
-
finally {
|
|
37576
|
-
try {
|
|
37577
|
-
if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
|
|
37578
|
-
}
|
|
37579
|
-
finally { if (e_1) throw e_1.error; }
|
|
37580
|
-
}
|
|
37581
|
-
}
|
|
37582
|
-
var result = updateTieMatchUpScore({
|
|
37583
|
-
event: params.event,
|
|
37584
|
-
removeScore: true,
|
|
37585
|
-
tournamentRecord: tournamentRecord,
|
|
37586
|
-
drawDefinition: drawDefinition,
|
|
37587
|
-
matchUpsMap: matchUpsMap,
|
|
37588
|
-
matchUpId: matchUpId,
|
|
37589
|
-
});
|
|
37590
|
-
if (result.error)
|
|
37591
|
-
return decorateResult({ result: result, stack: stack });
|
|
37592
|
-
if (params.tiebreakReset && !result.tieFormatRemoved) {
|
|
37593
|
-
// check for scenarios where an added "Tiebreaker" collectionDefinition/matchUp has been added
|
|
37594
|
-
var inheritedTieFormat = (_c = resolveTieFormat({
|
|
37595
|
-
drawDefinition: drawDefinition,
|
|
37596
|
-
structure: structure,
|
|
37597
|
-
event: event,
|
|
37598
|
-
})) === null || _c === void 0 ? void 0 : _c.tieFormat;
|
|
37599
|
-
if (matchUp.tieFormat && inheritedTieFormat) {
|
|
37600
|
-
var _f = compareTieFormats({
|
|
37601
|
-
descendant: matchUp.tieFormat,
|
|
37602
|
-
ancestor: inheritedTieFormat,
|
|
37603
|
-
}), matchUpCountDifference = _f.matchUpCountDifference, descendantDifferences = _f.descendantDifferences, ancestorDifferences = _f.ancestorDifferences, valueDifference = _f.valueDifference;
|
|
37604
|
-
if (descendantDifferences.collectionIds.length === 1 &&
|
|
37605
|
-
!ancestorDifferences.collectionIds.length &&
|
|
37606
|
-
!ancestorDifferences.groupsCount &&
|
|
37607
|
-
matchUpCountDifference === 1 &&
|
|
37608
|
-
valueDifference === 1) {
|
|
37609
|
-
var result_2 = resetTieFormat({
|
|
37610
|
-
tournamentRecord: tournamentRecord,
|
|
37611
|
-
drawDefinition: drawDefinition,
|
|
37612
|
-
matchUpId: matchUpId,
|
|
37613
|
-
event: event,
|
|
37614
|
-
});
|
|
37615
|
-
if (result_2.error)
|
|
37616
|
-
return result_2;
|
|
37617
|
-
}
|
|
37618
|
-
}
|
|
37619
|
-
}
|
|
37620
|
-
return __assign({}, SUCCESS);
|
|
37621
|
-
}
|
|
37622
|
-
|
|
37623
|
-
function removeSeeding(_a) {
|
|
37624
|
-
var _b, _c;
|
|
37625
|
-
var tournamentRecord = _a.tournamentRecord, drawDefinition = _a.drawDefinition, entryStatuses = _a.entryStatuses, scaleName = _a.scaleName, drawId = _a.drawId, event = _a.event, stage = _a.stage;
|
|
37626
|
-
if (!tournamentRecord)
|
|
37627
|
-
return { error: MISSING_TOURNAMENT_RECORD };
|
|
37628
|
-
if (!event)
|
|
37629
|
-
return { error: MISSING_EVENT };
|
|
37630
|
-
scaleName =
|
|
37631
|
-
scaleName ||
|
|
37632
|
-
((_b = event.category) === null || _b === void 0 ? void 0 : _b.categoryName) ||
|
|
37633
|
-
((_c = event.category) === null || _c === void 0 ? void 0 : _c.ageCategoryCode);
|
|
37634
|
-
var scaleAttributes = {
|
|
37635
|
-
eventType: event.eventType,
|
|
37636
|
-
scaleType: SEEDING$1,
|
|
37637
|
-
scaleName: scaleName,
|
|
37638
|
-
};
|
|
37639
|
-
return removeScaleValues({
|
|
37640
|
-
tournamentRecord: tournamentRecord,
|
|
37641
|
-
scaleAttributes: scaleAttributes,
|
|
37642
|
-
drawDefinition: drawDefinition,
|
|
37643
|
-
entryStatuses: entryStatuses,
|
|
37644
|
-
drawId: drawId,
|
|
37645
|
-
event: event,
|
|
37646
|
-
stage: stage,
|
|
37647
|
-
});
|
|
37648
|
-
}
|
|
37649
|
-
|
|
37650
|
-
function generateAdHocMatchUps(_a) {
|
|
37651
|
-
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
37652
|
-
var participantIdPairings = _a.participantIdPairings, _p = _a.matchUpIds, matchUpIds = _p === void 0 ? [] : _p, drawDefinition = _a.drawDefinition, matchUpsCount = _a.matchUpsCount, roundNumber = _a.roundNumber, structureId = _a.structureId, newRound = _a.newRound;
|
|
37653
|
-
if (typeof drawDefinition !== 'object')
|
|
37654
|
-
return { error: MISSING_DRAW_DEFINITION };
|
|
37655
|
-
if (!structureId && ((_b = drawDefinition.structures) === null || _b === void 0 ? void 0 : _b.length) === 1)
|
|
37656
|
-
structureId = (_d = (_c = drawDefinition.structures) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.structureId;
|
|
37657
|
-
if (typeof structureId !== 'string')
|
|
37658
|
-
return { error: MISSING_STRUCTURE_ID };
|
|
37659
|
-
// if drawDefinition and structureId are provided it is possible to infer roundNumber
|
|
37660
|
-
var structure = (_e = drawDefinition.structures) === null || _e === void 0 ? void 0 : _e.find(function (structure) { return structure.structureId === structureId; });
|
|
37661
|
-
if (!structure)
|
|
37662
|
-
return { error: STRUCTURE_NOT_FOUND };
|
|
37663
|
-
var structureHasRoundPositions;
|
|
37664
|
-
var existingMatchUps = (_f = structure.matchUps) !== null && _f !== void 0 ? _f : [];
|
|
37665
|
-
var lastRoundNumber = existingMatchUps === null || existingMatchUps === void 0 ? void 0 : existingMatchUps.reduce(function (roundNumber, matchUp) {
|
|
37666
|
-
if (matchUp.roundPosition)
|
|
37667
|
-
structureHasRoundPositions = true;
|
|
37668
|
-
return ((matchUp === null || matchUp === void 0 ? void 0 : matchUp.roundNumber) || 0) > roundNumber
|
|
37669
|
-
? matchUp.roundNumber
|
|
37670
|
-
: roundNumber;
|
|
37671
|
-
}, 0);
|
|
37672
|
-
if (!matchUpsCount) {
|
|
37673
|
-
var selectedEntries = (_h = (_g = drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.entries) === null || _g === void 0 ? void 0 : _g.filter(function (entry) {
|
|
37674
|
-
var entryStatus = entry.entryStatus;
|
|
37675
|
-
return STRUCTURE_SELECTED_STATUSES.includes(entryStatus);
|
|
37676
|
-
})) !== null && _h !== void 0 ? _h : [];
|
|
37677
|
-
var roundMatchUpsCount = Math.floor((selectedEntries === null || selectedEntries === void 0 ? void 0 : selectedEntries.length) / 2) || 1;
|
|
37678
|
-
if (newRound) {
|
|
37679
|
-
matchUpsCount = roundMatchUpsCount;
|
|
37680
|
-
}
|
|
37681
|
-
else {
|
|
37682
|
-
var targetRoundNumber_1 = (_j = roundNumber !== null && roundNumber !== void 0 ? roundNumber : lastRoundNumber) !== null && _j !== void 0 ? _j : 1;
|
|
37683
|
-
var existingRoundMatchUps = (_m = (_l = (_k = structure.matchUps) === null || _k === void 0 ? void 0 : _k.filter(function (matchUp) { return matchUp.roundNumber === targetRoundNumber_1; })) === null || _l === void 0 ? void 0 : _l.length) !== null && _m !== void 0 ? _m : 0;
|
|
37684
|
-
var maxRemaining = roundMatchUpsCount - existingRoundMatchUps;
|
|
37685
|
-
if (maxRemaining > 0)
|
|
37686
|
-
matchUpsCount = maxRemaining;
|
|
37687
|
-
}
|
|
37688
|
-
}
|
|
37689
|
-
if ((participantIdPairings && !Array.isArray(participantIdPairings)) ||
|
|
37690
|
-
(matchUpsCount && !isConvertableInteger(matchUpsCount)) ||
|
|
37691
|
-
(matchUpIds && !Array.isArray(matchUpIds)) ||
|
|
37692
|
-
(!participantIdPairings && !matchUpsCount)) {
|
|
37693
|
-
return { error: INVALID_VALUES, info: 'matchUpsCount or pairings error' };
|
|
37694
|
-
}
|
|
37695
|
-
// structure must not be a container of other structures
|
|
37696
|
-
// structure must not contain matchUps with roundPosition
|
|
37697
|
-
// structure must not determine finishingPosition by ROUND_OUTCOME
|
|
37698
|
-
if (structure.structures ||
|
|
37699
|
-
structureHasRoundPositions ||
|
|
37700
|
-
structure.finishingPosition === ROUND_OUTCOME) {
|
|
37701
|
-
return { error: INVALID_STRUCTURE };
|
|
37702
|
-
}
|
|
37703
|
-
if (roundNumber && roundNumber - 1 > (lastRoundNumber || 0))
|
|
37704
|
-
return { error: INVALID_VALUES, info: 'roundNumber error' };
|
|
37705
|
-
var nextRoundNumber = roundNumber !== null && roundNumber !== void 0 ? roundNumber : ((newRound && (lastRoundNumber !== null && lastRoundNumber !== void 0 ? lastRoundNumber : 0) + 1) || lastRoundNumber || 1);
|
|
37706
|
-
participantIdPairings =
|
|
37707
|
-
participantIdPairings !== null && participantIdPairings !== void 0 ? participantIdPairings : generateRange(0, matchUpsCount).map(function () { return ({
|
|
37708
|
-
participantIds: [undefined, undefined],
|
|
37709
|
-
}); });
|
|
37710
|
-
var matchUps = participantIdPairings === null || participantIdPairings === void 0 ? void 0 : participantIdPairings.map(function (pairing) {
|
|
37711
|
-
var _a, _b;
|
|
37712
|
-
var idStack = (_a = pairing === null || pairing === void 0 ? void 0 : pairing.participantIds) !== null && _a !== void 0 ? _a : [undefined, undefined];
|
|
37713
|
-
// ensure there are always 2 sides in generated matchUps
|
|
37714
|
-
idStack.push.apply(idStack, [undefined, undefined]);
|
|
37715
|
-
var participantIds = idStack.slice(0, 2);
|
|
37716
|
-
var sides = participantIds.map(function (participantId, i) {
|
|
37717
|
-
return definedAttributes({
|
|
37718
|
-
sideNumber: i + 1,
|
|
37719
|
-
participantId: participantId,
|
|
37720
|
-
});
|
|
37721
|
-
});
|
|
37722
|
-
return {
|
|
37723
|
-
matchUpId: (_b = matchUpIds.pop()) !== null && _b !== void 0 ? _b : UUID(),
|
|
37724
|
-
roundNumber: nextRoundNumber,
|
|
37725
|
-
matchUpStatus: TO_BE_PLAYED,
|
|
37726
|
-
sides: sides,
|
|
37727
|
-
};
|
|
37728
|
-
});
|
|
37729
|
-
return __assign({ matchUpsCount: (_o = matchUps === null || matchUps === void 0 ? void 0 : matchUps.length) !== null && _o !== void 0 ? _o : 0, matchUps: matchUps }, SUCCESS);
|
|
37730
|
-
}
|
|
37731
|
-
|
|
37732
|
-
function generateCandidate(_a) {
|
|
37733
|
-
var _b = _a.maxIterations, maxIterations = _b === void 0 ? 4000 : _b, // cap the processing intensity of the candidate generator
|
|
37734
|
-
valueSortedPairings = _a.valueSortedPairings, // pairings sorted by value from low to high
|
|
37735
|
-
pairingValues = _a.pairingValues, valueObjects = _a.valueObjects, deltaObjects = _a.deltaObjects;
|
|
37736
|
-
var pairingValueMap = Object.assign.apply(Object, __spreadArray([{}], __read(valueSortedPairings.map(function (rm) {
|
|
37737
|
-
var _a;
|
|
37738
|
-
return (_a = {}, _a[rm.pairing] = rm.value, _a);
|
|
37739
|
-
})), false));
|
|
37740
|
-
var actors = Object.keys(pairingValues);
|
|
37741
|
-
var proposedCandidates = [];
|
|
37742
|
-
// generate an initial candidate value with no stipulated pairings
|
|
37743
|
-
var initialProposal = roundCandidate({
|
|
37744
|
-
actorsCount: actors.length,
|
|
37745
|
-
valueSortedPairings: valueSortedPairings,
|
|
37746
|
-
pairingValueMap: pairingValueMap,
|
|
37747
|
-
deltaObjects: deltaObjects,
|
|
37748
|
-
valueObjects: valueObjects,
|
|
37749
|
-
});
|
|
37750
|
-
var candidateHashes = [candidateHash(initialProposal)];
|
|
37751
|
-
proposedCandidates.push(initialProposal);
|
|
37752
|
-
var lowCandidateValue = initialProposal.value;
|
|
37753
|
-
var deltaCandidate = initialProposal;
|
|
37754
|
-
// iterations is the number of loops over valueSortedPairings
|
|
37755
|
-
var candidatesCount = 0;
|
|
37756
|
-
var iterations = 0;
|
|
37757
|
-
var opponentCount = actors.length;
|
|
37758
|
-
var calculatedIterations;
|
|
37759
|
-
// calculate the number of opponents to consider for each participantId
|
|
37760
|
-
do {
|
|
37761
|
-
opponentCount -= 1;
|
|
37762
|
-
calculatedIterations = actors.length * pairingValues[actors[0]].length;
|
|
37763
|
-
} while (calculatedIterations > maxIterations && opponentCount > 5);
|
|
37764
|
-
// keep track of proposed pairings
|
|
37765
|
-
var stipulatedPairs = [];
|
|
37766
|
-
// for each actor generate a roundCandidate using opponentCount of pairing values
|
|
37767
|
-
actors.forEach(function (actor) {
|
|
37768
|
-
var participantIdPairings = pairingValues[actor];
|
|
37769
|
-
// opponentCount limits the number of opponents to consider
|
|
37770
|
-
participantIdPairings.slice(0, opponentCount).forEach(function (pairing) {
|
|
37771
|
-
iterations += 1;
|
|
37772
|
-
var stipulatedPair = pairingHash(actor, pairing.opponent);
|
|
37773
|
-
if (!stipulatedPairs.includes(stipulatedPair)) {
|
|
37774
|
-
var proposed = roundCandidate({
|
|
37775
|
-
// each roundCandidate starts with stipulated pairings
|
|
37776
|
-
stipulated: [[actor, pairing.opponent]],
|
|
37777
|
-
actorsCount: actors.length,
|
|
37778
|
-
valueSortedPairings: valueSortedPairings,
|
|
37779
|
-
pairingValueMap: pairingValueMap,
|
|
37780
|
-
deltaObjects: deltaObjects,
|
|
37781
|
-
valueObjects: valueObjects,
|
|
37782
|
-
});
|
|
37783
|
-
// ensure no duplicate candidates are considered
|
|
37784
|
-
if (!candidateHashes.includes(candidateHash(proposed))) {
|
|
37785
|
-
candidateHashes.push(candidateHash(proposed));
|
|
37786
|
-
proposedCandidates.push(proposed);
|
|
37787
|
-
var maxDelta = proposed.maxDelta, value = proposed.value;
|
|
37788
|
-
if (maxDelta < deltaCandidate.maxDelta)
|
|
37789
|
-
deltaCandidate = proposed;
|
|
37790
|
-
if (value < lowCandidateValue ||
|
|
37791
|
-
(value === lowCandidateValue && Math.round(Math.random())) // randomize if equivalent values
|
|
37792
|
-
) {
|
|
37793
|
-
lowCandidateValue = value;
|
|
37794
|
-
}
|
|
37795
|
-
stipulatedPairs.push(stipulatedPair);
|
|
37796
|
-
candidatesCount += 1;
|
|
37797
|
-
}
|
|
37798
|
-
}
|
|
37799
|
-
});
|
|
37800
|
-
proposedCandidates = proposedCandidates.filter(function (proposed) { return Math.abs(proposed.value - lowCandidateValue) < 5; });
|
|
37801
|
-
});
|
|
37802
|
-
proposedCandidates.sort(function (a, b) { return a.maxDiff - b.maxDiff; });
|
|
37803
|
-
var candidate = randomPop(proposedCandidates);
|
|
37804
|
-
return {
|
|
37805
|
-
candidatesCount: candidatesCount,
|
|
37806
|
-
deltaCandidate: deltaCandidate,
|
|
37807
|
-
maxIterations: maxIterations,
|
|
37808
|
-
iterations: iterations,
|
|
37809
|
-
candidate: candidate,
|
|
37810
|
-
};
|
|
37811
|
-
}
|
|
37812
|
-
function candidateHash(candidate) {
|
|
37813
|
-
return candidate.participantIdPairings
|
|
37814
|
-
.map(function (_a) {
|
|
37815
|
-
var participantIds = _a.participantIds;
|
|
37816
|
-
return participantIds.sort().join('|');
|
|
37817
|
-
})
|
|
37818
|
-
.sort()
|
|
37819
|
-
.join('/');
|
|
37820
|
-
}
|
|
37821
|
-
function roundCandidate(_a) {
|
|
37822
|
-
var valueSortedPairings = _a.valueSortedPairings, _b = _a.stipulated, stipulated = _b === void 0 ? [] : _b, pairingValueMap = _a.pairingValueMap, deltaObjects = _a.deltaObjects, valueObjects = _a.valueObjects, actorsCount = _a.actorsCount;
|
|
37823
|
-
// roundPlayers starts with the stipulated pairing
|
|
37824
|
-
var roundPlayers = [].concat.apply([], __spreadArray([], __read(stipulated), false));
|
|
37825
|
-
// aggregates the pairings generated for a roundCandidate
|
|
37826
|
-
var participantIdPairings = [];
|
|
37827
|
-
// candidateValue is the sum of all participantIdPairings in a roundCandidate
|
|
37828
|
-
// the winning candidate has the LOWEST total value
|
|
37829
|
-
var candidateValue = 0;
|
|
37830
|
-
// candidateValue is initialized with any stipulated pairings
|
|
37831
|
-
stipulated.filter(Boolean).forEach(function (participantIds) {
|
|
37832
|
-
var _a = __read(participantIds, 2), p1 = _a[0], p2 = _a[1];
|
|
37833
|
-
var pairing = pairingHash(p1, p2);
|
|
37834
|
-
var value = pairingValueMap[pairing];
|
|
37835
|
-
participantIdPairings.push({ participantIds: participantIds, value: value });
|
|
37836
|
-
candidateValue += pairingValueMap[pairing];
|
|
37837
|
-
});
|
|
37838
|
-
// valueSortedPairings is an array sorted from lowest value to highest value
|
|
37839
|
-
// introduce random shuffling of chunks of valueSortedPairings
|
|
37840
|
-
var consideredPairings = chunkArray(valueSortedPairings, actorsCount)
|
|
37841
|
-
.map(function (pairings) {
|
|
37842
|
-
return shuffleArray(pairings).map(function (pairing) { return (__assign(__assign({}, pairing), { value: pairing.value + Math.random() * Math.round(Math.random()) })); });
|
|
37843
|
-
})
|
|
37844
|
-
.flat();
|
|
37845
|
-
// go through the valueSortedPairings (of all possible unique pairings)
|
|
37846
|
-
consideredPairings.forEach(function (rankedPairing) {
|
|
37847
|
-
var participantIds = rankedPairing.pairing.split('|');
|
|
37848
|
-
var opponentExists = participantIds.reduce(function (p, c) { return roundPlayers.includes(c) || p; }, false);
|
|
37849
|
-
if (!opponentExists) {
|
|
37850
|
-
roundPlayers.push.apply(roundPlayers, __spreadArray([], __read(participantIds), false));
|
|
37851
|
-
var value = rankedPairing.value;
|
|
37852
|
-
candidateValue += value;
|
|
37853
|
-
participantIdPairings.push({ participantIds: participantIds, value: value });
|
|
37854
|
-
}
|
|
37855
|
-
});
|
|
37856
|
-
// sort the candidate's proposed pairings by value
|
|
37857
|
-
participantIdPairings.sort(function (a, b) { return a.value - b.value; });
|
|
37858
|
-
// determine the greatest delta in the candidate's pairings
|
|
37859
|
-
var maxDelta = participantIdPairings.reduce(function (p, c) {
|
|
37860
|
-
var _a = __read(c.participantIds, 2), p1 = _a[0], p2 = _a[1];
|
|
37861
|
-
var hash = pairingHash(p1, p2);
|
|
37862
|
-
var delta = deltaObjects[hash];
|
|
37863
|
-
return delta > p ? delta : p;
|
|
37864
|
-
}, 0);
|
|
37865
|
-
// determine the greatest delta in the candidate's pairings
|
|
37866
|
-
var maxDiff = participantIdPairings.reduce(function (p, c) {
|
|
37867
|
-
var _a = __read(c.participantIds, 2), p1 = _a[0], p2 = _a[1];
|
|
37868
|
-
var hash = pairingHash(p1, p2);
|
|
37869
|
-
var diff = valueObjects[hash];
|
|
37870
|
-
return diff > p ? diff : p;
|
|
37871
|
-
}, 0);
|
|
37872
|
-
return { value: candidateValue, participantIdPairings: participantIdPairings, maxDelta: maxDelta, maxDiff: maxDiff };
|
|
37873
|
-
}
|
|
37874
|
-
function pairingHash(id1, id2) {
|
|
37875
|
-
return [id1, id2].sort(stringSort).join('|');
|
|
37876
|
-
}
|
|
37877
|
-
|
|
37878
|
-
function getPairingsData(_a) {
|
|
37879
|
-
var participantIds = _a.participantIds;
|
|
37880
|
-
var possiblePairings = {};
|
|
37881
|
-
var uniquePairings = [];
|
|
37882
|
-
participantIds.forEach(function (participantId) {
|
|
37883
|
-
possiblePairings[participantId] = participantIds.filter(function (id) { return id !== participantId; });
|
|
37884
|
-
possiblePairings[participantId].forEach(function (id) {
|
|
37885
|
-
var pairing = pairingHash(id, participantId);
|
|
37886
|
-
if (!uniquePairings.includes(pairing))
|
|
37887
|
-
uniquePairings.push(pairing);
|
|
37888
|
-
});
|
|
37889
|
-
});
|
|
37890
|
-
var deltaObjects = Object.assign.apply(Object, __spreadArray([{}], __read(uniquePairings.map(function (pairing) {
|
|
37891
|
-
var _a;
|
|
37892
|
-
return (_a = {}, _a[pairing] = 0, _a);
|
|
37893
|
-
})), false));
|
|
37894
|
-
return { uniquePairings: uniquePairings, possiblePairings: possiblePairings, deltaObjects: deltaObjects };
|
|
37895
|
-
}
|
|
37896
|
-
|
|
37897
|
-
function getEncounters(_a) {
|
|
37898
|
-
var e_1, _b;
|
|
37899
|
-
var matchUps = _a.matchUps;
|
|
37900
|
-
var encounters = [];
|
|
37901
|
-
try {
|
|
37902
|
-
for (var matchUps_1 = __values(matchUps), matchUps_1_1 = matchUps_1.next(); !matchUps_1_1.done; matchUps_1_1 = matchUps_1.next()) {
|
|
37903
|
-
var matchUp = matchUps_1_1.value;
|
|
37904
|
-
var participantIds = matchUp.sides.map(extractAttributes('participantId'));
|
|
37905
|
-
if (participantIds.length === 2) {
|
|
37906
|
-
var _c = __read(participantIds, 2), p1 = _c[0], p2 = _c[1];
|
|
37907
|
-
var pairing = pairingHash(p1, p2);
|
|
37908
|
-
if (!encounters.includes(pairing))
|
|
37909
|
-
encounters.push(pairing);
|
|
37910
|
-
}
|
|
37911
|
-
}
|
|
37912
|
-
}
|
|
37913
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
37914
|
-
finally {
|
|
37915
|
-
try {
|
|
37916
|
-
if (matchUps_1_1 && !matchUps_1_1.done && (_b = matchUps_1.return)) _b.call(matchUps_1);
|
|
37917
|
-
}
|
|
37918
|
-
finally { if (e_1) throw e_1.error; }
|
|
37919
|
-
}
|
|
37920
|
-
return { encounters: encounters };
|
|
37503
|
+
return { encounters: encounters };
|
|
37921
37504
|
}
|
|
37922
37505
|
|
|
37923
37506
|
function getParticipantPairingValues(_a) {
|
|
@@ -38085,7 +37668,7 @@ var MAX_ITERATIONS = 4000;
|
|
|
38085
37668
|
function generateDrawMaticRound(_a) {
|
|
38086
37669
|
var e_1, _b, e_2, _c, e_3, _d;
|
|
38087
37670
|
var _e, _f;
|
|
38088
|
-
var _g = _a.encounterValue, encounterValue = _g === void 0 ? ENCOUNTER_VALUE : _g, _h = _a.sameTeamValue, sameTeamValue = _h === void 0 ? SAME_TEAM_VALUE : _h, _j = _a.maxIterations, maxIterations = _j === void 0 ? MAX_ITERATIONS : _j, _k = _a.generateMatchUps, generateMatchUps = _k === void 0 ? true : _k, tournamentParticipants = _a.tournamentParticipants, participantIds = _a.participantIds, drawDefinition = _a.drawDefinition, adHocRatings = _a.adHocRatings, structureId = _a.structureId, _l = _a.salted, salted = _l === void 0 ? 0.5 : _l, matchUpIds = _a.matchUpIds, eventType = _a.eventType, structure = _a.structure, scaleName = _a.scaleName;
|
|
37671
|
+
var _g = _a.encounterValue, encounterValue = _g === void 0 ? ENCOUNTER_VALUE : _g, _h = _a.sameTeamValue, sameTeamValue = _h === void 0 ? SAME_TEAM_VALUE : _h, _j = _a.maxIterations, maxIterations = _j === void 0 ? MAX_ITERATIONS : _j, _k = _a.generateMatchUps, generateMatchUps = _k === void 0 ? true : _k, tournamentParticipants = _a.tournamentParticipants, participantIds = _a.participantIds, drawDefinition = _a.drawDefinition, adHocRatings = _a.adHocRatings, structureId = _a.structureId, _l = _a.salted, salted = _l === void 0 ? 0.5 : _l, matchUpIds = _a.matchUpIds, eventType = _a.eventType, structure = _a.structure, scaleName = _a.scaleName, isMock = _a.isMock, event = _a.event;
|
|
38089
37672
|
if (!drawDefinition)
|
|
38090
37673
|
return { error: MISSING_DRAW_DEFINITION };
|
|
38091
37674
|
if (!structure && !structureId)
|
|
@@ -38118,218 +37701,847 @@ function generateDrawMaticRound(_a) {
|
|
|
38118
37701
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
38119
37702
|
finally {
|
|
38120
37703
|
try {
|
|
38121
|
-
if (encounters_1_1 && !encounters_1_1.done && (_b = encounters_1.return)) _b.call(encounters_1);
|
|
37704
|
+
if (encounters_1_1 && !encounters_1_1.done && (_b = encounters_1.return)) _b.call(encounters_1);
|
|
37705
|
+
}
|
|
37706
|
+
finally { if (e_1) throw e_1.error; }
|
|
37707
|
+
}
|
|
37708
|
+
var teamParticipants = tournamentParticipants === null || tournamentParticipants === void 0 ? void 0 : tournamentParticipants.filter(function (_a) {
|
|
37709
|
+
var participantType = _a.participantType;
|
|
37710
|
+
return participantType === TEAM;
|
|
37711
|
+
});
|
|
37712
|
+
if (teamParticipants) {
|
|
37713
|
+
try {
|
|
37714
|
+
// add SAME_TEAM_VALUE for participants who appear on the same team
|
|
37715
|
+
for (var teamParticipants_1 = __values(teamParticipants), teamParticipants_1_1 = teamParticipants_1.next(); !teamParticipants_1_1.done; teamParticipants_1_1 = teamParticipants_1.next()) {
|
|
37716
|
+
var teamParticipant = teamParticipants_1_1.value;
|
|
37717
|
+
var participantIds_1 = (_f = teamParticipant.individualParticipantIds) !== null && _f !== void 0 ? _f : [];
|
|
37718
|
+
var uniquePairings_2 = getPairingsData({ participantIds: participantIds_1 }).uniquePairings;
|
|
37719
|
+
try {
|
|
37720
|
+
for (var uniquePairings_1 = (e_3 = void 0, __values(uniquePairings_2)), uniquePairings_1_1 = uniquePairings_1.next(); !uniquePairings_1_1.done; uniquePairings_1_1 = uniquePairings_1.next()) {
|
|
37721
|
+
var pairing = uniquePairings_1_1.value;
|
|
37722
|
+
if (!valueObjects[pairing])
|
|
37723
|
+
valueObjects[pairing] = 0;
|
|
37724
|
+
valueObjects[pairing] += sameTeamValue;
|
|
37725
|
+
}
|
|
37726
|
+
}
|
|
37727
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
37728
|
+
finally {
|
|
37729
|
+
try {
|
|
37730
|
+
if (uniquePairings_1_1 && !uniquePairings_1_1.done && (_d = uniquePairings_1.return)) _d.call(uniquePairings_1);
|
|
37731
|
+
}
|
|
37732
|
+
finally { if (e_3) throw e_3.error; }
|
|
37733
|
+
}
|
|
37734
|
+
}
|
|
37735
|
+
}
|
|
37736
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
37737
|
+
finally {
|
|
37738
|
+
try {
|
|
37739
|
+
if (teamParticipants_1_1 && !teamParticipants_1_1.done && (_c = teamParticipants_1.return)) _c.call(teamParticipants_1);
|
|
37740
|
+
}
|
|
37741
|
+
finally { if (e_2) throw e_2.error; }
|
|
37742
|
+
}
|
|
37743
|
+
}
|
|
37744
|
+
// deltaObjects contain the difference in ratings between two participants
|
|
37745
|
+
// {
|
|
37746
|
+
// 'P-I-0|P-I-1': 0,
|
|
37747
|
+
// 'P-I-0|P-I-2': 0,
|
|
37748
|
+
// 'P-I-0|P-I-3': 0
|
|
37749
|
+
// }
|
|
37750
|
+
var _m = getPairingsData({
|
|
37751
|
+
participantIds: participantIds,
|
|
37752
|
+
}), uniquePairings = _m.uniquePairings, possiblePairings = _m.possiblePairings, deltaObjects = _m.deltaObjects;
|
|
37753
|
+
var params = {
|
|
37754
|
+
tournamentParticipants: tournamentParticipants,
|
|
37755
|
+
possiblePairings: possiblePairings,
|
|
37756
|
+
drawDefinition: drawDefinition,
|
|
37757
|
+
participantIds: participantIds,
|
|
37758
|
+
uniquePairings: uniquePairings,
|
|
37759
|
+
maxIterations: maxIterations,
|
|
37760
|
+
adHocRatings: adHocRatings,
|
|
37761
|
+
deltaObjects: deltaObjects,
|
|
37762
|
+
valueObjects: valueObjects,
|
|
37763
|
+
eventType: eventType,
|
|
37764
|
+
scaleName: scaleName,
|
|
37765
|
+
structure: structure,
|
|
37766
|
+
salted: salted,
|
|
37767
|
+
};
|
|
37768
|
+
var _o = getPairings(params), candidatesCount = _o.candidatesCount, participantIdPairings = _o.participantIdPairings, iterations = _o.iterations, candidate = _o.candidate;
|
|
37769
|
+
if (!candidatesCount)
|
|
37770
|
+
return { error: NO_CANDIDATES };
|
|
37771
|
+
var matchUps;
|
|
37772
|
+
if (generateMatchUps) {
|
|
37773
|
+
var result = generateAdHocMatchUps({
|
|
37774
|
+
structureId: structure === null || structure === void 0 ? void 0 : structure.structureId,
|
|
37775
|
+
participantIdPairings: participantIdPairings,
|
|
37776
|
+
newRound: true,
|
|
37777
|
+
drawDefinition: drawDefinition,
|
|
37778
|
+
matchUpIds: matchUpIds,
|
|
37779
|
+
isMock: isMock,
|
|
37780
|
+
event: event,
|
|
37781
|
+
});
|
|
37782
|
+
if (result.error)
|
|
37783
|
+
return result;
|
|
37784
|
+
matchUps = result.matchUps;
|
|
37785
|
+
}
|
|
37786
|
+
var maxDelta = candidate.maxDelta, maxDiff = candidate.maxDiff;
|
|
37787
|
+
return __assign(__assign({}, SUCCESS), { participantIdPairings: participantIdPairings, candidatesCount: candidatesCount, iterations: iterations, matchUps: matchUps, maxDelta: maxDelta, maxDiff: maxDiff });
|
|
37788
|
+
}
|
|
37789
|
+
|
|
37790
|
+
function drawMatic(_a) {
|
|
37791
|
+
var e_1, _b;
|
|
37792
|
+
var _c, _d, _e, _f, _g;
|
|
37793
|
+
var restrictEntryStatus = _a.restrictEntryStatus, _h = _a.adHocRatings, adHocRatings = _h === void 0 ? {} : _h, generateMatchUps = _a.generateMatchUps, tournamentRecord = _a.tournamentRecord, participantIds = _a.participantIds, encounterValue = _a.encounterValue, sameTeamValue = _a.sameTeamValue, drawDefinition = _a.drawDefinition, scaleAccessor = _a.scaleAccessor, maxIterations = _a.maxIterations, structureId = _a.structureId, matchUpIds = _a.matchUpIds, scaleName = _a.scaleName, // custom rating name to seed dynamic ratings
|
|
37794
|
+
eventType = _a.eventType, isMock = _a.isMock, salted = _a.salted, event = _a.event;
|
|
37795
|
+
if (typeof drawDefinition !== 'object' ||
|
|
37796
|
+
(drawDefinition.drawType && drawDefinition.drawType !== AD_HOC)) {
|
|
37797
|
+
return { error: INVALID_DRAW_DEFINITION };
|
|
37798
|
+
}
|
|
37799
|
+
if (!Array.isArray(drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.entries) &&
|
|
37800
|
+
participantIds &&
|
|
37801
|
+
!Array.isArray(participantIds)) {
|
|
37802
|
+
return { error: INVALID_VALUES, info: 'Missing Entries' };
|
|
37803
|
+
}
|
|
37804
|
+
eventType = eventType !== null && eventType !== void 0 ? eventType : event === null || event === void 0 ? void 0 : event.eventType;
|
|
37805
|
+
var enteredParticipantIds = (_c = drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.entries) === null || _c === void 0 ? void 0 : _c.filter(function (entry) {
|
|
37806
|
+
var entryStatus = entry.entryStatus;
|
|
37807
|
+
return (!restrictEntryStatus ||
|
|
37808
|
+
STRUCTURE_SELECTED_STATUSES.includes(entryStatus));
|
|
37809
|
+
}).map(getParticipantId);
|
|
37810
|
+
if (participantIds) {
|
|
37811
|
+
// ensure all participantIds are in drawDefinition.entries
|
|
37812
|
+
var invalidParticipantIds = participantIds.filter(function (participantId) { return !(enteredParticipantIds === null || enteredParticipantIds === void 0 ? void 0 : enteredParticipantIds.includes(participantId)); });
|
|
37813
|
+
if (invalidParticipantIds === null || invalidParticipantIds === void 0 ? void 0 : invalidParticipantIds.length)
|
|
37814
|
+
return decorateResult({
|
|
37815
|
+
result: { error: INVALID_PARTICIPANT_ID },
|
|
37816
|
+
info: { invalidParticipantIds: invalidParticipantIds },
|
|
37817
|
+
});
|
|
37818
|
+
}
|
|
37819
|
+
else {
|
|
37820
|
+
participantIds = enteredParticipantIds;
|
|
37821
|
+
}
|
|
37822
|
+
// if no structureId is specified find the latest AD_HOC stage which has matchUps
|
|
37823
|
+
if (!structureId) {
|
|
37824
|
+
var targetStructure = (_e = (_d = drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.structures) === null || _d === void 0 ? void 0 : _d.filter(function (structure) { return structure.stageSequence === 1; })) === null || _e === void 0 ? void 0 : _e.reduce(function (targetStructure, structure) {
|
|
37825
|
+
var orderNumber = structure.stage && stageOrder$1[structure.stage];
|
|
37826
|
+
var structureIsAdHoc = isAdHoc({ drawDefinition: drawDefinition, structure: structure });
|
|
37827
|
+
return structureIsAdHoc &&
|
|
37828
|
+
orderNumber > (stageOrder$1[targetStructure === null || targetStructure === void 0 ? void 0 : targetStructure.stage] || 1)
|
|
37829
|
+
? structure
|
|
37830
|
+
: targetStructure;
|
|
37831
|
+
}, undefined);
|
|
37832
|
+
structureId = targetStructure === null || targetStructure === void 0 ? void 0 : targetStructure.structureId;
|
|
37833
|
+
}
|
|
37834
|
+
var structure = (_f = drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.structures) === null || _f === void 0 ? void 0 : _f.find(function (structure) { return structure.structureId === structureId; });
|
|
37835
|
+
if (!structure)
|
|
37836
|
+
return { error: STRUCTURE_NOT_FOUND };
|
|
37837
|
+
// an AD_HOC structure is one that has no child structures and in which no matchUps have roundPosition
|
|
37838
|
+
var structureIsAdHoc = isAdHoc({ drawDefinition: drawDefinition, structure: structure });
|
|
37839
|
+
if (!structureIsAdHoc)
|
|
37840
|
+
return { error: INVALID_DRAW_DEFINITION };
|
|
37841
|
+
var tournamentParticipants = (_g = tournamentRecord.participants) !== null && _g !== void 0 ? _g : [];
|
|
37842
|
+
var _loop_1 = function (participantId) {
|
|
37843
|
+
var participant = tournamentParticipants === null || tournamentParticipants === void 0 ? void 0 : tournamentParticipants.find(function (participant) { return participant.participantId === participantId; });
|
|
37844
|
+
// first see if there is already a dynamic value
|
|
37845
|
+
var scaleValue = getScaleValue({
|
|
37846
|
+
scaleName: "".concat(scaleName, ".").concat(DYNAMIC),
|
|
37847
|
+
scaleAccessor: scaleAccessor,
|
|
37848
|
+
participant: participant,
|
|
37849
|
+
eventType: eventType,
|
|
37850
|
+
});
|
|
37851
|
+
// if no dynamic value found and a seeding scaleValue is provided...
|
|
37852
|
+
if (!scaleValue && scaleName) {
|
|
37853
|
+
scaleValue = getScaleValue({
|
|
37854
|
+
scaleAccessor: scaleAccessor,
|
|
37855
|
+
participant: participant,
|
|
37856
|
+
scaleName: scaleName,
|
|
37857
|
+
eventType: eventType,
|
|
37858
|
+
});
|
|
37859
|
+
}
|
|
37860
|
+
if (scaleValue && !adHocRatings[participantId])
|
|
37861
|
+
adHocRatings[participantId] = scaleValue;
|
|
37862
|
+
};
|
|
37863
|
+
try {
|
|
37864
|
+
for (var _j = __values(participantIds !== null && participantIds !== void 0 ? participantIds : []), _k = _j.next(); !_k.done; _k = _j.next()) {
|
|
37865
|
+
var participantId = _k.value;
|
|
37866
|
+
_loop_1(participantId);
|
|
37867
|
+
}
|
|
37868
|
+
}
|
|
37869
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
37870
|
+
finally {
|
|
37871
|
+
try {
|
|
37872
|
+
if (_k && !_k.done && (_b = _j.return)) _b.call(_j);
|
|
37873
|
+
}
|
|
37874
|
+
finally { if (e_1) throw e_1.error; }
|
|
37875
|
+
}
|
|
37876
|
+
// TODO: update dynamic ratings based on matchUps present from last played round
|
|
37877
|
+
// use scaleEngine.generateDynamicRatings(); see dynamicCalculations.test.ts
|
|
37878
|
+
return generateDrawMaticRound({
|
|
37879
|
+
tournamentParticipants: tournamentParticipants,
|
|
37880
|
+
generateMatchUps: generateMatchUps,
|
|
37881
|
+
participantIds: participantIds,
|
|
37882
|
+
encounterValue: encounterValue,
|
|
37883
|
+
sameTeamValue: sameTeamValue,
|
|
37884
|
+
drawDefinition: drawDefinition,
|
|
37885
|
+
maxIterations: maxIterations,
|
|
37886
|
+
adHocRatings: adHocRatings,
|
|
37887
|
+
matchUpIds: matchUpIds,
|
|
37888
|
+
structure: structure,
|
|
37889
|
+
eventType: eventType,
|
|
37890
|
+
salted: salted,
|
|
37891
|
+
isMock: isMock,
|
|
37892
|
+
event: event,
|
|
37893
|
+
});
|
|
37894
|
+
}
|
|
37895
|
+
function getScaleValue(_a) {
|
|
37896
|
+
var _b;
|
|
37897
|
+
var _c = _a.scaleType, scaleType = _c === void 0 ? RATING$2 : _c, scaleAccessor = _a.scaleAccessor, participant = _a.participant, scaleName = _a.scaleName, eventType = _a.eventType;
|
|
37898
|
+
var scaleAttributes = {
|
|
37899
|
+
eventType: eventType !== null && eventType !== void 0 ? eventType : SINGLES_EVENT,
|
|
37900
|
+
scaleType: scaleType,
|
|
37901
|
+
scaleName: scaleName,
|
|
37902
|
+
};
|
|
37903
|
+
var result = participant &&
|
|
37904
|
+
participantScaleItem({
|
|
37905
|
+
scaleAttributes: scaleAttributes,
|
|
37906
|
+
participant: participant,
|
|
37907
|
+
});
|
|
37908
|
+
var scaleValue = (_b = result === null || result === void 0 ? void 0 : result.scaleItem) === null || _b === void 0 ? void 0 : _b.scaleValue;
|
|
37909
|
+
return scaleAccessor && isObject(scaleValue)
|
|
37910
|
+
? scaleValue[scaleAccessor]
|
|
37911
|
+
: scaleValue;
|
|
37912
|
+
}
|
|
37913
|
+
|
|
37914
|
+
function addAdHocMatchUps(_a) {
|
|
37915
|
+
var _b;
|
|
37916
|
+
var _c, _d, _e, _f, _g, _h, _j;
|
|
37917
|
+
var tournamentRecord = _a.tournamentRecord, drawDefinition = _a.drawDefinition, structureId = _a.structureId, matchUps = _a.matchUps;
|
|
37918
|
+
if (typeof drawDefinition !== 'object')
|
|
37919
|
+
return { error: MISSING_DRAW_DEFINITION };
|
|
37920
|
+
if (!structureId && ((_c = drawDefinition.structures) === null || _c === void 0 ? void 0 : _c.length) === 1)
|
|
37921
|
+
structureId = (_e = (_d = drawDefinition.structures) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.structureId;
|
|
37922
|
+
if (typeof structureId !== 'string')
|
|
37923
|
+
return { error: MISSING_STRUCTURE_ID };
|
|
37924
|
+
if (!validMatchUps(matchUps))
|
|
37925
|
+
return { error: INVALID_VALUES, info: mustBeAnArray('matchUps') };
|
|
37926
|
+
var structure = (_f = drawDefinition.structures) === null || _f === void 0 ? void 0 : _f.find(function (structure) { return structure.structureId === structureId; });
|
|
37927
|
+
if (!structure)
|
|
37928
|
+
return { error: STRUCTURE_NOT_FOUND };
|
|
37929
|
+
var existingMatchUps = structure === null || structure === void 0 ? void 0 : structure.matchUps;
|
|
37930
|
+
var structureHasRoundPositions = existingMatchUps.find(function (matchUp) { return !!matchUp.roundPosition; });
|
|
37931
|
+
if (structure.structures ||
|
|
37932
|
+
structureHasRoundPositions ||
|
|
37933
|
+
structure.finishingPosition === ROUND_OUTCOME) {
|
|
37934
|
+
return { error: INVALID_STRUCTURE };
|
|
37935
|
+
}
|
|
37936
|
+
var existingMatchUpIds = (_j = (_h = (_g = allTournamentMatchUps({
|
|
37937
|
+
tournamentRecord: tournamentRecord,
|
|
37938
|
+
inContext: false,
|
|
37939
|
+
})) === null || _g === void 0 ? void 0 : _g.matchUps) === null || _h === void 0 ? void 0 : _h.map(getMatchUpId)) !== null && _j !== void 0 ? _j : [];
|
|
37940
|
+
var newMatchUpIds = matchUps.map(getMatchUpId);
|
|
37941
|
+
if (overlap(existingMatchUpIds, newMatchUpIds)) {
|
|
37942
|
+
return {
|
|
37943
|
+
error: EXISTING_MATCHUP_ID,
|
|
37944
|
+
info: 'One or more matchUpIds already present in tournamentRecord',
|
|
37945
|
+
};
|
|
37946
|
+
}
|
|
37947
|
+
(_b = structure.matchUps).push.apply(_b, __spreadArray([], __read(matchUps), false));
|
|
37948
|
+
addMatchUpsNotice({
|
|
37949
|
+
tournamentId: tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.tournamentId,
|
|
37950
|
+
drawDefinition: drawDefinition,
|
|
37951
|
+
matchUps: matchUps,
|
|
37952
|
+
});
|
|
37953
|
+
modifyDrawNotice({ drawDefinition: drawDefinition, structureIds: [structureId] });
|
|
37954
|
+
return __assign({}, SUCCESS);
|
|
37955
|
+
}
|
|
37956
|
+
|
|
37957
|
+
function attachFlightProfile(_a) {
|
|
37958
|
+
var _b;
|
|
37959
|
+
var deleteExisting = _a.deleteExisting, event = _a.event, flightProfile = _a.flightProfile;
|
|
37960
|
+
var stack = 'attachFlightProfile';
|
|
37961
|
+
if (!flightProfile)
|
|
37962
|
+
return decorateResult({ result: { error: MISSING_VALUE }, stack: stack });
|
|
37963
|
+
if (!event)
|
|
37964
|
+
return decorateResult({ result: { error: MISSING_EVENT }, stack: stack });
|
|
37965
|
+
var existingFlightProfile = getFlightProfile({ event: event }).flightProfile;
|
|
37966
|
+
if (existingFlightProfile && !deleteExisting)
|
|
37967
|
+
return decorateResult({ result: { error: EXISTING_PROFILE }, stack: stack });
|
|
37968
|
+
if ((_b = event.drawDefinitions) === null || _b === void 0 ? void 0 : _b.length)
|
|
37969
|
+
return decorateResult({
|
|
37970
|
+
result: { error: EXISTING_DRAW_DEFINITIONS },
|
|
37971
|
+
stack: stack,
|
|
37972
|
+
});
|
|
37973
|
+
var extension = {
|
|
37974
|
+
name: FLIGHT_PROFILE,
|
|
37975
|
+
value: flightProfile,
|
|
37976
|
+
};
|
|
37977
|
+
addEventExtension({ event: event, extension: extension });
|
|
37978
|
+
return __assign({ flightProfile: makeDeepCopy(flightProfile, false, true) }, SUCCESS);
|
|
37979
|
+
}
|
|
37980
|
+
|
|
37981
|
+
/**
|
|
37982
|
+
*
|
|
37983
|
+
* @param {object} tournamentRecord - passed automatically if tournamentEngine.setState()
|
|
37984
|
+
* @param {string[]} participantIds
|
|
37985
|
+
* @param {string} scaleAttributes - { scaleType, scaleName, eventType }
|
|
37986
|
+
* @returns {boolean} { success: true } or { error }
|
|
37987
|
+
*/
|
|
37988
|
+
function removeParticipantsScaleItems(_a) {
|
|
37989
|
+
var _b;
|
|
37990
|
+
var tournamentRecord = _a.tournamentRecord, scaleAttributes = _a.scaleAttributes, participantIds = _a.participantIds;
|
|
37991
|
+
if (!tournamentRecord)
|
|
37992
|
+
return { error: MISSING_TOURNAMENT_RECORD };
|
|
37993
|
+
if (!participantIds)
|
|
37994
|
+
return { error: MISSING_PARTICIPANT_IDS };
|
|
37995
|
+
if (!scaleAttributes)
|
|
37996
|
+
return { error: MISSING_VALUE, info: 'scaleAttributes required' };
|
|
37997
|
+
var scaleType = scaleAttributes.scaleType, eventType = scaleAttributes.eventType, scaleName = scaleAttributes.scaleName;
|
|
37998
|
+
var itemType = [SCALE, scaleType, eventType, scaleName].join('.');
|
|
37999
|
+
(_b = tournamentRecord.participants) === null || _b === void 0 ? void 0 : _b.forEach(function (participant) {
|
|
38000
|
+
if (participantIds.includes(participant.participantId) &&
|
|
38001
|
+
participant.timeItems) {
|
|
38002
|
+
participant.timeItems = participant.timeItems.filter(function (timeItem) {
|
|
38003
|
+
return timeItem && (timeItem === null || timeItem === void 0 ? void 0 : timeItem.itemType) !== itemType;
|
|
38004
|
+
});
|
|
38005
|
+
}
|
|
38006
|
+
});
|
|
38007
|
+
return __assign({}, SUCCESS);
|
|
38008
|
+
}
|
|
38009
|
+
|
|
38010
|
+
/**
|
|
38011
|
+
*
|
|
38012
|
+
* @param {object} tournamentRecord - passed automatically if tournamentEngine.setState()
|
|
38013
|
+
* @param {string} eventId - resolves to event
|
|
38014
|
+
* @param {string} drawId - OPTIONAL - resolves drawDefinition - scopes participants to clear to drawDefinition.entries or flightProfile.flight.drawEntries
|
|
38015
|
+
* @param {string} scaleAttributes - { scaleType, scaleName, eventType }
|
|
38016
|
+
* @param {string} stage - OPTIONAL - filter event or draw entries by stage
|
|
38017
|
+
* @returns {boolean} { success: true } or { error }
|
|
38018
|
+
*/
|
|
38019
|
+
function removeScaleValues(_a) {
|
|
38020
|
+
var _b;
|
|
38021
|
+
var tournamentRecord = _a.tournamentRecord, scaleAttributes = _a.scaleAttributes, drawDefinition = _a.drawDefinition, entryStatuses = _a.entryStatuses, drawId = _a.drawId, event = _a.event, stage = _a.stage;
|
|
38022
|
+
if (!event)
|
|
38023
|
+
return { error: MISSING_EVENT };
|
|
38024
|
+
if (entryStatuses && !Array.isArray(entryStatuses))
|
|
38025
|
+
return decorateResult({
|
|
38026
|
+
result: { error: INVALID_VALUES },
|
|
38027
|
+
info: mustBeAnArray('entryStatus'),
|
|
38028
|
+
stack: 'removeScaleValues',
|
|
38029
|
+
});
|
|
38030
|
+
var entries = event.entries;
|
|
38031
|
+
if (drawId) {
|
|
38032
|
+
var flightProfile = getFlightProfile({ event: event }).flightProfile;
|
|
38033
|
+
var flight = (_b = flightProfile === null || flightProfile === void 0 ? void 0 : flightProfile.flights) === null || _b === void 0 ? void 0 : _b.find(function (flight) { return flight.drawId === drawId; });
|
|
38034
|
+
if (flight) {
|
|
38035
|
+
entries = flight.drawEntries;
|
|
38036
|
+
}
|
|
38037
|
+
else {
|
|
38038
|
+
entries = drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.entries;
|
|
38039
|
+
}
|
|
38040
|
+
}
|
|
38041
|
+
var stageEntries = (entries || []).filter(function (entry) {
|
|
38042
|
+
return (!stage || !entry.entryStage || entry.entryStage === stage) &&
|
|
38043
|
+
(!entryStatuses || entryStatuses.includes(entry.entryStatus));
|
|
38044
|
+
});
|
|
38045
|
+
var participantIds = stageEntries.map(getParticipantId);
|
|
38046
|
+
return removeParticipantsScaleItems({
|
|
38047
|
+
tournamentRecord: tournamentRecord,
|
|
38048
|
+
scaleAttributes: scaleAttributes,
|
|
38049
|
+
participantIds: participantIds,
|
|
38050
|
+
});
|
|
38051
|
+
}
|
|
38052
|
+
|
|
38053
|
+
function applyLineUps(_a) {
|
|
38054
|
+
var e_1, _b, e_2, _c, e_3, _d, e_4, _e;
|
|
38055
|
+
var _f, _g, _h, _j;
|
|
38056
|
+
var tournamentRecord = _a.tournamentRecord, drawDefinition = _a.drawDefinition, matchUpId = _a.matchUpId, lineUps = _a.lineUps, event = _a.event;
|
|
38057
|
+
if (!tournamentRecord)
|
|
38058
|
+
return { error: MISSING_TOURNAMENT_RECORD };
|
|
38059
|
+
if (!drawDefinition)
|
|
38060
|
+
return { error: DRAW_DEFINITION_NOT_FOUND };
|
|
38061
|
+
if (typeof matchUpId !== 'string')
|
|
38062
|
+
return { error: INVALID_MATCHUP };
|
|
38063
|
+
if (!Array.isArray(lineUps))
|
|
38064
|
+
return { error: INVALID_VALUES, lineUps: lineUps };
|
|
38065
|
+
var stack = 'applyLineUps';
|
|
38066
|
+
var tournamentParticipants = tournamentRecord.participants || [];
|
|
38067
|
+
var result = findDrawMatchUp({
|
|
38068
|
+
tournamentParticipants: tournamentParticipants,
|
|
38069
|
+
inContext: true,
|
|
38070
|
+
drawDefinition: drawDefinition,
|
|
38071
|
+
matchUpId: matchUpId,
|
|
38072
|
+
});
|
|
38073
|
+
if (result.error)
|
|
38074
|
+
return result;
|
|
38075
|
+
if (!result.matchUp)
|
|
38076
|
+
return { error: MATCHUP_NOT_FOUND };
|
|
38077
|
+
var inContextMatchUp = result.matchUp, structure = result.structure;
|
|
38078
|
+
var drawPositions = inContextMatchUp.drawPositions, matchUpType = inContextMatchUp.matchUpType;
|
|
38079
|
+
if (matchUpType !== TEAM$1)
|
|
38080
|
+
return { error: INVALID_MATCHUP };
|
|
38081
|
+
if (!(drawPositions === null || drawPositions === void 0 ? void 0 : drawPositions.length))
|
|
38082
|
+
return { error: MISSING_DRAW_POSITIONS };
|
|
38083
|
+
var tieFormat = (_f = resolveTieFormat({
|
|
38084
|
+
matchUp: inContextMatchUp,
|
|
38085
|
+
drawDefinition: drawDefinition,
|
|
38086
|
+
structure: structure,
|
|
38087
|
+
event: event,
|
|
38088
|
+
})) === null || _f === void 0 ? void 0 : _f.tieFormat;
|
|
38089
|
+
// verify integrity of lineUps...
|
|
38090
|
+
// 1. all participantIds must be valid individualParticipantIds
|
|
38091
|
+
// 2. there should be at most one participantId for a given collectionPosition in singles
|
|
38092
|
+
// 3. there should be at most two participantIds for a given collectionPosition in doubles
|
|
38093
|
+
var sideAssignments = {};
|
|
38094
|
+
try {
|
|
38095
|
+
for (var lineUps_1 = __values(lineUps), lineUps_1_1 = lineUps_1.next(); !lineUps_1_1.done; lineUps_1_1 = lineUps_1.next()) {
|
|
38096
|
+
var lineUp = lineUps_1_1.value;
|
|
38097
|
+
if (!Array.isArray(lineUp))
|
|
38098
|
+
return { error: INVALID_VALUES, lineUp: lineUp };
|
|
38099
|
+
// maintain mapping of collectionId|collectionPosition to the participantIds assigned
|
|
38100
|
+
var collectionParticipantIds = {};
|
|
38101
|
+
var sideNumbers = [];
|
|
38102
|
+
var _loop_1 = function (lineUpAssignment) {
|
|
38103
|
+
var e_5, _m;
|
|
38104
|
+
if (typeof lineUpAssignment !== 'object')
|
|
38105
|
+
return { value: { error: INVALID_VALUES, lineUpAssignment: lineUpAssignment } };
|
|
38106
|
+
var participantId = lineUpAssignment.participantId, _o = lineUpAssignment.collectionAssignments, collectionAssignments = _o === void 0 ? [] : _o;
|
|
38107
|
+
if (!Array.isArray(collectionAssignments))
|
|
38108
|
+
return { value: { error: INVALID_VALUES, collectionAssignments: collectionAssignments } };
|
|
38109
|
+
var participant = tournamentParticipants.find(function (participant) { return participant.participantId === participantId; });
|
|
38110
|
+
if (!participant)
|
|
38111
|
+
return { value: { error: PARTICIPANT_NOT_FOUND } };
|
|
38112
|
+
if (participant.participantType !== INDIVIDUAL)
|
|
38113
|
+
return { value: { error: INVALID_PARTICIPANT_TYPE } };
|
|
38114
|
+
var sideNumber_1 = (_h = (_g = inContextMatchUp.sides) === null || _g === void 0 ? void 0 : _g.find(function (side) { var _a, _b; return (_b = (_a = side.participant) === null || _a === void 0 ? void 0 : _a.individualParticipantIds) === null || _b === void 0 ? void 0 : _b.includes(participantId); })) === null || _h === void 0 ? void 0 : _h.sideNumber;
|
|
38115
|
+
if (sideNumber_1)
|
|
38116
|
+
sideNumbers.push(sideNumber_1);
|
|
38117
|
+
var _loop_3 = function (collectionAssignment) {
|
|
38118
|
+
if (typeof collectionAssignment !== 'object')
|
|
38119
|
+
return { value: { error: INVALID_VALUES, collectionAssignment: collectionAssignment } };
|
|
38120
|
+
var collectionId = collectionAssignment.collectionId, collectionPosition = collectionAssignment.collectionPosition;
|
|
38121
|
+
var collectionDefinition = (_j = tieFormat === null || tieFormat === void 0 ? void 0 : tieFormat.collectionDefinitions) === null || _j === void 0 ? void 0 : _j.find(function (collectionDefinition) {
|
|
38122
|
+
return collectionDefinition.collectionId === collectionId;
|
|
38123
|
+
});
|
|
38124
|
+
// all collectionIds in the lineUp must be present in the tieFormat collectionDefinitions
|
|
38125
|
+
if (!collectionDefinition)
|
|
38126
|
+
return { value: { error: INVALID_VALUES, collectionId: collectionId } };
|
|
38127
|
+
var aggregator = "".concat(collectionId, "-").concat(collectionPosition);
|
|
38128
|
+
if (!collectionParticipantIds[aggregator]) {
|
|
38129
|
+
collectionParticipantIds[aggregator] = [];
|
|
38130
|
+
}
|
|
38131
|
+
var participantsCount = collectionParticipantIds[aggregator].length;
|
|
38132
|
+
if ((collectionDefinition.matchUpType === SINGLES && participantsCount) ||
|
|
38133
|
+
(collectionDefinition.matchUpType === DOUBLES &&
|
|
38134
|
+
participantsCount > 1)) {
|
|
38135
|
+
return { value: {
|
|
38136
|
+
info: 'Excessive collectionPosition assignments',
|
|
38137
|
+
error: INVALID_VALUES,
|
|
38138
|
+
} };
|
|
38139
|
+
}
|
|
38140
|
+
collectionParticipantIds[aggregator].push(participantId);
|
|
38141
|
+
};
|
|
38142
|
+
try {
|
|
38143
|
+
for (var collectionAssignments_1 = (e_5 = void 0, __values(collectionAssignments)), collectionAssignments_1_1 = collectionAssignments_1.next(); !collectionAssignments_1_1.done; collectionAssignments_1_1 = collectionAssignments_1.next()) {
|
|
38144
|
+
var collectionAssignment = collectionAssignments_1_1.value;
|
|
38145
|
+
var state_2 = _loop_3(collectionAssignment);
|
|
38146
|
+
if (typeof state_2 === "object")
|
|
38147
|
+
return state_2;
|
|
38148
|
+
}
|
|
38149
|
+
}
|
|
38150
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
38151
|
+
finally {
|
|
38152
|
+
try {
|
|
38153
|
+
if (collectionAssignments_1_1 && !collectionAssignments_1_1.done && (_m = collectionAssignments_1.return)) _m.call(collectionAssignments_1);
|
|
38154
|
+
}
|
|
38155
|
+
finally { if (e_5) throw e_5.error; }
|
|
38156
|
+
}
|
|
38157
|
+
};
|
|
38158
|
+
try {
|
|
38159
|
+
for (var lineUp_1 = (e_2 = void 0, __values(lineUp)), lineUp_1_1 = lineUp_1.next(); !lineUp_1_1.done; lineUp_1_1 = lineUp_1.next()) {
|
|
38160
|
+
var lineUpAssignment = lineUp_1_1.value;
|
|
38161
|
+
var state_1 = _loop_1(lineUpAssignment);
|
|
38162
|
+
if (typeof state_1 === "object")
|
|
38163
|
+
return state_1.value;
|
|
38164
|
+
}
|
|
38165
|
+
}
|
|
38166
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
38167
|
+
finally {
|
|
38168
|
+
try {
|
|
38169
|
+
if (lineUp_1_1 && !lineUp_1_1.done && (_c = lineUp_1.return)) _c.call(lineUp_1);
|
|
38170
|
+
}
|
|
38171
|
+
finally { if (e_2) throw e_2.error; }
|
|
38172
|
+
}
|
|
38173
|
+
// ensure that doubles pair participants exist, otherwise create
|
|
38174
|
+
var collectionParticipantIdPairs = Object.values(collectionParticipantIds);
|
|
38175
|
+
try {
|
|
38176
|
+
for (var collectionParticipantIdPairs_1 = (e_3 = void 0, __values(collectionParticipantIdPairs)), collectionParticipantIdPairs_1_1 = collectionParticipantIdPairs_1.next(); !collectionParticipantIdPairs_1_1.done; collectionParticipantIdPairs_1_1 = collectionParticipantIdPairs_1.next()) {
|
|
38177
|
+
var participantIds = collectionParticipantIdPairs_1_1.value;
|
|
38178
|
+
if (participantIds.length === 2) {
|
|
38179
|
+
var pairedParticipant = getPairedParticipant({
|
|
38180
|
+
tournamentParticipants: tournamentParticipants,
|
|
38181
|
+
participantIds: participantIds,
|
|
38182
|
+
}).participant;
|
|
38183
|
+
if (!pairedParticipant) {
|
|
38184
|
+
// create pair participant
|
|
38185
|
+
var newPairParticipant = {
|
|
38186
|
+
participantType: PAIR,
|
|
38187
|
+
participantRole: COMPETITOR,
|
|
38188
|
+
individualParticipantIds: participantIds,
|
|
38189
|
+
};
|
|
38190
|
+
var result_1 = addParticipant({
|
|
38191
|
+
participant: newPairParticipant,
|
|
38192
|
+
pairOverride: true,
|
|
38193
|
+
tournamentRecord: tournamentRecord,
|
|
38194
|
+
});
|
|
38195
|
+
if (result_1.error)
|
|
38196
|
+
return result_1;
|
|
38197
|
+
}
|
|
38198
|
+
}
|
|
38199
|
+
}
|
|
38200
|
+
}
|
|
38201
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
38202
|
+
finally {
|
|
38203
|
+
try {
|
|
38204
|
+
if (collectionParticipantIdPairs_1_1 && !collectionParticipantIdPairs_1_1.done && (_d = collectionParticipantIdPairs_1.return)) _d.call(collectionParticipantIdPairs_1);
|
|
38205
|
+
}
|
|
38206
|
+
finally { if (e_3) throw e_3.error; }
|
|
38207
|
+
}
|
|
38208
|
+
// determine sideNumber based on instances of participants appearing in team participants assigned to sides
|
|
38209
|
+
// allows for some team members to be "borrowed"
|
|
38210
|
+
var instances = instanceCount(sideNumbers);
|
|
38211
|
+
var sideNumber = ((instances[1] || 0) > (instances[2] || 0) && 1) ||
|
|
38212
|
+
((instances[2] || 0) > (instances[1] || 0) && 2) ||
|
|
38213
|
+
undefined;
|
|
38214
|
+
// if side not previously assigned, map sideNumber to lineUp
|
|
38215
|
+
var sideAssignmentKeys = Object.keys(sideAssignments).map(function (key) {
|
|
38216
|
+
return parseInt(key);
|
|
38217
|
+
});
|
|
38218
|
+
if (sideNumber && !sideAssignmentKeys.includes(sideNumber)) {
|
|
38219
|
+
sideAssignments[sideNumber] = lineUp;
|
|
38220
|
+
}
|
|
38221
|
+
}
|
|
38222
|
+
}
|
|
38223
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
38224
|
+
finally {
|
|
38225
|
+
try {
|
|
38226
|
+
if (lineUps_1_1 && !lineUps_1_1.done && (_b = lineUps_1.return)) _b.call(lineUps_1);
|
|
38122
38227
|
}
|
|
38123
38228
|
finally { if (e_1) throw e_1.error; }
|
|
38124
38229
|
}
|
|
38125
|
-
|
|
38126
|
-
|
|
38127
|
-
|
|
38128
|
-
|
|
38129
|
-
|
|
38130
|
-
|
|
38131
|
-
|
|
38132
|
-
|
|
38133
|
-
|
|
38134
|
-
|
|
38135
|
-
|
|
38136
|
-
|
|
38137
|
-
|
|
38138
|
-
|
|
38139
|
-
|
|
38140
|
-
valueObjects[pairing] = 0;
|
|
38141
|
-
valueObjects[pairing] += sameTeamValue;
|
|
38142
|
-
}
|
|
38143
|
-
}
|
|
38144
|
-
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
38145
|
-
finally {
|
|
38146
|
-
try {
|
|
38147
|
-
if (uniquePairings_1_1 && !uniquePairings_1_1.done && (_d = uniquePairings_1.return)) _d.call(uniquePairings_1);
|
|
38148
|
-
}
|
|
38149
|
-
finally { if (e_3) throw e_3.error; }
|
|
38150
|
-
}
|
|
38151
|
-
}
|
|
38230
|
+
if (!Object.keys(sideAssignments).length)
|
|
38231
|
+
return { error: VALUE_UNCHANGED };
|
|
38232
|
+
result = findDrawMatchUp({ drawDefinition: drawDefinition, matchUpId: matchUpId });
|
|
38233
|
+
if (result.error)
|
|
38234
|
+
return result;
|
|
38235
|
+
if (!result.matchUp)
|
|
38236
|
+
return { error: MATCHUP_NOT_FOUND };
|
|
38237
|
+
var matchUp = result.matchUp;
|
|
38238
|
+
if (!matchUp.sides)
|
|
38239
|
+
matchUp.sides = [];
|
|
38240
|
+
var _loop_2 = function (sideNumber) {
|
|
38241
|
+
var side = matchUp.sides.find(function (side) { return side.sideNumber === sideNumber; });
|
|
38242
|
+
var assignment = sideAssignments[sideNumber];
|
|
38243
|
+
if (!assignment) {
|
|
38244
|
+
return "continue";
|
|
38152
38245
|
}
|
|
38153
|
-
|
|
38154
|
-
|
|
38155
|
-
|
|
38156
|
-
|
|
38157
|
-
|
|
38158
|
-
finally { if (e_2) throw e_2.error; }
|
|
38246
|
+
else if (!side) {
|
|
38247
|
+
matchUp.sides.push({ lineUp: assignment, sideNumber: sideNumber });
|
|
38248
|
+
}
|
|
38249
|
+
else {
|
|
38250
|
+
side.lineUp = assignment;
|
|
38159
38251
|
}
|
|
38160
|
-
}
|
|
38161
|
-
// deltaObjects contain the difference in ratings between two participants
|
|
38162
|
-
// {
|
|
38163
|
-
// 'P-I-0|P-I-1': 0,
|
|
38164
|
-
// 'P-I-0|P-I-2': 0,
|
|
38165
|
-
// 'P-I-0|P-I-3': 0
|
|
38166
|
-
// }
|
|
38167
|
-
var _m = getPairingsData({
|
|
38168
|
-
participantIds: participantIds,
|
|
38169
|
-
}), uniquePairings = _m.uniquePairings, possiblePairings = _m.possiblePairings, deltaObjects = _m.deltaObjects;
|
|
38170
|
-
var params = {
|
|
38171
|
-
tournamentParticipants: tournamentParticipants,
|
|
38172
|
-
possiblePairings: possiblePairings,
|
|
38173
|
-
drawDefinition: drawDefinition,
|
|
38174
|
-
participantIds: participantIds,
|
|
38175
|
-
uniquePairings: uniquePairings,
|
|
38176
|
-
maxIterations: maxIterations,
|
|
38177
|
-
adHocRatings: adHocRatings,
|
|
38178
|
-
deltaObjects: deltaObjects,
|
|
38179
|
-
valueObjects: valueObjects,
|
|
38180
|
-
eventType: eventType,
|
|
38181
|
-
scaleName: scaleName,
|
|
38182
|
-
structure: structure,
|
|
38183
|
-
salted: salted,
|
|
38184
38252
|
};
|
|
38185
|
-
|
|
38186
|
-
|
|
38187
|
-
|
|
38188
|
-
|
|
38189
|
-
|
|
38190
|
-
var result = generateAdHocMatchUps({
|
|
38191
|
-
structureId: structure === null || structure === void 0 ? void 0 : structure.structureId,
|
|
38192
|
-
participantIdPairings: participantIdPairings,
|
|
38193
|
-
newRound: true,
|
|
38194
|
-
drawDefinition: drawDefinition,
|
|
38195
|
-
matchUpIds: matchUpIds,
|
|
38196
|
-
});
|
|
38197
|
-
if (result.error)
|
|
38198
|
-
return result;
|
|
38199
|
-
matchUps = result.matchUps;
|
|
38253
|
+
try {
|
|
38254
|
+
for (var _k = __values([1, 2]), _l = _k.next(); !_l.done; _l = _k.next()) {
|
|
38255
|
+
var sideNumber = _l.value;
|
|
38256
|
+
_loop_2(sideNumber);
|
|
38257
|
+
}
|
|
38200
38258
|
}
|
|
38201
|
-
|
|
38202
|
-
|
|
38259
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
38260
|
+
finally {
|
|
38261
|
+
try {
|
|
38262
|
+
if (_l && !_l.done && (_e = _k.return)) _e.call(_k);
|
|
38263
|
+
}
|
|
38264
|
+
finally { if (e_4) throw e_4.error; }
|
|
38265
|
+
}
|
|
38266
|
+
modifyMatchUpNotice({
|
|
38267
|
+
tournamentId: tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.tournamentId,
|
|
38268
|
+
context: stack,
|
|
38269
|
+
drawDefinition: drawDefinition,
|
|
38270
|
+
matchUp: matchUp,
|
|
38271
|
+
});
|
|
38272
|
+
return __assign({}, SUCCESS);
|
|
38203
38273
|
}
|
|
38204
38274
|
|
|
38205
|
-
function
|
|
38206
|
-
var e_1,
|
|
38207
|
-
var
|
|
38208
|
-
var
|
|
38209
|
-
|
|
38210
|
-
|
|
38211
|
-
|
|
38212
|
-
return
|
|
38213
|
-
}
|
|
38214
|
-
if (
|
|
38215
|
-
|
|
38216
|
-
|
|
38217
|
-
|
|
38218
|
-
|
|
38219
|
-
|
|
38220
|
-
|
|
38221
|
-
|
|
38222
|
-
|
|
38223
|
-
STRUCTURE_SELECTED_STATUSES.includes(entryStatus));
|
|
38224
|
-
}).map(getParticipantId);
|
|
38225
|
-
if (participantIds) {
|
|
38226
|
-
// ensure all participantIds are in drawDefinition.entries
|
|
38227
|
-
var invalidParticipantIds = participantIds.filter(function (participantId) { return !(enteredParticipantIds === null || enteredParticipantIds === void 0 ? void 0 : enteredParticipantIds.includes(participantId)); });
|
|
38228
|
-
if (invalidParticipantIds === null || invalidParticipantIds === void 0 ? void 0 : invalidParticipantIds.length)
|
|
38229
|
-
return decorateResult({
|
|
38230
|
-
result: { error: INVALID_PARTICIPANT_ID },
|
|
38231
|
-
info: { invalidParticipantIds: invalidParticipantIds },
|
|
38232
|
-
});
|
|
38233
|
-
}
|
|
38234
|
-
else {
|
|
38235
|
-
participantIds = enteredParticipantIds;
|
|
38236
|
-
}
|
|
38237
|
-
// if no structureId is specified find the latest AD_HOC stage which has matchUps
|
|
38238
|
-
if (!structureId) {
|
|
38239
|
-
var targetStructure = (_e = (_d = drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.structures) === null || _d === void 0 ? void 0 : _d.filter(function (structure) { return structure.stageSequence === 1; })) === null || _e === void 0 ? void 0 : _e.reduce(function (targetStructure, structure) {
|
|
38240
|
-
var orderNumber = structure.stage && stageOrder$1[structure.stage];
|
|
38241
|
-
var structureIsAdHoc = isAdHoc({ drawDefinition: drawDefinition, structure: structure });
|
|
38242
|
-
return structureIsAdHoc &&
|
|
38243
|
-
orderNumber > (stageOrder$1[targetStructure === null || targetStructure === void 0 ? void 0 : targetStructure.stage] || 1)
|
|
38244
|
-
? structure
|
|
38245
|
-
: targetStructure;
|
|
38246
|
-
}, undefined);
|
|
38247
|
-
structureId = targetStructure === null || targetStructure === void 0 ? void 0 : targetStructure.structureId;
|
|
38248
|
-
}
|
|
38249
|
-
var structure = (_f = drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.structures) === null || _f === void 0 ? void 0 : _f.find(function (structure) { return structure.structureId === structureId; });
|
|
38250
|
-
if (!structure)
|
|
38251
|
-
return { error: STRUCTURE_NOT_FOUND };
|
|
38252
|
-
// an AD_HOC structure is one that has no child structures and in which no matchUps have roundPosition
|
|
38253
|
-
var structureIsAdHoc = isAdHoc({ drawDefinition: drawDefinition, structure: structure });
|
|
38254
|
-
if (!structureIsAdHoc)
|
|
38255
|
-
return { error: INVALID_DRAW_DEFINITION };
|
|
38256
|
-
tournamentParticipants =
|
|
38257
|
-
(_g = tournamentParticipants !== null && tournamentParticipants !== void 0 ? tournamentParticipants : tournamentRecord.participants) !== null && _g !== void 0 ? _g : [];
|
|
38258
|
-
var _loop_1 = function (participantId) {
|
|
38259
|
-
var participant = tournamentParticipants === null || tournamentParticipants === void 0 ? void 0 : tournamentParticipants.find(function (participant) { return participant.participantId === participantId; });
|
|
38260
|
-
// first see if there is already a dynamic value
|
|
38261
|
-
var scaleValue = getScaleValue({
|
|
38262
|
-
scaleName: "".concat(scaleName, ".").concat(DYNAMIC),
|
|
38263
|
-
scaleAccessor: scaleAccessor,
|
|
38264
|
-
participant: participant,
|
|
38265
|
-
eventType: eventType,
|
|
38275
|
+
function resetTieFormat(params) {
|
|
38276
|
+
var _a, _b, e_1, _c, e_2, _d;
|
|
38277
|
+
var _e, _f, _g;
|
|
38278
|
+
var stack = 'resetTieFormat';
|
|
38279
|
+
var drawDefinition = params.drawDefinition, event = params.event, uuids = params.uuids;
|
|
38280
|
+
var paramCheck = checkRequiredParameters(params, [(_a = {}, _a[TOURNAMENT_RECORD] = true, _a[MATCHUP_ID] = true, _a)], stack);
|
|
38281
|
+
if (paramCheck.error)
|
|
38282
|
+
return paramCheck;
|
|
38283
|
+
var resolutions = resolveFromParameters(params, [(_b = {}, _b[PARAM] = MATCHUP, _b)]);
|
|
38284
|
+
if (resolutions[ERROR])
|
|
38285
|
+
return resolutions;
|
|
38286
|
+
var tournamentId = (_e = params.tournamentRecord) === null || _e === void 0 ? void 0 : _e.tournamentId;
|
|
38287
|
+
var _h = (_f = resolutions === null || resolutions === void 0 ? void 0 : resolutions.matchUp) !== null && _f !== void 0 ? _f : {}, matchUp = _h.matchUp, structure = _h.structure;
|
|
38288
|
+
if (!(matchUp === null || matchUp === void 0 ? void 0 : matchUp.tieMatchUps))
|
|
38289
|
+
return decorateResult({
|
|
38290
|
+
result: { error: INVALID_MATCHUP },
|
|
38291
|
+
info: 'Must be a TEAM matchUp',
|
|
38292
|
+
stack: stack,
|
|
38266
38293
|
});
|
|
38267
|
-
|
|
38268
|
-
|
|
38269
|
-
|
|
38270
|
-
|
|
38271
|
-
|
|
38272
|
-
|
|
38273
|
-
|
|
38294
|
+
// if there is no tieFormat there is nothing to do
|
|
38295
|
+
if (!matchUp.tieFormat)
|
|
38296
|
+
return __assign({}, SUCCESS);
|
|
38297
|
+
var tieFormat = (_g = resolveTieFormat({
|
|
38298
|
+
structure: structure,
|
|
38299
|
+
drawDefinition: drawDefinition,
|
|
38300
|
+
event: event,
|
|
38301
|
+
})) === null || _g === void 0 ? void 0 : _g.tieFormat;
|
|
38302
|
+
if (!tieFormat)
|
|
38303
|
+
return decorateResult({
|
|
38304
|
+
result: { error: NOT_FOUND },
|
|
38305
|
+
info: 'No inherited tieFormat',
|
|
38306
|
+
stack: stack,
|
|
38307
|
+
});
|
|
38308
|
+
var deletedMatchUpIds = [];
|
|
38309
|
+
var collectionIds = [];
|
|
38310
|
+
var tieMatchUps = [];
|
|
38311
|
+
var newMatchUps = [];
|
|
38312
|
+
var _loop_1 = function (collectionDefinition) {
|
|
38313
|
+
// delete any matchUp.tieMatchUps that are not found in the ancestor tieFormat collectionDefinitions
|
|
38314
|
+
var matchUpCount = collectionDefinition.matchUpCount, collectionId = collectionDefinition.collectionId;
|
|
38315
|
+
collectionIds.push(collectionId);
|
|
38316
|
+
var existingCollectionMatchUps = (matchUp.tieMatchUps || []).filter(function (matchUp) { return matchUp.collectionId === collectionId; });
|
|
38317
|
+
if (existingCollectionMatchUps.length > matchUpCount) {
|
|
38318
|
+
// sort by matchUpStatus to prioritize active or completed matchUpsA
|
|
38319
|
+
existingCollectionMatchUps.sort(function (a, b) {
|
|
38320
|
+
return (a.matchUpStatus === TO_BE_PLAYED ? 1 : 0) -
|
|
38321
|
+
(b.matchUpStatus === TO_BE_PLAYED ? 1 : 0);
|
|
38274
38322
|
});
|
|
38323
|
+
tieMatchUps.push.apply(tieMatchUps, __spreadArray([], __read(existingCollectionMatchUps.slice(0, matchUpCount)), false));
|
|
38324
|
+
deletedMatchUpIds.push.apply(deletedMatchUpIds, __spreadArray([], __read(existingCollectionMatchUps.slice(3).map(getMatchUpId)), false));
|
|
38325
|
+
}
|
|
38326
|
+
else {
|
|
38327
|
+
tieMatchUps.push.apply(tieMatchUps, __spreadArray([], __read(existingCollectionMatchUps), false));
|
|
38328
|
+
if (existingCollectionMatchUps.length < matchUpCount) {
|
|
38329
|
+
var matchUpsLimit = matchUpCount - existingCollectionMatchUps.length;
|
|
38330
|
+
var matchUps = generateCollectionMatchUps({
|
|
38331
|
+
collectionDefinition: collectionDefinition,
|
|
38332
|
+
matchUpsLimit: matchUpsLimit,
|
|
38333
|
+
uuids: uuids,
|
|
38334
|
+
});
|
|
38335
|
+
newMatchUps.push.apply(newMatchUps, __spreadArray([], __read(matchUps), false));
|
|
38336
|
+
}
|
|
38275
38337
|
}
|
|
38276
|
-
if (scaleValue && !adHocRatings[participantId])
|
|
38277
|
-
adHocRatings[participantId] = scaleValue;
|
|
38278
38338
|
};
|
|
38279
38339
|
try {
|
|
38280
|
-
for (var _j = __values(
|
|
38281
|
-
var
|
|
38282
|
-
_loop_1(
|
|
38340
|
+
for (var _j = __values(tieFormat.collectionDefinitions), _k = _j.next(); !_k.done; _k = _j.next()) {
|
|
38341
|
+
var collectionDefinition = _k.value;
|
|
38342
|
+
_loop_1(collectionDefinition);
|
|
38283
38343
|
}
|
|
38284
38344
|
}
|
|
38285
38345
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
38286
38346
|
finally {
|
|
38287
38347
|
try {
|
|
38288
|
-
if (_k && !_k.done && (
|
|
38348
|
+
if (_k && !_k.done && (_c = _j.return)) _c.call(_j);
|
|
38289
38349
|
}
|
|
38290
38350
|
finally { if (e_1) throw e_1.error; }
|
|
38291
38351
|
}
|
|
38292
|
-
|
|
38293
|
-
|
|
38294
|
-
|
|
38295
|
-
|
|
38296
|
-
|
|
38297
|
-
|
|
38298
|
-
|
|
38299
|
-
|
|
38352
|
+
try {
|
|
38353
|
+
for (var _l = __values((matchUp === null || matchUp === void 0 ? void 0 : matchUp.tieMatchUps) || []), _m = _l.next(); !_m.done; _m = _l.next()) {
|
|
38354
|
+
var tieMatchUp = _m.value;
|
|
38355
|
+
if (tieMatchUp.collectionId &&
|
|
38356
|
+
!collectionIds.includes(tieMatchUp.collectionId))
|
|
38357
|
+
deletedMatchUpIds.push(tieMatchUp.matchUpId);
|
|
38358
|
+
}
|
|
38359
|
+
}
|
|
38360
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
38361
|
+
finally {
|
|
38362
|
+
try {
|
|
38363
|
+
if (_m && !_m.done && (_d = _l.return)) _d.call(_l);
|
|
38364
|
+
}
|
|
38365
|
+
finally { if (e_2) throw e_2.error; }
|
|
38366
|
+
}
|
|
38367
|
+
if (newMatchUps.length) {
|
|
38368
|
+
tieMatchUps.push.apply(tieMatchUps, __spreadArray([], __read(newMatchUps), false));
|
|
38369
|
+
addMatchUpsNotice({
|
|
38370
|
+
eventId: event === null || event === void 0 ? void 0 : event.eventId,
|
|
38371
|
+
matchUps: newMatchUps,
|
|
38372
|
+
drawDefinition: drawDefinition,
|
|
38373
|
+
tournamentId: tournamentId,
|
|
38374
|
+
});
|
|
38375
|
+
}
|
|
38376
|
+
if (deletedMatchUpIds.length) {
|
|
38377
|
+
deleteMatchUpsNotice({
|
|
38378
|
+
matchUpIds: deletedMatchUpIds,
|
|
38379
|
+
eventId: event === null || event === void 0 ? void 0 : event.eventId,
|
|
38380
|
+
drawDefinition: drawDefinition,
|
|
38381
|
+
tournamentId: tournamentId,
|
|
38382
|
+
});
|
|
38383
|
+
}
|
|
38384
|
+
if (matchUp) {
|
|
38385
|
+
matchUp.tieMatchUps = tieMatchUps;
|
|
38386
|
+
matchUp.tieFormatId = undefined;
|
|
38387
|
+
matchUp.tieFormat = undefined;
|
|
38388
|
+
modifyMatchUpNotice({
|
|
38389
|
+
structureId: structure === null || structure === void 0 ? void 0 : structure.structureId,
|
|
38390
|
+
eventId: event === null || event === void 0 ? void 0 : event.eventId,
|
|
38391
|
+
context: stack,
|
|
38392
|
+
drawDefinition: drawDefinition,
|
|
38393
|
+
tournamentId: tournamentId,
|
|
38394
|
+
matchUp: matchUp,
|
|
38395
|
+
});
|
|
38396
|
+
}
|
|
38397
|
+
return __assign(__assign({}, SUCCESS), { newMatchUps: newMatchUps, deletedMatchUpIds: deletedMatchUpIds });
|
|
38398
|
+
}
|
|
38399
|
+
|
|
38400
|
+
function resetScorecard(params) {
|
|
38401
|
+
var e_1, _a;
|
|
38402
|
+
var _b, _c;
|
|
38403
|
+
var tournamentRecord = params.tournamentRecord, drawDefinition = params.drawDefinition, matchUpId = params.matchUpId, event = params.event;
|
|
38404
|
+
var stack = 'resetScorecard';
|
|
38405
|
+
// Check for missing parameters ---------------------------------------------
|
|
38406
|
+
if (!drawDefinition)
|
|
38407
|
+
return decorateResult({
|
|
38408
|
+
result: { error: MISSING_DRAW_DEFINITION },
|
|
38409
|
+
stack: stack,
|
|
38410
|
+
});
|
|
38411
|
+
if (!matchUpId)
|
|
38412
|
+
return decorateResult({ result: { error: MISSING_MATCHUP_ID }, stack: stack });
|
|
38413
|
+
if (!isString(matchUpId))
|
|
38414
|
+
return decorateResult({
|
|
38415
|
+
result: { error: INVALID_VALUES, matchUpId: matchUpId },
|
|
38416
|
+
stack: stack,
|
|
38417
|
+
});
|
|
38418
|
+
// Get map of all drawMatchUps and inContextDrawMatchUPs ---------------------
|
|
38419
|
+
var matchUpsMap = getMatchUpsMap({ drawDefinition: drawDefinition });
|
|
38420
|
+
var inContextDrawMatchUps = getAllDrawMatchUps({
|
|
38421
|
+
nextMatchUps: true,
|
|
38422
|
+
inContext: true,
|
|
38300
38423
|
drawDefinition: drawDefinition,
|
|
38301
|
-
|
|
38302
|
-
|
|
38303
|
-
|
|
38424
|
+
matchUpsMap: matchUpsMap,
|
|
38425
|
+
}).matchUps;
|
|
38426
|
+
// Find target matchUp ------------------------------------------------------
|
|
38427
|
+
var matchUp = matchUpsMap.drawMatchUps.find(function (matchUp) { return matchUp.matchUpId === matchUpId; });
|
|
38428
|
+
var inContextMatchUp = inContextDrawMatchUps === null || inContextDrawMatchUps === void 0 ? void 0 : inContextDrawMatchUps.find(function (matchUp) { return matchUp.matchUpId === matchUpId; });
|
|
38429
|
+
if (!matchUp || !inContextDrawMatchUps)
|
|
38430
|
+
return { error: MATCHUP_NOT_FOUND };
|
|
38431
|
+
// only accept matchUpType: TEAM
|
|
38432
|
+
if (matchUp.matchUpType !== TEAM_EVENT)
|
|
38433
|
+
return { error: INVALID_MATCHUP };
|
|
38434
|
+
// Get winner/loser position targets ----------------------------------------
|
|
38435
|
+
var targetData = positionTargets({
|
|
38436
|
+
inContextDrawMatchUps: inContextDrawMatchUps,
|
|
38437
|
+
drawDefinition: drawDefinition,
|
|
38438
|
+
matchUpId: matchUpId,
|
|
38439
|
+
});
|
|
38440
|
+
var structureId = inContextMatchUp === null || inContextMatchUp === void 0 ? void 0 : inContextMatchUp.structureId;
|
|
38441
|
+
var structure = findStructure({ drawDefinition: drawDefinition, structureId: structureId }).structure;
|
|
38442
|
+
Object.assign(params, {
|
|
38443
|
+
inContextDrawMatchUps: inContextDrawMatchUps,
|
|
38444
|
+
inContextMatchUp: inContextMatchUp,
|
|
38445
|
+
matchUpsMap: matchUpsMap,
|
|
38446
|
+
targetData: targetData,
|
|
38304
38447
|
structure: structure,
|
|
38305
|
-
|
|
38306
|
-
|
|
38448
|
+
matchUp: matchUp,
|
|
38449
|
+
});
|
|
38450
|
+
// with propagating winningSide changes, activeDownstream only applies to eventType: TEAM
|
|
38451
|
+
var activeDownstream = isActiveDownstream(params);
|
|
38452
|
+
if (activeDownstream)
|
|
38453
|
+
return { error: CANNOT_CHANGE_WINNING_SIDE };
|
|
38454
|
+
if ((_b = matchUp.tieMatchUps) === null || _b === void 0 ? void 0 : _b.length) {
|
|
38455
|
+
try {
|
|
38456
|
+
for (var _d = __values(matchUp.tieMatchUps), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
38457
|
+
var tieMatchUp = _e.value;
|
|
38458
|
+
var result_1 = setMatchUpState({
|
|
38459
|
+
matchUpId: tieMatchUp.matchUpId,
|
|
38460
|
+
matchUpTieId: matchUpId,
|
|
38461
|
+
winningSide: undefined,
|
|
38462
|
+
removeScore: true,
|
|
38463
|
+
tournamentRecord: tournamentRecord,
|
|
38464
|
+
drawDefinition: drawDefinition,
|
|
38465
|
+
event: event,
|
|
38466
|
+
});
|
|
38467
|
+
if (result_1.error)
|
|
38468
|
+
return decorateResult({ result: result_1, stack: stack });
|
|
38469
|
+
}
|
|
38470
|
+
}
|
|
38471
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
38472
|
+
finally {
|
|
38473
|
+
try {
|
|
38474
|
+
if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
|
|
38475
|
+
}
|
|
38476
|
+
finally { if (e_1) throw e_1.error; }
|
|
38477
|
+
}
|
|
38478
|
+
}
|
|
38479
|
+
var result = updateTieMatchUpScore({
|
|
38480
|
+
event: params.event,
|
|
38481
|
+
removeScore: true,
|
|
38482
|
+
tournamentRecord: tournamentRecord,
|
|
38483
|
+
drawDefinition: drawDefinition,
|
|
38484
|
+
matchUpsMap: matchUpsMap,
|
|
38485
|
+
matchUpId: matchUpId,
|
|
38307
38486
|
});
|
|
38487
|
+
if (result.error)
|
|
38488
|
+
return decorateResult({ result: result, stack: stack });
|
|
38489
|
+
if (params.tiebreakReset && !result.tieFormatRemoved) {
|
|
38490
|
+
// check for scenarios where an added "Tiebreaker" collectionDefinition/matchUp has been added
|
|
38491
|
+
var inheritedTieFormat = (_c = resolveTieFormat({
|
|
38492
|
+
drawDefinition: drawDefinition,
|
|
38493
|
+
structure: structure,
|
|
38494
|
+
event: event,
|
|
38495
|
+
})) === null || _c === void 0 ? void 0 : _c.tieFormat;
|
|
38496
|
+
if (matchUp.tieFormat && inheritedTieFormat) {
|
|
38497
|
+
var _f = compareTieFormats({
|
|
38498
|
+
descendant: matchUp.tieFormat,
|
|
38499
|
+
ancestor: inheritedTieFormat,
|
|
38500
|
+
}), matchUpCountDifference = _f.matchUpCountDifference, descendantDifferences = _f.descendantDifferences, ancestorDifferences = _f.ancestorDifferences, valueDifference = _f.valueDifference;
|
|
38501
|
+
if (descendantDifferences.collectionIds.length === 1 &&
|
|
38502
|
+
!ancestorDifferences.collectionIds.length &&
|
|
38503
|
+
!ancestorDifferences.groupsCount &&
|
|
38504
|
+
matchUpCountDifference === 1 &&
|
|
38505
|
+
valueDifference === 1) {
|
|
38506
|
+
var result_2 = resetTieFormat({
|
|
38507
|
+
tournamentRecord: tournamentRecord,
|
|
38508
|
+
drawDefinition: drawDefinition,
|
|
38509
|
+
matchUpId: matchUpId,
|
|
38510
|
+
event: event,
|
|
38511
|
+
});
|
|
38512
|
+
if (result_2.error)
|
|
38513
|
+
return result_2;
|
|
38514
|
+
}
|
|
38515
|
+
}
|
|
38516
|
+
}
|
|
38517
|
+
return __assign({}, SUCCESS);
|
|
38308
38518
|
}
|
|
38309
|
-
|
|
38310
|
-
|
|
38311
|
-
var
|
|
38519
|
+
|
|
38520
|
+
function removeSeeding(_a) {
|
|
38521
|
+
var _b, _c;
|
|
38522
|
+
var tournamentRecord = _a.tournamentRecord, drawDefinition = _a.drawDefinition, entryStatuses = _a.entryStatuses, scaleName = _a.scaleName, drawId = _a.drawId, event = _a.event, stage = _a.stage;
|
|
38523
|
+
if (!tournamentRecord)
|
|
38524
|
+
return { error: MISSING_TOURNAMENT_RECORD };
|
|
38525
|
+
if (!event)
|
|
38526
|
+
return { error: MISSING_EVENT };
|
|
38527
|
+
scaleName =
|
|
38528
|
+
scaleName ||
|
|
38529
|
+
((_b = event.category) === null || _b === void 0 ? void 0 : _b.categoryName) ||
|
|
38530
|
+
((_c = event.category) === null || _c === void 0 ? void 0 : _c.ageCategoryCode);
|
|
38312
38531
|
var scaleAttributes = {
|
|
38313
|
-
eventType: eventType
|
|
38314
|
-
scaleType:
|
|
38532
|
+
eventType: event.eventType,
|
|
38533
|
+
scaleType: SEEDING$1,
|
|
38315
38534
|
scaleName: scaleName,
|
|
38316
38535
|
};
|
|
38317
|
-
|
|
38318
|
-
|
|
38319
|
-
|
|
38320
|
-
|
|
38321
|
-
|
|
38322
|
-
|
|
38323
|
-
|
|
38324
|
-
|
|
38325
|
-
|
|
38326
|
-
}
|
|
38327
|
-
|
|
38328
|
-
function drawMatic(params) {
|
|
38329
|
-
var _a;
|
|
38330
|
-
var tournamentParticipants = (_a = params.tournamentRecord) === null || _a === void 0 ? void 0 : _a.participants;
|
|
38331
|
-
Object.assign(params, { tournamentParticipants: tournamentParticipants });
|
|
38332
|
-
return drawMatic$1(params);
|
|
38536
|
+
return removeScaleValues({
|
|
38537
|
+
tournamentRecord: tournamentRecord,
|
|
38538
|
+
scaleAttributes: scaleAttributes,
|
|
38539
|
+
drawDefinition: drawDefinition,
|
|
38540
|
+
entryStatuses: entryStatuses,
|
|
38541
|
+
drawId: drawId,
|
|
38542
|
+
event: event,
|
|
38543
|
+
stage: stage,
|
|
38544
|
+
});
|
|
38333
38545
|
}
|
|
38334
38546
|
|
|
38335
38547
|
function setSubOrder(_a) {
|
|
@@ -40759,6 +40971,14 @@ function deriveQualifyingPositions(_a) {
|
|
|
40759
40971
|
return qualifyingPositions;
|
|
40760
40972
|
}
|
|
40761
40973
|
|
|
40974
|
+
function getDrawTypeCoercion(_a) {
|
|
40975
|
+
var _b, _c, _d, _e, _f, _g;
|
|
40976
|
+
var policyDefinitions = _a.policyDefinitions, appliedPolicies = _a.appliedPolicies, drawType = _a.drawType;
|
|
40977
|
+
var policyDefined = (_b = policyDefinitions === null || policyDefinitions === void 0 ? void 0 : policyDefinitions[POLICY_TYPE_DRAWS]) === null || _b === void 0 ? void 0 : _b.drawTypeCoercion;
|
|
40978
|
+
var policyApplied = (_c = appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[POLICY_TYPE_DRAWS]) === null || _c === void 0 ? void 0 : _c.drawTypeCoercion;
|
|
40979
|
+
return ((_g = (_f = (_e = (_d = (typeof policyDefined === 'boolean' ? policyDefined : undefined)) !== null && _d !== void 0 ? _d : (drawType && (policyDefined === null || policyDefined === void 0 ? void 0 : policyDefined[drawType]))) !== null && _e !== void 0 ? _e : (typeof policyApplied === 'boolean' ? policyApplied : undefined)) !== null && _f !== void 0 ? _f : (drawType && (policyApplied === null || policyApplied === void 0 ? void 0 : policyApplied[drawType]))) !== null && _g !== void 0 ? _g : true);
|
|
40980
|
+
}
|
|
40981
|
+
|
|
40762
40982
|
// first iteration only links to a single playoff structure
|
|
40763
40983
|
// future iteration should allow structureOptions to specify
|
|
40764
40984
|
// groups of finishing drawPositions which playoff
|
|
@@ -41119,17 +41339,17 @@ function getGenerators(params) {
|
|
|
41119
41339
|
|
|
41120
41340
|
function generateDrawStructuresAndLinks(params) {
|
|
41121
41341
|
var e_1, _a, e_2, _b;
|
|
41122
|
-
var _c, _d, _e, _f, _g, _h, _j
|
|
41123
|
-
var
|
|
41124
|
-
drawDefinition =
|
|
41125
|
-
var drawTypeCoercion = (
|
|
41342
|
+
var _c, _d, _e, _f, _g, _h, _j;
|
|
41343
|
+
var _k = params || {}, _l = _k.enforceMinimumDrawSize, enforceMinimumDrawSize = _l === void 0 ? true : _l, overwriteExisting = _k.overwriteExisting, appliedPolicies = _k.appliedPolicies, staggeredEntry = _k.staggeredEntry, // optional - specifies main structure FEED_IN for drawTypes CURTIS_CONSOLATION, FEED_IN_CHAMPIONSHIPS, FMLC
|
|
41344
|
+
drawDefinition = _k.drawDefinition, tieFormat = _k.tieFormat, drawSize = _k.drawSize, isMock = _k.isMock, uuids = _k.uuids;
|
|
41345
|
+
var drawTypeCoercion = (_c = params.drawTypeCoercion) !== null && _c !== void 0 ? _c : getDrawTypeCoercion({ appliedPolicies: appliedPolicies, drawType: params.drawType });
|
|
41126
41346
|
var stack = 'generateDrawStructuresAndLinks';
|
|
41127
41347
|
var drawType = (drawTypeCoercion && params.drawSize === 2 && SINGLE_ELIMINATION) ||
|
|
41128
41348
|
params.drawType ||
|
|
41129
41349
|
SINGLE_ELIMINATION;
|
|
41130
41350
|
var structures = [], links = [];
|
|
41131
|
-
var matchUpType = (
|
|
41132
|
-
var existingQualifyingStructures = (
|
|
41351
|
+
var matchUpType = (_d = params === null || params === void 0 ? void 0 : params.matchUpType) !== null && _d !== void 0 ? _d : SINGLES;
|
|
41352
|
+
var existingQualifyingStructures = (_e = drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.structures) === null || _e === void 0 ? void 0 : _e.filter(function (_a) {
|
|
41133
41353
|
var stage = _a.stage;
|
|
41134
41354
|
return stage === QUALIFYING;
|
|
41135
41355
|
});
|
|
@@ -41140,11 +41360,11 @@ function generateDrawStructuresAndLinks(params) {
|
|
|
41140
41360
|
var structureId = _a.structureId;
|
|
41141
41361
|
return structureId;
|
|
41142
41362
|
});
|
|
41143
|
-
var existingMainStructure = (
|
|
41363
|
+
var existingMainStructure = (_f = drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.structures) === null || _f === void 0 ? void 0 : _f.find(function (_a) {
|
|
41144
41364
|
var stage = _a.stage, stageSequence = _a.stageSequence;
|
|
41145
41365
|
return stage === MAIN && stageSequence === 1;
|
|
41146
41366
|
});
|
|
41147
|
-
var existingQualifyingLinks = (
|
|
41367
|
+
var existingQualifyingLinks = (_g = drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.links) === null || _g === void 0 ? void 0 : _g.filter(function (link) {
|
|
41148
41368
|
return link.target.structureId === (existingMainStructure === null || existingMainStructure === void 0 ? void 0 : existingMainStructure.structureId) &&
|
|
41149
41369
|
(existingQualifyingStructureIds === null || existingQualifyingStructureIds === void 0 ? void 0 : existingQualifyingStructureIds.includes(link.source.structureId));
|
|
41150
41370
|
});
|
|
@@ -41179,7 +41399,7 @@ function generateDrawStructuresAndLinks(params) {
|
|
|
41179
41399
|
var structure = existingQualifyingStructures === null || existingQualifyingStructures === void 0 ? void 0 : existingQualifyingStructures.find(function (structure) { return structure.structureId === qualifyingStructureId; });
|
|
41180
41400
|
return getQualifiersCount(link, structure);
|
|
41181
41401
|
}).filter(Boolean).reduce(function (a, b) { return a + b; }, 0);
|
|
41182
|
-
var mainStructureIsPlaceholder = !!(existingMainStructure && !((
|
|
41402
|
+
var mainStructureIsPlaceholder = !!(existingMainStructure && !((_h = existingMainStructure === null || existingMainStructure === void 0 ? void 0 : existingMainStructure.matchUps) === null || _h === void 0 ? void 0 : _h.length));
|
|
41183
41403
|
if ((existingQualifyingStructures === null || existingQualifyingStructures === void 0 ? void 0 : existingQualifyingStructures.length) && !mainStructureIsPlaceholder) {
|
|
41184
41404
|
return { error: EXISTING_STAGE };
|
|
41185
41405
|
}
|
|
@@ -41196,10 +41416,10 @@ function generateDrawStructuresAndLinks(params) {
|
|
|
41196
41416
|
if (qualifyingResult === null || qualifyingResult === void 0 ? void 0 : qualifyingResult.error) {
|
|
41197
41417
|
return qualifyingResult;
|
|
41198
41418
|
}
|
|
41199
|
-
var
|
|
41419
|
+
var _m = qualifyingResult || {
|
|
41200
41420
|
qualifyingDrawPositionsCount: existingQualifyingDrawPositionsCount,
|
|
41201
41421
|
qualifiersCount: existingQualifiersCount,
|
|
41202
|
-
}, qualifyingDrawPositionsCount =
|
|
41422
|
+
}, qualifyingDrawPositionsCount = _m.qualifyingDrawPositionsCount, qualifyingDetails = _m.qualifyingDetails, qualifiersCount = _m.qualifiersCount;
|
|
41203
41423
|
if (qualifyingDrawPositionsCount) {
|
|
41204
41424
|
if (qualifyingResult === null || qualifyingResult === void 0 ? void 0 : qualifyingResult.structures) {
|
|
41205
41425
|
structures.push.apply(structures, __spreadArray([], __read(qualifyingResult.structures), false));
|
|
@@ -41245,7 +41465,7 @@ function generateDrawStructuresAndLinks(params) {
|
|
|
41245
41465
|
});
|
|
41246
41466
|
}
|
|
41247
41467
|
}
|
|
41248
|
-
var
|
|
41468
|
+
var _o = getGenerators(params), generators = _o.generators, error = _o.error;
|
|
41249
41469
|
if (error) {
|
|
41250
41470
|
return { error: error };
|
|
41251
41471
|
}
|
|
@@ -41301,18 +41521,18 @@ function generateDrawStructuresAndLinks(params) {
|
|
|
41301
41521
|
return stage === MAIN && stageSequence === 1;
|
|
41302
41522
|
});
|
|
41303
41523
|
try {
|
|
41304
|
-
for (var
|
|
41305
|
-
var qualifyingDetail =
|
|
41524
|
+
for (var _p = __values(qualifyingDetails || []), _q = _p.next(); !_q.done; _q = _p.next()) {
|
|
41525
|
+
var qualifyingDetail = _q.value;
|
|
41306
41526
|
var qualifyingRoundNumber = qualifyingDetail.finalQualifyingRoundNumber, qualifyingStructureId = qualifyingDetail.finalQualifyingStructureId, targetEntryRound = qualifyingDetail.roundTarget, finishingPositions = qualifyingDetail.finishingPositions, linkType = qualifyingDetail.linkType;
|
|
41307
41527
|
var link = mainStructure &&
|
|
41308
|
-
((
|
|
41528
|
+
((_j = generateQualifyingLink({
|
|
41309
41529
|
targetStructureId: mainStructure.structureId,
|
|
41310
41530
|
sourceStructureId: qualifyingStructureId,
|
|
41311
41531
|
sourceRoundNumber: qualifyingRoundNumber,
|
|
41312
41532
|
finishingPositions: finishingPositions,
|
|
41313
41533
|
targetEntryRound: targetEntryRound,
|
|
41314
41534
|
linkType: linkType,
|
|
41315
|
-
})) === null ||
|
|
41535
|
+
})) === null || _j === void 0 ? void 0 : _j.link);
|
|
41316
41536
|
if (link === null || link === void 0 ? void 0 : link.error)
|
|
41317
41537
|
return link;
|
|
41318
41538
|
if (link) {
|
|
@@ -41323,7 +41543,7 @@ function generateDrawStructuresAndLinks(params) {
|
|
|
41323
41543
|
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
41324
41544
|
finally {
|
|
41325
41545
|
try {
|
|
41326
|
-
if (
|
|
41546
|
+
if (_q && !_q.done && (_b = _p.return)) _b.call(_p);
|
|
41327
41547
|
}
|
|
41328
41548
|
finally { if (e_2) throw e_2.error; }
|
|
41329
41549
|
}
|
|
@@ -41959,21 +42179,25 @@ var POLICY_SEEDING_DEFAULT = (_a$c = {},
|
|
|
41959
42179
|
|
|
41960
42180
|
function generateDrawDefinition(params) {
|
|
41961
42181
|
var _a, e_1, _b, e_2, _c, e_3, _d, e_4, _e, _f, e_5, _g, e_6, _h, _j;
|
|
41962
|
-
var _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30
|
|
42182
|
+
var _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30;
|
|
41963
42183
|
var stack = 'generateDrawDefinition';
|
|
41964
|
-
var
|
|
42184
|
+
var _31 = params.considerEventEntries, considerEventEntries = _31 === void 0 ? true : _31, // in the absence of drawSize and drawEntries, look to event.entries
|
|
41965
42185
|
ignoreAllowedDrawTypes = params.ignoreAllowedDrawTypes, voluntaryConsolation = params.voluntaryConsolation, hydrateCollections = params.hydrateCollections, ignoreStageSpace = params.ignoreStageSpace, tournamentRecord = params.tournamentRecord, qualifyingOnly = params.qualifyingOnly, tieFormatName = params.tieFormatName, drawEntries = params.drawEntries, placeByes = params.placeByes, event = params.event;
|
|
41966
42186
|
var appliedPolicies = (_k = getAppliedPolicies({
|
|
41967
42187
|
tournamentRecord: tournamentRecord,
|
|
41968
42188
|
event: event,
|
|
41969
42189
|
}).appliedPolicies) !== null && _k !== void 0 ? _k : {};
|
|
41970
42190
|
var policyDefinitions = makeDeepCopy((_l = params.policyDefinitions) !== null && _l !== void 0 ? _l : {}, false, true);
|
|
41971
|
-
var drawTypeCoercion = (
|
|
42191
|
+
var drawTypeCoercion = (_m = params.drawTypeCoercion) !== null && _m !== void 0 ? _m : getDrawTypeCoercion({
|
|
42192
|
+
drawType: params.drawType,
|
|
42193
|
+
policyDefinitions: policyDefinitions,
|
|
42194
|
+
appliedPolicies: appliedPolicies,
|
|
42195
|
+
});
|
|
41972
42196
|
var drawType = (drawTypeCoercion && params.drawSize === 2 && SINGLE_ELIMINATION) ||
|
|
41973
42197
|
params.drawType ||
|
|
41974
42198
|
SINGLE_ELIMINATION;
|
|
41975
|
-
var seedingPolicy = (
|
|
41976
|
-
var seedingProfile = (
|
|
42199
|
+
var seedingPolicy = (_o = policyDefinitions === null || policyDefinitions === void 0 ? void 0 : policyDefinitions[POLICY_TYPE_SEEDING]) !== null && _o !== void 0 ? _o : appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[POLICY_TYPE_SEEDING];
|
|
42200
|
+
var seedingProfile = (_s = (_p = params.seedingProfile) !== null && _p !== void 0 ? _p : (_r = (_q = seedingPolicy === null || seedingPolicy === void 0 ? void 0 : seedingPolicy.seedingProfile) === null || _q === void 0 ? void 0 : _q.drawTypes) === null || _r === void 0 ? void 0 : _r[drawType]) !== null && _s !== void 0 ? _s : seedingPolicy === null || seedingPolicy === void 0 ? void 0 : seedingPolicy.seedingProfile;
|
|
41977
42201
|
// extend policyDefinitions only if a seedingProfile was specified in params
|
|
41978
42202
|
if (params.seedingProfile) {
|
|
41979
42203
|
if (!policyDefinitions[POLICY_TYPE_SEEDING]) {
|
|
@@ -41983,29 +42207,29 @@ function generateDrawDefinition(params) {
|
|
|
41983
42207
|
}
|
|
41984
42208
|
// get participants both for entry validation and for automated placement
|
|
41985
42209
|
// automated placement requires them to be "inContext" for avoidance policies to work
|
|
41986
|
-
var
|
|
42210
|
+
var _32 = getParticipants({
|
|
41987
42211
|
withIndividualParticipants: true,
|
|
41988
42212
|
convertExtensions: true,
|
|
41989
42213
|
internalUse: true,
|
|
41990
42214
|
tournamentRecord: tournamentRecord,
|
|
41991
|
-
}), participants =
|
|
41992
|
-
var enforceGender = (
|
|
42215
|
+
}), participants = _32.participants, participantMap = _32.participantMap;
|
|
42216
|
+
var enforceGender = (_w = (_t = params.enforceGender) !== null && _t !== void 0 ? _t : (_v = (_u = policyDefinitions === null || policyDefinitions === void 0 ? void 0 : policyDefinitions[POLICY_TYPE_MATCHUP_ACTIONS]) === null || _u === void 0 ? void 0 : _u.participants) === null || _v === void 0 ? void 0 : _v.enforceGender) !== null && _w !== void 0 ? _w : (_y = (_x = appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[POLICY_TYPE_MATCHUP_ACTIONS]) === null || _x === void 0 ? void 0 : _x.participants) === null || _y === void 0 ? void 0 : _y.enforceGender;
|
|
41993
42217
|
// if tournamentRecord is provided, and unless instructed to ignore valid types,
|
|
41994
42218
|
// check for restrictions on allowed drawTypes
|
|
41995
42219
|
var allowedDrawTypes = !ignoreAllowedDrawTypes &&
|
|
41996
42220
|
tournamentRecord &&
|
|
41997
42221
|
getAllowedDrawTypes({
|
|
41998
42222
|
tournamentRecord: tournamentRecord,
|
|
41999
|
-
categoryType: (
|
|
42000
|
-
categoryName: (
|
|
42223
|
+
categoryType: (_z = event === null || event === void 0 ? void 0 : event.category) === null || _z === void 0 ? void 0 : _z.categoryType,
|
|
42224
|
+
categoryName: (_0 = event === null || event === void 0 ? void 0 : event.category) === null || _0 === void 0 ? void 0 : _0.categoryName,
|
|
42001
42225
|
});
|
|
42002
42226
|
if ((allowedDrawTypes === null || allowedDrawTypes === void 0 ? void 0 : allowedDrawTypes.length) && !allowedDrawTypes.includes(drawType)) {
|
|
42003
42227
|
return decorateResult({ result: { error: INVALID_DRAW_TYPE }, stack: stack });
|
|
42004
42228
|
}
|
|
42005
|
-
var eventEntries = (
|
|
42229
|
+
var eventEntries = (_2 = (_1 = event === null || event === void 0 ? void 0 : event.entries) === null || _1 === void 0 ? void 0 : _1.filter(function (entry) {
|
|
42006
42230
|
return entry.entryStatus &&
|
|
42007
42231
|
__spreadArray(__spreadArray([], __read(STRUCTURE_SELECTED_STATUSES), false), [QUALIFIER], false).includes(entry.entryStatus);
|
|
42008
|
-
})) !== null &&
|
|
42232
|
+
})) !== null && _2 !== void 0 ? _2 : [];
|
|
42009
42233
|
var consideredEntries = ((qualifyingOnly && []) ||
|
|
42010
42234
|
drawEntries ||
|
|
42011
42235
|
(considerEventEntries ? eventEntries : [])).filter(function (_a) {
|
|
@@ -42049,12 +42273,12 @@ function generateDrawDefinition(params) {
|
|
|
42049
42273
|
});
|
|
42050
42274
|
}
|
|
42051
42275
|
var seedsCount = typeof params.seedsCount !== 'number'
|
|
42052
|
-
? ensureInt((
|
|
42053
|
-
: (
|
|
42276
|
+
? ensureInt((_3 = params.seedsCount) !== null && _3 !== void 0 ? _3 : 0)
|
|
42277
|
+
: (_4 = params.seedsCount) !== null && _4 !== void 0 ? _4 : 0;
|
|
42054
42278
|
var eventType = event === null || event === void 0 ? void 0 : event.eventType;
|
|
42055
|
-
var matchUpType = (
|
|
42279
|
+
var matchUpType = (_5 = params.matchUpType) !== null && _5 !== void 0 ? _5 : eventType;
|
|
42056
42280
|
var existingDrawDefinition = params.drawId
|
|
42057
|
-
? (
|
|
42281
|
+
? (_6 = event === null || event === void 0 ? void 0 : event.drawDefinitions) === null || _6 === void 0 ? void 0 : _6.find(function (d) { return d.drawId === params.drawId; })
|
|
42058
42282
|
: undefined;
|
|
42059
42283
|
// drawDefinition cannot have both tieFormat and matchUpFormat
|
|
42060
42284
|
var tieFormat = params.tieFormat, matchUpFormat = params.matchUpFormat;
|
|
@@ -42062,16 +42286,16 @@ function generateDrawDefinition(params) {
|
|
|
42062
42286
|
if (matchUpType === TEAM$1 && eventType === TEAM$1) {
|
|
42063
42287
|
// if there is an existingDrawDefinition which has a tieFormat on MAIN structure
|
|
42064
42288
|
// use this tieFormat ONLY when no tieFormat is specified in params
|
|
42065
|
-
var existingMainTieFormat = (
|
|
42289
|
+
var existingMainTieFormat = (_8 = (_7 = existingDrawDefinition === null || existingDrawDefinition === void 0 ? void 0 : existingDrawDefinition.structures) === null || _7 === void 0 ? void 0 : _7.find(function (_a) {
|
|
42066
42290
|
var stage = _a.stage;
|
|
42067
42291
|
return stage === MAIN;
|
|
42068
|
-
})) === null ||
|
|
42292
|
+
})) === null || _8 === void 0 ? void 0 : _8.tieFormat;
|
|
42069
42293
|
tieFormat =
|
|
42070
42294
|
tieFormat ||
|
|
42071
42295
|
existingMainTieFormat ||
|
|
42072
42296
|
// if tieFormatName is provided and it matches the name of the tieFormat attached to parent event...
|
|
42073
42297
|
(tieFormatName &&
|
|
42074
|
-
((
|
|
42298
|
+
((_9 = event === null || event === void 0 ? void 0 : event.tieFormat) === null || _9 === void 0 ? void 0 : _9.tieFormatName) === tieFormatName &&
|
|
42075
42299
|
event.tieFormat) ||
|
|
42076
42300
|
// if the tieFormatName is not found in the factory then will use default
|
|
42077
42301
|
(tieFormatName &&
|
|
@@ -42127,7 +42351,7 @@ function generateDrawDefinition(params) {
|
|
|
42127
42351
|
var result = checkTieFormat({ tieFormat: tieFormat });
|
|
42128
42352
|
if (result.error)
|
|
42129
42353
|
return decorateResult({ result: result, stack: stack });
|
|
42130
|
-
drawDefinition.tieFormat = (
|
|
42354
|
+
drawDefinition.tieFormat = (_10 = result.tieFormat) !== null && _10 !== void 0 ? _10 : tieFormat;
|
|
42131
42355
|
}
|
|
42132
42356
|
else if (matchUpFormat) {
|
|
42133
42357
|
var result = setMatchUpMatchUpFormat({
|
|
@@ -42165,8 +42389,8 @@ function generateDrawDefinition(params) {
|
|
|
42165
42389
|
}
|
|
42166
42390
|
else {
|
|
42167
42391
|
try {
|
|
42168
|
-
for (var
|
|
42169
|
-
var key =
|
|
42392
|
+
for (var _33 = __values(Object.keys(policyDefinitions)), _34 = _33.next(); !_34.done; _34 = _33.next()) {
|
|
42393
|
+
var key = _34.value;
|
|
42170
42394
|
if (JSON.stringify(appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[key]) !==
|
|
42171
42395
|
JSON.stringify(policyDefinitions[key])) {
|
|
42172
42396
|
policiesToAttach[key] = policyDefinitions[key];
|
|
@@ -42176,7 +42400,7 @@ function generateDrawDefinition(params) {
|
|
|
42176
42400
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
42177
42401
|
finally {
|
|
42178
42402
|
try {
|
|
42179
|
-
if (
|
|
42403
|
+
if (_34 && !_34.done && (_b = _33.return)) _b.call(_33);
|
|
42180
42404
|
}
|
|
42181
42405
|
finally { if (e_1) throw e_1.error; }
|
|
42182
42406
|
}
|
|
@@ -42203,19 +42427,19 @@ function generateDrawDefinition(params) {
|
|
|
42203
42427
|
}
|
|
42204
42428
|
// ---------------------------------------------------------------------------
|
|
42205
42429
|
// find existing MAIN structureId if existingDrawDefinition
|
|
42206
|
-
var structureId = (
|
|
42430
|
+
var structureId = (_12 = (_11 = existingDrawDefinition === null || existingDrawDefinition === void 0 ? void 0 : existingDrawDefinition.structures) === null || _11 === void 0 ? void 0 : _11.find(function (structure) { return structure.stage === MAIN && structure.stageSequence === 1; })) === null || _12 === void 0 ? void 0 : _12.structureId;
|
|
42207
42431
|
var entries = drawEntries !== null && drawEntries !== void 0 ? drawEntries : eventEntries;
|
|
42208
42432
|
var positioningReports = [];
|
|
42209
42433
|
var drawTypeResult;
|
|
42210
42434
|
var conflicts = [];
|
|
42211
42435
|
var generateQualifyingPlaceholder = params.qualifyingPlaceholder &&
|
|
42212
|
-
!((
|
|
42436
|
+
!((_13 = params.qualifyingProfiles) === null || _13 === void 0 ? void 0 : _13.length) &&
|
|
42213
42437
|
!existingDrawDefinition;
|
|
42214
42438
|
var existingQualifyingStructures = existingDrawDefinition
|
|
42215
|
-
? (
|
|
42439
|
+
? (_14 = existingDrawDefinition.structures) === null || _14 === void 0 ? void 0 : _14.filter(function (structure) { return structure.stage === QUALIFYING; })
|
|
42216
42440
|
: [];
|
|
42217
42441
|
var existingQualifyingPlaceholderStructureId = (existingQualifyingStructures === null || existingQualifyingStructures === void 0 ? void 0 : existingQualifyingStructures.length) === 1 &&
|
|
42218
|
-
!((
|
|
42442
|
+
!((_15 = existingQualifyingStructures[0].matchUps) === null || _15 === void 0 ? void 0 : _15.length) &&
|
|
42219
42443
|
existingQualifyingStructures[0].structureId;
|
|
42220
42444
|
if (existingQualifyingPlaceholderStructureId) {
|
|
42221
42445
|
var qualifyingProfiles = params.qualifyingProfiles;
|
|
@@ -42231,24 +42455,24 @@ function generateDrawDefinition(params) {
|
|
|
42231
42455
|
if (qualifyingResult === null || qualifyingResult === void 0 ? void 0 : qualifyingResult.error) {
|
|
42232
42456
|
return qualifyingResult;
|
|
42233
42457
|
}
|
|
42234
|
-
drawDefinition.structures = (
|
|
42458
|
+
drawDefinition.structures = (_16 = drawDefinition.structures) === null || _16 === void 0 ? void 0 : _16.filter(function (_a) {
|
|
42235
42459
|
var structureId = _a.structureId;
|
|
42236
42460
|
return structureId !== existingQualifyingPlaceholderStructureId;
|
|
42237
42461
|
});
|
|
42238
|
-
drawDefinition.links = (
|
|
42462
|
+
drawDefinition.links = (_17 = drawDefinition.links) === null || _17 === void 0 ? void 0 : _17.filter(function (_a) {
|
|
42239
42463
|
var source = _a.source;
|
|
42240
42464
|
return source.structureId !== existingQualifyingPlaceholderStructureId;
|
|
42241
42465
|
});
|
|
42242
|
-
var
|
|
42466
|
+
var _35 = qualifyingResult !== null && qualifyingResult !== void 0 ? qualifyingResult : {}, qualifiersCount = _35.qualifiersCount, qualifyingDrawPositionsCount = _35.qualifyingDrawPositionsCount, qualifyingDetails = _35.qualifyingDetails;
|
|
42243
42467
|
if (qualifyingDrawPositionsCount) {
|
|
42244
42468
|
if (qualifyingResult === null || qualifyingResult === void 0 ? void 0 : qualifyingResult.structures) {
|
|
42245
|
-
(
|
|
42469
|
+
(_18 = drawDefinition.structures) === null || _18 === void 0 ? void 0 : _18.push.apply(_18, __spreadArray([], __read(qualifyingResult.structures), false));
|
|
42246
42470
|
}
|
|
42247
42471
|
if (qualifyingResult === null || qualifyingResult === void 0 ? void 0 : qualifyingResult.links) {
|
|
42248
|
-
(
|
|
42472
|
+
(_19 = drawDefinition.links) === null || _19 === void 0 ? void 0 : _19.push.apply(_19, __spreadArray([], __read(qualifyingResult.links), false));
|
|
42249
42473
|
}
|
|
42250
42474
|
}
|
|
42251
|
-
var mainStructure = (
|
|
42475
|
+
var mainStructure = (_20 = drawDefinition.structures) === null || _20 === void 0 ? void 0 : _20.find(function (_a) {
|
|
42252
42476
|
var stage = _a.stage, stageSequence = _a.stageSequence;
|
|
42253
42477
|
return stage === MAIN && stageSequence === 1;
|
|
42254
42478
|
});
|
|
@@ -42274,12 +42498,12 @@ function generateDrawDefinition(params) {
|
|
|
42274
42498
|
if (result.error)
|
|
42275
42499
|
return result;
|
|
42276
42500
|
try {
|
|
42277
|
-
for (var
|
|
42501
|
+
for (var _36 = __values((drawEntries !== null && drawEntries !== void 0 ? drawEntries : []).filter(function (_a) {
|
|
42278
42502
|
var entryStage = _a.entryStage;
|
|
42279
42503
|
return entryStage === QUALIFYING;
|
|
42280
|
-
})),
|
|
42281
|
-
var entry =
|
|
42282
|
-
var entryData = __assign(__assign({}, entry), { entryStage: (
|
|
42504
|
+
})), _37 = _36.next(); !_37.done; _37 = _36.next()) {
|
|
42505
|
+
var entry = _37.value;
|
|
42506
|
+
var entryData = __assign(__assign({}, entry), { entryStage: (_21 = entry.entryStage) !== null && _21 !== void 0 ? _21 : MAIN, drawDefinition: drawDefinition });
|
|
42283
42507
|
// ignore errors (EXITING_PARTICIPANT)
|
|
42284
42508
|
addDrawEntry(entryData);
|
|
42285
42509
|
}
|
|
@@ -42287,23 +42511,23 @@ function generateDrawDefinition(params) {
|
|
|
42287
42511
|
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
42288
42512
|
finally {
|
|
42289
42513
|
try {
|
|
42290
|
-
if (
|
|
42514
|
+
if (_37 && !_37.done && (_c = _36.return)) _c.call(_36);
|
|
42291
42515
|
}
|
|
42292
42516
|
finally { if (e_2) throw e_2.error; }
|
|
42293
42517
|
}
|
|
42294
42518
|
try {
|
|
42295
|
-
for (var
|
|
42296
|
-
var qualifyingDetail =
|
|
42519
|
+
for (var _38 = __values(qualifyingDetails || []), _39 = _38.next(); !_39.done; _39 = _38.next()) {
|
|
42520
|
+
var qualifyingDetail = _39.value;
|
|
42297
42521
|
var qualifyingRoundNumber = qualifyingDetail.finalQualifyingRoundNumber, qualifyingStructureId = qualifyingDetail.finalQualifyingStructureId, targetEntryRound = qualifyingDetail.roundTarget, finishingPositions = qualifyingDetail.finishingPositions, linkType = qualifyingDetail.linkType;
|
|
42298
42522
|
var link = mainStructure &&
|
|
42299
|
-
((
|
|
42523
|
+
((_22 = generateQualifyingLink({
|
|
42300
42524
|
targetStructureId: mainStructure.structureId,
|
|
42301
42525
|
sourceStructureId: qualifyingStructureId,
|
|
42302
42526
|
sourceRoundNumber: qualifyingRoundNumber,
|
|
42303
42527
|
finishingPositions: finishingPositions,
|
|
42304
42528
|
targetEntryRound: targetEntryRound,
|
|
42305
42529
|
linkType: linkType,
|
|
42306
|
-
})) === null ||
|
|
42530
|
+
})) === null || _22 === void 0 ? void 0 : _22.link);
|
|
42307
42531
|
if (link === null || link === void 0 ? void 0 : link.error)
|
|
42308
42532
|
return link;
|
|
42309
42533
|
if (link) {
|
|
@@ -42316,7 +42540,7 @@ function generateDrawDefinition(params) {
|
|
|
42316
42540
|
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
42317
42541
|
finally {
|
|
42318
42542
|
try {
|
|
42319
|
-
if (
|
|
42543
|
+
if (_39 && !_39.done && (_d = _38.return)) _d.call(_38);
|
|
42320
42544
|
}
|
|
42321
42545
|
finally { if (e_3) throw e_3.error; }
|
|
42322
42546
|
}
|
|
@@ -42335,7 +42559,7 @@ function generateDrawDefinition(params) {
|
|
|
42335
42559
|
// if drawEntries and entryStage !== stage ignore
|
|
42336
42560
|
if (drawEntries && entry.entryStage && entry.entryStage !== MAIN)
|
|
42337
42561
|
continue;
|
|
42338
|
-
var entryData = __assign(__assign({}, entry), { ignoreStageSpace: ignoreStageSpace !== null && ignoreStageSpace !== void 0 ? ignoreStageSpace : drawType === AD_HOC, entryStage: (
|
|
42562
|
+
var entryData = __assign(__assign({}, entry), { ignoreStageSpace: ignoreStageSpace !== null && ignoreStageSpace !== void 0 ? ignoreStageSpace : drawType === AD_HOC, entryStage: (_23 = entry.entryStage) !== null && _23 !== void 0 ? _23 : MAIN, drawDefinition: drawDefinition, drawType: drawType });
|
|
42339
42563
|
var result = addDrawEntry(entryData);
|
|
42340
42564
|
if (drawEntries && result.error) {
|
|
42341
42565
|
// only report errors with drawEntries
|
|
@@ -42359,13 +42583,13 @@ function generateDrawDefinition(params) {
|
|
|
42359
42583
|
if (structureResult.error && !structureResult.conflicts) {
|
|
42360
42584
|
return structureResult;
|
|
42361
42585
|
}
|
|
42362
|
-
if ((
|
|
42586
|
+
if ((_24 = structureResult.positioningReport) === null || _24 === void 0 ? void 0 : _24.length)
|
|
42363
42587
|
positioningReports.push((_f = {}, _f[MAIN] = structureResult.positioningReport, _f));
|
|
42364
42588
|
structureId = structureResult.structureId;
|
|
42365
42589
|
if (structureResult.conflicts)
|
|
42366
42590
|
conflicts = structureResult.conflicts;
|
|
42367
42591
|
if (drawType === AD_HOC && params.roundsCount) {
|
|
42368
|
-
var entries_2 = (
|
|
42592
|
+
var entries_2 = (_25 = event === null || event === void 0 ? void 0 : event.entries) === null || _25 === void 0 ? void 0 : _25.filter(function (_a) {
|
|
42369
42593
|
var entryStage = _a.entryStage, entryStatus = _a.entryStatus;
|
|
42370
42594
|
return (!entryStage || entryStage === MAIN) &&
|
|
42371
42595
|
entryStatus &&
|
|
@@ -42377,7 +42601,7 @@ function generateDrawDefinition(params) {
|
|
|
42377
42601
|
var _a, _b, _c;
|
|
42378
42602
|
if (params.automated) {
|
|
42379
42603
|
var _d = (_a = params.drawMatic) !== null && _a !== void 0 ? _a : {}, restrictEntryStatus = _d.restrictEntryStatus, generateMatchUps = _d.generateMatchUps, structureId_1 = _d.structureId, matchUpIds = _d.matchUpIds, scaleName = _d.scaleName;
|
|
42380
|
-
var matchUps = drawMatic
|
|
42604
|
+
var matchUps = drawMatic({
|
|
42381
42605
|
eventType: (_c = (_b = params.drawMatic) === null || _b === void 0 ? void 0 : _b.eventType) !== null && _c !== void 0 ? _c : matchUpType,
|
|
42382
42606
|
generateMatchUps: generateMatchUps !== null && generateMatchUps !== void 0 ? generateMatchUps : true,
|
|
42383
42607
|
restrictEntryStatus: restrictEntryStatus,
|
|
@@ -42386,7 +42610,8 @@ function generateDrawDefinition(params) {
|
|
|
42386
42610
|
drawDefinition: drawDefinition,
|
|
42387
42611
|
structureId: structureId_1,
|
|
42388
42612
|
matchUpIds: matchUpIds,
|
|
42389
|
-
scaleName: scaleName,
|
|
42613
|
+
scaleName: scaleName, // custom rating name to seed dynamic ratings
|
|
42614
|
+
event: event,
|
|
42390
42615
|
}).matchUps;
|
|
42391
42616
|
addAdHocMatchUps({
|
|
42392
42617
|
tournamentRecord: tournamentRecord,
|
|
@@ -42400,6 +42625,7 @@ function generateDrawDefinition(params) {
|
|
|
42400
42625
|
newRound: true,
|
|
42401
42626
|
drawDefinition: drawDefinition,
|
|
42402
42627
|
matchUpsCount: matchUpsCount_1,
|
|
42628
|
+
event: event,
|
|
42403
42629
|
}).matchUps;
|
|
42404
42630
|
addAdHocMatchUps({
|
|
42405
42631
|
tournamentRecord: tournamentRecord,
|
|
@@ -42420,8 +42646,8 @@ function generateDrawDefinition(params) {
|
|
|
42420
42646
|
var roundTarget = 1;
|
|
42421
42647
|
params.qualifyingProfiles.sort(roundTargetSort);
|
|
42422
42648
|
try {
|
|
42423
|
-
for (var
|
|
42424
|
-
var roundTargetProfile =
|
|
42649
|
+
for (var _40 = __values(params.qualifyingProfiles), _41 = _40.next(); !_41.done; _41 = _40.next()) {
|
|
42650
|
+
var roundTargetProfile = _41.value;
|
|
42425
42651
|
if (!Array.isArray(roundTargetProfile.structureProfiles))
|
|
42426
42652
|
return decorateResult({
|
|
42427
42653
|
info: mustBeAnArray('structureProfiles'),
|
|
@@ -42429,13 +42655,13 @@ function generateDrawDefinition(params) {
|
|
|
42429
42655
|
stack: stack,
|
|
42430
42656
|
});
|
|
42431
42657
|
roundTarget = roundTargetProfile.roundTarget || roundTarget;
|
|
42432
|
-
var sortedStructureProfiles = ((
|
|
42658
|
+
var sortedStructureProfiles = ((_26 = roundTargetProfile.structureProfiles) === null || _26 === void 0 ? void 0 : _26.sort(sequenceSort)) || [];
|
|
42433
42659
|
var sequence = 1;
|
|
42434
42660
|
try {
|
|
42435
42661
|
for (var sortedStructureProfiles_1 = (e_6 = void 0, __values(sortedStructureProfiles)), sortedStructureProfiles_1_1 = sortedStructureProfiles_1.next(); !sortedStructureProfiles_1_1.done; sortedStructureProfiles_1_1 = sortedStructureProfiles_1.next()) {
|
|
42436
42662
|
var structureProfile = sortedStructureProfiles_1_1.value;
|
|
42437
|
-
var qualifyingRoundNumber = structureProfile.qualifyingRoundNumber, qualifyingPositions = structureProfile.qualifyingPositions, seededParticipants = structureProfile.seededParticipants, seedingScaleName = structureProfile.seedingScaleName,
|
|
42438
|
-
var qualifyingStageResult = prepareStage(__assign(__assign(__assign({}, drawTypeResult), params), { seedingProfile: (
|
|
42663
|
+
var qualifyingRoundNumber = structureProfile.qualifyingRoundNumber, qualifyingPositions = structureProfile.qualifyingPositions, seededParticipants = structureProfile.seededParticipants, seedingScaleName = structureProfile.seedingScaleName, _42 = structureProfile.seedsCount, seedsCount_1 = _42 === void 0 ? 0 : _42, seedByRanking = structureProfile.seedByRanking, placeByes_1 = structureProfile.placeByes, drawSize_1 = structureProfile.drawSize;
|
|
42664
|
+
var qualifyingStageResult = prepareStage(__assign(__assign(__assign({}, drawTypeResult), params), { seedingProfile: (_27 = structureProfile.seedingProfile) !== null && _27 !== void 0 ? _27 : seedingProfile, stageSequence: sequence, qualifyingRoundNumber: qualifyingRoundNumber, preparedStructureIds: preparedStructureIds, qualifyingPositions: qualifyingPositions, seededParticipants: seededParticipants, stage: QUALIFYING, seedingScaleName: seedingScaleName, appliedPolicies: appliedPolicies, drawDefinition: drawDefinition, qualifyingOnly: qualifyingOnly, seedByRanking: seedByRanking, participants: participants, roundTarget: roundTarget, seedsCount: seedsCount_1, placeByes: placeByes_1, drawSize: drawSize_1, entries: entries }));
|
|
42439
42665
|
if (qualifyingStageResult.error) {
|
|
42440
42666
|
return qualifyingStageResult;
|
|
42441
42667
|
}
|
|
@@ -42443,9 +42669,9 @@ function generateDrawDefinition(params) {
|
|
|
42443
42669
|
preparedStructureIds.push(qualifyingStageResult.structureId);
|
|
42444
42670
|
}
|
|
42445
42671
|
sequence += 1;
|
|
42446
|
-
if ((
|
|
42672
|
+
if ((_28 = qualifyingStageResult.conflicts) === null || _28 === void 0 ? void 0 : _28.length)
|
|
42447
42673
|
qualifyingConflicts.push.apply(qualifyingConflicts, __spreadArray([], __read(qualifyingStageResult.conflicts), false));
|
|
42448
|
-
if ((
|
|
42674
|
+
if ((_29 = qualifyingStageResult.positioningReport) === null || _29 === void 0 ? void 0 : _29.length)
|
|
42449
42675
|
positioningReports.push((_j = {},
|
|
42450
42676
|
_j[QUALIFYING] = qualifyingStageResult.positioningReport,
|
|
42451
42677
|
_j));
|
|
@@ -42464,7 +42690,7 @@ function generateDrawDefinition(params) {
|
|
|
42464
42690
|
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
42465
42691
|
finally {
|
|
42466
42692
|
try {
|
|
42467
|
-
if (
|
|
42693
|
+
if (_41 && !_41.done && (_g = _40.return)) _g.call(_40);
|
|
42468
42694
|
}
|
|
42469
42695
|
finally { if (e_5) throw e_5.error; }
|
|
42470
42696
|
}
|
|
@@ -42488,7 +42714,7 @@ function generateDrawDefinition(params) {
|
|
|
42488
42714
|
drawDefinition.links.push(link);
|
|
42489
42715
|
}
|
|
42490
42716
|
drawDefinition.drawName =
|
|
42491
|
-
(
|
|
42717
|
+
(_30 = params.drawName) !== null && _30 !== void 0 ? _30 : (drawType && constantToString(drawType));
|
|
42492
42718
|
if (typeof voluntaryConsolation === 'object' && drawSize >= 4) {
|
|
42493
42719
|
addVoluntaryConsolationStructure(__assign(__assign({}, voluntaryConsolation), { drawDefinition: drawDefinition, matchUpType: matchUpType }));
|
|
42494
42720
|
}
|
|
@@ -52325,19 +52551,19 @@ function unPublishEventSeeding(_a) {
|
|
|
52325
52551
|
}
|
|
52326
52552
|
|
|
52327
52553
|
var publishingGovernor = {
|
|
52328
|
-
getTournamentInfo: getTournamentInfo,
|
|
52329
|
-
getVenueData: getVenueData,
|
|
52330
|
-
getCourtInfo: getCourtInfo,
|
|
52331
52554
|
getAllEventData: getAllEventData,
|
|
52332
|
-
|
|
52555
|
+
getCourtInfo: getCourtInfo,
|
|
52333
52556
|
getDrawData: getDrawData,
|
|
52334
|
-
|
|
52557
|
+
getEventData: getEventData,
|
|
52558
|
+
getPublishState: getPublishState,
|
|
52559
|
+
getVenueData: getVenueData,
|
|
52560
|
+
publishEvent: publishEvent,
|
|
52335
52561
|
publishEventSeeding: publishEventSeeding,
|
|
52562
|
+
publishOrderOfPlay: publishOrderOfPlay,
|
|
52336
52563
|
setEventDisplay: setEventDisplay,
|
|
52337
52564
|
unPublishEvent: unPublishEvent,
|
|
52338
|
-
|
|
52565
|
+
unPublishEventSeeding: unPublishEventSeeding,
|
|
52339
52566
|
unPublishOrderOfPlay: unPublishOrderOfPlay,
|
|
52340
|
-
publishOrderOfPlay: publishOrderOfPlay,
|
|
52341
52567
|
};
|
|
52342
52568
|
|
|
52343
52569
|
function getEligibleVoluntaryConsolationParticipants(_a) {
|
|
@@ -53304,6 +53530,54 @@ function getParticipantEventDetails(_a) {
|
|
|
53304
53530
|
return { eventDetails: relevantEvents };
|
|
53305
53531
|
}
|
|
53306
53532
|
|
|
53533
|
+
function getCompetitionPublishedDrawDetails(_a) {
|
|
53534
|
+
var e_1, _b, e_2, _c;
|
|
53535
|
+
var _d, _e;
|
|
53536
|
+
var tournamentRecords = _a.tournamentRecords;
|
|
53537
|
+
var drawIds = [];
|
|
53538
|
+
var detailsMap = {};
|
|
53539
|
+
try {
|
|
53540
|
+
for (var _f = __values(Object.values(tournamentRecords)), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
53541
|
+
var tournamentRecord = _g.value;
|
|
53542
|
+
var _loop_1 = function (event_1) {
|
|
53543
|
+
var eventPubStatus = getEventPublishStatus({ event: event_1 });
|
|
53544
|
+
var drawDetails = eventPubStatus === null || eventPubStatus === void 0 ? void 0 : eventPubStatus.drawDetails;
|
|
53545
|
+
if (isObject(drawDetails)) {
|
|
53546
|
+
Object.assign(detailsMap, drawDetails);
|
|
53547
|
+
drawIds.push.apply(drawIds, __spreadArray([], __read(Object.keys(drawDetails).filter(function (drawId) {
|
|
53548
|
+
return getDrawPublishStatus({ drawId: drawId, drawDetails: drawDetails });
|
|
53549
|
+
})), false));
|
|
53550
|
+
}
|
|
53551
|
+
else if ((_e = eventPubStatus === null || eventPubStatus === void 0 ? void 0 : eventPubStatus.drawIds) === null || _e === void 0 ? void 0 : _e.length) {
|
|
53552
|
+
// LEGACY - deprecate
|
|
53553
|
+
drawIds.push.apply(drawIds, __spreadArray([], __read(eventPubStatus.drawIds), false));
|
|
53554
|
+
}
|
|
53555
|
+
};
|
|
53556
|
+
try {
|
|
53557
|
+
for (var _h = (e_2 = void 0, __values((_d = tournamentRecord.events) !== null && _d !== void 0 ? _d : [])), _j = _h.next(); !_j.done; _j = _h.next()) {
|
|
53558
|
+
var event_1 = _j.value;
|
|
53559
|
+
_loop_1(event_1);
|
|
53560
|
+
}
|
|
53561
|
+
}
|
|
53562
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
53563
|
+
finally {
|
|
53564
|
+
try {
|
|
53565
|
+
if (_j && !_j.done && (_c = _h.return)) _c.call(_h);
|
|
53566
|
+
}
|
|
53567
|
+
finally { if (e_2) throw e_2.error; }
|
|
53568
|
+
}
|
|
53569
|
+
}
|
|
53570
|
+
}
|
|
53571
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
53572
|
+
finally {
|
|
53573
|
+
try {
|
|
53574
|
+
if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
|
|
53575
|
+
}
|
|
53576
|
+
finally { if (e_1) throw e_1.error; }
|
|
53577
|
+
}
|
|
53578
|
+
return { drawIds: drawIds, detailsMap: detailsMap };
|
|
53579
|
+
}
|
|
53580
|
+
|
|
53307
53581
|
function scheduledSortedMatchUps(_a) {
|
|
53308
53582
|
var e_1, _b, e_2, _c, e_3, _d, e_4, _e;
|
|
53309
53583
|
var schedulingProfile = _a.schedulingProfile, _f = _a.matchUps, matchUps = _f === void 0 ? [] : _f;
|
|
@@ -53832,53 +54106,6 @@ function competitionScheduleMatchUps(params) {
|
|
|
53832
54106
|
: courtMatchUps;
|
|
53833
54107
|
}
|
|
53834
54108
|
}
|
|
53835
|
-
function getCompetitionPublishedDrawDetails(_a) {
|
|
53836
|
-
var e_1, _b, e_2, _c;
|
|
53837
|
-
var _d, _e;
|
|
53838
|
-
var tournamentRecords = _a.tournamentRecords;
|
|
53839
|
-
var drawIds = [];
|
|
53840
|
-
var detailsMap = {};
|
|
53841
|
-
try {
|
|
53842
|
-
for (var _f = __values(Object.values(tournamentRecords)), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
53843
|
-
var tournamentRecord = _g.value;
|
|
53844
|
-
var _loop_1 = function (event_1) {
|
|
53845
|
-
var eventPubStatus = getEventPublishStatus({ event: event_1 });
|
|
53846
|
-
var drawDetails = eventPubStatus === null || eventPubStatus === void 0 ? void 0 : eventPubStatus.drawDetails;
|
|
53847
|
-
if (isObject(drawDetails)) {
|
|
53848
|
-
Object.assign(detailsMap, drawDetails);
|
|
53849
|
-
drawIds.push.apply(drawIds, __spreadArray([], __read(Object.keys(drawDetails).filter(function (drawId) {
|
|
53850
|
-
return getDrawPublishStatus({ drawId: drawId, drawDetails: drawDetails });
|
|
53851
|
-
})), false));
|
|
53852
|
-
}
|
|
53853
|
-
else if ((_e = eventPubStatus === null || eventPubStatus === void 0 ? void 0 : eventPubStatus.drawIds) === null || _e === void 0 ? void 0 : _e.length) {
|
|
53854
|
-
// LEGACY - deprecate
|
|
53855
|
-
drawIds.push.apply(drawIds, __spreadArray([], __read(eventPubStatus.drawIds), false));
|
|
53856
|
-
}
|
|
53857
|
-
};
|
|
53858
|
-
try {
|
|
53859
|
-
for (var _h = (e_2 = void 0, __values((_d = tournamentRecord.events) !== null && _d !== void 0 ? _d : [])), _j = _h.next(); !_j.done; _j = _h.next()) {
|
|
53860
|
-
var event_1 = _j.value;
|
|
53861
|
-
_loop_1(event_1);
|
|
53862
|
-
}
|
|
53863
|
-
}
|
|
53864
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
53865
|
-
finally {
|
|
53866
|
-
try {
|
|
53867
|
-
if (_j && !_j.done && (_c = _h.return)) _c.call(_h);
|
|
53868
|
-
}
|
|
53869
|
-
finally { if (e_2) throw e_2.error; }
|
|
53870
|
-
}
|
|
53871
|
-
}
|
|
53872
|
-
}
|
|
53873
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
53874
|
-
finally {
|
|
53875
|
-
try {
|
|
53876
|
-
if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
|
|
53877
|
-
}
|
|
53878
|
-
finally { if (e_1) throw e_1.error; }
|
|
53879
|
-
}
|
|
53880
|
-
return { drawIds: drawIds, detailsMap: detailsMap };
|
|
53881
|
-
}
|
|
53882
54109
|
|
|
53883
54110
|
function getParticipantMembership(_a) {
|
|
53884
54111
|
var tournamentRecord = _a.tournamentRecord, participantId = _a.participantId;
|
|
@@ -53905,6 +54132,53 @@ function getParticipantMembership(_a) {
|
|
|
53905
54132
|
}, {});
|
|
53906
54133
|
}
|
|
53907
54134
|
|
|
54135
|
+
/**
|
|
54136
|
+
*
|
|
54137
|
+
* @param {object[]} outcomes - array of outcomes to be applied to matchUps, relevent attributes: { eventId: string; drawId: string; }
|
|
54138
|
+
*
|
|
54139
|
+
*/
|
|
54140
|
+
function bulkUpdatePublishedEventIds(_a) {
|
|
54141
|
+
var _b;
|
|
54142
|
+
var tournamentRecord = _a.tournamentRecord, outcomes = _a.outcomes;
|
|
54143
|
+
if (!tournamentRecord)
|
|
54144
|
+
return { error: MISSING_TOURNAMENT_RECORD };
|
|
54145
|
+
if (!(outcomes === null || outcomes === void 0 ? void 0 : outcomes.length))
|
|
54146
|
+
return { error: MISSING_VALUE, info: 'Missing outcomes' };
|
|
54147
|
+
var eventIdsMap = outcomes.reduce(function (eventIdsMap, outcome) {
|
|
54148
|
+
var drawId = outcome.drawId, eventId = outcome.eventId;
|
|
54149
|
+
if (eventId && drawId) {
|
|
54150
|
+
if (!eventIdsMap[eventId]) {
|
|
54151
|
+
eventIdsMap[eventId] = [drawId];
|
|
54152
|
+
}
|
|
54153
|
+
else if (!eventIdsMap[eventId].includes(drawId)) {
|
|
54154
|
+
eventIdsMap[eventId].push(drawId);
|
|
54155
|
+
}
|
|
54156
|
+
}
|
|
54157
|
+
return eventIdsMap;
|
|
54158
|
+
}, {});
|
|
54159
|
+
var relevantEventsIds = Object.keys(eventIdsMap);
|
|
54160
|
+
var relevantEvents = (_b = tournamentRecord.events) === null || _b === void 0 ? void 0 : _b.filter(function (event) {
|
|
54161
|
+
return relevantEventsIds.includes(event.eventId);
|
|
54162
|
+
});
|
|
54163
|
+
var publishedEventIds = relevantEvents
|
|
54164
|
+
.filter(function (event) {
|
|
54165
|
+
var pubStatus = getEventPublishStatus({ event: event });
|
|
54166
|
+
var _a = pubStatus !== null && pubStatus !== void 0 ? pubStatus : {}, drawDetails = _a.drawDetails, drawIds = _a.drawIds;
|
|
54167
|
+
var eventId = event.eventId;
|
|
54168
|
+
var publishedDrawIds = eventIdsMap[eventId].filter(function (drawId) {
|
|
54169
|
+
var keyedDrawIds = drawDetails
|
|
54170
|
+
? Object.keys(pubStatus.drawDetails).filter(function (drawId) {
|
|
54171
|
+
return getDrawPublishStatus({ drawId: drawId, drawDetails: drawDetails });
|
|
54172
|
+
})
|
|
54173
|
+
: [];
|
|
54174
|
+
return (drawIds === null || drawIds === void 0 ? void 0 : drawIds.includes(drawId)) || keyedDrawIds.includes(drawId);
|
|
54175
|
+
});
|
|
54176
|
+
return publishedDrawIds.length;
|
|
54177
|
+
})
|
|
54178
|
+
.map(function (event) { return event.eventId; });
|
|
54179
|
+
return { publishedEventIds: publishedEventIds, eventIdPublishedDrawIdsMap: eventIdsMap };
|
|
54180
|
+
}
|
|
54181
|
+
|
|
53908
54182
|
function getSourceStructureIdsAndRelevantLinks(_a) {
|
|
53909
54183
|
var targetRoundNumber = _a.targetRoundNumber, finishingPosition = _a.finishingPosition, drawDefinition = _a.drawDefinition, structureId = _a.structureId, // structure for which source and target links are to be found
|
|
53910
54184
|
linkType = _a.linkType;
|
|
@@ -55752,20 +56026,6 @@ function getParticipantSchedules(_a) {
|
|
|
55752
56026
|
return __assign({ participantSchedules: participantSchedules }, SUCCESS);
|
|
55753
56027
|
}
|
|
55754
56028
|
|
|
55755
|
-
function getMaxEntryPosition(params) {
|
|
55756
|
-
var _a = params.entries, entries = _a === void 0 ? [] : _a, entryStatus = params.entryStatus, stage = params.stage;
|
|
55757
|
-
return Math.max.apply(Math, __spreadArray(__spreadArray([], __read(entries
|
|
55758
|
-
.filter(function (entry) {
|
|
55759
|
-
return (!stage || stage === entry.entryStage) &&
|
|
55760
|
-
(!entryStatus || entry.entryStatus === entryStatus) &&
|
|
55761
|
-
!isNaN(entry.entryPosition);
|
|
55762
|
-
})
|
|
55763
|
-
.map(function (_a) {
|
|
55764
|
-
var entryPosition = _a.entryPosition;
|
|
55765
|
-
return ensureInt(entryPosition || 0);
|
|
55766
|
-
})), false), [0], false));
|
|
55767
|
-
}
|
|
55768
|
-
|
|
55769
56029
|
function isValidForQualifying(_a) {
|
|
55770
56030
|
var structureId = _a.structureId, drawDefinition = _a.drawDefinition;
|
|
55771
56031
|
if (!drawDefinition)
|
|
@@ -56164,6 +56424,20 @@ function getParticipantSignInStatus(_a) {
|
|
|
56164
56424
|
return timeItem && timeItem.itemValue === SIGNED_IN && SIGNED_IN;
|
|
56165
56425
|
}
|
|
56166
56426
|
|
|
56427
|
+
function getMaxEntryPosition(params) {
|
|
56428
|
+
var _a = params.entries, entries = _a === void 0 ? [] : _a, entryStatus = params.entryStatus, stage = params.stage;
|
|
56429
|
+
return Math.max.apply(Math, __spreadArray(__spreadArray([], __read(entries
|
|
56430
|
+
.filter(function (entry) {
|
|
56431
|
+
return (!stage || stage === entry.entryStage) &&
|
|
56432
|
+
(!entryStatus || entry.entryStatus === entryStatus) &&
|
|
56433
|
+
!isNaN(entry.entryPosition);
|
|
56434
|
+
})
|
|
56435
|
+
.map(function (_a) {
|
|
56436
|
+
var entryPosition = _a.entryPosition;
|
|
56437
|
+
return ensureInt(entryPosition || 0);
|
|
56438
|
+
})), false), [0], false));
|
|
56439
|
+
}
|
|
56440
|
+
|
|
56167
56441
|
function checkIsDual(tournamentRecord) {
|
|
56168
56442
|
var _a, _b, _c, _d, _e;
|
|
56169
56443
|
var teamParticipants = (_a = tournamentRecord.participants) === null || _a === void 0 ? void 0 : _a.filter(function (_a) {
|
|
@@ -56242,54 +56516,6 @@ function getMatchUpFormat(params) {
|
|
|
56242
56516
|
};
|
|
56243
56517
|
}
|
|
56244
56518
|
|
|
56245
|
-
/**
|
|
56246
|
-
*
|
|
56247
|
-
* @param {object} tournamentRecord - passed in automatically by tournamentEngine
|
|
56248
|
-
* @param {object[]} outcomes - array of outcomes to be applied to matchUps, relevent attributes: { eventId: string; drawId: string; }
|
|
56249
|
-
*
|
|
56250
|
-
*/
|
|
56251
|
-
function bulkUpdatePublishedEventIds(_a) {
|
|
56252
|
-
var _b;
|
|
56253
|
-
var tournamentRecord = _a.tournamentRecord, outcomes = _a.outcomes;
|
|
56254
|
-
if (!tournamentRecord)
|
|
56255
|
-
return { error: MISSING_TOURNAMENT_RECORD };
|
|
56256
|
-
if (!(outcomes === null || outcomes === void 0 ? void 0 : outcomes.length))
|
|
56257
|
-
return { error: MISSING_VALUE, info: 'Missing outcomes' };
|
|
56258
|
-
var eventIdsMap = outcomes.reduce(function (eventIdsMap, outcome) {
|
|
56259
|
-
var drawId = outcome.drawId, eventId = outcome.eventId;
|
|
56260
|
-
if (eventId && drawId) {
|
|
56261
|
-
if (!eventIdsMap[eventId]) {
|
|
56262
|
-
eventIdsMap[eventId] = [drawId];
|
|
56263
|
-
}
|
|
56264
|
-
else if (!eventIdsMap[eventId].includes(drawId)) {
|
|
56265
|
-
eventIdsMap[eventId].push(drawId);
|
|
56266
|
-
}
|
|
56267
|
-
}
|
|
56268
|
-
return eventIdsMap;
|
|
56269
|
-
}, {});
|
|
56270
|
-
var relevantEventsIds = Object.keys(eventIdsMap);
|
|
56271
|
-
var relevantEvents = (_b = tournamentRecord.events) === null || _b === void 0 ? void 0 : _b.filter(function (event) {
|
|
56272
|
-
return relevantEventsIds.includes(event.eventId);
|
|
56273
|
-
});
|
|
56274
|
-
var publishedEventIds = relevantEvents
|
|
56275
|
-
.filter(function (event) {
|
|
56276
|
-
var pubStatus = getEventPublishStatus({ event: event });
|
|
56277
|
-
var _a = pubStatus !== null && pubStatus !== void 0 ? pubStatus : {}, drawDetails = _a.drawDetails, drawIds = _a.drawIds;
|
|
56278
|
-
var eventId = event.eventId;
|
|
56279
|
-
var publishedDrawIds = eventIdsMap[eventId].filter(function (drawId) {
|
|
56280
|
-
var keyedDrawIds = drawDetails
|
|
56281
|
-
? Object.keys(pubStatus.drawDetails).filter(function (drawId) {
|
|
56282
|
-
return getDrawPublishStatus({ drawId: drawId, drawDetails: drawDetails });
|
|
56283
|
-
})
|
|
56284
|
-
: [];
|
|
56285
|
-
return (drawIds === null || drawIds === void 0 ? void 0 : drawIds.includes(drawId)) || keyedDrawIds.includes(drawId);
|
|
56286
|
-
});
|
|
56287
|
-
return publishedDrawIds.length;
|
|
56288
|
-
})
|
|
56289
|
-
.map(function (event) { return event.eventId; });
|
|
56290
|
-
return { publishedEventIds: publishedEventIds, eventIdPublishedDrawIdsMap: eventIdsMap };
|
|
56291
|
-
}
|
|
56292
|
-
|
|
56293
56519
|
function publicFindParticipant(params) {
|
|
56294
56520
|
var _a, e_1, _b;
|
|
56295
56521
|
var tournamentRecord = params.tournamentRecord, policyDefinitions = params.policyDefinitions, contextProfile = params.contextProfile, participantId = params.participantId, personId = params.personId;
|
|
@@ -57390,6 +57616,7 @@ var queryGovernor = {
|
|
|
57390
57616
|
getCourts: getCourts,
|
|
57391
57617
|
getDrawDefinitionTimeItem: getDrawDefinitionTimeItem,
|
|
57392
57618
|
getDrawParticipantRepresentativeIds: getDrawParticipantRepresentativeIds,
|
|
57619
|
+
getDrawTypeCoercion: getDrawTypeCoercion,
|
|
57393
57620
|
getEligibleVoluntaryConsolationParticipants: getEligibleVoluntaryConsolationParticipants,
|
|
57394
57621
|
getEntriesAndSeedsCount: getEntriesAndSeedsCount,
|
|
57395
57622
|
getEvent: getEvent,
|
|
@@ -57435,6 +57662,7 @@ var queryGovernor = {
|
|
|
57435
57662
|
getTeamLineUp: getTeamLineUp,
|
|
57436
57663
|
getTieFormat: getTieFormat,
|
|
57437
57664
|
getTournamentIds: getTournamentIds,
|
|
57665
|
+
getTournamentInfo: getTournamentInfo,
|
|
57438
57666
|
getTournamentPenalties: getTournamentPenalties,
|
|
57439
57667
|
getTournamentPersons: getTournamentPersons,
|
|
57440
57668
|
getTournamentStructures: getTournamentStructures,
|
|
@@ -65450,6 +65678,10 @@ var governors = {
|
|
|
65450
65678
|
venueGovernor: venueGovernor,
|
|
65451
65679
|
};
|
|
65452
65680
|
|
|
65681
|
+
var factoryTypes = {
|
|
65682
|
+
__proto__: null
|
|
65683
|
+
};
|
|
65684
|
+
|
|
65453
65685
|
var forge = {};
|
|
65454
65686
|
|
|
65455
65687
|
var _a$8;
|
|
@@ -65818,7 +66050,7 @@ function asyncExecutionQueue(engine, directives, rollbackOnError) {
|
|
|
65818
66050
|
var e_1, _a;
|
|
65819
66051
|
return __generator(this, function (_b) {
|
|
65820
66052
|
if (!Array.isArray(directives))
|
|
65821
|
-
return [2 /*return*/, { error: INVALID_VALUES }];
|
|
66053
|
+
return [2 /*return*/, { error: INVALID_VALUES, message: 'directives must be an array' }];
|
|
65822
66054
|
methods = getMethods();
|
|
65823
66055
|
start = Date.now();
|
|
65824
66056
|
snapshot = rollbackOnError && makeDeepCopy(getTournamentRecords(), false, true);
|
|
@@ -65827,7 +66059,7 @@ function asyncExecutionQueue(engine, directives, rollbackOnError) {
|
|
|
65827
66059
|
for (directives_1 = __values(directives), directives_1_1 = directives_1.next(); !directives_1_1.done; directives_1_1 = directives_1.next()) {
|
|
65828
66060
|
directive = directives_1_1.value;
|
|
65829
66061
|
if (typeof directive !== 'object')
|
|
65830
|
-
return [2 /*return*/, { error: INVALID_VALUES }];
|
|
66062
|
+
return [2 /*return*/, { error: INVALID_VALUES, message: 'directive must be an object' }];
|
|
65831
66063
|
methodName = directive.method, params = directive.params;
|
|
65832
66064
|
if (!methods[methodName])
|
|
65833
66065
|
return [2 /*return*/, logMethodNotFound({ methodName: methodName, start: start, params: params })];
|
|
@@ -65865,15 +66097,18 @@ function asyncEngineInvoke(engine, args) {
|
|
|
65865
66097
|
switch (_d.label) {
|
|
65866
66098
|
case 0:
|
|
65867
66099
|
if (!isObject(args))
|
|
65868
|
-
return [2 /*return*/, { error: INVALID_VALUES }];
|
|
66100
|
+
return [2 /*return*/, { error: INVALID_VALUES, message: 'args must be an object' }];
|
|
65869
66101
|
methodsCount = Object.values(args).filter(isFunction).length;
|
|
65870
66102
|
if (methodsCount > 1)
|
|
65871
|
-
return [2 /*return*/, {
|
|
66103
|
+
return [2 /*return*/, {
|
|
66104
|
+
message: 'there must be only one arg with typeof function',
|
|
66105
|
+
error: INVALID_VALUES,
|
|
66106
|
+
}];
|
|
65872
66107
|
methodName = methodsCount
|
|
65873
66108
|
? Object.keys(args).find(function (key) { return isFunction(args[key]); })
|
|
65874
66109
|
: isString(args.method) && args.method;
|
|
65875
66110
|
if (!methodName)
|
|
65876
|
-
return [2 /*return*/, { error:
|
|
66111
|
+
return [2 /*return*/, { error: METHOD_NOT_FOUND }];
|
|
65877
66112
|
_b = args, _c = methodName, passedMethod = _b[_c], remainingArgs = __rest(_b, [typeof _c === "symbol" ? _c : _c + ""]);
|
|
65878
66113
|
params = (args === null || args === void 0 ? void 0 : args.params) || __assign({}, remainingArgs);
|
|
65879
66114
|
snapshot = params.rollbackOnError && makeDeepCopy(getTournamentRecords(), false, true);
|
|
@@ -65996,6 +66231,7 @@ function engineStart(engine, engineInvoke) {
|
|
|
65996
66231
|
return processResult(engine, result);
|
|
65997
66232
|
};
|
|
65998
66233
|
engine.setTournamentId = function (tournamentId) { return setTournamentId(tournamentId); };
|
|
66234
|
+
engine.getTournamentId = function () { return getTournamentId(); };
|
|
65999
66235
|
engine.setTournamentRecord = function (tournamentRecord, deepCopyOption, deepCopyAttributes) {
|
|
66000
66236
|
setDeepCopy(deepCopyOption, deepCopyAttributes);
|
|
66001
66237
|
var result = setTournamentRecord(tournamentRecord, deepCopyOption);
|
|
@@ -66027,15 +66263,18 @@ function asyncEngine(test) {
|
|
|
66027
66263
|
|
|
66028
66264
|
function askInvoke(engine, args) {
|
|
66029
66265
|
if (!isObject(args))
|
|
66030
|
-
return { error: INVALID_VALUES };
|
|
66266
|
+
return { error: INVALID_VALUES, message: 'args must be an object' };
|
|
66031
66267
|
var methodsCount = Object.values(args).filter(isFunction).length;
|
|
66032
66268
|
if (methodsCount > 1)
|
|
66033
|
-
return {
|
|
66269
|
+
return {
|
|
66270
|
+
message: 'there must be only one arg with typeof function',
|
|
66271
|
+
error: INVALID_VALUES,
|
|
66272
|
+
};
|
|
66034
66273
|
var methodName = methodsCount
|
|
66035
66274
|
? Object.keys(args).find(function (key) { return isFunction(args[key]); })
|
|
66036
66275
|
: isString(args.method) && args.method;
|
|
66037
66276
|
if (!methodName)
|
|
66038
|
-
return { error:
|
|
66277
|
+
return { error: METHOD_NOT_FOUND };
|
|
66039
66278
|
var _a = args, _b = methodName, passedMethod = _a[_b], remainingArgs = __rest(_a, [typeof _b === "symbol" ? _b : _b + ""]);
|
|
66040
66279
|
var params = (args === null || args === void 0 ? void 0 : args.params) || __assign({}, remainingArgs);
|
|
66041
66280
|
var method = passedMethod || engine[methodName] || getMethods$1()[methodName];
|
|
@@ -66055,7 +66294,7 @@ var askEngine = (function () {
|
|
|
66055
66294
|
function executionQueue(engine, directives, rollbackOnError) {
|
|
66056
66295
|
var e_1, _a;
|
|
66057
66296
|
if (!Array.isArray(directives))
|
|
66058
|
-
return { error: INVALID_VALUES };
|
|
66297
|
+
return { error: INVALID_VALUES, message: 'directives must be an array' };
|
|
66059
66298
|
var methods = getMethods();
|
|
66060
66299
|
var start = Date.now();
|
|
66061
66300
|
var snapshot = rollbackOnError && makeDeepCopy(getTournamentRecords(), false, true);
|
|
@@ -66064,7 +66303,7 @@ function executionQueue(engine, directives, rollbackOnError) {
|
|
|
66064
66303
|
for (var directives_1 = __values(directives), directives_1_1 = directives_1.next(); !directives_1_1.done; directives_1_1 = directives_1.next()) {
|
|
66065
66304
|
var directive = directives_1_1.value;
|
|
66066
66305
|
if (typeof directive !== 'object')
|
|
66067
|
-
return { error: INVALID_VALUES };
|
|
66306
|
+
return { error: INVALID_VALUES, message: 'directive must be an object' };
|
|
66068
66307
|
var methodName = directive.method, params = directive.params;
|
|
66069
66308
|
if (!methods[methodName])
|
|
66070
66309
|
return logMethodNotFound({ methodName: methodName, start: start, params: params });
|
|
@@ -66095,15 +66334,18 @@ function executionQueue(engine, directives, rollbackOnError) {
|
|
|
66095
66334
|
function engineInvoke(engine, args) {
|
|
66096
66335
|
var _a;
|
|
66097
66336
|
if (!isObject(args))
|
|
66098
|
-
return { error: INVALID_VALUES };
|
|
66337
|
+
return { error: INVALID_VALUES, message: 'args must be an object' };
|
|
66099
66338
|
var methodsCount = Object.values(args).filter(isFunction).length;
|
|
66100
66339
|
if (methodsCount > 1)
|
|
66101
|
-
return {
|
|
66340
|
+
return {
|
|
66341
|
+
message: 'there must be only one arg with typeof function',
|
|
66342
|
+
error: INVALID_VALUES,
|
|
66343
|
+
};
|
|
66102
66344
|
var methodName = methodsCount
|
|
66103
66345
|
? Object.keys(args).find(function (key) { return isFunction(args[key]); })
|
|
66104
66346
|
: isString(args.method) && args.method;
|
|
66105
66347
|
if (!methodName)
|
|
66106
|
-
return { error:
|
|
66348
|
+
return { error: METHOD_NOT_FOUND };
|
|
66107
66349
|
var _b = args, _c = methodName, passedMethod = _b[_c], remainingArgs = __rest(_b, [typeof _c === "symbol" ? _c : _c + ""]);
|
|
66108
66350
|
var params = (args === null || args === void 0 ? void 0 : args.params) || __assign({}, remainingArgs);
|
|
66109
66351
|
var snapshot = params.rollbackOnError && makeDeepCopy(getTournamentRecords(), false, true);
|
|
@@ -67432,17 +67674,17 @@ var factoryConstants = {
|
|
|
67432
67674
|
exports.askEngine = askEngine;
|
|
67433
67675
|
exports.asyncEngine = asyncEngine;
|
|
67434
67676
|
exports.competitionEngine = competitionEngine;
|
|
67435
|
-
exports.deleteNotices = deleteNotices;
|
|
67436
67677
|
exports.drawDefinitionConstants = drawDefinitionConstants;
|
|
67437
67678
|
exports.entryStatusConstants = entryStatusConstants;
|
|
67438
67679
|
exports.errorConditionConstants = errorConditionConstants;
|
|
67439
67680
|
exports.eventConstants = eventConstants;
|
|
67440
67681
|
exports.factoryConstants = factoryConstants;
|
|
67682
|
+
exports.factoryTypes = factoryTypes;
|
|
67441
67683
|
exports.fixtures = fixtures;
|
|
67442
67684
|
exports.flightConstants = flightConstants;
|
|
67443
67685
|
exports.forge = forge;
|
|
67444
67686
|
exports.genderConstants = genderConstants;
|
|
67445
|
-
exports.
|
|
67687
|
+
exports.globalState = globalState$1;
|
|
67446
67688
|
exports.governors = governors;
|
|
67447
67689
|
exports.keyValueConstants = keyValueConstants;
|
|
67448
67690
|
exports.matchUpActionConstants = matchUpActionConstants;
|
|
@@ -67461,11 +67703,6 @@ exports.resultConstants = resultConstants;
|
|
|
67461
67703
|
exports.scaleConstants = scaleConstants;
|
|
67462
67704
|
exports.scaleEngine = scaleEngine;
|
|
67463
67705
|
exports.scoreGovernor = scoreGovernor;
|
|
67464
|
-
exports.setDeepCopy = setDeepCopy;
|
|
67465
|
-
exports.setDevContext = setDevContext;
|
|
67466
|
-
exports.setGlobalLog = setGlobalLog;
|
|
67467
|
-
exports.setStateProvider = setStateProvider;
|
|
67468
|
-
exports.setSubscriptions = setSubscriptions;
|
|
67469
67706
|
exports.surfaceConstants = surfaceConstants;
|
|
67470
67707
|
exports.syncEngine = engine;
|
|
67471
67708
|
exports.timeItemConstants = timeItemConstants;
|