tods-competition-factory 1.8.3 → 1.8.4
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 +290 -26
- package/dist/forge/generate.mjs.map +1 -1
- package/dist/forge/query.mjs +12 -0
- package/dist/forge/query.mjs.map +1 -1
- package/dist/forge/transform.mjs +250 -4
- package/dist/forge/transform.mjs.map +1 -1
- package/dist/forge/utilities.mjs +175 -0
- package/dist/forge/utilities.mjs.map +1 -1
- package/dist/index.mjs +299 -133
- package/dist/index.mjs.map +1 -1
- package/dist/tods-competition-factory.development.cjs.js +333 -150
- 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
|
@@ -319,7 +319,7 @@ function groupConsecutiveNumbers(arr) {
|
|
|
319
319
|
return result;
|
|
320
320
|
}, []);
|
|
321
321
|
}
|
|
322
|
-
function allNumeric(arr) {
|
|
322
|
+
function allNumeric$1(arr) {
|
|
323
323
|
return arr.reduce((numeric, item) => !isNaN(parseInt(item)) && numeric, true);
|
|
324
324
|
}
|
|
325
325
|
function noNumeric(arr) {
|
|
@@ -587,6 +587,10 @@ const MISSING_VALUE = {
|
|
|
587
587
|
message: "Missing value",
|
|
588
588
|
code: "ERR_MISSING_VALUE"
|
|
589
589
|
};
|
|
590
|
+
const INVALID_DATE = {
|
|
591
|
+
message: "Invalid Date",
|
|
592
|
+
code: "ERR_INVALID_DATE"
|
|
593
|
+
};
|
|
590
594
|
const INVALID_PARTICIPANT_ID = {
|
|
591
595
|
message: "Invalid participantId",
|
|
592
596
|
code: "ERR_INVALID_PARTICIPANT_ID"
|
|
@@ -703,10 +707,18 @@ const INVALID_CONFIGURATION = {
|
|
|
703
707
|
message: "Invalid configuration",
|
|
704
708
|
code: "ERR_INVALID_CONFIG"
|
|
705
709
|
};
|
|
710
|
+
const INVALID_COLLECTION_DEFINITION = {
|
|
711
|
+
message: "Invalid collectionDefinition",
|
|
712
|
+
code: "ERR_INVALID_COLLECTION_DEFINITION"
|
|
713
|
+
};
|
|
706
714
|
const INVALID_OBJECT = {
|
|
707
715
|
message: "Invalid object",
|
|
708
716
|
code: "ERR_INVALID_OBJECT"
|
|
709
717
|
};
|
|
718
|
+
const INVALID_CATEGORY = {
|
|
719
|
+
message: "Invalid category",
|
|
720
|
+
code: "ERR_INVALID_CATEGORY"
|
|
721
|
+
};
|
|
710
722
|
const INVALID_VALUES = {
|
|
711
723
|
message: "Invalid values",
|
|
712
724
|
code: "ERR_INVALID_VALUES"
|
|
@@ -933,7 +945,11 @@ function deleteNotice({ key, topic }) {
|
|
|
933
945
|
function getTopics() {
|
|
934
946
|
return _globalStateProvider.getTopics();
|
|
935
947
|
}
|
|
948
|
+
function getProvider() {
|
|
949
|
+
return _globalStateProvider;
|
|
950
|
+
}
|
|
936
951
|
|
|
952
|
+
const validDateString = /^[\d]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][\d]|3[0-1])$/;
|
|
937
953
|
const validTimeString = /^((0[\d]|1[\d]|2[0-3]):[0-5][\d](:[0-5][\d])?)([.,][0-9]{3})?$/;
|
|
938
954
|
const dateValidation = /^([\d]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][\d]|3[0-1]))([ T](0[\d]|1[\d]|2[0-3]):[0-5][\d](:[0-5][\d])?)?([.,][\d]{3})?Z?$/;
|
|
939
955
|
|
|
@@ -957,6 +973,9 @@ function isDateObject(value) {
|
|
|
957
973
|
return datePrototype === "[object Date]";
|
|
958
974
|
}
|
|
959
975
|
}
|
|
976
|
+
function isValidDateString(scheduleDate) {
|
|
977
|
+
return isISODateString(scheduleDate) || validDateString.test(scheduleDate);
|
|
978
|
+
}
|
|
960
979
|
const getUTCdateString = (date) => {
|
|
961
980
|
const dateDate = isDate(date) || isISODateString(date) ? new Date(date) : /* @__PURE__ */ new Date();
|
|
962
981
|
const monthNumber = dateDate.getUTCMonth() + 1;
|
|
@@ -1007,6 +1026,11 @@ function extractTime(dateString) {
|
|
|
1007
1026
|
function extractDate(dateString) {
|
|
1008
1027
|
return isISODateString(dateString) || dateValidation.test(dateString) ? dateString.split("T")[0] : void 0;
|
|
1009
1028
|
}
|
|
1029
|
+
function dateStringDaysChange(dateString, daysChange) {
|
|
1030
|
+
const date = new Date(dateString);
|
|
1031
|
+
date.setDate(date.getDate() + daysChange);
|
|
1032
|
+
return extractDate(date.toISOString());
|
|
1033
|
+
}
|
|
1010
1034
|
function splitTime(value) {
|
|
1011
1035
|
value = typeof value !== "string" ? "00:00" : value;
|
|
1012
1036
|
const o = {}, time = {};
|
|
@@ -1060,6 +1084,13 @@ function sameDay(date1, date2) {
|
|
|
1060
1084
|
}
|
|
1061
1085
|
|
|
1062
1086
|
function makeDeepCopy(sourceObject, convertExtensions, internalUse, removeExtensions, iteration = 0) {
|
|
1087
|
+
if (getProvider().makeDeepCopy)
|
|
1088
|
+
return getProvider().makeDeepCopy(
|
|
1089
|
+
sourceObject,
|
|
1090
|
+
convertExtensions,
|
|
1091
|
+
internalUse,
|
|
1092
|
+
removeExtensions
|
|
1093
|
+
);
|
|
1063
1094
|
const deepCopy = deepCopyEnabled();
|
|
1064
1095
|
const { stringify, toJSON, ignore, modulate } = deepCopy || {};
|
|
1065
1096
|
if (!deepCopy?.enabled && !internalUse || typeof sourceObject !== "object" || typeof sourceObject === "function" || sourceObject === null || typeof deepCopy?.threshold === "number" && iteration >= deepCopy.threshold) {
|
|
@@ -3893,7 +3924,7 @@ function getOrderedDrawPositions({
|
|
|
3893
3924
|
(pair) => overlap(pair || [], drawPositions.filter(Boolean))
|
|
3894
3925
|
) || unassignedDrawPositions;
|
|
3895
3926
|
const isFeedRound = targetRoundProfile?.feedRound;
|
|
3896
|
-
if (allNumeric(drawPositions)) {
|
|
3927
|
+
if (allNumeric$1(drawPositions)) {
|
|
3897
3928
|
const orderedDrawPositions = drawPositions.sort(numericSort);
|
|
3898
3929
|
return {
|
|
3899
3930
|
orderedDrawPositions: orderedDrawPositions.length === 2 ? orderedDrawPositions : displayOrder,
|
|
@@ -5035,22 +5066,25 @@ function groupRounds({ groupSize, drawPositionOffset }) {
|
|
|
5035
5066
|
);
|
|
5036
5067
|
}
|
|
5037
5068
|
|
|
5038
|
-
function generateRoundRobin({
|
|
5039
|
-
|
|
5040
|
-
|
|
5041
|
-
|
|
5042
|
-
|
|
5043
|
-
|
|
5044
|
-
|
|
5045
|
-
|
|
5046
|
-
|
|
5047
|
-
|
|
5048
|
-
|
|
5049
|
-
|
|
5050
|
-
|
|
5051
|
-
|
|
5052
|
-
|
|
5053
|
-
|
|
5069
|
+
function generateRoundRobin(params) {
|
|
5070
|
+
const {
|
|
5071
|
+
groupNameBase = "Group",
|
|
5072
|
+
playoffAttributes,
|
|
5073
|
+
stageSequence = 1,
|
|
5074
|
+
structureOptions,
|
|
5075
|
+
appliedPolicies,
|
|
5076
|
+
seedingProfile,
|
|
5077
|
+
stage = MAIN,
|
|
5078
|
+
matchUpType,
|
|
5079
|
+
roundTarget,
|
|
5080
|
+
structureId,
|
|
5081
|
+
groupNames,
|
|
5082
|
+
drawSize,
|
|
5083
|
+
idPrefix,
|
|
5084
|
+
isMock,
|
|
5085
|
+
uuids
|
|
5086
|
+
} = params;
|
|
5087
|
+
const structureName = params.structureName ?? playoffAttributes?.["0"]?.name ?? constantToString(MAIN);
|
|
5054
5088
|
const { groupCount, groupSize } = deriveGroups({
|
|
5055
5089
|
structureOptions,
|
|
5056
5090
|
appliedPolicies,
|
|
@@ -5070,12 +5104,13 @@ function generateRoundRobin({
|
|
|
5070
5104
|
maxRoundNumber = Math.max(
|
|
5071
5105
|
...matchUps.map(({ roundNumber }) => roundNumber)
|
|
5072
5106
|
);
|
|
5107
|
+
const structureName2 = groupNames?.[structureOrder - 1] ?? `${groupNameBase} ${structureOrder}`;
|
|
5073
5108
|
return structureTemplate({
|
|
5074
|
-
structureName: `${groupNameBase} ${structureOrder}`,
|
|
5075
5109
|
structureId: uuids?.pop(),
|
|
5076
5110
|
structureType: ITEM,
|
|
5077
5111
|
finishingPosition,
|
|
5078
5112
|
structureOrder,
|
|
5113
|
+
structureName: structureName2,
|
|
5079
5114
|
matchUps
|
|
5080
5115
|
});
|
|
5081
5116
|
});
|
|
@@ -14261,7 +14296,7 @@ function generatePlayoffStructures(params) {
|
|
|
14261
14296
|
const attributeProfile = playoffAttributes?.[exitProfile];
|
|
14262
14297
|
const base = playoffStructureNameBase && `${playoffStructureNameBase} ` || "";
|
|
14263
14298
|
const customNaming = playoffAttributes?.[finishingPositionRange] ?? finishingPositionNaming?.[finishingPositionRange];
|
|
14264
|
-
const structureName = customNaming?.name || attributeProfile?.name && (addNameBaseToAttributeName ? `${base}${attributeProfile?.name}` : attributeProfile.name) || `${base}${finishingPositionRange}`;
|
|
14299
|
+
const structureName = params.structureName || customNaming?.name || attributeProfile?.name && (addNameBaseToAttributeName ? `${base}${attributeProfile?.name}` : attributeProfile.name) || `${base}${finishingPositionRange}`;
|
|
14265
14300
|
const structureAbbreviation = customNaming?.abbreviation || attributeProfile?.abbreviation;
|
|
14266
14301
|
const mainParams = {
|
|
14267
14302
|
idPrefix: idPrefix && `${idPrefix}-${structureName}-RP`,
|
|
@@ -14417,12 +14452,14 @@ function feedInChampionship(params) {
|
|
|
14417
14452
|
fmlc
|
|
14418
14453
|
});
|
|
14419
14454
|
if (drawSize > 2) {
|
|
14455
|
+
const name = playoffAttributes?.["0-1"]?.name ?? constantToString(CONSOLATION);
|
|
14456
|
+
const structureName2 = params.playoffStructureNameBase ? `${params.playoffStructureNameBase} ${name}` : name;
|
|
14420
14457
|
const consolationStructure = structureTemplate({
|
|
14421
|
-
structureName: playoffAttributes?.["0-1"]?.name ?? constantToString(CONSOLATION),
|
|
14422
14458
|
matchUps: consolationMatchUps,
|
|
14423
14459
|
structureId: uuids?.pop(),
|
|
14424
14460
|
stage: CONSOLATION,
|
|
14425
14461
|
stageSequence: 1,
|
|
14462
|
+
structureName: structureName2,
|
|
14426
14463
|
matchUpType
|
|
14427
14464
|
});
|
|
14428
14465
|
structures.push(consolationStructure);
|
|
@@ -14568,8 +14605,9 @@ function processPlayoffGroups({
|
|
|
14568
14605
|
} else if ([COMPASS, OLYMPIC, PLAY_OFF].includes(playoffDrawType)) {
|
|
14569
14606
|
const params2 = {
|
|
14570
14607
|
playoffAttributes: playoffGroup.playoffAttributes ?? playoffAttributes,
|
|
14608
|
+
playoffStructureNameBase: playoffGroup.playoffStructureNameBase,
|
|
14571
14609
|
structureId: playoffGroup.structureId ?? uuids?.pop(),
|
|
14572
|
-
|
|
14610
|
+
structureName: playoffGroup.structureName,
|
|
14573
14611
|
idPrefix: idPrefix && `${idPrefix}-po`,
|
|
14574
14612
|
addNameBaseToAttributeName: true,
|
|
14575
14613
|
finishingPositionOffset,
|
|
@@ -14622,7 +14660,9 @@ function processPlayoffGroups({
|
|
|
14622
14660
|
].includes(playoffDrawType)) {
|
|
14623
14661
|
const uuidsFMLC = [uuids?.pop(), uuids?.pop()];
|
|
14624
14662
|
const params2 = {
|
|
14663
|
+
playoffStructureNameBase: playoffGroup.playoffStructureNameBase,
|
|
14625
14664
|
structureId: playoffGroup.structureId ?? uuids?.pop(),
|
|
14665
|
+
playoffAttributes: playoffGroup.playoffAttributes,
|
|
14626
14666
|
idPrefix: idPrefix && `${idPrefix}-po`,
|
|
14627
14667
|
finishingPositionOffset,
|
|
14628
14668
|
uuids: uuidsFMLC,
|
|
@@ -16164,6 +16204,208 @@ function drawPositionsAssignedParticipantIds({ structure, matchUp }) {
|
|
|
16164
16204
|
return assignedParticipantIds?.length === 2;
|
|
16165
16205
|
}
|
|
16166
16206
|
|
|
16207
|
+
const typeMatch = (arr, type) => arr.filter(Boolean).every((i) => typeof i === type);
|
|
16208
|
+
const allNumeric = (arr) => arr.filter(Boolean).every(isNumeric);
|
|
16209
|
+
function getCategoryAgeDetails(params) {
|
|
16210
|
+
const category = params.category;
|
|
16211
|
+
if (typeof category !== "object")
|
|
16212
|
+
return { error: INVALID_CATEGORY };
|
|
16213
|
+
let { ageCategoryCode, ageMaxDate, ageMinDate, ageMax, ageMin } = category;
|
|
16214
|
+
const categoryName = category.categoryName;
|
|
16215
|
+
let combinedAge;
|
|
16216
|
+
if (!typeMatch(
|
|
16217
|
+
[ageCategoryCode, ageMaxDate, ageMinDate, categoryName],
|
|
16218
|
+
"string"
|
|
16219
|
+
) || !allNumeric(
|
|
16220
|
+
[ageMax, ageMin]
|
|
16221
|
+
))
|
|
16222
|
+
return { error: INVALID_CATEGORY };
|
|
16223
|
+
const consideredDate = params.consideredDate ?? extractDate((/* @__PURE__ */ new Date()).toLocaleDateString("sv"));
|
|
16224
|
+
if (!isValidDateString(consideredDate))
|
|
16225
|
+
return { error: INVALID_DATE };
|
|
16226
|
+
const [consideredYear] = consideredDate.split("-").slice(0, 3).map((n) => parseInt(n));
|
|
16227
|
+
const previousDayDate = dateStringDaysChange(consideredDate, -1);
|
|
16228
|
+
const [previousDayMonth, previousDay] = previousDayDate.split("-").slice(1, 3).map((n) => parseInt(n));
|
|
16229
|
+
const previousMonthDay = `${zeroPad(previousDayMonth)}-${zeroPad(
|
|
16230
|
+
previousDay
|
|
16231
|
+
)}`;
|
|
16232
|
+
const nextDayDate = dateStringDaysChange(consideredDate, 1);
|
|
16233
|
+
const [nextDayMonth, nextDay] = nextDayDate.split("-").slice(1, 3).map((n) => parseInt(n));
|
|
16234
|
+
const nextMonthDay = `${zeroPad(nextDayMonth)}-${zeroPad(nextDay)}`;
|
|
16235
|
+
let calculatedAgeMaxDate = ageMin && dateStringDaysChange(consideredDate, -1 * 365 * ageMin);
|
|
16236
|
+
let calculatedAgeMinDate = ageMax && dateStringDaysChange(consideredDate, -1 * 365 * ageMax);
|
|
16237
|
+
const errors = [];
|
|
16238
|
+
const addError = (errorString) => !errors.includes(errorString) && errors.push(errorString);
|
|
16239
|
+
ageCategoryCode = ageCategoryCode ?? categoryName;
|
|
16240
|
+
const prePost = /^([UO]?)(\d{1,2})([UO]?)$/;
|
|
16241
|
+
const extractCombined = /^C(\d{1,2})-(\d{1,2})$/;
|
|
16242
|
+
const isBetween = ageCategoryCode?.includes("-");
|
|
16243
|
+
const isCombined = isBetween && ageCategoryCode?.match(extractCombined);
|
|
16244
|
+
const isCoded = ageCategoryCode?.match(prePost);
|
|
16245
|
+
const constructedDate = (y, df) => `${y}-${df}`;
|
|
16246
|
+
const uPre = (ageInt) => {
|
|
16247
|
+
const ageMinYear = consideredYear - ageInt;
|
|
16248
|
+
const newMinDate = constructedDate(ageMinYear, nextMonthDay);
|
|
16249
|
+
if (category.ageMinDate && category.ageMinDate !== newMinDate)
|
|
16250
|
+
addError(`Invalid submitted ageMinDate: ${ageMinDate}`);
|
|
16251
|
+
ageMinDate = newMinDate;
|
|
16252
|
+
if (ageCategoryCode) {
|
|
16253
|
+
if (category.ageMax && category.ageMax !== ageInt - 1) {
|
|
16254
|
+
addError(`Invalid submitted ageMax: ${ageMax}`);
|
|
16255
|
+
calculatedAgeMinDate = void 0;
|
|
16256
|
+
}
|
|
16257
|
+
ageMax = ageInt - 1;
|
|
16258
|
+
}
|
|
16259
|
+
};
|
|
16260
|
+
const uPost = (ageInt) => {
|
|
16261
|
+
const ageMinYear = consideredYear - ageInt - 1;
|
|
16262
|
+
const newMinDate = constructedDate(ageMinYear, nextMonthDay);
|
|
16263
|
+
if (category.ageMin && category.ageMin > ageInt) {
|
|
16264
|
+
addError(`Invalid submitted ageMin: ${ageMin}`);
|
|
16265
|
+
}
|
|
16266
|
+
if (category.ageMax && category.ageMax > ageInt) {
|
|
16267
|
+
addError(`Invalid submitted ageMax: ${ageMax}`);
|
|
16268
|
+
}
|
|
16269
|
+
if (category.ageMinDate && category.ageMinDate !== newMinDate)
|
|
16270
|
+
addError(`Invalid submitted ageMinDate: ${ageMinDate}`);
|
|
16271
|
+
ageMinDate = newMinDate;
|
|
16272
|
+
if (ageCategoryCode) {
|
|
16273
|
+
if (category.ageMax && category.ageMax !== ageInt) {
|
|
16274
|
+
addError(`Invalid submitted ageMax: ${ageMax}`);
|
|
16275
|
+
calculatedAgeMaxDate = void 0;
|
|
16276
|
+
}
|
|
16277
|
+
ageMax = ageInt;
|
|
16278
|
+
}
|
|
16279
|
+
};
|
|
16280
|
+
const oPre = (ageInt) => {
|
|
16281
|
+
const ageMaxYear = consideredYear - ageInt;
|
|
16282
|
+
const newMaxDate = constructedDate(ageMaxYear, previousMonthDay);
|
|
16283
|
+
if (category.ageMaxDate && category.ageMaxDate !== newMaxDate)
|
|
16284
|
+
addError(`Invalid submitted ageMaxDate: ${ageMaxDate}`);
|
|
16285
|
+
ageMaxDate = newMaxDate;
|
|
16286
|
+
if (ageCategoryCode) {
|
|
16287
|
+
if (category.ageMin && category.ageMin !== ageInt + 1) {
|
|
16288
|
+
addError(`Invalid submitted ageMin: ${ageMin}`);
|
|
16289
|
+
calculatedAgeMaxDate = void 0;
|
|
16290
|
+
}
|
|
16291
|
+
ageMin = ageInt + 1;
|
|
16292
|
+
}
|
|
16293
|
+
};
|
|
16294
|
+
const oPost = (ageInt) => {
|
|
16295
|
+
const ageMaxYear = consideredYear - ageInt - 1;
|
|
16296
|
+
const newMaxDate = constructedDate(ageMaxYear, previousMonthDay);
|
|
16297
|
+
if (category.ageMaxDate && category.ageMaxDate !== newMaxDate)
|
|
16298
|
+
addError(`Invalid submitted ageMaxDate: ${ageMaxDate}`);
|
|
16299
|
+
ageMaxDate = newMaxDate;
|
|
16300
|
+
if (ageCategoryCode) {
|
|
16301
|
+
if (category.ageMin && category.ageMin !== ageInt) {
|
|
16302
|
+
addError(`Invalid submitted ageMin: ${ageMin}`);
|
|
16303
|
+
calculatedAgeMaxDate = void 0;
|
|
16304
|
+
}
|
|
16305
|
+
ageMin = ageInt;
|
|
16306
|
+
}
|
|
16307
|
+
};
|
|
16308
|
+
const processCode = (code) => {
|
|
16309
|
+
const [pre, age, post] = (code.match(prePost) || []).slice(1);
|
|
16310
|
+
const ageInt = parseInt(age);
|
|
16311
|
+
if (pre === "U") {
|
|
16312
|
+
if (category.ageMaxDate && category.ageMaxDate !== ageMaxDate) {
|
|
16313
|
+
addError(`Invalid submitted ageMaxDate: ${category.ageMaxDate}`);
|
|
16314
|
+
}
|
|
16315
|
+
uPre(ageInt);
|
|
16316
|
+
} else if (pre === "O") {
|
|
16317
|
+
oPre(ageInt);
|
|
16318
|
+
}
|
|
16319
|
+
if (post === "U") {
|
|
16320
|
+
if (category.ageMaxDate && category.ageMaxDate !== ageMaxDate) {
|
|
16321
|
+
addError(`Invalid submitted ageMaxDate: ${category.ageMaxDate}`);
|
|
16322
|
+
}
|
|
16323
|
+
uPost(ageInt);
|
|
16324
|
+
} else if (post === "O") {
|
|
16325
|
+
oPost(ageInt);
|
|
16326
|
+
}
|
|
16327
|
+
ageMaxDate = ageMaxDate ?? calculatedAgeMaxDate;
|
|
16328
|
+
ageMinDate = ageMinDate ?? calculatedAgeMinDate;
|
|
16329
|
+
};
|
|
16330
|
+
if (isCombined) {
|
|
16331
|
+
ageMaxDate = void 0;
|
|
16332
|
+
ageMinDate = void 0;
|
|
16333
|
+
ageMax = void 0;
|
|
16334
|
+
ageMin = void 0;
|
|
16335
|
+
if (category.ageMin) {
|
|
16336
|
+
const ageMaxYear = consideredYear - category.ageMin;
|
|
16337
|
+
ageMaxDate = constructedDate(ageMaxYear, previousMonthDay);
|
|
16338
|
+
}
|
|
16339
|
+
if (category.ageMax) {
|
|
16340
|
+
const ageMinYear = consideredYear - category.ageMax - 1;
|
|
16341
|
+
ageMinDate = constructedDate(ageMinYear, nextMonthDay);
|
|
16342
|
+
}
|
|
16343
|
+
const [lowAge, highAge] = (ageCategoryCode?.match(extractCombined) ?? []).slice(1).map((n) => parseInt(n));
|
|
16344
|
+
if (lowAge <= highAge) {
|
|
16345
|
+
ageMin = lowAge;
|
|
16346
|
+
ageMax = highAge;
|
|
16347
|
+
combinedAge = true;
|
|
16348
|
+
} else {
|
|
16349
|
+
addError(`Invalid combined age range ${ageCategoryCode}`);
|
|
16350
|
+
}
|
|
16351
|
+
} else if (isBetween) {
|
|
16352
|
+
ageCategoryCode?.split("-").forEach(processCode);
|
|
16353
|
+
} else if (isCoded) {
|
|
16354
|
+
processCode(ageCategoryCode);
|
|
16355
|
+
} else {
|
|
16356
|
+
if (ageMin)
|
|
16357
|
+
oPre(ageMin);
|
|
16358
|
+
if (ageMax)
|
|
16359
|
+
uPost(ageMax);
|
|
16360
|
+
}
|
|
16361
|
+
if (ageMax && category.ageMin && category.ageMin > ageMax) {
|
|
16362
|
+
addError(`Invalid submitted ageMin: ${category.ageMin}`);
|
|
16363
|
+
ageMin = void 0;
|
|
16364
|
+
}
|
|
16365
|
+
const result = definedAttributes({
|
|
16366
|
+
consideredDate,
|
|
16367
|
+
combinedAge,
|
|
16368
|
+
ageMaxDate,
|
|
16369
|
+
ageMinDate,
|
|
16370
|
+
ageMax,
|
|
16371
|
+
ageMin
|
|
16372
|
+
});
|
|
16373
|
+
if (errors.length)
|
|
16374
|
+
result.errors = errors;
|
|
16375
|
+
return result;
|
|
16376
|
+
}
|
|
16377
|
+
|
|
16378
|
+
function categoryCanContain({
|
|
16379
|
+
childCategory,
|
|
16380
|
+
withDetails,
|
|
16381
|
+
category
|
|
16382
|
+
}) {
|
|
16383
|
+
const categoryDetails = getCategoryAgeDetails({ category });
|
|
16384
|
+
const childCategoryDetails = getCategoryAgeDetails({
|
|
16385
|
+
category: childCategory
|
|
16386
|
+
});
|
|
16387
|
+
const invalidAgeMin = childCategoryDetails.ageMin && (categoryDetails.ageMin && childCategoryDetails.ageMin < categoryDetails.ageMin || categoryDetails.ageMax && childCategoryDetails.ageMin > categoryDetails.ageMax);
|
|
16388
|
+
const invalidAgeMax = childCategoryDetails.ageMax && (categoryDetails.ageMax && childCategoryDetails.ageMax > categoryDetails.ageMax || categoryDetails.ageMin && childCategoryDetails.ageMax < categoryDetails.ageMin);
|
|
16389
|
+
const invalidAgeMinDate = childCategoryDetails.ageMinDate && categoryDetails.ageMaxDate && new Date(childCategoryDetails.ageMinDate) > new Date(categoryDetails.ageMaxDate);
|
|
16390
|
+
const invalidAgeMaxDate = childCategoryDetails.ageMaxDate && categoryDetails.ageMinDate && new Date(childCategoryDetails.ageMaxDate) < new Date(categoryDetails.ageMinDate);
|
|
16391
|
+
const valid = !invalidAgeMax && !invalidAgeMin && !invalidAgeMinDate && !invalidAgeMaxDate;
|
|
16392
|
+
const ignoreFalse = true;
|
|
16393
|
+
const result = definedAttributes(
|
|
16394
|
+
{
|
|
16395
|
+
valid,
|
|
16396
|
+
invalidAgeMax,
|
|
16397
|
+
invalidAgeMin,
|
|
16398
|
+
invalidAgeMinDate,
|
|
16399
|
+
invalidAgeMaxDate
|
|
16400
|
+
},
|
|
16401
|
+
ignoreFalse
|
|
16402
|
+
);
|
|
16403
|
+
if (withDetails) {
|
|
16404
|
+
Object.assign(result, { categoryDetails, childCategoryDetails });
|
|
16405
|
+
}
|
|
16406
|
+
return result;
|
|
16407
|
+
}
|
|
16408
|
+
|
|
16167
16409
|
function stringify(matchUpFormatObject, preserveRedundant) {
|
|
16168
16410
|
if (typeof matchUpFormatObject !== "object")
|
|
16169
16411
|
return;
|
|
@@ -16272,6 +16514,7 @@ const matchUpFormatCode = {
|
|
|
16272
16514
|
};
|
|
16273
16515
|
|
|
16274
16516
|
function validateTieFormat(params) {
|
|
16517
|
+
const checkCategory = !!(params?.enforceCategory !== false && params?.category);
|
|
16275
16518
|
const checkGender = !!(params?.enforceGender !== false && params?.gender);
|
|
16276
16519
|
const checkCollectionIds = params?.checkCollectionIds;
|
|
16277
16520
|
const tieFormat = params?.tieFormat;
|
|
@@ -16308,9 +16551,11 @@ function validateTieFormat(params) {
|
|
|
16308
16551
|
if ((setValue || scoreValue) && !collectionValue)
|
|
16309
16552
|
aggregateValueImperative = true;
|
|
16310
16553
|
const { valid: valid2, errors: collectionDefinitionErrors } = validateCollectionDefinition({
|
|
16554
|
+
referenceCategory: params.category,
|
|
16311
16555
|
referenceGender: params.gender,
|
|
16312
16556
|
collectionDefinition,
|
|
16313
16557
|
checkCollectionIds,
|
|
16558
|
+
checkCategory,
|
|
16314
16559
|
checkGender
|
|
16315
16560
|
});
|
|
16316
16561
|
if (valid2) {
|
|
@@ -16352,19 +16597,22 @@ function validateTieFormat(params) {
|
|
|
16352
16597
|
return result;
|
|
16353
16598
|
}
|
|
16354
16599
|
function validateCollectionDefinition({
|
|
16600
|
+
checkCategory = true,
|
|
16355
16601
|
collectionDefinition,
|
|
16356
16602
|
checkCollectionIds,
|
|
16357
16603
|
checkGender = true,
|
|
16604
|
+
referenceCategory,
|
|
16358
16605
|
referenceGender,
|
|
16359
16606
|
event
|
|
16360
16607
|
}) {
|
|
16361
16608
|
referenceGender = referenceGender ?? event?.gender;
|
|
16609
|
+
const stack = "validateCollectionDefinition";
|
|
16362
16610
|
const errors = [];
|
|
16363
16611
|
if (typeof collectionDefinition !== "object") {
|
|
16364
16612
|
errors.push(
|
|
16365
16613
|
`collectionDefinition must be an object: ${collectionDefinition}`
|
|
16366
16614
|
);
|
|
16367
|
-
return { errors, error: INVALID_OBJECT };
|
|
16615
|
+
return decorateResult({ result: { errors, error: INVALID_OBJECT }, stack });
|
|
16368
16616
|
}
|
|
16369
16617
|
const {
|
|
16370
16618
|
collectionValueProfiles,
|
|
@@ -16377,6 +16625,7 @@ function validateCollectionDefinition({
|
|
|
16377
16625
|
matchUpType,
|
|
16378
16626
|
scoreValue,
|
|
16379
16627
|
setValue,
|
|
16628
|
+
category,
|
|
16380
16629
|
gender
|
|
16381
16630
|
} = collectionDefinition;
|
|
16382
16631
|
if (checkCollectionIds && typeof collectionId !== "string") {
|
|
@@ -16422,8 +16671,23 @@ function validateCollectionDefinition({
|
|
|
16422
16671
|
if (checkGender && referenceGender && gender && [GenderEnum.Male, GenderEnum.Female].includes(referenceGender) && referenceGender !== gender) {
|
|
16423
16672
|
errors.push(`Invalid gender: ${gender}`);
|
|
16424
16673
|
}
|
|
16674
|
+
if (checkCategory && referenceCategory && category) {
|
|
16675
|
+
const result = categoryCanContain({
|
|
16676
|
+
category: referenceCategory,
|
|
16677
|
+
childCategory: category
|
|
16678
|
+
});
|
|
16679
|
+
if (!result.valid)
|
|
16680
|
+
return decorateResult({
|
|
16681
|
+
result: { error: INVALID_CATEGORY },
|
|
16682
|
+
context: result,
|
|
16683
|
+
stack
|
|
16684
|
+
});
|
|
16685
|
+
}
|
|
16425
16686
|
if (errors.length)
|
|
16426
|
-
return {
|
|
16687
|
+
return decorateResult({
|
|
16688
|
+
result: { errors, error: INVALID_COLLECTION_DEFINITION },
|
|
16689
|
+
stack
|
|
16690
|
+
});
|
|
16427
16691
|
return { valid: true };
|
|
16428
16692
|
}
|
|
16429
16693
|
function checkTieFormat(tieFormat) {
|
|
@@ -19111,7 +19375,7 @@ function generateRoundRobinWithPlayOff(params) {
|
|
|
19111
19375
|
};
|
|
19112
19376
|
const { structures, groupCount, groupSize } = generateRoundRobin(mainDrawProperties);
|
|
19113
19377
|
if (groupCount < 1) {
|
|
19114
|
-
|
|
19378
|
+
return { error: INVALID_CONFIGURATION };
|
|
19115
19379
|
}
|
|
19116
19380
|
const playoffGroups = structureOptions?.playoffGroups || [
|
|
19117
19381
|
{ finishingPositions: [1], structureName: constantToString(PLAY_OFF) }
|
|
@@ -22715,8 +22979,8 @@ function prepareStage(params) {
|
|
|
22715
22979
|
});
|
|
22716
22980
|
if (!scaledEntries?.length && seedByRanking) {
|
|
22717
22981
|
const rankingScaleAttributes = {
|
|
22718
|
-
scaleType: RANKING,
|
|
22719
22982
|
scaleName: categoryName || ageCategoryCode,
|
|
22983
|
+
scaleType: RANKING,
|
|
22720
22984
|
eventType
|
|
22721
22985
|
};
|
|
22722
22986
|
({ scaledEntries } = getScaledEntries({
|