tods-competition-factory 1.7.2 → 1.7.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/forge/generate.mjs +18 -9
- package/dist/forge/generate.mjs.map +1 -1
- package/dist/forge/query.mjs +1 -1
- package/dist/forge/query.mjs.map +1 -1
- package/dist/forge/transform.mjs +1 -1
- package/dist/forge/transform.mjs.map +1 -1
- package/dist/index.mjs +26 -15
- package/dist/index.mjs.map +1 -1
- package/dist/tods-competition-factory.development.cjs.js +36 -22
- 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 +1 -1
|
@@ -362,7 +362,7 @@ var matchUpFormatCode = {
|
|
|
362
362
|
};
|
|
363
363
|
|
|
364
364
|
function factoryVersion() {
|
|
365
|
-
return '1.7.
|
|
365
|
+
return '1.7.3';
|
|
366
366
|
}
|
|
367
367
|
|
|
368
368
|
/******************************************************************************
|
|
@@ -7409,7 +7409,7 @@ function getRoundMatchUps$1(_a) {
|
|
|
7409
7409
|
.map(function (key) { return ensureInt(key); })
|
|
7410
7410
|
.filter(function (f) { return !isNaN(f); });
|
|
7411
7411
|
roundNumbers.forEach(function (roundNumber) {
|
|
7412
|
-
var _a, _b, _c;
|
|
7412
|
+
var _a, _b, _c, _d, _e;
|
|
7413
7413
|
var currentRoundMatchUps = roundMatchUps[roundNumber].sort(function (a, b) { return a.roundPosition - b.roundPosition; });
|
|
7414
7414
|
var currentRoundDrawPositions = currentRoundMatchUps
|
|
7415
7415
|
.map(function (matchUp) { return (matchUp === null || matchUp === void 0 ? void 0 : matchUp.drawPositions) || []; })
|
|
@@ -7427,7 +7427,7 @@ function getRoundMatchUps$1(_a) {
|
|
|
7427
7427
|
roundProfile[roundNumber].abbreviatedRoundName =
|
|
7428
7428
|
(_c = finishingRoundMap[roundNumber]) === null || _c === void 0 ? void 0 : _c.abbreviatedRoundName;
|
|
7429
7429
|
roundProfile[roundNumber].finishingPositionRange =
|
|
7430
|
-
roundMatchUps[roundNumber][0].finishingPositionRange;
|
|
7430
|
+
(_e = (_d = roundMatchUps[roundNumber]) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.finishingPositionRange;
|
|
7431
7431
|
if (roundNumber === 1 || !roundProfile[roundNumber - 1]) {
|
|
7432
7432
|
var orderedDrawPositions = currentRoundDrawPositions.sort(numericSort);
|
|
7433
7433
|
var pairedDrawPositions = chunkArray(orderedDrawPositions, 2);
|
|
@@ -31250,10 +31250,12 @@ function getParticipantEntries(params) {
|
|
|
31250
31250
|
if (!participation)
|
|
31251
31251
|
return;
|
|
31252
31252
|
if (!finishingPositionRange_1)
|
|
31253
|
-
finishingPositionRange_1 =
|
|
31253
|
+
finishingPositionRange_1 =
|
|
31254
|
+
participation === null || participation === void 0 ? void 0 : participation.finishingPositionRange;
|
|
31254
31255
|
if (diff_1(finishingPositionRange_1) >
|
|
31255
|
-
diff_1(participation.finishingPositionRange))
|
|
31256
|
-
finishingPositionRange_1 =
|
|
31256
|
+
diff_1(participation === null || participation === void 0 ? void 0 : participation.finishingPositionRange))
|
|
31257
|
+
finishingPositionRange_1 =
|
|
31258
|
+
participation === null || participation === void 0 ? void 0 : participation.finishingPositionRange;
|
|
31257
31259
|
var notQualifying = participation.stage !== QUALIFYING;
|
|
31258
31260
|
if (notQualifying)
|
|
31259
31261
|
nonQualifyingOrder_1 += 1;
|
|
@@ -31263,10 +31265,12 @@ function getParticipantEntries(params) {
|
|
|
31263
31265
|
return definedAttributes(__assign(__assign({}, participation), { participationOrder: participationOrder, flightNumber: flightNumber }));
|
|
31264
31266
|
})
|
|
31265
31267
|
.filter(Boolean);
|
|
31266
|
-
participantAggregator.draws[drawId]
|
|
31267
|
-
|
|
31268
|
-
|
|
31269
|
-
|
|
31268
|
+
if (participantAggregator.draws[drawId]) {
|
|
31269
|
+
participantAggregator.draws[drawId].finishingPositionRange =
|
|
31270
|
+
finishingPositionRange_1;
|
|
31271
|
+
participantAggregator.draws[drawId].structureParticipation =
|
|
31272
|
+
orderedParticipation;
|
|
31273
|
+
}
|
|
31270
31274
|
}
|
|
31271
31275
|
};
|
|
31272
31276
|
try {
|
|
@@ -47878,20 +47882,32 @@ function removeStructure(_a) {
|
|
|
47878
47882
|
}
|
|
47879
47883
|
|
|
47880
47884
|
function generateAdHocMatchUps$1(_a) {
|
|
47881
|
-
var _b, _c, _d, _e, _f, _g;
|
|
47882
|
-
var participantIdPairings = _a.participantIdPairings,
|
|
47885
|
+
var _b, _c, _d, _e, _f, _g, _h, _j;
|
|
47886
|
+
var participantIdPairings = _a.participantIdPairings, _k = _a.addToStructure, addToStructure = _k === void 0 ? true : _k, tournamentRecord = _a.tournamentRecord, _l = _a.matchUpIds, matchUpIds = _l === void 0 ? [] : _l, drawDefinition = _a.drawDefinition, matchUpsCount = _a.matchUpsCount, roundNumber = _a.roundNumber, structureId = _a.structureId, newRound = _a.newRound;
|
|
47883
47887
|
if (typeof drawDefinition !== 'object')
|
|
47884
47888
|
return { error: MISSING_DRAW_DEFINITION };
|
|
47885
47889
|
if (!structureId && ((_b = drawDefinition.structures) === null || _b === void 0 ? void 0 : _b.length) === 1)
|
|
47886
47890
|
structureId = (_d = (_c = drawDefinition.structures) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.structureId;
|
|
47887
47891
|
if (typeof structureId !== 'string')
|
|
47888
47892
|
return { error: MISSING_STRUCTURE_ID };
|
|
47889
|
-
if
|
|
47890
|
-
|
|
47893
|
+
// if drawDefinition and structureId are provided it is possible to infer roundNumber
|
|
47894
|
+
var structure = (_e = drawDefinition.structures) === null || _e === void 0 ? void 0 : _e.find(function (structure) { return structure.structureId === structureId; });
|
|
47895
|
+
if (!structure)
|
|
47896
|
+
return { error: STRUCTURE_NOT_FOUND };
|
|
47897
|
+
if (!matchUpsCount) {
|
|
47898
|
+
var selectedEntries = (_g = (_f = drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.entries) === null || _f === void 0 ? void 0 : _f.filter(function (entry) {
|
|
47891
47899
|
var entryStatus = entry.entryStatus;
|
|
47892
47900
|
return STRUCTURE_SELECTED_STATUSES.includes(entryStatus);
|
|
47893
|
-
})) !== null &&
|
|
47894
|
-
|
|
47901
|
+
})) !== null && _g !== void 0 ? _g : [];
|
|
47902
|
+
var roundMatchUpsCount = Math.floor((selectedEntries === null || selectedEntries === void 0 ? void 0 : selectedEntries.length) / 2) || 1;
|
|
47903
|
+
if (newRound) {
|
|
47904
|
+
matchUpsCount = roundMatchUpsCount;
|
|
47905
|
+
}
|
|
47906
|
+
else {
|
|
47907
|
+
var maxRemaining = roundMatchUpsCount - (((_h = structure.matchUps) === null || _h === void 0 ? void 0 : _h.length) || 0); // TODO: minus the number of existing matchUps in roundNumber
|
|
47908
|
+
if (maxRemaining > 0)
|
|
47909
|
+
matchUpsCount = maxRemaining;
|
|
47910
|
+
}
|
|
47895
47911
|
}
|
|
47896
47912
|
if ((participantIdPairings && !Array.isArray(participantIdPairings)) ||
|
|
47897
47913
|
(matchUpsCount && !isConvertableInteger(matchUpsCount)) ||
|
|
@@ -47899,10 +47915,8 @@ function generateAdHocMatchUps$1(_a) {
|
|
|
47899
47915
|
(!participantIdPairings && !matchUpsCount)) {
|
|
47900
47916
|
return { error: INVALID_VALUES, info: 'matchUpsCount or pairings error' };
|
|
47901
47917
|
}
|
|
47902
|
-
// if drawDefinition and structureId are provided it is possible to infer roundNumber
|
|
47903
|
-
var structure = (_g = drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.structures) === null || _g === void 0 ? void 0 : _g.find(function (structure) { return structure.structureId === structureId; });
|
|
47904
47918
|
var structureHasRoundPositions;
|
|
47905
|
-
var existingMatchUps = structure
|
|
47919
|
+
var existingMatchUps = (_j = structure.matchUps) !== null && _j !== void 0 ? _j : [];
|
|
47906
47920
|
var lastRoundNumber = existingMatchUps === null || existingMatchUps === void 0 ? void 0 : existingMatchUps.reduce(function (roundNumber, matchUp) {
|
|
47907
47921
|
if (matchUp.roundPosition)
|
|
47908
47922
|
structureHasRoundPositions = true;
|
|
@@ -47913,14 +47927,14 @@ function generateAdHocMatchUps$1(_a) {
|
|
|
47913
47927
|
// structure must not be a container of other structures
|
|
47914
47928
|
// structure must not contain matchUps with roundPosition
|
|
47915
47929
|
// structure must not determine finishingPosition by ROUND_OUTCOME
|
|
47916
|
-
if (
|
|
47930
|
+
if (structure.structures ||
|
|
47917
47931
|
structureHasRoundPositions ||
|
|
47918
|
-
|
|
47932
|
+
structure.finishingPosition === ROUND_OUTCOME) {
|
|
47919
47933
|
return { error: INVALID_STRUCTURE };
|
|
47920
47934
|
}
|
|
47921
47935
|
if (roundNumber && roundNumber - 1 > (lastRoundNumber || 0))
|
|
47922
47936
|
return { error: INVALID_VALUES, info: 'roundNumber error' };
|
|
47923
|
-
var nextRoundNumber = roundNumber !== null && roundNumber !== void 0 ? roundNumber : (newRound
|
|
47937
|
+
var nextRoundNumber = roundNumber !== null && roundNumber !== void 0 ? roundNumber : ((newRound && (lastRoundNumber !== null && lastRoundNumber !== void 0 ? lastRoundNumber : 0) + 1) || lastRoundNumber || 1);
|
|
47924
47938
|
participantIdPairings =
|
|
47925
47939
|
participantIdPairings !== null && participantIdPairings !== void 0 ? participantIdPairings : generateRange(0, matchUpsCount).map(function () { return ({
|
|
47926
47940
|
participantIds: [undefined, undefined],
|