tods-competition-factory 2.0.1 → 2.0.3
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 +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/tods-competition-factory.d.ts +19 -32
- package/dist/tods-competition-factory.development.cjs.js +142 -136
- package/dist/tods-competition-factory.development.cjs.js.map +1 -1
- package/dist/tods-competition-factory.production.cjs.min.js +1 -1
- package/dist/tods-competition-factory.production.cjs.min.js.map +1 -1
- package/package.json +2 -2
|
@@ -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.3';
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
/******************************************************************************
|
|
@@ -3966,15 +3966,13 @@ function drawUpdatedAt(drawDefinition, structureIds) {
|
|
|
3966
3966
|
if (!drawDefinition)
|
|
3967
3967
|
return { error: MISSING_DRAW_DEFINITION };
|
|
3968
3968
|
var timeStamp = Date.now();
|
|
3969
|
-
if (drawDefinition.updatedAt &&
|
|
3970
|
-
timeStamp === new Date(drawDefinition.updatedAt).getTime())
|
|
3969
|
+
if (drawDefinition.updatedAt && timeStamp === new Date(drawDefinition.updatedAt).getTime())
|
|
3971
3970
|
timeStamp += 1;
|
|
3972
3971
|
var updatedAt = new Date(timeStamp).toISOString();
|
|
3973
3972
|
var relevantStructureIds = structureIds === null || structureIds === void 0 ? void 0 : structureIds.filter(Boolean);
|
|
3974
3973
|
drawDefinition.updatedAt = updatedAt;
|
|
3975
3974
|
(_a = drawDefinition.structures) === null || _a === void 0 ? void 0 : _a.filter(Boolean).forEach(function (structure) {
|
|
3976
|
-
if (!(relevantStructureIds === null || relevantStructureIds === void 0 ? void 0 : relevantStructureIds.length) ||
|
|
3977
|
-
(relevantStructureIds === null || relevantStructureIds === void 0 ? void 0 : relevantStructureIds.includes(structure.structureId))) {
|
|
3975
|
+
if (!(relevantStructureIds === null || relevantStructureIds === void 0 ? void 0 : relevantStructureIds.length) || (relevantStructureIds === null || relevantStructureIds === void 0 ? void 0 : relevantStructureIds.includes(structure.structureId))) {
|
|
3978
3976
|
structure.updatedAt = updatedAt;
|
|
3979
3977
|
}
|
|
3980
3978
|
});
|
|
@@ -26406,21 +26404,16 @@ function pruneDrawDefinition(_a) {
|
|
|
26406
26404
|
var structureId = _a.structureId;
|
|
26407
26405
|
return mainStructure_1.structureId === structureId;
|
|
26408
26406
|
});
|
|
26409
|
-
var matchUps = (_b = mainStructure_1.matchUps) !== null && _b !== void 0 ? _b : [];
|
|
26410
|
-
relevantMatchUps = matchUps
|
|
26411
|
-
.sort(function (a, b) { return a.roundPosition - b.roundPosition; })
|
|
26412
|
-
.filter(function (_a) {
|
|
26407
|
+
var matchUps = ((_b = mainStructure_1.matchUps) !== null && _b !== void 0 ? _b : []).sort(function (a, b) { return a.roundPosition - b.roundPosition; });
|
|
26408
|
+
relevantMatchUps = matchUps.filter(function (_a) {
|
|
26413
26409
|
var roundNumber = _a.roundNumber;
|
|
26414
26410
|
return !structureData_1.inactiveRounds.includes(roundNumber);
|
|
26415
26411
|
});
|
|
26416
26412
|
var relevantMatchUpIds_1 = relevantMatchUps.map(getMatchUpId);
|
|
26417
|
-
var deletedMatchUpIds = matchUps
|
|
26418
|
-
.map(getMatchUpId)
|
|
26419
|
-
.filter(function (matchUpId) { return !relevantMatchUpIds_1.includes(matchUpId); });
|
|
26413
|
+
var deletedMatchUpIds = matchUps.map(getMatchUpId).filter(function (matchUpId) { return !relevantMatchUpIds_1.includes(matchUpId); });
|
|
26420
26414
|
// only ifMatchPlay can the positionAssignments be reallocated
|
|
26421
26415
|
if (isMatchPlay) {
|
|
26422
26416
|
var matchPlayMatchUps = relevantMatchUps
|
|
26423
|
-
.sort(function (a, b) { return a.roundPosition - b.roundPosition; })
|
|
26424
26417
|
.filter(function (_a) {
|
|
26425
26418
|
var roundNumber = _a.roundNumber;
|
|
26426
26419
|
return !structureData_1.inactiveRounds.includes(roundNumber);
|
|
@@ -26451,9 +26444,7 @@ function pruneDrawDefinition(_a) {
|
|
|
26451
26444
|
}
|
|
26452
26445
|
});
|
|
26453
26446
|
if (matchPlayDrawPositions) {
|
|
26454
|
-
var updatedPositionAssignments = (_c = mainStructure_1 === null || mainStructure_1 === void 0 ? void 0 : mainStructure_1.positionAssignments) === null || _c === void 0 ? void 0 : _c.filter(function (assignment) {
|
|
26455
|
-
return existingDrawPositions_1.includes(assignment.drawPosition);
|
|
26456
|
-
}).map(function (assignment) {
|
|
26447
|
+
var updatedPositionAssignments = (_c = mainStructure_1 === null || mainStructure_1 === void 0 ? void 0 : mainStructure_1.positionAssignments) === null || _c === void 0 ? void 0 : _c.filter(function (assignment) { return existingDrawPositions_1.includes(assignment.drawPosition); }).map(function (assignment) {
|
|
26457
26448
|
assignment.drawPosition = drawPositionsMap_1[assignment.drawPosition];
|
|
26458
26449
|
return assignment;
|
|
26459
26450
|
});
|
|
@@ -26512,17 +26503,21 @@ function assignDrawPosition(_a) {
|
|
|
26512
26503
|
return __assign({}, SUCCESS);
|
|
26513
26504
|
}
|
|
26514
26505
|
|
|
26515
|
-
function deleteAdHocMatchUps(
|
|
26516
|
-
var e_1,
|
|
26517
|
-
var _c, _d, _e, _f, _g;
|
|
26518
|
-
var tournamentRecord =
|
|
26506
|
+
function deleteAdHocMatchUps(params) {
|
|
26507
|
+
var e_1, _a;
|
|
26508
|
+
var _b, _c, _d, _e, _f, _g, _h, _j;
|
|
26509
|
+
var tournamentRecord = params.tournamentRecord, _k = params.matchUpIds, matchUpIds = _k === void 0 ? [] : _k, drawDefinition = params.drawDefinition, event = params.event;
|
|
26519
26510
|
if (typeof drawDefinition !== 'object')
|
|
26520
26511
|
return { error: MISSING_DRAW_DEFINITION };
|
|
26521
|
-
if (typeof structureId !== 'string')
|
|
26522
|
-
return { error: MISSING_STRUCTURE_ID };
|
|
26523
26512
|
if (!Array.isArray(matchUpIds))
|
|
26524
26513
|
return { error: INVALID_VALUES };
|
|
26525
|
-
var
|
|
26514
|
+
var structureId = (_b = params.structureId) !== null && _b !== void 0 ? _b : (_d = (_c = drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.structures) === null || _c === void 0 ? void 0 : _c.find(function (structure) { var _a; return (_a = structure.matchUps) === null || _a === void 0 ? void 0 : _a.some(function (_a) {
|
|
26515
|
+
var matchUpId = _a.matchUpId;
|
|
26516
|
+
return matchUpIds.includes(matchUpId);
|
|
26517
|
+
}); })) === null || _d === void 0 ? void 0 : _d.structureId;
|
|
26518
|
+
if (!structureId)
|
|
26519
|
+
return { error: STRUCTURE_NOT_FOUND };
|
|
26520
|
+
var structure = (_e = drawDefinition.structures) === null || _e === void 0 ? void 0 : _e.find(function (structure) { return structure.structureId === structureId; });
|
|
26526
26521
|
if (!structure)
|
|
26527
26522
|
return { error: STRUCTURE_NOT_FOUND };
|
|
26528
26523
|
var existingMatchUps = structure === null || structure === void 0 ? void 0 : structure.matchUps;
|
|
@@ -26531,21 +26526,28 @@ function deleteAdHocMatchUps(_a) {
|
|
|
26531
26526
|
return { error: INVALID_STRUCTURE };
|
|
26532
26527
|
}
|
|
26533
26528
|
var matchUpIdsWithScoreValue = [];
|
|
26534
|
-
var matchUpsToDelete = (
|
|
26529
|
+
var matchUpsToDelete = (_f = existingMatchUps === null || existingMatchUps === void 0 ? void 0 : existingMatchUps.filter(function (_a) {
|
|
26535
26530
|
var matchUpId = _a.matchUpId, score = _a.score;
|
|
26536
26531
|
if (checkScoreHasValue({ score: score }))
|
|
26537
26532
|
matchUpIdsWithScoreValue.push(matchUpId);
|
|
26538
26533
|
return matchUpIds.includes(matchUpId);
|
|
26539
|
-
})) !== null &&
|
|
26540
|
-
var matchUpIdsToDelete = matchUpsToDelete.map(
|
|
26534
|
+
})) !== null && _f !== void 0 ? _f : [];
|
|
26535
|
+
var matchUpIdsToDelete = matchUpsToDelete.map(getMatchUpId);
|
|
26536
|
+
var tieMatchUpIdsToDelete = matchUpsToDelete
|
|
26537
|
+
.map(function (_a) {
|
|
26538
|
+
var tieMatchUps = _a.tieMatchUps;
|
|
26539
|
+
return tieMatchUps === null || tieMatchUps === void 0 ? void 0 : tieMatchUps.map(getMatchUpId);
|
|
26540
|
+
})
|
|
26541
|
+
.filter(Boolean)
|
|
26542
|
+
.flat();
|
|
26541
26543
|
if (matchUpIdsToDelete.length) {
|
|
26542
|
-
structure.matchUps = ((
|
|
26544
|
+
structure.matchUps = ((_g = structure.matchUps) !== null && _g !== void 0 ? _g : []).filter(function (_a) {
|
|
26543
26545
|
var matchUpId = _a.matchUpId;
|
|
26544
26546
|
return !matchUpIdsToDelete.includes(matchUpId);
|
|
26545
26547
|
});
|
|
26546
26548
|
deleteMatchUpsNotice({
|
|
26547
26549
|
tournamentId: tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.tournamentId,
|
|
26548
|
-
matchUpIds: matchUpIdsToDelete,
|
|
26550
|
+
matchUpIds: __spreadArray(__spreadArray([], __read(tieMatchUpIdsToDelete), false), __read(matchUpIdsToDelete), false),
|
|
26549
26551
|
action: 'deleteAdHocMatchUps',
|
|
26550
26552
|
eventId: event === null || event === void 0 ? void 0 : event.eventId,
|
|
26551
26553
|
drawDefinition: drawDefinition,
|
|
@@ -26577,7 +26579,7 @@ function deleteAdHocMatchUps(_a) {
|
|
|
26577
26579
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
26578
26580
|
finally {
|
|
26579
26581
|
try {
|
|
26580
|
-
if (missingRoundNumbers_1_1 && !missingRoundNumbers_1_1.done && (
|
|
26582
|
+
if (missingRoundNumbers_1_1 && !missingRoundNumbers_1_1.done && (_a = missingRoundNumbers_1.return)) _a.call(missingRoundNumbers_1);
|
|
26581
26583
|
}
|
|
26582
26584
|
finally { if (e_1) throw e_1.error; }
|
|
26583
26585
|
}
|
|
@@ -26586,7 +26588,7 @@ function deleteAdHocMatchUps(_a) {
|
|
|
26586
26588
|
structure.positionAssignments = unique(structure.matchUps
|
|
26587
26589
|
.flatMap(function (matchUp) { var _a; return ((_a = matchUp.sides) !== null && _a !== void 0 ? _a : []).map(function (side) { return side.participantId; }); })
|
|
26588
26590
|
.filter(Boolean)).map(function (participantId) { return ({ participantId: participantId }); });
|
|
26589
|
-
var matchUpFormat = (
|
|
26591
|
+
var matchUpFormat = (_j = (_h = structure === null || structure === void 0 ? void 0 : structure.matchUpFormat) !== null && _h !== void 0 ? _h : drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.matchUpFormat) !== null && _j !== void 0 ? _j : event === null || event === void 0 ? void 0 : event.matchUpFormat;
|
|
26590
26592
|
var result = updateAssignmentParticipantResults({
|
|
26591
26593
|
positionAssignments: structure.positionAssignments,
|
|
26592
26594
|
matchUps: structure.matchUps,
|
|
@@ -26641,11 +26643,11 @@ function removeRoundMatchUps(_a) {
|
|
|
26641
26643
|
}
|
|
26642
26644
|
return __assign({}, SUCCESS);
|
|
26643
26645
|
}
|
|
26644
|
-
// TODO: move to drawEngine and passthrough
|
|
26645
26646
|
function removeAdHocRound(_a) {
|
|
26646
26647
|
var _b;
|
|
26647
26648
|
var removeCompletedMatchUps = _a.removeCompletedMatchUps, drawDefinition = _a.drawDefinition, tournamentId = _a.tournamentId, roundNumber = _a.roundNumber, structure = _a.structure, eventId = _a.eventId;
|
|
26648
26649
|
var matchUps = (_b = structure === null || structure === void 0 ? void 0 : structure.matchUps) !== null && _b !== void 0 ? _b : [];
|
|
26650
|
+
var deletedTieMatchUpIds = [];
|
|
26649
26651
|
var deletedMatchUpIds = [];
|
|
26650
26652
|
var roundRemoved = false;
|
|
26651
26653
|
var roundNumbers = matchUps
|
|
@@ -26660,13 +26662,17 @@ function removeAdHocRound(_a) {
|
|
|
26660
26662
|
var updatedMatchUps = matchUps.filter(function (matchUp) {
|
|
26661
26663
|
var target = matchUp.roundNumber === roundNumber &&
|
|
26662
26664
|
(!completedMatchUpStatuses.includes(matchUp.matchUpStatus) || removeCompletedMatchUps);
|
|
26663
|
-
if (target)
|
|
26665
|
+
if (target) {
|
|
26664
26666
|
deletedMatchUpIds.push(matchUp.matchUpId);
|
|
26667
|
+
if (matchUp.tieMatchUps) {
|
|
26668
|
+
deletedTieMatchUpIds.push.apply(deletedTieMatchUpIds, __spreadArray([], __read(matchUp.tieMatchUps.map(getMatchUpId)), false));
|
|
26669
|
+
}
|
|
26670
|
+
}
|
|
26665
26671
|
return !target;
|
|
26666
26672
|
});
|
|
26667
26673
|
if (deletedMatchUpIds.length) {
|
|
26668
26674
|
deleteMatchUpsNotice({
|
|
26669
|
-
matchUpIds: deletedMatchUpIds,
|
|
26675
|
+
matchUpIds: __spreadArray(__spreadArray([], __read(deletedTieMatchUpIds), false), __read(deletedMatchUpIds), false),
|
|
26670
26676
|
drawDefinition: drawDefinition,
|
|
26671
26677
|
tournamentId: tournamentId,
|
|
26672
26678
|
eventId: eventId,
|
|
@@ -26692,19 +26698,20 @@ function removeAdHocRound(_a) {
|
|
|
26692
26698
|
return __assign({ deletedMatchUpsCount: deletedMatchUpIds.length, roundRemoved: roundRemoved }, SUCCESS);
|
|
26693
26699
|
}
|
|
26694
26700
|
|
|
26695
|
-
function addAdHocMatchUps(
|
|
26696
|
-
var
|
|
26697
|
-
var _c, _d, _e, _f, _g, _h
|
|
26698
|
-
var tournamentRecord =
|
|
26701
|
+
function addAdHocMatchUps(params) {
|
|
26702
|
+
var _a;
|
|
26703
|
+
var _b, _c, _d, _e, _f, _g, _h;
|
|
26704
|
+
var suppressNotifications = params.suppressNotifications, tournamentRecord = params.tournamentRecord, drawDefinition = params.drawDefinition, matchUps = params.matchUps, event = params.event;
|
|
26699
26705
|
if (typeof drawDefinition !== 'object')
|
|
26700
26706
|
return { error: MISSING_DRAW_DEFINITION };
|
|
26701
|
-
|
|
26702
|
-
|
|
26707
|
+
var structureId = params === null || params === void 0 ? void 0 : params.structureId;
|
|
26708
|
+
if (!structureId && ((_b = drawDefinition.structures) === null || _b === void 0 ? void 0 : _b.length) === 1)
|
|
26709
|
+
structureId = (_d = (_c = drawDefinition.structures) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.structureId;
|
|
26703
26710
|
if (typeof structureId !== 'string')
|
|
26704
26711
|
return { error: MISSING_STRUCTURE_ID };
|
|
26705
26712
|
if (!validMatchUps(matchUps))
|
|
26706
26713
|
return { error: INVALID_VALUES, info: mustBeAnArray('matchUps') };
|
|
26707
|
-
var structure = (
|
|
26714
|
+
var structure = (_e = drawDefinition.structures) === null || _e === void 0 ? void 0 : _e.find(function (structure) { return structure.structureId === structureId; });
|
|
26708
26715
|
if (!structure)
|
|
26709
26716
|
return { error: STRUCTURE_NOT_FOUND };
|
|
26710
26717
|
var existingMatchUps = structure === null || structure === void 0 ? void 0 : structure.matchUps;
|
|
@@ -26712,10 +26719,10 @@ function addAdHocMatchUps(_a) {
|
|
|
26712
26719
|
if (structure.structures || structureHasRoundPositions || structure.finishingPosition === ROUND_OUTCOME) {
|
|
26713
26720
|
return { error: INVALID_STRUCTURE };
|
|
26714
26721
|
}
|
|
26715
|
-
var existingMatchUpIds = (
|
|
26722
|
+
var existingMatchUpIds = (_h = (_g = (_f = allTournamentMatchUps({
|
|
26716
26723
|
tournamentRecord: tournamentRecord,
|
|
26717
26724
|
inContext: false,
|
|
26718
|
-
})) === null ||
|
|
26725
|
+
})) === null || _f === void 0 ? void 0 : _f.matchUps) === null || _g === void 0 ? void 0 : _g.map(getMatchUpId)) !== null && _h !== void 0 ? _h : [];
|
|
26719
26726
|
var newMatchUpIds = matchUps.map(getMatchUpId);
|
|
26720
26727
|
if (overlap(existingMatchUpIds, newMatchUpIds)) {
|
|
26721
26728
|
return {
|
|
@@ -26723,13 +26730,23 @@ function addAdHocMatchUps(_a) {
|
|
|
26723
26730
|
info: 'One or more matchUpIds already present in tournamentRecord',
|
|
26724
26731
|
};
|
|
26725
26732
|
}
|
|
26726
|
-
(
|
|
26727
|
-
|
|
26728
|
-
|
|
26729
|
-
|
|
26730
|
-
|
|
26731
|
-
})
|
|
26732
|
-
|
|
26733
|
+
(_a = structure.matchUps).push.apply(_a, __spreadArray([], __read(matchUps), false));
|
|
26734
|
+
var tieMatchUps = matchUps
|
|
26735
|
+
.map(function (_a) {
|
|
26736
|
+
var tieMatchUps = _a.tieMatchUps;
|
|
26737
|
+
return tieMatchUps;
|
|
26738
|
+
})
|
|
26739
|
+
.filter(Boolean)
|
|
26740
|
+
.flat();
|
|
26741
|
+
if (!suppressNotifications) {
|
|
26742
|
+
addMatchUpsNotice({
|
|
26743
|
+
tournamentId: tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.tournamentId,
|
|
26744
|
+
matchUps: __spreadArray(__spreadArray([], __read(tieMatchUps), false), __read(matchUps), false),
|
|
26745
|
+
eventId: event === null || event === void 0 ? void 0 : event.eventId,
|
|
26746
|
+
drawDefinition: drawDefinition,
|
|
26747
|
+
});
|
|
26748
|
+
modifyDrawNotice({ drawDefinition: drawDefinition, structureIds: [structureId] });
|
|
26749
|
+
}
|
|
26733
26750
|
return __assign({}, SUCCESS);
|
|
26734
26751
|
}
|
|
26735
26752
|
|
|
@@ -26783,6 +26800,36 @@ function setSubOrder(_a) {
|
|
|
26783
26800
|
return __assign({}, SUCCESS);
|
|
26784
26801
|
}
|
|
26785
26802
|
|
|
26803
|
+
function generateSeedingScaleItems(_a) {
|
|
26804
|
+
var scaleAttributes = _a.scaleAttributes, scaledEntries = _a.scaledEntries, stageEntries = _a.stageEntries, seedsCount = _a.seedsCount, scaleName = _a.scaleName;
|
|
26805
|
+
if (!scaleAttributes)
|
|
26806
|
+
return { error: MISSING_VALUE, info: 'missing scaleAttributes' };
|
|
26807
|
+
var seededEntries = Object.assign.apply(Object, __spreadArray([{}], __read((scaledEntries || [])
|
|
26808
|
+
.slice(0, seedsCount)
|
|
26809
|
+
.map(function (_a, index) {
|
|
26810
|
+
var _b;
|
|
26811
|
+
var participantId = _a.participantId;
|
|
26812
|
+
return (_b = {}, _b[participantId] = index + 1, _b);
|
|
26813
|
+
})), false));
|
|
26814
|
+
scaleName = scaleName || scaleAttributes.scaleName;
|
|
26815
|
+
var scaleDate = new Date().toISOString();
|
|
26816
|
+
var scaleItemsWithParticipantIds = stageEntries.map(function (_a) {
|
|
26817
|
+
var participantId = _a.participantId;
|
|
26818
|
+
var scaleItem = {
|
|
26819
|
+
scaleValue: seededEntries[participantId],
|
|
26820
|
+
eventType: scaleAttributes.eventType,
|
|
26821
|
+
scaleType: SEEDING$1,
|
|
26822
|
+
scaleName: scaleName,
|
|
26823
|
+
scaleDate: scaleDate,
|
|
26824
|
+
};
|
|
26825
|
+
return {
|
|
26826
|
+
scaleItems: [scaleItem],
|
|
26827
|
+
participantId: participantId,
|
|
26828
|
+
};
|
|
26829
|
+
});
|
|
26830
|
+
return { scaleItemsWithParticipantIds: scaleItemsWithParticipantIds };
|
|
26831
|
+
}
|
|
26832
|
+
|
|
26786
26833
|
function getEliminationDrawSize(_a) {
|
|
26787
26834
|
var participantsCount = _a.participantsCount, participantCount = _a.participantCount;
|
|
26788
26835
|
participantsCount = participantsCount !== null && participantsCount !== void 0 ? participantsCount : participantCount;
|
|
@@ -26883,36 +26930,6 @@ function getEntriesAndSeedsCount(_a) {
|
|
|
26883
26930
|
return { entries: entries, seedsCount: seedsCount, stageEntries: stageEntries };
|
|
26884
26931
|
}
|
|
26885
26932
|
|
|
26886
|
-
function generateSeedingScaleItems(_a) {
|
|
26887
|
-
var scaleAttributes = _a.scaleAttributes, scaledEntries = _a.scaledEntries, stageEntries = _a.stageEntries, seedsCount = _a.seedsCount, scaleName = _a.scaleName;
|
|
26888
|
-
if (!scaleAttributes)
|
|
26889
|
-
return { error: MISSING_VALUE, info: 'missing scaleAttributes' };
|
|
26890
|
-
var seededEntries = Object.assign.apply(Object, __spreadArray([{}], __read((scaledEntries || [])
|
|
26891
|
-
.slice(0, seedsCount)
|
|
26892
|
-
.map(function (_a, index) {
|
|
26893
|
-
var _b;
|
|
26894
|
-
var participantId = _a.participantId;
|
|
26895
|
-
return (_b = {}, _b[participantId] = index + 1, _b);
|
|
26896
|
-
})), false));
|
|
26897
|
-
scaleName = scaleName || scaleAttributes.scaleName;
|
|
26898
|
-
var scaleDate = new Date().toISOString();
|
|
26899
|
-
var scaleItemsWithParticipantIds = stageEntries.map(function (_a) {
|
|
26900
|
-
var participantId = _a.participantId;
|
|
26901
|
-
var scaleItem = {
|
|
26902
|
-
scaleValue: seededEntries[participantId],
|
|
26903
|
-
eventType: scaleAttributes.eventType,
|
|
26904
|
-
scaleType: SEEDING$1,
|
|
26905
|
-
scaleName: scaleName,
|
|
26906
|
-
scaleDate: scaleDate,
|
|
26907
|
-
};
|
|
26908
|
-
return {
|
|
26909
|
-
scaleItems: [scaleItem],
|
|
26910
|
-
participantId: participantId,
|
|
26911
|
-
};
|
|
26912
|
-
});
|
|
26913
|
-
return { scaleItemsWithParticipantIds: scaleItemsWithParticipantIds };
|
|
26914
|
-
}
|
|
26915
|
-
|
|
26916
26933
|
function getParticipantScaleItem(params) {
|
|
26917
26934
|
var _a;
|
|
26918
26935
|
var tournamentRecord = params.tournamentRecord, scaleAttributes = params.scaleAttributes, participantId = params.participantId;
|
|
@@ -26976,23 +26993,6 @@ function getScaledEntries(_a) {
|
|
|
26976
26993
|
}
|
|
26977
26994
|
}
|
|
26978
26995
|
|
|
26979
|
-
/**
|
|
26980
|
-
*
|
|
26981
|
-
* @param {object} tournamentRecord - passed automatically if tournamentEngine.setState() has been called
|
|
26982
|
-
* @param {string} eventId - resolved by tournamentEngine to the event object
|
|
26983
|
-
*
|
|
26984
|
-
* @param {object} policyDefinitions - seeding policyDefinitions determines the # of seeds for given participantsCount/drawSize
|
|
26985
|
-
* @param {object} scaleAttributes -
|
|
26986
|
-
* @param {string} scaleName - OPTIONAL - defaults to scaleAttributes.scaleName
|
|
26987
|
-
* @param {number} drawSize - OPTIONAL - defaults to calculation based on # of entries
|
|
26988
|
-
* @param {string} drawId - OPTIONAL - will use flight.drawEntries or drawDefinition.entries rather than event.entries
|
|
26989
|
-
* @param {string} stage - OPTIONAL - filters entries by specified stage
|
|
26990
|
-
*
|
|
26991
|
-
* @param {boolean} sortDescending - OPTIONAL - defaults to false
|
|
26992
|
-
* @param {function} scaleSortMethod - OPTIONAL - user defined sorting method
|
|
26993
|
-
*
|
|
26994
|
-
* @returns {object} - { success: true } or { error }
|
|
26995
|
-
*/
|
|
26996
26996
|
function autoSeeding(_a) {
|
|
26997
26997
|
var _b;
|
|
26998
26998
|
var tournamentRecord = _a.tournamentRecord, drawDefinition = _a.drawDefinition, policyDefinitions = _a.policyDefinitions, scaleAttributes = _a.scaleAttributes, scaleName = _a.scaleName, drawSize = _a.drawSize, drawId = _a.drawId, event = _a.event, stage = _a.stage, sortDescending = _a.sortDescending, scaleSortMethod = _a.scaleSortMethod;
|
|
@@ -32565,9 +32565,9 @@ var POLICY_SEEDING_DEFAULT = (_a$b = {},
|
|
|
32565
32565
|
|
|
32566
32566
|
function generateDrawDefinition(params) {
|
|
32567
32567
|
var _a, e_1, _b, e_2, _c, e_3, _d, e_4, _e, _f, e_5, _g, e_6, _h, _j;
|
|
32568
|
-
var _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34;
|
|
32568
|
+
var _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35;
|
|
32569
32569
|
var stack = 'generateDrawDefinition';
|
|
32570
|
-
var
|
|
32570
|
+
var _36 = params.enforceMinimumDrawSize, enforceMinimumDrawSize = _36 === void 0 ? true : _36, _37 = params.considerEventEntries, considerEventEntries = _37 === void 0 ? true : _37, // in the absence of drawSize and drawEntries, look to event.entries
|
|
32571
32571
|
ignoreAllowedDrawTypes = params.ignoreAllowedDrawTypes, voluntaryConsolation = params.voluntaryConsolation, hydrateCollections = params.hydrateCollections, ignoreStageSpace = params.ignoreStageSpace, tournamentRecord = params.tournamentRecord, qualifyingOnly = params.qualifyingOnly, tieFormatName = params.tieFormatName, drawEntries = params.drawEntries, placeByes = params.placeByes, event = params.event;
|
|
32572
32572
|
var isMock = (_k = params.isMock) !== null && _k !== void 0 ? _k : true;
|
|
32573
32573
|
var idPrefix = params.idPrefix;
|
|
@@ -32578,12 +32578,12 @@ function generateDrawDefinition(params) {
|
|
|
32578
32578
|
var policyDefinitions = makeDeepCopy((_m = params.policyDefinitions) !== null && _m !== void 0 ? _m : {}, false, true);
|
|
32579
32579
|
// get participants both for entry validation and for automated placement
|
|
32580
32580
|
// automated placement requires them to be "inContext" for avoidance policies to work
|
|
32581
|
-
var
|
|
32581
|
+
var _38 = getParticipants({
|
|
32582
32582
|
withIndividualParticipants: true,
|
|
32583
32583
|
convertExtensions: true,
|
|
32584
32584
|
internalUse: true,
|
|
32585
32585
|
tournamentRecord: tournamentRecord,
|
|
32586
|
-
}), participants =
|
|
32586
|
+
}), participants = _38.participants, participantMap = _38.participantMap;
|
|
32587
32587
|
var eventEntries = (_p = (_o = event === null || event === void 0 ? void 0 : event.entries) === null || _o === void 0 ? void 0 : _o.filter(function (entry) { return entry.entryStatus && __spreadArray(__spreadArray([], __read(STRUCTURE_SELECTED_STATUSES), false), [QUALIFIER], false).includes(entry.entryStatus); })) !== null && _p !== void 0 ? _p : [];
|
|
32588
32588
|
// -------------------- BEGIN PARAMETER DERIVATION AND VALIDATION -------------------------
|
|
32589
32589
|
var consideredEntries = ((qualifyingOnly && []) ||
|
|
@@ -32766,8 +32766,8 @@ function generateDrawDefinition(params) {
|
|
|
32766
32766
|
}
|
|
32767
32767
|
else {
|
|
32768
32768
|
try {
|
|
32769
|
-
for (var
|
|
32770
|
-
var key =
|
|
32769
|
+
for (var _39 = __values(Object.keys(policyDefinitions)), _40 = _39.next(); !_40.done; _40 = _39.next()) {
|
|
32770
|
+
var key = _40.value;
|
|
32771
32771
|
if (JSON.stringify(appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[key]) !== JSON.stringify(policyDefinitions[key])) {
|
|
32772
32772
|
policiesToAttach[key] = policyDefinitions[key];
|
|
32773
32773
|
}
|
|
@@ -32776,7 +32776,7 @@ function generateDrawDefinition(params) {
|
|
|
32776
32776
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
32777
32777
|
finally {
|
|
32778
32778
|
try {
|
|
32779
|
-
if (
|
|
32779
|
+
if (_40 && !_40.done && (_b = _39.return)) _b.call(_39);
|
|
32780
32780
|
}
|
|
32781
32781
|
finally { if (e_1) throw e_1.error; }
|
|
32782
32782
|
}
|
|
@@ -32836,7 +32836,7 @@ function generateDrawDefinition(params) {
|
|
|
32836
32836
|
var source = _a.source;
|
|
32837
32837
|
return source.structureId !== existingQualifyingPlaceholderStructureId;
|
|
32838
32838
|
});
|
|
32839
|
-
var
|
|
32839
|
+
var _41 = qualifyingResult !== null && qualifyingResult !== void 0 ? qualifyingResult : {}, qualifiersCount = _41.qualifiersCount, qualifyingDrawPositionsCount = _41.qualifyingDrawPositionsCount, qualifyingDetails = _41.qualifyingDetails;
|
|
32840
32840
|
if (qualifyingDrawPositionsCount) {
|
|
32841
32841
|
if (qualifyingResult === null || qualifyingResult === void 0 ? void 0 : qualifyingResult.structures) {
|
|
32842
32842
|
(_18 = drawDefinition.structures) === null || _18 === void 0 ? void 0 : _18.push.apply(_18, __spreadArray([], __read(qualifyingResult.structures), false));
|
|
@@ -32871,11 +32871,11 @@ function generateDrawDefinition(params) {
|
|
|
32871
32871
|
if (result.error)
|
|
32872
32872
|
return result;
|
|
32873
32873
|
try {
|
|
32874
|
-
for (var
|
|
32874
|
+
for (var _42 = __values((drawEntries !== null && drawEntries !== void 0 ? drawEntries : []).filter(function (_a) {
|
|
32875
32875
|
var entryStage = _a.entryStage;
|
|
32876
32876
|
return entryStage === QUALIFYING;
|
|
32877
|
-
})),
|
|
32878
|
-
var entry =
|
|
32877
|
+
})), _43 = _42.next(); !_43.done; _43 = _42.next()) {
|
|
32878
|
+
var entry = _43.value;
|
|
32879
32879
|
var entryData = __assign(__assign({}, entry), { entryStage: (_21 = entry.entryStage) !== null && _21 !== void 0 ? _21 : MAIN, drawDefinition: drawDefinition });
|
|
32880
32880
|
// ignore errors (EXITING_PARTICIPANT)
|
|
32881
32881
|
addDrawEntry(entryData);
|
|
@@ -32884,13 +32884,13 @@ function generateDrawDefinition(params) {
|
|
|
32884
32884
|
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
32885
32885
|
finally {
|
|
32886
32886
|
try {
|
|
32887
|
-
if (
|
|
32887
|
+
if (_43 && !_43.done && (_c = _42.return)) _c.call(_42);
|
|
32888
32888
|
}
|
|
32889
32889
|
finally { if (e_2) throw e_2.error; }
|
|
32890
32890
|
}
|
|
32891
32891
|
try {
|
|
32892
|
-
for (var
|
|
32893
|
-
var qualifyingDetail =
|
|
32892
|
+
for (var _44 = __values(qualifyingDetails || []), _45 = _44.next(); !_45.done; _45 = _44.next()) {
|
|
32893
|
+
var qualifyingDetail = _45.value;
|
|
32894
32894
|
var qualifyingRoundNumber = qualifyingDetail.finalQualifyingRoundNumber, qualifyingStructureId = qualifyingDetail.finalQualifyingStructureId, targetEntryRound = qualifyingDetail.roundTarget, finishingPositions = qualifyingDetail.finishingPositions, linkType = qualifyingDetail.linkType;
|
|
32895
32895
|
var link = mainStructure &&
|
|
32896
32896
|
((_22 = generateQualifyingLink({
|
|
@@ -32913,7 +32913,7 @@ function generateDrawDefinition(params) {
|
|
|
32913
32913
|
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
32914
32914
|
finally {
|
|
32915
32915
|
try {
|
|
32916
|
-
if (
|
|
32916
|
+
if (_45 && !_45.done && (_d = _44.return)) _d.call(_44);
|
|
32917
32917
|
}
|
|
32918
32918
|
finally { if (e_3) throw e_3.error; }
|
|
32919
32919
|
}
|
|
@@ -32968,7 +32968,7 @@ function generateDrawDefinition(params) {
|
|
|
32968
32968
|
var participantIds = entries_2 === null || entries_2 === void 0 ? void 0 : entries_2.map(getParticipantId);
|
|
32969
32969
|
var matchUpsCount_1 = entries_2 ? Math.floor(entries_2.length / 2) : 0;
|
|
32970
32970
|
if (params.automated) {
|
|
32971
|
-
var
|
|
32971
|
+
var _46 = (_27 = params.drawMatic) !== null && _27 !== void 0 ? _27 : {}, restrictEntryStatus = _46.restrictEntryStatus, generateMatchUps = _46.generateMatchUps, structureId_1 = _46.structureId, matchUpIds = _46.matchUpIds, scaleName = _46.scaleName;
|
|
32972
32972
|
var result = drawMatic({
|
|
32973
32973
|
eventType: (_29 = (_28 = params.drawMatic) === null || _28 === void 0 ? void 0 : _28.eventType) !== null && _29 !== void 0 ? _29 : matchUpType,
|
|
32974
32974
|
generateMatchUps: generateMatchUps !== null && generateMatchUps !== void 0 ? generateMatchUps : true,
|
|
@@ -32984,12 +32984,15 @@ function generateDrawDefinition(params) {
|
|
|
32984
32984
|
isMock: isMock,
|
|
32985
32985
|
event: event,
|
|
32986
32986
|
});
|
|
32987
|
-
|
|
32988
|
-
|
|
32989
|
-
|
|
32990
|
-
|
|
32991
|
-
|
|
32992
|
-
|
|
32987
|
+
((_30 = result === null || result === void 0 ? void 0 : result.matchUps) === null || _30 === void 0 ? void 0 : _30.length) &&
|
|
32988
|
+
addAdHocMatchUps({
|
|
32989
|
+
suppressNotifications: true,
|
|
32990
|
+
matchUps: result.matchUps,
|
|
32991
|
+
tournamentRecord: tournamentRecord,
|
|
32992
|
+
drawDefinition: drawDefinition,
|
|
32993
|
+
structureId: structureId_1,
|
|
32994
|
+
event: event,
|
|
32995
|
+
});
|
|
32993
32996
|
}
|
|
32994
32997
|
else {
|
|
32995
32998
|
generateRange(1, params.roundsCount + 1).forEach(function () {
|
|
@@ -33001,12 +33004,15 @@ function generateDrawDefinition(params) {
|
|
|
33001
33004
|
isMock: isMock,
|
|
33002
33005
|
event: event,
|
|
33003
33006
|
}).matchUps;
|
|
33004
|
-
|
|
33005
|
-
|
|
33006
|
-
|
|
33007
|
-
|
|
33008
|
-
|
|
33009
|
-
|
|
33007
|
+
(matchUps === null || matchUps === void 0 ? void 0 : matchUps.length) &&
|
|
33008
|
+
addAdHocMatchUps({
|
|
33009
|
+
suppressNotifications: true,
|
|
33010
|
+
tournamentRecord: tournamentRecord,
|
|
33011
|
+
drawDefinition: drawDefinition,
|
|
33012
|
+
structureId: structureId,
|
|
33013
|
+
matchUps: matchUps,
|
|
33014
|
+
event: event,
|
|
33015
|
+
});
|
|
33010
33016
|
});
|
|
33011
33017
|
}
|
|
33012
33018
|
}
|
|
@@ -33020,8 +33026,8 @@ function generateDrawDefinition(params) {
|
|
|
33020
33026
|
var roundTarget = 1;
|
|
33021
33027
|
params.qualifyingProfiles.sort(roundTargetSort);
|
|
33022
33028
|
try {
|
|
33023
|
-
for (var
|
|
33024
|
-
var roundTargetProfile =
|
|
33029
|
+
for (var _47 = __values(params.qualifyingProfiles), _48 = _47.next(); !_48.done; _48 = _47.next()) {
|
|
33030
|
+
var roundTargetProfile = _48.value;
|
|
33025
33031
|
if (!Array.isArray(roundTargetProfile.structureProfiles))
|
|
33026
33032
|
return decorateResult({
|
|
33027
33033
|
info: mustBeAnArray('structureProfiles'),
|
|
@@ -33029,13 +33035,13 @@ function generateDrawDefinition(params) {
|
|
|
33029
33035
|
stack: stack,
|
|
33030
33036
|
});
|
|
33031
33037
|
roundTarget = roundTargetProfile.roundTarget || roundTarget;
|
|
33032
|
-
var sortedStructureProfiles = ((
|
|
33038
|
+
var sortedStructureProfiles = ((_31 = roundTargetProfile.structureProfiles) === null || _31 === void 0 ? void 0 : _31.sort(sequenceSort)) || [];
|
|
33033
33039
|
var sequence = 1;
|
|
33034
33040
|
try {
|
|
33035
33041
|
for (var sortedStructureProfiles_1 = (e_6 = void 0, __values(sortedStructureProfiles)), sortedStructureProfiles_1_1 = sortedStructureProfiles_1.next(); !sortedStructureProfiles_1_1.done; sortedStructureProfiles_1_1 = sortedStructureProfiles_1.next()) {
|
|
33036
33042
|
var structureProfile = sortedStructureProfiles_1_1.value;
|
|
33037
|
-
var qualifyingRoundNumber = structureProfile.qualifyingRoundNumber, qualifyingPositions = structureProfile.qualifyingPositions, seededParticipants = structureProfile.seededParticipants, seedingScaleName = structureProfile.seedingScaleName,
|
|
33038
|
-
var qualifyingStageResult = prepareStage(__assign(__assign(__assign({}, drawTypeResult), params), { seedingProfile: (
|
|
33043
|
+
var qualifyingRoundNumber = structureProfile.qualifyingRoundNumber, qualifyingPositions = structureProfile.qualifyingPositions, seededParticipants = structureProfile.seededParticipants, seedingScaleName = structureProfile.seedingScaleName, _49 = structureProfile.seedsCount, seedsCount = _49 === void 0 ? 0 : _49, seedByRanking = structureProfile.seedByRanking, placeByes_1 = structureProfile.placeByes, drawSize_1 = structureProfile.drawSize;
|
|
33044
|
+
var qualifyingStageResult = prepareStage(__assign(__assign(__assign({}, drawTypeResult), params), { seedingProfile: (_32 = structureProfile.seedingProfile) !== null && _32 !== void 0 ? _32 : seedingProfile, stageSequence: sequence, qualifyingRoundNumber: qualifyingRoundNumber, preparedStructureIds: preparedStructureIds, qualifyingPositions: qualifyingPositions, seededParticipants: seededParticipants, stage: QUALIFYING, seedingScaleName: seedingScaleName, appliedPolicies: appliedPolicies, drawDefinition: drawDefinition, qualifyingOnly: qualifyingOnly, seedByRanking: seedByRanking, participants: participants, roundTarget: roundTarget, seedsCount: seedsCount, placeByes: placeByes_1, drawSize: drawSize_1, entries: entries }));
|
|
33039
33045
|
if (qualifyingStageResult.error) {
|
|
33040
33046
|
return qualifyingStageResult;
|
|
33041
33047
|
}
|
|
@@ -33043,9 +33049,9 @@ function generateDrawDefinition(params) {
|
|
|
33043
33049
|
preparedStructureIds.push(qualifyingStageResult.structureId);
|
|
33044
33050
|
}
|
|
33045
33051
|
sequence += 1;
|
|
33046
|
-
if ((
|
|
33052
|
+
if ((_33 = qualifyingStageResult.conflicts) === null || _33 === void 0 ? void 0 : _33.length)
|
|
33047
33053
|
qualifyingConflicts.push.apply(qualifyingConflicts, __spreadArray([], __read(qualifyingStageResult.conflicts), false));
|
|
33048
|
-
if ((
|
|
33054
|
+
if ((_34 = qualifyingStageResult.positioningReport) === null || _34 === void 0 ? void 0 : _34.length)
|
|
33049
33055
|
positioningReports.push((_j = {},
|
|
33050
33056
|
_j[QUALIFYING] = qualifyingStageResult.positioningReport,
|
|
33051
33057
|
_j));
|
|
@@ -33064,7 +33070,7 @@ function generateDrawDefinition(params) {
|
|
|
33064
33070
|
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
33065
33071
|
finally {
|
|
33066
33072
|
try {
|
|
33067
|
-
if (
|
|
33073
|
+
if (_48 && !_48.done && (_g = _47.return)) _g.call(_47);
|
|
33068
33074
|
}
|
|
33069
33075
|
finally { if (e_5) throw e_5.error; }
|
|
33070
33076
|
}
|
|
@@ -33087,7 +33093,7 @@ function generateDrawDefinition(params) {
|
|
|
33087
33093
|
drawDefinition.links = [];
|
|
33088
33094
|
drawDefinition.links.push(link);
|
|
33089
33095
|
}
|
|
33090
|
-
drawDefinition.drawName = (
|
|
33096
|
+
drawDefinition.drawName = (_35 = params.drawName) !== null && _35 !== void 0 ? _35 : (drawType && constantToString(drawType));
|
|
33091
33097
|
if (typeof voluntaryConsolation === 'object' && drawSize >= 4) {
|
|
33092
33098
|
addVoluntaryConsolationStructure(__assign(__assign({}, voluntaryConsolation), { drawDefinition: drawDefinition, matchUpType: matchUpType }));
|
|
33093
33099
|
}
|
|
@@ -65115,10 +65121,10 @@ function asyncEngineInvoke(engine, args) {
|
|
|
65115
65121
|
});
|
|
65116
65122
|
}
|
|
65117
65123
|
|
|
65118
|
-
function importMethods(engine, engineInvoke, submittedMethods,
|
|
65124
|
+
function importMethods(engine, engineInvoke, submittedMethods, traverse, maxDepth) {
|
|
65119
65125
|
if (!isObject(submittedMethods))
|
|
65120
65126
|
return { error: INVALID_VALUES };
|
|
65121
|
-
var collectionFilter = Array.isArray(
|
|
65127
|
+
var collectionFilter = Array.isArray(traverse) ? traverse : [];
|
|
65122
65128
|
var methods = {};
|
|
65123
65129
|
var attrWalker = function (obj, depth) {
|
|
65124
65130
|
if (depth === void 0) { depth = 0; }
|
|
@@ -65127,7 +65133,7 @@ function importMethods(engine, engineInvoke, submittedMethods, collections, maxD
|
|
|
65127
65133
|
methods[key] = obj[key];
|
|
65128
65134
|
}
|
|
65129
65135
|
else if (isObject(obj[key]) &&
|
|
65130
|
-
(
|
|
65136
|
+
(traverse === true || (collectionFilter === null || collectionFilter === void 0 ? void 0 : collectionFilter.includes(key))) &&
|
|
65131
65137
|
(maxDepth === undefined || depth < maxDepth)) {
|
|
65132
65138
|
attrWalker(obj[key], depth + 1);
|
|
65133
65139
|
}
|