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/query.mjs
CHANGED
|
@@ -499,93 +499,6 @@ function getTournamentId() {
|
|
|
499
499
|
return _globalStateProvider.getTournamentId();
|
|
500
500
|
}
|
|
501
501
|
|
|
502
|
-
function isObject(obj) {
|
|
503
|
-
return typeof obj === "object";
|
|
504
|
-
}
|
|
505
|
-
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);
|
|
506
|
-
function getAttr(o, attr) {
|
|
507
|
-
const attrs = attr.split(".");
|
|
508
|
-
for (const a of attrs) {
|
|
509
|
-
o = o?.[a];
|
|
510
|
-
if (!o)
|
|
511
|
-
return;
|
|
512
|
-
}
|
|
513
|
-
return o;
|
|
514
|
-
}
|
|
515
|
-
function definedAttributes(obj, ignoreFalse, ignoreEmptyArrays, shallow) {
|
|
516
|
-
if (typeof obj !== "object" || obj === null)
|
|
517
|
-
return obj;
|
|
518
|
-
const deepCopy = deepCopyEnabled();
|
|
519
|
-
if (!deepCopy?.enabled)
|
|
520
|
-
shallow = true;
|
|
521
|
-
const ignoreValues = ["", void 0, null];
|
|
522
|
-
if (ignoreFalse)
|
|
523
|
-
ignoreValues.push(false);
|
|
524
|
-
const definedKeys = Object.keys(obj).filter(
|
|
525
|
-
(key) => !ignoreValues.includes(obj[key]) && (!ignoreEmptyArrays || (Array.isArray(obj[key]) ? obj[key].length : true))
|
|
526
|
-
);
|
|
527
|
-
return Object.assign(
|
|
528
|
-
{},
|
|
529
|
-
...definedKeys.map((key) => {
|
|
530
|
-
return Array.isArray(obj[key]) ? {
|
|
531
|
-
[key]: shallow ? obj[key] : obj[key].map((m) => definedAttributes(m))
|
|
532
|
-
} : { [key]: shallow ? obj[key] : definedAttributes(obj[key]) };
|
|
533
|
-
})
|
|
534
|
-
);
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
function attributeFilter(params) {
|
|
538
|
-
if (params === null)
|
|
539
|
-
return {};
|
|
540
|
-
const { source, template } = params || {};
|
|
541
|
-
if (!template)
|
|
542
|
-
return source;
|
|
543
|
-
const target = {};
|
|
544
|
-
attributeCopy(source, template, target);
|
|
545
|
-
return target;
|
|
546
|
-
function attributeCopy(valuesObject, templateObject, outputObject) {
|
|
547
|
-
if (!valuesObject || !templateObject)
|
|
548
|
-
return void 0;
|
|
549
|
-
const vKeys = Object.keys(valuesObject);
|
|
550
|
-
const oKeys = Object.keys(templateObject);
|
|
551
|
-
const orMap = Object.assign(
|
|
552
|
-
{},
|
|
553
|
-
...oKeys.filter((key) => key.indexOf("||")).map((key) => key.split("||").map((or) => ({ [or]: key }))).flat()
|
|
554
|
-
);
|
|
555
|
-
const allKeys = oKeys.concat(...Object.keys(orMap));
|
|
556
|
-
const wildcard = allKeys.includes("*");
|
|
557
|
-
for (const vKey of vKeys) {
|
|
558
|
-
if (allKeys.indexOf(vKey) >= 0 || wildcard) {
|
|
559
|
-
const templateKey = orMap[vKey] || vKey;
|
|
560
|
-
const tobj = templateObject[templateKey] || wildcard;
|
|
561
|
-
const vobj = valuesObject[vKey];
|
|
562
|
-
if (typeof tobj === "object" && typeof vobj !== "function" && !Array.isArray(tobj)) {
|
|
563
|
-
if (Array.isArray(vobj)) {
|
|
564
|
-
const mappedElements = vobj.map((arrayMember) => {
|
|
565
|
-
const target2 = {};
|
|
566
|
-
const result = attributeCopy(arrayMember, tobj, target2);
|
|
567
|
-
return result !== false ? target2 : void 0;
|
|
568
|
-
}).filter(Boolean);
|
|
569
|
-
outputObject[vKey] = mappedElements;
|
|
570
|
-
} else if (vobj) {
|
|
571
|
-
outputObject[vKey] = {};
|
|
572
|
-
attributeCopy(vobj, tobj, outputObject[vKey]);
|
|
573
|
-
}
|
|
574
|
-
} else {
|
|
575
|
-
const value = valuesObject[vKey];
|
|
576
|
-
const exclude = Array.isArray(tobj) && !tobj.includes(value);
|
|
577
|
-
if (exclude)
|
|
578
|
-
return false;
|
|
579
|
-
if (templateObject[vKey] || wildcard && templateObject[vKey] !== false) {
|
|
580
|
-
outputObject[vKey] = value;
|
|
581
|
-
}
|
|
582
|
-
}
|
|
583
|
-
}
|
|
584
|
-
}
|
|
585
|
-
return void 0;
|
|
586
|
-
}
|
|
587
|
-
}
|
|
588
|
-
|
|
589
502
|
const validDateString = /^[\d]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][\d]|3[0-1])$/;
|
|
590
503
|
const validTimeString = /^((0[\d]|1[\d]|2[0-3]):[0-5][\d](:[0-5][\d])?)([.,][0-9]{3})?$/;
|
|
591
504
|
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?$/;
|
|
@@ -772,6 +685,144 @@ function extensionsToAttributes(extensions) {
|
|
|
772
685
|
}).filter(Boolean);
|
|
773
686
|
}
|
|
774
687
|
|
|
688
|
+
function getAccessorValue({ element, accessor }) {
|
|
689
|
+
if (typeof accessor !== "string")
|
|
690
|
+
return { values: [] };
|
|
691
|
+
const targetElement = makeDeepCopy(element);
|
|
692
|
+
const attributes = accessor.split(".");
|
|
693
|
+
const values = [];
|
|
694
|
+
let value;
|
|
695
|
+
processKeys({ targetElement, attributes });
|
|
696
|
+
const result = { value };
|
|
697
|
+
if (values.length)
|
|
698
|
+
result.values = values;
|
|
699
|
+
return result;
|
|
700
|
+
function processKeys({
|
|
701
|
+
targetElement: targetElement2,
|
|
702
|
+
attributes: attributes2 = [],
|
|
703
|
+
significantCharacters
|
|
704
|
+
}) {
|
|
705
|
+
for (const [index, attribute] of attributes2.entries()) {
|
|
706
|
+
if (targetElement2?.[attribute]) {
|
|
707
|
+
const remainingKeys = attributes2.slice(index + 1);
|
|
708
|
+
if (!remainingKeys.length) {
|
|
709
|
+
if (!value)
|
|
710
|
+
value = targetElement2[attribute];
|
|
711
|
+
if (!values.includes(targetElement2[attribute])) {
|
|
712
|
+
values.push(targetElement2[attribute]);
|
|
713
|
+
}
|
|
714
|
+
} else if (Array.isArray(targetElement2[attribute])) {
|
|
715
|
+
const values2 = targetElement2[attribute];
|
|
716
|
+
values2.forEach(
|
|
717
|
+
(nestedTarget) => processKeys({
|
|
718
|
+
targetElement: nestedTarget,
|
|
719
|
+
attributes: remainingKeys
|
|
720
|
+
})
|
|
721
|
+
);
|
|
722
|
+
} else {
|
|
723
|
+
targetElement2 = targetElement2[attribute];
|
|
724
|
+
checkValue({ targetElement: targetElement2, index });
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
function checkValue({ targetElement: targetElement3, index }) {
|
|
729
|
+
if (targetElement3 && index === attributes2.length - 1 && ["string", "number"].includes(typeof targetElement3)) {
|
|
730
|
+
const extractedValue = significantCharacters ? targetElement3.slice(0, significantCharacters) : targetElement3;
|
|
731
|
+
if (value) {
|
|
732
|
+
if (!values.includes(extractedValue)) {
|
|
733
|
+
values.push(extractedValue);
|
|
734
|
+
}
|
|
735
|
+
} else {
|
|
736
|
+
value = extractedValue;
|
|
737
|
+
values.push(extractedValue);
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
function isObject(obj) {
|
|
745
|
+
return typeof obj === "object";
|
|
746
|
+
}
|
|
747
|
+
const extractAttributes = (accessor) => (element) => !accessor || typeof element !== "object" ? void 0 : Array.isArray(accessor) && accessor.map((a) => ({
|
|
748
|
+
[a]: getAccessorValue({ element, accessor: a })?.value
|
|
749
|
+
})) || typeof accessor === "object" && Object.keys(accessor).map((key) => ({
|
|
750
|
+
[key]: getAccessorValue({ element, accessor: key })?.value
|
|
751
|
+
})) || (typeof accessor === "string" && getAccessorValue({ element, accessor }))?.value;
|
|
752
|
+
function definedAttributes(obj, ignoreFalse, ignoreEmptyArrays, shallow) {
|
|
753
|
+
if (typeof obj !== "object" || obj === null)
|
|
754
|
+
return obj;
|
|
755
|
+
const deepCopy = deepCopyEnabled();
|
|
756
|
+
if (!deepCopy?.enabled)
|
|
757
|
+
shallow = true;
|
|
758
|
+
const ignoreValues = ["", void 0, null];
|
|
759
|
+
if (ignoreFalse)
|
|
760
|
+
ignoreValues.push(false);
|
|
761
|
+
const definedKeys = Object.keys(obj).filter(
|
|
762
|
+
(key) => !ignoreValues.includes(obj[key]) && (!ignoreEmptyArrays || (Array.isArray(obj[key]) ? obj[key].length : true))
|
|
763
|
+
);
|
|
764
|
+
return Object.assign(
|
|
765
|
+
{},
|
|
766
|
+
...definedKeys.map((key) => {
|
|
767
|
+
return Array.isArray(obj[key]) ? {
|
|
768
|
+
[key]: shallow ? obj[key] : obj[key].map((m) => definedAttributes(m))
|
|
769
|
+
} : { [key]: shallow ? obj[key] : definedAttributes(obj[key]) };
|
|
770
|
+
})
|
|
771
|
+
);
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
function attributeFilter(params) {
|
|
775
|
+
if (params === null)
|
|
776
|
+
return {};
|
|
777
|
+
const { source, template } = params || {};
|
|
778
|
+
if (!template)
|
|
779
|
+
return source;
|
|
780
|
+
const target = {};
|
|
781
|
+
attributeCopy(source, template, target);
|
|
782
|
+
return target;
|
|
783
|
+
function attributeCopy(valuesObject, templateObject, outputObject) {
|
|
784
|
+
if (!valuesObject || !templateObject)
|
|
785
|
+
return void 0;
|
|
786
|
+
const vKeys = Object.keys(valuesObject);
|
|
787
|
+
const oKeys = Object.keys(templateObject);
|
|
788
|
+
const orMap = Object.assign(
|
|
789
|
+
{},
|
|
790
|
+
...oKeys.filter((key) => key.indexOf("||")).map((key) => key.split("||").map((or) => ({ [or]: key }))).flat()
|
|
791
|
+
);
|
|
792
|
+
const allKeys = oKeys.concat(...Object.keys(orMap));
|
|
793
|
+
const wildcard = allKeys.includes("*");
|
|
794
|
+
for (const vKey of vKeys) {
|
|
795
|
+
if (allKeys.indexOf(vKey) >= 0 || wildcard) {
|
|
796
|
+
const templateKey = orMap[vKey] || vKey;
|
|
797
|
+
const tobj = templateObject[templateKey] || wildcard;
|
|
798
|
+
const vobj = valuesObject[vKey];
|
|
799
|
+
if (typeof tobj === "object" && typeof vobj !== "function" && !Array.isArray(tobj)) {
|
|
800
|
+
if (Array.isArray(vobj)) {
|
|
801
|
+
const mappedElements = vobj.map((arrayMember) => {
|
|
802
|
+
const target2 = {};
|
|
803
|
+
const result = attributeCopy(arrayMember, tobj, target2);
|
|
804
|
+
return result !== false ? target2 : void 0;
|
|
805
|
+
}).filter(Boolean);
|
|
806
|
+
outputObject[vKey] = mappedElements;
|
|
807
|
+
} else if (vobj) {
|
|
808
|
+
outputObject[vKey] = {};
|
|
809
|
+
attributeCopy(vobj, tobj, outputObject[vKey]);
|
|
810
|
+
}
|
|
811
|
+
} else {
|
|
812
|
+
const value = valuesObject[vKey];
|
|
813
|
+
const exclude = Array.isArray(tobj) && !tobj.includes(value);
|
|
814
|
+
if (exclude)
|
|
815
|
+
return false;
|
|
816
|
+
if (templateObject[vKey] || wildcard && templateObject[vKey] !== false) {
|
|
817
|
+
outputObject[vKey] = value;
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
return void 0;
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
|
|
775
826
|
function numericSort(a, b) {
|
|
776
827
|
return a - b;
|
|
777
828
|
}
|
|
@@ -4891,7 +4942,8 @@ function resolveTieFormat({
|
|
|
4891
4942
|
|
|
4892
4943
|
const add = (a, b) => (a || 0) + (b || 0);
|
|
4893
4944
|
function getBand(spread, bandProfiles) {
|
|
4894
|
-
|
|
4945
|
+
const spreadValue = Array.isArray(spread) ? spread[0] : spread;
|
|
4946
|
+
return isNaN(spreadValue) && WALKOVER || spreadValue <= bandProfiles[DECISIVE] && DECISIVE || spreadValue <= bandProfiles[ROUTINE] && ROUTINE || COMPETITIVE;
|
|
4895
4947
|
}
|
|
4896
4948
|
function getScoreComponents({ score }) {
|
|
4897
4949
|
const sets = score?.sets || [];
|
|
@@ -4943,7 +4995,8 @@ function getMatchUpCompetitiveProfile({
|
|
|
4943
4995
|
const scoreComponents = getScoreComponents({ score });
|
|
4944
4996
|
const spread = pctSpread([scoreComponents]);
|
|
4945
4997
|
const competitiveness = getBand(spread, bandProfiles);
|
|
4946
|
-
|
|
4998
|
+
const pctSpreadValue = Array.isArray(spread) ? spread[0] : spread;
|
|
4999
|
+
return { ...SUCCESS, competitiveness, pctSpread: pctSpreadValue };
|
|
4947
5000
|
}
|
|
4948
5001
|
|
|
4949
5002
|
function findMatchupFormatAverageTimes(params) {
|
|
@@ -6765,12 +6818,15 @@ function isAdHoc({ drawDefinition, structure }) {
|
|
|
6765
6818
|
const hasDrawPosition = matchUps?.find(
|
|
6766
6819
|
(matchUp) => matchUp?.drawPositions?.length
|
|
6767
6820
|
);
|
|
6768
|
-
return !structure?.structures && !(drawDefinition?.drawType && drawDefinition.drawType !== AD_HOC) && !hasRoundPosition && !hasDrawPosition;
|
|
6821
|
+
return !structure?.structures && structure?.stage !== VOLUNTARY_CONSOLATION && !(drawDefinition?.drawType && drawDefinition.drawType !== AD_HOC) && !hasRoundPosition && !hasDrawPosition;
|
|
6769
6822
|
}
|
|
6770
6823
|
|
|
6771
6824
|
const POLICY_ROUND_NAMING_DEFAULT = {
|
|
6772
6825
|
[POLICY_TYPE_ROUND_NAMING]: {
|
|
6773
6826
|
policyName: "Round Naming Default",
|
|
6827
|
+
namingConventions: {
|
|
6828
|
+
round: "Round"
|
|
6829
|
+
},
|
|
6774
6830
|
abbreviatedRoundNamingMap: {
|
|
6775
6831
|
// key is matchUpsCount for the round
|
|
6776
6832
|
1: "F",
|
|
@@ -6810,6 +6866,9 @@ function getRoundContextProfile({
|
|
|
6810
6866
|
const roundNamingMap = roundNamingPolicy?.roundNamingMap || defaultRoundNamingPolicy.roundNamingMap || {};
|
|
6811
6867
|
const abbreviatedRoundNamingMap = roundNamingPolicy?.abbreviatedRoundNamingMap || defaultRoundNamingPolicy.abbreviatedRoundNamingMap || {};
|
|
6812
6868
|
const roundNamePrefix = roundNamingPolicy?.affixes || defaultRoundNamingPolicy.affixes;
|
|
6869
|
+
const roundNumberAffix = roundNamePrefix.roundNumber || defaultRoundNamingPolicy.affixes.roundNumber;
|
|
6870
|
+
const namingConventions = roundNamingPolicy?.namingConventions || defaultRoundNamingPolicy.namingConventions;
|
|
6871
|
+
const roundNameFallback = namingConventions.round;
|
|
6813
6872
|
const stageInitial = stage && stage !== MAIN && stage[0];
|
|
6814
6873
|
const stageConstants = roundNamingPolicy?.stageConstants;
|
|
6815
6874
|
const stageConstant = stage && stageConstants?.[stage] || stageInitial;
|
|
@@ -6818,8 +6877,8 @@ function getRoundContextProfile({
|
|
|
6818
6877
|
Object.assign(
|
|
6819
6878
|
roundNamingProfile,
|
|
6820
6879
|
...roundProfileKeys.map((key) => {
|
|
6821
|
-
const roundName =
|
|
6822
|
-
const abbreviatedRoundName =
|
|
6880
|
+
const roundName = `${roundNameFallback} ${key}`;
|
|
6881
|
+
const abbreviatedRoundName = `${roundNumberAffix}${key}`;
|
|
6823
6882
|
return { [key]: { roundName, abbreviatedRoundName } };
|
|
6824
6883
|
})
|
|
6825
6884
|
);
|
|
@@ -10666,56 +10725,6 @@ function getCompetitionPublishedDrawIds({
|
|
|
10666
10725
|
return { drawIds };
|
|
10667
10726
|
}
|
|
10668
10727
|
|
|
10669
|
-
function getAccessorValue({ element, accessor }) {
|
|
10670
|
-
if (typeof accessor !== "string")
|
|
10671
|
-
return { values: [] };
|
|
10672
|
-
const targetElement = makeDeepCopy(element);
|
|
10673
|
-
const attributes = accessor.split(".");
|
|
10674
|
-
const values = [];
|
|
10675
|
-
let value;
|
|
10676
|
-
processKeys({ targetElement, attributes });
|
|
10677
|
-
const result = { value };
|
|
10678
|
-
if (values.length)
|
|
10679
|
-
result.values = values;
|
|
10680
|
-
return result;
|
|
10681
|
-
function processKeys({
|
|
10682
|
-
targetElement: targetElement2,
|
|
10683
|
-
attributes: attributes2 = [],
|
|
10684
|
-
significantCharacters
|
|
10685
|
-
}) {
|
|
10686
|
-
for (const [index, attribute] of attributes2.entries()) {
|
|
10687
|
-
if (targetElement2?.[attribute]) {
|
|
10688
|
-
if (Array.isArray(targetElement2[attribute])) {
|
|
10689
|
-
const values2 = targetElement2[attribute];
|
|
10690
|
-
const remainingKeys = attributes2.slice(index);
|
|
10691
|
-
values2.forEach(
|
|
10692
|
-
(nestedTarget) => processKeys({
|
|
10693
|
-
targetElement: nestedTarget,
|
|
10694
|
-
attributes: remainingKeys
|
|
10695
|
-
})
|
|
10696
|
-
);
|
|
10697
|
-
} else {
|
|
10698
|
-
targetElement2 = targetElement2[attribute];
|
|
10699
|
-
checkValue({ targetElement: targetElement2, index });
|
|
10700
|
-
}
|
|
10701
|
-
}
|
|
10702
|
-
}
|
|
10703
|
-
function checkValue({ targetElement: targetElement3, index }) {
|
|
10704
|
-
if (targetElement3 && index === attributes2.length - 1 && ["string", "number"].includes(typeof targetElement3)) {
|
|
10705
|
-
const extractedValue = significantCharacters ? targetElement3.slice(0, significantCharacters) : targetElement3;
|
|
10706
|
-
if (value) {
|
|
10707
|
-
if (!values.includes(extractedValue)) {
|
|
10708
|
-
values.push(extractedValue);
|
|
10709
|
-
}
|
|
10710
|
-
} else {
|
|
10711
|
-
value = extractedValue;
|
|
10712
|
-
values.push(extractedValue);
|
|
10713
|
-
}
|
|
10714
|
-
}
|
|
10715
|
-
}
|
|
10716
|
-
}
|
|
10717
|
-
}
|
|
10718
|
-
|
|
10719
10728
|
function filterParticipants({
|
|
10720
10729
|
participantFilters = {},
|
|
10721
10730
|
tournamentRecord,
|