tods-competition-factory 1.8.18 → 1.8.19
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 +92 -20
- package/dist/forge/generate.mjs.map +1 -1
- package/dist/forge/query.mjs +3 -3
- package/dist/forge/query.mjs.map +1 -1
- package/dist/forge/transform.mjs +238 -166
- package/dist/forge/transform.mjs.map +1 -1
- package/dist/index.mjs +533 -493
- package/dist/index.mjs.map +1 -1
- package/dist/tods-competition-factory.development.cjs.js +463 -398
- 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/generate.mjs
CHANGED
|
@@ -9454,8 +9454,8 @@ function updateInContextMatchUp({ tournamentId, inContextMatchUp }) {
|
|
|
9454
9454
|
return { error: MISSING_MATCHUP };
|
|
9455
9455
|
}
|
|
9456
9456
|
addNotice({
|
|
9457
|
-
topic: UPDATE_INCONTEXT_MATCHUP,
|
|
9458
9457
|
payload: { inContextMatchUp, tournamentId },
|
|
9458
|
+
topic: UPDATE_INCONTEXT_MATCHUP,
|
|
9459
9459
|
key: inContextMatchUp.matchUpId
|
|
9460
9460
|
});
|
|
9461
9461
|
return { ...SUCCESS };
|
|
@@ -10654,8 +10654,8 @@ function updateSideLineUp({
|
|
|
10654
10654
|
element: drawDefinition,
|
|
10655
10655
|
name: LINEUPS
|
|
10656
10656
|
});
|
|
10657
|
-
const
|
|
10658
|
-
const lineUp =
|
|
10657
|
+
const lineUps = existingExtension?.value || {};
|
|
10658
|
+
const lineUp = makeDeepCopy(lineUps[teamParticipantId], false, true);
|
|
10659
10659
|
if (sideExists) {
|
|
10660
10660
|
matchUp?.sides?.forEach((side) => {
|
|
10661
10661
|
if (side.sideNumber === drawPositionSideNumber) {
|
|
@@ -10670,13 +10670,12 @@ function updateSideLineUp({
|
|
|
10670
10670
|
const targetSide = matchUp.sides.find(
|
|
10671
10671
|
(side) => side.sideNumber === drawPositionSideNumber
|
|
10672
10672
|
);
|
|
10673
|
-
if (targetSide)
|
|
10673
|
+
if (targetSide)
|
|
10674
10674
|
targetSide.lineUp = lineUp;
|
|
10675
|
-
}
|
|
10676
10675
|
}
|
|
10677
10676
|
modifyMatchUpNotice({
|
|
10678
10677
|
tournamentId: tournamentRecord?.tournamentId,
|
|
10679
|
-
context: "
|
|
10678
|
+
context: "updateSidLineUp",
|
|
10680
10679
|
eventId: event?.eventId,
|
|
10681
10680
|
drawDefinition,
|
|
10682
10681
|
matchUp
|
|
@@ -11493,10 +11492,10 @@ function removeLineUpSubstitutions({ lineUp }) {
|
|
|
11493
11492
|
const participantAssignments = {};
|
|
11494
11493
|
const permutations = unique(
|
|
11495
11494
|
lineUp.flatMap(
|
|
11496
|
-
({ collectionAssignments }) => collectionAssignments
|
|
11495
|
+
({ collectionAssignments }) => collectionAssignments?.map(
|
|
11497
11496
|
({ collectionId, collectionPosition }) => [collectionId, collectionPosition].join("|")
|
|
11498
11497
|
)
|
|
11499
|
-
)
|
|
11498
|
+
).filter(Boolean)
|
|
11500
11499
|
);
|
|
11501
11500
|
permutations.forEach((permutation) => {
|
|
11502
11501
|
const [collectionId, position] = permutation.split("|");
|
|
@@ -15973,7 +15972,7 @@ const toBePlayed = {
|
|
|
15973
15972
|
winningSide: void 0
|
|
15974
15973
|
};
|
|
15975
15974
|
|
|
15976
|
-
function
|
|
15975
|
+
function findDrawMatchUp({
|
|
15977
15976
|
tournamentParticipants,
|
|
15978
15977
|
afterRecoveryTimes,
|
|
15979
15978
|
contextContent,
|
|
@@ -16035,7 +16034,7 @@ function modifyMatchUpScore({
|
|
|
16035
16034
|
const isDualMatchUp = matchUp.matchUpType === TEAM$2;
|
|
16036
16035
|
if (isDualMatchUp && drawDefinition) {
|
|
16037
16036
|
if (matchUpId && matchUp.matchUpId !== matchUpId) {
|
|
16038
|
-
const findResult =
|
|
16037
|
+
const findResult = findDrawMatchUp({
|
|
16039
16038
|
drawDefinition,
|
|
16040
16039
|
matchUpId,
|
|
16041
16040
|
event
|
|
@@ -16064,7 +16063,7 @@ function modifyMatchUpScore({
|
|
|
16064
16063
|
if (removeWinningSide)
|
|
16065
16064
|
matchUp.winningSide = void 0;
|
|
16066
16065
|
if (!structure && drawDefinition) {
|
|
16067
|
-
({ structure } =
|
|
16066
|
+
({ structure } = findDrawMatchUp({
|
|
16068
16067
|
drawDefinition,
|
|
16069
16068
|
matchUpId,
|
|
16070
16069
|
event
|
|
@@ -16219,6 +16218,48 @@ function drawPositionsAssignedParticipantIds({ structure, matchUp }) {
|
|
|
16219
16218
|
return assignedParticipantIds?.length === 2;
|
|
16220
16219
|
}
|
|
16221
16220
|
|
|
16221
|
+
function ensureSideLineUps({
|
|
16222
|
+
inContextDualMatchUp,
|
|
16223
|
+
drawDefinition,
|
|
16224
|
+
tournamentId,
|
|
16225
|
+
dualMatchUp,
|
|
16226
|
+
eventId
|
|
16227
|
+
}) {
|
|
16228
|
+
if (dualMatchUp && !dualMatchUp?.sides?.length) {
|
|
16229
|
+
if (!inContextDualMatchUp) {
|
|
16230
|
+
inContextDualMatchUp = findDrawMatchUp({
|
|
16231
|
+
matchUpId: dualMatchUp.matchUpId,
|
|
16232
|
+
inContext: true,
|
|
16233
|
+
drawDefinition
|
|
16234
|
+
})?.matchUp;
|
|
16235
|
+
}
|
|
16236
|
+
const { extension } = findExtension$1({
|
|
16237
|
+
element: drawDefinition,
|
|
16238
|
+
name: LINEUPS
|
|
16239
|
+
});
|
|
16240
|
+
const lineUps = makeDeepCopy(extension?.value || {}, false, true);
|
|
16241
|
+
const extractSideDetail = ({
|
|
16242
|
+
displaySideNumber,
|
|
16243
|
+
drawPosition,
|
|
16244
|
+
sideNumber
|
|
16245
|
+
}) => ({ drawPosition, sideNumber, displaySideNumber });
|
|
16246
|
+
dualMatchUp.sides = inContextDualMatchUp?.sides?.map((side) => {
|
|
16247
|
+
const participantId = side.participantId;
|
|
16248
|
+
return {
|
|
16249
|
+
...extractSideDetail(side),
|
|
16250
|
+
lineUp: participantId && lineUps[participantId] || []
|
|
16251
|
+
};
|
|
16252
|
+
});
|
|
16253
|
+
modifyMatchUpNotice({
|
|
16254
|
+
context: "ensureSidLineUps",
|
|
16255
|
+
matchUp: dualMatchUp,
|
|
16256
|
+
drawDefinition,
|
|
16257
|
+
tournamentId,
|
|
16258
|
+
eventId
|
|
16259
|
+
});
|
|
16260
|
+
}
|
|
16261
|
+
}
|
|
16262
|
+
|
|
16222
16263
|
const typeMatch = (arr, type) => arr.filter(Boolean).every((i) => typeof i === type);
|
|
16223
16264
|
const allNumeric = (arr) => arr.filter(Boolean).every(isNumeric);
|
|
16224
16265
|
function getCategoryAgeDetails(params) {
|
|
@@ -16390,28 +16431,53 @@ function getCategoryAgeDetails(params) {
|
|
|
16390
16431
|
return result;
|
|
16391
16432
|
}
|
|
16392
16433
|
|
|
16434
|
+
function validateCategory({ category }) {
|
|
16435
|
+
if (!isObject(category))
|
|
16436
|
+
return { error: INVALID_VALUES };
|
|
16437
|
+
const categoryDetails = getCategoryAgeDetails({ category });
|
|
16438
|
+
if (categoryDetails.error)
|
|
16439
|
+
return { error: categoryDetails };
|
|
16440
|
+
const { ratingMax, ratingMin } = category;
|
|
16441
|
+
if (ratingMax && !isNumeric(ratingMax))
|
|
16442
|
+
return decorateResult({
|
|
16443
|
+
result: { error: INVALID_VALUES },
|
|
16444
|
+
context: { ratingMax }
|
|
16445
|
+
});
|
|
16446
|
+
if (ratingMin && !isNumeric(ratingMin))
|
|
16447
|
+
return decorateResult({
|
|
16448
|
+
result: { error: INVALID_VALUES },
|
|
16449
|
+
context: { ratingMin }
|
|
16450
|
+
});
|
|
16451
|
+
return { ...categoryDetails };
|
|
16452
|
+
}
|
|
16453
|
+
|
|
16393
16454
|
function categoryCanContain({
|
|
16394
16455
|
childCategory,
|
|
16395
16456
|
withDetails,
|
|
16396
16457
|
category
|
|
16397
16458
|
}) {
|
|
16398
|
-
const categoryDetails =
|
|
16399
|
-
const childCategoryDetails =
|
|
16459
|
+
const categoryDetails = validateCategory({ category });
|
|
16460
|
+
const childCategoryDetails = validateCategory({
|
|
16400
16461
|
category: childCategory
|
|
16401
16462
|
});
|
|
16402
16463
|
const invalidAgeMin = childCategoryDetails.ageMin && (categoryDetails.ageMin && childCategoryDetails.ageMin < categoryDetails.ageMin || categoryDetails.ageMax && childCategoryDetails.ageMin > categoryDetails.ageMax);
|
|
16403
16464
|
const invalidAgeMax = childCategoryDetails.ageMax && (categoryDetails.ageMax && childCategoryDetails.ageMax > categoryDetails.ageMax || categoryDetails.ageMin && childCategoryDetails.ageMax < categoryDetails.ageMin);
|
|
16404
16465
|
const invalidAgeMinDate = childCategoryDetails.ageMinDate && categoryDetails.ageMaxDate && new Date(childCategoryDetails.ageMinDate) > new Date(categoryDetails.ageMaxDate);
|
|
16405
16466
|
const invalidAgeMaxDate = childCategoryDetails.ageMaxDate && categoryDetails.ageMinDate && new Date(childCategoryDetails.ageMaxDate) < new Date(categoryDetails.ageMinDate);
|
|
16406
|
-
const
|
|
16467
|
+
const ratingComparison = category.ratingType && childCategory.ratingType && category.ratingType === childCategory.ratingType;
|
|
16468
|
+
const invalidRatingRange = ratingComparison && (category.ratingMin && childCategory.ratingMin && childCategory.ratingMin < category.ratingMin || category.ratingMax && childCategory.ratingMax && childCategory.ratingMax > category.ratingMax || category.ratingMin && childCategory.ratingMax && childCategory.ratingMax < category.ratingMin || category.ratingMax && childCategory.ratingMin && childCategory.ratingMin > category.ratingMax);
|
|
16469
|
+
const invalidBallType = category.ballType && childCategory.ballType && category.ballType !== childCategory.ballType;
|
|
16470
|
+
const valid = !invalidRatingRange && !invalidAgeMinDate && !invalidAgeMaxDate && !invalidBallType && !invalidAgeMax && !invalidAgeMin;
|
|
16407
16471
|
const ignoreFalse = true;
|
|
16408
16472
|
const result = definedAttributes(
|
|
16409
16473
|
{
|
|
16410
|
-
|
|
16474
|
+
invalidRatingRange,
|
|
16475
|
+
invalidAgeMinDate,
|
|
16476
|
+
invalidAgeMaxDate,
|
|
16477
|
+
invalidBallType,
|
|
16411
16478
|
invalidAgeMax,
|
|
16412
16479
|
invalidAgeMin,
|
|
16413
|
-
|
|
16414
|
-
invalidAgeMaxDate
|
|
16480
|
+
valid
|
|
16415
16481
|
},
|
|
16416
16482
|
ignoreFalse
|
|
16417
16483
|
);
|
|
@@ -17007,7 +17073,7 @@ function generateTieMatchUpScore(params) {
|
|
|
17007
17073
|
}
|
|
17008
17074
|
if (!winningSide && tallyDirectives) {
|
|
17009
17075
|
const matchUpId = matchUp.matchUpId;
|
|
17010
|
-
const inContextMatchUp = matchUp.hasContext ? matchUp : matchUpsMap?.drawMatchUps?.[matchUpId] || drawDefinition &&
|
|
17076
|
+
const inContextMatchUp = matchUp.hasContext ? matchUp : matchUpsMap?.drawMatchUps?.[matchUpId] || drawDefinition && findDrawMatchUp({
|
|
17011
17077
|
inContext: true,
|
|
17012
17078
|
drawDefinition,
|
|
17013
17079
|
matchUpId
|
|
@@ -17051,7 +17117,7 @@ function updateTieMatchUpScore({
|
|
|
17051
17117
|
matchUpId,
|
|
17052
17118
|
event
|
|
17053
17119
|
}) {
|
|
17054
|
-
const result =
|
|
17120
|
+
const result = findDrawMatchUp({ drawDefinition, event, matchUpId });
|
|
17055
17121
|
if (result.error)
|
|
17056
17122
|
return result;
|
|
17057
17123
|
if (!result.matchUp)
|
|
@@ -17059,6 +17125,12 @@ function updateTieMatchUpScore({
|
|
|
17059
17125
|
const { matchUp, structure } = result;
|
|
17060
17126
|
if (!matchUp.tieMatchUps)
|
|
17061
17127
|
return { error: INVALID_MATCHUP };
|
|
17128
|
+
ensureSideLineUps({
|
|
17129
|
+
tournamentId: tournamentRecord?.tournamentId,
|
|
17130
|
+
eventId: event?.eventId,
|
|
17131
|
+
dualMatchUp: matchUp,
|
|
17132
|
+
drawDefinition
|
|
17133
|
+
});
|
|
17062
17134
|
const { extension } = findExtension({
|
|
17063
17135
|
name: DISABLE_AUTO_CALC,
|
|
17064
17136
|
element: matchUp
|
|
@@ -21040,7 +21112,7 @@ function setMatchUpFormat(params) {
|
|
|
21040
21112
|
return { error: UNRECOGNIZED_MATCHUP_FORMAT };
|
|
21041
21113
|
const stack = "setMatchUpFormat";
|
|
21042
21114
|
if (matchUpId) {
|
|
21043
|
-
const result =
|
|
21115
|
+
const result = findDrawMatchUp({
|
|
21044
21116
|
drawDefinition,
|
|
21045
21117
|
matchUpId,
|
|
21046
21118
|
event
|