tods-competition-factory 1.7.6 → 1.7.8
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 +158 -144
- package/dist/forge/generate.mjs.map +1 -1
- package/dist/forge/query.mjs +151 -142
- package/dist/forge/query.mjs.map +1 -1
- package/dist/forge/transform.mjs +153 -94
- package/dist/forge/transform.mjs.map +1 -1
- package/dist/forge/utilities.d.ts +1 -1
- package/dist/forge/utilities.mjs +126 -75
- package/dist/forge/utilities.mjs.map +1 -1
- package/dist/index.mjs +456 -217
- package/dist/index.mjs.map +1 -1
- package/dist/tods-competition-factory.development.cjs.js +564 -298
- 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 +5 -5
package/dist/forge/transform.mjs
CHANGED
|
@@ -575,93 +575,6 @@ function getTopics() {
|
|
|
575
575
|
return _globalStateProvider.getTopics();
|
|
576
576
|
}
|
|
577
577
|
|
|
578
|
-
function isObject(obj) {
|
|
579
|
-
return typeof obj === "object";
|
|
580
|
-
}
|
|
581
|
-
const extractAttributes = (atz) => (o) => !atz || typeof o !== "object" ? void 0 : Array.isArray(atz) && atz.map((a) => ({ [a]: o[a] })) || typeof atz === "object" && Object.keys(atz).map((key) => ({ [key]: o[key] })) || typeof atz === "string" && getAttr(o, atz);
|
|
582
|
-
function getAttr(o, attr) {
|
|
583
|
-
const attrs = attr.split(".");
|
|
584
|
-
for (const a of attrs) {
|
|
585
|
-
o = o?.[a];
|
|
586
|
-
if (!o)
|
|
587
|
-
return;
|
|
588
|
-
}
|
|
589
|
-
return o;
|
|
590
|
-
}
|
|
591
|
-
function definedAttributes(obj, ignoreFalse, ignoreEmptyArrays, shallow) {
|
|
592
|
-
if (typeof obj !== "object" || obj === null)
|
|
593
|
-
return obj;
|
|
594
|
-
const deepCopy = deepCopyEnabled();
|
|
595
|
-
if (!deepCopy?.enabled)
|
|
596
|
-
shallow = true;
|
|
597
|
-
const ignoreValues = ["", void 0, null];
|
|
598
|
-
if (ignoreFalse)
|
|
599
|
-
ignoreValues.push(false);
|
|
600
|
-
const definedKeys = Object.keys(obj).filter(
|
|
601
|
-
(key) => !ignoreValues.includes(obj[key]) && (!ignoreEmptyArrays || (Array.isArray(obj[key]) ? obj[key].length : true))
|
|
602
|
-
);
|
|
603
|
-
return Object.assign(
|
|
604
|
-
{},
|
|
605
|
-
...definedKeys.map((key) => {
|
|
606
|
-
return Array.isArray(obj[key]) ? {
|
|
607
|
-
[key]: shallow ? obj[key] : obj[key].map((m) => definedAttributes(m))
|
|
608
|
-
} : { [key]: shallow ? obj[key] : definedAttributes(obj[key]) };
|
|
609
|
-
})
|
|
610
|
-
);
|
|
611
|
-
}
|
|
612
|
-
|
|
613
|
-
function attributeFilter(params) {
|
|
614
|
-
if (params === null)
|
|
615
|
-
return {};
|
|
616
|
-
const { source, template } = params || {};
|
|
617
|
-
if (!template)
|
|
618
|
-
return source;
|
|
619
|
-
const target = {};
|
|
620
|
-
attributeCopy(source, template, target);
|
|
621
|
-
return target;
|
|
622
|
-
function attributeCopy(valuesObject, templateObject, outputObject) {
|
|
623
|
-
if (!valuesObject || !templateObject)
|
|
624
|
-
return void 0;
|
|
625
|
-
const vKeys = Object.keys(valuesObject);
|
|
626
|
-
const oKeys = Object.keys(templateObject);
|
|
627
|
-
const orMap = Object.assign(
|
|
628
|
-
{},
|
|
629
|
-
...oKeys.filter((key) => key.indexOf("||")).map((key) => key.split("||").map((or) => ({ [or]: key }))).flat()
|
|
630
|
-
);
|
|
631
|
-
const allKeys = oKeys.concat(...Object.keys(orMap));
|
|
632
|
-
const wildcard = allKeys.includes("*");
|
|
633
|
-
for (const vKey of vKeys) {
|
|
634
|
-
if (allKeys.indexOf(vKey) >= 0 || wildcard) {
|
|
635
|
-
const templateKey = orMap[vKey] || vKey;
|
|
636
|
-
const tobj = templateObject[templateKey] || wildcard;
|
|
637
|
-
const vobj = valuesObject[vKey];
|
|
638
|
-
if (typeof tobj === "object" && typeof vobj !== "function" && !Array.isArray(tobj)) {
|
|
639
|
-
if (Array.isArray(vobj)) {
|
|
640
|
-
const mappedElements = vobj.map((arrayMember) => {
|
|
641
|
-
const target2 = {};
|
|
642
|
-
const result = attributeCopy(arrayMember, tobj, target2);
|
|
643
|
-
return result !== false ? target2 : void 0;
|
|
644
|
-
}).filter(Boolean);
|
|
645
|
-
outputObject[vKey] = mappedElements;
|
|
646
|
-
} else if (vobj) {
|
|
647
|
-
outputObject[vKey] = {};
|
|
648
|
-
attributeCopy(vobj, tobj, outputObject[vKey]);
|
|
649
|
-
}
|
|
650
|
-
} else {
|
|
651
|
-
const value = valuesObject[vKey];
|
|
652
|
-
const exclude = Array.isArray(tobj) && !tobj.includes(value);
|
|
653
|
-
if (exclude)
|
|
654
|
-
return false;
|
|
655
|
-
if (templateObject[vKey] || wildcard && templateObject[vKey] !== false) {
|
|
656
|
-
outputObject[vKey] = value;
|
|
657
|
-
}
|
|
658
|
-
}
|
|
659
|
-
}
|
|
660
|
-
}
|
|
661
|
-
return void 0;
|
|
662
|
-
}
|
|
663
|
-
}
|
|
664
|
-
|
|
665
578
|
const validTimeString = /^((0[\d]|1[\d]|2[0-3]):[0-5][\d](:[0-5][\d])?)([.,][0-9]{3})?$/;
|
|
666
579
|
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?$/;
|
|
667
580
|
const timeValidation = /^([\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?$/;
|
|
@@ -905,6 +818,144 @@ function extensionsToAttributes(extensions) {
|
|
|
905
818
|
}).filter(Boolean);
|
|
906
819
|
}
|
|
907
820
|
|
|
821
|
+
function getAccessorValue({ element, accessor }) {
|
|
822
|
+
if (typeof accessor !== "string")
|
|
823
|
+
return { values: [] };
|
|
824
|
+
const targetElement = makeDeepCopy(element);
|
|
825
|
+
const attributes = accessor.split(".");
|
|
826
|
+
const values = [];
|
|
827
|
+
let value;
|
|
828
|
+
processKeys({ targetElement, attributes });
|
|
829
|
+
const result = { value };
|
|
830
|
+
if (values.length)
|
|
831
|
+
result.values = values;
|
|
832
|
+
return result;
|
|
833
|
+
function processKeys({
|
|
834
|
+
targetElement: targetElement2,
|
|
835
|
+
attributes: attributes2 = [],
|
|
836
|
+
significantCharacters
|
|
837
|
+
}) {
|
|
838
|
+
for (const [index, attribute] of attributes2.entries()) {
|
|
839
|
+
if (targetElement2?.[attribute]) {
|
|
840
|
+
const remainingKeys = attributes2.slice(index + 1);
|
|
841
|
+
if (!remainingKeys.length) {
|
|
842
|
+
if (!value)
|
|
843
|
+
value = targetElement2[attribute];
|
|
844
|
+
if (!values.includes(targetElement2[attribute])) {
|
|
845
|
+
values.push(targetElement2[attribute]);
|
|
846
|
+
}
|
|
847
|
+
} else if (Array.isArray(targetElement2[attribute])) {
|
|
848
|
+
const values2 = targetElement2[attribute];
|
|
849
|
+
values2.forEach(
|
|
850
|
+
(nestedTarget) => processKeys({
|
|
851
|
+
targetElement: nestedTarget,
|
|
852
|
+
attributes: remainingKeys
|
|
853
|
+
})
|
|
854
|
+
);
|
|
855
|
+
} else {
|
|
856
|
+
targetElement2 = targetElement2[attribute];
|
|
857
|
+
checkValue({ targetElement: targetElement2, index });
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
function checkValue({ targetElement: targetElement3, index }) {
|
|
862
|
+
if (targetElement3 && index === attributes2.length - 1 && ["string", "number"].includes(typeof targetElement3)) {
|
|
863
|
+
const extractedValue = significantCharacters ? targetElement3.slice(0, significantCharacters) : targetElement3;
|
|
864
|
+
if (value) {
|
|
865
|
+
if (!values.includes(extractedValue)) {
|
|
866
|
+
values.push(extractedValue);
|
|
867
|
+
}
|
|
868
|
+
} else {
|
|
869
|
+
value = extractedValue;
|
|
870
|
+
values.push(extractedValue);
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
function isObject(obj) {
|
|
878
|
+
return typeof obj === "object";
|
|
879
|
+
}
|
|
880
|
+
const extractAttributes = (accessor) => (element) => !accessor || typeof element !== "object" ? void 0 : Array.isArray(accessor) && accessor.map((a) => ({
|
|
881
|
+
[a]: getAccessorValue({ element, accessor: a })?.value
|
|
882
|
+
})) || typeof accessor === "object" && Object.keys(accessor).map((key) => ({
|
|
883
|
+
[key]: getAccessorValue({ element, accessor: key })?.value
|
|
884
|
+
})) || (typeof accessor === "string" && getAccessorValue({ element, accessor }))?.value;
|
|
885
|
+
function definedAttributes(obj, ignoreFalse, ignoreEmptyArrays, shallow) {
|
|
886
|
+
if (typeof obj !== "object" || obj === null)
|
|
887
|
+
return obj;
|
|
888
|
+
const deepCopy = deepCopyEnabled();
|
|
889
|
+
if (!deepCopy?.enabled)
|
|
890
|
+
shallow = true;
|
|
891
|
+
const ignoreValues = ["", void 0, null];
|
|
892
|
+
if (ignoreFalse)
|
|
893
|
+
ignoreValues.push(false);
|
|
894
|
+
const definedKeys = Object.keys(obj).filter(
|
|
895
|
+
(key) => !ignoreValues.includes(obj[key]) && (!ignoreEmptyArrays || (Array.isArray(obj[key]) ? obj[key].length : true))
|
|
896
|
+
);
|
|
897
|
+
return Object.assign(
|
|
898
|
+
{},
|
|
899
|
+
...definedKeys.map((key) => {
|
|
900
|
+
return Array.isArray(obj[key]) ? {
|
|
901
|
+
[key]: shallow ? obj[key] : obj[key].map((m) => definedAttributes(m))
|
|
902
|
+
} : { [key]: shallow ? obj[key] : definedAttributes(obj[key]) };
|
|
903
|
+
})
|
|
904
|
+
);
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
function attributeFilter(params) {
|
|
908
|
+
if (params === null)
|
|
909
|
+
return {};
|
|
910
|
+
const { source, template } = params || {};
|
|
911
|
+
if (!template)
|
|
912
|
+
return source;
|
|
913
|
+
const target = {};
|
|
914
|
+
attributeCopy(source, template, target);
|
|
915
|
+
return target;
|
|
916
|
+
function attributeCopy(valuesObject, templateObject, outputObject) {
|
|
917
|
+
if (!valuesObject || !templateObject)
|
|
918
|
+
return void 0;
|
|
919
|
+
const vKeys = Object.keys(valuesObject);
|
|
920
|
+
const oKeys = Object.keys(templateObject);
|
|
921
|
+
const orMap = Object.assign(
|
|
922
|
+
{},
|
|
923
|
+
...oKeys.filter((key) => key.indexOf("||")).map((key) => key.split("||").map((or) => ({ [or]: key }))).flat()
|
|
924
|
+
);
|
|
925
|
+
const allKeys = oKeys.concat(...Object.keys(orMap));
|
|
926
|
+
const wildcard = allKeys.includes("*");
|
|
927
|
+
for (const vKey of vKeys) {
|
|
928
|
+
if (allKeys.indexOf(vKey) >= 0 || wildcard) {
|
|
929
|
+
const templateKey = orMap[vKey] || vKey;
|
|
930
|
+
const tobj = templateObject[templateKey] || wildcard;
|
|
931
|
+
const vobj = valuesObject[vKey];
|
|
932
|
+
if (typeof tobj === "object" && typeof vobj !== "function" && !Array.isArray(tobj)) {
|
|
933
|
+
if (Array.isArray(vobj)) {
|
|
934
|
+
const mappedElements = vobj.map((arrayMember) => {
|
|
935
|
+
const target2 = {};
|
|
936
|
+
const result = attributeCopy(arrayMember, tobj, target2);
|
|
937
|
+
return result !== false ? target2 : void 0;
|
|
938
|
+
}).filter(Boolean);
|
|
939
|
+
outputObject[vKey] = mappedElements;
|
|
940
|
+
} else if (vobj) {
|
|
941
|
+
outputObject[vKey] = {};
|
|
942
|
+
attributeCopy(vobj, tobj, outputObject[vKey]);
|
|
943
|
+
}
|
|
944
|
+
} else {
|
|
945
|
+
const value = valuesObject[vKey];
|
|
946
|
+
const exclude = Array.isArray(tobj) && !tobj.includes(value);
|
|
947
|
+
if (exclude)
|
|
948
|
+
return false;
|
|
949
|
+
if (templateObject[vKey] || wildcard && templateObject[vKey] !== false) {
|
|
950
|
+
outputObject[vKey] = value;
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
return void 0;
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
|
|
908
959
|
function numericSort(a, b) {
|
|
909
960
|
return a - b;
|
|
910
961
|
}
|
|
@@ -3217,7 +3268,8 @@ function getCollectionPositionMatchUps({ matchUps }) {
|
|
|
3217
3268
|
|
|
3218
3269
|
const add = (a, b) => (a || 0) + (b || 0);
|
|
3219
3270
|
function getBand(spread, bandProfiles) {
|
|
3220
|
-
|
|
3271
|
+
const spreadValue = Array.isArray(spread) ? spread[0] : spread;
|
|
3272
|
+
return isNaN(spreadValue) && WALKOVER || spreadValue <= bandProfiles[DECISIVE] && DECISIVE || spreadValue <= bandProfiles[ROUTINE] && ROUTINE || COMPETITIVE;
|
|
3221
3273
|
}
|
|
3222
3274
|
function getScoreComponents({ score }) {
|
|
3223
3275
|
const sets = score?.sets || [];
|
|
@@ -3287,7 +3339,8 @@ function getMatchUpCompetitiveProfile({
|
|
|
3287
3339
|
const scoreComponents = getScoreComponents({ score });
|
|
3288
3340
|
const spread = pctSpread([scoreComponents]);
|
|
3289
3341
|
const competitiveness = getBand(spread, bandProfiles);
|
|
3290
|
-
|
|
3342
|
+
const pctSpreadValue = Array.isArray(spread) ? spread[0] : spread;
|
|
3343
|
+
return { ...SUCCESS, competitiveness, pctSpread: pctSpreadValue };
|
|
3291
3344
|
}
|
|
3292
3345
|
|
|
3293
3346
|
function findMatchupFormatAverageTimes(params) {
|
|
@@ -5564,12 +5617,15 @@ function isAdHoc({ drawDefinition, structure }) {
|
|
|
5564
5617
|
const hasDrawPosition = matchUps?.find(
|
|
5565
5618
|
(matchUp) => matchUp?.drawPositions?.length
|
|
5566
5619
|
);
|
|
5567
|
-
return !structure?.structures && !(drawDefinition?.drawType && drawDefinition.drawType !== AD_HOC) && !hasRoundPosition && !hasDrawPosition;
|
|
5620
|
+
return !structure?.structures && structure?.stage !== VOLUNTARY_CONSOLATION && !(drawDefinition?.drawType && drawDefinition.drawType !== AD_HOC) && !hasRoundPosition && !hasDrawPosition;
|
|
5568
5621
|
}
|
|
5569
5622
|
|
|
5570
5623
|
const POLICY_ROUND_NAMING_DEFAULT = {
|
|
5571
5624
|
[POLICY_TYPE_ROUND_NAMING]: {
|
|
5572
5625
|
policyName: "Round Naming Default",
|
|
5626
|
+
namingConventions: {
|
|
5627
|
+
round: "Round"
|
|
5628
|
+
},
|
|
5573
5629
|
abbreviatedRoundNamingMap: {
|
|
5574
5630
|
// key is matchUpsCount for the round
|
|
5575
5631
|
1: "F",
|
|
@@ -5609,6 +5665,9 @@ function getRoundContextProfile({
|
|
|
5609
5665
|
const roundNamingMap = roundNamingPolicy?.roundNamingMap || defaultRoundNamingPolicy.roundNamingMap || {};
|
|
5610
5666
|
const abbreviatedRoundNamingMap = roundNamingPolicy?.abbreviatedRoundNamingMap || defaultRoundNamingPolicy.abbreviatedRoundNamingMap || {};
|
|
5611
5667
|
const roundNamePrefix = roundNamingPolicy?.affixes || defaultRoundNamingPolicy.affixes;
|
|
5668
|
+
const roundNumberAffix = roundNamePrefix.roundNumber || defaultRoundNamingPolicy.affixes.roundNumber;
|
|
5669
|
+
const namingConventions = roundNamingPolicy?.namingConventions || defaultRoundNamingPolicy.namingConventions;
|
|
5670
|
+
const roundNameFallback = namingConventions.round;
|
|
5612
5671
|
const stageInitial = stage && stage !== MAIN && stage[0];
|
|
5613
5672
|
const stageConstants = roundNamingPolicy?.stageConstants;
|
|
5614
5673
|
const stageConstant = stage && stageConstants?.[stage] || stageInitial;
|
|
@@ -5617,8 +5676,8 @@ function getRoundContextProfile({
|
|
|
5617
5676
|
Object.assign(
|
|
5618
5677
|
roundNamingProfile,
|
|
5619
5678
|
...roundProfileKeys.map((key) => {
|
|
5620
|
-
const roundName =
|
|
5621
|
-
const abbreviatedRoundName =
|
|
5679
|
+
const roundName = `${roundNameFallback} ${key}`;
|
|
5680
|
+
const abbreviatedRoundName = `${roundNumberAffix}${key}`;
|
|
5622
5681
|
return { [key]: { roundName, abbreviatedRoundName } };
|
|
5623
5682
|
})
|
|
5624
5683
|
);
|
|
@@ -16537,8 +16596,8 @@ function modifyMatchUpFormatTiming({
|
|
|
16537
16596
|
recoveryTimes
|
|
16538
16597
|
});
|
|
16539
16598
|
addTournamentExtension({
|
|
16540
|
-
|
|
16541
|
-
|
|
16599
|
+
extension: { name, value },
|
|
16600
|
+
tournamentRecord
|
|
16542
16601
|
});
|
|
16543
16602
|
}
|
|
16544
16603
|
return { ...SUCCESS };
|