tods-competition-factory 1.8.14 → 1.8.16
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.d.ts +1 -0
- package/dist/forge/generate.mjs +103 -82
- package/dist/forge/generate.mjs.map +1 -1
- package/dist/forge/query.d.ts +1 -2
- package/dist/forge/query.mjs +69 -58
- package/dist/forge/query.mjs.map +1 -1
- package/dist/forge/transform.d.ts +1 -0
- package/dist/forge/transform.mjs +51 -43
- package/dist/forge/transform.mjs.map +1 -1
- package/dist/index.mjs +331 -100
- package/dist/index.mjs.map +1 -1
- package/dist/tods-competition-factory.development.cjs.js +470 -128
- 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
package/dist/forge/transform.mjs
CHANGED
|
@@ -2280,11 +2280,11 @@ function countSets({
|
|
|
2280
2280
|
score
|
|
2281
2281
|
}) {
|
|
2282
2282
|
const setsTally = [0, 0];
|
|
2283
|
-
const
|
|
2284
|
-
const matchUpWinnerIndex = matchUpWinningSide - 1;
|
|
2283
|
+
const sets = score?.sets;
|
|
2284
|
+
const matchUpWinnerIndex = typeof matchUpWinningSide === "number" && matchUpWinningSide - 1;
|
|
2285
2285
|
const parsedMatchUpFormat = parse(matchUpFormat);
|
|
2286
2286
|
const setsToWin = getSetsToWin(parsedMatchUpFormat?.bestOf ?? 1);
|
|
2287
|
-
if (matchUpStatus === DEFAULTED && tallyPolicy?.setsCreditForDefaults || matchUpStatus === WALKOVER$1 && tallyPolicy?.setsCreditForWalkovers) {
|
|
2287
|
+
if (typeof matchUpWinnerIndex === "number" && (matchUpStatus === DEFAULTED && tallyPolicy?.setsCreditForDefaults || matchUpStatus === WALKOVER$1 && tallyPolicy?.setsCreditForWalkovers)) {
|
|
2288
2288
|
setsTally[matchUpWinnerIndex] = setsToWin;
|
|
2289
2289
|
} else {
|
|
2290
2290
|
for (const set of sets || []) {
|
|
@@ -2293,7 +2293,7 @@ function countSets({
|
|
|
2293
2293
|
setsTally[setWinningSide - 1] += 1;
|
|
2294
2294
|
}
|
|
2295
2295
|
}
|
|
2296
|
-
if (matchUpStatus === RETIRED) {
|
|
2296
|
+
if (typeof matchUpWinnerIndex === "number" && matchUpStatus === RETIRED) {
|
|
2297
2297
|
if (+setsTally[1 - matchUpWinnerIndex] === setsToWin)
|
|
2298
2298
|
setsTally[1 - matchUpWinnerIndex] -= 1;
|
|
2299
2299
|
if (tallyPolicy?.setsCreditForRetirements)
|
|
@@ -2311,13 +2311,13 @@ function countGames({
|
|
|
2311
2311
|
const { sets } = score || {};
|
|
2312
2312
|
if (!sets)
|
|
2313
2313
|
return [0, 0];
|
|
2314
|
-
const matchUpWinnerIndex = matchUpWinningSide - 1;
|
|
2314
|
+
const matchUpWinnerIndex = typeof matchUpWinningSide === "number" && matchUpWinningSide - 1;
|
|
2315
2315
|
const parsedMatchUpFormat = parse(matchUpFormat);
|
|
2316
2316
|
const bestOf = parsedMatchUpFormat?.bestOf ?? 1;
|
|
2317
2317
|
const setsToWin = getSetsToWin(bestOf);
|
|
2318
2318
|
const tiebreakAt = parsedMatchUpFormat?.setFormat?.tiebreakAt || 0;
|
|
2319
2319
|
const gamesTally = [[], []];
|
|
2320
|
-
if (matchUpStatus === DEFAULTED && tallyPolicy?.gamesCreditForDefaults || matchUpStatus === WALKOVER$1 && tallyPolicy?.gamesCreditForWalkovers) {
|
|
2320
|
+
if (typeof matchUpWinnerIndex === "number" && (matchUpStatus === DEFAULTED && tallyPolicy?.gamesCreditForDefaults || matchUpStatus === WALKOVER$1 && tallyPolicy?.gamesCreditForWalkovers)) {
|
|
2321
2321
|
const gamesForSet = parsedMatchUpFormat?.setFormat?.setTo || 0;
|
|
2322
2322
|
const minimumGameWins = setsToWin * gamesForSet;
|
|
2323
2323
|
gamesTally[matchUpWinnerIndex].push(minimumGameWins);
|
|
@@ -2337,7 +2337,7 @@ function countGames({
|
|
|
2337
2337
|
}
|
|
2338
2338
|
});
|
|
2339
2339
|
}
|
|
2340
|
-
if (matchUpStatus === RETIRED) {
|
|
2340
|
+
if (matchUpStatus === RETIRED && typeof matchUpWinnerIndex === "number") {
|
|
2341
2341
|
const whichFormat = sets.length > setsToWin && parsedMatchUpFormat?.finalSetFormat ? "finalSetFormat" : "setFormat";
|
|
2342
2342
|
const format = parsedMatchUpFormat?.[whichFormat];
|
|
2343
2343
|
if (isGamesBased(format.based)) {
|
|
@@ -2377,10 +2377,14 @@ function countGames({
|
|
|
2377
2377
|
gamesTally[1].reduce((a, b) => a + b, 0)
|
|
2378
2378
|
];
|
|
2379
2379
|
}
|
|
2380
|
-
function countPoints({
|
|
2381
|
-
|
|
2380
|
+
function countPoints({
|
|
2381
|
+
matchUpFormat,
|
|
2382
|
+
score
|
|
2383
|
+
}) {
|
|
2384
|
+
const parsedMatchUpFormat = matchUpFormat ? parse(matchUpFormat) : void 0;
|
|
2382
2385
|
const bestOf = parsedMatchUpFormat?.bestOf ?? 1;
|
|
2383
2386
|
const setsToWin = getSetsToWin(bestOf);
|
|
2387
|
+
const tiebreaksTally = [0, 0];
|
|
2384
2388
|
const pointsTally = [0, 0];
|
|
2385
2389
|
score?.sets?.forEach((set, i) => {
|
|
2386
2390
|
const setNumber = set.setNumber || i + 1;
|
|
@@ -2397,9 +2401,11 @@ function countPoints({ matchUpFormat, score }) {
|
|
|
2397
2401
|
pointsTally[0] += ensureInt(set.side1TiebreakScore || 0);
|
|
2398
2402
|
if (set.side2TiebreakScore)
|
|
2399
2403
|
pointsTally[1] += ensureInt(set.side2TiebreakScore || 0);
|
|
2404
|
+
if ((set.side1TiebreakScore || set.side2TiebreakScore) && set.winningSide)
|
|
2405
|
+
tiebreaksTally[set.winningSide - 1] += 1;
|
|
2400
2406
|
}
|
|
2401
2407
|
});
|
|
2402
|
-
return pointsTally;
|
|
2408
|
+
return { pointsTally, tiebreaksTally };
|
|
2403
2409
|
}
|
|
2404
2410
|
function getSetsToWin(bestOfGames) {
|
|
2405
2411
|
return bestOfGames && Math.ceil(bestOfGames / 2) || 1;
|
|
@@ -2504,7 +2510,7 @@ function getParticipantResults({
|
|
|
2504
2510
|
const winningParticipantId = winningSide && getWinningSideId(matchUp);
|
|
2505
2511
|
const losingParticipantId = winningSide && getLosingSideId(matchUp);
|
|
2506
2512
|
if (!winningParticipantId && !losingParticipantId) {
|
|
2507
|
-
if (completedMatchUpStatuses.includes(matchUpStatus)) {
|
|
2513
|
+
if (matchUpStatus && completedMatchUpStatuses.includes(matchUpStatus)) {
|
|
2508
2514
|
const participantIdSide1 = getSideId(matchUp, 0);
|
|
2509
2515
|
const participantIdSide2 = getSideId(matchUp, 1);
|
|
2510
2516
|
if (participantIdSide1) {
|
|
@@ -2519,10 +2525,10 @@ function getParticipantResults({
|
|
|
2519
2525
|
perPlayer = 0;
|
|
2520
2526
|
for (const tieMatchUp of tieMatchUps) {
|
|
2521
2527
|
if (tieMatchUp.winningSide) {
|
|
2522
|
-
const tieWinningParticipantId = sides
|
|
2528
|
+
const tieWinningParticipantId = sides?.find(
|
|
2523
2529
|
({ sideNumber }) => sideNumber === tieMatchUp.winningSide
|
|
2524
2530
|
)?.participantId;
|
|
2525
|
-
const tieLosingParticipantId = sides
|
|
2531
|
+
const tieLosingParticipantId = sides?.find(
|
|
2526
2532
|
({ sideNumber }) => sideNumber === tieMatchUp.winningSide
|
|
2527
2533
|
)?.participantId;
|
|
2528
2534
|
if (tieWinningParticipantId && tieLosingParticipantId) {
|
|
@@ -2641,26 +2647,30 @@ function getParticipantResults({
|
|
|
2641
2647
|
}
|
|
2642
2648
|
}
|
|
2643
2649
|
if (manualGamesOverride) {
|
|
2644
|
-
const side1participantId = sides
|
|
2650
|
+
const side1participantId = sides?.find(
|
|
2645
2651
|
({ sideNumber }) => sideNumber === 1
|
|
2646
2652
|
)?.participantId;
|
|
2647
|
-
const side2participantId = sides
|
|
2653
|
+
const side2participantId = sides?.find(
|
|
2648
2654
|
({ sideNumber }) => sideNumber === 2
|
|
2649
2655
|
)?.participantId;
|
|
2650
2656
|
checkInitializeParticipant(participantResults, side1participantId);
|
|
2651
2657
|
checkInitializeParticipant(participantResults, side2participantId);
|
|
2652
|
-
const gamesWonSide1 = score
|
|
2653
|
-
(total, set) => total + set
|
|
2658
|
+
const gamesWonSide1 = score?.sets?.reduce(
|
|
2659
|
+
(total, set) => total + (set?.side1Score ?? 0),
|
|
2654
2660
|
0
|
|
2655
2661
|
);
|
|
2656
|
-
const gamesWonSide2 = score
|
|
2657
|
-
(total, set) => total + set.side2Score,
|
|
2662
|
+
const gamesWonSide2 = score?.sets?.reduce(
|
|
2663
|
+
(total, set) => total + (set.side2Score ?? 0),
|
|
2658
2664
|
0
|
|
2659
2665
|
);
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2666
|
+
if (side1participantId) {
|
|
2667
|
+
participantResults[side1participantId].gamesWon += gamesWonSide1;
|
|
2668
|
+
participantResults[side1participantId].gamesLost += gamesWonSide2;
|
|
2669
|
+
}
|
|
2670
|
+
if (side2participantId) {
|
|
2671
|
+
participantResults[side2participantId].gamesWon += gamesWonSide2;
|
|
2672
|
+
participantResults[side2participantId].gamesLost += gamesWonSide1;
|
|
2673
|
+
}
|
|
2664
2674
|
}
|
|
2665
2675
|
}
|
|
2666
2676
|
calculatePercentages({
|
|
@@ -2787,7 +2797,7 @@ function processMatchUp({
|
|
|
2787
2797
|
winningSide,
|
|
2788
2798
|
score
|
|
2789
2799
|
});
|
|
2790
|
-
const pointsTally = countPoints({ score, matchUpFormat });
|
|
2800
|
+
const { pointsTally } = countPoints({ score, matchUpFormat });
|
|
2791
2801
|
if (winningParticipantId) {
|
|
2792
2802
|
participantResults[winningParticipantId].setsWon += setsTally[winningSideIndex];
|
|
2793
2803
|
participantResults[winningParticipantId].setsLost += setsTally[losingSideIndex];
|
|
@@ -9872,6 +9882,21 @@ function addNationalityCode({
|
|
|
9872
9882
|
persons.forEach(annotatePerson);
|
|
9873
9883
|
}
|
|
9874
9884
|
|
|
9885
|
+
function addIndividualParticipants({ participantMap }) {
|
|
9886
|
+
const participantObjects = Object.values(participantMap);
|
|
9887
|
+
for (const participantObject of participantObjects) {
|
|
9888
|
+
const participant = participantObject.participant;
|
|
9889
|
+
if (participant.individualParticipantIds?.length) {
|
|
9890
|
+
participant.individualParticipants = [];
|
|
9891
|
+
for (const participantId of participant.individualParticipantIds) {
|
|
9892
|
+
participant.individualParticipants.push(
|
|
9893
|
+
participantMap[participantId].participant
|
|
9894
|
+
);
|
|
9895
|
+
}
|
|
9896
|
+
}
|
|
9897
|
+
}
|
|
9898
|
+
}
|
|
9899
|
+
|
|
9875
9900
|
function getTimeItem({
|
|
9876
9901
|
returnPreviousValues,
|
|
9877
9902
|
itemSubTypes,
|
|
@@ -9974,20 +9999,6 @@ function signedIn(participant) {
|
|
|
9974
9999
|
});
|
|
9975
10000
|
return timeItem?.itemValue === SIGNED_IN;
|
|
9976
10001
|
}
|
|
9977
|
-
function addIndividualParticipants({ participantMap }) {
|
|
9978
|
-
const participantObjects = Object.values(participantMap);
|
|
9979
|
-
for (const participantObject of participantObjects) {
|
|
9980
|
-
const participant = participantObject.participant;
|
|
9981
|
-
if (participant.individualParticipantIds?.length) {
|
|
9982
|
-
participant.individualParticipants = [];
|
|
9983
|
-
for (const participantId of participant.individualParticipantIds) {
|
|
9984
|
-
participant.individualParticipants.push(
|
|
9985
|
-
participantMap[participantId].participant
|
|
9986
|
-
);
|
|
9987
|
-
}
|
|
9988
|
-
}
|
|
9989
|
-
}
|
|
9990
|
-
}
|
|
9991
10002
|
function processIndividualParticipantIds({
|
|
9992
10003
|
individualParticipantIds,
|
|
9993
10004
|
participantCopy,
|
|
@@ -10266,7 +10277,6 @@ function allEventMatchUps(params) {
|
|
|
10266
10277
|
if (!event)
|
|
10267
10278
|
return { error: MISSING_EVENT };
|
|
10268
10279
|
const { eventId, eventName, endDate, category, gender, matchUpFormat } = event;
|
|
10269
|
-
const eventMatchUps2 = [];
|
|
10270
10280
|
const additionalContext = {
|
|
10271
10281
|
...context,
|
|
10272
10282
|
...definedAttributes({
|
|
@@ -10310,7 +10320,7 @@ function allEventMatchUps(params) {
|
|
|
10310
10320
|
}).scheduleTiming;
|
|
10311
10321
|
const matchUps = drawDefinitions.flatMap(
|
|
10312
10322
|
(drawDefinition) => {
|
|
10313
|
-
const { matchUps: matchUps2
|
|
10323
|
+
const { matchUps: matchUps2 } = getAllDrawMatchUps({
|
|
10314
10324
|
tournamentParticipants: participants,
|
|
10315
10325
|
tournamentAppliedPolicies,
|
|
10316
10326
|
scheduleVisibilityFilters,
|
|
@@ -10330,12 +10340,10 @@ function allEventMatchUps(params) {
|
|
|
10330
10340
|
inContext,
|
|
10331
10341
|
event
|
|
10332
10342
|
});
|
|
10333
|
-
if (matchUpsMap?.drawMatchUps)
|
|
10334
|
-
eventMatchUps2.push(...matchUpsMap.drawMatchUps);
|
|
10335
10343
|
return matchUps2 ?? [];
|
|
10336
10344
|
}
|
|
10337
10345
|
);
|
|
10338
|
-
return { matchUps
|
|
10346
|
+
return { matchUps };
|
|
10339
10347
|
}
|
|
10340
10348
|
|
|
10341
10349
|
function addFinishingRounds({
|