tods-competition-factory 0.293.0 → 0.294.0

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.
@@ -249,7 +249,7 @@ const matchUpFormatCode = {
249
249
  };
250
250
 
251
251
  function factoryVersion() {
252
- return '0.293.0';
252
+ return '0.294.0';
253
253
  }
254
254
 
255
255
  function decorateResult({
@@ -2394,12 +2394,12 @@ function validateTieFormat({
2394
2394
  if (!valid) {
2395
2395
  return decorateResult({
2396
2396
  result: {
2397
- error: INVALID_TIE_FORMAT,
2398
- stack,
2399
2397
  context: {
2400
2398
  tieFormat,
2401
2399
  errors
2402
- }
2400
+ },
2401
+ error: INVALID_TIE_FORMAT,
2402
+ stack
2403
2403
  }
2404
2404
  });
2405
2405
  } else {
@@ -6431,7 +6431,7 @@ const matchUpFormats = {
6431
6431
  TIMED20
6432
6432
  };
6433
6433
 
6434
- var collectionDefinitions$f = [
6434
+ var collectionDefinitions$g = [
6435
6435
  {
6436
6436
  collectionName: "Doubles",
6437
6437
  matchUpCount: 3,
@@ -6447,17 +6447,17 @@ var collectionDefinitions$f = [
6447
6447
  matchUpValue: 1
6448
6448
  }
6449
6449
  ];
6450
- var tieFormatName$f = "COLLEGE_D3";
6451
- var winCriteria$f = {
6450
+ var tieFormatName$g = "COLLEGE_D3";
6451
+ var winCriteria$g = {
6452
6452
  valueGoal: 5
6453
6453
  };
6454
6454
  var COLLEGE_D3$1 = {
6455
- collectionDefinitions: collectionDefinitions$f,
6456
- tieFormatName: tieFormatName$f,
6457
- winCriteria: winCriteria$f
6455
+ collectionDefinitions: collectionDefinitions$g,
6456
+ tieFormatName: tieFormatName$g,
6457
+ winCriteria: winCriteria$g
6458
6458
  };
6459
6459
 
6460
- var collectionDefinitions$e = [
6460
+ var collectionDefinitions$f = [
6461
6461
  {
6462
6462
  collectionName: "Doubles",
6463
6463
  collectionValue: 1,
@@ -6473,17 +6473,17 @@ var collectionDefinitions$e = [
6473
6473
  matchUpValue: 1
6474
6474
  }
6475
6475
  ];
6476
- var tieFormatName$e = "COLLEGE_DEFAULT";
6477
- var winCriteria$e = {
6476
+ var tieFormatName$f = "COLLEGE_DEFAULT";
6477
+ var winCriteria$f = {
6478
6478
  valueGoal: 5
6479
6479
  };
6480
6480
  var COLLEGE_DEFAULT$1 = {
6481
- collectionDefinitions: collectionDefinitions$e,
6482
- tieFormatName: tieFormatName$e,
6483
- winCriteria: winCriteria$e
6481
+ collectionDefinitions: collectionDefinitions$f,
6482
+ tieFormatName: tieFormatName$f,
6483
+ winCriteria: winCriteria$f
6484
6484
  };
6485
6485
 
6486
- var collectionDefinitions$d = [
6486
+ var collectionDefinitions$e = [
6487
6487
  {
6488
6488
  collectionName: "Doubles",
6489
6489
  matchUpCount: 3,
@@ -6499,17 +6499,17 @@ var collectionDefinitions$d = [
6499
6499
  matchUpValue: 1
6500
6500
  }
6501
6501
  ];
6502
- var tieFormatName$d = "COLLEGE_JUCO";
6503
- var winCriteria$d = {
6502
+ var tieFormatName$e = "COLLEGE_JUCO";
6503
+ var winCriteria$e = {
6504
6504
  valueGoal: 5
6505
6505
  };
6506
6506
  var COLLEGE_JUCO$1 = {
6507
- collectionDefinitions: collectionDefinitions$d,
6508
- tieFormatName: tieFormatName$d,
6509
- winCriteria: winCriteria$d
6507
+ collectionDefinitions: collectionDefinitions$e,
6508
+ tieFormatName: tieFormatName$e,
6509
+ winCriteria: winCriteria$e
6510
6510
  };
6511
6511
 
6512
- var collectionDefinitions$c = [
6512
+ var collectionDefinitions$d = [
6513
6513
  {
6514
6514
  collectionName: "Doubles",
6515
6515
  matchUpCount: 1,
@@ -6525,17 +6525,17 @@ var collectionDefinitions$c = [
6525
6525
  matchUpValue: 1
6526
6526
  }
6527
6527
  ];
6528
- var tieFormatName$c = "DOMINANT_DUO";
6529
- var winCriteria$c = {
6528
+ var tieFormatName$d = "DOMINANT_DUO";
6529
+ var winCriteria$d = {
6530
6530
  valueGoal: 2
6531
6531
  };
6532
6532
  var DOMINANT_DUO_TIE_FORMAT = {
6533
- collectionDefinitions: collectionDefinitions$c,
6534
- tieFormatName: tieFormatName$c,
6535
- winCriteria: winCriteria$c
6533
+ collectionDefinitions: collectionDefinitions$d,
6534
+ tieFormatName: tieFormatName$d,
6535
+ winCriteria: winCriteria$d
6536
6536
  };
6537
6537
 
6538
- var collectionDefinitions$b = [
6538
+ var collectionDefinitions$c = [
6539
6539
  {
6540
6540
  collectionName: "Mixed Doubles",
6541
6541
  gender: "MIXED",
@@ -6561,17 +6561,17 @@ var collectionDefinitions$b = [
6561
6561
  matchUpValue: 1
6562
6562
  }
6563
6563
  ];
6564
- var tieFormatName$b = "DOMINANT_DUO_MIXED";
6565
- var winCriteria$b = {
6564
+ var tieFormatName$c = "DOMINANT_DUO_MIXED";
6565
+ var winCriteria$c = {
6566
6566
  valueGoal: 2
6567
6567
  };
6568
6568
  var DOMINANT_DUO_MIXED_TIE_FORMAT = {
6569
- collectionDefinitions: collectionDefinitions$b,
6570
- tieFormatName: tieFormatName$b,
6571
- winCriteria: winCriteria$b
6569
+ collectionDefinitions: collectionDefinitions$c,
6570
+ tieFormatName: tieFormatName$c,
6571
+ winCriteria: winCriteria$c
6572
6572
  };
6573
6573
 
6574
- var collectionDefinitions$a = [
6574
+ var collectionDefinitions$b = [
6575
6575
  {
6576
6576
  collectionGroupNumber: 1,
6577
6577
  matchUpType: "DOUBLES",
@@ -6629,18 +6629,18 @@ var collectionGroups$2 = [
6629
6629
  groupName: "Day 3"
6630
6630
  }
6631
6631
  ];
6632
- var tieFormatName$a = "LAVER_CUP";
6633
- var winCriteria$a = {
6632
+ var tieFormatName$b = "LAVER_CUP";
6633
+ var winCriteria$b = {
6634
6634
  valueGoal: 13
6635
6635
  };
6636
6636
  var LAVER_CUP_TIE_FORMAT = {
6637
- collectionDefinitions: collectionDefinitions$a,
6637
+ collectionDefinitions: collectionDefinitions$b,
6638
6638
  collectionGroups: collectionGroups$2,
6639
- tieFormatName: tieFormatName$a,
6640
- winCriteria: winCriteria$a
6639
+ tieFormatName: tieFormatName$b,
6640
+ winCriteria: winCriteria$b
6641
6641
  };
6642
6642
 
6643
- var collectionDefinitions$9 = [
6643
+ var collectionDefinitions$a = [
6644
6644
  {
6645
6645
  collectionName: "Round 1",
6646
6646
  matchUpCount: 3,
@@ -6663,19 +6663,19 @@ var collectionDefinitions$9 = [
6663
6663
  scoreValue: 1
6664
6664
  }
6665
6665
  ];
6666
- var tieFormatName$9 = "Doubles Shuffle";
6666
+ var tieFormatName$a = "Doubles Shuffle";
6667
6667
  var unrestrictedSelections = true;
6668
- var winCriteria$9 = {
6668
+ var winCriteria$a = {
6669
6669
  aggregateValue: true
6670
6670
  };
6671
6671
  var TEAM_AGGREGATION_TIE_FORMAT = {
6672
- collectionDefinitions: collectionDefinitions$9,
6673
- tieFormatName: tieFormatName$9,
6672
+ collectionDefinitions: collectionDefinitions$a,
6673
+ tieFormatName: tieFormatName$a,
6674
6674
  unrestrictedSelections: unrestrictedSelections,
6675
- winCriteria: winCriteria$9
6675
+ winCriteria: winCriteria$a
6676
6676
  };
6677
6677
 
6678
- var collectionDefinitions$8 = [
6678
+ var collectionDefinitions$9 = [
6679
6679
  {
6680
6680
  category: {
6681
6681
  ageCategoryCode: "14U"
@@ -6750,15 +6750,247 @@ var collectionGroups$1 = [
6750
6750
  }
6751
6751
  }
6752
6752
  ];
6753
- var tieFormatName$8 = "USTA_BREWER_CUP";
6754
- var winCriteria$8 = {
6753
+ var tieFormatName$9 = "USTA_BREWER_CUP";
6754
+ var winCriteria$9 = {
6755
6755
  valueGoal: 4
6756
6756
  };
6757
6757
  var USTA_BREWER_CUP_TIE_FORMAT = {
6758
- collectionDefinitions: collectionDefinitions$8,
6758
+ collectionDefinitions: collectionDefinitions$9,
6759
6759
  collectionGroups: collectionGroups$1,
6760
+ tieFormatName: tieFormatName$9,
6761
+ winCriteria: winCriteria$9
6762
+ };
6763
+
6764
+ var winCriteria$8 = {
6765
+ valueGoal: 23
6766
+ };
6767
+ var tieFormatName$8 = "USTA_OZAKI_CUP";
6768
+ var collectionDefinitions$8 = [
6769
+ {
6770
+ category: {
6771
+ ageCategoryCode: "18U"
6772
+ },
6773
+ matchUpFormat: "SET3-S:6/TB7-F:TB10",
6774
+ collectionName: "18U Boys Singles",
6775
+ matchUpType: "SINGLES",
6776
+ matchUpCount: 3,
6777
+ matchUpValue: 1,
6778
+ gender: "MALE"
6779
+ },
6780
+ {
6781
+ category: {
6782
+ ageCategoryCode: "18U"
6783
+ },
6784
+ matchUpFormat: "SET3-S:6/TB7-F:TB10",
6785
+ collectionName: "18U Girls Singles",
6786
+ matchUpType: "SINGLES",
6787
+ gender: "FEMALE",
6788
+ matchUpCount: 3,
6789
+ matchUpValue: 1
6790
+ },
6791
+ {
6792
+ category: {
6793
+ ageCategoryCode: "18U"
6794
+ },
6795
+ collectionName: "18U Boys Doubles",
6796
+ matchUpFormat: "SET1-S:8/TB8",
6797
+ matchUpType: "DOUBLES",
6798
+ matchUpCount: 1,
6799
+ matchUpValue: 1,
6800
+ gender: "MALE"
6801
+ },
6802
+ {
6803
+ category: {
6804
+ ageCategoryCode: "18U"
6805
+ },
6806
+ collectionName: "18U Girls Doubles",
6807
+ matchUpFormat: "SET1-S:8/TB8",
6808
+ matchUpType: "DOUBLES",
6809
+ gender: "FEMALE",
6810
+ matchUpCount: 1,
6811
+ matchUpValue: 1
6812
+ },
6813
+ {
6814
+ category: {
6815
+ ageCategoryCode: "18U"
6816
+ },
6817
+ collectionName: "18U Mixed Doubles",
6818
+ matchUpFormat: "SET1-S:8/TB8",
6819
+ matchUpType: "DOUBLES",
6820
+ gender: "MIXED",
6821
+ matchUpCount: 1,
6822
+ matchUpValue: 1
6823
+ },
6824
+ {
6825
+ category: {
6826
+ ageCategoryCode: "16U"
6827
+ },
6828
+ matchUpFormat: "SET3-S:6/TB7-F:TB10",
6829
+ collectionName: "16U Boys Singles",
6830
+ matchUpType: "SINGLES",
6831
+ matchUpCount: 3,
6832
+ matchUpValue: 1,
6833
+ gender: "MALE"
6834
+ },
6835
+ {
6836
+ category: {
6837
+ ageCategoryCode: "16U"
6838
+ },
6839
+ matchUpFormat: "SET3-S:6/TB7-F:TB10",
6840
+ collectionName: "16U Girls Singles",
6841
+ matchUpType: "SINGLES",
6842
+ gender: "FEMALE",
6843
+ matchUpCount: 3,
6844
+ matchUpValue: 1
6845
+ },
6846
+ {
6847
+ category: {
6848
+ ageCategoryCode: "16U"
6849
+ },
6850
+ collectionName: "16U Boys Doubles",
6851
+ matchUpFormat: "SET1-S:8/TB8",
6852
+ matchUpType: "DOUBLES",
6853
+ matchUpCount: 1,
6854
+ matchUpValue: 1,
6855
+ gender: "MALE"
6856
+ },
6857
+ {
6858
+ category: {
6859
+ ageCategoryCode: "16U"
6860
+ },
6861
+ collectionName: "16U Girls Doubles",
6862
+ matchUpFormat: "SET1-S:8/TB8",
6863
+ matchUpType: "DOUBLES",
6864
+ gender: "FEMALE",
6865
+ matchUpCount: 1,
6866
+ matchUpValue: 1
6867
+ },
6868
+ {
6869
+ category: {
6870
+ ageCategoryCode: "16U"
6871
+ },
6872
+ collectionName: "16U Mixed Doubles",
6873
+ matchUpFormat: "SET1-S:8/TB8",
6874
+ matchUpType: "DOUBLES",
6875
+ gender: "MIXED",
6876
+ matchUpCount: 1,
6877
+ matchUpValue: 1
6878
+ },
6879
+ {
6880
+ category: {
6881
+ ageCategoryCode: "14U"
6882
+ },
6883
+ matchUpFormat: "SET3-S:6/TB7-F:TB10",
6884
+ collectionName: "14U Boys Singles",
6885
+ matchUpType: "SINGLES",
6886
+ matchUpCount: 3,
6887
+ matchUpValue: 1,
6888
+ gender: "MALE"
6889
+ },
6890
+ {
6891
+ category: {
6892
+ ageCategoryCode: "14U"
6893
+ },
6894
+ matchUpFormat: "SET3-S:6/TB7-F:TB10",
6895
+ collectionName: "14U Girls Singles",
6896
+ matchUpType: "SINGLES",
6897
+ gender: "FEMALE",
6898
+ matchUpCount: 3,
6899
+ matchUpValue: 1
6900
+ },
6901
+ {
6902
+ category: {
6903
+ ageCategoryCode: "14U"
6904
+ },
6905
+ collectionName: "14U Boys Doubles",
6906
+ matchUpFormat: "SET1-S:8/TB8",
6907
+ matchUpType: "DOUBLES",
6908
+ matchUpCount: 1,
6909
+ matchUpValue: 1,
6910
+ gender: "MALE"
6911
+ },
6912
+ {
6913
+ category: {
6914
+ ageCategoryCode: "14U"
6915
+ },
6916
+ collectionName: "14U Girls Doubles",
6917
+ matchUpFormat: "SET1-S:8/TB8",
6918
+ matchUpType: "DOUBLES",
6919
+ gender: "FEMALE",
6920
+ matchUpCount: 1,
6921
+ matchUpValue: 1
6922
+ },
6923
+ {
6924
+ category: {
6925
+ ageCategoryCode: "14U"
6926
+ },
6927
+ collectionName: "14U Mixed Doubles",
6928
+ matchUpFormat: "SET1-S:8/TB8",
6929
+ matchUpType: "DOUBLES",
6930
+ gender: "MIXED",
6931
+ matchUpCount: 1,
6932
+ matchUpValue: 1
6933
+ },
6934
+ {
6935
+ category: {
6936
+ ageCategoryCode: "12U"
6937
+ },
6938
+ matchUpFormat: "SET3-S:6/TB7-F:TB10",
6939
+ collectionName: "12U Boys Singles",
6940
+ matchUpType: "SINGLES",
6941
+ matchUpCount: 3,
6942
+ matchUpValue: 1,
6943
+ gender: "MALE"
6944
+ },
6945
+ {
6946
+ category: {
6947
+ ageCategoryCode: "12U"
6948
+ },
6949
+ matchUpFormat: "SET3-S:6/TB7-F:TB10",
6950
+ collectionName: "12U Girls Singles",
6951
+ matchUpType: "SINGLES",
6952
+ gender: "FEMALE",
6953
+ matchUpCount: 3,
6954
+ matchUpValue: 1
6955
+ },
6956
+ {
6957
+ category: {
6958
+ ageCategoryCode: "12U"
6959
+ },
6960
+ collectionName: "12U Boys Doubles",
6961
+ matchUpFormat: "SET1-S:8/TB8",
6962
+ matchUpType: "DOUBLES",
6963
+ matchUpCount: 1,
6964
+ matchUpValue: 1,
6965
+ gender: "MALE"
6966
+ },
6967
+ {
6968
+ category: {
6969
+ ageCategoryCode: "12U"
6970
+ },
6971
+ collectionName: "12U Girls Doubles",
6972
+ matchUpFormat: "SET1-S:8/TB8",
6973
+ matchUpType: "DOUBLES",
6974
+ gender: "FEMALE",
6975
+ matchUpCount: 1,
6976
+ matchUpValue: 1
6977
+ },
6978
+ {
6979
+ category: {
6980
+ ageCategoryCode: "12U"
6981
+ },
6982
+ collectionName: "12U Mixed Doubles",
6983
+ matchUpFormat: "SET1-S:8/TB8",
6984
+ matchUpType: "DOUBLES",
6985
+ gender: "MIXED",
6986
+ matchUpCount: 1,
6987
+ matchUpValue: 1
6988
+ }
6989
+ ];
6990
+ var USTA_OZAKI_CUP_TIE_FORMAT = {
6991
+ winCriteria: winCriteria$8,
6760
6992
  tieFormatName: tieFormatName$8,
6761
- winCriteria: winCriteria$8
6993
+ collectionDefinitions: collectionDefinitions$8
6762
6994
  };
6763
6995
 
6764
6996
  var collectionDefinitions$7 = [
@@ -7161,6 +7393,7 @@ const tieFormats = {
7161
7393
  LAVER_CUP: LAVER_CUP_TIE_FORMAT,
7162
7394
  TEAM_DOUBLES_3_AGGREGATION: TEAM_AGGREGATION_TIE_FORMAT,
7163
7395
  USTA_BREWER_CUP: USTA_BREWER_CUP_TIE_FORMAT,
7396
+ USTA_OZAKI_CUP: USTA_OZAKI_CUP_TIE_FORMAT,
7164
7397
  USTA_COLLEGE: USTA_COLLEGE_TIE_FORMAT,
7165
7398
  USTA_GOLD_TEAM_CHALLENGE: USTA_GOLD_TEAM_CHALLENGE_FORMAT,
7166
7399
  USTA_INTERSECTIONAL: USTA_INTERSECTIONAL_TIE_FORMAT,
@@ -17460,6 +17693,7 @@ function addSchedulingProfileRound({
17460
17693
  };
17461
17694
  }
17462
17695
 
17696
+ const stack = 'addSchedulingProfileRound';
17463
17697
  const {
17464
17698
  extension
17465
17699
  } = findExtension$1({
@@ -17504,12 +17738,21 @@ function addSchedulingProfileRound({
17504
17738
 
17505
17739
  const excludeKeys = ['notBeforeTime'];
17506
17740
 
17507
- const hashRound = r => Object.keys(r).filter(key => !excludeKeys.includes(key)).sort().map(k => r[k]).join('|');
17741
+ const hashRound = r => Object.keys(r).filter(key => !excludeKeys.includes(key)).sort().map(k => {
17742
+ if (typeof r[k] === 'object') {
17743
+ return hashRound(r[k]);
17744
+ }
17745
+
17746
+ return r[k];
17747
+ }).flat().join('|');
17508
17748
 
17509
17749
  const roundExists = venueOnDate.rounds.find(existingRound => hashRound(existingRound) === hashRound(round));
17510
- if (roundExists) return {
17511
- error: EXISTING_ROUND
17512
- };
17750
+ if (roundExists) return decorateResult({
17751
+ result: {
17752
+ error: EXISTING_ROUND
17753
+ },
17754
+ stack
17755
+ });
17513
17756
  venueOnDate.rounds.push(round);
17514
17757
  const result = setSchedulingProfile$1({
17515
17758
  tournamentRecords,
@@ -31766,35 +32009,86 @@ function removeMatchUpCourtAssignment$1(params) {
31766
32009
  });
31767
32010
  }
31768
32011
 
32012
+ function getMatchUpDailyLimitsUpdate$1({
32013
+ tournamentRecords
32014
+ }) {
32015
+ return getExtensionUpdate({
32016
+ tournamentRecords,
32017
+ extensionName: SCHEDULE_LIMITS
32018
+ });
32019
+ }
32020
+
31769
32021
  const {
31770
32022
  stageOrder
31771
32023
  } = drawDefinitionConstants;
31772
32024
  function getProfileRounds({
31773
- tournamentRecords
32025
+ schedulingProfile,
32026
+ tournamentRecords,
32027
+ tournamentRecord,
32028
+ withRoundId
31774
32029
  }) {
31775
- const {
31776
- schedulingProfile,
31777
- error
31778
- } = getSchedulingProfile$1({
31779
- tournamentRecords
31780
- });
31781
- if (error) return {
31782
- error
32030
+ if (tournamentRecord && !tournamentRecords) {
32031
+ if (typeof tournamentRecord !== 'object') {
32032
+ return {
32033
+ error: INVALID_TOURNAMENT_RECORD
32034
+ };
32035
+ } else {
32036
+ tournamentRecords = {
32037
+ [tournamentRecord.tournamentId]: tournamentRecord
32038
+ };
32039
+ }
32040
+ }
32041
+
32042
+ if (schedulingProfile) {
32043
+ const profileValidity = validateSchedulingProfile({
32044
+ tournamentRecords,
32045
+ schedulingProfile
32046
+ });
32047
+ if (profileValidity.error) return profileValidity;
32048
+ }
32049
+
32050
+ if (!schedulingProfile) {
32051
+ const result = getSchedulingProfile$1({
32052
+ tournamentRecords
32053
+ });
32054
+ if (result.error) return result;
32055
+ schedulingProfile = result.schedulingProfile;
32056
+ }
32057
+
32058
+ if (!schedulingProfile) return {
32059
+ error: NOT_FOUND
31783
32060
  };
32061
+ const segmentedRounds = {};
31784
32062
  const profileRounds = schedulingProfile.map(({
31785
- venues
32063
+ venues,
32064
+ scheduleDate
31786
32065
  }) => venues.map(({
31787
32066
  rounds
31788
- }) => rounds.map(round => getRef(round)))).flat(Infinity);
32067
+ }) => rounds.map(round => {
32068
+ var _roundRef$roundSegmen;
32069
+
32070
+ const roundRef = getRoundId(round);
32071
+
32072
+ if ((_roundRef$roundSegmen = roundRef.roundSegment) !== null && _roundRef$roundSegmen !== void 0 && _roundRef$roundSegmen.segmentsCount) {
32073
+ segmentedRounds[roundRef.id] = roundRef.roundSegment.segmentsCount;
32074
+ }
32075
+
32076
+ return definedAttributes({
32077
+ id: withRoundId ? roundRef.id : undefined,
32078
+ scheduleDate,
32079
+ ...roundRef
32080
+ });
32081
+ }))).flat(Infinity);
31789
32082
  return {
31790
- profileRounds
32083
+ profileRounds,
32084
+ segmentedRounds
31791
32085
  };
31792
32086
  }
31793
32087
 
31794
- function getRef(obj) {
32088
+ function getRoundId(obj) {
31795
32089
  const {
31796
32090
  containerStructureId,
31797
- segmentNumber,
32091
+ roundSegment,
31798
32092
  isRoundRobin,
31799
32093
  tournamentId,
31800
32094
  roundNumber,
@@ -31804,15 +32098,15 @@ function getRef(obj) {
31804
32098
  } = obj;
31805
32099
  const relevantStructureId = isRoundRobin ? containerStructureId : structureId; // retain order
31806
32100
 
31807
- const ref = [tournamentId, // 1
32101
+ const id = [tournamentId, // 1
31808
32102
  eventId, // 2
31809
32103
  drawId, // 3
31810
32104
  relevantStructureId, // 4
31811
32105
  roundNumber // 5
31812
32106
  ].join('|');
31813
32107
  return definedAttributes({
31814
- ref,
31815
- segmentNumber,
32108
+ id,
32109
+ roundSegment,
31816
32110
  tournamentId,
31817
32111
  eventId,
31818
32112
  drawId,
@@ -31820,89 +32114,214 @@ function getRef(obj) {
31820
32114
  roundNumber
31821
32115
  });
31822
32116
  }
31823
- /*
31824
- export function roundIsScheduled({ matchUp, schedulingProfile }) {
31825
- const ref = getRef(matchUp).ref;
31826
- return !!schedulingProfile.find((profile) =>
31827
- profile.venues.find((venue) =>
31828
- venue.rounds.find((round) => {
31829
- const roundRef = getRef(round).ref;
31830
- if (roundRef === ref) {
31831
- if (!round.roundSegment) return true;
31832
- }
31833
- })
31834
- )
31835
- );
31836
- }
31837
- */
31838
32117
 
32118
+ function getRoundProfile(matchUps) {
32119
+ const matchUpsCount = matchUps.length;
32120
+ const byeCount = matchUps.filter(({
32121
+ sides
32122
+ }) => sides === null || sides === void 0 ? void 0 : sides.some(({
32123
+ bye
32124
+ }) => bye)).length || 0;
32125
+ const completedCount = matchUps.filter(({
32126
+ winningSide,
32127
+ matchUpStatus
32128
+ }) => winningSide || completedMatchUpStatuses.includes(matchUpStatus)).length || 0;
32129
+ const scheduledCount = matchUps.filter(({
32130
+ schedule
32131
+ }) => (schedule === null || schedule === void 0 ? void 0 : schedule.scheduledDate) && (schedule === null || schedule === void 0 ? void 0 : schedule.scheduledTime)).length || 0;
32132
+ const consideredCount = matchUpsCount - byeCount;
32133
+ const isComplete = consideredCount === completedCount;
32134
+ const unscheduledCount = consideredCount - scheduledCount;
32135
+ const incompleteCount = consideredCount - scheduledCount;
32136
+ const isScheduled = consideredCount === scheduledCount;
32137
+ return {
32138
+ unscheduledCount,
32139
+ incompleteCount,
32140
+ scheduledCount,
32141
+ completedCount,
32142
+ matchUpsCount,
32143
+ isScheduled,
32144
+ isComplete,
32145
+ byeCount
32146
+ };
32147
+ }
31839
32148
 
31840
32149
  function getRounds({
31841
- tournamentRecords
32150
+ excludeScheduleDateProfileRounds,
32151
+ excludeScheduledRounds,
32152
+ excludeCompletedRounds,
32153
+ inContextMatchUps,
32154
+ schedulingProfile,
32155
+ tournamentRecords,
32156
+ tournamentRecord,
32157
+ withSplitRounds,
32158
+ matchUpFilters,
32159
+ withRoundId,
32160
+ context
31842
32161
  }) {
31843
32162
  var _allCompetitionMatchU;
31844
32163
 
31845
- if (typeof tournamentRecords !== 'object' || !Object.keys(tournamentRecords).length) return {
32164
+ if (inContextMatchUps && !Array.isArray(inContextMatchUps || typeof inContextMatchUps[0] !== 'object')) {
32165
+ return {
32166
+ error: INVALID_VALUES,
32167
+ inContextMatchUps
32168
+ };
32169
+ }
32170
+
32171
+ if (tournamentRecord && !tournamentRecords) {
32172
+ if (typeof tournamentRecord !== 'object') {
32173
+ return {
32174
+ error: INVALID_TOURNAMENT_RECORD
32175
+ };
32176
+ } else {
32177
+ tournamentRecords = {
32178
+ [tournamentRecord.tournamentId]: tournamentRecord
32179
+ };
32180
+ }
32181
+ }
32182
+
32183
+ const noTournamentRecords = typeof tournamentRecords !== 'object' || !Object.keys(tournamentRecords).length;
32184
+ const needsTournamentRecords = !inContextMatchUps || !schedulingProfile && (excludeScheduleDateProfileRounds || excludeCompletedRounds || schedulingProfile || withSplitRounds);
32185
+ if (needsTournamentRecords && noTournamentRecords) return {
31846
32186
  error: MISSING_TOURNAMENT_RECORDS
31847
32187
  };
31848
- const matchUps = ((_allCompetitionMatchU = allCompetitionMatchUps({
31849
- tournamentRecords
32188
+ const {
32189
+ segmentedRounds,
32190
+ profileRounds
32191
+ } = excludeScheduleDateProfileRounds || excludeCompletedRounds || schedulingProfile || withSplitRounds ? getProfileRounds({
32192
+ tournamentRecords,
32193
+ schedulingProfile
32194
+ }) : {};
32195
+ const profileRoundsMap = excludeScheduleDateProfileRounds && Object.assign({}, ...profileRounds.map(profile => ({
32196
+ [profile.id]: profile
32197
+ })));
32198
+ const consideredMatchUps = inContextMatchUps || ((_allCompetitionMatchU = allCompetitionMatchUps({
32199
+ tournamentRecords,
32200
+ matchUpFilters
31850
32201
  })) === null || _allCompetitionMatchU === void 0 ? void 0 : _allCompetitionMatchU.matchUps) || [];
31851
- const rounds = Object.values(matchUps.reduce((rounds, matchUp) => {
31852
- var _rounds$ref$roundMatc, _rounds$ref;
32202
+ const excludedRounds = [];
32203
+ let rounds = consideredMatchUps && Object.values(consideredMatchUps.reduce((rounds, matchUp) => {
32204
+ var _rounds$id$matchUps, _rounds$id;
31853
32205
 
31854
- const ref = getRef(matchUp).ref;
31855
- const roundMatchUps = [...((_rounds$ref$roundMatc = (_rounds$ref = rounds[ref]) === null || _rounds$ref === void 0 ? void 0 : _rounds$ref.roundMatchUps) !== null && _rounds$ref$roundMatc !== void 0 ? _rounds$ref$roundMatc : []), matchUp];
32206
+ const id = getRoundId(matchUp).id;
32207
+ const segmentsCount = segmentedRounds === null || segmentedRounds === void 0 ? void 0 : segmentedRounds[id];
32208
+ const matchUps = [...((_rounds$id$matchUps = (_rounds$id = rounds[id]) === null || _rounds$id === void 0 ? void 0 : _rounds$id.matchUps) !== null && _rounds$id$matchUps !== void 0 ? _rounds$id$matchUps : []), matchUp];
31856
32209
  const {
31857
32210
  containerStructureId,
31858
- drawId,
31859
- drawName,
31860
- eventId,
31861
- eventName,
32211
+ stageSequence,
32212
+ structureName,
32213
+ tournamentId,
31862
32214
  isRoundRobin,
31863
32215
  matchUpType,
31864
- roundName,
31865
32216
  roundNumber,
31866
32217
  roundOffset,
31867
- stageSequence,
31868
32218
  structureId,
31869
- structureName,
31870
- tournamentId
32219
+ eventName,
32220
+ roundName,
32221
+ drawName,
32222
+ eventId,
32223
+ drawId
31871
32224
  } = matchUp;
31872
32225
  const relevantStructureId = isRoundRobin ? containerStructureId : structureId;
31873
32226
  return { ...rounds,
31874
- [ref]: {
31875
- drawId,
31876
- drawName,
31877
- eventId,
31878
- eventName,
32227
+ [id]: {
32228
+ id: withRoundId ? id : undefined,
32229
+ structureId: relevantStructureId,
32230
+ stageSequence,
32231
+ segmentsCount,
32232
+ structureName,
32233
+ tournamentId,
31879
32234
  matchUpType,
31880
- roundMatchUps,
31881
- roundName,
31882
32235
  roundNumber,
31883
32236
  roundOffset,
31884
- stageSequence,
31885
- structureId: relevantStructureId,
31886
- structureName,
31887
- tournamentId
32237
+ eventName,
32238
+ roundName,
32239
+ drawName,
32240
+ matchUps,
32241
+ eventId,
32242
+ drawId
31888
32243
  }
31889
32244
  };
31890
32245
  }, {})).map(round => {
31891
- var _round$roundMatchUps$, _round$roundMatchUps;
31892
-
31893
- const matchUpsCount = (_round$roundMatchUps$ = (_round$roundMatchUps = round.roundMatchUps) === null || _round$roundMatchUps === void 0 ? void 0 : _round$roundMatchUps.length) !== null && _round$roundMatchUps$ !== void 0 ? _round$roundMatchUps$ : 0;
31894
32246
  const {
31895
32247
  minFinishingSum,
31896
32248
  winnerFinishingPositionRange
31897
- } = getFinishingPositionDetails(round.roundMatchUps);
31898
- return { ...round,
32249
+ } = getFinishingPositionDetails(round.matchUps);
32250
+ const segmentsCount = round.segmentsCount;
32251
+
32252
+ if (segmentsCount) {
32253
+ const chunkSize = round.matchUps.length / segmentsCount;
32254
+ const sortedMatchUps = chunkArray(round.matchUps.sort((a, b) => a.roundPosition - b.roundPosition), chunkSize);
32255
+ return sortedMatchUps.map((matchUps, i) => {
32256
+ const {
32257
+ unscheduledCount,
32258
+ incompleteCount,
32259
+ matchUpsCount,
32260
+ isScheduled,
32261
+ isComplete,
32262
+ byeCount
32263
+ } = getRoundProfile(matchUps);
32264
+ return definedAttributes({ ...round,
32265
+ ...context,
32266
+ roundSegment: {
32267
+ segmentsCount,
32268
+ segmentNumber: i + 1
32269
+ },
32270
+ winnerFinishingPositionRange,
32271
+ unscheduledCount,
32272
+ incompleteCount,
32273
+ minFinishingSum,
32274
+ matchUpsCount,
32275
+ isScheduled,
32276
+ isComplete,
32277
+ byeCount,
32278
+ matchUps
32279
+ });
32280
+ });
32281
+ }
32282
+
32283
+ const {
32284
+ unscheduledCount,
32285
+ incompleteCount,
32286
+ matchUpsCount,
32287
+ isScheduled,
32288
+ isComplete,
32289
+ byeCount
32290
+ } = getRoundProfile(round.matchUps);
32291
+ return definedAttributes({ ...round,
32292
+ ...context,
31899
32293
  winnerFinishingPositionRange,
32294
+ unscheduledCount,
32295
+ incompleteCount,
31900
32296
  minFinishingSum,
31901
- matchUpsCount
31902
- };
31903
- }).sort(roundSort);
32297
+ matchUpsCount,
32298
+ isScheduled,
32299
+ isComplete,
32300
+ byeCount
32301
+ });
32302
+ }).flat().filter(round => {
32303
+ if (excludeScheduleDateProfileRounds) {
32304
+ const scheduleDate = extractDate(excludeScheduleDateProfileRounds);
32305
+ const roundId = withRoundId ? round.id : getRoundId(round).id;
32306
+
32307
+ if (scheduleDate && profileRoundsMap[roundId] && extractDate(profileRoundsMap[roundId].scheduleDate) === scheduleDate) {
32308
+ return false;
32309
+ }
32310
+ }
32311
+
32312
+ const {
32313
+ isComplete,
32314
+ isScheduled
32315
+ } = round;
32316
+ const keepComplete = !excludeCompletedRounds || !isComplete;
32317
+ const keepScheduled = !excludeScheduledRounds || !isScheduled;
32318
+ const keepRound = keepComplete && keepScheduled;
32319
+ if (!keepRound) excludedRounds.push(round);
32320
+ return keepRound;
32321
+ }).sort(roundSort) || [];
31904
32322
  return { ...SUCCESS,
31905
- rounds
32323
+ rounds,
32324
+ excludedRounds
31906
32325
  };
31907
32326
  } // Sort rounds by order in which they will be played
31908
32327
 
@@ -31926,15 +32345,6 @@ function getFinishingPositionDetails(matchUps) {
31926
32345
  });
31927
32346
  }
31928
32347
 
31929
- function getMatchUpDailyLimitsUpdate$1({
31930
- tournamentRecords
31931
- }) {
31932
- return getExtensionUpdate({
31933
- tournamentRecords,
31934
- extensionName: SCHEDULE_LIMITS
31935
- });
31936
- }
31937
-
31938
32348
  function bulkUpdateCourtAssignments({
31939
32349
  tournamentRecords,
31940
32350
  courtAssignments,
@@ -47412,11 +47822,15 @@ function removeCollectionDefinition({
47412
47822
  }
47413
47823
 
47414
47824
  const prunedTieFormat = definedAttributes(tieFormat);
47825
+ result = validateTieFormat({
47826
+ tieFormat: prunedTieFormat
47827
+ });
47828
+ if (result.error) return result;
47415
47829
 
47416
47830
  if (eventId) {
47417
47831
  event.tieFormat = prunedTieFormat; // NOTE: there is not a modifyEventNotice
47418
47832
  } else if (matchUpId) {
47419
- matchUp.tieFormat = tieFormat;
47833
+ matchUp.tieFormat = prunedTieFormat;
47420
47834
  } else if (structure) {
47421
47835
  structure.tieFormat = prunedTieFormat;
47422
47836
  } else if (drawDefinition) {
@@ -47446,15 +47860,10 @@ function validUpdate({
47446
47860
  return valid;
47447
47861
  }
47448
47862
 
47449
- function updateCollectionDefinitions(element, tieFormat) {
47450
- element.tieFormat = tieFormat;
47451
- }
47452
-
47453
47863
  function mapsCheck(map1, map2) {
47454
47864
  const referenceKeys = Object.keys(map1);
47455
47865
  return intersection(referenceKeys, Object.keys(map2)).length === referenceKeys.length;
47456
- } // only allows update to collectionName and matchUpFormat
47457
-
47866
+ }
47458
47867
 
47459
47868
  function updateTieFormat({
47460
47869
  updateInProgressMatchUps,
@@ -47474,7 +47883,7 @@ function updateTieFormat({
47474
47883
 
47475
47884
  if (event && eventId) {
47476
47885
  if (event.tieFormat) {
47477
- updateCollectionDefinitions(event, tieFormat);
47886
+ event.tieFormat = copyTieFormat(tieFormat);
47478
47887
  } else {
47479
47888
  // ensure that all matchUps in the event contain tieMatchUps referenced by tieFormat
47480
47889
  const {
@@ -47507,7 +47916,7 @@ function updateTieFormat({
47507
47916
  }
47508
47917
  } else if (matchUp) {
47509
47918
  if (matchUp.tieFormat) {
47510
- updateCollectionDefinitions(matchUp, tieFormat);
47919
+ matchUp.tieFormat = copyTieFormat(tieFormat);
47511
47920
  } else {
47512
47921
  // ensure that all tieMatchUps are referenced by tieFormat
47513
47922
  const matchUpMap = instanceCount(matchUp.tieMatchUps.map(({
@@ -47539,7 +47948,7 @@ function updateTieFormat({
47539
47948
  });
47540
47949
  } else if (structure) {
47541
47950
  if (structure.tieFormat) {
47542
- updateCollectionDefinitions(structure, tieFormat);
47951
+ structure.tieFormat = copyTieFormat(tieFormat);
47543
47952
  } else {
47544
47953
  // ensure that all matchUps in the structure contain tieMatchUps referenced by tieFormat
47545
47954
  const {
@@ -47586,7 +47995,7 @@ function updateTieFormat({
47586
47995
  });
47587
47996
  } else if (drawDefinition) {
47588
47997
  if (drawDefinition.tieFormat) {
47589
- updateCollectionDefinitions(drawDefinition, tieFormat);
47998
+ drawDefinition.tieFormat = copyTieFormat(tieFormat);
47590
47999
  } else {
47591
48000
  // ensure that all matchUps in the draw contain tieMatchUps referenced by tieFormat
47592
48001
  const {
@@ -47658,10 +48067,8 @@ function updateStructureMatchUps$1({
47658
48067
  }) && matchUp.tieFormat);
47659
48068
 
47660
48069
  for (const matchUp of targetMatchUps) {
47661
- var _matchUp$tieFormat;
47662
-
47663
- if ((_matchUp$tieFormat = matchUp.tieFormat) !== null && _matchUp$tieFormat !== void 0 && _matchUp$tieFormat.collectionDefinitions) {
47664
- updateCollectionDefinitions(matchUp, tieFormat);
48070
+ if (matchUp.tieFormat) {
48071
+ matchUp.tieFormat = copyTieFormat(tieFormat);
47665
48072
  modifyMatchUpNotice({
47666
48073
  tournamentId: tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.tournamentId,
47667
48074
  drawDefinition,
@@ -47782,18 +48189,21 @@ function modifyCollectionDefinition({
47782
48189
  }
47783
48190
  }
47784
48191
 
48192
+ if (collectionOrder) collectionDefinition.collectionOrder = collectionOrder;
47785
48193
  if (collectionName) collectionDefinition.collectionName = collectionName;
47786
48194
  if (matchUpFormat) collectionDefinition.matchUpFormat = matchUpFormat;
47787
- if (collectionOrder) collectionDefinition.collectionOrder = collectionOrder; // cleanup any undefined attributes
47788
-
47789
- tieFormat.collectionDefinitions = tieFormat.collectionDefinitions.map(def => def.collectionId === collectionId ? definedAttributes(collectionDefinition) : def);
48195
+ const prunedTieFormat = definedAttributes(tieFormat);
48196
+ result = validateTieFormat({
48197
+ tieFormat: prunedTieFormat
48198
+ });
48199
+ if (result.error) return result;
47790
48200
  return updateTieFormat({
48201
+ tieFormat: prunedTieFormat,
47791
48202
  updateInProgressMatchUps,
47792
48203
  tournamentRecord,
47793
48204
  drawDefinition,
47794
48205
  structureId,
47795
48206
  structure,
47796
- tieFormat,
47797
48207
  eventId,
47798
48208
  matchUp,
47799
48209
  event
@@ -47889,9 +48299,14 @@ function addCollectionDefinition({
47889
48299
  const modifiedStructureIds = [];
47890
48300
  const addedMatchUps = [];
47891
48301
  let targetMatchUps = [];
48302
+ const prunedTieFormat = definedAttributes(tieFormat);
48303
+ result = validateTieFormat({
48304
+ tieFormat: prunedTieFormat
48305
+ });
48306
+ if (result.error) return result;
47892
48307
 
47893
48308
  if (eventId) {
47894
- event.tieFormat = tieFormat; // all team matchUps in the event which do not have tieFormats and where draws/strucures do not have tieFormats should have matchUps added
48309
+ event.tieFormat = prunedTieFormat; // all team matchUps in the event which do not have tieFormats and where draws/strucures do not have tieFormats should have matchUps added
47895
48310
 
47896
48311
  for (const drawDefinition of event.drawDefinitions || []) {
47897
48312
  if (drawDefinition.tieFormat) continue;
@@ -47919,7 +48334,7 @@ function addCollectionDefinition({
47919
48334
  addedMatchUps
47920
48335
  });
47921
48336
  } else if (structureId && structure) {
47922
- structure.tieFormat = tieFormat;
48337
+ structure.tieFormat = prunedTieFormat;
47923
48338
  const result = updateStructureMatchUps({
47924
48339
  updateInProgressMatchUps,
47925
48340
  collectionDefinition,
@@ -47943,7 +48358,7 @@ function addCollectionDefinition({
47943
48358
  })) return {
47944
48359
  error: CANNOT_MODIFY_TIEFORMAT
47945
48360
  };
47946
- matchUp.tieFormat = tieFormat;
48361
+ matchUp.tieFormat = prunedTieFormat;
47947
48362
  const newMatchUps = generateCollectionMatchUps({
47948
48363
  collectionDefinition,
47949
48364
  uuids
@@ -47960,7 +48375,7 @@ function addCollectionDefinition({
47960
48375
  });
47961
48376
  } else if (drawDefinition) {
47962
48377
  // all team matchUps in the drawDefinition which do not have tieFormats and where strucures do not have tieFormats should have matchUps added
47963
- drawDefinition.tieFormat = tieFormat;
48378
+ drawDefinition.tieFormat = prunedTieFormat;
47964
48379
 
47965
48380
  for (const structure of drawDefinition.structures || []) {
47966
48381
  const result = updateStructureMatchUps({
@@ -47989,9 +48404,9 @@ function addCollectionDefinition({
47989
48404
  }
47990
48405
 
47991
48406
  return { ...SUCCESS,
47992
- tieFormat,
47993
- addedMatchUps,
47994
- targetMatchUps
48407
+ tieFormat: prunedTieFormat,
48408
+ targetMatchUps,
48409
+ addedMatchUps
47995
48410
  };
47996
48411
  }
47997
48412
 
@@ -52014,8 +52429,10 @@ function removeInvalidScheduling({
52014
52429
  const tournamentGovernor = {
52015
52430
  addNotes,
52016
52431
  removeNotes,
52017
- analyzeTournament,
52018
52432
  analyzeDraws,
52433
+ analyzeTournament,
52434
+ getRounds,
52435
+ getProfileRounds,
52019
52436
  setTournamentName,
52020
52437
  setTournamentNotes,
52021
52438
  setTournamentDates,
@@ -54061,6 +54478,7 @@ const DOMINANT_DUO_MIXED = 'DOMINANT_DUO_MIXED';
54061
54478
  const LAVER_CUP = 'LAVER_CUP';
54062
54479
  const TEAM_DOUBLES_3_AGGREGATION = 'TEAM_DOUBLES_3_AGGREGATION';
54063
54480
  const USTA_BREWER_CUP = 'USTA_BREWER_CUP';
54481
+ const USTA_OZAKI_CUP = 'USTA_OZAKI_CUP';
54064
54482
  const USTA_COLLEGE = 'USTA_COLLEGE';
54065
54483
  const USTA_GOLD_TEAM_CHALLENGE = 'USTA_GOLD_TEAM_CHALLENGE';
54066
54484
  const USTA_LEVEL_1 = 'USTA_LEVEL_1';
@@ -54078,6 +54496,7 @@ const tieFormatConstants = {
54078
54496
  LAVER_CUP,
54079
54497
  TEAM_DOUBLES_3_AGGREGATION,
54080
54498
  USTA_BREWER_CUP,
54499
+ USTA_OZAKI_CUP,
54081
54500
  USTA_COLLEGE,
54082
54501
  USTA_GOLD_TEAM_CHALLENGE,
54083
54502
  USTA_INTERSECTIONAL,
@@ -54151,6 +54570,7 @@ const namedFormats = {
54151
54570
  [DOMINANT_DUO_MIXED]: DOMINANT_DUO_MIXED_TIE_FORMAT,
54152
54571
  [TEAM_DOUBLES_3_AGGREGATION]: TEAM_AGGREGATION_TIE_FORMAT,
54153
54572
  [USTA_BREWER_CUP]: USTA_BREWER_CUP_TIE_FORMAT,
54573
+ [USTA_OZAKI_CUP]: USTA_OZAKI_CUP_TIE_FORMAT,
54154
54574
  [USTA_COLLEGE]: USTA_COLLEGE_TIE_FORMAT,
54155
54575
  [USTA_GOLD_TEAM_CHALLENGE]: USTA_GOLD_TEAM_CHALLENGE_FORMAT,
54156
54576
  [USTA_INTERSECTIONAL]: USTA_INTERSECTIONAL_TIE_FORMAT,
@@ -65474,7 +65894,7 @@ function generateTournamentRecord({
65474
65894
  }
65475
65895
  }
65476
65896
 
65477
- return definedAttributes({
65897
+ return definedAttributes({ ...SUCCESS,
65478
65898
  tournamentRecord,
65479
65899
  scheduledRounds,
65480
65900
  schedulerResult,