tods-competition-factory 0.97.0 → 0.99.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/tods-competition-factory.development.cjs.js +227 -105
- package/dist/tods-competition-factory.development.cjs.js.map +1 -1
- package/dist/tods-competition-factory.production.cjs.min.js +1 -1
- package/dist/tods-competition-factory.production.cjs.min.js.map +1 -1
- package/dist/tods-competition-factory.production.esm.min.js +1 -1
- package/dist/tods-competition-factory.production.esm.min.js.map +1 -1
- package/package.json +4 -4
|
@@ -249,7 +249,7 @@ const matchUpFormatCode = {
|
|
|
249
249
|
};
|
|
250
250
|
|
|
251
251
|
function factoryVersion() {
|
|
252
|
-
return '0.
|
|
252
|
+
return '0.99.0';
|
|
253
253
|
}
|
|
254
254
|
|
|
255
255
|
const FORMAT_STANDARD = 'SET3-S:6/TB7'; // Best of 3 Tiebreak Sets to 6
|
|
@@ -20740,8 +20740,10 @@ function swapWinnerLoser(params) {
|
|
|
20740
20740
|
function setMatchUpStatus$2(params) {
|
|
20741
20741
|
var _inContextMatchUp$dra, _matchUp$sides;
|
|
20742
20742
|
|
|
20743
|
-
//
|
|
20743
|
+
// always clear score if DOUBLE_WALKOVER or WALKOVER
|
|
20744
|
+
if ([WALKOVER$1, DOUBLE_WALKOVER].includes(params.matchUpStatus)) params.score = undefined; // matchUpStatus in params is the new status
|
|
20744
20745
|
// winningSide in params is new winningSide
|
|
20746
|
+
|
|
20745
20747
|
const {
|
|
20746
20748
|
allowChangePropagation = undefined,
|
|
20747
20749
|
// factory default
|
|
@@ -22412,7 +22414,7 @@ function addDrawDefinition$1({
|
|
|
22412
22414
|
drawDefinition,
|
|
22413
22415
|
event
|
|
22414
22416
|
}) {
|
|
22415
|
-
var _flightProfile$flight, _flightProfile$flight2, _flightProfile$flight3, _event$drawDefinition, _flightProfile$flight4;
|
|
22417
|
+
var _flightProfile$flight, _flightProfile$links, _flightProfile$links$, _flightProfile$links$2, _flightProfile$flight2, _flightProfile$flight3, _event$drawDefinition, _flightProfile$flight4;
|
|
22416
22418
|
|
|
22417
22419
|
if (!drawDefinition) return {
|
|
22418
22420
|
error: MISSING_DRAW_ID
|
|
@@ -22443,33 +22445,53 @@ function addDrawDefinition$1({
|
|
|
22443
22445
|
} = getFlightProfile({
|
|
22444
22446
|
event
|
|
22445
22447
|
});
|
|
22446
|
-
const relevantFlight = flightDefinition && (flightProfile === null || flightProfile === void 0 ? void 0 : (_flightProfile$flight = flightProfile.flights) === null || _flightProfile$flight === void 0 ? void 0 : _flightProfile$flight.find(flight => flight.flightNumber === flightDefinition.flightNumber));
|
|
22448
|
+
const relevantFlight = flightDefinition && (flightProfile === null || flightProfile === void 0 ? void 0 : (_flightProfile$flight = flightProfile.flights) === null || _flightProfile$flight === void 0 ? void 0 : _flightProfile$flight.find(flight => flight.flightNumber === flightDefinition.flightNumber)); // if there is a source drawId specified, the source draw must exist
|
|
22449
|
+
|
|
22450
|
+
const sourceDrawId = flightProfile === null || flightProfile === void 0 ? void 0 : (_flightProfile$links = flightProfile.links) === null || _flightProfile$links === void 0 ? void 0 : (_flightProfile$links$ = _flightProfile$links.find(link => {
|
|
22451
|
+
var _link$target;
|
|
22452
|
+
|
|
22453
|
+
return (link === null || link === void 0 ? void 0 : (_link$target = link.target) === null || _link$target === void 0 ? void 0 : _link$target.drawId) === drawId;
|
|
22454
|
+
})) === null || _flightProfile$links$ === void 0 ? void 0 : (_flightProfile$links$2 = _flightProfile$links$.source) === null || _flightProfile$links$2 === void 0 ? void 0 : _flightProfile$links$2.drawId;
|
|
22455
|
+
const sourceDrawIdError = sourceDrawId && !event.drawDefinitions.find(drawDefinition => drawDefinition.drawId === sourceDrawId);
|
|
22456
|
+
if (sourceDrawIdError) return {
|
|
22457
|
+
error: MISSING_DRAW_DEFINITION,
|
|
22458
|
+
sourceDrawId
|
|
22459
|
+
};
|
|
22447
22460
|
const flightConflict = relevantFlight && relevantFlight.drawId !== drawDefinition.drawId;
|
|
22448
|
-
|
|
22449
|
-
|
|
22450
|
-
|
|
22451
|
-
|
|
22461
|
+
|
|
22462
|
+
if (flightConflict) {
|
|
22463
|
+
return {
|
|
22464
|
+
error: INVALID_DRAW_DEFINITION,
|
|
22465
|
+
relevantFlight
|
|
22466
|
+
};
|
|
22467
|
+
} // check relevantFlight.drawEntries are equivalent to drawEntries
|
|
22468
|
+
|
|
22452
22469
|
|
|
22453
22470
|
const matchingFlighEntries = relevantFlight === null || relevantFlight === void 0 ? void 0 : relevantFlight.drawEntries.every(({
|
|
22454
22471
|
participantId,
|
|
22455
22472
|
entryStatus
|
|
22456
22473
|
}) => {
|
|
22457
22474
|
const drawEntry = drawEntries.find(drawEntry => drawEntry && drawEntry.participantId === participantId);
|
|
22458
|
-
return (drawEntry === null || drawEntry === void 0 ? void 0 : drawEntry.entryStatus) === entryStatus;
|
|
22475
|
+
return !entryStatus || (drawEntry === null || drawEntry === void 0 ? void 0 : drawEntry.entryStatus) === entryStatus;
|
|
22459
22476
|
}); // check that all drawEntries have equivalent entryStatus to event.entries
|
|
22460
22477
|
|
|
22461
22478
|
const matchingEventEntries = !checkEntryStatus || eventEntries && (drawEntries === null || drawEntries === void 0 ? void 0 : drawEntries.every(({
|
|
22462
22479
|
participantId,
|
|
22463
|
-
entryStatus
|
|
22480
|
+
entryStatus,
|
|
22481
|
+
entryStage
|
|
22464
22482
|
}) => {
|
|
22465
22483
|
const eventEntry = eventEntries.find(eventEntry => eventEntry.participantId === participantId);
|
|
22466
|
-
|
|
22484
|
+
const isVoluntaryConsolation = (relevantFlight === null || relevantFlight === void 0 ? void 0 : relevantFlight.stage) === VOLUNTARY_CONSOLATION && entryStage === VOLUNTARY_CONSOLATION;
|
|
22485
|
+
return isVoluntaryConsolation || (eventEntry === null || eventEntry === void 0 ? void 0 : eventEntry.entryStatus) === entryStatus;
|
|
22467
22486
|
}));
|
|
22468
|
-
|
|
22469
|
-
|
|
22470
|
-
|
|
22471
|
-
|
|
22472
|
-
|
|
22487
|
+
|
|
22488
|
+
if (relevantFlight && !matchingFlighEntries) {
|
|
22489
|
+
return {
|
|
22490
|
+
error: INVALID_DRAW_DEFINITION,
|
|
22491
|
+
relevantFlight,
|
|
22492
|
+
matchingEventEntries
|
|
22493
|
+
};
|
|
22494
|
+
}
|
|
22473
22495
|
|
|
22474
22496
|
if (modifyEventEntries) {
|
|
22475
22497
|
drawEntries.filter(Boolean).forEach(drawEntry => {
|
|
@@ -33558,7 +33580,6 @@ function generateVoluntaryConsolationStructure$1({
|
|
|
33558
33580
|
drawSize,
|
|
33559
33581
|
event
|
|
33560
33582
|
}) {
|
|
33561
|
-
const stage = VOLUNTARY_CONSOLATION;
|
|
33562
33583
|
if (!drawDefinition) return {
|
|
33563
33584
|
error: MISSING_DRAW_DEFINITION
|
|
33564
33585
|
};
|
|
@@ -33569,13 +33590,14 @@ function generateVoluntaryConsolationStructure$1({
|
|
|
33569
33590
|
matchUpType,
|
|
33570
33591
|
drawSize
|
|
33571
33592
|
});
|
|
33593
|
+
const stage = VOLUNTARY_CONSOLATION;
|
|
33572
33594
|
const structure = structureTemplate({
|
|
33573
|
-
stage,
|
|
33574
|
-
matchUps,
|
|
33575
|
-
matchUpType,
|
|
33576
|
-
structureName,
|
|
33577
33595
|
structureAbbreviation,
|
|
33578
|
-
|
|
33596
|
+
structureName,
|
|
33597
|
+
structureId,
|
|
33598
|
+
matchUpType,
|
|
33599
|
+
matchUps,
|
|
33600
|
+
stage
|
|
33579
33601
|
});
|
|
33580
33602
|
drawDefinition.structures.push(structure);
|
|
33581
33603
|
|
|
@@ -35576,6 +35598,7 @@ function generateDrawType(params = {}) {
|
|
|
35576
35598
|
// optional - specifies main structure FEED_IN for drawTypes CURTIS_CONSOLATION, FEED_IN_CHAMPIONSHIPS, FMLC
|
|
35577
35599
|
structureName,
|
|
35578
35600
|
goesTo = true,
|
|
35601
|
+
stage = MAIN,
|
|
35579
35602
|
isMock,
|
|
35580
35603
|
uuids
|
|
35581
35604
|
} = params;
|
|
@@ -35593,12 +35616,20 @@ function generateDrawType(params = {}) {
|
|
|
35593
35616
|
stage: MAIN
|
|
35594
35617
|
});
|
|
35595
35618
|
|
|
35596
|
-
if (
|
|
35619
|
+
if (stage === VOLUNTARY_CONSOLATION) {
|
|
35597
35620
|
setStageDrawSize({
|
|
35598
35621
|
drawSize: params.drawSize,
|
|
35599
35622
|
drawDefinition,
|
|
35600
|
-
stage
|
|
35623
|
+
stage
|
|
35601
35624
|
});
|
|
35625
|
+
} else {
|
|
35626
|
+
if (!mainStageDrawPositionsCount) {
|
|
35627
|
+
setStageDrawSize({
|
|
35628
|
+
drawSize: params.drawSize,
|
|
35629
|
+
drawDefinition,
|
|
35630
|
+
stage: MAIN
|
|
35631
|
+
});
|
|
35632
|
+
}
|
|
35602
35633
|
} // first generate any qualifying structures
|
|
35603
35634
|
|
|
35604
35635
|
|
|
@@ -35672,7 +35703,7 @@ function generateDrawType(params = {}) {
|
|
|
35672
35703
|
} = getDrawStructures({
|
|
35673
35704
|
drawDefinition,
|
|
35674
35705
|
stageSequence,
|
|
35675
|
-
stage
|
|
35706
|
+
stage
|
|
35676
35707
|
});
|
|
35677
35708
|
const structureCount = stageStructures.length;
|
|
35678
35709
|
if (structureCount >= sequenceLimit) return {
|
|
@@ -35687,7 +35718,7 @@ function generateDrawType(params = {}) {
|
|
|
35687
35718
|
stageSequence,
|
|
35688
35719
|
matchUps: [],
|
|
35689
35720
|
matchUpType,
|
|
35690
|
-
stage
|
|
35721
|
+
stage
|
|
35691
35722
|
});
|
|
35692
35723
|
drawDefinition.structures.push(structure);
|
|
35693
35724
|
return Object.assign({
|
|
@@ -35703,8 +35734,8 @@ function generateDrawType(params = {}) {
|
|
|
35703
35734
|
structureId: uuids === null || uuids === void 0 ? void 0 : uuids.pop(),
|
|
35704
35735
|
stageSequence,
|
|
35705
35736
|
matchUpType,
|
|
35706
|
-
|
|
35707
|
-
|
|
35737
|
+
matchUps,
|
|
35738
|
+
stage
|
|
35708
35739
|
});
|
|
35709
35740
|
drawDefinition.structures.push(structure);
|
|
35710
35741
|
return Object.assign({
|
|
@@ -35720,8 +35751,8 @@ function generateDrawType(params = {}) {
|
|
|
35720
35751
|
structureId: uuids === null || uuids === void 0 ? void 0 : uuids.pop(),
|
|
35721
35752
|
stageSequence,
|
|
35722
35753
|
matchUpType,
|
|
35723
|
-
|
|
35724
|
-
|
|
35754
|
+
matchUps,
|
|
35755
|
+
stage
|
|
35725
35756
|
});
|
|
35726
35757
|
drawDefinition.structures.push(structure);
|
|
35727
35758
|
return Object.assign({
|
|
@@ -37107,6 +37138,7 @@ function addDrawEntry({
|
|
|
37107
37138
|
stage: entryStage,
|
|
37108
37139
|
drawDefinition
|
|
37109
37140
|
})) {
|
|
37141
|
+
console.log(drawDefinition.extensions[0]);
|
|
37110
37142
|
return {
|
|
37111
37143
|
error: INVALID_STAGE
|
|
37112
37144
|
};
|
|
@@ -45893,8 +45925,10 @@ function deleteDrawDefinitions({
|
|
|
45893
45925
|
});
|
|
45894
45926
|
}
|
|
45895
45927
|
|
|
45896
|
-
|
|
45897
|
-
|
|
45928
|
+
drawIds.forEach(drawId => {
|
|
45929
|
+
deleteDrawNotice({
|
|
45930
|
+
drawId
|
|
45931
|
+
});
|
|
45898
45932
|
});
|
|
45899
45933
|
return SUCCESS;
|
|
45900
45934
|
}
|
|
@@ -47201,12 +47235,102 @@ function generateVoluntaryConsolationStructure(params) {
|
|
|
47201
47235
|
});
|
|
47202
47236
|
}
|
|
47203
47237
|
|
|
47238
|
+
/**
|
|
47239
|
+
*
|
|
47240
|
+
* @param {object} orderedDrawIdsMap - required - mapping of ALL present drawIds => { [drawId]: drawOrder }
|
|
47241
|
+
*/
|
|
47242
|
+
|
|
47243
|
+
function updateDrawIdsOrder({
|
|
47244
|
+
event,
|
|
47245
|
+
orderedDrawIdsMap
|
|
47246
|
+
}) {
|
|
47247
|
+
var _event$drawDefinition, _flightProfile$flight;
|
|
47248
|
+
|
|
47249
|
+
if (typeof event !== 'object') return {
|
|
47250
|
+
error: MISSING_EVENT
|
|
47251
|
+
};
|
|
47252
|
+
if (!orderedDrawIdsMap) return {
|
|
47253
|
+
error: MISSING_VALUE,
|
|
47254
|
+
message: 'Missing drawIdsOrderMap'
|
|
47255
|
+
};
|
|
47256
|
+
if (typeof orderedDrawIdsMap !== 'object') return {
|
|
47257
|
+
error: INVALID_VALUES,
|
|
47258
|
+
message: 'orderedDrawIdsMap must be an object'
|
|
47259
|
+
};
|
|
47260
|
+
const drawOrders = Object.values(orderedDrawIdsMap);
|
|
47261
|
+
const validDrawOrders = drawOrders.every(drawOrder => !isNaN(drawOrder));
|
|
47262
|
+
if (!validDrawOrders) return {
|
|
47263
|
+
error: INVALID_VALUES,
|
|
47264
|
+
message: 'drawOrder must be numeric'
|
|
47265
|
+
};
|
|
47266
|
+
if (unique(drawOrders).length !== drawOrders.length) return {
|
|
47267
|
+
error: INVALID_VALUES,
|
|
47268
|
+
message: 'drawOrder values must be unique'
|
|
47269
|
+
};
|
|
47270
|
+
|
|
47271
|
+
if ((_event$drawDefinition = event.drawDefinitions) !== null && _event$drawDefinition !== void 0 && _event$drawDefinition.length) {
|
|
47272
|
+
const drawIds = (event.drawDefinitions || []).map(({
|
|
47273
|
+
drawId
|
|
47274
|
+
}) => drawId);
|
|
47275
|
+
const orderedDrawIds = Object.keys(orderedDrawIdsMap);
|
|
47276
|
+
if (intersection(drawIds, orderedDrawIds).length !== drawIds.length) return {
|
|
47277
|
+
error: INVALID_VALUES,
|
|
47278
|
+
message: 'Missing drawIds'
|
|
47279
|
+
};
|
|
47280
|
+
event.drawDefinitions.forEach(drawDefinition => {
|
|
47281
|
+
drawDefinition.drawOrder = orderedDrawIdsMap[drawDefinition.drawId];
|
|
47282
|
+
});
|
|
47283
|
+
}
|
|
47284
|
+
|
|
47285
|
+
const {
|
|
47286
|
+
flightProfile
|
|
47287
|
+
} = getFlightProfile({
|
|
47288
|
+
event
|
|
47289
|
+
});
|
|
47290
|
+
flightProfile === null || flightProfile === void 0 ? void 0 : (_flightProfile$flight = flightProfile.flights) === null || _flightProfile$flight === void 0 ? void 0 : _flightProfile$flight.forEach(flight => {
|
|
47291
|
+
flight.flightNumber = orderedDrawIdsMap[flight.drawId];
|
|
47292
|
+
});
|
|
47293
|
+
return SUCCESS;
|
|
47294
|
+
}
|
|
47295
|
+
|
|
47296
|
+
function refreshEventDrawOrder({
|
|
47297
|
+
tournamentRecord,
|
|
47298
|
+
event
|
|
47299
|
+
}) {
|
|
47300
|
+
var _event$drawDefinition;
|
|
47301
|
+
|
|
47302
|
+
if (!tournamentRecord) return {
|
|
47303
|
+
error: MISSING_TOURNAMENT_RECORD
|
|
47304
|
+
};
|
|
47305
|
+
if (!event) return {
|
|
47306
|
+
error: MISSING_EVENT
|
|
47307
|
+
};
|
|
47308
|
+
const {
|
|
47309
|
+
flightProfile
|
|
47310
|
+
} = getFlightProfile({
|
|
47311
|
+
event
|
|
47312
|
+
}); // if there is a flightProfile, derive order from that, otherwise use drawDefinitions array
|
|
47313
|
+
|
|
47314
|
+
const orderedDrawIdsMap = flightProfile !== null && flightProfile !== void 0 && flightProfile.flights ? Object.assign({}, ...flightProfile.flights.sort((a, b) => a.flightNumber - b.flightNumber).map((flight, i) => ({
|
|
47315
|
+
[flight.drawId]: i + 1
|
|
47316
|
+
}))) : (_event$drawDefinition = event.drawDefinitions) !== null && _event$drawDefinition !== void 0 && _event$drawDefinition.length ? Object.assign({}, ...event.drawDefinitions.sort((a, b) => a.drawOrder - b.drawOrder).map((drawDefinition, i) => ({
|
|
47317
|
+
[drawDefinition.drawId]: i + 1
|
|
47318
|
+
}))) : undefined;
|
|
47319
|
+
return orderedDrawIdsMap ? updateDrawIdsOrder({
|
|
47320
|
+
event,
|
|
47321
|
+
orderedDrawIdsMap
|
|
47322
|
+
}) : { ...SUCCESS
|
|
47323
|
+
};
|
|
47324
|
+
}
|
|
47325
|
+
|
|
47204
47326
|
function deleteFlightAndFlightDraw({
|
|
47205
47327
|
tournamentRecord,
|
|
47206
|
-
|
|
47328
|
+
auditData,
|
|
47207
47329
|
drawId,
|
|
47208
|
-
|
|
47330
|
+
event
|
|
47209
47331
|
}) {
|
|
47332
|
+
var _flightProfile$links, _flightProfile$links$, _flightProfile$links$2;
|
|
47333
|
+
|
|
47210
47334
|
if (!tournamentRecord) return {
|
|
47211
47335
|
error: MISSING_TOURNAMENT_RECORD
|
|
47212
47336
|
};
|
|
@@ -47221,20 +47345,42 @@ function deleteFlightAndFlightDraw({
|
|
|
47221
47345
|
} = getFlightProfile({
|
|
47222
47346
|
event
|
|
47223
47347
|
});
|
|
47348
|
+
const dependentDrawIds = (flightProfile === null || flightProfile === void 0 ? void 0 : (_flightProfile$links = flightProfile.links) === null || _flightProfile$links === void 0 ? void 0 : (_flightProfile$links$ = _flightProfile$links.filter(link => {
|
|
47349
|
+
var _link$source;
|
|
47350
|
+
|
|
47351
|
+
return ((_link$source = link.source) === null || _link$source === void 0 ? void 0 : _link$source.drawId) === drawId;
|
|
47352
|
+
})) === null || _flightProfile$links$ === void 0 ? void 0 : (_flightProfile$links$2 = _flightProfile$links$.map(link => {
|
|
47353
|
+
var _link$target;
|
|
47354
|
+
|
|
47355
|
+
return (_link$target = link.target) === null || _link$target === void 0 ? void 0 : _link$target.drawId;
|
|
47356
|
+
})) === null || _flightProfile$links$2 === void 0 ? void 0 : _flightProfile$links$2.filter(Boolean)) || [];
|
|
47224
47357
|
|
|
47225
47358
|
if (flightProfile) {
|
|
47226
47359
|
var _flightProfile$flight;
|
|
47227
47360
|
|
|
47228
47361
|
const flight = (_flightProfile$flight = flightProfile.flights) === null || _flightProfile$flight === void 0 ? void 0 : _flightProfile$flight.find(flight => flight.drawId === drawId);
|
|
47229
47362
|
|
|
47230
|
-
if (flight) {
|
|
47231
|
-
const flights = flightProfile.flights.filter(flight =>
|
|
47363
|
+
if (flight || dependentDrawIds.length) {
|
|
47364
|
+
const flights = flightProfile.flights.filter(flight => {
|
|
47365
|
+
const included = dependentDrawIds.includes(flight.drawId);
|
|
47366
|
+
return flight.drawId !== drawId && !included;
|
|
47367
|
+
});
|
|
47232
47368
|
const extension = {
|
|
47233
47369
|
name: FLIGHT_PROFILE,
|
|
47234
47370
|
value: { ...flightProfile,
|
|
47235
47371
|
flights
|
|
47236
47372
|
}
|
|
47237
|
-
};
|
|
47373
|
+
}; // TODO: this cleanup is not iterative
|
|
47374
|
+
|
|
47375
|
+
if (dependentDrawIds.length && flightProfile.links) {
|
|
47376
|
+
const links = flightProfile.links.filter(link => {
|
|
47377
|
+
var _link$target2;
|
|
47378
|
+
|
|
47379
|
+
return !dependentDrawIds.includes((_link$target2 = link.target) === null || _link$target2 === void 0 ? void 0 : _link$target2.drawId);
|
|
47380
|
+
});
|
|
47381
|
+
extension.value.links = links;
|
|
47382
|
+
}
|
|
47383
|
+
|
|
47238
47384
|
addEventExtension$1({
|
|
47239
47385
|
event,
|
|
47240
47386
|
extension
|
|
@@ -47245,10 +47391,13 @@ function deleteFlightAndFlightDraw({
|
|
|
47245
47391
|
deleteDrawDefinitions({
|
|
47246
47392
|
tournamentRecord,
|
|
47247
47393
|
eventId: event.eventId,
|
|
47248
|
-
drawIds: [drawId],
|
|
47394
|
+
drawIds: [drawId, ...dependentDrawIds],
|
|
47249
47395
|
auditData
|
|
47250
47396
|
});
|
|
47251
|
-
return
|
|
47397
|
+
return refreshEventDrawOrder({
|
|
47398
|
+
tournamentRecord,
|
|
47399
|
+
event
|
|
47400
|
+
});
|
|
47252
47401
|
}
|
|
47253
47402
|
|
|
47254
47403
|
function generateAdHocMatchUps(params) {
|
|
@@ -47637,64 +47786,6 @@ function pruneDrawDefinition({
|
|
|
47637
47786
|
};
|
|
47638
47787
|
}
|
|
47639
47788
|
|
|
47640
|
-
/**
|
|
47641
|
-
*
|
|
47642
|
-
* @param {object} orderedDrawIdsMap - required - mapping of ALL present drawIds => { [drawId]: drawOrder }
|
|
47643
|
-
*/
|
|
47644
|
-
|
|
47645
|
-
function updateDrawIdsOrder({
|
|
47646
|
-
event,
|
|
47647
|
-
orderedDrawIdsMap
|
|
47648
|
-
}) {
|
|
47649
|
-
var _event$drawDefinition, _flightProfile$flight;
|
|
47650
|
-
|
|
47651
|
-
if (typeof event !== 'object') return {
|
|
47652
|
-
error: MISSING_EVENT
|
|
47653
|
-
};
|
|
47654
|
-
if (!orderedDrawIdsMap) return {
|
|
47655
|
-
error: MISSING_VALUE,
|
|
47656
|
-
message: 'Missing drawIdsOrderMap'
|
|
47657
|
-
};
|
|
47658
|
-
if (typeof orderedDrawIdsMap !== 'object') return {
|
|
47659
|
-
error: INVALID_VALUES,
|
|
47660
|
-
message: 'orderedDrawIdsMap must be an object'
|
|
47661
|
-
};
|
|
47662
|
-
const drawOrders = Object.values(orderedDrawIdsMap);
|
|
47663
|
-
const validDrawOrders = drawOrders.every(drawOrder => !isNaN(drawOrder));
|
|
47664
|
-
if (!validDrawOrders) return {
|
|
47665
|
-
error: INVALID_VALUES,
|
|
47666
|
-
message: 'drawOrder must be numeric'
|
|
47667
|
-
};
|
|
47668
|
-
if (unique(drawOrders).length !== drawOrders.length) return {
|
|
47669
|
-
error: INVALID_VALUES,
|
|
47670
|
-
message: 'drawOrder values must be unique'
|
|
47671
|
-
};
|
|
47672
|
-
|
|
47673
|
-
if ((_event$drawDefinition = event.drawDefinitions) !== null && _event$drawDefinition !== void 0 && _event$drawDefinition.length) {
|
|
47674
|
-
const drawIds = (event.drawDefinitions || []).map(({
|
|
47675
|
-
drawId
|
|
47676
|
-
}) => drawId);
|
|
47677
|
-
const orderedDrawIds = Object.keys(orderedDrawIdsMap);
|
|
47678
|
-
if (intersection(drawIds, orderedDrawIds).length !== drawIds.length) return {
|
|
47679
|
-
error: INVALID_VALUES,
|
|
47680
|
-
message: 'Missing drawIds'
|
|
47681
|
-
};
|
|
47682
|
-
event.drawDefinitions.forEach(drawDefinition => {
|
|
47683
|
-
drawDefinition.drawOrder = orderedDrawIdsMap[drawDefinition.drawId];
|
|
47684
|
-
});
|
|
47685
|
-
}
|
|
47686
|
-
|
|
47687
|
-
const {
|
|
47688
|
-
flightProfile
|
|
47689
|
-
} = getFlightProfile({
|
|
47690
|
-
event
|
|
47691
|
-
});
|
|
47692
|
-
flightProfile === null || flightProfile === void 0 ? void 0 : (_flightProfile$flight = flightProfile.flights) === null || _flightProfile$flight === void 0 ? void 0 : _flightProfile$flight.forEach(flight => {
|
|
47693
|
-
flight.flightNumber = orderedDrawIdsMap[flight.drawId];
|
|
47694
|
-
});
|
|
47695
|
-
return SUCCESS;
|
|
47696
|
-
}
|
|
47697
|
-
|
|
47698
47789
|
function setOrderOfFinish(params) {
|
|
47699
47790
|
return setOrderOfFinish$1(params);
|
|
47700
47791
|
}
|
|
@@ -47797,12 +47888,13 @@ function addFlight({
|
|
|
47797
47888
|
qualifyingPositions,
|
|
47798
47889
|
drawEntries = [],
|
|
47799
47890
|
matchUpValue,
|
|
47891
|
+
sourceDrawId,
|
|
47800
47892
|
drawName,
|
|
47801
47893
|
drawId,
|
|
47802
47894
|
event,
|
|
47803
47895
|
stage
|
|
47804
47896
|
}) {
|
|
47805
|
-
var _flightProfile$flight, _flightProfile$flight2;
|
|
47897
|
+
var _getFlightProfile, _flightProfile$flight, _flightProfile$flight2, _flightProfile$flight3;
|
|
47806
47898
|
|
|
47807
47899
|
if (!event) return {
|
|
47808
47900
|
error: MISSING_EVENT
|
|
@@ -47823,17 +47915,26 @@ function addFlight({
|
|
|
47823
47915
|
}
|
|
47824
47916
|
}
|
|
47825
47917
|
|
|
47826
|
-
const {
|
|
47827
|
-
flightProfile
|
|
47828
|
-
} = getFlightProfile({
|
|
47918
|
+
const flightProfile = (_getFlightProfile = getFlightProfile({
|
|
47829
47919
|
event
|
|
47830
|
-
});
|
|
47831
|
-
|
|
47920
|
+
})) === null || _getFlightProfile === void 0 ? void 0 : _getFlightProfile.flightProfile; // VOLUNTARY_CONSOLATION stage requires a link be established from source draw
|
|
47921
|
+
|
|
47922
|
+
if (stage === VOLUNTARY_CONSOLATION && !sourceDrawId) return {
|
|
47923
|
+
error: MISSING_VALUE
|
|
47924
|
+
}; // sourceDrawId must exist in flightProfile
|
|
47925
|
+
|
|
47926
|
+
if (sourceDrawId && !(flightProfile !== null && flightProfile !== void 0 && (_flightProfile$flight = flightProfile.flights) !== null && _flightProfile$flight !== void 0 && _flightProfile$flight.find(({
|
|
47927
|
+
drawId
|
|
47928
|
+
}) => drawId === sourceDrawId))) return {
|
|
47929
|
+
error: MISSING_DRAW_ID
|
|
47930
|
+
};
|
|
47931
|
+
const flightNumbers = (flightProfile === null || flightProfile === void 0 ? void 0 : (_flightProfile$flight2 = flightProfile.flights) === null || _flightProfile$flight2 === void 0 ? void 0 : (_flightProfile$flight3 = _flightProfile$flight2.map(({
|
|
47832
47932
|
flightNumber
|
|
47833
|
-
}) => !isNaN(flightNumber) && parseInt(flightNumber))) === null || _flightProfile$
|
|
47933
|
+
}) => !isNaN(flightNumber) && parseInt(flightNumber))) === null || _flightProfile$flight3 === void 0 ? void 0 : _flightProfile$flight3.filter(Boolean)) || [];
|
|
47834
47934
|
const flightNumber = Math.max(0, ...flightNumbers) + 1;
|
|
47935
|
+
const flightDrawId = drawId || UUID();
|
|
47835
47936
|
const flight = {
|
|
47836
|
-
drawId:
|
|
47937
|
+
drawId: flightDrawId,
|
|
47837
47938
|
flightNumber,
|
|
47838
47939
|
matchUpValue,
|
|
47839
47940
|
drawEntries,
|
|
@@ -47854,6 +47955,26 @@ function addFlight({
|
|
|
47854
47955
|
flights
|
|
47855
47956
|
}
|
|
47856
47957
|
};
|
|
47958
|
+
|
|
47959
|
+
if (sourceDrawId) {
|
|
47960
|
+
// if there is a sourceDrawId construct a link
|
|
47961
|
+
const links = (flightProfile === null || flightProfile === void 0 ? void 0 : flightProfile.links) || [];
|
|
47962
|
+
|
|
47963
|
+
if (stage === VOLUNTARY_CONSOLATION) {
|
|
47964
|
+
links.push({
|
|
47965
|
+
linkType: LOSER,
|
|
47966
|
+
source: {
|
|
47967
|
+
drawId: sourceDrawId
|
|
47968
|
+
},
|
|
47969
|
+
target: {
|
|
47970
|
+
drawId: flightDrawId
|
|
47971
|
+
}
|
|
47972
|
+
});
|
|
47973
|
+
}
|
|
47974
|
+
|
|
47975
|
+
extension.value.links = links;
|
|
47976
|
+
}
|
|
47977
|
+
|
|
47857
47978
|
return addEventExtension$1({
|
|
47858
47979
|
event,
|
|
47859
47980
|
extension
|
|
@@ -48085,6 +48206,7 @@ const eventGovernor = {
|
|
|
48085
48206
|
deleteFlightProfileAndFlightDraws,
|
|
48086
48207
|
deleteFlightAndFlightDraw,
|
|
48087
48208
|
generateFlightProfile,
|
|
48209
|
+
refreshEventDrawOrder,
|
|
48088
48210
|
attachFlightProfile,
|
|
48089
48211
|
resetDrawDefinition,
|
|
48090
48212
|
pruneDrawDefinition,
|