tods-competition-factory 2.2.39 → 2.2.40

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.
@@ -4626,11 +4626,11 @@ declare function deleteFlightProfileAndFlightDraws({ autoPublish, tournamentReco
4626
4626
  event: any;
4627
4627
  force: any;
4628
4628
  }): {
4629
+ error: any;
4630
+ } | {
4629
4631
  success?: boolean;
4630
4632
  error?: ErrorType;
4631
4633
  info?: any;
4632
- } | {
4633
- error: any;
4634
4634
  };
4635
4635
 
4636
4636
  type ModifyEventMatchUpFormatTimingArgs = {
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  function factoryVersion() {
6
- return '2.2.39';
6
+ return '2.2.40';
7
7
  }
8
8
 
9
9
  const SINGLES_MATCHUP = 'SINGLES';
@@ -1992,8 +1992,15 @@ function getNumber$1(formatstring) {
1992
1992
  }
1993
1993
  function timedSetFormat(matchUpFormatObject) {
1994
1994
  let value = `T${matchUpFormatObject.minutes}`;
1995
- if (matchUpFormatObject.based)
1996
- value += matchUpFormatObject.based;
1995
+ if (matchUpFormatObject.based === 'A') {
1996
+ value += 'A';
1997
+ }
1998
+ else if (matchUpFormatObject.based === 'P') {
1999
+ value += 'P';
2000
+ }
2001
+ if (matchUpFormatObject.tiebreakFormat?.tiebreakTo) {
2002
+ value += `/TB${matchUpFormatObject.tiebreakFormat.tiebreakTo}`;
2003
+ }
1997
2004
  if (matchUpFormatObject.modifier)
1998
2005
  value += `@${matchUpFormatObject.modifier}`;
1999
2006
  return value;
@@ -2103,44 +2110,56 @@ function setsMatch(formatstring) {
2103
2110
  return result;
2104
2111
  }
2105
2112
  function parseSetFormat(formatstring) {
2106
- if (formatstring?.[1] === ':') {
2107
- const parts = formatstring.split(':');
2108
- const setType = setTypes$1[parts[0]];
2109
- const setFormatString = parts[1];
2110
- if (setType && setFormatString) {
2111
- const isTiebreakSet = setFormatString.startsWith('TB');
2112
- if (isTiebreakSet) {
2113
- const tiebreakSet = parseTiebreakFormat(setFormatString);
2114
- if (tiebreakSet === false)
2115
- return false;
2116
- return typeof tiebreakSet === 'object' ? { tiebreakSet } : undefined;
2117
- }
2118
- const timedSet = setFormatString.startsWith('T');
2119
- if (timedSet)
2120
- return parseTimedSet(setFormatString);
2121
- const parts = formatstring.match(/^[FS]:(\d+)([A-Za-z]*)/);
2122
- const NoAD = (parts && isNoAD(parts[2])) || false;
2123
- const validNoAD = !parts?.[2] || NoAD;
2124
- const setTo = parts ? getNumber(parts[1]) : undefined;
2125
- const tiebreakAtValue = parseTiebreakAt(setFormatString);
2126
- const validTiebreakAt = tiebreakAtValue !== false;
2127
- const tiebreakAt = (validTiebreakAt && tiebreakAtValue) || setTo;
2128
- const tiebreakFormat = parseTiebreakFormat(setFormatString.split('/')[1]);
2129
- const validTiebreak = tiebreakFormat !== false;
2130
- const result = { setTo };
2131
- if (NoAD)
2132
- result.NoAD = true;
2133
- if (tiebreakFormat) {
2134
- result.tiebreakFormat = tiebreakFormat;
2135
- result.tiebreakAt = tiebreakAt;
2136
- }
2137
- else {
2138
- result.noTiebreak = true;
2139
- }
2140
- return (setTo && validNoAD && validTiebreak && validTiebreakAt && result) || false;
2141
- }
2113
+ if (formatstring?.[1] !== ':')
2114
+ return undefined;
2115
+ const parts = formatstring.split(':');
2116
+ const setType = setTypes$1[parts[0]];
2117
+ const setFormatString = parts[1];
2118
+ if (!setType || !setFormatString)
2119
+ return undefined;
2120
+ return parseSetFormatString(formatstring, setFormatString);
2121
+ }
2122
+ function parseSetFormatString(formatstring, setFormatString) {
2123
+ if (setFormatString.startsWith('TB')) {
2124
+ return parseTiebreakSetFormat(setFormatString);
2142
2125
  }
2143
- return undefined;
2126
+ if (setFormatString.startsWith('T')) {
2127
+ return parseTimedSet(setFormatString);
2128
+ }
2129
+ return parseStandardSetFormat(formatstring, setFormatString);
2130
+ }
2131
+ function parseTiebreakSetFormat(setFormatString) {
2132
+ const tiebreakSet = parseTiebreakFormat(setFormatString);
2133
+ if (tiebreakSet === false)
2134
+ return false;
2135
+ return typeof tiebreakSet === 'object' ? { tiebreakSet } : undefined;
2136
+ }
2137
+ function parseStandardSetFormat(formatstring, setFormatString) {
2138
+ const parts = /^[FS]:(\d+)([A-Za-z]*)/.exec(formatstring);
2139
+ const NoAD = (parts && isNoAD(parts[2])) || false;
2140
+ const validNoAD = !parts?.[2] || NoAD;
2141
+ const setTo = parts ? getNumber(parts[1]) : undefined;
2142
+ const tiebreakAtValue = parseTiebreakAt(setFormatString);
2143
+ const validTiebreakAt = tiebreakAtValue !== false;
2144
+ const tiebreakAt = (validTiebreakAt && tiebreakAtValue) || setTo;
2145
+ const tiebreakFormat = parseTiebreakFormat(setFormatString.split('/')[1]);
2146
+ const validTiebreak = tiebreakFormat !== false;
2147
+ if (!setTo || !validNoAD || !validTiebreak || !validTiebreakAt)
2148
+ return false;
2149
+ return buildSetFormatResult(setTo, NoAD, tiebreakFormat, tiebreakAt);
2150
+ }
2151
+ function buildSetFormatResult(setTo, NoAD, tiebreakFormat, tiebreakAt) {
2152
+ const result = { setTo };
2153
+ if (NoAD)
2154
+ result.NoAD = true;
2155
+ if (tiebreakFormat) {
2156
+ result.tiebreakFormat = tiebreakFormat;
2157
+ result.tiebreakAt = tiebreakAt;
2158
+ }
2159
+ else {
2160
+ result.noTiebreak = true;
2161
+ }
2162
+ return result;
2144
2163
  }
2145
2164
  function parseTiebreakAt(setFormatString, expectNumber = true) {
2146
2165
  const tiebreakAtValue = setFormatString?.indexOf('@') > 0 && setFormatString.split('@');
@@ -2151,59 +2170,73 @@ function parseTiebreakAt(setFormatString, expectNumber = true) {
2151
2170
  return undefined;
2152
2171
  }
2153
2172
  function parseTiebreakFormat(formatstring) {
2154
- if (formatstring) {
2155
- if (formatstring.startsWith('TB')) {
2156
- const modifier = parseTiebreakAt(formatstring, false);
2157
- const parts = formatstring.match(/^TB(\d+)([A-Za-z]*)/);
2158
- const tiebreakToString = parts?.[1];
2159
- const NoAD = parts && isNoAD(parts[2]);
2160
- const validNoAD = !parts?.[2] || NoAD;
2161
- const tiebreakTo = getNumber(tiebreakToString);
2162
- if (tiebreakTo && validNoAD) {
2163
- const result = { tiebreakTo };
2164
- if (modifier && typeof modifier === 'string' && !isConvertableInteger(modifier)) {
2165
- result.modifier = modifier;
2166
- }
2167
- if (NoAD)
2168
- result.NoAD = true;
2169
- return result;
2170
- }
2171
- else {
2172
- return false;
2173
- }
2174
- }
2175
- else {
2176
- return false;
2177
- }
2173
+ if (!formatstring)
2174
+ return undefined;
2175
+ if (!formatstring.startsWith('TB'))
2176
+ return false;
2177
+ return parseTiebreakDetails(formatstring);
2178
+ }
2179
+ function parseTiebreakDetails(formatstring) {
2180
+ const modifier = parseTiebreakAt(formatstring, false);
2181
+ const parts = /^TB(\d+)([A-Za-z]*)/.exec(formatstring);
2182
+ const tiebreakToString = parts?.[1];
2183
+ const NoAD = parts && isNoAD(parts[2]);
2184
+ const validNoAD = !parts?.[2] || NoAD;
2185
+ const tiebreakTo = getNumber(tiebreakToString);
2186
+ if (!tiebreakTo || !validNoAD)
2187
+ return false;
2188
+ const result = { tiebreakTo };
2189
+ if (modifier && typeof modifier === 'string' && !isConvertableInteger(modifier)) {
2190
+ result.modifier = modifier;
2178
2191
  }
2179
- return undefined;
2192
+ if (NoAD)
2193
+ result.NoAD = true;
2194
+ return result;
2180
2195
  }
2181
2196
  function parseTimedSet(formatstring) {
2182
2197
  const timestring = formatstring.slice(1);
2183
- const parts = timestring.match(/^(\d+)(@?[A-Za-z]*)/);
2198
+ const parts = /^(\d+)([PGA])?(?:\/TB(\d+))?(@?[A-Za-z]*)?/.exec(timestring);
2184
2199
  const minutes = getNumber(parts?.[1]);
2185
2200
  if (!minutes)
2186
2201
  return;
2187
2202
  const setFormat = { timed: true, minutes };
2188
- const based = parts?.[2];
2189
- const validModifier = [undefined, 'P', 'G'].includes(based);
2190
- if (based && !validModifier) {
2191
- const modifier = timestring.match(/^(\d+)(@)([A-Za-z]+)$/)?.[3];
2203
+ const scoringMethod = parts?.[2];
2204
+ if (scoringMethod === 'A') {
2205
+ setFormat.based = 'A';
2206
+ }
2207
+ else if (scoringMethod === 'P') {
2208
+ setFormat.based = 'P';
2209
+ }
2210
+ else if (scoringMethod === 'G') {
2211
+ setFormat.based = 'G';
2212
+ }
2213
+ const setTiebreakTo = parts?.[3];
2214
+ if (setTiebreakTo) {
2215
+ const tiebreakToNumber = getNumber(setTiebreakTo);
2216
+ if (tiebreakToNumber) {
2217
+ setFormat.tiebreakFormat = { tiebreakTo: tiebreakToNumber };
2218
+ }
2219
+ }
2220
+ const legacyModifier = parts?.[4];
2221
+ const validModifier = [undefined, 'P', 'G', ''].includes(legacyModifier);
2222
+ if (legacyModifier && !validModifier) {
2223
+ const modifier = /^(\d+)([PGA])?(?:\/TB\d+)?(@)([A-Za-z]+)$/.exec(timestring)?.[4];
2192
2224
  if (modifier) {
2193
2225
  setFormat.modifier = modifier;
2194
2226
  return setFormat;
2195
2227
  }
2196
2228
  return;
2197
2229
  }
2198
- if (based)
2199
- setFormat.based = parts[2];
2230
+ if (legacyModifier)
2231
+ setFormat.based = legacyModifier;
2200
2232
  return setFormat;
2201
2233
  }
2202
2234
  function isNoAD(formatstring) {
2203
- return formatstring && formatstring.indexOf(NOAD) >= 0;
2235
+ return formatstring?.includes(NOAD);
2204
2236
  }
2205
2237
  function getNumber(formatstring) {
2206
- return !isNaN(Number(formatstring)) ? Number(formatstring) : 0;
2238
+ const num = Number(formatstring);
2239
+ return Number.isNaN(num) ? 0 : num;
2207
2240
  }
2208
2241
 
2209
2242
  function isValidMatchUpFormat({ matchUpFormat }) {
@@ -32429,12 +32462,39 @@ function analyzeScore({ existingMatchUpStatus, matchUpFormat, matchUpStatus, win
32429
32462
  const excessiveSetScore = !setValues.noTiebreak && maxSetScore > setValues.setTo + 1;
32430
32463
  return !excessiveSetScore;
32431
32464
  });
32432
- const calculatedWinningSide = ((!matchUpFormat || maxSetsCount === setsToWin) &&
32433
- maxSetsInstances === 1 &&
32434
- setsWinCounts.indexOf(maxSetsCount) + 1) ||
32435
- undefined;
32465
+ const isAggregateScoring = matchUpScoringFormat?.setFormat?.based === 'A' || matchUpScoringFormat?.finalSetFormat?.based === 'A';
32466
+ let calculatedWinningSide;
32467
+ if (isAggregateScoring && sets.length > 0) {
32468
+ const aggregateTotals = sets.reduce((totals, set) => {
32469
+ if (set.side1Score !== undefined || set.side2Score !== undefined) {
32470
+ totals[0] += set.side1Score ?? 0;
32471
+ totals[1] += set.side2Score ?? 0;
32472
+ }
32473
+ return totals;
32474
+ }, [0, 0]);
32475
+ if (aggregateTotals[0] > aggregateTotals[1]) {
32476
+ calculatedWinningSide = 1;
32477
+ }
32478
+ else if (aggregateTotals[1] > aggregateTotals[0]) {
32479
+ calculatedWinningSide = 2;
32480
+ }
32481
+ else {
32482
+ const tiebreakSet = sets.find((set) => set.side1TiebreakScore !== undefined || set.side2TiebreakScore !== undefined);
32483
+ if (tiebreakSet) {
32484
+ calculatedWinningSide = tiebreakSet.winningSide;
32485
+ }
32486
+ }
32487
+ }
32488
+ else {
32489
+ calculatedWinningSide =
32490
+ ((!matchUpFormat || maxSetsCount === setsToWin) &&
32491
+ maxSetsInstances === 1 &&
32492
+ setsWinCounts.indexOf(maxSetsCount) + 1) ||
32493
+ undefined;
32494
+ }
32436
32495
  const valid = !!(validSets &&
32437
- ((winningSide && winningSideSetsCount > losingSideSetsCount && winningSide === calculatedWinningSide) ||
32496
+ ((winningSide && isAggregateScoring && winningSide === calculatedWinningSide) ||
32497
+ (winningSide && !isAggregateScoring && winningSideSetsCount > losingSideSetsCount && winningSide === calculatedWinningSide) ||
32438
32498
  (winningSide && irregularEnding) ||
32439
32499
  (!winningSide &&
32440
32500
  !calculatedWinningSide &&