tods-competition-factory 2.1.0 → 2.1.2

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.
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  function factoryVersion() {
6
- return '2.1.0';
6
+ return '2.1.2';
7
7
  }
8
8
 
9
9
  function isFunction(obj) {
@@ -1095,7 +1095,12 @@ function setSubscriptions$1(params) {
1095
1095
  if (typeof params.subscriptions !== 'object')
1096
1096
  return { error: INVALID_VALUES };
1097
1097
  Object.keys(params.subscriptions).forEach((subscription) => {
1098
- syncGlobalState.subscriptions[subscription] = params.subscriptions[subscription];
1098
+ if (typeof params.subscriptions[subscription] === 'function') {
1099
+ syncGlobalState.subscriptions[subscription] = params.subscriptions[subscription];
1100
+ }
1101
+ else {
1102
+ delete syncGlobalState.subscriptions[subscription];
1103
+ }
1099
1104
  });
1100
1105
  return { ...SUCCESS };
1101
1106
  }
@@ -1640,6 +1645,9 @@ function deleteNotices() {
1640
1645
  function getTopics() {
1641
1646
  return _globalStateProvider.getTopics();
1642
1647
  }
1648
+ function hasTopic(topic) {
1649
+ return getTopics()?.topics?.includes(topic);
1650
+ }
1643
1651
  async function callListener(payload) {
1644
1652
  return _globalStateProvider.callListener(payload, globalState.globalSubscriptions);
1645
1653
  }
@@ -1737,6 +1745,7 @@ var globalState$1 = {
1737
1745
  getTournamentRecords: getTournamentRecords,
1738
1746
  globalLog: globalLog$1,
1739
1747
  handleCaughtError: handleCaughtError,
1748
+ hasTopic: hasTopic,
1740
1749
  removeTournamentRecord: removeTournamentRecord,
1741
1750
  setDeepCopy: setDeepCopy,
1742
1751
  setDevContext: setDevContext,
@@ -1823,6 +1832,184 @@ const eventConstants = {
1823
1832
  TEAM: TEAM$2,
1824
1833
  };
1825
1834
 
1835
+ const MAIN = 'MAIN';
1836
+ const QUALIFYING = 'QUALIFYING';
1837
+ const CONSOLATION = 'CONSOLATION';
1838
+ const VOLUNTARY_CONSOLATION = 'VOLUNTARY_CONSOLATION';
1839
+ const PLAY_OFF = 'PLAY_OFF';
1840
+ const validStages = [MAIN, QUALIFYING, CONSOLATION, PLAY_OFF, VOLUNTARY_CONSOLATION];
1841
+ const stageOrder$1 = {
1842
+ [QUALIFYING]: 1,
1843
+ [MAIN]: 2,
1844
+ [PLAY_OFF]: 3,
1845
+ [CONSOLATION]: 3,
1846
+ [VOLUNTARY_CONSOLATION]: 4,
1847
+ };
1848
+ const FINISHING_POSITIONS = 'finishingPositions';
1849
+ const AGGREGATE_EVENT_STRUCTURES = 'aggregateEventStructures';
1850
+ const finishOrder = {
1851
+ [MAIN]: 1,
1852
+ [PLAY_OFF]: 2,
1853
+ [CONSOLATION]: 3,
1854
+ [QUALIFYING]: 4,
1855
+ [VOLUNTARY_CONSOLATION]: 5,
1856
+ };
1857
+ const aggregateOrder = {
1858
+ [PLAY_OFF]: 1,
1859
+ [MAIN]: 2,
1860
+ [CONSOLATION]: 3,
1861
+ [QUALIFYING]: 4,
1862
+ [VOLUNTARY_CONSOLATION]: 5,
1863
+ };
1864
+ const CLUSTER = 'CLUSTER';
1865
+ const SEPARATE = 'SEPARATE';
1866
+ const WATERFALL = 'WATERFALL';
1867
+ const ITEM = 'ITEM';
1868
+ const CONTAINER = 'CONTAINER';
1869
+ const DRAW = 'DRAW';
1870
+ const RANDOM = 'RANDOM';
1871
+ const TOP_DOWN = 'TOP_DOWN';
1872
+ const BOTTOM_UP = 'BOTTOM_UP';
1873
+ const POSITION = 'POSITION';
1874
+ const WINNER = 'WINNER';
1875
+ const LOSER = 'LOSER';
1876
+ const FIRST_MATCHUP = 'FIRST_MATCHUP';
1877
+ const AD_HOC = 'AD_HOC';
1878
+ const FLEX_ROUNDS = 'AD_HOC';
1879
+ const FEED_IN$1 = 'FEED_IN';
1880
+ const COMPASS = 'COMPASS';
1881
+ const OLYMPIC = 'OLYMPIC';
1882
+ const KNOCKOUT = 'SINGLE_ELIMINATION';
1883
+ const SINGLE_ELIMINATION = 'SINGLE_ELIMINATION';
1884
+ const DOUBLE_ELIMINATION = 'DOUBLE_ELIMINATION';
1885
+ const FIRST_MATCH_LOSER_CONSOLATION = 'FIRST_MATCH_LOSER_CONSOLATION';
1886
+ const FIRST_ROUND_LOSER_CONSOLATION = 'FIRST_ROUND_LOSER_CONSOLATION';
1887
+ const LUCKY_DRAW = 'LUCKY_DRAW';
1888
+ const CURTIS = 'CURTIS_CONSOLATION';
1889
+ const CURTIS_CONSOLATION = 'CURTIS_CONSOLATION';
1890
+ const FICSF = 'FEED_IN_CHAMPIONSHIP_TO_SF';
1891
+ const FEED_IN_CHAMPIONSHIP_TO_SF = 'FEED_IN_CHAMPIONSHIP_TO_SF';
1892
+ const FICQF = 'FEED_IN_CHAMPIONSHIP_TO_QF';
1893
+ const FEED_IN_CHAMPIONSHIP_TO_QF = 'FEED_IN_CHAMPIONSHIP_TO_QF';
1894
+ const FICR16 = 'FEED_IN_CHAMPIONSHIP_TO_R16';
1895
+ const FEED_IN_CHAMPIONSHIP_TO_R16 = 'FEED_IN_CHAMPIONSHIP_TO_R16';
1896
+ const MFIC = 'MODIFIED_FEED_IN_CHAMPIONSHIP';
1897
+ const MODIFIED_FEED_IN_CHAMPIONSHIP = 'MODIFIED_FEED_IN_CHAMPIONSHIP';
1898
+ const FEED_IN_CHAMPIONSHIP = 'FEED_IN_CHAMPIONSHIP';
1899
+ const DOUBLE_ROUND_ROBIN = 'DOUBLE_ROUND_ROBIN';
1900
+ const ROUND_ROBIN = 'ROUND_ROBIN';
1901
+ const ROUND_ROBIN_WITH_PLAYOFF = 'ROUND_ROBIN_WITH_PLAYOFF';
1902
+ const DECIDER = 'DECIDER';
1903
+ const BACKDRAW = 'BACKDRAW';
1904
+ const COMPASS_ATTRIBUTES = {
1905
+ 0: { name: 'East', abbreviation: 'E' },
1906
+ '0-1': { name: 'West', abbreviation: 'W' },
1907
+ '0-2': { name: 'North', abbreviation: 'N' },
1908
+ '0-3': { name: 'Northeast', abbreviation: 'NE' },
1909
+ '0-1-1': { name: 'South', abbreviation: 'S' },
1910
+ '0-1-2': { name: 'Southwest', abbreviation: 'SW' },
1911
+ '0-2-1': { name: 'Northwest', abbreviation: 'NW' },
1912
+ '0-1-1-1': { name: 'Southeast', abbreviation: 'SE' },
1913
+ };
1914
+ const OLYMPIC_ATTRIBUTES = {
1915
+ 0: { name: 'East', abbreviation: 'E' },
1916
+ '0-1': { name: 'West', abbreviation: 'W' },
1917
+ '0-2': { name: 'North', abbreviation: 'N' },
1918
+ '0-1-1': { name: 'South', abbreviation: 'S' },
1919
+ };
1920
+ const WIN_RATIO$1 = 'WIN_RATIO';
1921
+ const ROUND_OUTCOME = 'ROUND_OUTCOME';
1922
+ const MULTI_STRUCTURE_DRAWS = [
1923
+ COMPASS,
1924
+ CURTIS,
1925
+ FEED_IN_CHAMPIONSHIP_TO_QF,
1926
+ FEED_IN_CHAMPIONSHIP_TO_R16,
1927
+ FEED_IN_CHAMPIONSHIP_TO_SF,
1928
+ FEED_IN_CHAMPIONSHIP,
1929
+ FICQF,
1930
+ FICR16,
1931
+ FICSF,
1932
+ FIRST_MATCH_LOSER_CONSOLATION,
1933
+ FIRST_ROUND_LOSER_CONSOLATION,
1934
+ LUCKY_DRAW,
1935
+ MODIFIED_FEED_IN_CHAMPIONSHIP,
1936
+ OLYMPIC,
1937
+ PLAY_OFF,
1938
+ ROUND_ROBIN_WITH_PLAYOFF,
1939
+ ];
1940
+ const generatedDrawTypes = [
1941
+ AD_HOC,
1942
+ COMPASS,
1943
+ CURTIS,
1944
+ DOUBLE_ELIMINATION,
1945
+ FEED_IN_CHAMPIONSHIP_TO_QF,
1946
+ FEED_IN_CHAMPIONSHIP_TO_R16,
1947
+ FEED_IN_CHAMPIONSHIP_TO_SF,
1948
+ FEED_IN_CHAMPIONSHIP,
1949
+ FEED_IN$1,
1950
+ FIRST_MATCH_LOSER_CONSOLATION,
1951
+ FIRST_ROUND_LOSER_CONSOLATION,
1952
+ LUCKY_DRAW,
1953
+ MODIFIED_FEED_IN_CHAMPIONSHIP,
1954
+ OLYMPIC,
1955
+ PLAY_OFF,
1956
+ ROUND_ROBIN,
1957
+ ROUND_ROBIN_WITH_PLAYOFF,
1958
+ SINGLE_ELIMINATION,
1959
+ ];
1960
+ const drawDefinitionConstants = {
1961
+ MAIN,
1962
+ QUALIFYING,
1963
+ CONSOLATION,
1964
+ ITEM,
1965
+ CONTAINER,
1966
+ FIRST_MATCHUP,
1967
+ WINNER,
1968
+ LOSER,
1969
+ AD_HOC,
1970
+ FEED_IN: FEED_IN$1,
1971
+ FLEX_ROUNDS,
1972
+ COMPASS,
1973
+ PLAY_OFF,
1974
+ OLYMPIC,
1975
+ KNOCKOUT,
1976
+ SINGLE_ELIMINATION,
1977
+ DOUBLE_ELIMINATION,
1978
+ CURTIS,
1979
+ FICSF,
1980
+ FICQF,
1981
+ FICR16,
1982
+ MFIC,
1983
+ VOLUNTARY_CONSOLATION,
1984
+ FIRST_MATCH_LOSER_CONSOLATION,
1985
+ FIRST_ROUND_LOSER_CONSOLATION,
1986
+ MODIFIED_FEED_IN_CHAMPIONSHIP,
1987
+ FEED_IN_CHAMPIONSHIP_TO_R16,
1988
+ FEED_IN_CHAMPIONSHIP_TO_QF,
1989
+ FEED_IN_CHAMPIONSHIP_TO_SF,
1990
+ FEED_IN_CHAMPIONSHIP,
1991
+ LUCKY_DRAW,
1992
+ ROUND_ROBIN_WITH_PLAYOFF,
1993
+ ROUND_ROBIN,
1994
+ DECIDER,
1995
+ BACKDRAW,
1996
+ COMPASS_ATTRIBUTES,
1997
+ OLYMPIC_ATTRIBUTES,
1998
+ DRAW,
1999
+ RANDOM,
2000
+ TOP_DOWN,
2001
+ BOTTOM_UP,
2002
+ WATERFALL,
2003
+ WIN_RATIO: WIN_RATIO$1,
2004
+ ROUND_OUTCOME,
2005
+ MULTI_STRUCTURE_DRAWS,
2006
+ generatedDrawTypes,
2007
+ stageOrder: stageOrder$1,
2008
+ finishOrder,
2009
+ AGGREGATE_EVENT_STRUCTURES,
2010
+ FINISHING_POSITIONS,
2011
+ };
2012
+
1826
2013
  const TOURNAMENT_RECORDS = 'tournamentRecords';
1827
2014
  const POLICY_DEFINITIONS = 'policyDefinitions';
1828
2015
  const TOURNAMENT_RECORD = 'tournamentRecord';
@@ -1837,6 +2024,7 @@ const ROUND_NUMBER = 'roundNumber';
1837
2024
  const STRUCTURE_ID = 'structureId';
1838
2025
  const PARTICIPANT = 'participant';
1839
2026
  const MATCHUP_IDS = 'matchUpIds';
2027
+ const ENTRY_STAGE = 'entryStage';
1840
2028
  const POLICY_TYPE = 'policyType';
1841
2029
  const STRUCTURES = 'structures';
1842
2030
  const MATCHUP_ID = 'matchUpId';
@@ -1871,6 +2059,7 @@ const ONE_OF = '_oneOf';
1871
2059
  const validators = {
1872
2060
  [EVENT_TYPE]: (value) => [SINGLES$1, DOUBLES$1, TEAM$2].includes(value),
1873
2061
  [ONLINE_RESOURCE]: (value) => intersection(Object.keys(value), [RESOURCE_SUB_TYPE, RESOURCE_TYPE, IDENTIFIER]).length === 3,
2062
+ [ENTRY_STAGE]: (value) => validStages.includes(value),
1874
2063
  };
1875
2064
  const errors = {
1876
2065
  [TOURNAMENT_RECORDS]: MISSING_TOURNAMENT_RECORDS,
@@ -2481,6 +2670,7 @@ const POLICY_TYPE_PARTICIPANT = 'participant';
2481
2670
  const POLICY_TYPE_PROGRESSION = 'progression';
2482
2671
  const POLICY_TYPE_SCHEDULING = 'scheduling';
2483
2672
  const POLICY_TYPE_AVOIDANCE = 'avoidance';
2673
+ const POLICY_TYPE_PRIVACY = 'participant';
2484
2674
  const POLICY_TYPE_DISPLAY = 'display';
2485
2675
  const POLICY_TYPE_SCORING = 'scoring';
2486
2676
  const POLICY_TYPE_SEEDING = 'seeding';
@@ -2500,6 +2690,7 @@ const policyConstants = {
2500
2690
  POLICY_TYPE_SCHEDULING,
2501
2691
  POLICY_TYPE_AVOIDANCE,
2502
2692
  POLICY_TYPE_DISPLAY,
2693
+ POLICY_TYPE_PRIVACY,
2503
2694
  POLICY_TYPE_FEED_IN,
2504
2695
  POLICY_TYPE_SCORING,
2505
2696
  POLICY_TYPE_SEEDING,
@@ -3071,184 +3262,6 @@ const matchUpStatusConstants = {
3071
3262
  WALKOVER: WALKOVER$2,
3072
3263
  };
3073
3264
 
3074
- const MAIN = 'MAIN';
3075
- const QUALIFYING = 'QUALIFYING';
3076
- const CONSOLATION = 'CONSOLATION';
3077
- const VOLUNTARY_CONSOLATION = 'VOLUNTARY_CONSOLATION';
3078
- const PLAY_OFF = 'PLAY_OFF';
3079
- const validStages = [MAIN, QUALIFYING, CONSOLATION, PLAY_OFF, VOLUNTARY_CONSOLATION];
3080
- const stageOrder$1 = {
3081
- [QUALIFYING]: 1,
3082
- [MAIN]: 2,
3083
- [PLAY_OFF]: 3,
3084
- [CONSOLATION]: 3,
3085
- [VOLUNTARY_CONSOLATION]: 4,
3086
- };
3087
- const FINISHING_POSITIONS = 'finishingPositions';
3088
- const AGGREGATE_EVENT_STRUCTURES = 'aggregateEventStructures';
3089
- const finishOrder = {
3090
- [MAIN]: 1,
3091
- [PLAY_OFF]: 2,
3092
- [CONSOLATION]: 3,
3093
- [QUALIFYING]: 4,
3094
- [VOLUNTARY_CONSOLATION]: 5,
3095
- };
3096
- const aggregateOrder = {
3097
- [PLAY_OFF]: 1,
3098
- [MAIN]: 2,
3099
- [CONSOLATION]: 3,
3100
- [QUALIFYING]: 4,
3101
- [VOLUNTARY_CONSOLATION]: 5,
3102
- };
3103
- const CLUSTER = 'CLUSTER';
3104
- const SEPARATE = 'SEPARATE';
3105
- const WATERFALL = 'WATERFALL';
3106
- const ITEM = 'ITEM';
3107
- const CONTAINER = 'CONTAINER';
3108
- const DRAW = 'DRAW';
3109
- const RANDOM = 'RANDOM';
3110
- const TOP_DOWN = 'TOP_DOWN';
3111
- const BOTTOM_UP = 'BOTTOM_UP';
3112
- const POSITION = 'POSITION';
3113
- const WINNER = 'WINNER';
3114
- const LOSER = 'LOSER';
3115
- const FIRST_MATCHUP = 'FIRST_MATCHUP';
3116
- const AD_HOC = 'AD_HOC';
3117
- const FLEX_ROUNDS = 'AD_HOC';
3118
- const FEED_IN$1 = 'FEED_IN';
3119
- const COMPASS = 'COMPASS';
3120
- const OLYMPIC = 'OLYMPIC';
3121
- const KNOCKOUT = 'SINGLE_ELIMINATION';
3122
- const SINGLE_ELIMINATION = 'SINGLE_ELIMINATION';
3123
- const DOUBLE_ELIMINATION = 'DOUBLE_ELIMINATION';
3124
- const FIRST_MATCH_LOSER_CONSOLATION = 'FIRST_MATCH_LOSER_CONSOLATION';
3125
- const FIRST_ROUND_LOSER_CONSOLATION = 'FIRST_ROUND_LOSER_CONSOLATION';
3126
- const LUCKY_DRAW = 'LUCKY_DRAW';
3127
- const CURTIS = 'CURTIS_CONSOLATION';
3128
- const CURTIS_CONSOLATION = 'CURTIS_CONSOLATION';
3129
- const FICSF = 'FEED_IN_CHAMPIONSHIP_TO_SF';
3130
- const FEED_IN_CHAMPIONSHIP_TO_SF = 'FEED_IN_CHAMPIONSHIP_TO_SF';
3131
- const FICQF = 'FEED_IN_CHAMPIONSHIP_TO_QF';
3132
- const FEED_IN_CHAMPIONSHIP_TO_QF = 'FEED_IN_CHAMPIONSHIP_TO_QF';
3133
- const FICR16 = 'FEED_IN_CHAMPIONSHIP_TO_R16';
3134
- const FEED_IN_CHAMPIONSHIP_TO_R16 = 'FEED_IN_CHAMPIONSHIP_TO_R16';
3135
- const MFIC = 'MODIFIED_FEED_IN_CHAMPIONSHIP';
3136
- const MODIFIED_FEED_IN_CHAMPIONSHIP = 'MODIFIED_FEED_IN_CHAMPIONSHIP';
3137
- const FEED_IN_CHAMPIONSHIP = 'FEED_IN_CHAMPIONSHIP';
3138
- const DOUBLE_ROUND_ROBIN = 'DOUBLE_ROUND_ROBIN';
3139
- const ROUND_ROBIN = 'ROUND_ROBIN';
3140
- const ROUND_ROBIN_WITH_PLAYOFF = 'ROUND_ROBIN_WITH_PLAYOFF';
3141
- const DECIDER = 'DECIDER';
3142
- const BACKDRAW = 'BACKDRAW';
3143
- const COMPASS_ATTRIBUTES = {
3144
- 0: { name: 'East', abbreviation: 'E' },
3145
- '0-1': { name: 'West', abbreviation: 'W' },
3146
- '0-2': { name: 'North', abbreviation: 'N' },
3147
- '0-3': { name: 'Northeast', abbreviation: 'NE' },
3148
- '0-1-1': { name: 'South', abbreviation: 'S' },
3149
- '0-1-2': { name: 'Southwest', abbreviation: 'SW' },
3150
- '0-2-1': { name: 'Northwest', abbreviation: 'NW' },
3151
- '0-1-1-1': { name: 'Southeast', abbreviation: 'SE' },
3152
- };
3153
- const OLYMPIC_ATTRIBUTES = {
3154
- 0: { name: 'East', abbreviation: 'E' },
3155
- '0-1': { name: 'West', abbreviation: 'W' },
3156
- '0-2': { name: 'North', abbreviation: 'N' },
3157
- '0-1-1': { name: 'South', abbreviation: 'S' },
3158
- };
3159
- const WIN_RATIO$1 = 'WIN_RATIO';
3160
- const ROUND_OUTCOME = 'ROUND_OUTCOME';
3161
- const MULTI_STRUCTURE_DRAWS = [
3162
- COMPASS,
3163
- CURTIS,
3164
- FEED_IN_CHAMPIONSHIP_TO_QF,
3165
- FEED_IN_CHAMPIONSHIP_TO_R16,
3166
- FEED_IN_CHAMPIONSHIP_TO_SF,
3167
- FEED_IN_CHAMPIONSHIP,
3168
- FICQF,
3169
- FICR16,
3170
- FICSF,
3171
- FIRST_MATCH_LOSER_CONSOLATION,
3172
- FIRST_ROUND_LOSER_CONSOLATION,
3173
- LUCKY_DRAW,
3174
- MODIFIED_FEED_IN_CHAMPIONSHIP,
3175
- OLYMPIC,
3176
- PLAY_OFF,
3177
- ROUND_ROBIN_WITH_PLAYOFF,
3178
- ];
3179
- const generatedDrawTypes = [
3180
- AD_HOC,
3181
- COMPASS,
3182
- CURTIS,
3183
- DOUBLE_ELIMINATION,
3184
- FEED_IN_CHAMPIONSHIP_TO_QF,
3185
- FEED_IN_CHAMPIONSHIP_TO_R16,
3186
- FEED_IN_CHAMPIONSHIP_TO_SF,
3187
- FEED_IN_CHAMPIONSHIP,
3188
- FEED_IN$1,
3189
- FIRST_MATCH_LOSER_CONSOLATION,
3190
- FIRST_ROUND_LOSER_CONSOLATION,
3191
- LUCKY_DRAW,
3192
- MODIFIED_FEED_IN_CHAMPIONSHIP,
3193
- OLYMPIC,
3194
- PLAY_OFF,
3195
- ROUND_ROBIN,
3196
- ROUND_ROBIN_WITH_PLAYOFF,
3197
- SINGLE_ELIMINATION,
3198
- ];
3199
- const drawDefinitionConstants = {
3200
- MAIN,
3201
- QUALIFYING,
3202
- CONSOLATION,
3203
- ITEM,
3204
- CONTAINER,
3205
- FIRST_MATCHUP,
3206
- WINNER,
3207
- LOSER,
3208
- AD_HOC,
3209
- FEED_IN: FEED_IN$1,
3210
- FLEX_ROUNDS,
3211
- COMPASS,
3212
- PLAY_OFF,
3213
- OLYMPIC,
3214
- KNOCKOUT,
3215
- SINGLE_ELIMINATION,
3216
- DOUBLE_ELIMINATION,
3217
- CURTIS,
3218
- FICSF,
3219
- FICQF,
3220
- FICR16,
3221
- MFIC,
3222
- VOLUNTARY_CONSOLATION,
3223
- FIRST_MATCH_LOSER_CONSOLATION,
3224
- FIRST_ROUND_LOSER_CONSOLATION,
3225
- MODIFIED_FEED_IN_CHAMPIONSHIP,
3226
- FEED_IN_CHAMPIONSHIP_TO_R16,
3227
- FEED_IN_CHAMPIONSHIP_TO_QF,
3228
- FEED_IN_CHAMPIONSHIP_TO_SF,
3229
- FEED_IN_CHAMPIONSHIP,
3230
- LUCKY_DRAW,
3231
- ROUND_ROBIN_WITH_PLAYOFF,
3232
- ROUND_ROBIN,
3233
- DECIDER,
3234
- BACKDRAW,
3235
- COMPASS_ATTRIBUTES,
3236
- OLYMPIC_ATTRIBUTES,
3237
- DRAW,
3238
- RANDOM,
3239
- TOP_DOWN,
3240
- BOTTOM_UP,
3241
- WATERFALL,
3242
- WIN_RATIO: WIN_RATIO$1,
3243
- ROUND_OUTCOME,
3244
- MULTI_STRUCTURE_DRAWS,
3245
- generatedDrawTypes,
3246
- stageOrder: stageOrder$1,
3247
- finishOrder,
3248
- AGGREGATE_EVENT_STRUCTURES,
3249
- FINISHING_POSITIONS,
3250
- };
3251
-
3252
3265
  function structureSort(a, b, config) {
3253
3266
  const getRoundTarget = (element) => findExtension({ element, name: ROUND_TARGET })?.extension?.value;
3254
3267
  const completed = config?.deprioritizeCompleted;
@@ -12727,12 +12740,11 @@ function getStageSpace({ entryStatus = DIRECT_ACCEPTANCE, drawDefinition, stageS
12727
12740
  }
12728
12741
 
12729
12742
  function addDrawEntry(params) {
12743
+ const paramsCheck = checkRequiredParameters(params, [{ [DRAW_DEFINITION]: true, [ENTRY_STAGE]: true }]);
12744
+ if (paramsCheck.error)
12745
+ return paramsCheck;
12730
12746
  const { suppressDuplicateEntries = true, entryStatus = DIRECT_ACCEPTANCE, entryStageSequence, entryStage = MAIN, ignoreStageSpace, drawDefinition, entryPosition, participant, roundTarget, extensions, extension, drawType, event, } = params;
12731
12747
  const stack = 'addDrawEntry';
12732
- if (!drawDefinition)
12733
- return { error: MISSING_DRAW_DEFINITION };
12734
- if (!entryStage)
12735
- return { error: MISSING_STAGE };
12736
12748
  if (drawType !== AD_HOC && !getValidStage({ stage: entryStage, drawDefinition })) {
12737
12749
  return decorateResult({ result: { error: INVALID_STAGE }, stack });
12738
12750
  }
@@ -12813,7 +12825,7 @@ function addDrawEntry(params) {
12813
12825
  }
12814
12826
  function addDrawEntries$1(params) {
12815
12827
  const stack = 'addDrawEntries';
12816
- const { suppressDuplicateEntries = true, entryStatus = DIRECT_ACCEPTANCE, stage = MAIN, autoEntryPositions = true, ignoreStageSpace, participantIds, drawDefinition, stageSequence, roundTarget, extension, event, } = params;
12828
+ const { suppressDuplicateEntries = true, entryStatus = DIRECT_ACCEPTANCE, autoEntryPositions = true, ignoreStageSpace, participantIds, drawDefinition, stageSequence, stage = MAIN, roundTarget, extension, event, } = params;
12817
12829
  if (!stage)
12818
12830
  return { error: MISSING_STAGE };
12819
12831
  if (!drawDefinition)
@@ -17516,117 +17528,26 @@ function resequenceStructures({ drawDefinition }) {
17516
17528
  return { ...SUCCESS };
17517
17529
  }
17518
17530
 
17519
- function addTimeItem(params) {
17520
- const { duplicateValues = true, creationTime = true, removePriorValues, timeItem } = params;
17521
- if (!timeItem)
17522
- return { error: MISSING_TIME_ITEM };
17523
- const element = deriveElement(params);
17524
- if (element.error)
17525
- return element;
17526
- const validTimeItem = isObject(timeItem) && isString(timeItem.itemType) && Object.keys(timeItem).includes('itemValue');
17527
- if (!validTimeItem)
17528
- return { error: INVALID_TIME_ITEM };
17529
- if (!element.timeItems) {
17530
- element.timeItems = [];
17531
- }
17532
- else if (hasEquivalentTimeItem({ element, duplicateValues, timeItem })) {
17533
- return { ...SUCCESS };
17534
- }
17535
- if (timeItem.itemSubTypes && !timeItem.itemSubTypes.length)
17536
- delete timeItem.itemSubTypes;
17537
- if (creationTime) {
17538
- const createdAt = new Date().toISOString();
17539
- Object.assign(timeItem, { createdAt });
17540
- }
17541
- if (removePriorValues)
17542
- element.timeItems = element.timeItems.filter(({ itemType }) => timeItem.itemType !== itemType);
17543
- const doNotAdd = removePriorValues && !timeItem.itemValue;
17544
- if (!doNotAdd)
17545
- element.timeItems.push(timeItem);
17546
- return { ...SUCCESS };
17547
- }
17548
- function hasEquivalentTimeItem({ element, duplicateValues, timeItem }) {
17549
- const { itemType, itemSubTypes, itemValue } = timeItem;
17550
- const existingTimeItem = itemType &&
17551
- getTimeItem({
17552
- itemSubTypes,
17553
- itemType,
17554
- element,
17555
- })?.timeItem;
17556
- return (existingTimeItem && JSON.stringify(existingTimeItem?.itemValue) === JSON.stringify(itemValue) && !duplicateValues);
17557
- }
17558
- function addParticipantTimeItem({ creationTime = true, removePriorValues, tournamentRecord, duplicateValues, participantId, timeItem, }) {
17559
- if (!tournamentRecord)
17560
- return { error: MISSING_TOURNAMENT_RECORD };
17561
- if (!participantId)
17562
- return { error: MISSING_PARTICIPANT_ID };
17563
- const result = findTournamentParticipant({ tournamentRecord, participantId });
17564
- if (result.error)
17565
- return result;
17566
- return addTimeItem({
17567
- element: result.participant,
17568
- removePriorValues,
17569
- duplicateValues,
17570
- creationTime,
17571
- timeItem,
17572
- });
17573
- }
17574
- function addTournamentTimeItem(params) {
17575
- const { removePriorValues, tournamentRecord, duplicateValues, creationTime, timeItem } = params;
17576
- if (!tournamentRecord)
17577
- return { error: MISSING_TOURNAMENT_RECORD };
17578
- return addTimeItem({
17579
- element: tournamentRecord,
17580
- removePriorValues,
17581
- duplicateValues,
17582
- creationTime,
17583
- timeItem,
17584
- });
17585
- }
17586
- function addEventTimeItem(params) {
17587
- const { removePriorValues, duplicateValues, creationTime, timeItem, event } = params;
17588
- if (!event)
17589
- return { error: EVENT_NOT_FOUND };
17590
- return addTimeItem({
17591
- removePriorValues,
17592
- duplicateValues,
17593
- element: event,
17594
- creationTime,
17595
- timeItem,
17596
- });
17597
- }
17598
-
17599
- function attachQualifyingStructure({ tournamentRecord, drawDefinition, structure, link }) {
17600
- if (!tournamentRecord)
17601
- return { error: MISSING_TOURNAMENT_RECORD };
17602
- if (!drawDefinition)
17603
- return { error: MISSING_DRAW_DEFINITION };
17604
- const result = attachQualifying({
17531
+ function attachQualifyingStructure(params) {
17532
+ const paramsCheck = checkRequiredParameters(params, [{ [TOURNAMENT_RECORD]: true, [DRAW_DEFINITION]: true }]);
17533
+ if (paramsCheck.error)
17534
+ return paramsCheck;
17535
+ const { tournamentRecord, drawDefinition, structure, link } = params;
17536
+ return attachQualifying({
17605
17537
  tournamentId: tournamentRecord.tournamentId,
17606
17538
  drawDefinition,
17607
17539
  structure,
17608
17540
  link,
17609
17541
  });
17610
- if (result.error)
17611
- return result;
17612
- const qualifyingDetails = {
17613
- structureId: structure.structureId,
17614
- drawId: drawDefinition.drawId,
17615
- };
17616
- const timeItem = {
17617
- itemType: 'attachQualifyingStructures',
17618
- itemValue: qualifyingDetails,
17619
- };
17620
- addTournamentTimeItem({ tournamentRecord, timeItem });
17621
- return result;
17622
17542
  }
17623
- function attachQualifying({ drawDefinition, tournamentId, structure, eventId, link }) {
17624
- if (!drawDefinition)
17625
- return { error: MISSING_DRAW_DEFINITION };
17626
- if (!structure)
17627
- return { error: MISSING_STRUCTURE };
17628
- if (!link)
17629
- return { error: MISSING_TARGET_LINK };
17543
+ function attachQualifying(params) {
17544
+ const paramsCheck = checkRequiredParameters(params, [
17545
+ { [DRAW_DEFINITION]: true, [STRUCTURE]: true },
17546
+ { link: true, [OF_TYPE]: OBJECT, [ERROR$1]: MISSING_TARGET_LINK },
17547
+ ]);
17548
+ if (paramsCheck.error)
17549
+ return paramsCheck;
17550
+ const { drawDefinition, tournamentId, structure, eventId, link } = params;
17630
17551
  const targetStructureId = link.target.structureId;
17631
17552
  const result = findStructure({
17632
17553
  drawDefinition,
@@ -18511,22 +18432,6 @@ function addQualifyingStructure(params) {
18511
18432
  const result = addQualifying(params);
18512
18433
  if (result.error)
18513
18434
  return result;
18514
- const { qualifyingRoundNumber, qualifyingPositions, targetStructureId, drawDefinition, structureName, matchUpType, drawSize, drawType, } = params;
18515
- const qualifyingDetails = definedAttributes({
18516
- drawId: drawDefinition.drawId,
18517
- qualifyingRoundNumber,
18518
- qualifyingPositions,
18519
- targetStructureId,
18520
- structureName,
18521
- matchUpType,
18522
- drawSize,
18523
- drawType,
18524
- });
18525
- const timeItem = {
18526
- itemType: 'addQualifyingStructures',
18527
- itemValue: qualifyingDetails,
18528
- };
18529
- addTournamentTimeItem({ tournamentRecord, timeItem });
18530
18435
  return result;
18531
18436
  }
18532
18437
  function addQualifying(params) {
@@ -22915,6 +22820,110 @@ function generateAndPopulatePlayoffStructures(params) {
22915
22820
  };
22916
22821
  }
22917
22822
 
22823
+ function getTimeItemValues({ element }) {
22824
+ if (!element)
22825
+ return { error: INVALID_VALUES };
22826
+ if (!element.timeItems)
22827
+ return {};
22828
+ if (!Array.isArray(element.timeItems))
22829
+ return { error: INVALID_VALUES };
22830
+ const mapItem = (key, value) => (a, i) => {
22831
+ if (!i[key])
22832
+ return a;
22833
+ a[i[key]] = i[value];
22834
+ return a;
22835
+ };
22836
+ return element.timeItems.reduce(mapItem('itemType', 'itemValue'), {});
22837
+ }
22838
+
22839
+ function addTimeItem(params) {
22840
+ const { duplicateValues = true, creationTime = true, removePriorValues, timeItem } = params;
22841
+ if (!timeItem)
22842
+ return { error: MISSING_TIME_ITEM };
22843
+ const element = deriveElement(params);
22844
+ if (element.error)
22845
+ return element;
22846
+ const validTimeItem = isObject(timeItem) && isString(timeItem.itemType) && Object.keys(timeItem).includes('itemValue');
22847
+ if (!validTimeItem)
22848
+ return { error: INVALID_TIME_ITEM };
22849
+ if (!element.timeItems) {
22850
+ element.timeItems = [];
22851
+ }
22852
+ else if (hasEquivalentTimeItem({ element, duplicateValues, timeItem })) {
22853
+ return { ...SUCCESS };
22854
+ }
22855
+ if (timeItem.itemSubTypes && !timeItem.itemSubTypes.length)
22856
+ delete timeItem.itemSubTypes;
22857
+ if (creationTime) {
22858
+ const createdAt = new Date().toISOString();
22859
+ Object.assign(timeItem, { createdAt });
22860
+ }
22861
+ if (removePriorValues)
22862
+ element.timeItems = element.timeItems.filter(({ itemType }) => timeItem.itemType !== itemType);
22863
+ const doNotAdd = removePriorValues && !timeItem.itemValue;
22864
+ if (!doNotAdd)
22865
+ element.timeItems.push(timeItem);
22866
+ return { ...SUCCESS };
22867
+ }
22868
+ function hasEquivalentTimeItem({ element, duplicateValues, timeItem }) {
22869
+ const { itemType, itemSubTypes, itemValue } = timeItem;
22870
+ const existingTimeItem = itemType &&
22871
+ getTimeItem({
22872
+ itemSubTypes,
22873
+ itemType,
22874
+ element,
22875
+ })?.timeItem;
22876
+ return (existingTimeItem && JSON.stringify(existingTimeItem?.itemValue) === JSON.stringify(itemValue) && !duplicateValues);
22877
+ }
22878
+ function addParticipantTimeItem({ creationTime = true, removePriorValues, tournamentRecord, duplicateValues, participantId, timeItem, }) {
22879
+ if (!tournamentRecord)
22880
+ return { error: MISSING_TOURNAMENT_RECORD };
22881
+ if (!participantId)
22882
+ return { error: MISSING_PARTICIPANT_ID };
22883
+ const result = findTournamentParticipant({ tournamentRecord, participantId });
22884
+ if (result.error)
22885
+ return result;
22886
+ return addTimeItem({
22887
+ element: result.participant,
22888
+ removePriorValues,
22889
+ duplicateValues,
22890
+ creationTime,
22891
+ timeItem,
22892
+ });
22893
+ }
22894
+ function addTournamentTimeItem(params) {
22895
+ const { removePriorValues, tournamentRecord, duplicateValues, creationTime, timeItem } = params;
22896
+ if (!tournamentRecord)
22897
+ return { error: MISSING_TOURNAMENT_RECORD };
22898
+ const result = addTimeItem({
22899
+ element: tournamentRecord,
22900
+ removePriorValues,
22901
+ duplicateValues,
22902
+ creationTime,
22903
+ timeItem,
22904
+ });
22905
+ if (result.error)
22906
+ return result;
22907
+ const timeItemValues = getTimeItemValues({ element: tournamentRecord });
22908
+ addNotice({
22909
+ payload: { timeItemValues, tournamentId: tournamentRecord.tournamentId },
22910
+ topic: MODIFY_TOURNAMENT_DETAIL,
22911
+ });
22912
+ return result;
22913
+ }
22914
+ function addEventTimeItem(params) {
22915
+ const { removePriorValues, duplicateValues, creationTime, timeItem, event } = params;
22916
+ if (!event)
22917
+ return { error: EVENT_NOT_FOUND };
22918
+ return addTimeItem({
22919
+ removePriorValues,
22920
+ duplicateValues,
22921
+ element: event,
22922
+ creationTime,
22923
+ timeItem,
22924
+ });
22925
+ }
22926
+
22918
22927
  function attachConsolationStructures(params) {
22919
22928
  return attachStructures({
22920
22929
  ...params,
@@ -33644,7 +33653,7 @@ function getTournamentInfo(params) {
33644
33653
  const { tournamentRecord } = params ?? {};
33645
33654
  if (!tournamentRecord)
33646
33655
  return { error: MISSING_TOURNAMENT_RECORD };
33647
- const tournamentInfo = (({ tournamentId, tournamentRank, tournamentStatus, formalName, tournamentName, promotionalName, onlineResources, localTimeZone, startDate, endDate, hostCountryCode, venues, notes, updatedAt, }) => ({
33656
+ const tournamentInfo = (({ tournamentId, tournamentRank, tournamentStatus, formalName, tournamentName, promotionalName, onlineResources, localTimeZone, activeDates, startDate, endDate, hostCountryCode, venues, notes, updatedAt, }) => ({
33648
33657
  tournamentId,
33649
33658
  tournamentRank,
33650
33659
  tournamentStatus,
@@ -33653,6 +33662,7 @@ function getTournamentInfo(params) {
33653
33662
  promotionalName,
33654
33663
  onlineResources,
33655
33664
  localTimeZone,
33665
+ activeDates,
33656
33666
  startDate,
33657
33667
  endDate,
33658
33668
  hostCountryCode,
@@ -33677,10 +33687,11 @@ function getTournamentInfo(params) {
33677
33687
  eventInfo.push(info);
33678
33688
  }
33679
33689
  }
33690
+ tournamentInfo.timeItemValues = getTimeItemValues({ element: tournamentRecord });
33680
33691
  tournamentInfo.publishState = publishState?.tournament;
33681
33692
  tournamentInfo.eventInfo = eventInfo;
33682
33693
  return {
33683
- tournamentInfo: makeDeepCopy(tournamentInfo, false, true),
33694
+ tournamentInfo: makeDeepCopy(definedAttributes(tournamentInfo), false, true),
33684
33695
  ...SUCCESS,
33685
33696
  };
33686
33697
  }
@@ -35282,13 +35293,54 @@ function getProfileRounds({ tournamentRecords, schedulingProfile, tournamentReco
35282
35293
  return { profileRounds, segmentedRounds };
35283
35294
  }
35284
35295
 
35296
+ function courtGridRows({ courtPrefix = 'C|', minRowsCount, courtsData }) {
35297
+ if (!Array.isArray(courtsData))
35298
+ return { error: INVALID_VALUES };
35299
+ const maxCourtOrder = courtsData?.reduce((order, court) => {
35300
+ const matchUps = court.matchUps || [];
35301
+ const courtOrder = Math.max(0, ...matchUps.map((m) => m.schedule.courtOrder || 0));
35302
+ return courtOrder > order ? courtOrder : order;
35303
+ }, 1);
35304
+ const rowsCount = minRowsCount ? Math.max(minRowsCount, maxCourtOrder) : maxCourtOrder;
35305
+ const rowBuilder = generateRange(0, rowsCount).map((rowIndex) => ({
35306
+ matchUps: generateRange(0, courtsData.length).map((courtIndex) => {
35307
+ const courtInfo = courtsData[courtIndex];
35308
+ const { courtId, venueId } = courtInfo;
35309
+ return {
35310
+ schedule: {
35311
+ courtOrder: rowIndex + 1,
35312
+ venueId,
35313
+ courtId,
35314
+ },
35315
+ };
35316
+ }),
35317
+ }));
35318
+ courtsData.forEach((courtInfo, i) => {
35319
+ for (const matchUp of courtInfo.matchUps) {
35320
+ const courtOrder = matchUp.schedule?.courtOrder;
35321
+ if (courtOrder) {
35322
+ rowBuilder[courtOrder - 1].matchUps[i] = matchUp;
35323
+ }
35324
+ }
35325
+ });
35326
+ return {
35327
+ courtPrefix,
35328
+ rows: rowBuilder.map((row, i) => Object.assign({ rowId: `rowId-${i + 1}` }, ...row.matchUps.map((matchUp, i) => ({
35329
+ [`${courtPrefix}${i}`]: matchUp,
35330
+ })))),
35331
+ };
35332
+ }
35333
+
35285
35334
  var query$4 = {
35286
35335
  __proto__: null,
35336
+ courtGridRows: courtGridRows,
35337
+ findVenue: findVenue,
35287
35338
  getPersonRequests: getPersonRequests,
35288
35339
  getProfileRounds: getProfileRounds,
35289
35340
  getScheduledRoundsDetails: getScheduledRoundsDetails,
35290
35341
  getSchedulingProfile: getSchedulingProfile,
35291
- getSchedulingProfileIssues: getSchedulingProfileIssues
35342
+ getSchedulingProfileIssues: getSchedulingProfileIssues,
35343
+ publicFindCourt: publicFindCourt
35292
35344
  };
35293
35345
 
35294
35346
  function getEntriesAndSeedsCount({ policyDefinitions, drawDefinition, drawSize, drawId, event, stage, }) {
@@ -35787,44 +35839,6 @@ function scheduledSortedMatchUps({ schedulingProfile, matchUps = [] }) {
35787
35839
  return sortedMatchUps;
35788
35840
  }
35789
35841
 
35790
- function courtGridRows({ courtPrefix = 'C|', minRowsCount, courtsData }) {
35791
- if (!Array.isArray(courtsData))
35792
- return { error: INVALID_VALUES };
35793
- const maxCourtOrder = courtsData?.reduce((order, court) => {
35794
- const matchUps = court.matchUps || [];
35795
- const courtOrder = Math.max(0, ...matchUps.map((m) => m.schedule.courtOrder || 0));
35796
- return courtOrder > order ? courtOrder : order;
35797
- }, 1);
35798
- const rowsCount = minRowsCount ? Math.max(minRowsCount, maxCourtOrder) : maxCourtOrder;
35799
- const rowBuilder = generateRange(0, rowsCount).map((rowIndex) => ({
35800
- matchUps: generateRange(0, courtsData.length).map((courtIndex) => {
35801
- const courtInfo = courtsData[courtIndex];
35802
- const { courtId, venueId } = courtInfo;
35803
- return {
35804
- schedule: {
35805
- courtOrder: rowIndex + 1,
35806
- venueId,
35807
- courtId,
35808
- },
35809
- };
35810
- }),
35811
- }));
35812
- courtsData.forEach((courtInfo, i) => {
35813
- for (const matchUp of courtInfo.matchUps) {
35814
- const courtOrder = matchUp.schedule?.courtOrder;
35815
- if (courtOrder) {
35816
- rowBuilder[courtOrder - 1].matchUps[i] = matchUp;
35817
- }
35818
- }
35819
- });
35820
- return {
35821
- courtPrefix,
35822
- rows: rowBuilder.map((row, i) => Object.assign({ rowId: `rowId-${i + 1}` }, ...row.matchUps.map((matchUp, i) => ({
35823
- [`${courtPrefix}${i}`]: matchUp,
35824
- })))),
35825
- };
35826
- }
35827
-
35828
35842
  function eventMatchUps(params) {
35829
35843
  let { participants: tournamentParticipants, contextContent, participantMap } = params;
35830
35844
  const { tournamentAppliedPolicies, scheduleVisibilityFilters, participantsProfile, afterRecoveryTimes, policyDefinitions, useParticipantMap, tournamentRecord, usePublishState, contextFilters, matchUpFilters, contextProfile, nextMatchUps, tournamentId, inContext, context, event, } = params;
@@ -37277,6 +37291,7 @@ var index$f = {
37277
37291
  checkValidEntries: checkValidEntries,
37278
37292
  compareTieFormats: compareTieFormats,
37279
37293
  competitionScheduleMatchUps: competitionScheduleMatchUps,
37294
+ courtGridRows: courtGridRows,
37280
37295
  credits: credits,
37281
37296
  drawMatchUps: drawMatchUps,
37282
37297
  eventMatchUps: eventMatchUps,
@@ -37284,6 +37299,7 @@ var index$f = {
37284
37299
  filterParticipants: filterParticipants,
37285
37300
  findDrawDefinition: publicFindDrawDefinition,
37286
37301
  findExtension: findExtension,
37302
+ findVenue: findVenue,
37287
37303
  getAllDrawMatchUps: getAllDrawMatchUps,
37288
37304
  getAllEventData: getAllEventData,
37289
37305
  getAllStructureMatchUps: getAllStructureMatchUps,
@@ -37382,6 +37398,7 @@ var index$f = {
37382
37398
  participantScaleItem: participantScaleItem,
37383
37399
  participantScheduledMatchUps: participantScheduledMatchUps,
37384
37400
  positionActions: positionActions,
37401
+ publicFindCourt: publicFindCourt,
37385
37402
  publicFindVenue: publicFindVenue,
37386
37403
  tallyParticipantResults: tallyParticipantResults,
37387
37404
  tieFormatGenderValidityCheck: tieFormatGenderValidityCheck,
@@ -38612,7 +38629,16 @@ function deleteDrawDefinitions(params) {
38612
38629
  return { error: result.error };
38613
38630
  }
38614
38631
  if (auditTrail.length) {
38615
- addNotice({ topic: AUDIT, payload: auditTrail });
38632
+ if (hasTopic(AUDIT)) {
38633
+ const tournamentId = tournamentRecord.tournamentId;
38634
+ addNotice({ topic: AUDIT, payload: { tournamentId, detail: auditTrail } });
38635
+ const result = getTimeItem({ element: event, itemType: DRAW_DELETIONS });
38636
+ const itemValue = (result?.timeItem?.itemValue || 0) + 1;
38637
+ addTimeItem({ element: event, timeItem: { itemType: DRAW_DELETIONS, itemValue }, removePriorValues: true });
38638
+ }
38639
+ else {
38640
+ addDrawDeletionTelemetry({ appliedPolicies, event, deletedDrawsDetail, auditData });
38641
+ }
38616
38642
  }
38617
38643
  if (matchUpIds.length) {
38618
38644
  deleteMatchUpsNotice({
@@ -38621,7 +38647,6 @@ function deleteDrawDefinitions(params) {
38621
38647
  });
38622
38648
  }
38623
38649
  drawIds.forEach((drawId) => deleteDrawNotice({ drawId }));
38624
- addDrawDeletionTelemetry({ appliedPolicies, event, deletedDrawsDetail, auditData });
38625
38650
  if (autoPublish && publishedDrawsDeleted) {
38626
38651
  const result = publishEvent({
38627
38652
  ...params.eventDataParams,
@@ -38865,6 +38890,23 @@ function removeTiming({ event }) {
38865
38890
  return removeEventExtension({ event, name: SCHEDULE_TIMING });
38866
38891
  }
38867
38892
 
38893
+ const MON = 'MON';
38894
+ const TUE = 'TUE';
38895
+ const WED = 'WED';
38896
+ const THU = 'THU';
38897
+ const FRI = 'FRI';
38898
+ const SAT = 'SAT';
38899
+ const SUN = 'SUN';
38900
+ const weekdayConstants = { MON, TUE, WED, THU, FRI, SAT, SUN };
38901
+
38902
+ function isValidWeekdaysValue(value) {
38903
+ if (!Array.isArray(value))
38904
+ return false;
38905
+ if (unique(value).length !== value.length)
38906
+ return false;
38907
+ return value.every((v) => Object.keys(weekdayConstants).includes(v));
38908
+ }
38909
+
38868
38910
  function setEventStartDate({ tournamentRecord, event, startDate }) {
38869
38911
  if (!tournamentRecord)
38870
38912
  return { error: MISSING_TOURNAMENT_RECORD };
@@ -38889,7 +38931,8 @@ function setEventStartDate({ tournamentRecord, event, startDate }) {
38889
38931
  event.startDate = startDate;
38890
38932
  return { ...SUCCESS };
38891
38933
  }
38892
- function setEventEndDate({ tournamentRecord, event, endDate }) {
38934
+ function setEventEndDate(params) {
38935
+ const { tournamentRecord, event, endDate } = params;
38893
38936
  if (!tournamentRecord)
38894
38937
  return { error: MISSING_TOURNAMENT_RECORD };
38895
38938
  if (!event)
@@ -38913,23 +38956,42 @@ function setEventEndDate({ tournamentRecord, event, endDate }) {
38913
38956
  event.endDate = endDate;
38914
38957
  return { ...SUCCESS };
38915
38958
  }
38916
- function setEventDates({ tournamentRecord, event, startDate, endDate }) {
38917
- if (!tournamentRecord)
38918
- return { error: MISSING_TOURNAMENT_RECORD };
38919
- if (!event)
38920
- return { error: MISSING_EVENT };
38921
- if (!startDate && !endDate)
38922
- return { error: MISSING_VALUE, info: 'missing date' };
38923
- if (startDate && !dateValidation.test(startDate))
38924
- return { error: INVALID_DATE };
38925
- if (endDate && !dateValidation.test(endDate))
38926
- return { error: INVALID_DATE };
38959
+ function setEventDates(params) {
38960
+ const paramsCheck = checkRequiredParameters(params, [
38961
+ { tournamentRecord: true, event: true },
38962
+ {
38963
+ [VALIDATE]: (value) => dateValidation.test(value),
38964
+ [INVALID]: INVALID_DATE,
38965
+ startDate: false,
38966
+ endDate: false,
38967
+ },
38968
+ {
38969
+ [VALIDATE]: (value) => value.every((d) => dateValidation.test(d)),
38970
+ [INVALID]: INVALID_DATE,
38971
+ activeDates: false,
38972
+ },
38973
+ {
38974
+ [VALIDATE]: isValidWeekdaysValue,
38975
+ weekdays: false,
38976
+ },
38977
+ ]);
38978
+ if (paramsCheck.error)
38979
+ return paramsCheck;
38980
+ const { tournamentRecord, activeDates, weekdays, event, startDate, endDate } = params;
38927
38981
  if (startDate && endDate) {
38928
38982
  const newStartDate = new Date(extractDate(startDate)).getTime();
38929
38983
  const newEndDate = new Date(extractDate(endDate)).getTime();
38930
38984
  if (newStartDate > newEndDate)
38931
38985
  return { error: INVALID_VALUES };
38932
38986
  }
38987
+ if (activeDates) {
38988
+ const start = startDate || tournamentRecord.startDate;
38989
+ const end = endDate || tournamentRecord.endDate;
38990
+ const validStart = !start || activeDates.every((d) => new Date(d) >= new Date(start));
38991
+ const validEnd = !end || activeDates.every((d) => new Date(d) <= new Date(end));
38992
+ if (!validStart || !validEnd)
38993
+ return { error: INVALID_DATE };
38994
+ }
38933
38995
  if (startDate) {
38934
38996
  const result = setEventStartDate({ tournamentRecord, event, startDate });
38935
38997
  if (result.error)
@@ -38940,6 +39002,10 @@ function setEventDates({ tournamentRecord, event, startDate, endDate }) {
38940
39002
  if (result.error)
38941
39003
  return result;
38942
39004
  }
39005
+ if (activeDates)
39006
+ event.activeDates = activeDates;
39007
+ if (weekdays)
39008
+ event.weekdays = weekdays;
38943
39009
  return { ...SUCCESS };
38944
39010
  }
38945
39011
  function getTournamentDates(tournamentRecord) {
@@ -39502,13 +39568,14 @@ function removeSeeding({ tournamentRecord, drawDefinition, entryStatuses, scaleN
39502
39568
  });
39503
39569
  }
39504
39570
 
39505
- function deleteEvents({ removePairParticipants, tournamentRecord, eventIds }) {
39506
- if (!tournamentRecord)
39507
- return { error: MISSING_TOURNAMENT_RECORD };
39508
- if (!tournamentRecord.events)
39509
- return { error: EVENT_NOT_FOUND };
39510
- if (!Array.isArray(eventIds))
39511
- return { error: MISSING_VALUE, info: mustBeAnArray('drawIds') };
39571
+ function deleteEvents(params) {
39572
+ const paramCheck = checkRequiredParameters(params, [
39573
+ { [TOURNAMENT_RECORD]: true },
39574
+ { eventIds: true, [OF_TYPE]: ARRAY },
39575
+ ]);
39576
+ if (paramCheck.error)
39577
+ return paramCheck;
39578
+ const { removePairParticipants, tournamentRecord, eventIds } = params;
39512
39579
  const auditTrail = [];
39513
39580
  const deletedEventDetails = [];
39514
39581
  const activePairParticipantIds = [];
@@ -39549,12 +39616,17 @@ function deleteEvents({ removePairParticipants, tournamentRecord, eventIds }) {
39549
39616
  }
39550
39617
  checkAndUpdateSchedulingProfile({ tournamentRecord });
39551
39618
  if (auditTrail.length) {
39552
- addNotice({ topic: AUDIT, payload: auditTrail });
39553
- const timeItem = {
39554
- itemType: DELETE_EVENTS,
39555
- itemValue: deletedEventDetails,
39556
- };
39557
- addTournamentTimeItem({ tournamentRecord, timeItem });
39619
+ if (hasTopic(AUDIT)) {
39620
+ const tournamentId = tournamentRecord.tournamentId;
39621
+ addNotice({ topic: AUDIT, payload: { type: DELETE_EVENTS, tournamentId, detail: auditTrail } });
39622
+ }
39623
+ else {
39624
+ const timeItem = {
39625
+ itemValue: deletedEventDetails,
39626
+ itemType: DELETE_EVENTS,
39627
+ };
39628
+ addTournamentTimeItem({ tournamentRecord, timeItem });
39629
+ }
39558
39630
  }
39559
39631
  return { ...SUCCESS };
39560
39632
  }
@@ -46098,7 +46170,16 @@ function auditAutoScheduling({ autoSchedulingAudit, tournamentRecords }) {
46098
46170
  itemValue,
46099
46171
  };
46100
46172
  for (const tournamentRecord of Object.values(tournamentRecords)) {
46101
- addTournamentTimeItem({ tournamentRecord, timeItem });
46173
+ const tournamentId = tournamentRecord.tournamentId;
46174
+ if (hasTopic(AUDIT)) {
46175
+ addNotice({
46176
+ payload: { type: AUTO_SCHEDULING_AUDIT, tournamentId, detail: itemValue },
46177
+ topic: AUDIT,
46178
+ });
46179
+ }
46180
+ else {
46181
+ addTournamentTimeItem({ tournamentRecord, timeItem });
46182
+ }
46102
46183
  }
46103
46184
  }
46104
46185
 
@@ -52640,16 +52721,18 @@ function getStructureReports({ firstFlightOnly = true, extensionProfiles, tourna
52640
52721
  [flight.drawId]: flight.flightNumber,
52641
52722
  }));
52642
52723
  const flightMap = flightNumbers && Object.assign({}, ...flightNumbers);
52643
- const drawDeletionsCount = extensions?.find((x) => x.name === DRAW_DELETIONS)?.value?.length || 0;
52724
+ const drawDeletionsExtension = extensions?.find((x) => x.name === DRAW_DELETIONS);
52725
+ const drawDeletionsTimeItem = eventTimeItems?.find((x) => x.itemType === DRAW_DELETIONS);
52726
+ const drawDeletionsCount = drawDeletionsExtension?.value?.length || drawDeletionsTimeItem?.itemValue || 0;
52644
52727
  const mapValues = Object.values(flightMap);
52645
52728
  const minFlightNumber = flightMap && Math.min(...mapValues);
52646
52729
  const eventSeedingBasis = getSeedingBasis(eventTimeItems);
52647
52730
  eventStructureReports[eventId] = {
52731
+ seedingBasis: eventSeedingBasis ? JSON.stringify(eventSeedingBasis) : undefined,
52648
52732
  totalPositionManipulations: 0,
52649
52733
  maxPositionManipulations: 0,
52650
52734
  generatedDrawsCount: 0,
52651
52735
  drawDeletionsCount,
52652
- seedingBasis: eventSeedingBasis ? JSON.stringify(eventSeedingBasis) : undefined,
52653
52736
  tournamentId,
52654
52737
  eventId,
52655
52738
  };
@@ -53959,16 +54042,13 @@ var mutate$3 = {
53959
54042
  calculateScheduleTimes: calculateScheduleTimes,
53960
54043
  clearMatchUpSchedule: clearMatchUpSchedule,
53961
54044
  clearScheduledMatchUps: clearScheduledMatchUps,
53962
- courtGridRows: courtGridRows,
53963
54045
  findMatchUpFormatTiming: findMatchUpFormatTiming,
53964
- findVenue: findVenue,
53965
54046
  generateBookings: generateBookings,
53966
54047
  generateVirtualCourts: generateVirtualCourts,
53967
54048
  matchUpScheduleChange: matchUpScheduleChange,
53968
54049
  modifyMatchUpFormatTiming: modifyMatchUpFormatTiming,
53969
54050
  proAutoSchedule: proAutoSchedule,
53970
54051
  proConflicts: proConflicts,
53971
- publicFindCourt: publicFindCourt,
53972
54052
  removeEventMatchUpFormatTiming: removeEventMatchUpFormatTiming,
53973
54053
  removeMatchUpCourtAssignment: removeMatchUpCourtAssignment,
53974
54054
  reorderUpcomingMatchUps: reorderUpcomingMatchUps,
@@ -55949,19 +56029,39 @@ function updateCourtAvailability({ tournamentRecord }) {
55949
56029
  }
55950
56030
 
55951
56031
  function setTournamentDates(params) {
55952
- const { tournamentRecord, startDate, endDate } = params;
56032
+ const { tournamentRecord, startDate, endDate, activeDates, weekdays } = params;
55953
56033
  const paramsCheck = checkRequiredParameters(params, [
55954
56034
  { tournamentRecord: true },
55955
56035
  {
55956
56036
  [VALIDATE]: (value) => dateValidation.test(value),
55957
- [ANY_OF]: { startDate: false, endDate: false },
55958
56037
  [INVALID]: INVALID_DATE,
56038
+ startDate: false,
56039
+ endDate: false,
56040
+ },
56041
+ {
56042
+ [VALIDATE]: (value) => value.every((d) => dateValidation.test(d)),
56043
+ [INVALID]: INVALID_DATE,
56044
+ activeDates: false,
56045
+ },
56046
+ {
56047
+ [VALIDATE]: isValidWeekdaysValue,
56048
+ weekdays: false,
55959
56049
  },
55960
56050
  ]);
55961
56051
  if (paramsCheck.error)
55962
56052
  return paramsCheck;
55963
56053
  if (endDate && startDate && new Date(endDate) < new Date(startDate))
55964
56054
  return { error: INVALID_VALUES };
56055
+ if (endDate && startDate && new Date(startDate) > new Date(endDate))
56056
+ return { error: INVALID_VALUES };
56057
+ if (activeDates) {
56058
+ const start = startDate || tournamentRecord.startDate;
56059
+ const end = endDate || tournamentRecord.endDate;
56060
+ const validStart = !start || activeDates.every((d) => new Date(d) >= new Date(start));
56061
+ const validEnd = !end || activeDates.every((d) => new Date(d) <= new Date(end));
56062
+ if (!validStart || !validEnd)
56063
+ return { error: INVALID_DATE };
56064
+ }
55965
56065
  let checkScheduling;
55966
56066
  if ((startDate && tournamentRecord.startDate && new Date(startDate) > new Date(tournamentRecord.startDate)) ||
55967
56067
  (endDate && tournamentRecord.endDate && new Date(endDate) < new Date(tournamentRecord.endDate))) {
@@ -55991,23 +56091,33 @@ function setTournamentDates(params) {
55991
56091
  if (endDate && tournamentRecord.startDate && new Date(endDate) < new Date(tournamentRecord.startDate)) {
55992
56092
  tournamentRecord.startDate = endDate;
55993
56093
  }
56094
+ if (activeDates)
56095
+ tournamentRecord.activeDates = activeDates;
56096
+ if (weekdays)
56097
+ tournamentRecord.weekdays = weekdays;
55994
56098
  const unscheduledMatchUpIds = checkScheduling && removeInvalidScheduling({ tournamentRecord })?.unscheduledMatchUpIds;
55995
56099
  updateCourtAvailability({ tournamentRecord });
55996
56100
  addNotice({
55997
- payload: {
56101
+ payload: definedAttributes({
55998
56102
  parentOrganisation: tournamentRecord.parentOrganisation,
55999
56103
  tournamentId: tournamentRecord.tournamentId,
56104
+ activeDates,
56000
56105
  startDate,
56106
+ weekdays,
56001
56107
  endDate,
56002
- },
56108
+ }),
56003
56109
  topic: MODIFY_TOURNAMENT_DETAIL,
56004
56110
  });
56005
56111
  return { ...SUCCESS, unscheduledMatchUpIds, datesAdded, datesRemoved };
56006
56112
  }
56007
56113
  function setTournamentStartDate({ tournamentRecord, startDate }) {
56114
+ if (!startDate)
56115
+ return { error: INVALID_DATE };
56008
56116
  return setTournamentDates({ tournamentRecord, startDate });
56009
56117
  }
56010
56118
  function setTournamentEndDate({ tournamentRecord, endDate }) {
56119
+ if (!endDate)
56120
+ return { error: INVALID_DATE };
56011
56121
  return setTournamentDates({ tournamentRecord, endDate });
56012
56122
  }
56013
56123
  function removeInvalidScheduling({ tournamentRecord }) {
@@ -58797,7 +58907,8 @@ var index = {
58797
58907
  tournamentConstants: tournamentConstants,
58798
58908
  upcomingMatchUpStatuses: upcomingMatchUpStatuses,
58799
58909
  validMatchUpStatuses: validMatchUpStatuses,
58800
- venueConstants: venueConstants
58910
+ venueConstants: venueConstants,
58911
+ weekdayConstants: weekdayConstants
58801
58912
  };
58802
58913
 
58803
58914
  exports.activeMatchUpStatuses = activeMatchUpStatuses;
@@ -58875,4 +58986,5 @@ exports.validMatchUpStatuses = validMatchUpStatuses;
58875
58986
  exports.venueConstants = venueConstants;
58876
58987
  exports.venueGovernor = index$2;
58877
58988
  exports.version = factoryVersion;
58989
+ exports.weekdayConstants = weekdayConstants;
58878
58990
  //# sourceMappingURL=tods-competition-factory.development.cjs.js.map