tods-competition-factory 1.7.10 → 1.7.12
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 +15 -11
- package/dist/forge/generate.mjs.map +1 -1
- package/dist/forge/query.mjs +5 -2
- package/dist/forge/query.mjs.map +1 -1
- package/dist/index.mjs +71 -61
- package/dist/index.mjs.map +1 -1
- package/dist/tods-competition-factory.development.cjs.js +84 -63
- 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.12';
|
|
366
366
|
}
|
|
367
367
|
|
|
368
368
|
/******************************************************************************
|
|
@@ -18241,7 +18241,6 @@ function compareTieFormats(_a) {
|
|
|
18241
18241
|
return collectionOrder;
|
|
18242
18242
|
})
|
|
18243
18243
|
.join('|'));
|
|
18244
|
-
var different = nameDifference || orderDifference || ancestorDesc !== descendantDesc;
|
|
18245
18244
|
var descendantCollectionDefinitions = Object.assign.apply(Object, __spreadArray([{}], __read(((descendant === null || descendant === void 0 ? void 0 : descendant.collectionDefinitions) || []).map(function (collectionDefinition) {
|
|
18246
18245
|
var _a;
|
|
18247
18246
|
return (_a = {},
|
|
@@ -18256,8 +18255,8 @@ function compareTieFormats(_a) {
|
|
|
18256
18255
|
})), false));
|
|
18257
18256
|
descendantDifferences.collectionIds = difference(Object.keys(descendantCollectionDefinitions), Object.keys(ancestorCollectionDefinitions));
|
|
18258
18257
|
ancestorDifferences.collectionIds = difference(Object.keys(ancestorCollectionDefinitions), Object.keys(descendantCollectionDefinitions));
|
|
18259
|
-
descendantDifferences.collectionsValue = getCollectionsValue(descendantCollectionDefinitions
|
|
18260
|
-
ancestorDifferences.collectionsValue = getCollectionsValue(ancestorCollectionDefinitions
|
|
18258
|
+
descendantDifferences.collectionsValue = getCollectionsValue(descendantCollectionDefinitions);
|
|
18259
|
+
ancestorDifferences.collectionsValue = getCollectionsValue(ancestorCollectionDefinitions);
|
|
18261
18260
|
descendantDifferences.groupsCount =
|
|
18262
18261
|
(_c = (_b = ancestor === null || ancestor === void 0 ? void 0 : ancestor.collectionGroups) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : (0 - ((_e = (_d = descendant === null || descendant === void 0 ? void 0 : descendant.collectionGroups) === null || _d === void 0 ? void 0 : _d.length) !== null && _e !== void 0 ? _e : 0) || 0);
|
|
18263
18262
|
ancestorDifferences.groupsCount = descendantDifferences.groupsCount
|
|
@@ -18267,20 +18266,32 @@ function compareTieFormats(_a) {
|
|
|
18267
18266
|
ancestorDifferences.collectionsValue.totalValue;
|
|
18268
18267
|
var matchUpCountDifference = descendantDifferences.collectionsValue.totalMatchUps -
|
|
18269
18268
|
ancestorDifferences.collectionsValue.totalMatchUps;
|
|
18269
|
+
var different = nameDifference ||
|
|
18270
|
+
orderDifference ||
|
|
18271
|
+
ancestorDesc !== descendantDesc ||
|
|
18272
|
+
valueDifference !== 0;
|
|
18270
18273
|
return __assign(__assign({ matchUpFormatDifferences: matchUpFormatDifferences, matchUpCountDifference: matchUpCountDifference, descendantDifferences: descendantDifferences, ancestorDifferences: ancestorDifferences, orderDifference: orderDifference, valueDifference: valueDifference, nameDifference: nameDifference, descendantDesc: descendantDesc, ancestorDesc: ancestorDesc }, SUCCESS), { different: different });
|
|
18271
18274
|
}
|
|
18272
|
-
function getCollectionsValue(definitions
|
|
18275
|
+
function getCollectionsValue(definitions) {
|
|
18273
18276
|
var totalMatchUps = 0;
|
|
18274
|
-
var
|
|
18277
|
+
var collectionIds = Object.keys(definitions);
|
|
18278
|
+
var totalValue = collectionIds.reduce(function (total, collectionId) {
|
|
18275
18279
|
var collectionDefinition = definitions[collectionId];
|
|
18276
|
-
var collectionValueProfiles = collectionDefinition.collectionValueProfiles, collectionValue = collectionDefinition.collectionValue, matchUpCount = collectionDefinition.matchUpCount, matchUpValue = collectionDefinition.matchUpValue;
|
|
18280
|
+
var collectionValueProfiles = collectionDefinition.collectionValueProfiles, collectionValue = collectionDefinition.collectionValue, matchUpCount = collectionDefinition.matchUpCount, matchUpValue = collectionDefinition.matchUpValue, scoreValue = collectionDefinition.scoreValue, setValue = collectionDefinition.setValue;
|
|
18277
18281
|
totalMatchUps += matchUpCount;
|
|
18278
18282
|
if (collectionValueProfiles)
|
|
18279
18283
|
return (total +
|
|
18280
18284
|
collectionValueProfiles.reduce(function (total, profile) { return total + profile.value; }, 0));
|
|
18281
|
-
if (
|
|
18282
|
-
|
|
18283
|
-
|
|
18285
|
+
if (matchUpCount) {
|
|
18286
|
+
if (isConvertableInteger(matchUpValue))
|
|
18287
|
+
return total + matchUpValue * matchUpCount;
|
|
18288
|
+
if (isConvertableInteger(scoreValue))
|
|
18289
|
+
return total + scoreValue * matchUpCount;
|
|
18290
|
+
if (isConvertableInteger(setValue))
|
|
18291
|
+
return total + setValue * matchUpCount;
|
|
18292
|
+
return total + collectionValue;
|
|
18293
|
+
}
|
|
18294
|
+
return total;
|
|
18284
18295
|
}, 0);
|
|
18285
18296
|
return { totalValue: totalValue, totalMatchUps: totalMatchUps };
|
|
18286
18297
|
}
|
|
@@ -47939,8 +47950,8 @@ function removeStructure(_a) {
|
|
|
47939
47950
|
}
|
|
47940
47951
|
|
|
47941
47952
|
function generateAdHocMatchUps$1(_a) {
|
|
47942
|
-
var _b, _c, _d, _e, _f, _g, _h, _j;
|
|
47943
|
-
var participantIdPairings = _a.participantIdPairings,
|
|
47953
|
+
var _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
47954
|
+
var participantIdPairings = _a.participantIdPairings, _l = _a.addToStructure, addToStructure = _l === void 0 ? true : _l, tournamentRecord = _a.tournamentRecord, _m = _a.matchUpIds, matchUpIds = _m === void 0 ? [] : _m, drawDefinition = _a.drawDefinition, matchUpsCount = _a.matchUpsCount, roundNumber = _a.roundNumber, structureId = _a.structureId, newRound = _a.newRound;
|
|
47944
47955
|
if (typeof drawDefinition !== 'object')
|
|
47945
47956
|
return { error: MISSING_DRAW_DEFINITION };
|
|
47946
47957
|
if (!structureId && ((_b = drawDefinition.structures) === null || _b === void 0 ? void 0 : _b.length) === 1)
|
|
@@ -47951,17 +47962,28 @@ function generateAdHocMatchUps$1(_a) {
|
|
|
47951
47962
|
var structure = (_e = drawDefinition.structures) === null || _e === void 0 ? void 0 : _e.find(function (structure) { return structure.structureId === structureId; });
|
|
47952
47963
|
if (!structure)
|
|
47953
47964
|
return { error: STRUCTURE_NOT_FOUND };
|
|
47965
|
+
var structureHasRoundPositions;
|
|
47966
|
+
var existingMatchUps = (_f = structure.matchUps) !== null && _f !== void 0 ? _f : [];
|
|
47967
|
+
var lastRoundNumber = existingMatchUps === null || existingMatchUps === void 0 ? void 0 : existingMatchUps.reduce(function (roundNumber, matchUp) {
|
|
47968
|
+
if (matchUp.roundPosition)
|
|
47969
|
+
structureHasRoundPositions = true;
|
|
47970
|
+
return ((matchUp === null || matchUp === void 0 ? void 0 : matchUp.roundNumber) || 0) > roundNumber
|
|
47971
|
+
? matchUp.roundNumber
|
|
47972
|
+
: roundNumber;
|
|
47973
|
+
}, 0);
|
|
47954
47974
|
if (!matchUpsCount) {
|
|
47955
|
-
var selectedEntries = (
|
|
47975
|
+
var selectedEntries = (_h = (_g = drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.entries) === null || _g === void 0 ? void 0 : _g.filter(function (entry) {
|
|
47956
47976
|
var entryStatus = entry.entryStatus;
|
|
47957
47977
|
return STRUCTURE_SELECTED_STATUSES.includes(entryStatus);
|
|
47958
|
-
})) !== null &&
|
|
47978
|
+
})) !== null && _h !== void 0 ? _h : [];
|
|
47959
47979
|
var roundMatchUpsCount = Math.floor((selectedEntries === null || selectedEntries === void 0 ? void 0 : selectedEntries.length) / 2) || 1;
|
|
47960
47980
|
if (newRound) {
|
|
47961
47981
|
matchUpsCount = roundMatchUpsCount;
|
|
47962
47982
|
}
|
|
47963
47983
|
else {
|
|
47964
|
-
var
|
|
47984
|
+
var targetRoundNumber_1 = roundNumber || lastRoundNumber || 1;
|
|
47985
|
+
var existingRoundMatchUps = ((_k = (_j = structure.matchUps) === null || _j === void 0 ? void 0 : _j.filter(function (matchUp) { return matchUp.roundNumber === targetRoundNumber_1; })) === null || _k === void 0 ? void 0 : _k.length) || 0;
|
|
47986
|
+
var maxRemaining = roundMatchUpsCount - existingRoundMatchUps;
|
|
47965
47987
|
if (maxRemaining > 0)
|
|
47966
47988
|
matchUpsCount = maxRemaining;
|
|
47967
47989
|
}
|
|
@@ -47972,15 +47994,6 @@ function generateAdHocMatchUps$1(_a) {
|
|
|
47972
47994
|
(!participantIdPairings && !matchUpsCount)) {
|
|
47973
47995
|
return { error: INVALID_VALUES, info: 'matchUpsCount or pairings error' };
|
|
47974
47996
|
}
|
|
47975
|
-
var structureHasRoundPositions;
|
|
47976
|
-
var existingMatchUps = (_j = structure.matchUps) !== null && _j !== void 0 ? _j : [];
|
|
47977
|
-
var lastRoundNumber = existingMatchUps === null || existingMatchUps === void 0 ? void 0 : existingMatchUps.reduce(function (roundNumber, matchUp) {
|
|
47978
|
-
if (matchUp.roundPosition)
|
|
47979
|
-
structureHasRoundPositions = true;
|
|
47980
|
-
return ((matchUp === null || matchUp === void 0 ? void 0 : matchUp.roundNumber) || 0) > roundNumber
|
|
47981
|
-
? matchUp.roundNumber
|
|
47982
|
-
: roundNumber;
|
|
47983
|
-
}, 0);
|
|
47984
47997
|
// structure must not be a container of other structures
|
|
47985
47998
|
// structure must not contain matchUps with roundPosition
|
|
47986
47999
|
// structure must not determine finishingPosition by ROUND_OUTCOME
|
|
@@ -48682,11 +48695,11 @@ function setPositionAssignments$1(_a) {
|
|
|
48682
48695
|
return __assign({}, SUCCESS);
|
|
48683
48696
|
}
|
|
48684
48697
|
|
|
48685
|
-
// build up an array of participantIds which are assigned positions in structures
|
|
48686
|
-
// optionally filter to included only specified stages
|
|
48687
48698
|
function getAssignedParticipantIds(_a) {
|
|
48688
48699
|
var drawDefinition = _a.drawDefinition, stages = _a.stages;
|
|
48689
|
-
var stageStructures = ((drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.structures) || []).filter(function (structure) {
|
|
48700
|
+
var stageStructures = ((drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.structures) || []).filter(function (structure) {
|
|
48701
|
+
return !(stages === null || stages === void 0 ? void 0 : stages.length) || (structure.stage && stages.includes(structure.stage));
|
|
48702
|
+
});
|
|
48690
48703
|
return stageStructures
|
|
48691
48704
|
.map(function (structure) {
|
|
48692
48705
|
var positionAssignments = getPositionAssignments$1({
|
|
@@ -49281,45 +49294,56 @@ function participantInFlightEntries(_a) {
|
|
|
49281
49294
|
}
|
|
49282
49295
|
|
|
49283
49296
|
function removeEventEntries(_a) {
|
|
49284
|
-
var _b, _c;
|
|
49285
|
-
var
|
|
49297
|
+
var _b, _c, _d, _e, _f;
|
|
49298
|
+
var _g = _a.autoEntryPositions, autoEntryPositions = _g === void 0 ? true : _g, _h = _a.participantIds, participantIds = _h === void 0 ? [] : _h, entryStatuses = _a.entryStatuses, stage = _a.stage, event = _a.event;
|
|
49286
49299
|
var stack = 'removeEventEntries';
|
|
49287
49300
|
if (!(event === null || event === void 0 ? void 0 : event.eventId))
|
|
49288
49301
|
return { error: MISSING_EVENT };
|
|
49289
|
-
if (!Array.isArray(participantIds)
|
|
49290
|
-
return
|
|
49291
|
-
|
|
49292
|
-
stack: stack,
|
|
49293
|
-
});
|
|
49294
|
-
participantIds = participantIds === null || participantIds === void 0 ? void 0 : participantIds.filter(Boolean);
|
|
49295
|
-
if (!(participantIds === null || participantIds === void 0 ? void 0 : participantIds.length))
|
|
49296
|
-
return decorateResult({
|
|
49297
|
-
result: { error: MISSING_PARTICIPANT_IDS },
|
|
49298
|
-
stack: stack,
|
|
49299
|
-
});
|
|
49300
|
-
var eventId = event.eventId;
|
|
49301
|
-
if (!tournamentParticipants) {
|
|
49302
|
-
// cannot use getParticipants() because event objects don't have drawIds array
|
|
49303
|
-
tournamentParticipants = getTournamentParticipants({
|
|
49304
|
-
participantFilters: { participantIds: participantIds },
|
|
49305
|
-
tournamentRecord: tournamentRecord,
|
|
49306
|
-
withEvents: true,
|
|
49307
|
-
withDraws: true,
|
|
49308
|
-
}).tournamentParticipants;
|
|
49302
|
+
if (!Array.isArray(participantIds) ||
|
|
49303
|
+
participantIds.some(function (participantId) { return !isString(participantId); })) {
|
|
49304
|
+
return decorateResult({ result: { error: INVALID_PARTICIPANT_ID }, stack: stack });
|
|
49309
49305
|
}
|
|
49310
|
-
|
|
49311
|
-
|
|
49312
|
-
|
|
49313
|
-
|
|
49314
|
-
return
|
|
49315
|
-
})
|
|
49316
|
-
|
|
49317
|
-
|
|
49306
|
+
// do not filter by stages; must kmow all participantIds assigned to any stage!
|
|
49307
|
+
var assignedParticipantIds = ((_b = event.drawDefinitions) !== null && _b !== void 0 ? _b : []).flatMap(function (drawDefinition) { return getAssignedParticipantIds({ drawDefinition: drawDefinition }); });
|
|
49308
|
+
var statusParticipantIds = (((entryStatuses === null || entryStatuses === void 0 ? void 0 : entryStatuses.length) &&
|
|
49309
|
+
((_c = event.entries) === null || _c === void 0 ? void 0 : _c.filter(function (entry) {
|
|
49310
|
+
return entry.entryStatus && entryStatuses.includes(entry.entryStatus);
|
|
49311
|
+
}))) ||
|
|
49312
|
+
[])
|
|
49313
|
+
.map(extractAttributes('participantId'))
|
|
49314
|
+
.filter(function (participantId) { return !assignedParticipantIds.includes(participantId); });
|
|
49315
|
+
var stageParticipantIds = ((stage &&
|
|
49316
|
+
((_d = event.entries) === null || _d === void 0 ? void 0 : _d.filter(function (entry) { return entry.entryStage && entry.entryStage === stage; }))) ||
|
|
49317
|
+
[])
|
|
49318
|
+
.map(extractAttributes('participantId'))
|
|
49319
|
+
.filter(function (participantId) { return !assignedParticipantIds.includes(participantId); });
|
|
49320
|
+
if (participantIds.length) {
|
|
49321
|
+
participantIds = participantIds.filter(function (participantId) {
|
|
49322
|
+
return (!(entryStatuses === null || entryStatuses === void 0 ? void 0 : entryStatuses.length) ||
|
|
49323
|
+
statusParticipantIds.includes(participantId)) &&
|
|
49324
|
+
(!stage || stageParticipantIds.includes(participantId));
|
|
49325
|
+
});
|
|
49326
|
+
}
|
|
49327
|
+
else if (statusParticipantIds.length && stageParticipantIds.length) {
|
|
49328
|
+
participantIds = intersection(statusParticipantIds, stageParticipantIds);
|
|
49329
|
+
}
|
|
49330
|
+
else if (statusParticipantIds.length) {
|
|
49331
|
+
participantIds = statusParticipantIds;
|
|
49332
|
+
}
|
|
49333
|
+
else if (stageParticipantIds.length) {
|
|
49334
|
+
participantIds = stageParticipantIds;
|
|
49335
|
+
}
|
|
49336
|
+
if ((participantIds === null || participantIds === void 0 ? void 0 : participantIds.length) &&
|
|
49337
|
+
assignedParticipantIds.some(function (participantId) {
|
|
49338
|
+
return participantIds.includes(participantId);
|
|
49339
|
+
})) {
|
|
49318
49340
|
return decorateResult({
|
|
49319
49341
|
result: { error: EXISTING_PARTICIPANT_DRAW_POSITION_ASSIGNMENT },
|
|
49320
49342
|
stack: stack,
|
|
49321
49343
|
});
|
|
49322
49344
|
}
|
|
49345
|
+
if (!(participantIds === null || participantIds === void 0 ? void 0 : participantIds.length))
|
|
49346
|
+
return __assign(__assign({}, SUCCESS), { participantIdsRemoved: [] });
|
|
49323
49347
|
var participantIdsRemoved = [];
|
|
49324
49348
|
event.entries = (event.entries || []).filter(function (entry) {
|
|
49325
49349
|
var keepEntry = !participantIds.includes(entry === null || entry === void 0 ? void 0 : entry.participantId);
|
|
@@ -49334,10 +49358,10 @@ function removeEventEntries(_a) {
|
|
|
49334
49358
|
}
|
|
49335
49359
|
// also remove entry from all flights and drawDefinitions
|
|
49336
49360
|
var flightProfile = getFlightProfile({ event: event }).flightProfile;
|
|
49337
|
-
(
|
|
49361
|
+
(_e = flightProfile === null || flightProfile === void 0 ? void 0 : flightProfile.flights) === null || _e === void 0 ? void 0 : _e.forEach(function (flight) {
|
|
49338
49362
|
flight.drawEntries = (flight.drawEntries || []).filter(function (entry) { return !participantIds.includes(entry.participantId); });
|
|
49339
49363
|
});
|
|
49340
|
-
(
|
|
49364
|
+
(_f = event.drawDefinitions) === null || _f === void 0 ? void 0 : _f.forEach(function (drawDefinition) {
|
|
49341
49365
|
drawDefinition.entries = (drawDefinition.entries || []).filter(function (entry) { return !participantIds.includes(entry.participantId); });
|
|
49342
49366
|
});
|
|
49343
49367
|
return __assign(__assign({}, SUCCESS), { participantIdsRemoved: participantIdsRemoved });
|
|
@@ -49494,7 +49518,6 @@ function addEventEntries(params) {
|
|
|
49494
49518
|
removeEventEntries({
|
|
49495
49519
|
participantIds: ungroupedParticipantIdsToRemove,
|
|
49496
49520
|
autoEntryPositions: false,
|
|
49497
|
-
tournamentRecord: tournamentRecord,
|
|
49498
49521
|
event: event,
|
|
49499
49522
|
});
|
|
49500
49523
|
}
|
|
@@ -49830,8 +49853,6 @@ function deleteParticipants(params) {
|
|
|
49830
49853
|
for (var _f = __values(tournamentRecord.events || []), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
49831
49854
|
var event_1 = _g.value;
|
|
49832
49855
|
var result = removeEventEntries({
|
|
49833
|
-
tournamentParticipants: tournamentParticipants,
|
|
49834
|
-
tournamentRecord: tournamentRecord,
|
|
49835
49856
|
participantIds: participantIds,
|
|
49836
49857
|
event: event_1,
|
|
49837
49858
|
});
|
|
@@ -50012,7 +50033,6 @@ function destroyGroupEntry(_a) {
|
|
|
50012
50033
|
// remove the group participant from event entries
|
|
50013
50034
|
var result = removeEventEntries({
|
|
50014
50035
|
participantIds: [participantId],
|
|
50015
|
-
tournamentRecord: tournamentRecord,
|
|
50016
50036
|
event: event,
|
|
50017
50037
|
});
|
|
50018
50038
|
if (result.error)
|
|
@@ -65524,6 +65544,7 @@ var lastNames = [
|
|
|
65524
65544
|
"Dallas",
|
|
65525
65545
|
"Diamond",
|
|
65526
65546
|
"Deckard",
|
|
65547
|
+
"Dunbar",
|
|
65527
65548
|
"Earhart",
|
|
65528
65549
|
"Eisenstein",
|
|
65529
65550
|
"Eldritch",
|