tods-competition-factory 2.0.0 → 2.0.2
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 +6 -3
- package/dist/tods-competition-factory.development.cjs.js +197 -146
- 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.2';
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
/******************************************************************************
|
|
@@ -214,7 +214,9 @@ function numericSort(a, b) {
|
|
|
214
214
|
function ensureInt(val) {
|
|
215
215
|
if (typeof val === 'number')
|
|
216
216
|
return parseInt(val.toString());
|
|
217
|
-
|
|
217
|
+
if (typeof val === 'string')
|
|
218
|
+
return parseInt(val);
|
|
219
|
+
return 0;
|
|
218
220
|
}
|
|
219
221
|
|
|
220
222
|
function isPowerOf2(n) {
|
|
@@ -3964,15 +3966,13 @@ function drawUpdatedAt(drawDefinition, structureIds) {
|
|
|
3964
3966
|
if (!drawDefinition)
|
|
3965
3967
|
return { error: MISSING_DRAW_DEFINITION };
|
|
3966
3968
|
var timeStamp = Date.now();
|
|
3967
|
-
if (drawDefinition.updatedAt &&
|
|
3968
|
-
timeStamp === new Date(drawDefinition.updatedAt).getTime())
|
|
3969
|
+
if (drawDefinition.updatedAt && timeStamp === new Date(drawDefinition.updatedAt).getTime())
|
|
3969
3970
|
timeStamp += 1;
|
|
3970
3971
|
var updatedAt = new Date(timeStamp).toISOString();
|
|
3971
3972
|
var relevantStructureIds = structureIds === null || structureIds === void 0 ? void 0 : structureIds.filter(Boolean);
|
|
3972
3973
|
drawDefinition.updatedAt = updatedAt;
|
|
3973
3974
|
(_a = drawDefinition.structures) === null || _a === void 0 ? void 0 : _a.filter(Boolean).forEach(function (structure) {
|
|
3974
|
-
if (!(relevantStructureIds === null || relevantStructureIds === void 0 ? void 0 : relevantStructureIds.length) ||
|
|
3975
|
-
(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))) {
|
|
3976
3976
|
structure.updatedAt = updatedAt;
|
|
3977
3977
|
}
|
|
3978
3978
|
});
|
|
@@ -26404,21 +26404,16 @@ function pruneDrawDefinition(_a) {
|
|
|
26404
26404
|
var structureId = _a.structureId;
|
|
26405
26405
|
return mainStructure_1.structureId === structureId;
|
|
26406
26406
|
});
|
|
26407
|
-
var matchUps = (_b = mainStructure_1.matchUps) !== null && _b !== void 0 ? _b : [];
|
|
26408
|
-
relevantMatchUps = matchUps
|
|
26409
|
-
.sort(function (a, b) { return a.roundPosition - b.roundPosition; })
|
|
26410
|
-
.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) {
|
|
26411
26409
|
var roundNumber = _a.roundNumber;
|
|
26412
26410
|
return !structureData_1.inactiveRounds.includes(roundNumber);
|
|
26413
26411
|
});
|
|
26414
26412
|
var relevantMatchUpIds_1 = relevantMatchUps.map(getMatchUpId);
|
|
26415
|
-
var deletedMatchUpIds = matchUps
|
|
26416
|
-
.map(getMatchUpId)
|
|
26417
|
-
.filter(function (matchUpId) { return !relevantMatchUpIds_1.includes(matchUpId); });
|
|
26413
|
+
var deletedMatchUpIds = matchUps.map(getMatchUpId).filter(function (matchUpId) { return !relevantMatchUpIds_1.includes(matchUpId); });
|
|
26418
26414
|
// only ifMatchPlay can the positionAssignments be reallocated
|
|
26419
26415
|
if (isMatchPlay) {
|
|
26420
26416
|
var matchPlayMatchUps = relevantMatchUps
|
|
26421
|
-
.sort(function (a, b) { return a.roundPosition - b.roundPosition; })
|
|
26422
26417
|
.filter(function (_a) {
|
|
26423
26418
|
var roundNumber = _a.roundNumber;
|
|
26424
26419
|
return !structureData_1.inactiveRounds.includes(roundNumber);
|
|
@@ -26449,9 +26444,7 @@ function pruneDrawDefinition(_a) {
|
|
|
26449
26444
|
}
|
|
26450
26445
|
});
|
|
26451
26446
|
if (matchPlayDrawPositions) {
|
|
26452
|
-
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) {
|
|
26453
|
-
return existingDrawPositions_1.includes(assignment.drawPosition);
|
|
26454
|
-
}).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) {
|
|
26455
26448
|
assignment.drawPosition = drawPositionsMap_1[assignment.drawPosition];
|
|
26456
26449
|
return assignment;
|
|
26457
26450
|
});
|
|
@@ -26510,17 +26503,21 @@ function assignDrawPosition(_a) {
|
|
|
26510
26503
|
return __assign({}, SUCCESS);
|
|
26511
26504
|
}
|
|
26512
26505
|
|
|
26513
|
-
function deleteAdHocMatchUps(
|
|
26514
|
-
var e_1,
|
|
26515
|
-
var _c, _d, _e, _f, _g;
|
|
26516
|
-
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;
|
|
26517
26510
|
if (typeof drawDefinition !== 'object')
|
|
26518
26511
|
return { error: MISSING_DRAW_DEFINITION };
|
|
26519
|
-
if (typeof structureId !== 'string')
|
|
26520
|
-
return { error: MISSING_STRUCTURE_ID };
|
|
26521
26512
|
if (!Array.isArray(matchUpIds))
|
|
26522
26513
|
return { error: INVALID_VALUES };
|
|
26523
|
-
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; });
|
|
26524
26521
|
if (!structure)
|
|
26525
26522
|
return { error: STRUCTURE_NOT_FOUND };
|
|
26526
26523
|
var existingMatchUps = structure === null || structure === void 0 ? void 0 : structure.matchUps;
|
|
@@ -26529,21 +26526,28 @@ function deleteAdHocMatchUps(_a) {
|
|
|
26529
26526
|
return { error: INVALID_STRUCTURE };
|
|
26530
26527
|
}
|
|
26531
26528
|
var matchUpIdsWithScoreValue = [];
|
|
26532
|
-
var matchUpsToDelete = (
|
|
26529
|
+
var matchUpsToDelete = (_f = existingMatchUps === null || existingMatchUps === void 0 ? void 0 : existingMatchUps.filter(function (_a) {
|
|
26533
26530
|
var matchUpId = _a.matchUpId, score = _a.score;
|
|
26534
26531
|
if (checkScoreHasValue({ score: score }))
|
|
26535
26532
|
matchUpIdsWithScoreValue.push(matchUpId);
|
|
26536
26533
|
return matchUpIds.includes(matchUpId);
|
|
26537
|
-
})) !== null &&
|
|
26538
|
-
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();
|
|
26539
26543
|
if (matchUpIdsToDelete.length) {
|
|
26540
|
-
structure.matchUps = ((
|
|
26544
|
+
structure.matchUps = ((_g = structure.matchUps) !== null && _g !== void 0 ? _g : []).filter(function (_a) {
|
|
26541
26545
|
var matchUpId = _a.matchUpId;
|
|
26542
26546
|
return !matchUpIdsToDelete.includes(matchUpId);
|
|
26543
26547
|
});
|
|
26544
26548
|
deleteMatchUpsNotice({
|
|
26545
26549
|
tournamentId: tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.tournamentId,
|
|
26546
|
-
matchUpIds: matchUpIdsToDelete,
|
|
26550
|
+
matchUpIds: __spreadArray(__spreadArray([], __read(tieMatchUpIdsToDelete), false), __read(matchUpIdsToDelete), false),
|
|
26547
26551
|
action: 'deleteAdHocMatchUps',
|
|
26548
26552
|
eventId: event === null || event === void 0 ? void 0 : event.eventId,
|
|
26549
26553
|
drawDefinition: drawDefinition,
|
|
@@ -26575,7 +26579,7 @@ function deleteAdHocMatchUps(_a) {
|
|
|
26575
26579
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
26576
26580
|
finally {
|
|
26577
26581
|
try {
|
|
26578
|
-
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);
|
|
26579
26583
|
}
|
|
26580
26584
|
finally { if (e_1) throw e_1.error; }
|
|
26581
26585
|
}
|
|
@@ -26584,7 +26588,7 @@ function deleteAdHocMatchUps(_a) {
|
|
|
26584
26588
|
structure.positionAssignments = unique(structure.matchUps
|
|
26585
26589
|
.flatMap(function (matchUp) { var _a; return ((_a = matchUp.sides) !== null && _a !== void 0 ? _a : []).map(function (side) { return side.participantId; }); })
|
|
26586
26590
|
.filter(Boolean)).map(function (participantId) { return ({ participantId: participantId }); });
|
|
26587
|
-
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;
|
|
26588
26592
|
var result = updateAssignmentParticipantResults({
|
|
26589
26593
|
positionAssignments: structure.positionAssignments,
|
|
26590
26594
|
matchUps: structure.matchUps,
|
|
@@ -26639,11 +26643,11 @@ function removeRoundMatchUps(_a) {
|
|
|
26639
26643
|
}
|
|
26640
26644
|
return __assign({}, SUCCESS);
|
|
26641
26645
|
}
|
|
26642
|
-
// TODO: move to drawEngine and passthrough
|
|
26643
26646
|
function removeAdHocRound(_a) {
|
|
26644
26647
|
var _b;
|
|
26645
26648
|
var removeCompletedMatchUps = _a.removeCompletedMatchUps, drawDefinition = _a.drawDefinition, tournamentId = _a.tournamentId, roundNumber = _a.roundNumber, structure = _a.structure, eventId = _a.eventId;
|
|
26646
26649
|
var matchUps = (_b = structure === null || structure === void 0 ? void 0 : structure.matchUps) !== null && _b !== void 0 ? _b : [];
|
|
26650
|
+
var deletedTieMatchUpIds = [];
|
|
26647
26651
|
var deletedMatchUpIds = [];
|
|
26648
26652
|
var roundRemoved = false;
|
|
26649
26653
|
var roundNumbers = matchUps
|
|
@@ -26658,13 +26662,17 @@ function removeAdHocRound(_a) {
|
|
|
26658
26662
|
var updatedMatchUps = matchUps.filter(function (matchUp) {
|
|
26659
26663
|
var target = matchUp.roundNumber === roundNumber &&
|
|
26660
26664
|
(!completedMatchUpStatuses.includes(matchUp.matchUpStatus) || removeCompletedMatchUps);
|
|
26661
|
-
if (target)
|
|
26665
|
+
if (target) {
|
|
26662
26666
|
deletedMatchUpIds.push(matchUp.matchUpId);
|
|
26667
|
+
if (matchUp.tieMatchUps) {
|
|
26668
|
+
deletedTieMatchUpIds.push.apply(deletedTieMatchUpIds, __spreadArray([], __read(matchUp.tieMatchUps.map(getMatchUpId)), false));
|
|
26669
|
+
}
|
|
26670
|
+
}
|
|
26663
26671
|
return !target;
|
|
26664
26672
|
});
|
|
26665
26673
|
if (deletedMatchUpIds.length) {
|
|
26666
26674
|
deleteMatchUpsNotice({
|
|
26667
|
-
matchUpIds: deletedMatchUpIds,
|
|
26675
|
+
matchUpIds: __spreadArray(__spreadArray([], __read(deletedTieMatchUpIds), false), __read(deletedMatchUpIds), false),
|
|
26668
26676
|
drawDefinition: drawDefinition,
|
|
26669
26677
|
tournamentId: tournamentId,
|
|
26670
26678
|
eventId: eventId,
|
|
@@ -26693,7 +26701,7 @@ function removeAdHocRound(_a) {
|
|
|
26693
26701
|
function addAdHocMatchUps(_a) {
|
|
26694
26702
|
var _b;
|
|
26695
26703
|
var _c, _d, _e, _f, _g, _h, _j;
|
|
26696
|
-
var tournamentRecord = _a.tournamentRecord, drawDefinition = _a.drawDefinition, structureId = _a.structureId, matchUps = _a.matchUps;
|
|
26704
|
+
var tournamentRecord = _a.tournamentRecord, drawDefinition = _a.drawDefinition, structureId = _a.structureId, matchUps = _a.matchUps, event = _a.event;
|
|
26697
26705
|
if (typeof drawDefinition !== 'object')
|
|
26698
26706
|
return { error: MISSING_DRAW_DEFINITION };
|
|
26699
26707
|
if (!structureId && ((_c = drawDefinition.structures) === null || _c === void 0 ? void 0 : _c.length) === 1)
|
|
@@ -26722,10 +26730,18 @@ function addAdHocMatchUps(_a) {
|
|
|
26722
26730
|
};
|
|
26723
26731
|
}
|
|
26724
26732
|
(_b = structure.matchUps).push.apply(_b, __spreadArray([], __read(matchUps), false));
|
|
26733
|
+
var tieMatchUps = matchUps
|
|
26734
|
+
.map(function (_a) {
|
|
26735
|
+
var tieMatchUps = _a.tieMatchUps;
|
|
26736
|
+
return tieMatchUps;
|
|
26737
|
+
})
|
|
26738
|
+
.filter(Boolean)
|
|
26739
|
+
.flat();
|
|
26725
26740
|
addMatchUpsNotice({
|
|
26726
26741
|
tournamentId: tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.tournamentId,
|
|
26742
|
+
matchUps: __spreadArray(__spreadArray([], __read(tieMatchUps), false), __read(matchUps), false),
|
|
26743
|
+
eventId: event === null || event === void 0 ? void 0 : event.eventId,
|
|
26727
26744
|
drawDefinition: drawDefinition,
|
|
26728
|
-
matchUps: matchUps,
|
|
26729
26745
|
});
|
|
26730
26746
|
modifyDrawNotice({ drawDefinition: drawDefinition, structureIds: [structureId] });
|
|
26731
26747
|
return __assign({}, SUCCESS);
|
|
@@ -29429,6 +29445,35 @@ function deriveQualifyingPositions(_a) {
|
|
|
29429
29445
|
return qualifyingPositions;
|
|
29430
29446
|
}
|
|
29431
29447
|
|
|
29448
|
+
function getCoercedDrawType(params) {
|
|
29449
|
+
var drawTypeCoercion = params.drawTypeCoercion, enforceMinimumDrawSize = params.enforceMinimumDrawSize;
|
|
29450
|
+
var drawSize = ensureInt(params.drawSize);
|
|
29451
|
+
var drawType = (drawTypeCoercion &&
|
|
29452
|
+
(typeof drawTypeCoercion === 'boolean' || drawTypeCoercion <= 2) &&
|
|
29453
|
+
drawSize === 2 &&
|
|
29454
|
+
SINGLE_ELIMINATION) ||
|
|
29455
|
+
params.drawType ||
|
|
29456
|
+
SINGLE_ELIMINATION;
|
|
29457
|
+
var multiStructure = MULTI_STRUCTURE_DRAWS.includes(drawType);
|
|
29458
|
+
if (drawSize && multiStructure) {
|
|
29459
|
+
if (drawTypeCoercion && ((typeof drawTypeCoercion === 'boolean' && drawSize < 4) || drawSize <= drawTypeCoercion)) {
|
|
29460
|
+
drawType = SINGLE_ELIMINATION;
|
|
29461
|
+
}
|
|
29462
|
+
else if (drawSize < 4 && enforceMinimumDrawSize) {
|
|
29463
|
+
return __assign(__assign({}, decorateResult({
|
|
29464
|
+
context: {
|
|
29465
|
+
enforceMinimumDrawSize: enforceMinimumDrawSize,
|
|
29466
|
+
drawSize: drawSize,
|
|
29467
|
+
drawType: drawType,
|
|
29468
|
+
},
|
|
29469
|
+
result: { error: INVALID_DRAW_SIZE },
|
|
29470
|
+
stack: 'getCoercedDrawType',
|
|
29471
|
+
})), { drawType: drawType });
|
|
29472
|
+
}
|
|
29473
|
+
}
|
|
29474
|
+
return { drawType: drawType };
|
|
29475
|
+
}
|
|
29476
|
+
|
|
29432
29477
|
// first iteration only links to a single playoff structure
|
|
29433
29478
|
// future iteration should allow structureOptions to specify
|
|
29434
29479
|
// groups of finishing drawPositions which playoff
|
|
@@ -29792,10 +29837,19 @@ function generateDrawStructuresAndLinks(params) {
|
|
|
29792
29837
|
var e_1, _a, e_2, _b;
|
|
29793
29838
|
var _c, _d, _e, _f, _g, _h, _j;
|
|
29794
29839
|
var _k = params || {}, _l = _k.enforceMinimumDrawSize, enforceMinimumDrawSize = _l === void 0 ? true : _l, overwriteExisting = _k.overwriteExisting, appliedPolicies = _k.appliedPolicies, staggeredEntry = _k.staggeredEntry, // optional - specifies main structure FEED_IN for drawTypes CURTIS_CONSOLATION, FEED_IN_CHAMPIONSHIPS, FMLC
|
|
29795
|
-
drawDefinition = _k.drawDefinition, tieFormat = _k.tieFormat,
|
|
29840
|
+
drawDefinition = _k.drawDefinition, tieFormat = _k.tieFormat, isMock = _k.isMock, uuids = _k.uuids;
|
|
29841
|
+
var drawSize = ensureInt(params.drawSize);
|
|
29796
29842
|
var drawTypeCoercion = (_c = params.drawTypeCoercion) !== null && _c !== void 0 ? _c : getDrawTypeCoercion({ appliedPolicies: appliedPolicies, drawType: params.drawType });
|
|
29797
29843
|
var stack = 'generateDrawStructuresAndLinks';
|
|
29798
|
-
var
|
|
29844
|
+
var coercedDrawType = getCoercedDrawType({
|
|
29845
|
+
drawType: params.drawType,
|
|
29846
|
+
enforceMinimumDrawSize: enforceMinimumDrawSize,
|
|
29847
|
+
drawTypeCoercion: drawTypeCoercion,
|
|
29848
|
+
drawSize: drawSize,
|
|
29849
|
+
});
|
|
29850
|
+
if (coercedDrawType.error)
|
|
29851
|
+
return coercedDrawType;
|
|
29852
|
+
var drawType = coercedDrawType.drawType;
|
|
29799
29853
|
var structures = [], links = [];
|
|
29800
29854
|
var matchUpType = (_d = params === null || params === void 0 ? void 0 : params.matchUpType) !== null && _d !== void 0 ? _d : SINGLES;
|
|
29801
29855
|
var existingQualifyingStructures = (_e = drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.structures) === null || _e === void 0 ? void 0 : _e.filter(function (_a) {
|
|
@@ -29881,7 +29935,6 @@ function generateDrawStructuresAndLinks(params) {
|
|
|
29881
29935
|
// check that drawSize is a valid value
|
|
29882
29936
|
var invalidDrawSize = drawType !== AD_HOC &&
|
|
29883
29937
|
(!drawSize ||
|
|
29884
|
-
isNaN(drawSize) ||
|
|
29885
29938
|
drawSize < 2 ||
|
|
29886
29939
|
(!staggeredEntry &&
|
|
29887
29940
|
![FEED_IN$1, LUCKY_DRAW].includes(drawType) &&
|
|
@@ -29894,24 +29947,6 @@ function generateDrawStructuresAndLinks(params) {
|
|
|
29894
29947
|
stack: stack,
|
|
29895
29948
|
});
|
|
29896
29949
|
}
|
|
29897
|
-
var multiStructure = MULTI_STRUCTURE_DRAWS.includes(drawType);
|
|
29898
|
-
if (drawSize && ensureInt(drawSize) < 4 && multiStructure) {
|
|
29899
|
-
if (drawTypeCoercion) {
|
|
29900
|
-
drawType = SINGLE_ELIMINATION;
|
|
29901
|
-
}
|
|
29902
|
-
else if (enforceMinimumDrawSize) {
|
|
29903
|
-
return decorateResult({
|
|
29904
|
-
context: {
|
|
29905
|
-
enforceMinimumDrawSize: enforceMinimumDrawSize,
|
|
29906
|
-
invalidDrawSize: invalidDrawSize,
|
|
29907
|
-
drawSize: drawSize,
|
|
29908
|
-
drawType: drawType,
|
|
29909
|
-
},
|
|
29910
|
-
result: { error: INVALID_DRAW_SIZE },
|
|
29911
|
-
stack: stack,
|
|
29912
|
-
});
|
|
29913
|
-
}
|
|
29914
|
-
}
|
|
29915
29950
|
var _o = getGenerators(params), generators = _o.generators, error = _o.error;
|
|
29916
29951
|
if (error) {
|
|
29917
29952
|
return { error: error };
|
|
@@ -32109,8 +32144,8 @@ var tieFormatDefaults = function (params) {
|
|
|
32109
32144
|
|
|
32110
32145
|
function drawMatic(params) {
|
|
32111
32146
|
var e_1, _a, e_2, _b;
|
|
32112
|
-
var _c, _d, _e, _f, _g, _h, _j, _k;
|
|
32113
|
-
var restrictEntryStatus = params.restrictEntryStatus,
|
|
32147
|
+
var _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
32148
|
+
var restrictEntryStatus = params.restrictEntryStatus, enableDoubleRobin = params.enableDoubleRobin, _m = params.adHocRatings, adHocRatings = _m === void 0 ? {} : _m, generateMatchUps = params.generateMatchUps, tournamentRecord = params.tournamentRecord, encounterValue = params.encounterValue, sameTeamValue = params.sameTeamValue, drawDefinition = params.drawDefinition, scaleAccessor = params.scaleAccessor, maxIterations = params.maxIterations, roundsCount = params.roundsCount, matchUpIds = params.matchUpIds, scaleName = params.scaleName, // custom rating name to seed dynamic ratings
|
|
32114
32149
|
idPrefix = params.idPrefix, salted = params.salted, event = params.event;
|
|
32115
32150
|
if (roundsCount && typeof roundsCount !== 'number') {
|
|
32116
32151
|
return { error: INVALID_VALUES, info: 'roundsCount must be a number' };
|
|
@@ -32140,7 +32175,9 @@ function drawMatic(params) {
|
|
|
32140
32175
|
else {
|
|
32141
32176
|
participantIds = enteredParticipantIds;
|
|
32142
32177
|
}
|
|
32143
|
-
if (roundsCount &&
|
|
32178
|
+
if (roundsCount &&
|
|
32179
|
+
roundsCount > participantIds.length - 1 &&
|
|
32180
|
+
(!enableDoubleRobin || roundsCount > (participantIds.length - 1) * 2)) {
|
|
32144
32181
|
return { error: INVALID_VALUES, info: 'Not enough participants for roundsCount' };
|
|
32145
32182
|
}
|
|
32146
32183
|
// if no structureId is specified find the latest AD_HOC stage which has matchUps
|
|
@@ -32184,15 +32221,15 @@ function drawMatic(params) {
|
|
|
32184
32221
|
adHocRatings[participantId] = scaleValue;
|
|
32185
32222
|
};
|
|
32186
32223
|
try {
|
|
32187
|
-
for (var
|
|
32188
|
-
var participantId =
|
|
32224
|
+
for (var _o = __values(participantIds !== null && participantIds !== void 0 ? participantIds : []), _p = _o.next(); !_p.done; _p = _o.next()) {
|
|
32225
|
+
var participantId = _p.value;
|
|
32189
32226
|
_loop_1(participantId);
|
|
32190
32227
|
}
|
|
32191
32228
|
}
|
|
32192
32229
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
32193
32230
|
finally {
|
|
32194
32231
|
try {
|
|
32195
|
-
if (
|
|
32232
|
+
if (_p && !_p.done && (_a = _o.return)) _a.call(_o);
|
|
32196
32233
|
}
|
|
32197
32234
|
finally { if (e_1) throw e_1.error; }
|
|
32198
32235
|
}
|
|
@@ -32202,8 +32239,8 @@ function drawMatic(params) {
|
|
|
32202
32239
|
var roundResults = [];
|
|
32203
32240
|
var roundNumber;
|
|
32204
32241
|
try {
|
|
32205
|
-
for (var
|
|
32206
|
-
var iteration =
|
|
32242
|
+
for (var _q = __values(generateRange(1, (roundsCount !== null && roundsCount !== void 0 ? roundsCount : 1) + 1)), _r = _q.next(); !_r.done; _r = _q.next()) {
|
|
32243
|
+
var iteration = _r.value;
|
|
32207
32244
|
var result = generateDrawMaticRound({
|
|
32208
32245
|
ignoreLastRoundNumber: true,
|
|
32209
32246
|
tournamentParticipants: tournamentParticipants,
|
|
@@ -32227,7 +32264,7 @@ function drawMatic(params) {
|
|
|
32227
32264
|
return result;
|
|
32228
32265
|
var roundMatchUps = result.matchUps, roundResult = __rest(result, ["matchUps"]);
|
|
32229
32266
|
roundResults.push(__assign(__assign({}, roundResult), { iteration: iteration, matchUpsCount: roundMatchUps === null || roundMatchUps === void 0 ? void 0 : roundMatchUps.length }));
|
|
32230
|
-
roundNumber = ((roundResult === null || roundResult === void 0 ? void 0 : roundResult.roundNumber)
|
|
32267
|
+
roundNumber = ((_l = roundResult === null || roundResult === void 0 ? void 0 : roundResult.roundNumber) !== null && _l !== void 0 ? _l : 1) + 1;
|
|
32231
32268
|
if (roundMatchUps === null || roundMatchUps === void 0 ? void 0 : roundMatchUps.length) {
|
|
32232
32269
|
matchUps.push.apply(matchUps, __spreadArray([], __read(roundMatchUps), false));
|
|
32233
32270
|
}
|
|
@@ -32236,7 +32273,7 @@ function drawMatic(params) {
|
|
|
32236
32273
|
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
32237
32274
|
finally {
|
|
32238
32275
|
try {
|
|
32239
|
-
if (
|
|
32276
|
+
if (_r && !_r.done && (_b = _q.return)) _b.call(_q);
|
|
32240
32277
|
}
|
|
32241
32278
|
finally { if (e_2) throw e_2.error; }
|
|
32242
32279
|
}
|
|
@@ -32544,7 +32581,7 @@ function generateDrawDefinition(params) {
|
|
|
32544
32581
|
var _a, e_1, _b, e_2, _c, e_3, _d, e_4, _e, _f, e_5, _g, e_6, _h, _j;
|
|
32545
32582
|
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;
|
|
32546
32583
|
var stack = 'generateDrawDefinition';
|
|
32547
|
-
var _35 = params.
|
|
32584
|
+
var _35 = params.enforceMinimumDrawSize, enforceMinimumDrawSize = _35 === void 0 ? true : _35, _36 = params.considerEventEntries, considerEventEntries = _36 === void 0 ? true : _36, // in the absence of drawSize and drawEntries, look to event.entries
|
|
32548
32585
|
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;
|
|
32549
32586
|
var isMock = (_k = params.isMock) !== null && _k !== void 0 ? _k : true;
|
|
32550
32587
|
var idPrefix = params.idPrefix;
|
|
@@ -32553,49 +32590,23 @@ function generateDrawDefinition(params) {
|
|
|
32553
32590
|
event: event,
|
|
32554
32591
|
}).appliedPolicies) !== null && _l !== void 0 ? _l : {};
|
|
32555
32592
|
var policyDefinitions = makeDeepCopy((_m = params.policyDefinitions) !== null && _m !== void 0 ? _m : {}, false, true);
|
|
32556
|
-
var drawTypeCoercion = (_o = params.drawTypeCoercion) !== null && _o !== void 0 ? _o : getDrawTypeCoercion({
|
|
32557
|
-
drawType: params.drawType,
|
|
32558
|
-
policyDefinitions: policyDefinitions,
|
|
32559
|
-
appliedPolicies: appliedPolicies,
|
|
32560
|
-
});
|
|
32561
|
-
var drawType = (drawTypeCoercion && params.drawSize === 2 && SINGLE_ELIMINATION) || params.drawType || SINGLE_ELIMINATION;
|
|
32562
|
-
var seedingPolicy = (_p = policyDefinitions === null || policyDefinitions === void 0 ? void 0 : policyDefinitions[POLICY_TYPE_SEEDING]) !== null && _p !== void 0 ? _p : appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[POLICY_TYPE_SEEDING];
|
|
32563
|
-
var seedingProfile = (_t = (_q = params.seedingProfile) !== null && _q !== void 0 ? _q : (_s = (_r = seedingPolicy === null || seedingPolicy === void 0 ? void 0 : seedingPolicy.seedingProfile) === null || _r === void 0 ? void 0 : _r.drawTypes) === null || _s === void 0 ? void 0 : _s[drawType]) !== null && _t !== void 0 ? _t : seedingPolicy === null || seedingPolicy === void 0 ? void 0 : seedingPolicy.seedingProfile;
|
|
32564
|
-
// extend policyDefinitions only if a seedingProfile was specified in params
|
|
32565
|
-
if (params.seedingProfile) {
|
|
32566
|
-
if (!policyDefinitions[POLICY_TYPE_SEEDING]) {
|
|
32567
|
-
policyDefinitions[POLICY_TYPE_SEEDING] = __assign({}, POLICY_SEEDING_DEFAULT[POLICY_TYPE_SEEDING]);
|
|
32568
|
-
}
|
|
32569
|
-
policyDefinitions[POLICY_TYPE_SEEDING].seedingProfile = seedingProfile;
|
|
32570
|
-
}
|
|
32571
32593
|
// get participants both for entry validation and for automated placement
|
|
32572
32594
|
// automated placement requires them to be "inContext" for avoidance policies to work
|
|
32573
|
-
var
|
|
32595
|
+
var _37 = getParticipants({
|
|
32574
32596
|
withIndividualParticipants: true,
|
|
32575
32597
|
convertExtensions: true,
|
|
32576
32598
|
internalUse: true,
|
|
32577
32599
|
tournamentRecord: tournamentRecord,
|
|
32578
|
-
}), participants =
|
|
32579
|
-
var
|
|
32580
|
-
//
|
|
32581
|
-
// check for restrictions on allowed drawTypes
|
|
32582
|
-
var allowedDrawTypes = !ignoreAllowedDrawTypes &&
|
|
32583
|
-
tournamentRecord &&
|
|
32584
|
-
getAllowedDrawTypes({
|
|
32585
|
-
tournamentRecord: tournamentRecord,
|
|
32586
|
-
categoryType: (_0 = event === null || event === void 0 ? void 0 : event.category) === null || _0 === void 0 ? void 0 : _0.categoryType,
|
|
32587
|
-
categoryName: (_1 = event === null || event === void 0 ? void 0 : event.category) === null || _1 === void 0 ? void 0 : _1.categoryName,
|
|
32588
|
-
});
|
|
32589
|
-
if ((allowedDrawTypes === null || allowedDrawTypes === void 0 ? void 0 : allowedDrawTypes.length) && !allowedDrawTypes.includes(drawType)) {
|
|
32590
|
-
return decorateResult({ result: { error: INVALID_DRAW_TYPE }, stack: stack });
|
|
32591
|
-
}
|
|
32592
|
-
var eventEntries = (_3 = (_2 = event === null || event === void 0 ? void 0 : event.entries) === null || _2 === void 0 ? void 0 : _2.filter(function (entry) { return entry.entryStatus && __spreadArray(__spreadArray([], __read(STRUCTURE_SELECTED_STATUSES), false), [QUALIFIER], false).includes(entry.entryStatus); })) !== null && _3 !== void 0 ? _3 : [];
|
|
32600
|
+
}), participants = _37.participants, participantMap = _37.participantMap;
|
|
32601
|
+
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 : [];
|
|
32602
|
+
// -------------------- BEGIN PARAMETER DERIVATION AND VALIDATION -------------------------
|
|
32593
32603
|
var consideredEntries = ((qualifyingOnly && []) ||
|
|
32594
32604
|
drawEntries ||
|
|
32595
32605
|
(considerEventEntries ? eventEntries : [])).filter(function (_a) {
|
|
32596
32606
|
var entryStage = _a.entryStage;
|
|
32597
32607
|
return !entryStage || entryStage === MAIN;
|
|
32598
32608
|
});
|
|
32609
|
+
var enforceGender = (_t = (_q = params.enforceGender) !== null && _q !== void 0 ? _q : (_s = (_r = policyDefinitions === null || policyDefinitions === void 0 ? void 0 : policyDefinitions[POLICY_TYPE_MATCHUP_ACTIONS]) === null || _r === void 0 ? void 0 : _r.participants) === null || _s === void 0 ? void 0 : _s.enforceGender) !== null && _t !== void 0 ? _t : (_v = (_u = appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[POLICY_TYPE_MATCHUP_ACTIONS]) === null || _u === void 0 ? void 0 : _u.participants) === null || _v === void 0 ? void 0 : _v.enforceGender;
|
|
32599
32610
|
// entries participantTypes must correspond with eventType
|
|
32600
32611
|
// this is only possible if the event is provided
|
|
32601
32612
|
var validEntriesResult = event &&
|
|
@@ -32612,23 +32623,56 @@ function generateDrawDefinition(params) {
|
|
|
32612
32623
|
return decorateResult({ result: validEntriesResult, stack: stack });
|
|
32613
32624
|
var derivedDrawSize = !params.drawSize &&
|
|
32614
32625
|
consideredEntries.length &&
|
|
32615
|
-
![AD_HOC, DOUBLE_ELIMINATION, FEED_IN$1, ROUND_ROBIN, ROUND_ROBIN_WITH_PLAYOFF].includes(drawType) &&
|
|
32626
|
+
![AD_HOC, DOUBLE_ELIMINATION, FEED_IN$1, ROUND_ROBIN, ROUND_ROBIN_WITH_PLAYOFF].includes((_w = params.drawType) !== null && _w !== void 0 ? _w : '') &&
|
|
32616
32627
|
nextPowerOf2(consideredEntries.length);
|
|
32617
32628
|
// coersion of drawSize and seedsCount to integers
|
|
32618
|
-
var drawSize = derivedDrawSize ||
|
|
32619
|
-
|
|
32620
|
-
|
|
32629
|
+
var drawSize = derivedDrawSize || (params.drawSize && ensureInt(params.drawSize)) || false; // required for isNaN check
|
|
32630
|
+
var drawTypeCoercion = (_x = params.drawTypeCoercion) !== null && _x !== void 0 ? _x : getDrawTypeCoercion({
|
|
32631
|
+
drawType: params.drawType,
|
|
32632
|
+
policyDefinitions: policyDefinitions,
|
|
32633
|
+
appliedPolicies: appliedPolicies,
|
|
32634
|
+
});
|
|
32635
|
+
var coercedDrawType = getCoercedDrawType({
|
|
32636
|
+
drawType: params.drawType,
|
|
32637
|
+
enforceMinimumDrawSize: enforceMinimumDrawSize,
|
|
32638
|
+
drawTypeCoercion: drawTypeCoercion,
|
|
32639
|
+
drawSize: drawSize,
|
|
32640
|
+
});
|
|
32641
|
+
if (coercedDrawType.error)
|
|
32642
|
+
return coercedDrawType;
|
|
32643
|
+
var drawType = coercedDrawType.drawType;
|
|
32644
|
+
var seedingPolicy = (_y = policyDefinitions === null || policyDefinitions === void 0 ? void 0 : policyDefinitions[POLICY_TYPE_SEEDING]) !== null && _y !== void 0 ? _y : appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[POLICY_TYPE_SEEDING];
|
|
32645
|
+
var seedingProfile = (_2 = (_z = params.seedingProfile) !== null && _z !== void 0 ? _z : (_1 = (_0 = seedingPolicy === null || seedingPolicy === void 0 ? void 0 : seedingPolicy.seedingProfile) === null || _0 === void 0 ? void 0 : _0.drawTypes) === null || _1 === void 0 ? void 0 : _1[drawType]) !== null && _2 !== void 0 ? _2 : seedingPolicy === null || seedingPolicy === void 0 ? void 0 : seedingPolicy.seedingProfile;
|
|
32646
|
+
// extend policyDefinitions only if a seedingProfile was specified in params
|
|
32647
|
+
if (params.seedingProfile) {
|
|
32648
|
+
if (!policyDefinitions[POLICY_TYPE_SEEDING]) {
|
|
32649
|
+
policyDefinitions[POLICY_TYPE_SEEDING] = __assign({}, POLICY_SEEDING_DEFAULT[POLICY_TYPE_SEEDING]);
|
|
32650
|
+
}
|
|
32651
|
+
policyDefinitions[POLICY_TYPE_SEEDING].seedingProfile = seedingProfile;
|
|
32652
|
+
}
|
|
32653
|
+
// if tournamentRecord is provided, and unless instructed to ignore valid types,
|
|
32654
|
+
// check for restrictions on allowed drawTypes
|
|
32655
|
+
var allowedDrawTypes = !ignoreAllowedDrawTypes &&
|
|
32656
|
+
tournamentRecord &&
|
|
32657
|
+
getAllowedDrawTypes({
|
|
32658
|
+
tournamentRecord: tournamentRecord,
|
|
32659
|
+
categoryType: (_3 = event === null || event === void 0 ? void 0 : event.category) === null || _3 === void 0 ? void 0 : _3.categoryType,
|
|
32660
|
+
categoryName: (_4 = event === null || event === void 0 ? void 0 : event.category) === null || _4 === void 0 ? void 0 : _4.categoryName,
|
|
32661
|
+
});
|
|
32662
|
+
if ((allowedDrawTypes === null || allowedDrawTypes === void 0 ? void 0 : allowedDrawTypes.length) && !allowedDrawTypes.includes(drawType)) {
|
|
32663
|
+
return decorateResult({ result: { error: INVALID_DRAW_TYPE }, stack: stack });
|
|
32664
|
+
}
|
|
32621
32665
|
if (isNaN(drawSize) && drawType !== AD_HOC) {
|
|
32622
32666
|
return decorateResult({
|
|
32623
32667
|
result: { error: MISSING_DRAW_SIZE },
|
|
32624
32668
|
stack: stack,
|
|
32625
32669
|
});
|
|
32626
32670
|
}
|
|
32627
|
-
|
|
32671
|
+
// -------------------- END OF PARAMETER DERIVATION AND VALIDATION -------------------------
|
|
32628
32672
|
var eventType = event === null || event === void 0 ? void 0 : event.eventType;
|
|
32629
|
-
var matchUpType = (
|
|
32673
|
+
var matchUpType = (_5 = params.matchUpType) !== null && _5 !== void 0 ? _5 : eventType;
|
|
32630
32674
|
var existingDrawDefinition = params.drawId
|
|
32631
|
-
? (
|
|
32675
|
+
? (_6 = event === null || event === void 0 ? void 0 : event.drawDefinitions) === null || _6 === void 0 ? void 0 : _6.find(function (d) { return d.drawId === params.drawId; })
|
|
32632
32676
|
: undefined;
|
|
32633
32677
|
// drawDefinition cannot have both tieFormat and matchUpFormat
|
|
32634
32678
|
var tieFormat = params.tieFormat, matchUpFormat = params.matchUpFormat;
|
|
@@ -32636,15 +32680,15 @@ function generateDrawDefinition(params) {
|
|
|
32636
32680
|
if (matchUpType === TEAM$1 && eventType === TEAM$1) {
|
|
32637
32681
|
// if there is an existingDrawDefinition which has a tieFormat on MAIN structure
|
|
32638
32682
|
// use this tieFormat ONLY when no tieFormat is specified in params
|
|
32639
|
-
var existingMainTieFormat = (
|
|
32683
|
+
var existingMainTieFormat = (_8 = (_7 = existingDrawDefinition === null || existingDrawDefinition === void 0 ? void 0 : existingDrawDefinition.structures) === null || _7 === void 0 ? void 0 : _7.find(function (_a) {
|
|
32640
32684
|
var stage = _a.stage;
|
|
32641
32685
|
return stage === MAIN;
|
|
32642
|
-
})) === null ||
|
|
32686
|
+
})) === null || _8 === void 0 ? void 0 : _8.tieFormat;
|
|
32643
32687
|
tieFormat =
|
|
32644
32688
|
tieFormat ||
|
|
32645
32689
|
existingMainTieFormat ||
|
|
32646
32690
|
// if tieFormatName is provided and it matches the name of the tieFormat attached to parent event...
|
|
32647
|
-
(tieFormatName && ((
|
|
32691
|
+
(tieFormatName && ((_9 = event === null || event === void 0 ? void 0 : event.tieFormat) === null || _9 === void 0 ? void 0 : _9.tieFormatName) === tieFormatName && event.tieFormat) ||
|
|
32648
32692
|
// if the tieFormatName is not found in the factory then will use default
|
|
32649
32693
|
(tieFormatName &&
|
|
32650
32694
|
tieFormatDefaults({
|
|
@@ -32698,7 +32742,7 @@ function generateDrawDefinition(params) {
|
|
|
32698
32742
|
var result = checkTieFormat({ tieFormat: tieFormat });
|
|
32699
32743
|
if (result.error)
|
|
32700
32744
|
return decorateResult({ result: result, stack: stack });
|
|
32701
|
-
drawDefinition.tieFormat = (
|
|
32745
|
+
drawDefinition.tieFormat = (_10 = result.tieFormat) !== null && _10 !== void 0 ? _10 : tieFormat;
|
|
32702
32746
|
}
|
|
32703
32747
|
else if (matchUpFormat) {
|
|
32704
32748
|
var result = setMatchUpMatchUpFormat({
|
|
@@ -32736,8 +32780,8 @@ function generateDrawDefinition(params) {
|
|
|
32736
32780
|
}
|
|
32737
32781
|
else {
|
|
32738
32782
|
try {
|
|
32739
|
-
for (var
|
|
32740
|
-
var key =
|
|
32783
|
+
for (var _38 = __values(Object.keys(policyDefinitions)), _39 = _38.next(); !_39.done; _39 = _38.next()) {
|
|
32784
|
+
var key = _39.value;
|
|
32741
32785
|
if (JSON.stringify(appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[key]) !== JSON.stringify(policyDefinitions[key])) {
|
|
32742
32786
|
policiesToAttach[key] = policyDefinitions[key];
|
|
32743
32787
|
}
|
|
@@ -32746,7 +32790,7 @@ function generateDrawDefinition(params) {
|
|
|
32746
32790
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
32747
32791
|
finally {
|
|
32748
32792
|
try {
|
|
32749
|
-
if (
|
|
32793
|
+
if (_39 && !_39.done && (_b = _38.return)) _b.call(_38);
|
|
32750
32794
|
}
|
|
32751
32795
|
finally { if (e_1) throw e_1.error; }
|
|
32752
32796
|
}
|
|
@@ -32772,17 +32816,17 @@ function generateDrawDefinition(params) {
|
|
|
32772
32816
|
}
|
|
32773
32817
|
// ---------------------------------------------------------------------------
|
|
32774
32818
|
// find existing MAIN structureId if existingDrawDefinition
|
|
32775
|
-
var structureId = (
|
|
32819
|
+
var structureId = (_12 = (_11 = existingDrawDefinition === null || existingDrawDefinition === void 0 ? void 0 : existingDrawDefinition.structures) === null || _11 === void 0 ? void 0 : _11.find(function (structure) { return structure.stage === MAIN && structure.stageSequence === 1; })) === null || _12 === void 0 ? void 0 : _12.structureId;
|
|
32776
32820
|
var entries = drawEntries !== null && drawEntries !== void 0 ? drawEntries : eventEntries;
|
|
32777
32821
|
var positioningReports = [];
|
|
32778
32822
|
var drawTypeResult;
|
|
32779
32823
|
var conflicts = [];
|
|
32780
|
-
var generateQualifyingPlaceholder = params.qualifyingPlaceholder && !((
|
|
32824
|
+
var generateQualifyingPlaceholder = params.qualifyingPlaceholder && !((_13 = params.qualifyingProfiles) === null || _13 === void 0 ? void 0 : _13.length) && !existingDrawDefinition;
|
|
32781
32825
|
var existingQualifyingStructures = existingDrawDefinition
|
|
32782
|
-
? (
|
|
32826
|
+
? (_14 = existingDrawDefinition.structures) === null || _14 === void 0 ? void 0 : _14.filter(function (structure) { return structure.stage === QUALIFYING; })
|
|
32783
32827
|
: [];
|
|
32784
32828
|
var existingQualifyingPlaceholderStructureId = (existingQualifyingStructures === null || existingQualifyingStructures === void 0 ? void 0 : existingQualifyingStructures.length) === 1 &&
|
|
32785
|
-
!((
|
|
32829
|
+
!((_15 = existingQualifyingStructures[0].matchUps) === null || _15 === void 0 ? void 0 : _15.length) &&
|
|
32786
32830
|
existingQualifyingStructures[0].structureId;
|
|
32787
32831
|
if (existingQualifyingPlaceholderStructureId) {
|
|
32788
32832
|
var qualifyingProfiles = params.qualifyingProfiles;
|
|
@@ -32798,24 +32842,24 @@ function generateDrawDefinition(params) {
|
|
|
32798
32842
|
if (qualifyingResult === null || qualifyingResult === void 0 ? void 0 : qualifyingResult.error) {
|
|
32799
32843
|
return qualifyingResult;
|
|
32800
32844
|
}
|
|
32801
|
-
drawDefinition.structures = (
|
|
32845
|
+
drawDefinition.structures = (_16 = drawDefinition.structures) === null || _16 === void 0 ? void 0 : _16.filter(function (_a) {
|
|
32802
32846
|
var structureId = _a.structureId;
|
|
32803
32847
|
return structureId !== existingQualifyingPlaceholderStructureId;
|
|
32804
32848
|
});
|
|
32805
|
-
drawDefinition.links = (
|
|
32849
|
+
drawDefinition.links = (_17 = drawDefinition.links) === null || _17 === void 0 ? void 0 : _17.filter(function (_a) {
|
|
32806
32850
|
var source = _a.source;
|
|
32807
32851
|
return source.structureId !== existingQualifyingPlaceholderStructureId;
|
|
32808
32852
|
});
|
|
32809
|
-
var
|
|
32853
|
+
var _40 = qualifyingResult !== null && qualifyingResult !== void 0 ? qualifyingResult : {}, qualifiersCount = _40.qualifiersCount, qualifyingDrawPositionsCount = _40.qualifyingDrawPositionsCount, qualifyingDetails = _40.qualifyingDetails;
|
|
32810
32854
|
if (qualifyingDrawPositionsCount) {
|
|
32811
32855
|
if (qualifyingResult === null || qualifyingResult === void 0 ? void 0 : qualifyingResult.structures) {
|
|
32812
|
-
(
|
|
32856
|
+
(_18 = drawDefinition.structures) === null || _18 === void 0 ? void 0 : _18.push.apply(_18, __spreadArray([], __read(qualifyingResult.structures), false));
|
|
32813
32857
|
}
|
|
32814
32858
|
if (qualifyingResult === null || qualifyingResult === void 0 ? void 0 : qualifyingResult.links) {
|
|
32815
|
-
(
|
|
32859
|
+
(_19 = drawDefinition.links) === null || _19 === void 0 ? void 0 : _19.push.apply(_19, __spreadArray([], __read(qualifyingResult.links), false));
|
|
32816
32860
|
}
|
|
32817
32861
|
}
|
|
32818
|
-
var mainStructure = (
|
|
32862
|
+
var mainStructure = (_20 = drawDefinition.structures) === null || _20 === void 0 ? void 0 : _20.find(function (_a) {
|
|
32819
32863
|
var stage = _a.stage, stageSequence = _a.stageSequence;
|
|
32820
32864
|
return stage === MAIN && stageSequence === 1;
|
|
32821
32865
|
});
|
|
@@ -32841,12 +32885,12 @@ function generateDrawDefinition(params) {
|
|
|
32841
32885
|
if (result.error)
|
|
32842
32886
|
return result;
|
|
32843
32887
|
try {
|
|
32844
|
-
for (var
|
|
32888
|
+
for (var _41 = __values((drawEntries !== null && drawEntries !== void 0 ? drawEntries : []).filter(function (_a) {
|
|
32845
32889
|
var entryStage = _a.entryStage;
|
|
32846
32890
|
return entryStage === QUALIFYING;
|
|
32847
|
-
})),
|
|
32848
|
-
var entry =
|
|
32849
|
-
var entryData = __assign(__assign({}, entry), { entryStage: (
|
|
32891
|
+
})), _42 = _41.next(); !_42.done; _42 = _41.next()) {
|
|
32892
|
+
var entry = _42.value;
|
|
32893
|
+
var entryData = __assign(__assign({}, entry), { entryStage: (_21 = entry.entryStage) !== null && _21 !== void 0 ? _21 : MAIN, drawDefinition: drawDefinition });
|
|
32850
32894
|
// ignore errors (EXITING_PARTICIPANT)
|
|
32851
32895
|
addDrawEntry(entryData);
|
|
32852
32896
|
}
|
|
@@ -32854,23 +32898,23 @@ function generateDrawDefinition(params) {
|
|
|
32854
32898
|
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
32855
32899
|
finally {
|
|
32856
32900
|
try {
|
|
32857
|
-
if (
|
|
32901
|
+
if (_42 && !_42.done && (_c = _41.return)) _c.call(_41);
|
|
32858
32902
|
}
|
|
32859
32903
|
finally { if (e_2) throw e_2.error; }
|
|
32860
32904
|
}
|
|
32861
32905
|
try {
|
|
32862
|
-
for (var
|
|
32863
|
-
var qualifyingDetail =
|
|
32906
|
+
for (var _43 = __values(qualifyingDetails || []), _44 = _43.next(); !_44.done; _44 = _43.next()) {
|
|
32907
|
+
var qualifyingDetail = _44.value;
|
|
32864
32908
|
var qualifyingRoundNumber = qualifyingDetail.finalQualifyingRoundNumber, qualifyingStructureId = qualifyingDetail.finalQualifyingStructureId, targetEntryRound = qualifyingDetail.roundTarget, finishingPositions = qualifyingDetail.finishingPositions, linkType = qualifyingDetail.linkType;
|
|
32865
32909
|
var link = mainStructure &&
|
|
32866
|
-
((
|
|
32910
|
+
((_22 = generateQualifyingLink({
|
|
32867
32911
|
targetStructureId: mainStructure.structureId,
|
|
32868
32912
|
sourceStructureId: qualifyingStructureId,
|
|
32869
32913
|
sourceRoundNumber: qualifyingRoundNumber,
|
|
32870
32914
|
finishingPositions: finishingPositions,
|
|
32871
32915
|
targetEntryRound: targetEntryRound,
|
|
32872
32916
|
linkType: linkType,
|
|
32873
|
-
})) === null ||
|
|
32917
|
+
})) === null || _22 === void 0 ? void 0 : _22.link);
|
|
32874
32918
|
if (link === null || link === void 0 ? void 0 : link.error)
|
|
32875
32919
|
return link;
|
|
32876
32920
|
if (link) {
|
|
@@ -32883,7 +32927,7 @@ function generateDrawDefinition(params) {
|
|
|
32883
32927
|
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
32884
32928
|
finally {
|
|
32885
32929
|
try {
|
|
32886
|
-
if (
|
|
32930
|
+
if (_44 && !_44.done && (_d = _43.return)) _d.call(_43);
|
|
32887
32931
|
}
|
|
32888
32932
|
finally { if (e_3) throw e_3.error; }
|
|
32889
32933
|
}
|
|
@@ -32902,7 +32946,7 @@ function generateDrawDefinition(params) {
|
|
|
32902
32946
|
// if drawEntries and entryStage !== stage ignore
|
|
32903
32947
|
if (drawEntries && entry.entryStage && entry.entryStage !== MAIN)
|
|
32904
32948
|
continue;
|
|
32905
|
-
var entryData = __assign(__assign({}, entry), { ignoreStageSpace: ignoreStageSpace !== null && ignoreStageSpace !== void 0 ? ignoreStageSpace : drawType === AD_HOC, entryStage: (
|
|
32949
|
+
var entryData = __assign(__assign({}, entry), { ignoreStageSpace: ignoreStageSpace !== null && ignoreStageSpace !== void 0 ? ignoreStageSpace : drawType === AD_HOC, entryStage: (_23 = entry.entryStage) !== null && _23 !== void 0 ? _23 : MAIN, drawDefinition: drawDefinition, drawType: drawType });
|
|
32906
32950
|
var result = addDrawEntry(entryData);
|
|
32907
32951
|
if (drawEntries && result.error) {
|
|
32908
32952
|
// only report errors with drawEntries
|
|
@@ -32919,8 +32963,7 @@ function generateDrawDefinition(params) {
|
|
|
32919
32963
|
finally { if (e_4) throw e_4.error; }
|
|
32920
32964
|
}
|
|
32921
32965
|
// temporary until seeding is supported in LUCKY_DRAW
|
|
32922
|
-
|
|
32923
|
-
seedsCount = 0;
|
|
32966
|
+
var seedsCount = drawType === LUCKY_DRAW ? 0 : ensureInt((_24 = params.seedsCount) !== null && _24 !== void 0 ? _24 : 0);
|
|
32924
32967
|
var structureResult = prepareStage(__assign(__assign(__assign({}, drawTypeResult), params), { qualifyingOnly: !drawSize || qualifyingOnly, // ooo!! If there is no drawSize then MAIN is not being generated
|
|
32925
32968
|
appliedPolicies: appliedPolicies, drawDefinition: drawDefinition, seedingProfile: seedingProfile, participants: participants, stage: MAIN, seedsCount: seedsCount, placeByes: placeByes, drawSize: drawSize, entries: entries }));
|
|
32926
32969
|
if (structureResult.error && !structureResult.conflicts) {
|
|
@@ -32939,7 +32982,7 @@ function generateDrawDefinition(params) {
|
|
|
32939
32982
|
var participantIds = entries_2 === null || entries_2 === void 0 ? void 0 : entries_2.map(getParticipantId);
|
|
32940
32983
|
var matchUpsCount_1 = entries_2 ? Math.floor(entries_2.length / 2) : 0;
|
|
32941
32984
|
if (params.automated) {
|
|
32942
|
-
var
|
|
32985
|
+
var _45 = (_27 = params.drawMatic) !== null && _27 !== void 0 ? _27 : {}, restrictEntryStatus = _45.restrictEntryStatus, generateMatchUps = _45.generateMatchUps, structureId_1 = _45.structureId, matchUpIds = _45.matchUpIds, scaleName = _45.scaleName;
|
|
32943
32986
|
var result = drawMatic({
|
|
32944
32987
|
eventType: (_29 = (_28 = params.drawMatic) === null || _28 === void 0 ? void 0 : _28.eventType) !== null && _29 !== void 0 ? _29 : matchUpType,
|
|
32945
32988
|
generateMatchUps: generateMatchUps !== null && generateMatchUps !== void 0 ? generateMatchUps : true,
|
|
@@ -32960,6 +33003,7 @@ function generateDrawDefinition(params) {
|
|
|
32960
33003
|
tournamentRecord: tournamentRecord,
|
|
32961
33004
|
drawDefinition: drawDefinition,
|
|
32962
33005
|
structureId: structureId_1,
|
|
33006
|
+
event: event,
|
|
32963
33007
|
});
|
|
32964
33008
|
}
|
|
32965
33009
|
else {
|
|
@@ -32977,6 +33021,7 @@ function generateDrawDefinition(params) {
|
|
|
32977
33021
|
drawDefinition: drawDefinition,
|
|
32978
33022
|
structureId: structureId,
|
|
32979
33023
|
matchUps: matchUps,
|
|
33024
|
+
event: event,
|
|
32980
33025
|
});
|
|
32981
33026
|
});
|
|
32982
33027
|
}
|
|
@@ -32991,8 +33036,8 @@ function generateDrawDefinition(params) {
|
|
|
32991
33036
|
var roundTarget = 1;
|
|
32992
33037
|
params.qualifyingProfiles.sort(roundTargetSort);
|
|
32993
33038
|
try {
|
|
32994
|
-
for (var
|
|
32995
|
-
var roundTargetProfile =
|
|
33039
|
+
for (var _46 = __values(params.qualifyingProfiles), _47 = _46.next(); !_47.done; _47 = _46.next()) {
|
|
33040
|
+
var roundTargetProfile = _47.value;
|
|
32996
33041
|
if (!Array.isArray(roundTargetProfile.structureProfiles))
|
|
32997
33042
|
return decorateResult({
|
|
32998
33043
|
info: mustBeAnArray('structureProfiles'),
|
|
@@ -33005,8 +33050,8 @@ function generateDrawDefinition(params) {
|
|
|
33005
33050
|
try {
|
|
33006
33051
|
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()) {
|
|
33007
33052
|
var structureProfile = sortedStructureProfiles_1_1.value;
|
|
33008
|
-
var qualifyingRoundNumber = structureProfile.qualifyingRoundNumber, qualifyingPositions = structureProfile.qualifyingPositions, seededParticipants = structureProfile.seededParticipants, seedingScaleName = structureProfile.seedingScaleName,
|
|
33009
|
-
var qualifyingStageResult = prepareStage(__assign(__assign(__assign({}, drawTypeResult), params), { seedingProfile: (_31 = structureProfile.seedingProfile) !== null && _31 !== void 0 ? _31 : 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:
|
|
33053
|
+
var qualifyingRoundNumber = structureProfile.qualifyingRoundNumber, qualifyingPositions = structureProfile.qualifyingPositions, seededParticipants = structureProfile.seededParticipants, seedingScaleName = structureProfile.seedingScaleName, _48 = structureProfile.seedsCount, seedsCount = _48 === void 0 ? 0 : _48, seedByRanking = structureProfile.seedByRanking, placeByes_1 = structureProfile.placeByes, drawSize_1 = structureProfile.drawSize;
|
|
33054
|
+
var qualifyingStageResult = prepareStage(__assign(__assign(__assign({}, drawTypeResult), params), { seedingProfile: (_31 = structureProfile.seedingProfile) !== null && _31 !== void 0 ? _31 : 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 }));
|
|
33010
33055
|
if (qualifyingStageResult.error) {
|
|
33011
33056
|
return qualifyingStageResult;
|
|
33012
33057
|
}
|
|
@@ -33035,7 +33080,7 @@ function generateDrawDefinition(params) {
|
|
|
33035
33080
|
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
33036
33081
|
finally {
|
|
33037
33082
|
try {
|
|
33038
|
-
if (
|
|
33083
|
+
if (_47 && !_47.done && (_g = _46.return)) _g.call(_46);
|
|
33039
33084
|
}
|
|
33040
33085
|
finally { if (e_5) throw e_5.error; }
|
|
33041
33086
|
}
|
|
@@ -48595,9 +48640,11 @@ function generateAddress(addressAttributes) {
|
|
|
48595
48640
|
|
|
48596
48641
|
var lastNames = [
|
|
48597
48642
|
"Abbey",
|
|
48598
|
-
"Assange",
|
|
48599
48643
|
"Ahern",
|
|
48600
48644
|
"Ampleforth",
|
|
48645
|
+
"Ananiadis",
|
|
48646
|
+
"Andelic",
|
|
48647
|
+
"Assange",
|
|
48601
48648
|
"Atreides",
|
|
48602
48649
|
"Austen",
|
|
48603
48650
|
"Bach",
|
|
@@ -48634,6 +48681,7 @@ var lastNames = [
|
|
|
48634
48681
|
"Escher",
|
|
48635
48682
|
"Eyre",
|
|
48636
48683
|
"Faulkner",
|
|
48684
|
+
"Fulcher",
|
|
48637
48685
|
"Fukuoka",
|
|
48638
48686
|
"Godel",
|
|
48639
48687
|
"Goldstein",
|
|
@@ -48699,6 +48747,7 @@ var lastNames = [
|
|
|
48699
48747
|
"Watson",
|
|
48700
48748
|
"Wolin",
|
|
48701
48749
|
"Wirt",
|
|
48750
|
+
"Waschuk",
|
|
48702
48751
|
"Wormwood"
|
|
48703
48752
|
];
|
|
48704
48753
|
var firstFemale = [
|
|
@@ -48777,10 +48826,12 @@ var firstMale = [
|
|
|
48777
48826
|
"August",
|
|
48778
48827
|
"Axel",
|
|
48779
48828
|
"Barda",
|
|
48829
|
+
"Barry",
|
|
48780
48830
|
"Bill",
|
|
48781
48831
|
"Bruce",
|
|
48782
48832
|
"Charles",
|
|
48783
48833
|
"Chris",
|
|
48834
|
+
"Constantine",
|
|
48784
48835
|
"Darwin",
|
|
48785
48836
|
"David",
|
|
48786
48837
|
"Derrick",
|
|
@@ -65080,10 +65131,10 @@ function asyncEngineInvoke(engine, args) {
|
|
|
65080
65131
|
});
|
|
65081
65132
|
}
|
|
65082
65133
|
|
|
65083
|
-
function importMethods(engine, engineInvoke, submittedMethods,
|
|
65134
|
+
function importMethods(engine, engineInvoke, submittedMethods, traverse, maxDepth) {
|
|
65084
65135
|
if (!isObject(submittedMethods))
|
|
65085
65136
|
return { error: INVALID_VALUES };
|
|
65086
|
-
var collectionFilter = Array.isArray(
|
|
65137
|
+
var collectionFilter = Array.isArray(traverse) ? traverse : [];
|
|
65087
65138
|
var methods = {};
|
|
65088
65139
|
var attrWalker = function (obj, depth) {
|
|
65089
65140
|
if (depth === void 0) { depth = 0; }
|
|
@@ -65092,7 +65143,7 @@ function importMethods(engine, engineInvoke, submittedMethods, collections, maxD
|
|
|
65092
65143
|
methods[key] = obj[key];
|
|
65093
65144
|
}
|
|
65094
65145
|
else if (isObject(obj[key]) &&
|
|
65095
|
-
(
|
|
65146
|
+
(traverse === true || (collectionFilter === null || collectionFilter === void 0 ? void 0 : collectionFilter.includes(key))) &&
|
|
65096
65147
|
(maxDepth === undefined || depth < maxDepth)) {
|
|
65097
65148
|
attrWalker(obj[key], depth + 1);
|
|
65098
65149
|
}
|