tods-competition-factory 1.8.6 → 1.8.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/forge/generate.d.ts +10 -0
- package/dist/forge/generate.mjs +10 -1
- package/dist/forge/generate.mjs.map +1 -1
- package/dist/forge/query.d.ts +65 -52
- package/dist/forge/query.mjs +802 -779
- package/dist/forge/query.mjs.map +1 -1
- package/dist/forge/transform.d.ts +10 -0
- package/dist/forge/transform.mjs +9 -0
- package/dist/forge/transform.mjs.map +1 -1
- package/dist/forge/utilities.mjs.map +1 -1
- package/dist/index.mjs +434 -335
- package/dist/index.mjs.map +1 -1
- package/dist/tods-competition-factory.development.cjs.js +428 -316
- package/dist/tods-competition-factory.development.cjs.js.map +1 -1
- package/dist/tods-competition-factory.production.cjs.min.js +1 -1
- package/dist/tods-competition-factory.production.cjs.min.js.map +1 -1
- package/package.json +2 -2
|
@@ -1217,6 +1217,10 @@ var INVALID_OBJECT = {
|
|
|
1217
1217
|
message: 'Invalid object',
|
|
1218
1218
|
code: 'ERR_INVALID_OBJECT',
|
|
1219
1219
|
};
|
|
1220
|
+
var INVALID_GENDER = {
|
|
1221
|
+
message: 'Invalid gender',
|
|
1222
|
+
code: 'ERR_INVALID_GENDER',
|
|
1223
|
+
};
|
|
1220
1224
|
var INVALID_CATEGORY = {
|
|
1221
1225
|
message: 'Invalid category',
|
|
1222
1226
|
code: 'ERR_INVALID_CATEGORY',
|
|
@@ -1334,6 +1338,7 @@ var errorConditionConstants = {
|
|
|
1334
1338
|
INVALID_ENTRIES: INVALID_ENTRIES,
|
|
1335
1339
|
INVALID_EVENT_TYPE: INVALID_EVENT_TYPE,
|
|
1336
1340
|
INVALID_GAME_SCORES: INVALID_GAME_SCORES,
|
|
1341
|
+
INVALID_GENDER: INVALID_GENDER,
|
|
1337
1342
|
INVALID_MATCHUP_FORMAT: INVALID_MATCHUP_FORMAT,
|
|
1338
1343
|
INVALID_MATCHUP_STATUS: INVALID_MATCHUP_STATUS,
|
|
1339
1344
|
INVALID_MATCHUP_STATUS_BYE: INVALID_MATCHUP_STATUS_BYE,
|
|
@@ -2898,7 +2903,7 @@ var matchUpFormatCode = {
|
|
|
2898
2903
|
};
|
|
2899
2904
|
|
|
2900
2905
|
function factoryVersion() {
|
|
2901
|
-
return '1.8.
|
|
2906
|
+
return '1.8.8';
|
|
2902
2907
|
}
|
|
2903
2908
|
|
|
2904
2909
|
function getObjectTieFormat(obj) {
|
|
@@ -3922,6 +3927,11 @@ function validateCollectionDefinition(_a) {
|
|
|
3922
3927
|
[GenderEnum.Male, GenderEnum.Female].includes(referenceGender) &&
|
|
3923
3928
|
referenceGender !== gender) {
|
|
3924
3929
|
errors.push("Invalid gender: ".concat(gender));
|
|
3930
|
+
return decorateResult({
|
|
3931
|
+
context: { referenceGender: referenceGender, gender: gender },
|
|
3932
|
+
result: { error: INVALID_GENDER },
|
|
3933
|
+
stack: stack,
|
|
3934
|
+
});
|
|
3925
3935
|
}
|
|
3926
3936
|
if (checkCategory && referenceCategory && category) {
|
|
3927
3937
|
var result = categoryCanContain({
|
|
@@ -38133,283 +38143,6 @@ function getMatchUpDailyLimitsUpdate$1(_a) {
|
|
|
38133
38143
|
});
|
|
38134
38144
|
}
|
|
38135
38145
|
|
|
38136
|
-
var stageOrder = drawDefinitionConstants.stageOrder;
|
|
38137
|
-
function getProfileRounds(_a) {
|
|
38138
|
-
var _b;
|
|
38139
|
-
var tournamentRecords = _a.tournamentRecords, schedulingProfile = _a.schedulingProfile, tournamentRecord = _a.tournamentRecord, withRoundId = _a.withRoundId;
|
|
38140
|
-
if (tournamentRecord && !tournamentRecords) {
|
|
38141
|
-
if (typeof tournamentRecord !== 'object') {
|
|
38142
|
-
return { error: INVALID_TOURNAMENT_RECORD };
|
|
38143
|
-
}
|
|
38144
|
-
else {
|
|
38145
|
-
tournamentRecords = (_b = {}, _b[tournamentRecord.tournamentId] = tournamentRecord, _b);
|
|
38146
|
-
}
|
|
38147
|
-
}
|
|
38148
|
-
if (schedulingProfile) {
|
|
38149
|
-
var profileValidity = validateSchedulingProfile({
|
|
38150
|
-
tournamentRecords: tournamentRecords,
|
|
38151
|
-
schedulingProfile: schedulingProfile,
|
|
38152
|
-
});
|
|
38153
|
-
if (profileValidity.error)
|
|
38154
|
-
return profileValidity;
|
|
38155
|
-
}
|
|
38156
|
-
if (!schedulingProfile && tournamentRecords) {
|
|
38157
|
-
var result = getSchedulingProfile$1({ tournamentRecords: tournamentRecords });
|
|
38158
|
-
if (result.error)
|
|
38159
|
-
return result;
|
|
38160
|
-
schedulingProfile = result.schedulingProfile;
|
|
38161
|
-
}
|
|
38162
|
-
if (!schedulingProfile)
|
|
38163
|
-
return { error: NOT_FOUND };
|
|
38164
|
-
var segmentedRounds = {};
|
|
38165
|
-
var profileRounds = schedulingProfile
|
|
38166
|
-
.map(function (_a) {
|
|
38167
|
-
var venues = _a.venues, scheduleDate = _a.scheduleDate;
|
|
38168
|
-
return venues.map(function (_a) {
|
|
38169
|
-
var rounds = _a.rounds;
|
|
38170
|
-
return rounds.map(function (round) {
|
|
38171
|
-
var _a;
|
|
38172
|
-
var roundRef = getRoundId(round);
|
|
38173
|
-
if ((_a = roundRef.roundSegment) === null || _a === void 0 ? void 0 : _a.segmentsCount) {
|
|
38174
|
-
segmentedRounds[roundRef.id] = roundRef.roundSegment.segmentsCount;
|
|
38175
|
-
}
|
|
38176
|
-
return definedAttributes(__assign({ id: withRoundId ? roundRef.id : undefined, scheduleDate: scheduleDate }, roundRef));
|
|
38177
|
-
});
|
|
38178
|
-
});
|
|
38179
|
-
})
|
|
38180
|
-
.flat(Infinity);
|
|
38181
|
-
return { profileRounds: profileRounds, segmentedRounds: segmentedRounds };
|
|
38182
|
-
}
|
|
38183
|
-
function getRoundId(obj) {
|
|
38184
|
-
var containerStructureId = obj.containerStructureId, roundSegment = obj.roundSegment, isRoundRobin = obj.isRoundRobin, tournamentId = obj.tournamentId, roundNumber = obj.roundNumber, structureId = obj.structureId, eventId = obj.eventId, drawId = obj.drawId;
|
|
38185
|
-
var relevantStructureId = isRoundRobin ? containerStructureId : structureId;
|
|
38186
|
-
// retain order
|
|
38187
|
-
var id = [
|
|
38188
|
-
tournamentId,
|
|
38189
|
-
eventId,
|
|
38190
|
-
drawId,
|
|
38191
|
-
relevantStructureId,
|
|
38192
|
-
roundNumber, // 5
|
|
38193
|
-
].join('|');
|
|
38194
|
-
return definedAttributes({
|
|
38195
|
-
id: id,
|
|
38196
|
-
roundSegment: roundSegment,
|
|
38197
|
-
tournamentId: tournamentId,
|
|
38198
|
-
eventId: eventId,
|
|
38199
|
-
drawId: drawId,
|
|
38200
|
-
structureId: relevantStructureId,
|
|
38201
|
-
roundNumber: roundNumber,
|
|
38202
|
-
});
|
|
38203
|
-
}
|
|
38204
|
-
function getRoundProfile(matchUps) {
|
|
38205
|
-
var matchUpsCount = matchUps.length;
|
|
38206
|
-
var byeCount = matchUps.filter(function (_a) {
|
|
38207
|
-
var sides = _a.sides;
|
|
38208
|
-
return sides === null || sides === void 0 ? void 0 : sides.some(function (_a) {
|
|
38209
|
-
var bye = _a.bye;
|
|
38210
|
-
return bye;
|
|
38211
|
-
});
|
|
38212
|
-
}).length || 0;
|
|
38213
|
-
var completedCount = matchUps.filter(function (_a) {
|
|
38214
|
-
var winningSide = _a.winningSide, matchUpStatus = _a.matchUpStatus;
|
|
38215
|
-
return winningSide || completedMatchUpStatuses.includes(matchUpStatus);
|
|
38216
|
-
}).length || 0;
|
|
38217
|
-
var scheduledCount = matchUps.filter(function (_a) {
|
|
38218
|
-
var schedule = _a.schedule;
|
|
38219
|
-
return (schedule === null || schedule === void 0 ? void 0 : schedule.scheduledDate) && (schedule === null || schedule === void 0 ? void 0 : schedule.scheduledTime);
|
|
38220
|
-
}).length || 0;
|
|
38221
|
-
var consideredCount = matchUpsCount - byeCount;
|
|
38222
|
-
var isComplete = consideredCount === completedCount;
|
|
38223
|
-
var unscheduledCount = consideredCount - scheduledCount;
|
|
38224
|
-
var incompleteCount = consideredCount - scheduledCount;
|
|
38225
|
-
var isScheduled = consideredCount === scheduledCount;
|
|
38226
|
-
return {
|
|
38227
|
-
unscheduledCount: unscheduledCount,
|
|
38228
|
-
incompleteCount: incompleteCount,
|
|
38229
|
-
scheduledCount: scheduledCount,
|
|
38230
|
-
completedCount: completedCount,
|
|
38231
|
-
matchUpsCount: matchUpsCount,
|
|
38232
|
-
isScheduled: isScheduled,
|
|
38233
|
-
isComplete: isComplete,
|
|
38234
|
-
byeCount: byeCount,
|
|
38235
|
-
};
|
|
38236
|
-
}
|
|
38237
|
-
function getRounds(_a) {
|
|
38238
|
-
var _b;
|
|
38239
|
-
var _c;
|
|
38240
|
-
var excludeScheduleDateProfileRounds = _a.excludeScheduleDateProfileRounds, excludeScheduledRounds = _a.excludeScheduledRounds, excludeCompletedRounds = _a.excludeCompletedRounds, inContextMatchUps = _a.inContextMatchUps, tournamentRecords = _a.tournamentRecords, schedulingProfile = _a.schedulingProfile, tournamentRecord = _a.tournamentRecord, withSplitRounds = _a.withSplitRounds, matchUpFilters = _a.matchUpFilters, withRoundId = _a.withRoundId, context = _a.context;
|
|
38241
|
-
if (inContextMatchUps &&
|
|
38242
|
-
!Array.isArray(inContextMatchUps || typeof inContextMatchUps[0] !== 'object')) {
|
|
38243
|
-
return { error: INVALID_VALUES, inContextMatchUps: inContextMatchUps };
|
|
38244
|
-
}
|
|
38245
|
-
if (tournamentRecord && !tournamentRecords) {
|
|
38246
|
-
if (typeof tournamentRecord !== 'object') {
|
|
38247
|
-
return { error: INVALID_TOURNAMENT_RECORD };
|
|
38248
|
-
}
|
|
38249
|
-
else {
|
|
38250
|
-
tournamentRecords = (_b = {}, _b[tournamentRecord.tournamentId] = tournamentRecord, _b);
|
|
38251
|
-
}
|
|
38252
|
-
}
|
|
38253
|
-
var noTournamentRecords = typeof tournamentRecords !== 'object' ||
|
|
38254
|
-
!Object.keys(tournamentRecords).length;
|
|
38255
|
-
var needsTournamentRecords = !inContextMatchUps ||
|
|
38256
|
-
(!schedulingProfile &&
|
|
38257
|
-
(excludeScheduleDateProfileRounds ||
|
|
38258
|
-
excludeCompletedRounds ||
|
|
38259
|
-
schedulingProfile ||
|
|
38260
|
-
withSplitRounds));
|
|
38261
|
-
if (needsTournamentRecords && noTournamentRecords)
|
|
38262
|
-
return { error: MISSING_TOURNAMENT_RECORDS };
|
|
38263
|
-
var events = Object.values(tournamentRecords !== null && tournamentRecords !== void 0 ? tournamentRecords : {})
|
|
38264
|
-
.map(function (_a) {
|
|
38265
|
-
var events = _a.events;
|
|
38266
|
-
return events;
|
|
38267
|
-
})
|
|
38268
|
-
.flat();
|
|
38269
|
-
var _d = (tournamentRecords &&
|
|
38270
|
-
(excludeScheduleDateProfileRounds ||
|
|
38271
|
-
excludeCompletedRounds ||
|
|
38272
|
-
schedulingProfile ||
|
|
38273
|
-
withSplitRounds) &&
|
|
38274
|
-
getProfileRounds({ tournamentRecords: tournamentRecords, schedulingProfile: schedulingProfile })) ||
|
|
38275
|
-
{}, segmentedRounds = _d.segmentedRounds, profileRounds = _d.profileRounds;
|
|
38276
|
-
var profileRoundsMap = excludeScheduleDateProfileRounds && Object.assign.apply(Object, __spreadArray([{}], __read(profileRounds.map(function (profile) {
|
|
38277
|
-
var _a;
|
|
38278
|
-
return (_a = {}, _a[profile.id] = profile, _a);
|
|
38279
|
-
})), false));
|
|
38280
|
-
var consideredMatchUps = inContextMatchUps ||
|
|
38281
|
-
(tournamentRecords &&
|
|
38282
|
-
((_c = allCompetitionMatchUps({ tournamentRecords: tournamentRecords, matchUpFilters: matchUpFilters })) === null || _c === void 0 ? void 0 : _c.matchUps)) ||
|
|
38283
|
-
[];
|
|
38284
|
-
var excludedRounds = [];
|
|
38285
|
-
var rounds = (consideredMatchUps &&
|
|
38286
|
-
Object.values(consideredMatchUps.reduce(function (rounds, matchUp) {
|
|
38287
|
-
var _a;
|
|
38288
|
-
var _b, _c;
|
|
38289
|
-
var id = getRoundId(matchUp).id;
|
|
38290
|
-
var segmentsCount = segmentedRounds === null || segmentedRounds === void 0 ? void 0 : segmentedRounds[id];
|
|
38291
|
-
var matchUps = __spreadArray(__spreadArray([], __read(((_c = (_b = rounds[id]) === null || _b === void 0 ? void 0 : _b.matchUps) !== null && _c !== void 0 ? _c : [])), false), [matchUp], false);
|
|
38292
|
-
var containerStructureId = matchUp.containerStructureId, stageSequence = matchUp.stageSequence, structureName = matchUp.structureName, tournamentId = matchUp.tournamentId, isRoundRobin = matchUp.isRoundRobin, matchUpType = matchUp.matchUpType, roundNumber = matchUp.roundNumber, roundOffset = matchUp.roundOffset, structureId = matchUp.structureId, eventName = matchUp.eventName, roundName = matchUp.roundName, drawName = matchUp.drawName, eventId = matchUp.eventId, drawId = matchUp.drawId;
|
|
38293
|
-
var relevantStructureId = isRoundRobin
|
|
38294
|
-
? containerStructureId
|
|
38295
|
-
: structureId;
|
|
38296
|
-
return __assign(__assign({}, rounds), (_a = {}, _a[id] = {
|
|
38297
|
-
id: withRoundId ? id : undefined,
|
|
38298
|
-
structureId: relevantStructureId,
|
|
38299
|
-
stageSequence: stageSequence,
|
|
38300
|
-
segmentsCount: segmentsCount,
|
|
38301
|
-
structureName: structureName,
|
|
38302
|
-
tournamentId: tournamentId,
|
|
38303
|
-
matchUpType: matchUpType,
|
|
38304
|
-
roundNumber: roundNumber,
|
|
38305
|
-
roundOffset: roundOffset,
|
|
38306
|
-
eventName: eventName,
|
|
38307
|
-
roundName: roundName,
|
|
38308
|
-
drawName: drawName,
|
|
38309
|
-
matchUps: matchUps,
|
|
38310
|
-
eventId: eventId,
|
|
38311
|
-
drawId: drawId,
|
|
38312
|
-
}, _a));
|
|
38313
|
-
}, {}))
|
|
38314
|
-
.map(function (round) {
|
|
38315
|
-
var _a = getFinishingPositionDetails(round.matchUps), minFinishingSum = _a.minFinishingSum, winnerFinishingPositionRange = _a.winnerFinishingPositionRange;
|
|
38316
|
-
var segmentsCount = round.segmentsCount;
|
|
38317
|
-
if (segmentsCount) {
|
|
38318
|
-
var chunkSize = round.matchUps.length / segmentsCount;
|
|
38319
|
-
var sortedMatchUps = chunkArray(round.matchUps.sort(function (a, b) { return a.roundPosition - b.roundPosition; }), chunkSize);
|
|
38320
|
-
return sortedMatchUps.map(function (matchUps, i) {
|
|
38321
|
-
var _a = getRoundProfile(matchUps), unscheduledCount = _a.unscheduledCount, incompleteCount = _a.incompleteCount, matchUpsCount = _a.matchUpsCount, isScheduled = _a.isScheduled, isComplete = _a.isComplete, byeCount = _a.byeCount;
|
|
38322
|
-
var roundTiming = getRoundTiming({
|
|
38323
|
-
matchUps: round.matchUps,
|
|
38324
|
-
tournamentRecords: tournamentRecords,
|
|
38325
|
-
events: events,
|
|
38326
|
-
round: round,
|
|
38327
|
-
});
|
|
38328
|
-
return definedAttributes(__assign(__assign(__assign({}, round), context), { roundSegment: { segmentsCount: segmentsCount, segmentNumber: i + 1 }, winnerFinishingPositionRange: winnerFinishingPositionRange, unscheduledCount: unscheduledCount, incompleteCount: incompleteCount, minFinishingSum: minFinishingSum, matchUpsCount: matchUpsCount, isScheduled: isScheduled, roundTiming: roundTiming, isComplete: isComplete, byeCount: byeCount, matchUps: matchUps }));
|
|
38329
|
-
});
|
|
38330
|
-
}
|
|
38331
|
-
var _b = getRoundProfile(round.matchUps), unscheduledCount = _b.unscheduledCount, incompleteCount = _b.incompleteCount, matchUpsCount = _b.matchUpsCount, isScheduled = _b.isScheduled, isComplete = _b.isComplete, byeCount = _b.byeCount;
|
|
38332
|
-
var roundTiming = getRoundTiming({
|
|
38333
|
-
matchUps: round.matchUps,
|
|
38334
|
-
tournamentRecords: tournamentRecords,
|
|
38335
|
-
events: events,
|
|
38336
|
-
round: round,
|
|
38337
|
-
});
|
|
38338
|
-
return definedAttributes(__assign(__assign(__assign({}, round), context), { winnerFinishingPositionRange: winnerFinishingPositionRange, unscheduledCount: unscheduledCount, incompleteCount: incompleteCount, minFinishingSum: minFinishingSum, matchUpsCount: matchUpsCount, isScheduled: isScheduled, roundTiming: roundTiming, isComplete: isComplete, byeCount: byeCount }));
|
|
38339
|
-
})
|
|
38340
|
-
.flat()
|
|
38341
|
-
.filter(function (round) {
|
|
38342
|
-
if (excludeScheduleDateProfileRounds) {
|
|
38343
|
-
var scheduleDate = extractDate(excludeScheduleDateProfileRounds);
|
|
38344
|
-
var roundId = withRoundId ? round.id : getRoundId(round).id;
|
|
38345
|
-
if (scheduleDate &&
|
|
38346
|
-
profileRoundsMap[roundId] &&
|
|
38347
|
-
extractDate(profileRoundsMap[roundId].scheduleDate) ===
|
|
38348
|
-
scheduleDate) {
|
|
38349
|
-
return false;
|
|
38350
|
-
}
|
|
38351
|
-
}
|
|
38352
|
-
var isComplete = round.isComplete, isScheduled = round.isScheduled;
|
|
38353
|
-
var keepComplete = !excludeCompletedRounds || !isComplete;
|
|
38354
|
-
var keepScheduled = !excludeScheduledRounds || !isScheduled;
|
|
38355
|
-
var keepRound = keepComplete && keepScheduled;
|
|
38356
|
-
if (!keepRound)
|
|
38357
|
-
excludedRounds.push(round);
|
|
38358
|
-
return keepRound;
|
|
38359
|
-
})
|
|
38360
|
-
.sort(roundSort)) ||
|
|
38361
|
-
[];
|
|
38362
|
-
return __assign(__assign({}, SUCCESS), { rounds: rounds, excludedRounds: excludedRounds });
|
|
38363
|
-
}
|
|
38364
|
-
function getRoundTiming(_a) {
|
|
38365
|
-
var round = _a.round, matchUps = _a.matchUps, events = _a.events, tournamentRecords = _a.tournamentRecords;
|
|
38366
|
-
var event = events.find(function (event) { return event.eventId === round.eventId; });
|
|
38367
|
-
var _b = event || {}, eventType = _b.eventType, category = _b.category, categoryType = _b.categoryType;
|
|
38368
|
-
var _c = category || {}, categoryName = _c.categoryName, ageCategoryCode = _c.ageCategoryCode;
|
|
38369
|
-
var formatCounts = instanceCount(matchUps.map(function (_a) {
|
|
38370
|
-
var matchUpFormat = _a.matchUpFormat;
|
|
38371
|
-
return matchUpFormat;
|
|
38372
|
-
}));
|
|
38373
|
-
var roundMinutes = 0;
|
|
38374
|
-
Object.keys(formatCounts).forEach(function (matchUpFormat) {
|
|
38375
|
-
var formatCount = formatCounts[matchUpFormat];
|
|
38376
|
-
var result = findMatchUpFormatTiming({
|
|
38377
|
-
categoryName: categoryName || ageCategoryCode,
|
|
38378
|
-
tournamentId: round.tournamentId,
|
|
38379
|
-
eventId: round.eventId,
|
|
38380
|
-
tournamentRecords: tournamentRecords,
|
|
38381
|
-
matchUpFormat: matchUpFormat,
|
|
38382
|
-
categoryType: categoryType,
|
|
38383
|
-
eventType: eventType,
|
|
38384
|
-
});
|
|
38385
|
-
if (result.error)
|
|
38386
|
-
return result;
|
|
38387
|
-
var formatMinutes = result.averageMinutes * formatCount;
|
|
38388
|
-
if (!isNaN(roundMinutes))
|
|
38389
|
-
roundMinutes += formatMinutes;
|
|
38390
|
-
return undefined;
|
|
38391
|
-
});
|
|
38392
|
-
return { roundMinutes: roundMinutes };
|
|
38393
|
-
}
|
|
38394
|
-
// Sort rounds by order in which they will be played
|
|
38395
|
-
function roundSort(a, b) {
|
|
38396
|
-
return (a.eventName.localeCompare(b.eventName) ||
|
|
38397
|
-
a.eventId.localeCompare(b.eventId) ||
|
|
38398
|
-
(stageOrder[a === null || a === void 0 ? void 0 : a.stage] || 0) - (stageOrder[b === null || b === void 0 ? void 0 : b.stage] || 0) ||
|
|
38399
|
-
b.matchUpsCount - a.matchUpsCount ||
|
|
38400
|
-
"".concat(a.stageSequence, "-").concat(a.roundNumber, "-").concat(a.minFinishingSum).localeCompare("".concat(b.stageSequence, "-").concat(b.roundNumber, "-").concat(b.minFinishingSum)));
|
|
38401
|
-
}
|
|
38402
|
-
function getFinishingPositionDetails(matchUps) {
|
|
38403
|
-
return (matchUps || []).reduce(function (foo, matchUp) {
|
|
38404
|
-
var _a, _b;
|
|
38405
|
-
var sum = (((_a = matchUp.finishingPositionRange) === null || _a === void 0 ? void 0 : _a.winner) || []).reduce(function (a, b) { return a + b; }, 0);
|
|
38406
|
-
var winnerFinishingPositionRange = (((_b = matchUp.finishingPositionRange) === null || _b === void 0 ? void 0 : _b.winner) || []).join('-') || '';
|
|
38407
|
-
return !foo.minFinishingSum || sum < foo.minFinishingSum
|
|
38408
|
-
? { minFinishingSum: sum, winnerFinishingPositionRange: winnerFinishingPositionRange }
|
|
38409
|
-
: foo;
|
|
38410
|
-
}, { minFinishingSum: 0, winnerFinishingPositionRange: '' });
|
|
38411
|
-
}
|
|
38412
|
-
|
|
38413
38146
|
function bulkUpdateCourtAssignments(_a) {
|
|
38414
38147
|
var tournamentRecords = _a.tournamentRecords, courtAssignments = _a.courtAssignments, courtDayDate = _a.courtDayDate;
|
|
38415
38148
|
if (!tournamentRecords)
|
|
@@ -38855,6 +38588,148 @@ function reorderUpcomingMatchUps(params) {
|
|
|
38855
38588
|
}
|
|
38856
38589
|
}
|
|
38857
38590
|
|
|
38591
|
+
function getRoundId(obj) {
|
|
38592
|
+
var containerStructureId = obj.containerStructureId, roundSegment = obj.roundSegment, isRoundRobin = obj.isRoundRobin, tournamentId = obj.tournamentId, roundNumber = obj.roundNumber, structureId = obj.structureId, eventId = obj.eventId, drawId = obj.drawId;
|
|
38593
|
+
var relevantStructureId = isRoundRobin ? containerStructureId : structureId;
|
|
38594
|
+
// retain order
|
|
38595
|
+
var id = [
|
|
38596
|
+
tournamentId,
|
|
38597
|
+
eventId,
|
|
38598
|
+
drawId,
|
|
38599
|
+
relevantStructureId,
|
|
38600
|
+
roundNumber, // 5
|
|
38601
|
+
].join('|');
|
|
38602
|
+
return definedAttributes({
|
|
38603
|
+
structureId: relevantStructureId,
|
|
38604
|
+
roundSegment: roundSegment,
|
|
38605
|
+
tournamentId: tournamentId,
|
|
38606
|
+
roundNumber: roundNumber,
|
|
38607
|
+
eventId: eventId,
|
|
38608
|
+
drawId: drawId,
|
|
38609
|
+
id: id,
|
|
38610
|
+
});
|
|
38611
|
+
}
|
|
38612
|
+
function getRoundTiming(_a) {
|
|
38613
|
+
var round = _a.round, matchUps = _a.matchUps, events = _a.events, tournamentRecords = _a.tournamentRecords;
|
|
38614
|
+
var event = events.find(function (event) { return event.eventId === round.eventId; });
|
|
38615
|
+
var _b = event || {}, eventType = _b.eventType, category = _b.category, categoryType = _b.categoryType;
|
|
38616
|
+
var _c = category || {}, categoryName = _c.categoryName, ageCategoryCode = _c.ageCategoryCode;
|
|
38617
|
+
var formatCounts = instanceCount(matchUps.map(function (_a) {
|
|
38618
|
+
var matchUpFormat = _a.matchUpFormat;
|
|
38619
|
+
return matchUpFormat;
|
|
38620
|
+
}));
|
|
38621
|
+
var roundMinutes = 0;
|
|
38622
|
+
Object.keys(formatCounts).forEach(function (matchUpFormat) {
|
|
38623
|
+
var formatCount = formatCounts[matchUpFormat];
|
|
38624
|
+
var result = findMatchUpFormatTiming({
|
|
38625
|
+
categoryName: categoryName || ageCategoryCode,
|
|
38626
|
+
tournamentId: round.tournamentId,
|
|
38627
|
+
eventId: round.eventId,
|
|
38628
|
+
tournamentRecords: tournamentRecords,
|
|
38629
|
+
matchUpFormat: matchUpFormat,
|
|
38630
|
+
categoryType: categoryType,
|
|
38631
|
+
eventType: eventType,
|
|
38632
|
+
});
|
|
38633
|
+
if (result.error)
|
|
38634
|
+
return result;
|
|
38635
|
+
var formatMinutes = result.averageMinutes * formatCount;
|
|
38636
|
+
if (!isNaN(roundMinutes))
|
|
38637
|
+
roundMinutes += formatMinutes;
|
|
38638
|
+
return undefined;
|
|
38639
|
+
});
|
|
38640
|
+
return { roundMinutes: roundMinutes };
|
|
38641
|
+
}
|
|
38642
|
+
function getFinishingPositionDetails(matchUps) {
|
|
38643
|
+
return (matchUps || []).reduce(function (foo, matchUp) {
|
|
38644
|
+
var _a, _b;
|
|
38645
|
+
var sum = (((_a = matchUp.finishingPositionRange) === null || _a === void 0 ? void 0 : _a.winner) || []).reduce(function (a, b) { return a + b; }, 0);
|
|
38646
|
+
var winnerFinishingPositionRange = (((_b = matchUp.finishingPositionRange) === null || _b === void 0 ? void 0 : _b.winner) || []).join('-') || '';
|
|
38647
|
+
return !foo.minFinishingSum || sum < foo.minFinishingSum
|
|
38648
|
+
? { minFinishingSum: sum, winnerFinishingPositionRange: winnerFinishingPositionRange }
|
|
38649
|
+
: foo;
|
|
38650
|
+
}, { minFinishingSum: 0, winnerFinishingPositionRange: '' });
|
|
38651
|
+
}
|
|
38652
|
+
function getRoundProfile(matchUps) {
|
|
38653
|
+
var matchUpsCount = matchUps.length;
|
|
38654
|
+
var byeCount = matchUps.filter(function (_a) {
|
|
38655
|
+
var sides = _a.sides;
|
|
38656
|
+
return sides === null || sides === void 0 ? void 0 : sides.some(function (_a) {
|
|
38657
|
+
var bye = _a.bye;
|
|
38658
|
+
return bye;
|
|
38659
|
+
});
|
|
38660
|
+
}).length || 0;
|
|
38661
|
+
var completedCount = matchUps.filter(function (_a) {
|
|
38662
|
+
var winningSide = _a.winningSide, matchUpStatus = _a.matchUpStatus;
|
|
38663
|
+
return winningSide || completedMatchUpStatuses.includes(matchUpStatus);
|
|
38664
|
+
}).length || 0;
|
|
38665
|
+
var scheduledCount = matchUps.filter(function (_a) {
|
|
38666
|
+
var schedule = _a.schedule;
|
|
38667
|
+
return (schedule === null || schedule === void 0 ? void 0 : schedule.scheduledDate) && (schedule === null || schedule === void 0 ? void 0 : schedule.scheduledTime);
|
|
38668
|
+
}).length || 0;
|
|
38669
|
+
var consideredCount = matchUpsCount - byeCount;
|
|
38670
|
+
var isComplete = consideredCount === completedCount;
|
|
38671
|
+
var unscheduledCount = consideredCount - scheduledCount;
|
|
38672
|
+
var incompleteCount = consideredCount - scheduledCount;
|
|
38673
|
+
var isScheduled = consideredCount === scheduledCount;
|
|
38674
|
+
return {
|
|
38675
|
+
unscheduledCount: unscheduledCount,
|
|
38676
|
+
incompleteCount: incompleteCount,
|
|
38677
|
+
scheduledCount: scheduledCount,
|
|
38678
|
+
completedCount: completedCount,
|
|
38679
|
+
matchUpsCount: matchUpsCount,
|
|
38680
|
+
isScheduled: isScheduled,
|
|
38681
|
+
isComplete: isComplete,
|
|
38682
|
+
byeCount: byeCount,
|
|
38683
|
+
};
|
|
38684
|
+
}
|
|
38685
|
+
|
|
38686
|
+
function getProfileRounds(_a) {
|
|
38687
|
+
var _b;
|
|
38688
|
+
var tournamentRecords = _a.tournamentRecords, schedulingProfile = _a.schedulingProfile, tournamentRecord = _a.tournamentRecord, withRoundId = _a.withRoundId;
|
|
38689
|
+
if (tournamentRecord && !tournamentRecords) {
|
|
38690
|
+
if (typeof tournamentRecord !== 'object') {
|
|
38691
|
+
return { error: INVALID_TOURNAMENT_RECORD };
|
|
38692
|
+
}
|
|
38693
|
+
else {
|
|
38694
|
+
tournamentRecords = (_b = {}, _b[tournamentRecord.tournamentId] = tournamentRecord, _b);
|
|
38695
|
+
}
|
|
38696
|
+
}
|
|
38697
|
+
if (schedulingProfile) {
|
|
38698
|
+
var profileValidity = validateSchedulingProfile({
|
|
38699
|
+
tournamentRecords: tournamentRecords,
|
|
38700
|
+
schedulingProfile: schedulingProfile,
|
|
38701
|
+
});
|
|
38702
|
+
if (profileValidity.error)
|
|
38703
|
+
return profileValidity;
|
|
38704
|
+
}
|
|
38705
|
+
if (!schedulingProfile && tournamentRecords) {
|
|
38706
|
+
var result = getSchedulingProfile$1({ tournamentRecords: tournamentRecords });
|
|
38707
|
+
if (result.error)
|
|
38708
|
+
return result;
|
|
38709
|
+
schedulingProfile = result.schedulingProfile;
|
|
38710
|
+
}
|
|
38711
|
+
if (!schedulingProfile)
|
|
38712
|
+
return { error: NOT_FOUND };
|
|
38713
|
+
var segmentedRounds = {};
|
|
38714
|
+
var profileRounds = schedulingProfile
|
|
38715
|
+
.map(function (_a) {
|
|
38716
|
+
var venues = _a.venues, scheduleDate = _a.scheduleDate;
|
|
38717
|
+
return venues.map(function (_a) {
|
|
38718
|
+
var rounds = _a.rounds;
|
|
38719
|
+
return rounds.map(function (round) {
|
|
38720
|
+
var _a;
|
|
38721
|
+
var roundRef = getRoundId(round);
|
|
38722
|
+
if ((_a = roundRef.roundSegment) === null || _a === void 0 ? void 0 : _a.segmentsCount) {
|
|
38723
|
+
segmentedRounds[roundRef.id] = roundRef.roundSegment.segmentsCount;
|
|
38724
|
+
}
|
|
38725
|
+
return definedAttributes(__assign({ id: withRoundId ? roundRef.id : undefined, scheduleDate: scheduleDate }, roundRef));
|
|
38726
|
+
});
|
|
38727
|
+
});
|
|
38728
|
+
})
|
|
38729
|
+
.flat(Infinity);
|
|
38730
|
+
return { profileRounds: profileRounds, segmentedRounds: segmentedRounds };
|
|
38731
|
+
}
|
|
38732
|
+
|
|
38858
38733
|
function addMatchUpScheduleItems$1(params) {
|
|
38859
38734
|
return addMatchUpScheduleItems$2(params);
|
|
38860
38735
|
}
|
|
@@ -39495,6 +39370,171 @@ function matchUpScheduleChange(params) {
|
|
|
39495
39370
|
}
|
|
39496
39371
|
}
|
|
39497
39372
|
|
|
39373
|
+
var stageOrder = drawDefinitionConstants.stageOrder;
|
|
39374
|
+
// Sort rounds by order in which they will be played
|
|
39375
|
+
function roundSort(a, b) {
|
|
39376
|
+
return (a.eventName.localeCompare(b.eventName) ||
|
|
39377
|
+
a.eventId.localeCompare(b.eventId) ||
|
|
39378
|
+
(stageOrder[a === null || a === void 0 ? void 0 : a.stage] || 0) - (stageOrder[b === null || b === void 0 ? void 0 : b.stage] || 0) ||
|
|
39379
|
+
b.matchUpsCount - a.matchUpsCount ||
|
|
39380
|
+
"".concat(a.stageSequence, "-").concat(a.roundNumber, "-").concat(a.minFinishingSum).localeCompare("".concat(b.stageSequence, "-").concat(b.roundNumber, "-").concat(b.minFinishingSum)));
|
|
39381
|
+
}
|
|
39382
|
+
|
|
39383
|
+
function getRounds(_a) {
|
|
39384
|
+
var _b;
|
|
39385
|
+
var _c;
|
|
39386
|
+
var excludeScheduleDateProfileRounds = _a.excludeScheduleDateProfileRounds, excludeScheduledRounds = _a.excludeScheduledRounds, excludeCompletedRounds = _a.excludeCompletedRounds, inContextMatchUps = _a.inContextMatchUps, tournamentRecords = _a.tournamentRecords, schedulingProfile = _a.schedulingProfile, tournamentRecord = _a.tournamentRecord, withSplitRounds = _a.withSplitRounds, matchUpFilters = _a.matchUpFilters, scheduleDate = _a.scheduleDate, withRoundId = _a.withRoundId, venueId = _a.venueId, context = _a.context;
|
|
39387
|
+
if (inContextMatchUps &&
|
|
39388
|
+
!Array.isArray(inContextMatchUps || typeof inContextMatchUps[0] !== 'object')) {
|
|
39389
|
+
return { error: INVALID_VALUES, inContextMatchUps: inContextMatchUps };
|
|
39390
|
+
}
|
|
39391
|
+
if (tournamentRecord && !tournamentRecords) {
|
|
39392
|
+
if (typeof tournamentRecord !== 'object') {
|
|
39393
|
+
return { error: INVALID_TOURNAMENT_RECORD };
|
|
39394
|
+
}
|
|
39395
|
+
else {
|
|
39396
|
+
tournamentRecords = (_b = {}, _b[tournamentRecord.tournamentId] = tournamentRecord, _b);
|
|
39397
|
+
}
|
|
39398
|
+
}
|
|
39399
|
+
var noTournamentRecords = typeof tournamentRecords !== 'object' ||
|
|
39400
|
+
!Object.keys(tournamentRecords).length;
|
|
39401
|
+
var needsTournamentRecords = venueId ||
|
|
39402
|
+
scheduleDate ||
|
|
39403
|
+
!inContextMatchUps ||
|
|
39404
|
+
(!schedulingProfile &&
|
|
39405
|
+
(excludeScheduleDateProfileRounds ||
|
|
39406
|
+
excludeCompletedRounds ||
|
|
39407
|
+
schedulingProfile ||
|
|
39408
|
+
withSplitRounds));
|
|
39409
|
+
if (needsTournamentRecords && noTournamentRecords)
|
|
39410
|
+
return { error: MISSING_TOURNAMENT_RECORDS };
|
|
39411
|
+
var tournamentVenueIds = Object.assign.apply(Object, __spreadArray([{}], __read(Object.values(tournamentRecords !== null && tournamentRecords !== void 0 ? tournamentRecords : {}).map(function (_a) {
|
|
39412
|
+
var _b;
|
|
39413
|
+
var _c = _a.venues, venues = _c === void 0 ? [] : _c, tournamentId = _a.tournamentId;
|
|
39414
|
+
return (_b = {},
|
|
39415
|
+
_b[tournamentId] = venues === null || venues === void 0 ? void 0 : venues.map(function (_a) {
|
|
39416
|
+
var venueId = _a.venueId;
|
|
39417
|
+
return venueId;
|
|
39418
|
+
}),
|
|
39419
|
+
_b);
|
|
39420
|
+
})), false));
|
|
39421
|
+
var events = Object.values(tournamentRecords !== null && tournamentRecords !== void 0 ? tournamentRecords : {})
|
|
39422
|
+
.map(function (_a) {
|
|
39423
|
+
var _b = _a.events, events = _b === void 0 ? [] : _b, tournamentId = _a.tournamentId, startDate = _a.startDate, endDate = _a.endDate;
|
|
39424
|
+
return events.map(function (event) {
|
|
39425
|
+
var _a, _b;
|
|
39426
|
+
return (__assign(__assign({}, event), { validVenueIds: tournamentVenueIds[tournamentId], startDate: (_a = event.startDate) !== null && _a !== void 0 ? _a : startDate, endDate: (_b = event.endDate) !== null && _b !== void 0 ? _b : endDate }));
|
|
39427
|
+
});
|
|
39428
|
+
})
|
|
39429
|
+
.flat();
|
|
39430
|
+
var _d = (tournamentRecords &&
|
|
39431
|
+
(excludeScheduleDateProfileRounds ||
|
|
39432
|
+
excludeCompletedRounds ||
|
|
39433
|
+
schedulingProfile ||
|
|
39434
|
+
withSplitRounds) &&
|
|
39435
|
+
getProfileRounds({ tournamentRecords: tournamentRecords, schedulingProfile: schedulingProfile })) ||
|
|
39436
|
+
{}, segmentedRounds = _d.segmentedRounds, profileRounds = _d.profileRounds;
|
|
39437
|
+
var profileRoundsMap = excludeScheduleDateProfileRounds && Object.assign.apply(Object, __spreadArray([{}], __read(profileRounds.map(function (profile) {
|
|
39438
|
+
var _a;
|
|
39439
|
+
return (_a = {}, _a[profile.id] = profile, _a);
|
|
39440
|
+
})), false));
|
|
39441
|
+
var consideredMatchUps = inContextMatchUps ||
|
|
39442
|
+
(tournamentRecords &&
|
|
39443
|
+
((_c = allCompetitionMatchUps({ tournamentRecords: tournamentRecords, matchUpFilters: matchUpFilters })) === null || _c === void 0 ? void 0 : _c.matchUps)) ||
|
|
39444
|
+
[];
|
|
39445
|
+
var excludedRounds = [];
|
|
39446
|
+
var rounds = (consideredMatchUps &&
|
|
39447
|
+
Object.values(consideredMatchUps.reduce(function (rounds, matchUp) {
|
|
39448
|
+
var _a;
|
|
39449
|
+
var _b, _c;
|
|
39450
|
+
var id = getRoundId(matchUp).id;
|
|
39451
|
+
var segmentsCount = segmentedRounds === null || segmentedRounds === void 0 ? void 0 : segmentedRounds[id];
|
|
39452
|
+
var matchUps = __spreadArray(__spreadArray([], __read(((_c = (_b = rounds[id]) === null || _b === void 0 ? void 0 : _b.matchUps) !== null && _c !== void 0 ? _c : [])), false), [matchUp], false);
|
|
39453
|
+
var containerStructureId = matchUp.containerStructureId, stageSequence = matchUp.stageSequence, structureName = matchUp.structureName, tournamentId = matchUp.tournamentId, isRoundRobin = matchUp.isRoundRobin, matchUpType = matchUp.matchUpType, roundNumber = matchUp.roundNumber, roundOffset = matchUp.roundOffset, structureId = matchUp.structureId, eventName = matchUp.eventName, roundName = matchUp.roundName, drawName = matchUp.drawName, eventId = matchUp.eventId, drawId = matchUp.drawId;
|
|
39454
|
+
var relevantStructureId = isRoundRobin
|
|
39455
|
+
? containerStructureId
|
|
39456
|
+
: structureId;
|
|
39457
|
+
return __assign(__assign({}, rounds), (_a = {}, _a[id] = {
|
|
39458
|
+
id: withRoundId ? id : undefined,
|
|
39459
|
+
structureId: relevantStructureId,
|
|
39460
|
+
stageSequence: stageSequence,
|
|
39461
|
+
segmentsCount: segmentsCount,
|
|
39462
|
+
structureName: structureName,
|
|
39463
|
+
tournamentId: tournamentId,
|
|
39464
|
+
matchUpType: matchUpType,
|
|
39465
|
+
roundNumber: roundNumber,
|
|
39466
|
+
roundOffset: roundOffset,
|
|
39467
|
+
eventName: eventName,
|
|
39468
|
+
roundName: roundName,
|
|
39469
|
+
drawName: drawName,
|
|
39470
|
+
matchUps: matchUps,
|
|
39471
|
+
eventId: eventId,
|
|
39472
|
+
drawId: drawId,
|
|
39473
|
+
}, _a));
|
|
39474
|
+
}, {}))
|
|
39475
|
+
.map(function (round) {
|
|
39476
|
+
var _a = getFinishingPositionDetails(round.matchUps), minFinishingSum = _a.minFinishingSum, winnerFinishingPositionRange = _a.winnerFinishingPositionRange;
|
|
39477
|
+
var segmentsCount = round.segmentsCount;
|
|
39478
|
+
if (segmentsCount) {
|
|
39479
|
+
var chunkSize = round.matchUps.length / segmentsCount;
|
|
39480
|
+
var sortedMatchUps = chunkArray(round.matchUps.sort(function (a, b) { return a.roundPosition - b.roundPosition; }), chunkSize);
|
|
39481
|
+
return sortedMatchUps.map(function (matchUps, i) {
|
|
39482
|
+
var _a = getRoundProfile(matchUps), unscheduledCount = _a.unscheduledCount, incompleteCount = _a.incompleteCount, matchUpsCount = _a.matchUpsCount, isScheduled = _a.isScheduled, isComplete = _a.isComplete, byeCount = _a.byeCount;
|
|
39483
|
+
var roundTiming = getRoundTiming({
|
|
39484
|
+
matchUps: round.matchUps,
|
|
39485
|
+
tournamentRecords: tournamentRecords,
|
|
39486
|
+
events: events,
|
|
39487
|
+
round: round,
|
|
39488
|
+
});
|
|
39489
|
+
return definedAttributes(__assign(__assign(__assign({}, round), context), { roundSegment: { segmentsCount: segmentsCount, segmentNumber: i + 1 }, winnerFinishingPositionRange: winnerFinishingPositionRange, unscheduledCount: unscheduledCount, incompleteCount: incompleteCount, minFinishingSum: minFinishingSum, matchUpsCount: matchUpsCount, isScheduled: isScheduled, roundTiming: roundTiming, isComplete: isComplete, byeCount: byeCount, matchUps: matchUps }));
|
|
39490
|
+
});
|
|
39491
|
+
}
|
|
39492
|
+
var _b = getRoundProfile(round.matchUps), unscheduledCount = _b.unscheduledCount, incompleteCount = _b.incompleteCount, matchUpsCount = _b.matchUpsCount, isScheduled = _b.isScheduled, isComplete = _b.isComplete, byeCount = _b.byeCount;
|
|
39493
|
+
var roundTiming = getRoundTiming({
|
|
39494
|
+
matchUps: round.matchUps,
|
|
39495
|
+
tournamentRecords: tournamentRecords,
|
|
39496
|
+
events: events,
|
|
39497
|
+
round: round,
|
|
39498
|
+
});
|
|
39499
|
+
return definedAttributes(__assign(__assign(__assign({}, round), context), { winnerFinishingPositionRange: winnerFinishingPositionRange, unscheduledCount: unscheduledCount, incompleteCount: incompleteCount, minFinishingSum: minFinishingSum, matchUpsCount: matchUpsCount, isScheduled: isScheduled, roundTiming: roundTiming, isComplete: isComplete, byeCount: byeCount }));
|
|
39500
|
+
})
|
|
39501
|
+
.flat()
|
|
39502
|
+
.filter(function (round) {
|
|
39503
|
+
if (excludeScheduleDateProfileRounds) {
|
|
39504
|
+
var scheduleDate_1 = extractDate(excludeScheduleDateProfileRounds);
|
|
39505
|
+
var roundId = withRoundId ? round.id : getRoundId(round).id;
|
|
39506
|
+
if (scheduleDate_1 &&
|
|
39507
|
+
profileRoundsMap[roundId] &&
|
|
39508
|
+
extractDate(profileRoundsMap[roundId].scheduleDate) ===
|
|
39509
|
+
scheduleDate_1) {
|
|
39510
|
+
return false;
|
|
39511
|
+
}
|
|
39512
|
+
}
|
|
39513
|
+
var isComplete = round.isComplete, isScheduled = round.isScheduled;
|
|
39514
|
+
var keepComplete = !excludeCompletedRounds || !isComplete;
|
|
39515
|
+
var keepScheduled = !excludeScheduledRounds || !isScheduled;
|
|
39516
|
+
var event = venueId || scheduleDate
|
|
39517
|
+
? events === null || events === void 0 ? void 0 : events.find(function (_a) {
|
|
39518
|
+
var eventId = _a.eventId;
|
|
39519
|
+
return eventId === round.eventId;
|
|
39520
|
+
})
|
|
39521
|
+
: undefined;
|
|
39522
|
+
var validDate = !scheduleDate ||
|
|
39523
|
+
((event === null || event === void 0 ? void 0 : event.startDate) &&
|
|
39524
|
+
(event === null || event === void 0 ? void 0 : event.endDate) &&
|
|
39525
|
+
new Date(scheduleDate) >= new Date(event === null || event === void 0 ? void 0 : event.startDate) &&
|
|
39526
|
+
new Date(scheduleDate) <= new Date(event === null || event === void 0 ? void 0 : event.endDate));
|
|
39527
|
+
var validVenue = !venueId || (event === null || event === void 0 ? void 0 : event.validVenueIds.includes(venueId));
|
|
39528
|
+
var keepRound = keepComplete && keepScheduled && validVenue && validDate;
|
|
39529
|
+
if (!keepRound)
|
|
39530
|
+
excludedRounds.push(round);
|
|
39531
|
+
return keepRound;
|
|
39532
|
+
})
|
|
39533
|
+
.sort(roundSort)) ||
|
|
39534
|
+
[];
|
|
39535
|
+
return __assign(__assign({}, SUCCESS), { rounds: rounds, excludedRounds: excludedRounds });
|
|
39536
|
+
}
|
|
39537
|
+
|
|
39498
39538
|
function addMatchUpScheduleItems(params) {
|
|
39499
39539
|
var result = getDrawDefinition$1(params);
|
|
39500
39540
|
if (result.error)
|
|
@@ -42375,20 +42415,28 @@ var competitionEngine = (function () {
|
|
|
42375
42415
|
var elapsed = Date.now() - start;
|
|
42376
42416
|
var devContext = getDevContext();
|
|
42377
42417
|
var log = { method: methodName };
|
|
42378
|
-
var
|
|
42379
|
-
|
|
42418
|
+
var logError = result.error &&
|
|
42419
|
+
(devContext.errors === true ||
|
|
42420
|
+
(Array.isArray(devContext.errors) &&
|
|
42421
|
+
devContext.errors.includes(methodName)));
|
|
42422
|
+
var exclude = Array.isArray(devContext.exclude) &&
|
|
42423
|
+
devContext.exclude.includes(methodName);
|
|
42424
|
+
if (!exclude &&
|
|
42425
|
+
![undefined, false].includes(devContext.perf) &&
|
|
42380
42426
|
(isNaN(devContext.perf) || elapsed > devContext.perf))
|
|
42381
42427
|
log.elapsed = elapsed;
|
|
42382
|
-
if (
|
|
42383
|
-
(
|
|
42384
|
-
|
|
42385
|
-
((
|
|
42428
|
+
if (!exclude &&
|
|
42429
|
+
(logError ||
|
|
42430
|
+
(devContext.params && !Array.isArray(devContext.params)) ||
|
|
42431
|
+
(Array.isArray(devContext.params) &&
|
|
42432
|
+
((_a = devContext.params) === null || _a === void 0 ? void 0 : _a.includes(methodName))))) {
|
|
42386
42433
|
log.params = params;
|
|
42387
42434
|
}
|
|
42388
|
-
if (
|
|
42389
|
-
(
|
|
42390
|
-
|
|
42391
|
-
((
|
|
42435
|
+
if (!exclude &&
|
|
42436
|
+
(logError ||
|
|
42437
|
+
(devContext.result && !Array.isArray(devContext.result)) ||
|
|
42438
|
+
(Array.isArray(devContext.result) &&
|
|
42439
|
+
((_b = devContext.result) === null || _b === void 0 ? void 0 : _b.includes(methodName))))) {
|
|
42392
42440
|
log.result = result;
|
|
42393
42441
|
}
|
|
42394
42442
|
if (Object.keys(log).length > 1)
|
|
@@ -45790,7 +45838,7 @@ function getAvoidanceConflicts(_a) {
|
|
|
45790
45838
|
}
|
|
45791
45839
|
|
|
45792
45840
|
function getSwapOptions(_a) {
|
|
45793
|
-
var positionedParticipants = _a.positionedParticipants, potentialDrawPositions = _a.potentialDrawPositions,
|
|
45841
|
+
var positionedParticipants = _a.positionedParticipants, potentialDrawPositions = _a.potentialDrawPositions, drawPositionGroups = _a.drawPositionGroups, avoidanceConflicts = _a.avoidanceConflicts, isRoundRobin = _a.isRoundRobin;
|
|
45794
45842
|
return avoidanceConflicts
|
|
45795
45843
|
.map(function (conflict) {
|
|
45796
45844
|
var drawPositions = conflict.map(function (c) { return c.drawPosition; });
|
|
@@ -58273,28 +58321,84 @@ function setTournamentStatus(_a) {
|
|
|
58273
58321
|
return __assign({}, SUCCESS);
|
|
58274
58322
|
}
|
|
58275
58323
|
|
|
58276
|
-
// TODO: ability to add onlineResources to other items, e.g. organisations, participants, persons, venues, courts
|
|
58277
58324
|
function addOnlineResource(_a) {
|
|
58278
|
-
var
|
|
58325
|
+
var _b, _c, _d, _e, _f, _g;
|
|
58326
|
+
var tournamentRecord = _a.tournamentRecord, onlineResource = _a.onlineResource, organisationId = _a.organisationId, participantId = _a.participantId, personId = _a.personId, courtId = _a.courtId, venueId = _a.venueId;
|
|
58279
58327
|
if (!tournamentRecord)
|
|
58280
58328
|
return { error: MISSING_TOURNAMENT_RECORD };
|
|
58281
|
-
if (!onlineResource)
|
|
58329
|
+
if (!isObject(onlineResource))
|
|
58282
58330
|
return { error: MISSING_VALUE };
|
|
58283
|
-
if (
|
|
58284
|
-
|
|
58285
|
-
|
|
58286
|
-
|
|
58331
|
+
if (intersection(Object.keys(onlineResource), [
|
|
58332
|
+
'resourceSubType',
|
|
58333
|
+
'resourceType',
|
|
58334
|
+
'identifier',
|
|
58335
|
+
]).length !== 3)
|
|
58336
|
+
return decorateResult({
|
|
58337
|
+
result: { error: INVALID_OBJECT },
|
|
58338
|
+
context: { onlineResource: onlineResource },
|
|
58339
|
+
});
|
|
58340
|
+
if (organisationId) {
|
|
58341
|
+
if (((_b = tournamentRecord.parentOrganisation) === null || _b === void 0 ? void 0 : _b.parentOrganisationId) !==
|
|
58342
|
+
organisationId) {
|
|
58343
|
+
return decorateResult({ result: { error: NOT_FOUND } });
|
|
58344
|
+
}
|
|
58345
|
+
if (!tournamentRecord.parentOrganisation.onlineResources)
|
|
58346
|
+
tournamentRecord.parentOrganisation.onlineResources = [];
|
|
58347
|
+
tournamentRecord.parentOrganisation.onlineResources.push(onlineResource);
|
|
58348
|
+
}
|
|
58349
|
+
else if (participantId || personId) {
|
|
58350
|
+
var participant = ((_c = tournamentRecord.participants) !== null && _c !== void 0 ? _c : []).find(function (p) {
|
|
58351
|
+
var _a;
|
|
58352
|
+
return (personId && ((_a = p.person) === null || _a === void 0 ? void 0 : _a.personId) === personId) ||
|
|
58353
|
+
p.participantId === participantId;
|
|
58354
|
+
});
|
|
58355
|
+
if (!participant) {
|
|
58356
|
+
if (personId) {
|
|
58357
|
+
return decorateResult({ result: { error: NOT_FOUND } });
|
|
58358
|
+
}
|
|
58359
|
+
else {
|
|
58360
|
+
return decorateResult({ result: { error: PARTICIPANT_NOT_FOUND } });
|
|
58361
|
+
}
|
|
58362
|
+
}
|
|
58363
|
+
if (personId) {
|
|
58364
|
+
if (((_d = participant.person) === null || _d === void 0 ? void 0 : _d.personId) !== personId) {
|
|
58365
|
+
// both personId and participantId were provided and person does not match found participant
|
|
58366
|
+
return decorateResult({ result: { error: INVALID_PARTICIPANT } });
|
|
58367
|
+
}
|
|
58368
|
+
if (!participant.person.onlineResources)
|
|
58369
|
+
participant.person.onlineResources = [];
|
|
58370
|
+
participant.person.onlineResources.push(onlineResource);
|
|
58371
|
+
}
|
|
58372
|
+
else {
|
|
58373
|
+
if (!participant.onlineResources)
|
|
58374
|
+
participant.onlineResources = [];
|
|
58375
|
+
participant.onlineResources.push(onlineResource);
|
|
58376
|
+
}
|
|
58377
|
+
}
|
|
58378
|
+
else if (courtId) {
|
|
58379
|
+
var court = (_f = ((_e = tournamentRecord.venues) !== null && _e !== void 0 ? _e : [])
|
|
58380
|
+
.filter(function (v) { return !venueId || v.venueId === venueId; })
|
|
58381
|
+
.flatMap(function (v) { var _a; return ((_a = v.courts) !== null && _a !== void 0 ? _a : []).filter(function (c) { return c.courtId === courtId; }); })) === null || _f === void 0 ? void 0 : _f[0];
|
|
58382
|
+
if (!court)
|
|
58383
|
+
return decorateResult({ result: { error: COURT_NOT_FOUND } });
|
|
58384
|
+
if (!court.onlineResources)
|
|
58385
|
+
court.onlineResources = [];
|
|
58386
|
+
court.onlineResources.push(onlineResource);
|
|
58387
|
+
}
|
|
58388
|
+
else if (venueId) {
|
|
58389
|
+
var venue = ((_g = tournamentRecord.venues) !== null && _g !== void 0 ? _g : []).find(function (v) { return v.venueId === venueId; });
|
|
58390
|
+
if (!venue)
|
|
58391
|
+
return decorateResult({ result: { error: VENUE_NOT_FOUND } });
|
|
58392
|
+
if (!venue.onlineResources)
|
|
58393
|
+
venue.onlineResources = [];
|
|
58394
|
+
venue.onlineResources.push(onlineResource);
|
|
58395
|
+
}
|
|
58396
|
+
else {
|
|
58397
|
+
if (!tournamentRecord.onlineResources)
|
|
58398
|
+
tournamentRecord.onlineResources = [];
|
|
58399
|
+
tournamentRecord.onlineResources.push(onlineResource);
|
|
58400
|
+
}
|
|
58287
58401
|
return __assign({}, SUCCESS);
|
|
58288
|
-
/**
|
|
58289
|
-
[
|
|
58290
|
-
{
|
|
58291
|
-
identifier:
|
|
58292
|
-
resourceSubType: 'IMAGE',
|
|
58293
|
-
name: 'tournamentImage',
|
|
58294
|
-
resourceType: 'URL',
|
|
58295
|
-
},
|
|
58296
|
-
];
|
|
58297
|
-
*/
|
|
58298
58402
|
}
|
|
58299
58403
|
|
|
58300
58404
|
function analyzeDraws(_a) {
|
|
@@ -64997,20 +65101,28 @@ var tournamentEngine = (function () {
|
|
|
64997
65101
|
var elapsed = Date.now() - start;
|
|
64998
65102
|
var devContext = getDevContext();
|
|
64999
65103
|
var log = { method: methodName };
|
|
65000
|
-
var
|
|
65001
|
-
|
|
65104
|
+
var logError = result.error &&
|
|
65105
|
+
(devContext.errors === true ||
|
|
65106
|
+
(Array.isArray(devContext.errors) &&
|
|
65107
|
+
devContext.errors.includes(methodName)));
|
|
65108
|
+
var exclude = Array.isArray(devContext.exclude) &&
|
|
65109
|
+
devContext.exclude.includes(methodName);
|
|
65110
|
+
if (!exclude &&
|
|
65111
|
+
![undefined, false].includes(devContext.perf) &&
|
|
65002
65112
|
(isNaN(devContext.perf) || elapsed > devContext.perf))
|
|
65003
65113
|
log.elapsed = elapsed;
|
|
65004
|
-
if (
|
|
65005
|
-
(
|
|
65006
|
-
|
|
65007
|
-
((
|
|
65114
|
+
if (!exclude &&
|
|
65115
|
+
(logError ||
|
|
65116
|
+
(devContext.params && !Array.isArray(devContext.params)) ||
|
|
65117
|
+
(Array.isArray(devContext.params) &&
|
|
65118
|
+
((_a = devContext.params) === null || _a === void 0 ? void 0 : _a.includes(methodName))))) {
|
|
65008
65119
|
log.params = params;
|
|
65009
65120
|
}
|
|
65010
|
-
if (
|
|
65011
|
-
(
|
|
65012
|
-
|
|
65013
|
-
((
|
|
65121
|
+
if (!exclude &&
|
|
65122
|
+
(logError ||
|
|
65123
|
+
(devContext.result && !Array.isArray(devContext.result)) ||
|
|
65124
|
+
(Array.isArray(devContext.result) &&
|
|
65125
|
+
((_b = devContext.result) === null || _b === void 0 ? void 0 : _b.includes(methodName))))) {
|
|
65014
65126
|
log.result = result;
|
|
65015
65127
|
}
|
|
65016
65128
|
if (Object.keys(log).length > 1)
|