tods-competition-factory 2.0.21 → 2.0.22
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/index.mjs +6 -6
- package/dist/tods-competition-factory.d.ts +68 -77
- package/dist/tods-competition-factory.development.cjs.js +651 -606
- 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 +9 -9
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
function factoryVersion() {
|
|
6
|
-
return '2.0.
|
|
6
|
+
return '2.0.22';
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
const SUCCESS = { success: true };
|
|
@@ -2220,12 +2220,12 @@ const errors = {
|
|
|
2220
2220
|
[STRUCTURE]: MISSING_STRUCTURE,
|
|
2221
2221
|
[COURT_ID]: MISSING_COURT_ID,
|
|
2222
2222
|
[MATCHUPS]: MISSING_MATCHUPS,
|
|
2223
|
+
[EVENT_ID]: EVENT_NOT_FOUND,
|
|
2223
2224
|
[MATCHUP]: MISSING_MATCHUP,
|
|
2224
2225
|
[COURT_IDS]: MISSING_VALUE,
|
|
2225
2226
|
[VENUE_IDS]: MISSING_VALUE,
|
|
2226
2227
|
[DRAW_ID]: MISSING_DRAW_ID,
|
|
2227
|
-
[
|
|
2228
|
-
[EVENT]: EVENT_NOT_FOUND,
|
|
2228
|
+
[EVENT]: MISSING_EVENT,
|
|
2229
2229
|
};
|
|
2230
2230
|
const paramTypes = {
|
|
2231
2231
|
[TOURNAMENT_RECORDS]: OBJECT,
|
|
@@ -11466,7 +11466,7 @@ function getPublishState(params) {
|
|
|
11466
11466
|
};
|
|
11467
11467
|
}
|
|
11468
11468
|
else if (Array.isArray(drawIds) && drawIds?.length) {
|
|
11469
|
-
const eventDrawIds = event.drawDefinitions?.map(getDrawId)
|
|
11469
|
+
const eventDrawIds = event.drawDefinitions?.map(getDrawId) ?? [];
|
|
11470
11470
|
for (const drawId of drawIds) {
|
|
11471
11471
|
if (!isString(drawId))
|
|
11472
11472
|
return { error: INVALID_VALUES };
|
|
@@ -26787,8 +26787,8 @@ function getTournamentInfo(params) {
|
|
|
26787
26787
|
const publishState = getPublishState({ tournamentRecord })?.publishState;
|
|
26788
26788
|
const publishedEventIds = publishState?.tournament?.status?.publishedEventIds || [];
|
|
26789
26789
|
const eventInfo = [];
|
|
26790
|
-
for (const event of tournamentRecord.events
|
|
26791
|
-
if (publishedEventIds.includes(event.eventId)) {
|
|
26790
|
+
for (const event of tournamentRecord.events ?? []) {
|
|
26791
|
+
if (!params?.usePublishState || publishedEventIds.includes(event.eventId)) {
|
|
26792
26792
|
const info = extractEventInfo({ event }).eventInfo;
|
|
26793
26793
|
if (info)
|
|
26794
26794
|
eventInfo.push(info);
|
|
@@ -27168,6 +27168,573 @@ var query$8 = {
|
|
|
27168
27168
|
validateCollectionDefinition: validateCollectionDefinition
|
|
27169
27169
|
};
|
|
27170
27170
|
|
|
27171
|
+
function bulkUpdatePublishedEventIds({ tournamentRecord, outcomes }) {
|
|
27172
|
+
if (!tournamentRecord)
|
|
27173
|
+
return { error: MISSING_TOURNAMENT_RECORD };
|
|
27174
|
+
if (!outcomes?.length)
|
|
27175
|
+
return { error: MISSING_VALUE, info: 'Missing outcomes' };
|
|
27176
|
+
const eventIdsMap = outcomes.reduce((eventIdsMap, outcome) => {
|
|
27177
|
+
const { drawId, eventId } = outcome;
|
|
27178
|
+
if (eventId && drawId) {
|
|
27179
|
+
if (!eventIdsMap[eventId]) {
|
|
27180
|
+
eventIdsMap[eventId] = [drawId];
|
|
27181
|
+
}
|
|
27182
|
+
else if (!eventIdsMap[eventId].includes(drawId)) {
|
|
27183
|
+
eventIdsMap[eventId].push(drawId);
|
|
27184
|
+
}
|
|
27185
|
+
}
|
|
27186
|
+
return eventIdsMap;
|
|
27187
|
+
}, {});
|
|
27188
|
+
const relevantEventsIds = Object.keys(eventIdsMap);
|
|
27189
|
+
const relevantEvents = tournamentRecord.events?.filter((event) => relevantEventsIds.includes(event.eventId));
|
|
27190
|
+
const publishedEventIds = relevantEvents
|
|
27191
|
+
.filter((event) => {
|
|
27192
|
+
const pubStatus = getEventPublishStatus({ event });
|
|
27193
|
+
const { drawDetails, drawIds } = pubStatus ?? {};
|
|
27194
|
+
const { eventId } = event;
|
|
27195
|
+
const publishedDrawIds = eventIdsMap[eventId].filter((drawId) => {
|
|
27196
|
+
const keyedDrawIds = drawDetails
|
|
27197
|
+
? Object.keys(pubStatus.drawDetails).filter((drawId) => getDrawPublishStatus({ drawId, drawDetails }))
|
|
27198
|
+
: [];
|
|
27199
|
+
return drawIds?.includes(drawId) || keyedDrawIds.includes(drawId);
|
|
27200
|
+
});
|
|
27201
|
+
return publishedDrawIds.length;
|
|
27202
|
+
})
|
|
27203
|
+
.map((event) => event.eventId);
|
|
27204
|
+
return { publishedEventIds, eventIdPublishedDrawIdsMap: eventIdsMap };
|
|
27205
|
+
}
|
|
27206
|
+
|
|
27207
|
+
function getDisabledStatus({ dates = [], extension }) {
|
|
27208
|
+
if (!extension)
|
|
27209
|
+
return false;
|
|
27210
|
+
if (typeof extension.value === 'boolean' && extension.value)
|
|
27211
|
+
return true;
|
|
27212
|
+
if (!dates.length)
|
|
27213
|
+
return false;
|
|
27214
|
+
const disabledDates = isObject(extension.value) ? extension.value?.dates : undefined;
|
|
27215
|
+
if (Array.isArray(disabledDates)) {
|
|
27216
|
+
if (!disabledDates?.length)
|
|
27217
|
+
return false;
|
|
27218
|
+
const datesToConsider = disabledDates.filter((date) => !dates.length || dates.includes(date));
|
|
27219
|
+
return !!datesToConsider.length;
|
|
27220
|
+
}
|
|
27221
|
+
return undefined;
|
|
27222
|
+
}
|
|
27223
|
+
|
|
27224
|
+
function getInContextCourt({ convertExtensions, ignoreDisabled, venue, court }) {
|
|
27225
|
+
const inContextCourt = {
|
|
27226
|
+
...makeDeepCopy(court, convertExtensions, true),
|
|
27227
|
+
venueId: venue.venueId,
|
|
27228
|
+
};
|
|
27229
|
+
const { extension } = findExtension({
|
|
27230
|
+
name: DISABLED,
|
|
27231
|
+
element: court,
|
|
27232
|
+
});
|
|
27233
|
+
if (ignoreDisabled && extension) {
|
|
27234
|
+
const disabledDates = isObject(extension.value) ? extension.value?.dates : undefined;
|
|
27235
|
+
const dateAvailability = extension?.value === true
|
|
27236
|
+
? []
|
|
27237
|
+
: inContextCourt.dateAvailability
|
|
27238
|
+
.map((availability) => {
|
|
27239
|
+
const date = availability.date;
|
|
27240
|
+
if (!date || disabledDates.includes(date))
|
|
27241
|
+
return;
|
|
27242
|
+
return availability;
|
|
27243
|
+
})
|
|
27244
|
+
.filter(Boolean);
|
|
27245
|
+
inContextCourt.dateAvailability = dateAvailability;
|
|
27246
|
+
}
|
|
27247
|
+
return { inContextCourt };
|
|
27248
|
+
}
|
|
27249
|
+
|
|
27250
|
+
function getVenuesAndCourts(params) {
|
|
27251
|
+
const { convertExtensions, ignoreDisabled, venueIds = [], dates, } = params;
|
|
27252
|
+
const tournamentRecords = params.tournamentRecords ||
|
|
27253
|
+
(params.tournamentRecord && {
|
|
27254
|
+
[params.tournamentRecord.tournamentId]: params.tournamentRecord,
|
|
27255
|
+
}) ||
|
|
27256
|
+
{};
|
|
27257
|
+
const uniqueVenueIds = [];
|
|
27258
|
+
const uniqueCourtIds = [];
|
|
27259
|
+
const courts = [];
|
|
27260
|
+
const venues = [];
|
|
27261
|
+
const tournamentIds = Object.keys(tournamentRecords).filter((id) => !params.tournamentId || id === params.tournamentId);
|
|
27262
|
+
tournamentIds.forEach((tournamentId) => {
|
|
27263
|
+
const tournamentRecord = tournamentRecords[tournamentId];
|
|
27264
|
+
for (const venue of tournamentRecord.venues ?? []) {
|
|
27265
|
+
if (venueIds.length && !venueIds.includes(venue.venueId))
|
|
27266
|
+
continue;
|
|
27267
|
+
if (ignoreDisabled) {
|
|
27268
|
+
const { extension } = findExtension({
|
|
27269
|
+
name: DISABLED,
|
|
27270
|
+
element: venue,
|
|
27271
|
+
});
|
|
27272
|
+
if (extension?.value)
|
|
27273
|
+
continue;
|
|
27274
|
+
}
|
|
27275
|
+
if (!uniqueVenueIds.includes(venue.venueId)) {
|
|
27276
|
+
venues.push(makeDeepCopy(venue, convertExtensions, true));
|
|
27277
|
+
uniqueVenueIds.push(venue.venueId);
|
|
27278
|
+
}
|
|
27279
|
+
for (const court of venue.courts ?? []) {
|
|
27280
|
+
if (!uniqueCourtIds.includes(court.courtId)) {
|
|
27281
|
+
if (ignoreDisabled) {
|
|
27282
|
+
const { extension } = findExtension({
|
|
27283
|
+
name: DISABLED,
|
|
27284
|
+
element: court,
|
|
27285
|
+
});
|
|
27286
|
+
const isDisabled = getDisabledStatus({ extension, dates });
|
|
27287
|
+
if (isDisabled)
|
|
27288
|
+
continue;
|
|
27289
|
+
}
|
|
27290
|
+
const { inContextCourt } = getInContextCourt({
|
|
27291
|
+
convertExtensions,
|
|
27292
|
+
ignoreDisabled,
|
|
27293
|
+
venue,
|
|
27294
|
+
court,
|
|
27295
|
+
});
|
|
27296
|
+
courts.push(inContextCourt);
|
|
27297
|
+
uniqueCourtIds.push(court.courtId);
|
|
27298
|
+
}
|
|
27299
|
+
}
|
|
27300
|
+
}
|
|
27301
|
+
});
|
|
27302
|
+
return { courts, venues, ...SUCCESS };
|
|
27303
|
+
}
|
|
27304
|
+
function getTournamentVenuesAndCourts({ convertExtensions, tournamentRecord, ignoreDisabled, dates, }) {
|
|
27305
|
+
if (!tournamentRecord)
|
|
27306
|
+
return { error: MISSING_TOURNAMENT_RECORDS };
|
|
27307
|
+
const venues = makeDeepCopy(tournamentRecord.venues ?? [], convertExtensions)
|
|
27308
|
+
.filter((venue) => {
|
|
27309
|
+
if (!ignoreDisabled)
|
|
27310
|
+
return venue;
|
|
27311
|
+
const { extension } = findExtension({
|
|
27312
|
+
name: DISABLED,
|
|
27313
|
+
element: venue,
|
|
27314
|
+
});
|
|
27315
|
+
return !extension?.value && venue;
|
|
27316
|
+
})
|
|
27317
|
+
.filter(Boolean);
|
|
27318
|
+
const courts = venues.reduce((courts, venue) => {
|
|
27319
|
+
const additionalCourts = (venue?.courts || [])
|
|
27320
|
+
.filter((court) => {
|
|
27321
|
+
if (!ignoreDisabled && !dates?.length)
|
|
27322
|
+
return court;
|
|
27323
|
+
const { extension } = findExtension({
|
|
27324
|
+
name: DISABLED,
|
|
27325
|
+
element: court,
|
|
27326
|
+
});
|
|
27327
|
+
return getDisabledStatus({ extension, dates });
|
|
27328
|
+
})
|
|
27329
|
+
.filter(Boolean)
|
|
27330
|
+
.map((court) => {
|
|
27331
|
+
const { inContextCourt } = getInContextCourt({
|
|
27332
|
+
convertExtensions,
|
|
27333
|
+
ignoreDisabled,
|
|
27334
|
+
venue,
|
|
27335
|
+
court,
|
|
27336
|
+
});
|
|
27337
|
+
return inContextCourt;
|
|
27338
|
+
});
|
|
27339
|
+
return additionalCourts.length ? courts.concat(additionalCourts) : courts;
|
|
27340
|
+
}, []);
|
|
27341
|
+
return { venues, courts };
|
|
27342
|
+
}
|
|
27343
|
+
function getCompetitionVenues({ tournamentRecords, requireCourts, dates }) {
|
|
27344
|
+
if (typeof tournamentRecords !== 'object' || !Object.keys(tournamentRecords).length)
|
|
27345
|
+
return { error: MISSING_TOURNAMENT_RECORDS };
|
|
27346
|
+
const tournamentIds = Object.keys(tournamentRecords);
|
|
27347
|
+
return tournamentIds.reduce((accumulator, tournamentId) => {
|
|
27348
|
+
const tournamentRecord = tournamentRecords[tournamentId];
|
|
27349
|
+
const { venues } = getTournamentVenuesAndCourts({
|
|
27350
|
+
tournamentRecord,
|
|
27351
|
+
dates,
|
|
27352
|
+
});
|
|
27353
|
+
venues?.forEach((venue) => {
|
|
27354
|
+
const { venueId, courts } = venue;
|
|
27355
|
+
const includeVenue = !requireCourts || courts?.length;
|
|
27356
|
+
if (includeVenue && !accumulator.venueIds.includes(venueId)) {
|
|
27357
|
+
accumulator.venues.push(venue);
|
|
27358
|
+
accumulator.venueIds.push(venueId);
|
|
27359
|
+
}
|
|
27360
|
+
});
|
|
27361
|
+
return accumulator;
|
|
27362
|
+
}, { venues: [], venueIds: [] });
|
|
27363
|
+
}
|
|
27364
|
+
|
|
27365
|
+
function getAllEventData({ tournamentRecord, policyDefinitions }) {
|
|
27366
|
+
if (!tournamentRecord)
|
|
27367
|
+
return { error: MISSING_TOURNAMENT_RECORD };
|
|
27368
|
+
const events = tournamentRecord.events || [];
|
|
27369
|
+
const tournamentParticipants = tournamentRecord?.participants || [];
|
|
27370
|
+
const { tournamentInfo } = getTournamentInfo({ tournamentRecord });
|
|
27371
|
+
const { venues: venuesData } = getVenuesAndCourts({
|
|
27372
|
+
tournamentRecord,
|
|
27373
|
+
});
|
|
27374
|
+
const eventsData = events.map((event) => {
|
|
27375
|
+
const { eventId } = event;
|
|
27376
|
+
const eventInfo = extractEventInfo({ event }).eventInfo;
|
|
27377
|
+
const scheduleTiming = getScheduleTiming({
|
|
27378
|
+
tournamentRecord,
|
|
27379
|
+
event,
|
|
27380
|
+
}).scheduleTiming;
|
|
27381
|
+
const drawsData = (event.drawDefinitions || []).map((drawDefinition) => {
|
|
27382
|
+
const drawInfo = (({ drawId, drawName, matchUpFormat, updatedAt }) => ({
|
|
27383
|
+
matchUpFormat,
|
|
27384
|
+
updatedAt,
|
|
27385
|
+
drawName,
|
|
27386
|
+
drawId,
|
|
27387
|
+
}))(drawDefinition);
|
|
27388
|
+
const { abandonedMatchUps, completedMatchUps, upcomingMatchUps, pendingMatchUps } = getDrawMatchUps({
|
|
27389
|
+
requireParticipants: true,
|
|
27390
|
+
tournamentParticipants,
|
|
27391
|
+
context: { eventId },
|
|
27392
|
+
policyDefinitions,
|
|
27393
|
+
tournamentRecord,
|
|
27394
|
+
inContext: true,
|
|
27395
|
+
scheduleTiming,
|
|
27396
|
+
drawDefinition,
|
|
27397
|
+
event,
|
|
27398
|
+
});
|
|
27399
|
+
return {
|
|
27400
|
+
drawInfo,
|
|
27401
|
+
matchUps: {
|
|
27402
|
+
abandonedMatchUps,
|
|
27403
|
+
completedMatchUps,
|
|
27404
|
+
upcomingMatchUps,
|
|
27405
|
+
pendingMatchUps,
|
|
27406
|
+
},
|
|
27407
|
+
};
|
|
27408
|
+
});
|
|
27409
|
+
const publish = getEventPublishStatus({ event });
|
|
27410
|
+
Object.assign(eventInfo, {
|
|
27411
|
+
drawsData,
|
|
27412
|
+
publish,
|
|
27413
|
+
});
|
|
27414
|
+
return eventInfo;
|
|
27415
|
+
});
|
|
27416
|
+
const allEventData = { tournamentInfo, venuesData, eventsData };
|
|
27417
|
+
return { allEventData };
|
|
27418
|
+
}
|
|
27419
|
+
|
|
27420
|
+
function getDrawIsPublished({ publishStatus, drawId }) {
|
|
27421
|
+
if (publishStatus?.drawDetails) {
|
|
27422
|
+
return publishStatus.drawDetails?.[drawId]?.publishingDetail?.published;
|
|
27423
|
+
}
|
|
27424
|
+
else if (publishStatus?.drawIds) {
|
|
27425
|
+
return publishStatus.drawIds.includes(drawId);
|
|
27426
|
+
}
|
|
27427
|
+
return true;
|
|
27428
|
+
}
|
|
27429
|
+
|
|
27430
|
+
function getDrawData(params) {
|
|
27431
|
+
const { tournamentParticipants = [], includePositionAssignments, policyDefinitions, tournamentRecord, inContext = true, usePublishState, status = PUBLIC, drawDefinition, noDeepCopy, sortConfig, context, event, } = params;
|
|
27432
|
+
if (!drawDefinition)
|
|
27433
|
+
return { error: MISSING_DRAW_DEFINITION };
|
|
27434
|
+
const drawInfo = (({ matchUpFormat, updatedAt, drawType, drawName, drawId }) => ({
|
|
27435
|
+
matchUpFormat,
|
|
27436
|
+
updatedAt,
|
|
27437
|
+
drawName,
|
|
27438
|
+
drawType,
|
|
27439
|
+
drawId,
|
|
27440
|
+
}))(drawDefinition);
|
|
27441
|
+
let mainStageSeedAssignments, qualificationStageSeedAssignments;
|
|
27442
|
+
const { allStructuresLinked, sourceStructureIds, hasDrawFeedProfile, structureGroups } = getStructureGroups({
|
|
27443
|
+
drawDefinition,
|
|
27444
|
+
});
|
|
27445
|
+
if (!allStructuresLinked)
|
|
27446
|
+
return { error: UNLINKED_STRUCTURES };
|
|
27447
|
+
const publishStatus = params?.publishStatus ?? getEventPublishStatus({ event, status });
|
|
27448
|
+
const eventPublished = params.eventPublished ?? !!getPublishState({ event }).publishState?.status?.published;
|
|
27449
|
+
let drawActive = false;
|
|
27450
|
+
let participantPlacements = false;
|
|
27451
|
+
const groupedStructures = structureGroups.map((structureIds) => {
|
|
27452
|
+
const completedStructures = {};
|
|
27453
|
+
const structures = structureIds
|
|
27454
|
+
.map((structureId) => {
|
|
27455
|
+
const { structure } = findStructure({ drawDefinition, structureId });
|
|
27456
|
+
const { seedAssignments } = getStructureSeedAssignments({
|
|
27457
|
+
drawDefinition,
|
|
27458
|
+
structure,
|
|
27459
|
+
});
|
|
27460
|
+
if (structure?.stage === MAIN && structure.stageSequence === 1) {
|
|
27461
|
+
mainStageSeedAssignments = seedAssignments;
|
|
27462
|
+
}
|
|
27463
|
+
if (structure?.stage === QUALIFYING && structure.stageSequence === 1) {
|
|
27464
|
+
qualificationStageSeedAssignments = seedAssignments;
|
|
27465
|
+
}
|
|
27466
|
+
return structure;
|
|
27467
|
+
})
|
|
27468
|
+
.sort((a, b) => structureSort(a, b, sortConfig))
|
|
27469
|
+
.map((structure) => {
|
|
27470
|
+
if (!structure)
|
|
27471
|
+
return;
|
|
27472
|
+
const structureId = structure?.structureId;
|
|
27473
|
+
let seedAssignments = [];
|
|
27474
|
+
if (structure.stage && [MAIN, CONSOLATION, PLAY_OFF].includes(structure.stage)) {
|
|
27475
|
+
seedAssignments = mainStageSeedAssignments;
|
|
27476
|
+
}
|
|
27477
|
+
if (structure?.stage === QUALIFYING) {
|
|
27478
|
+
seedAssignments = qualificationStageSeedAssignments;
|
|
27479
|
+
}
|
|
27480
|
+
const { matchUps, roundMatchUps, roundProfile } = getAllStructureMatchUps({
|
|
27481
|
+
seedAssignments: !structure?.seedAssignments?.length ? seedAssignments : undefined,
|
|
27482
|
+
context: { drawId: drawInfo.drawId, ...context },
|
|
27483
|
+
tournamentParticipants,
|
|
27484
|
+
policyDefinitions,
|
|
27485
|
+
tournamentRecord,
|
|
27486
|
+
usePublishState,
|
|
27487
|
+
publishStatus,
|
|
27488
|
+
drawDefinition,
|
|
27489
|
+
inContext,
|
|
27490
|
+
structure,
|
|
27491
|
+
event,
|
|
27492
|
+
});
|
|
27493
|
+
const { positionAssignments } = getPositionAssignments$1({
|
|
27494
|
+
structure,
|
|
27495
|
+
});
|
|
27496
|
+
let participantResults = positionAssignments?.filter(xa(PARTICIPANT_ID)).map((assignment) => {
|
|
27497
|
+
const { drawPosition, participantId } = assignment;
|
|
27498
|
+
const { extension } = findExtension({
|
|
27499
|
+
element: assignment,
|
|
27500
|
+
name: TALLY,
|
|
27501
|
+
});
|
|
27502
|
+
participantPlacements = true;
|
|
27503
|
+
return {
|
|
27504
|
+
participantResult: extension?.value,
|
|
27505
|
+
participantId,
|
|
27506
|
+
drawPosition,
|
|
27507
|
+
};
|
|
27508
|
+
});
|
|
27509
|
+
if (!participantResults?.length && matchUps.length && params.allParticipantResults) {
|
|
27510
|
+
const { subOrderMap } = createSubOrderMap({ positionAssignments });
|
|
27511
|
+
const result = tallyParticipantResults({
|
|
27512
|
+
matchUpFormat: structure.matchUpFormat,
|
|
27513
|
+
policyDefinitions,
|
|
27514
|
+
subOrderMap,
|
|
27515
|
+
matchUps,
|
|
27516
|
+
});
|
|
27517
|
+
participantResults = positionAssignments?.filter(xa(PARTICIPANT_ID)).map((assignment) => {
|
|
27518
|
+
const { drawPosition, participantId } = assignment;
|
|
27519
|
+
participantPlacements = true;
|
|
27520
|
+
return {
|
|
27521
|
+
participantResult: participantId && result.participantResults[participantId],
|
|
27522
|
+
participantId,
|
|
27523
|
+
drawPosition,
|
|
27524
|
+
};
|
|
27525
|
+
});
|
|
27526
|
+
}
|
|
27527
|
+
const structureInfo = structure
|
|
27528
|
+
? (({ stageSequence, structureName, structureType, matchUpFormat, stage }) => ({
|
|
27529
|
+
stageSequence,
|
|
27530
|
+
structureName,
|
|
27531
|
+
structureType,
|
|
27532
|
+
matchUpFormat,
|
|
27533
|
+
stage,
|
|
27534
|
+
}))(structure)
|
|
27535
|
+
: {};
|
|
27536
|
+
structureInfo.sourceStructureIds = sourceStructureIds[structureId];
|
|
27537
|
+
structureInfo.hasDrawFeedProfile = hasDrawFeedProfile[structureId];
|
|
27538
|
+
structureInfo.positionAssignments = positionAssignments;
|
|
27539
|
+
structureInfo.structureActive = matchUps.reduce((active, matchUp) => {
|
|
27540
|
+
const activeMatchUpStatus = [
|
|
27541
|
+
COMPLETED$1,
|
|
27542
|
+
CANCELLED$1,
|
|
27543
|
+
DEFAULTED,
|
|
27544
|
+
RETIRED$1,
|
|
27545
|
+
WALKOVER$2,
|
|
27546
|
+
IN_PROGRESS$1,
|
|
27547
|
+
DOUBLE_DEFAULT,
|
|
27548
|
+
DOUBLE_WALKOVER,
|
|
27549
|
+
].includes(matchUp.matchUpStatus);
|
|
27550
|
+
return active || activeMatchUpStatus || !!matchUp.winningSide || !!matchUp.score?.scoreStringSide1;
|
|
27551
|
+
}, false);
|
|
27552
|
+
const structureCompleted = matchUps.reduce((completed, matchUp) => {
|
|
27553
|
+
return completed && [BYE, COMPLETED$1, RETIRED$1, WALKOVER$2, DEFAULTED, ABANDONED$1].includes(matchUp.matchUpStatus);
|
|
27554
|
+
}, !!matchUps.length);
|
|
27555
|
+
structureInfo.structureCompleted = structureCompleted;
|
|
27556
|
+
completedStructures[structureId] = structureCompleted;
|
|
27557
|
+
if (structureInfo.structureActive)
|
|
27558
|
+
drawActive = true;
|
|
27559
|
+
return {
|
|
27560
|
+
...structureInfo,
|
|
27561
|
+
participantResults,
|
|
27562
|
+
seedAssignments,
|
|
27563
|
+
roundMatchUps,
|
|
27564
|
+
roundProfile,
|
|
27565
|
+
structureId,
|
|
27566
|
+
};
|
|
27567
|
+
});
|
|
27568
|
+
structures.forEach((structure) => {
|
|
27569
|
+
if (!includePositionAssignments)
|
|
27570
|
+
delete structure.positionAssignments;
|
|
27571
|
+
structure.sourceStructuresComplete = structure.sourceStructureIds?.every((id) => completedStructures[id]);
|
|
27572
|
+
});
|
|
27573
|
+
return structures;
|
|
27574
|
+
});
|
|
27575
|
+
const structures = groupedStructures.flat();
|
|
27576
|
+
drawInfo.drawActive = drawActive;
|
|
27577
|
+
drawInfo.participantPlacements = participantPlacements;
|
|
27578
|
+
drawInfo.drawGenerated = structures?.reduce((generated, structure) => {
|
|
27579
|
+
return generated || !!structure?.roundMatchUps;
|
|
27580
|
+
}, false);
|
|
27581
|
+
drawInfo.drawCompleted = structures?.reduce((completed, structure) => completed && structure.structureCompleted, true);
|
|
27582
|
+
drawInfo.drawPublished = usePublishState
|
|
27583
|
+
? eventPublished && getDrawIsPublished({ publishStatus, drawId: drawInfo.drawId })
|
|
27584
|
+
: undefined;
|
|
27585
|
+
return {
|
|
27586
|
+
structures: !usePublishState || drawInfo.drawPublished
|
|
27587
|
+
? noDeepCopy
|
|
27588
|
+
? structures
|
|
27589
|
+
: makeDeepCopy(structures, false, true)
|
|
27590
|
+
: undefined,
|
|
27591
|
+
drawInfo: noDeepCopy ? drawInfo : makeDeepCopy(drawInfo, false, true),
|
|
27592
|
+
...SUCCESS,
|
|
27593
|
+
};
|
|
27594
|
+
}
|
|
27595
|
+
|
|
27596
|
+
function getEventData(params) {
|
|
27597
|
+
const { includePositionAssignments, participantsProfile, policyDefinitions, usePublishState, status = PUBLIC, sortConfig, } = params;
|
|
27598
|
+
const paramsCheck = checkRequiredParameters(params, [
|
|
27599
|
+
{ tournamentRecord: true },
|
|
27600
|
+
{ [ANY_OF]: { event: false, eventId: false } },
|
|
27601
|
+
]);
|
|
27602
|
+
if (paramsCheck.error)
|
|
27603
|
+
return paramsCheck;
|
|
27604
|
+
const tournamentRecord = makeDeepCopy(params.tournamentRecord, false, true);
|
|
27605
|
+
const foundEvent = !params.event ? findEvent({ tournamentRecord, eventId: params.eventId }).event : undefined;
|
|
27606
|
+
const event = params.event
|
|
27607
|
+
? makeDeepCopy(params.event, false, true)
|
|
27608
|
+
: (foundEvent && makeDeepCopy(foundEvent, false, true)) || undefined;
|
|
27609
|
+
if (!event)
|
|
27610
|
+
return { error: EVENT_NOT_FOUND };
|
|
27611
|
+
const { eventId } = event;
|
|
27612
|
+
const { tournamentId, endDate } = tournamentRecord;
|
|
27613
|
+
const publishStatus = getEventPublishStatus({ event, status });
|
|
27614
|
+
const publishState = getPublishState({ event }).publishState ?? {};
|
|
27615
|
+
const eventPublished = !!publishState?.status?.published;
|
|
27616
|
+
const { participants: tournamentParticipants } = getParticipants({
|
|
27617
|
+
withGroupings: true,
|
|
27618
|
+
withEvents: false,
|
|
27619
|
+
withDraws: false,
|
|
27620
|
+
policyDefinitions,
|
|
27621
|
+
...participantsProfile,
|
|
27622
|
+
tournamentRecord,
|
|
27623
|
+
});
|
|
27624
|
+
const stageFilter = ({ stage, drawId }) => {
|
|
27625
|
+
if (!usePublishState)
|
|
27626
|
+
return true;
|
|
27627
|
+
const stageDetails = publishStatus?.drawDetails?.[drawId]?.stageDetails;
|
|
27628
|
+
if (!stageDetails || !Object.keys(stageDetails).length)
|
|
27629
|
+
return true;
|
|
27630
|
+
return stageDetails[stage]?.published;
|
|
27631
|
+
};
|
|
27632
|
+
const structureFilter = ({ structureId, drawId }) => {
|
|
27633
|
+
if (!usePublishState)
|
|
27634
|
+
return true;
|
|
27635
|
+
const structureDetails = publishStatus?.drawDetails?.[drawId]?.structureDetails;
|
|
27636
|
+
if (!structureDetails || !Object.keys(structureDetails).length)
|
|
27637
|
+
return true;
|
|
27638
|
+
return structureDetails[structureId]?.published;
|
|
27639
|
+
};
|
|
27640
|
+
const drawFilter = ({ drawId }) => (!usePublishState ? true : getDrawIsPublished({ publishStatus, drawId }));
|
|
27641
|
+
const roundLimitMapper = ({ drawId, structure }) => {
|
|
27642
|
+
if (!usePublishState)
|
|
27643
|
+
return structure;
|
|
27644
|
+
const roundLimit = publishStatus?.drawDetails?.[drawId]?.structureDetails?.[structure.structureId]?.roundLimit;
|
|
27645
|
+
if (isConvertableInteger(roundLimit)) {
|
|
27646
|
+
const roundNumbers = generateRange(1, roundLimit + 1);
|
|
27647
|
+
const roundMatchUps = {};
|
|
27648
|
+
const roundProfile = {};
|
|
27649
|
+
for (const roundNumber of roundNumbers) {
|
|
27650
|
+
if (structure.roundMatchUps[roundNumber]) {
|
|
27651
|
+
roundMatchUps[roundNumber] = structure.roundMatchUps[roundNumber];
|
|
27652
|
+
roundProfile[roundNumber] = structure.roundProfile[roundNumber];
|
|
27653
|
+
}
|
|
27654
|
+
}
|
|
27655
|
+
structure.roundMatchUps = roundMatchUps;
|
|
27656
|
+
structure.roundProfile = roundProfile;
|
|
27657
|
+
}
|
|
27658
|
+
return structure;
|
|
27659
|
+
};
|
|
27660
|
+
const drawDefinitions = event.drawDefinitions || [];
|
|
27661
|
+
const drawsData = !usePublishState || eventPublished
|
|
27662
|
+
? drawDefinitions
|
|
27663
|
+
.filter(drawFilter)
|
|
27664
|
+
.map((drawDefinition) => (({ drawInfo, structures }) => ({
|
|
27665
|
+
...drawInfo,
|
|
27666
|
+
structures,
|
|
27667
|
+
}))(getDrawData({
|
|
27668
|
+
allParticipantResults: params.allParticipantResults,
|
|
27669
|
+
context: { eventId, tournamentId, endDate },
|
|
27670
|
+
includePositionAssignments,
|
|
27671
|
+
tournamentParticipants,
|
|
27672
|
+
noDeepCopy: true,
|
|
27673
|
+
policyDefinitions,
|
|
27674
|
+
tournamentRecord,
|
|
27675
|
+
usePublishState,
|
|
27676
|
+
drawDefinition,
|
|
27677
|
+
publishStatus,
|
|
27678
|
+
sortConfig,
|
|
27679
|
+
event,
|
|
27680
|
+
})))
|
|
27681
|
+
.map(({ structures, ...drawData }) => {
|
|
27682
|
+
const filteredStructures = structures
|
|
27683
|
+
?.filter(({ stage, structureId }) => structureFilter({ structureId, drawId: drawData.drawId }) &&
|
|
27684
|
+
stageFilter({ stage, drawId: drawData.drawId }))
|
|
27685
|
+
.map((structure) => roundLimitMapper({ drawId: drawData.drawId, structure }));
|
|
27686
|
+
return {
|
|
27687
|
+
...drawData,
|
|
27688
|
+
structures: filteredStructures,
|
|
27689
|
+
};
|
|
27690
|
+
})
|
|
27691
|
+
.filter((drawData) => drawData.structures?.length)
|
|
27692
|
+
: undefined;
|
|
27693
|
+
const { tournamentInfo } = getTournamentInfo({ tournamentRecord });
|
|
27694
|
+
const venues = tournamentRecord.venues || [];
|
|
27695
|
+
const venuesData = venues.map((venue) => (({ venueData }) => ({
|
|
27696
|
+
...venueData,
|
|
27697
|
+
}))(getVenueData({
|
|
27698
|
+
tournamentRecord,
|
|
27699
|
+
venueId: venue.venueId,
|
|
27700
|
+
})));
|
|
27701
|
+
const eventInfo = (({ eventId, eventName, eventType, eventLevel, surfaceCategory, matchUpFormat, category, gender, startDate, endDate, ballType, discipline, }) => ({
|
|
27702
|
+
eventId,
|
|
27703
|
+
eventName,
|
|
27704
|
+
eventType,
|
|
27705
|
+
eventLevel,
|
|
27706
|
+
surfaceCategory,
|
|
27707
|
+
matchUpFormat,
|
|
27708
|
+
category,
|
|
27709
|
+
gender,
|
|
27710
|
+
startDate,
|
|
27711
|
+
endDate,
|
|
27712
|
+
ballType,
|
|
27713
|
+
discipline,
|
|
27714
|
+
}))(event);
|
|
27715
|
+
const eventData = {
|
|
27716
|
+
tournamentInfo,
|
|
27717
|
+
venuesData,
|
|
27718
|
+
eventInfo,
|
|
27719
|
+
drawsData,
|
|
27720
|
+
};
|
|
27721
|
+
eventData.eventInfo.publishState = publishState;
|
|
27722
|
+
eventData.eventInfo.published = publishState?.status?.published;
|
|
27723
|
+
return { ...SUCCESS, eventData, participants: tournamentParticipants };
|
|
27724
|
+
}
|
|
27725
|
+
|
|
27726
|
+
var query$7 = {
|
|
27727
|
+
__proto__: null,
|
|
27728
|
+
bulkUpdatePublishedEventIds: bulkUpdatePublishedEventIds,
|
|
27729
|
+
getAllEventData: getAllEventData,
|
|
27730
|
+
getCourtInfo: getCourtInfo,
|
|
27731
|
+
getDrawData: getDrawData,
|
|
27732
|
+
getEventData: getEventData,
|
|
27733
|
+
getEventPublishStatus: getEventPublishStatus,
|
|
27734
|
+
getPublishState: getPublishState,
|
|
27735
|
+
getVenueData: getVenueData
|
|
27736
|
+
};
|
|
27737
|
+
|
|
27171
27738
|
function findMatchUpFormatTiming({ defaultRecoveryMinutes = 0, defaultAverageMinutes, tournamentRecords, matchUpFormat, categoryName, categoryType, tournamentId, eventType, eventId, }) {
|
|
27172
27739
|
if (!isValidMatchUpFormat({ matchUpFormat }))
|
|
27173
27740
|
return { error: UNRECOGNIZED_MATCHUP_FORMAT };
|
|
@@ -27486,164 +28053,6 @@ function getAllRelevantSchedulingIds(params) {
|
|
|
27486
28053
|
};
|
|
27487
28054
|
}
|
|
27488
28055
|
|
|
27489
|
-
function getDisabledStatus({ dates = [], extension }) {
|
|
27490
|
-
if (!extension)
|
|
27491
|
-
return false;
|
|
27492
|
-
if (typeof extension.value === 'boolean' && extension.value)
|
|
27493
|
-
return true;
|
|
27494
|
-
if (!dates.length)
|
|
27495
|
-
return false;
|
|
27496
|
-
const disabledDates = isObject(extension.value) ? extension.value?.dates : undefined;
|
|
27497
|
-
if (Array.isArray(disabledDates)) {
|
|
27498
|
-
if (!disabledDates?.length)
|
|
27499
|
-
return false;
|
|
27500
|
-
const datesToConsider = disabledDates.filter((date) => !dates.length || dates.includes(date));
|
|
27501
|
-
return !!datesToConsider.length;
|
|
27502
|
-
}
|
|
27503
|
-
return undefined;
|
|
27504
|
-
}
|
|
27505
|
-
|
|
27506
|
-
function getInContextCourt({ convertExtensions, ignoreDisabled, venue, court }) {
|
|
27507
|
-
const inContextCourt = {
|
|
27508
|
-
...makeDeepCopy(court, convertExtensions, true),
|
|
27509
|
-
venueId: venue.venueId,
|
|
27510
|
-
};
|
|
27511
|
-
const { extension } = findExtension({
|
|
27512
|
-
name: DISABLED,
|
|
27513
|
-
element: court,
|
|
27514
|
-
});
|
|
27515
|
-
if (ignoreDisabled && extension) {
|
|
27516
|
-
const disabledDates = isObject(extension.value) ? extension.value?.dates : undefined;
|
|
27517
|
-
const dateAvailability = extension?.value === true
|
|
27518
|
-
? []
|
|
27519
|
-
: inContextCourt.dateAvailability
|
|
27520
|
-
.map((availability) => {
|
|
27521
|
-
const date = availability.date;
|
|
27522
|
-
if (!date || disabledDates.includes(date))
|
|
27523
|
-
return;
|
|
27524
|
-
return availability;
|
|
27525
|
-
})
|
|
27526
|
-
.filter(Boolean);
|
|
27527
|
-
inContextCourt.dateAvailability = dateAvailability;
|
|
27528
|
-
}
|
|
27529
|
-
return { inContextCourt };
|
|
27530
|
-
}
|
|
27531
|
-
|
|
27532
|
-
function getVenuesAndCourts(params) {
|
|
27533
|
-
const { convertExtensions, ignoreDisabled, venueIds = [], dates, } = params;
|
|
27534
|
-
const tournamentRecords = params.tournamentRecords ||
|
|
27535
|
-
(params.tournamentRecord && {
|
|
27536
|
-
[params.tournamentRecord.tournamentId]: params.tournamentRecord,
|
|
27537
|
-
}) ||
|
|
27538
|
-
{};
|
|
27539
|
-
const uniqueVenueIds = [];
|
|
27540
|
-
const uniqueCourtIds = [];
|
|
27541
|
-
const courts = [];
|
|
27542
|
-
const venues = [];
|
|
27543
|
-
const tournamentIds = Object.keys(tournamentRecords).filter((id) => !params.tournamentId || id === params.tournamentId);
|
|
27544
|
-
tournamentIds.forEach((tournamentId) => {
|
|
27545
|
-
const tournamentRecord = tournamentRecords[tournamentId];
|
|
27546
|
-
for (const venue of tournamentRecord.venues ?? []) {
|
|
27547
|
-
if (venueIds.length && !venueIds.includes(venue.venueId))
|
|
27548
|
-
continue;
|
|
27549
|
-
if (ignoreDisabled) {
|
|
27550
|
-
const { extension } = findExtension({
|
|
27551
|
-
name: DISABLED,
|
|
27552
|
-
element: venue,
|
|
27553
|
-
});
|
|
27554
|
-
if (extension?.value)
|
|
27555
|
-
continue;
|
|
27556
|
-
}
|
|
27557
|
-
if (!uniqueVenueIds.includes(venue.venueId)) {
|
|
27558
|
-
venues.push(makeDeepCopy(venue, convertExtensions, true));
|
|
27559
|
-
uniqueVenueIds.push(venue.venueId);
|
|
27560
|
-
}
|
|
27561
|
-
for (const court of venue.courts ?? []) {
|
|
27562
|
-
if (!uniqueCourtIds.includes(court.courtId)) {
|
|
27563
|
-
if (ignoreDisabled) {
|
|
27564
|
-
const { extension } = findExtension({
|
|
27565
|
-
name: DISABLED,
|
|
27566
|
-
element: court,
|
|
27567
|
-
});
|
|
27568
|
-
const isDisabled = getDisabledStatus({ extension, dates });
|
|
27569
|
-
if (isDisabled)
|
|
27570
|
-
continue;
|
|
27571
|
-
}
|
|
27572
|
-
const { inContextCourt } = getInContextCourt({
|
|
27573
|
-
convertExtensions,
|
|
27574
|
-
ignoreDisabled,
|
|
27575
|
-
venue,
|
|
27576
|
-
court,
|
|
27577
|
-
});
|
|
27578
|
-
courts.push(inContextCourt);
|
|
27579
|
-
uniqueCourtIds.push(court.courtId);
|
|
27580
|
-
}
|
|
27581
|
-
}
|
|
27582
|
-
}
|
|
27583
|
-
});
|
|
27584
|
-
return { courts, venues, ...SUCCESS };
|
|
27585
|
-
}
|
|
27586
|
-
function getTournamentVenuesAndCourts({ convertExtensions, tournamentRecord, ignoreDisabled, dates, }) {
|
|
27587
|
-
if (!tournamentRecord)
|
|
27588
|
-
return { error: MISSING_TOURNAMENT_RECORDS };
|
|
27589
|
-
const venues = makeDeepCopy(tournamentRecord.venues ?? [], convertExtensions)
|
|
27590
|
-
.filter((venue) => {
|
|
27591
|
-
if (!ignoreDisabled)
|
|
27592
|
-
return venue;
|
|
27593
|
-
const { extension } = findExtension({
|
|
27594
|
-
name: DISABLED,
|
|
27595
|
-
element: venue,
|
|
27596
|
-
});
|
|
27597
|
-
return !extension?.value && venue;
|
|
27598
|
-
})
|
|
27599
|
-
.filter(Boolean);
|
|
27600
|
-
const courts = venues.reduce((courts, venue) => {
|
|
27601
|
-
const additionalCourts = (venue?.courts || [])
|
|
27602
|
-
.filter((court) => {
|
|
27603
|
-
if (!ignoreDisabled && !dates?.length)
|
|
27604
|
-
return court;
|
|
27605
|
-
const { extension } = findExtension({
|
|
27606
|
-
name: DISABLED,
|
|
27607
|
-
element: court,
|
|
27608
|
-
});
|
|
27609
|
-
return getDisabledStatus({ extension, dates });
|
|
27610
|
-
})
|
|
27611
|
-
.filter(Boolean)
|
|
27612
|
-
.map((court) => {
|
|
27613
|
-
const { inContextCourt } = getInContextCourt({
|
|
27614
|
-
convertExtensions,
|
|
27615
|
-
ignoreDisabled,
|
|
27616
|
-
venue,
|
|
27617
|
-
court,
|
|
27618
|
-
});
|
|
27619
|
-
return inContextCourt;
|
|
27620
|
-
});
|
|
27621
|
-
return additionalCourts.length ? courts.concat(additionalCourts) : courts;
|
|
27622
|
-
}, []);
|
|
27623
|
-
return { venues, courts };
|
|
27624
|
-
}
|
|
27625
|
-
function getCompetitionVenues({ tournamentRecords, requireCourts, dates }) {
|
|
27626
|
-
if (typeof tournamentRecords !== 'object' || !Object.keys(tournamentRecords).length)
|
|
27627
|
-
return { error: MISSING_TOURNAMENT_RECORDS };
|
|
27628
|
-
const tournamentIds = Object.keys(tournamentRecords);
|
|
27629
|
-
return tournamentIds.reduce((accumulator, tournamentId) => {
|
|
27630
|
-
const tournamentRecord = tournamentRecords[tournamentId];
|
|
27631
|
-
const { venues } = getTournamentVenuesAndCourts({
|
|
27632
|
-
tournamentRecord,
|
|
27633
|
-
dates,
|
|
27634
|
-
});
|
|
27635
|
-
venues?.forEach((venue) => {
|
|
27636
|
-
const { venueId, courts } = venue;
|
|
27637
|
-
const includeVenue = !requireCourts || courts?.length;
|
|
27638
|
-
if (includeVenue && !accumulator.venueIds.includes(venueId)) {
|
|
27639
|
-
accumulator.venues.push(venue);
|
|
27640
|
-
accumulator.venueIds.push(venueId);
|
|
27641
|
-
}
|
|
27642
|
-
});
|
|
27643
|
-
return accumulator;
|
|
27644
|
-
}, { venues: [], venueIds: [] });
|
|
27645
|
-
}
|
|
27646
|
-
|
|
27647
28056
|
function getSchedulingProfile({ tournamentRecords, tournamentRecord }) {
|
|
27648
28057
|
if (typeof tournamentRecords !== 'object' || !Object.keys(tournamentRecords).length)
|
|
27649
28058
|
return { error: MISSING_TOURNAMENT_RECORDS };
|
|
@@ -27972,7 +28381,7 @@ function getProfileRounds({ tournamentRecords, schedulingProfile, tournamentReco
|
|
|
27972
28381
|
return { profileRounds, segmentedRounds };
|
|
27973
28382
|
}
|
|
27974
28383
|
|
|
27975
|
-
var query$
|
|
28384
|
+
var query$6 = {
|
|
27976
28385
|
__proto__: null,
|
|
27977
28386
|
getPersonRequests: getPersonRequests,
|
|
27978
28387
|
getProfileRounds: getProfileRounds,
|
|
@@ -28014,7 +28423,7 @@ function getMaxEntryPosition(params) {
|
|
|
28014
28423
|
.map(({ entryPosition }) => ensureInt(entryPosition || 0)), 0);
|
|
28015
28424
|
}
|
|
28016
28425
|
|
|
28017
|
-
var query$
|
|
28426
|
+
var query$5 = {
|
|
28018
28427
|
__proto__: null,
|
|
28019
28428
|
getEntriesAndSeedsCount: getEntriesAndSeedsCount,
|
|
28020
28429
|
getMaxEntryPosition: getMaxEntryPosition
|
|
@@ -29930,7 +30339,7 @@ function drawMatchUps({ participants: tournamentParticipants, tournamentAppliedP
|
|
|
29930
30339
|
return { ...drawMatchUpsResult, groupInfo };
|
|
29931
30340
|
}
|
|
29932
30341
|
|
|
29933
|
-
var query$
|
|
30342
|
+
var query$4 = {
|
|
29934
30343
|
__proto__: null,
|
|
29935
30344
|
allCompetitionMatchUps: allCompetitionMatchUps,
|
|
29936
30345
|
allDrawMatchUps: allDrawMatchUps,
|
|
@@ -29993,7 +30402,7 @@ function getCourts({ tournamentRecord, venueId, venueIds }) {
|
|
|
29993
30402
|
return { courts };
|
|
29994
30403
|
}
|
|
29995
30404
|
|
|
29996
|
-
var query$
|
|
30405
|
+
var query$3 = {
|
|
29997
30406
|
__proto__: null,
|
|
29998
30407
|
getCompetitionVenues: getCompetitionVenues,
|
|
29999
30408
|
getCourts: getCourts,
|
|
@@ -30001,42 +30410,6 @@ var query$4 = {
|
|
|
30001
30410
|
publicFindVenue: publicFindVenue
|
|
30002
30411
|
};
|
|
30003
30412
|
|
|
30004
|
-
function bulkUpdatePublishedEventIds({ tournamentRecord, outcomes }) {
|
|
30005
|
-
if (!tournamentRecord)
|
|
30006
|
-
return { error: MISSING_TOURNAMENT_RECORD };
|
|
30007
|
-
if (!outcomes?.length)
|
|
30008
|
-
return { error: MISSING_VALUE, info: 'Missing outcomes' };
|
|
30009
|
-
const eventIdsMap = outcomes.reduce((eventIdsMap, outcome) => {
|
|
30010
|
-
const { drawId, eventId } = outcome;
|
|
30011
|
-
if (eventId && drawId) {
|
|
30012
|
-
if (!eventIdsMap[eventId]) {
|
|
30013
|
-
eventIdsMap[eventId] = [drawId];
|
|
30014
|
-
}
|
|
30015
|
-
else if (!eventIdsMap[eventId].includes(drawId)) {
|
|
30016
|
-
eventIdsMap[eventId].push(drawId);
|
|
30017
|
-
}
|
|
30018
|
-
}
|
|
30019
|
-
return eventIdsMap;
|
|
30020
|
-
}, {});
|
|
30021
|
-
const relevantEventsIds = Object.keys(eventIdsMap);
|
|
30022
|
-
const relevantEvents = tournamentRecord.events?.filter((event) => relevantEventsIds.includes(event.eventId));
|
|
30023
|
-
const publishedEventIds = relevantEvents
|
|
30024
|
-
.filter((event) => {
|
|
30025
|
-
const pubStatus = getEventPublishStatus({ event });
|
|
30026
|
-
const { drawDetails, drawIds } = pubStatus ?? {};
|
|
30027
|
-
const { eventId } = event;
|
|
30028
|
-
const publishedDrawIds = eventIdsMap[eventId].filter((drawId) => {
|
|
30029
|
-
const keyedDrawIds = drawDetails
|
|
30030
|
-
? Object.keys(pubStatus.drawDetails).filter((drawId) => getDrawPublishStatus({ drawId, drawDetails }))
|
|
30031
|
-
: [];
|
|
30032
|
-
return drawIds?.includes(drawId) || keyedDrawIds.includes(drawId);
|
|
30033
|
-
});
|
|
30034
|
-
return publishedDrawIds.length;
|
|
30035
|
-
})
|
|
30036
|
-
.map((event) => event.eventId);
|
|
30037
|
-
return { publishedEventIds, eventIdPublishedDrawIdsMap: eventIdsMap };
|
|
30038
|
-
}
|
|
30039
|
-
|
|
30040
30413
|
function getEventProperties({ tournamentRecord, event }) {
|
|
30041
30414
|
if (!tournamentRecord)
|
|
30042
30415
|
return { error: MISSING_TOURNAMENT_RECORD };
|
|
@@ -30301,9 +30674,8 @@ function getEvent({ tournamentRecord, drawDefinition, context, event }) {
|
|
|
30301
30674
|
});
|
|
30302
30675
|
}
|
|
30303
30676
|
|
|
30304
|
-
var query$
|
|
30677
|
+
var query$2 = {
|
|
30305
30678
|
__proto__: null,
|
|
30306
|
-
bulkUpdatePublishedEventIds: bulkUpdatePublishedEventIds,
|
|
30307
30679
|
categoryCanContain: categoryCanContain,
|
|
30308
30680
|
getCategoryAgeDetails: getCategoryAgeDetails,
|
|
30309
30681
|
getEvent: getEvent,
|
|
@@ -30340,6 +30712,7 @@ var index$g = {
|
|
|
30340
30712
|
findDrawDefinition: publicFindDrawDefinition,
|
|
30341
30713
|
findExtension: findExtension,
|
|
30342
30714
|
getAllDrawMatchUps: getAllDrawMatchUps,
|
|
30715
|
+
getAllEventData: getAllEventData,
|
|
30343
30716
|
getAllStructureMatchUps: getAllStructureMatchUps,
|
|
30344
30717
|
getAllowedDrawTypes: getAllowedDrawTypes,
|
|
30345
30718
|
getAllowedMatchUpFormats: getAllowedMatchUpFormats,
|
|
@@ -30354,15 +30727,19 @@ var index$g = {
|
|
|
30354
30727
|
getCompetitionParticipants: getCompetitionParticipants,
|
|
30355
30728
|
getCompetitionPenalties: getCompetitionPenalties,
|
|
30356
30729
|
getCompetitionVenues: getCompetitionVenues,
|
|
30730
|
+
getCourtInfo: getCourtInfo,
|
|
30357
30731
|
getCourts: getCourts,
|
|
30732
|
+
getDrawData: getDrawData,
|
|
30358
30733
|
getDrawDefinitionTimeItem: getDrawDefinitionTimeItem,
|
|
30359
30734
|
getDrawParticipantRepresentativeIds: getDrawParticipantRepresentativeIds,
|
|
30360
30735
|
getDrawTypeCoercion: getDrawTypeCoercion,
|
|
30361
30736
|
getEligibleVoluntaryConsolationParticipants: getEligibleVoluntaryConsolationParticipants,
|
|
30362
30737
|
getEntriesAndSeedsCount: getEntriesAndSeedsCount,
|
|
30363
30738
|
getEvent: getEvent,
|
|
30739
|
+
getEventData: getEventData,
|
|
30364
30740
|
getEventMatchUpFormatTiming: getEventMatchUpFormatTiming,
|
|
30365
30741
|
getEventProperties: getEventProperties,
|
|
30742
|
+
getEventPublishStatus: getEventPublishStatus,
|
|
30366
30743
|
getEventStructures: getEventStructures,
|
|
30367
30744
|
getEventTimeItem: getEventTimeItem,
|
|
30368
30745
|
getEvents: getEvents,
|
|
@@ -30398,6 +30775,7 @@ var index$g = {
|
|
|
30398
30775
|
getPositionsPlayedOff: getPositionsPlayedOff,
|
|
30399
30776
|
getPredictiveAccuracy: getPredictiveAccuracy,
|
|
30400
30777
|
getProfileRounds: getProfileRounds,
|
|
30778
|
+
getPublishState: getPublishState,
|
|
30401
30779
|
getRoundMatchUps: getRoundMatchUps,
|
|
30402
30780
|
getRounds: getRounds,
|
|
30403
30781
|
getScaleValues: getScaleValues,
|
|
@@ -30418,6 +30796,7 @@ var index$g = {
|
|
|
30418
30796
|
getTournamentStructures: getTournamentStructures,
|
|
30419
30797
|
getTournamentTimeItem: getTournamentTimeItem,
|
|
30420
30798
|
getValidGroupSizes: getValidGroupSizes,
|
|
30799
|
+
getVenueData: getVenueData,
|
|
30421
30800
|
getVenuesAndCourts: getVenuesAndCourts,
|
|
30422
30801
|
isAdHoc: isAdHoc,
|
|
30423
30802
|
isCompletedStructure: isCompletedStructure,
|
|
@@ -33792,7 +34171,7 @@ function parseScoreString({ tiebreakTo = 7, scoreString = '' }) {
|
|
|
33792
34171
|
}
|
|
33793
34172
|
}
|
|
33794
34173
|
|
|
33795
|
-
var query$
|
|
34174
|
+
var query$1 = {
|
|
33796
34175
|
__proto__: null,
|
|
33797
34176
|
analyzeSet: analyzeSet,
|
|
33798
34177
|
checkScoreHasValue: checkScoreHasValue,
|
|
@@ -33827,7 +34206,7 @@ var scoreGovernor = {
|
|
|
33827
34206
|
mutate: mutate$b,
|
|
33828
34207
|
parseMatchUpFormat: parse,
|
|
33829
34208
|
parseScoreString: parseScoreString,
|
|
33830
|
-
query: query$
|
|
34209
|
+
query: query$1,
|
|
33831
34210
|
redo: redo,
|
|
33832
34211
|
reverseScore: reverseScore,
|
|
33833
34212
|
setServingSide: setServingSide,
|
|
@@ -35858,7 +36237,7 @@ var mutate$a = {
|
|
|
35858
36237
|
removePolicy: removePolicy
|
|
35859
36238
|
};
|
|
35860
36239
|
|
|
35861
|
-
var query
|
|
36240
|
+
var query = {
|
|
35862
36241
|
__proto__: null,
|
|
35863
36242
|
findPolicy: findPolicy,
|
|
35864
36243
|
getAppliedPolicies: getAppliedPolicies,
|
|
@@ -35872,7 +36251,7 @@ var index$f = {
|
|
|
35872
36251
|
getAppliedPolicies: getAppliedPolicies,
|
|
35873
36252
|
getPolicyDefinitions: getPolicyDefinitions,
|
|
35874
36253
|
mutate: mutate$a,
|
|
35875
|
-
query: query
|
|
36254
|
+
query: query,
|
|
35876
36255
|
removePolicy: removePolicy
|
|
35877
36256
|
};
|
|
35878
36257
|
|
|
@@ -36861,7 +37240,7 @@ var index$d = {
|
|
|
36861
37240
|
mutate: mutate$9,
|
|
36862
37241
|
promoteAlternate: promoteAlternate,
|
|
36863
37242
|
promoteAlternates: promoteAlternates,
|
|
36864
|
-
query: query$
|
|
37243
|
+
query: query$5,
|
|
36865
37244
|
removeDrawEntries: removeDrawEntries,
|
|
36866
37245
|
removeEventEntries: removeEventEntries,
|
|
36867
37246
|
setEntryPosition: setEntryPosition,
|
|
@@ -36884,305 +37263,6 @@ function modifyEventPublishStatus({ removePriorValues = true, status = PUBLIC, s
|
|
|
36884
37263
|
});
|
|
36885
37264
|
}
|
|
36886
37265
|
|
|
36887
|
-
function getDrawIsPublished({ publishStatus, drawId }) {
|
|
36888
|
-
if (publishStatus?.drawDetails) {
|
|
36889
|
-
return publishStatus.drawDetails?.[drawId]?.publishingDetail?.published;
|
|
36890
|
-
}
|
|
36891
|
-
else if (publishStatus?.drawIds) {
|
|
36892
|
-
return publishStatus.drawIds.includes(drawId);
|
|
36893
|
-
}
|
|
36894
|
-
return true;
|
|
36895
|
-
}
|
|
36896
|
-
|
|
36897
|
-
function getDrawData(params) {
|
|
36898
|
-
const { tournamentParticipants = [], includePositionAssignments, policyDefinitions, tournamentRecord, inContext = true, usePublishState, status = PUBLIC, drawDefinition, noDeepCopy, sortConfig, context, event, } = params;
|
|
36899
|
-
if (!drawDefinition)
|
|
36900
|
-
return { error: MISSING_DRAW_DEFINITION };
|
|
36901
|
-
const drawInfo = (({ matchUpFormat, updatedAt, drawType, drawName, drawId }) => ({
|
|
36902
|
-
matchUpFormat,
|
|
36903
|
-
updatedAt,
|
|
36904
|
-
drawName,
|
|
36905
|
-
drawType,
|
|
36906
|
-
drawId,
|
|
36907
|
-
}))(drawDefinition);
|
|
36908
|
-
let mainStageSeedAssignments, qualificationStageSeedAssignments;
|
|
36909
|
-
const { allStructuresLinked, sourceStructureIds, hasDrawFeedProfile, structureGroups } = getStructureGroups({
|
|
36910
|
-
drawDefinition,
|
|
36911
|
-
});
|
|
36912
|
-
if (!allStructuresLinked)
|
|
36913
|
-
return { error: UNLINKED_STRUCTURES };
|
|
36914
|
-
const publishStatus = params?.publishStatus ?? getEventPublishStatus({ event, status });
|
|
36915
|
-
const eventPublished = params.eventPublished ?? !!getPublishState({ event }).publishState?.status?.published;
|
|
36916
|
-
let drawActive = false;
|
|
36917
|
-
let participantPlacements = false;
|
|
36918
|
-
const groupedStructures = structureGroups.map((structureIds) => {
|
|
36919
|
-
const completedStructures = {};
|
|
36920
|
-
const structures = structureIds
|
|
36921
|
-
.map((structureId) => {
|
|
36922
|
-
const { structure } = findStructure({ drawDefinition, structureId });
|
|
36923
|
-
const { seedAssignments } = getStructureSeedAssignments({
|
|
36924
|
-
drawDefinition,
|
|
36925
|
-
structure,
|
|
36926
|
-
});
|
|
36927
|
-
if (structure?.stage === MAIN && structure.stageSequence === 1) {
|
|
36928
|
-
mainStageSeedAssignments = seedAssignments;
|
|
36929
|
-
}
|
|
36930
|
-
if (structure?.stage === QUALIFYING && structure.stageSequence === 1) {
|
|
36931
|
-
qualificationStageSeedAssignments = seedAssignments;
|
|
36932
|
-
}
|
|
36933
|
-
return structure;
|
|
36934
|
-
})
|
|
36935
|
-
.sort((a, b) => structureSort(a, b, sortConfig))
|
|
36936
|
-
.map((structure) => {
|
|
36937
|
-
if (!structure)
|
|
36938
|
-
return;
|
|
36939
|
-
const structureId = structure?.structureId;
|
|
36940
|
-
let seedAssignments = [];
|
|
36941
|
-
if (structure.stage && [MAIN, CONSOLATION, PLAY_OFF].includes(structure.stage)) {
|
|
36942
|
-
seedAssignments = mainStageSeedAssignments;
|
|
36943
|
-
}
|
|
36944
|
-
if (structure?.stage === QUALIFYING) {
|
|
36945
|
-
seedAssignments = qualificationStageSeedAssignments;
|
|
36946
|
-
}
|
|
36947
|
-
const { matchUps, roundMatchUps, roundProfile } = getAllStructureMatchUps({
|
|
36948
|
-
seedAssignments: !structure?.seedAssignments?.length ? seedAssignments : undefined,
|
|
36949
|
-
context: { drawId: drawInfo.drawId, ...context },
|
|
36950
|
-
tournamentParticipants,
|
|
36951
|
-
policyDefinitions,
|
|
36952
|
-
tournamentRecord,
|
|
36953
|
-
usePublishState,
|
|
36954
|
-
publishStatus,
|
|
36955
|
-
drawDefinition,
|
|
36956
|
-
inContext,
|
|
36957
|
-
structure,
|
|
36958
|
-
event,
|
|
36959
|
-
});
|
|
36960
|
-
const { positionAssignments } = getPositionAssignments$1({
|
|
36961
|
-
structure,
|
|
36962
|
-
});
|
|
36963
|
-
let participantResults = positionAssignments?.filter(xa(PARTICIPANT_ID)).map((assignment) => {
|
|
36964
|
-
const { drawPosition, participantId } = assignment;
|
|
36965
|
-
const { extension } = findExtension({
|
|
36966
|
-
element: assignment,
|
|
36967
|
-
name: TALLY,
|
|
36968
|
-
});
|
|
36969
|
-
participantPlacements = true;
|
|
36970
|
-
return {
|
|
36971
|
-
participantResult: extension?.value,
|
|
36972
|
-
participantId,
|
|
36973
|
-
drawPosition,
|
|
36974
|
-
};
|
|
36975
|
-
});
|
|
36976
|
-
if (!participantResults?.length && matchUps.length && params.allParticipantResults) {
|
|
36977
|
-
const { subOrderMap } = createSubOrderMap({ positionAssignments });
|
|
36978
|
-
const result = tallyParticipantResults({
|
|
36979
|
-
matchUpFormat: structure.matchUpFormat,
|
|
36980
|
-
policyDefinitions,
|
|
36981
|
-
subOrderMap,
|
|
36982
|
-
matchUps,
|
|
36983
|
-
});
|
|
36984
|
-
participantResults = positionAssignments?.filter(xa(PARTICIPANT_ID)).map((assignment) => {
|
|
36985
|
-
const { drawPosition, participantId } = assignment;
|
|
36986
|
-
participantPlacements = true;
|
|
36987
|
-
return {
|
|
36988
|
-
participantResult: participantId && result.participantResults[participantId],
|
|
36989
|
-
participantId,
|
|
36990
|
-
drawPosition,
|
|
36991
|
-
};
|
|
36992
|
-
});
|
|
36993
|
-
}
|
|
36994
|
-
const structureInfo = structure
|
|
36995
|
-
? (({ stageSequence, structureName, structureType, matchUpFormat, stage }) => ({
|
|
36996
|
-
stageSequence,
|
|
36997
|
-
structureName,
|
|
36998
|
-
structureType,
|
|
36999
|
-
matchUpFormat,
|
|
37000
|
-
stage,
|
|
37001
|
-
}))(structure)
|
|
37002
|
-
: {};
|
|
37003
|
-
structureInfo.sourceStructureIds = sourceStructureIds[structureId];
|
|
37004
|
-
structureInfo.hasDrawFeedProfile = hasDrawFeedProfile[structureId];
|
|
37005
|
-
structureInfo.positionAssignments = positionAssignments;
|
|
37006
|
-
structureInfo.structureActive = matchUps.reduce((active, matchUp) => {
|
|
37007
|
-
const activeMatchUpStatus = [
|
|
37008
|
-
COMPLETED$1,
|
|
37009
|
-
CANCELLED$1,
|
|
37010
|
-
DEFAULTED,
|
|
37011
|
-
RETIRED$1,
|
|
37012
|
-
WALKOVER$2,
|
|
37013
|
-
IN_PROGRESS$1,
|
|
37014
|
-
DOUBLE_DEFAULT,
|
|
37015
|
-
DOUBLE_WALKOVER,
|
|
37016
|
-
].includes(matchUp.matchUpStatus);
|
|
37017
|
-
return active || activeMatchUpStatus || !!matchUp.winningSide || !!matchUp.score?.scoreStringSide1;
|
|
37018
|
-
}, false);
|
|
37019
|
-
const structureCompleted = matchUps.reduce((completed, matchUp) => {
|
|
37020
|
-
return completed && [BYE, COMPLETED$1, RETIRED$1, WALKOVER$2, DEFAULTED, ABANDONED$1].includes(matchUp.matchUpStatus);
|
|
37021
|
-
}, !!matchUps.length);
|
|
37022
|
-
structureInfo.structureCompleted = structureCompleted;
|
|
37023
|
-
completedStructures[structureId] = structureCompleted;
|
|
37024
|
-
if (structureInfo.structureActive)
|
|
37025
|
-
drawActive = true;
|
|
37026
|
-
return {
|
|
37027
|
-
...structureInfo,
|
|
37028
|
-
participantResults,
|
|
37029
|
-
seedAssignments,
|
|
37030
|
-
roundMatchUps,
|
|
37031
|
-
roundProfile,
|
|
37032
|
-
structureId,
|
|
37033
|
-
};
|
|
37034
|
-
});
|
|
37035
|
-
structures.forEach((structure) => {
|
|
37036
|
-
if (!includePositionAssignments)
|
|
37037
|
-
delete structure.positionAssignments;
|
|
37038
|
-
structure.sourceStructuresComplete = structure.sourceStructureIds?.every((id) => completedStructures[id]);
|
|
37039
|
-
});
|
|
37040
|
-
return structures;
|
|
37041
|
-
});
|
|
37042
|
-
const structures = groupedStructures.flat();
|
|
37043
|
-
drawInfo.drawActive = drawActive;
|
|
37044
|
-
drawInfo.participantPlacements = participantPlacements;
|
|
37045
|
-
drawInfo.drawGenerated = structures?.reduce((generated, structure) => {
|
|
37046
|
-
return generated || !!structure?.roundMatchUps;
|
|
37047
|
-
}, false);
|
|
37048
|
-
drawInfo.drawCompleted = structures?.reduce((completed, structure) => completed && structure.structureCompleted, true);
|
|
37049
|
-
drawInfo.drawPublished = usePublishState
|
|
37050
|
-
? eventPublished && getDrawIsPublished({ publishStatus, drawId: drawInfo.drawId })
|
|
37051
|
-
: undefined;
|
|
37052
|
-
return {
|
|
37053
|
-
structures: !usePublishState || drawInfo.drawPublished
|
|
37054
|
-
? noDeepCopy
|
|
37055
|
-
? structures
|
|
37056
|
-
: makeDeepCopy(structures, false, true)
|
|
37057
|
-
: undefined,
|
|
37058
|
-
drawInfo: noDeepCopy ? drawInfo : makeDeepCopy(drawInfo, false, true),
|
|
37059
|
-
...SUCCESS,
|
|
37060
|
-
};
|
|
37061
|
-
}
|
|
37062
|
-
|
|
37063
|
-
function getEventData(params) {
|
|
37064
|
-
const { includePositionAssignments, tournamentRecord: t, participantsProfile, policyDefinitions, usePublishState, status = PUBLIC, sortConfig, event: e, } = params;
|
|
37065
|
-
const tournamentRecord = makeDeepCopy(t, false, true);
|
|
37066
|
-
const event = makeDeepCopy(e, false, true);
|
|
37067
|
-
if (!tournamentRecord)
|
|
37068
|
-
return { error: MISSING_TOURNAMENT_RECORD };
|
|
37069
|
-
if (!event)
|
|
37070
|
-
return { error: MISSING_EVENT };
|
|
37071
|
-
const { eventId } = event;
|
|
37072
|
-
const { tournamentId, endDate } = tournamentRecord;
|
|
37073
|
-
const publishStatus = getEventPublishStatus({ event, status });
|
|
37074
|
-
const publishState = getPublishState({ event }).publishState ?? {};
|
|
37075
|
-
const eventPublished = !!publishState?.status?.published;
|
|
37076
|
-
const { participants: tournamentParticipants } = getParticipants({
|
|
37077
|
-
withGroupings: true,
|
|
37078
|
-
withEvents: false,
|
|
37079
|
-
withDraws: false,
|
|
37080
|
-
policyDefinitions,
|
|
37081
|
-
...participantsProfile,
|
|
37082
|
-
tournamentRecord,
|
|
37083
|
-
});
|
|
37084
|
-
const stageFilter = ({ stage, drawId }) => {
|
|
37085
|
-
if (!usePublishState)
|
|
37086
|
-
return true;
|
|
37087
|
-
const stageDetails = publishStatus?.drawDetails?.[drawId]?.stageDetails;
|
|
37088
|
-
if (!stageDetails || !Object.keys(stageDetails).length)
|
|
37089
|
-
return true;
|
|
37090
|
-
return stageDetails[stage]?.published;
|
|
37091
|
-
};
|
|
37092
|
-
const structureFilter = ({ structureId, drawId }) => {
|
|
37093
|
-
if (!usePublishState)
|
|
37094
|
-
return true;
|
|
37095
|
-
const structureDetails = publishStatus?.drawDetails?.[drawId]?.structureDetails;
|
|
37096
|
-
if (!structureDetails || !Object.keys(structureDetails).length)
|
|
37097
|
-
return true;
|
|
37098
|
-
return structureDetails[structureId]?.published;
|
|
37099
|
-
};
|
|
37100
|
-
const drawFilter = ({ drawId }) => (!usePublishState ? true : getDrawIsPublished({ publishStatus, drawId }));
|
|
37101
|
-
const roundLimitMapper = ({ drawId, structure }) => {
|
|
37102
|
-
if (!usePublishState)
|
|
37103
|
-
return structure;
|
|
37104
|
-
const roundLimit = publishStatus?.drawDetails?.[drawId]?.structureDetails?.[structure.structureId]?.roundLimit;
|
|
37105
|
-
if (isConvertableInteger(roundLimit)) {
|
|
37106
|
-
const roundNumbers = generateRange(1, roundLimit + 1);
|
|
37107
|
-
const roundMatchUps = {};
|
|
37108
|
-
const roundProfile = {};
|
|
37109
|
-
for (const roundNumber of roundNumbers) {
|
|
37110
|
-
if (structure.roundMatchUps[roundNumber]) {
|
|
37111
|
-
roundMatchUps[roundNumber] = structure.roundMatchUps[roundNumber];
|
|
37112
|
-
roundProfile[roundNumber] = structure.roundProfile[roundNumber];
|
|
37113
|
-
}
|
|
37114
|
-
}
|
|
37115
|
-
structure.roundMatchUps = roundMatchUps;
|
|
37116
|
-
structure.roundProfile = roundProfile;
|
|
37117
|
-
}
|
|
37118
|
-
return structure;
|
|
37119
|
-
};
|
|
37120
|
-
const drawDefinitions = event.drawDefinitions || [];
|
|
37121
|
-
const drawsData = !usePublishState || eventPublished
|
|
37122
|
-
? drawDefinitions
|
|
37123
|
-
.filter(drawFilter)
|
|
37124
|
-
.map((drawDefinition) => (({ drawInfo, structures }) => ({
|
|
37125
|
-
...drawInfo,
|
|
37126
|
-
structures,
|
|
37127
|
-
}))(getDrawData({
|
|
37128
|
-
allParticipantResults: params.allParticipantResults,
|
|
37129
|
-
context: { eventId, tournamentId, endDate },
|
|
37130
|
-
includePositionAssignments,
|
|
37131
|
-
tournamentParticipants,
|
|
37132
|
-
noDeepCopy: true,
|
|
37133
|
-
policyDefinitions,
|
|
37134
|
-
tournamentRecord,
|
|
37135
|
-
usePublishState,
|
|
37136
|
-
drawDefinition,
|
|
37137
|
-
publishStatus,
|
|
37138
|
-
sortConfig,
|
|
37139
|
-
event,
|
|
37140
|
-
})))
|
|
37141
|
-
.map(({ structures, ...drawData }) => {
|
|
37142
|
-
const filteredStructures = structures
|
|
37143
|
-
?.filter(({ stage, structureId }) => structureFilter({ structureId, drawId: drawData.drawId }) &&
|
|
37144
|
-
stageFilter({ stage, drawId: drawData.drawId }))
|
|
37145
|
-
.map((structure) => roundLimitMapper({ drawId: drawData.drawId, structure }));
|
|
37146
|
-
return {
|
|
37147
|
-
...drawData,
|
|
37148
|
-
structures: filteredStructures,
|
|
37149
|
-
};
|
|
37150
|
-
})
|
|
37151
|
-
.filter((drawData) => drawData.structures?.length)
|
|
37152
|
-
: undefined;
|
|
37153
|
-
const { tournamentInfo } = getTournamentInfo({ tournamentRecord });
|
|
37154
|
-
const venues = tournamentRecord.venues || [];
|
|
37155
|
-
const venuesData = venues.map((venue) => (({ venueData }) => ({
|
|
37156
|
-
...venueData,
|
|
37157
|
-
}))(getVenueData({
|
|
37158
|
-
tournamentRecord,
|
|
37159
|
-
venueId: venue.venueId,
|
|
37160
|
-
})));
|
|
37161
|
-
const eventInfo = (({ eventId, eventName, eventType, eventLevel, surfaceCategory, matchUpFormat, category, gender, startDate, endDate, ballType, discipline, }) => ({
|
|
37162
|
-
eventId,
|
|
37163
|
-
eventName,
|
|
37164
|
-
eventType,
|
|
37165
|
-
eventLevel,
|
|
37166
|
-
surfaceCategory,
|
|
37167
|
-
matchUpFormat,
|
|
37168
|
-
category,
|
|
37169
|
-
gender,
|
|
37170
|
-
startDate,
|
|
37171
|
-
endDate,
|
|
37172
|
-
ballType,
|
|
37173
|
-
discipline,
|
|
37174
|
-
}))(event);
|
|
37175
|
-
const eventData = {
|
|
37176
|
-
tournamentInfo,
|
|
37177
|
-
venuesData,
|
|
37178
|
-
eventInfo,
|
|
37179
|
-
drawsData,
|
|
37180
|
-
};
|
|
37181
|
-
eventData.eventInfo.publishState = publishState;
|
|
37182
|
-
eventData.eventInfo.published = publishState?.status?.published;
|
|
37183
|
-
return { ...SUCCESS, eventData, participants: tournamentParticipants };
|
|
37184
|
-
}
|
|
37185
|
-
|
|
37186
37266
|
function publishEvent(params) {
|
|
37187
37267
|
const { includePositionAssignments, removePriorValues, tournamentRecord, status = PUBLIC, event, drawIdsToRemove, drawIdsToAdd, } = params;
|
|
37188
37268
|
if (!tournamentRecord)
|
|
@@ -38731,7 +38811,6 @@ var index$c = {
|
|
|
38731
38811
|
addFlight: addFlight,
|
|
38732
38812
|
assignSeedPositions: assignSeedPositions,
|
|
38733
38813
|
attachFlightProfile: attachFlightProfile,
|
|
38734
|
-
bulkUpdatePublishedEventIds: bulkUpdatePublishedEventIds,
|
|
38735
38814
|
categoryCanContain: categoryCanContain,
|
|
38736
38815
|
deleteDrawDefinitions: deleteDrawDefinitions,
|
|
38737
38816
|
deleteEvents: deleteEvents,
|
|
@@ -38749,7 +38828,7 @@ var index$c = {
|
|
|
38749
38828
|
modifyEventMatchUpFormatTiming: modifyEventMatchUpFormatTiming,
|
|
38750
38829
|
modifyPairAssignment: modifyPairAssignment,
|
|
38751
38830
|
mutate: mutate$8,
|
|
38752
|
-
query: query$
|
|
38831
|
+
query: query$2,
|
|
38753
38832
|
refreshEventDrawOrder: refreshEventDrawOrder,
|
|
38754
38833
|
removeEventMatchUpFormatTiming: removeEventMatchUpFormatTiming,
|
|
38755
38834
|
removeScaleValues: removeScaleValues,
|
|
@@ -43948,7 +44027,7 @@ var index$9 = {
|
|
|
43948
44027
|
matchUpActions: matchUpActions,
|
|
43949
44028
|
mutate: mutate$7,
|
|
43950
44029
|
participantScheduledMatchUps: participantScheduledMatchUps,
|
|
43951
|
-
query: query$
|
|
44030
|
+
query: query$4,
|
|
43952
44031
|
removeDelegatedOutcome: removeDelegatedOutcome,
|
|
43953
44032
|
removeMatchUpSideParticipant: removeMatchUpSideParticipant,
|
|
43954
44033
|
removeTieMatchUpParticipantId: removeTieMatchUpParticipantId,
|
|
@@ -45537,22 +45616,40 @@ function clearSchedules({ scheduleAttributes = ['scheduledDate', 'scheduledTime'
|
|
|
45537
45616
|
matchUpFilters: { scheduledDates },
|
|
45538
45617
|
tournamentRecord,
|
|
45539
45618
|
}).matchUps ?? [];
|
|
45540
|
-
const
|
|
45541
|
-
|
|
45542
|
-
!ignoreMatchUpStatuses.includes(
|
|
45543
|
-
|
|
45544
|
-
|
|
45545
|
-
|
|
45546
|
-
|
|
45547
|
-
|
|
45548
|
-
|
|
45549
|
-
})
|
|
45619
|
+
const drawMatchUpIds = {};
|
|
45620
|
+
inContextMatchUps.forEach(({ matchUpStatus, schedule, drawId, matchUpId }) => {
|
|
45621
|
+
if ((!matchUpStatus || !ignoreMatchUpStatuses.includes(matchUpStatus)) &&
|
|
45622
|
+
hasSchedule({ schedule, scheduleAttributes }) &&
|
|
45623
|
+
(!venueIds?.length || venueIds.includes(schedule.venueId))) {
|
|
45624
|
+
if (!drawMatchUpIds[drawId])
|
|
45625
|
+
drawMatchUpIds[drawId] = [];
|
|
45626
|
+
drawMatchUpIds[drawId].push(matchUpId);
|
|
45627
|
+
}
|
|
45628
|
+
});
|
|
45629
|
+
const tournamentId = tournamentRecord.tournamentId;
|
|
45550
45630
|
let clearedScheduleCount = 0;
|
|
45551
|
-
for (const
|
|
45552
|
-
|
|
45553
|
-
|
|
45554
|
-
|
|
45555
|
-
|
|
45631
|
+
for (const drawId in drawMatchUpIds) {
|
|
45632
|
+
const { event, drawDefinition } = findEvent({ tournamentRecord, drawId });
|
|
45633
|
+
const drawMatchUps = allDrawMatchUps({ drawDefinition, matchUpFilters: { matchUpIds: drawMatchUpIds[drawId] } }).matchUps ?? [];
|
|
45634
|
+
for (const matchUp of drawMatchUps) {
|
|
45635
|
+
let modified = false;
|
|
45636
|
+
matchUp.timeItems = (matchUp.timeItems ?? []).filter((timeItem) => {
|
|
45637
|
+
const preserve = timeItem?.itemType &&
|
|
45638
|
+
![ALLOCATE_COURTS, ASSIGN_COURT, ASSIGN_VENUE, SCHEDULED_DATE, SCHEDULED_TIME].includes(timeItem?.itemType);
|
|
45639
|
+
if (!preserve)
|
|
45640
|
+
modified = true;
|
|
45641
|
+
return preserve;
|
|
45642
|
+
});
|
|
45643
|
+
if (modified) {
|
|
45644
|
+
modifyMatchUpNotice({
|
|
45645
|
+
context: 'clear schedules',
|
|
45646
|
+
eventId: event?.eventId,
|
|
45647
|
+
drawDefinition,
|
|
45648
|
+
tournamentId,
|
|
45649
|
+
matchUp,
|
|
45650
|
+
});
|
|
45651
|
+
clearedScheduleCount += 1;
|
|
45652
|
+
}
|
|
45556
45653
|
}
|
|
45557
45654
|
}
|
|
45558
45655
|
return { ...SUCCESS, clearedScheduleCount };
|
|
@@ -50684,73 +50781,6 @@ var mutate$4 = {
|
|
|
50684
50781
|
unPublishOrderOfPlay: unPublishOrderOfPlay
|
|
50685
50782
|
};
|
|
50686
50783
|
|
|
50687
|
-
function getAllEventData({ tournamentRecord, policyDefinitions }) {
|
|
50688
|
-
if (!tournamentRecord)
|
|
50689
|
-
return { error: MISSING_TOURNAMENT_RECORD };
|
|
50690
|
-
const events = tournamentRecord.events || [];
|
|
50691
|
-
const tournamentParticipants = tournamentRecord?.participants || [];
|
|
50692
|
-
const { tournamentInfo } = getTournamentInfo({ tournamentRecord });
|
|
50693
|
-
const { venues: venuesData } = getVenuesAndCourts({
|
|
50694
|
-
tournamentRecord,
|
|
50695
|
-
});
|
|
50696
|
-
const eventsData = events.map((event) => {
|
|
50697
|
-
const { eventId } = event;
|
|
50698
|
-
const eventInfo = extractEventInfo({ event }).eventInfo;
|
|
50699
|
-
const scheduleTiming = getScheduleTiming({
|
|
50700
|
-
tournamentRecord,
|
|
50701
|
-
event,
|
|
50702
|
-
}).scheduleTiming;
|
|
50703
|
-
const drawsData = (event.drawDefinitions || []).map((drawDefinition) => {
|
|
50704
|
-
const drawInfo = (({ drawId, drawName, matchUpFormat, updatedAt }) => ({
|
|
50705
|
-
matchUpFormat,
|
|
50706
|
-
updatedAt,
|
|
50707
|
-
drawName,
|
|
50708
|
-
drawId,
|
|
50709
|
-
}))(drawDefinition);
|
|
50710
|
-
const { abandonedMatchUps, completedMatchUps, upcomingMatchUps, pendingMatchUps } = getDrawMatchUps({
|
|
50711
|
-
requireParticipants: true,
|
|
50712
|
-
tournamentParticipants,
|
|
50713
|
-
context: { eventId },
|
|
50714
|
-
policyDefinitions,
|
|
50715
|
-
tournamentRecord,
|
|
50716
|
-
inContext: true,
|
|
50717
|
-
scheduleTiming,
|
|
50718
|
-
drawDefinition,
|
|
50719
|
-
event,
|
|
50720
|
-
});
|
|
50721
|
-
return {
|
|
50722
|
-
drawInfo,
|
|
50723
|
-
matchUps: {
|
|
50724
|
-
abandonedMatchUps,
|
|
50725
|
-
completedMatchUps,
|
|
50726
|
-
upcomingMatchUps,
|
|
50727
|
-
pendingMatchUps,
|
|
50728
|
-
},
|
|
50729
|
-
};
|
|
50730
|
-
});
|
|
50731
|
-
const publish = getEventPublishStatus({ event });
|
|
50732
|
-
Object.assign(eventInfo, {
|
|
50733
|
-
drawsData,
|
|
50734
|
-
publish,
|
|
50735
|
-
});
|
|
50736
|
-
return eventInfo;
|
|
50737
|
-
});
|
|
50738
|
-
const allEventData = { tournamentInfo, venuesData, eventsData };
|
|
50739
|
-
return { allEventData };
|
|
50740
|
-
}
|
|
50741
|
-
|
|
50742
|
-
var query = {
|
|
50743
|
-
__proto__: null,
|
|
50744
|
-
bulkUpdatePublishedEventIds: bulkUpdatePublishedEventIds,
|
|
50745
|
-
getAllEventData: getAllEventData,
|
|
50746
|
-
getCourtInfo: getCourtInfo,
|
|
50747
|
-
getDrawData: getDrawData,
|
|
50748
|
-
getEventData: getEventData,
|
|
50749
|
-
getEventPublishStatus: getEventPublishStatus,
|
|
50750
|
-
getPublishState: getPublishState,
|
|
50751
|
-
getVenueData: getVenueData
|
|
50752
|
-
};
|
|
50753
|
-
|
|
50754
50784
|
var index$7 = {
|
|
50755
50785
|
__proto__: null,
|
|
50756
50786
|
bulkUpdatePublishedEventIds: bulkUpdatePublishedEventIds,
|
|
@@ -50765,7 +50795,7 @@ var index$7 = {
|
|
|
50765
50795
|
publishEvent: publishEvent,
|
|
50766
50796
|
publishEventSeeding: publishEventSeeding,
|
|
50767
50797
|
publishOrderOfPlay: publishOrderOfPlay,
|
|
50768
|
-
query: query,
|
|
50798
|
+
query: query$7,
|
|
50769
50799
|
setEventDisplay: setEventDisplay,
|
|
50770
50800
|
unPublishEvent: unPublishEvent,
|
|
50771
50801
|
unPublishEventSeeding: unPublishEventSeeding,
|
|
@@ -52663,7 +52693,7 @@ var index$5 = {
|
|
|
52663
52693
|
proAutoSchedule: proAutoSchedule,
|
|
52664
52694
|
proConflicts: proConflicts,
|
|
52665
52695
|
publicFindCourt: publicFindCourt,
|
|
52666
|
-
query: query$
|
|
52696
|
+
query: query$6,
|
|
52667
52697
|
removeEventMatchUpFormatTiming: removeEventMatchUpFormatTiming,
|
|
52668
52698
|
removeMatchUpCourtAssignment: removeMatchUpCourtAssignment,
|
|
52669
52699
|
reorderUpcomingMatchUps: reorderUpcomingMatchUps,
|
|
@@ -54490,13 +54520,18 @@ function updateCourtAvailability({ tournamentRecord }) {
|
|
|
54490
54520
|
return { ...SUCCESS };
|
|
54491
54521
|
}
|
|
54492
54522
|
|
|
54493
|
-
function setTournamentDates(
|
|
54494
|
-
|
|
54495
|
-
|
|
54496
|
-
|
|
54497
|
-
|
|
54498
|
-
|
|
54499
|
-
|
|
54523
|
+
function setTournamentDates(params) {
|
|
54524
|
+
const { tournamentRecord, startDate, endDate } = params;
|
|
54525
|
+
const paramsCheck = checkRequiredParameters(params, [
|
|
54526
|
+
{ tournamentRecord: true },
|
|
54527
|
+
{
|
|
54528
|
+
[ANY_OF]: { startDate: false, endDate: false },
|
|
54529
|
+
[INVALID]: INVALID_DATE,
|
|
54530
|
+
[VALIDATE]: (value) => dateValidation.test(value),
|
|
54531
|
+
},
|
|
54532
|
+
]);
|
|
54533
|
+
if (paramsCheck.error)
|
|
54534
|
+
return paramsCheck;
|
|
54500
54535
|
if (endDate && startDate && new Date(endDate) < new Date(startDate))
|
|
54501
54536
|
return { error: INVALID_VALUES };
|
|
54502
54537
|
let checkScheduling;
|
|
@@ -54504,10 +54539,20 @@ function setTournamentDates({ tournamentRecord, startDate, endDate }) {
|
|
|
54504
54539
|
(endDate && tournamentRecord.endDate && new Date(endDate) < new Date(tournamentRecord.endDate))) {
|
|
54505
54540
|
checkScheduling = true;
|
|
54506
54541
|
}
|
|
54542
|
+
const initialDateRange = generateDateRange(tournamentRecord.startDate, tournamentRecord.endDate);
|
|
54507
54543
|
if (startDate)
|
|
54508
54544
|
tournamentRecord.startDate = startDate;
|
|
54509
54545
|
if (endDate)
|
|
54510
54546
|
tournamentRecord.endDate = endDate;
|
|
54547
|
+
const resultingDateRange = generateDateRange(tournamentRecord.startDate, tournamentRecord.endDate);
|
|
54548
|
+
const datesRemoved = initialDateRange.filter((date) => !resultingDateRange.includes(date));
|
|
54549
|
+
const datesAdded = resultingDateRange.filter((date) => !initialDateRange.includes(date));
|
|
54550
|
+
for (const event of tournamentRecord.events ?? []) {
|
|
54551
|
+
if (startDate && event.startDate && new Date(startDate) > new Date(event.startDate))
|
|
54552
|
+
event.startDate = startDate;
|
|
54553
|
+
if (endDate && event.endDate && new Date(endDate) < new Date(event.endDate))
|
|
54554
|
+
event.endDate = endDate;
|
|
54555
|
+
}
|
|
54511
54556
|
if (startDate && tournamentRecord.endDate && new Date(startDate) > new Date(tournamentRecord.endDate)) {
|
|
54512
54557
|
tournamentRecord.endDate = startDate;
|
|
54513
54558
|
}
|
|
@@ -54520,7 +54565,7 @@ function setTournamentDates({ tournamentRecord, startDate, endDate }) {
|
|
|
54520
54565
|
topic: MODIFY_TOURNAMENT_DETAIL,
|
|
54521
54566
|
payload: { startDate, endDate },
|
|
54522
54567
|
});
|
|
54523
|
-
return { ...SUCCESS, unscheduledMatchUpIds };
|
|
54568
|
+
return { ...SUCCESS, unscheduledMatchUpIds, datesAdded, datesRemoved };
|
|
54524
54569
|
}
|
|
54525
54570
|
function setTournamentStartDate({ tournamentRecord, startDate }) {
|
|
54526
54571
|
return setTournamentDates({ tournamentRecord, startDate });
|
|
@@ -55333,7 +55378,7 @@ var index$2 = {
|
|
|
55333
55378
|
modifyVenue: modifyVenue,
|
|
55334
55379
|
mutate: mutate,
|
|
55335
55380
|
publicFindVenue: publicFindVenue,
|
|
55336
|
-
query: query$
|
|
55381
|
+
query: query$3
|
|
55337
55382
|
};
|
|
55338
55383
|
|
|
55339
55384
|
var governors = {
|