tods-competition-factory 1.8.26 → 1.8.27
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 +91 -38
- package/dist/forge/generate.mjs.map +1 -1
- package/dist/forge/query.mjs.map +1 -1
- package/dist/forge/transform.mjs +101 -68
- package/dist/forge/transform.mjs.map +1 -1
- package/dist/forge/utilities.mjs.map +1 -1
- package/dist/index.mjs +270 -202
- package/dist/index.mjs.map +1 -1
- package/dist/tods-competition-factory.development.cjs.js +444 -396
- 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 +2 -2
package/dist/forge/generate.mjs
CHANGED
|
@@ -1452,6 +1452,7 @@ const POLICY_TYPE_MATCHUP_ACTIONS = "matchUpActions";
|
|
|
1452
1452
|
const POLICY_TYPE_ROUND_NAMING = "roundNaming";
|
|
1453
1453
|
const POLICY_TYPE_PARTICIPANT = "participant";
|
|
1454
1454
|
const POLICY_TYPE_SCHEDULING = "scheduling";
|
|
1455
|
+
const POLICY_TYPE_AVOIDANCE = "avoidance";
|
|
1455
1456
|
const POLICY_TYPE_DISPLAY = "display";
|
|
1456
1457
|
const POLICY_TYPE_SCORING = "scoring";
|
|
1457
1458
|
const POLICY_TYPE_SEEDING = "seeding";
|
|
@@ -10031,6 +10032,48 @@ function assignFedDrawPositionBye({
|
|
|
10031
10032
|
}
|
|
10032
10033
|
}
|
|
10033
10034
|
|
|
10035
|
+
function processAccessors({
|
|
10036
|
+
significantCharacters,
|
|
10037
|
+
accessors = [],
|
|
10038
|
+
value
|
|
10039
|
+
}) {
|
|
10040
|
+
const extractedValues = [];
|
|
10041
|
+
const accessor = accessors[0];
|
|
10042
|
+
if (value?.[accessor]) {
|
|
10043
|
+
const remainingKeys = accessors.slice(1);
|
|
10044
|
+
if (Array.isArray(value[accessor])) {
|
|
10045
|
+
const values = value[accessor];
|
|
10046
|
+
values.forEach((nestedValue) => {
|
|
10047
|
+
const result = processAccessors({
|
|
10048
|
+
accessors: remainingKeys,
|
|
10049
|
+
significantCharacters,
|
|
10050
|
+
value: nestedValue
|
|
10051
|
+
});
|
|
10052
|
+
extractedValues.push(...result);
|
|
10053
|
+
});
|
|
10054
|
+
} else {
|
|
10055
|
+
value = value[accessor];
|
|
10056
|
+
if (remainingKeys.length) {
|
|
10057
|
+
const result = processAccessors({
|
|
10058
|
+
accessors: remainingKeys,
|
|
10059
|
+
significantCharacters,
|
|
10060
|
+
value
|
|
10061
|
+
});
|
|
10062
|
+
extractedValues.push(...result);
|
|
10063
|
+
} else {
|
|
10064
|
+
checkValue({ value });
|
|
10065
|
+
}
|
|
10066
|
+
}
|
|
10067
|
+
}
|
|
10068
|
+
function checkValue({ value: value2 }) {
|
|
10069
|
+
if (value2 && ["string", "number"].includes(typeof value2)) {
|
|
10070
|
+
const extractedValue = significantCharacters ? value2.slice(0, significantCharacters) : value2;
|
|
10071
|
+
extractedValues.push(extractedValue);
|
|
10072
|
+
}
|
|
10073
|
+
}
|
|
10074
|
+
return extractedValues;
|
|
10075
|
+
}
|
|
10076
|
+
|
|
10034
10077
|
function getAttributeGroupings({
|
|
10035
10078
|
targetParticipantIds,
|
|
10036
10079
|
policyAttributes,
|
|
@@ -10082,8 +10125,14 @@ function extractAttributeValues({
|
|
|
10082
10125
|
policyAttributes.forEach((policyAttribute) => {
|
|
10083
10126
|
const { directive, groupings, key, significantCharacters } = policyAttribute || {};
|
|
10084
10127
|
if (key) {
|
|
10085
|
-
const
|
|
10086
|
-
|
|
10128
|
+
const accessors = key.split(".");
|
|
10129
|
+
extractedValues.push(
|
|
10130
|
+
...processAccessors({
|
|
10131
|
+
significantCharacters,
|
|
10132
|
+
value: participant,
|
|
10133
|
+
accessors
|
|
10134
|
+
})
|
|
10135
|
+
);
|
|
10087
10136
|
} else if (directive) {
|
|
10088
10137
|
const includeIds = policyAttribute?.includeIds;
|
|
10089
10138
|
const collectionIds = (idCollections?.[directive] || []).filter(
|
|
@@ -10112,32 +10161,6 @@ function extractAttributeValues({
|
|
|
10112
10161
|
});
|
|
10113
10162
|
const values = unique(extractedValues);
|
|
10114
10163
|
return { values };
|
|
10115
|
-
function processKeys({ value, keys = [], significantCharacters }) {
|
|
10116
|
-
for (const [index, key] of keys.entries()) {
|
|
10117
|
-
if (value?.[key]) {
|
|
10118
|
-
if (Array.isArray(value[key])) {
|
|
10119
|
-
const values2 = value[key];
|
|
10120
|
-
const remainingKeys = keys.slice(index);
|
|
10121
|
-
values2.forEach(
|
|
10122
|
-
(nestedValue) => processKeys({
|
|
10123
|
-
value: nestedValue,
|
|
10124
|
-
keys: remainingKeys,
|
|
10125
|
-
significantCharacters
|
|
10126
|
-
})
|
|
10127
|
-
);
|
|
10128
|
-
} else {
|
|
10129
|
-
value = value[key];
|
|
10130
|
-
checkValue({ value, index });
|
|
10131
|
-
}
|
|
10132
|
-
}
|
|
10133
|
-
}
|
|
10134
|
-
function checkValue({ value: value2, index }) {
|
|
10135
|
-
if (value2 && index === keys.length - 1 && ["string", "number"].includes(typeof value2)) {
|
|
10136
|
-
const extractedValue = significantCharacters ? value2.slice(0, significantCharacters) : value2;
|
|
10137
|
-
extractedValues.push(extractedValue);
|
|
10138
|
-
}
|
|
10139
|
-
}
|
|
10140
|
-
}
|
|
10141
10164
|
}
|
|
10142
10165
|
|
|
10143
10166
|
function getPositionedParticipants({
|
|
@@ -10792,10 +10815,11 @@ function updateMatchUpStatusCodes({
|
|
|
10792
10815
|
);
|
|
10793
10816
|
matchUp.matchUpStatusCodes = (matchUp.matchUpStatusCodes ?? []).map(
|
|
10794
10817
|
(code) => {
|
|
10795
|
-
|
|
10796
|
-
|
|
10818
|
+
const value = isString(code) || !isNaN(code) ? { code } : code;
|
|
10819
|
+
if (value.sideNumber === sourceSideNumber) {
|
|
10820
|
+
return { ...value, previousMatchUpStatus: sourceMatchUpStatus };
|
|
10797
10821
|
}
|
|
10798
|
-
return
|
|
10822
|
+
return value;
|
|
10799
10823
|
}
|
|
10800
10824
|
);
|
|
10801
10825
|
}
|
|
@@ -12206,7 +12230,7 @@ function positionUnseededParticipants({
|
|
|
12206
12230
|
drawDefinition,
|
|
12207
12231
|
event
|
|
12208
12232
|
});
|
|
12209
|
-
let
|
|
12233
|
+
let avoidance = (appliedPolicies ?? {})[POLICY_TYPE_AVOIDANCE];
|
|
12210
12234
|
if (structure.stage === PLAY_OFF) {
|
|
12211
12235
|
const groupings = entries.reduce((groupings2, entry) => {
|
|
12212
12236
|
if (!groupings2[entry.groupingValue])
|
|
@@ -16319,6 +16343,29 @@ function ensureSideLineUps({
|
|
|
16319
16343
|
}
|
|
16320
16344
|
}
|
|
16321
16345
|
|
|
16346
|
+
function genderValidityCheck({
|
|
16347
|
+
referenceGender,
|
|
16348
|
+
matchUpType,
|
|
16349
|
+
gender
|
|
16350
|
+
}) {
|
|
16351
|
+
const stack = "genderValidityCheck";
|
|
16352
|
+
if (referenceGender && gender && [GenderEnum.Male, GenderEnum.Female].includes(referenceGender) && [GenderEnum.Male, GenderEnum.Female].includes(gender)) {
|
|
16353
|
+
const valid = gender === referenceGender;
|
|
16354
|
+
return valid ? { valid: true } : decorateResult({
|
|
16355
|
+
result: { valid: false, error: INVALID_GENDER },
|
|
16356
|
+
context: { gender },
|
|
16357
|
+
stack
|
|
16358
|
+
});
|
|
16359
|
+
}
|
|
16360
|
+
if (matchUpType === TypeEnum.Singles && referenceGender === MIXED)
|
|
16361
|
+
return decorateResult({
|
|
16362
|
+
info: "matchUpType SINGLES is invalid for gender MIXED",
|
|
16363
|
+
result: { error: INVALID_GENDER, valid: false },
|
|
16364
|
+
stack
|
|
16365
|
+
});
|
|
16366
|
+
return { valid: true };
|
|
16367
|
+
}
|
|
16368
|
+
|
|
16322
16369
|
const typeMatch = (arr, type) => arr.filter(Boolean).every((i) => typeof i === type);
|
|
16323
16370
|
const allNumeric = (arr) => arr.filter(Boolean).every(isNumeric);
|
|
16324
16371
|
function getCategoryAgeDetails(params) {
|
|
@@ -16808,13 +16855,19 @@ function validateCollectionDefinition({
|
|
|
16808
16855
|
if (matchUpFormat && !matchUpFormatCode.isValid(matchUpFormat)) {
|
|
16809
16856
|
errors.push(`Invalid matchUpFormat: ${matchUpFormat}`);
|
|
16810
16857
|
}
|
|
16811
|
-
if (checkGender
|
|
16812
|
-
|
|
16813
|
-
|
|
16814
|
-
|
|
16815
|
-
|
|
16816
|
-
stack
|
|
16858
|
+
if (checkGender) {
|
|
16859
|
+
const result = genderValidityCheck({
|
|
16860
|
+
referenceGender,
|
|
16861
|
+
matchUpType,
|
|
16862
|
+
gender
|
|
16817
16863
|
});
|
|
16864
|
+
if (result.error) {
|
|
16865
|
+
return decorateResult({
|
|
16866
|
+
context: { referenceGender, gender },
|
|
16867
|
+
result,
|
|
16868
|
+
stack
|
|
16869
|
+
});
|
|
16870
|
+
}
|
|
16818
16871
|
}
|
|
16819
16872
|
if (checkCategory && referenceCategory && category) {
|
|
16820
16873
|
const result = categoryCanContain({
|