tods-competition-factory 1.7.7 → 1.7.9

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.
@@ -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
  }
@@ -6767,7 +6818,7 @@ function isAdHoc({ drawDefinition, structure }) {
6767
6818
  const hasDrawPosition = matchUps?.find(
6768
6819
  (matchUp) => matchUp?.drawPositions?.length
6769
6820
  );
6770
- 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;
6771
6822
  }
6772
6823
 
6773
6824
  const POLICY_ROUND_NAMING_DEFAULT = {
@@ -10674,56 +10725,6 @@ function getCompetitionPublishedDrawIds({
10674
10725
  return { drawIds };
10675
10726
  }
10676
10727
 
10677
- function getAccessorValue({ element, accessor }) {
10678
- if (typeof accessor !== "string")
10679
- return { values: [] };
10680
- const targetElement = makeDeepCopy(element);
10681
- const attributes = accessor.split(".");
10682
- const values = [];
10683
- let value;
10684
- processKeys({ targetElement, attributes });
10685
- const result = { value };
10686
- if (values.length)
10687
- result.values = values;
10688
- return result;
10689
- function processKeys({
10690
- targetElement: targetElement2,
10691
- attributes: attributes2 = [],
10692
- significantCharacters
10693
- }) {
10694
- for (const [index, attribute] of attributes2.entries()) {
10695
- if (targetElement2?.[attribute]) {
10696
- if (Array.isArray(targetElement2[attribute])) {
10697
- const values2 = targetElement2[attribute];
10698
- const remainingKeys = attributes2.slice(index);
10699
- values2.forEach(
10700
- (nestedTarget) => processKeys({
10701
- targetElement: nestedTarget,
10702
- attributes: remainingKeys
10703
- })
10704
- );
10705
- } else {
10706
- targetElement2 = targetElement2[attribute];
10707
- checkValue({ targetElement: targetElement2, index });
10708
- }
10709
- }
10710
- }
10711
- function checkValue({ targetElement: targetElement3, index }) {
10712
- if (targetElement3 && index === attributes2.length - 1 && ["string", "number"].includes(typeof targetElement3)) {
10713
- const extractedValue = significantCharacters ? targetElement3.slice(0, significantCharacters) : targetElement3;
10714
- if (value) {
10715
- if (!values.includes(extractedValue)) {
10716
- values.push(extractedValue);
10717
- }
10718
- } else {
10719
- value = extractedValue;
10720
- values.push(extractedValue);
10721
- }
10722
- }
10723
- }
10724
- }
10725
- }
10726
-
10727
10728
  function filterParticipants({
10728
10729
  participantFilters = {},
10729
10730
  tournamentRecord,