tods-competition-factory 2.1.5 → 2.1.6

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.5';
6
+ return '2.1.6';
7
7
  }
8
8
 
9
9
  function isFunction(obj) {
@@ -10439,7 +10439,7 @@ const logColors = {
10439
10439
 
10440
10440
  const globalLog = [];
10441
10441
  function pushGlobalLog(value, devContextOverride) {
10442
- if (typeof value === 'string')
10442
+ if (isString(value))
10443
10443
  value = { method: value };
10444
10444
  if (devContextOverride || getDevContext())
10445
10445
  globalLog.push(value);
@@ -40222,12 +40222,11 @@ function generateStatCrew(params) {
40222
40222
  if (paramsCheck.error)
40223
40223
  return paramsCheck;
40224
40224
  const { tournamentRecord } = params;
40225
- const { startDate, tournamentId } = tournamentRecord;
40225
+ const { startDate, tournamentId, tournamentName } = tournamentRecord;
40226
40226
  const teamParticipants = tournamentRecord.participants.filter((participant) => participant.participantType === TEAM);
40227
40227
  const homeTeam = teamParticipants?.find((team) => team.participantRoleResponsibilities?.includes('Home'));
40228
40228
  const awayTeams = teamParticipants?.filter((team) => team.participantId !== homeTeam?.participantId);
40229
40229
  const date = formatDate(startDate, '/', 'MDY');
40230
- const neutralGame = !homeTeam ? 'Y' : 'N';
40231
40230
  const homename = homeTeam?.participantName || awayTeams?.[1]?.participantName;
40232
40231
  const homeid = homeTeam?.participantId || awayTeams?.[1]?.participantId;
40233
40232
  const visname = awayTeams?.[0]?.participantName;
@@ -40243,26 +40242,47 @@ function generateStatCrew(params) {
40243
40242
  const tieValue = sideNumber === 1 ? side1TiebreakScore : side2TiebreakScore;
40244
40243
  return { [setKey]: setValue, [tbKey]: tieValue };
40245
40244
  }) ?? []));
40246
- const getParticipantAttibutes = ({ matchUpId, participant }) => {
40247
- const name = !participant.individualParticipants ? participant.participantName : undefined;
40245
+ const getParticipantAttibutes = ({ participant }) => {
40246
+ const pair = participant.individualParticipants?.length === 2;
40247
+ const pairTeamParticipantIds = pair
40248
+ ? unique(participant.individualParticipants?.map((p) => p.teams?.[0]?.participantId))
40249
+ : [];
40250
+ const pairTeamIds = pair ? unique(participant.individualParticipants?.map((p) => p.teams?.[0]?.teamId)) : [];
40251
+ const teamParticipantId = (!pair && participant.teams?.[0]?.participantId) ||
40252
+ (pairTeamParticipantIds?.length === 1 && pairTeamParticipantIds[0]) ||
40253
+ undefined;
40254
+ const team = (!pair && participant.teams?.[0]?.teamId) || (pairTeamIds?.length === 1 && pairTeamIds[0]) || teamParticipantId;
40255
+ const name = !pair ? participant.participantName : undefined;
40248
40256
  const name_1 = participant.individualParticipants?.[0]?.participantName;
40249
40257
  const name_2 = participant.individualParticipants?.[1]?.participantName;
40250
- const vh = matchUpId === homeid ? 'H' : 'V';
40251
- return definedAttributes({ vh, name, name_1, name_2 });
40258
+ const vh = (homeid && (teamParticipantId === homeid ? 'H' : 'V')) || '';
40259
+ return definedAttributes({ vh, team, name, name_1, name_2 });
40252
40260
  };
40253
40261
  const mapMatchUp = (matchUp) => {
40254
- const { collectionPosition: match, orderOfFinish: order, matchUpId, matchUpType, sides } = matchUp;
40262
+ const { collectionPosition: match, orderOfFinish: order, matchUpType, sides } = matchUp;
40255
40263
  const childArray = sides?.map((side) => {
40256
40264
  const { sideNumber, participant } = side;
40257
40265
  const scoreAttributes = getScoreAttributes({ sets: matchUp.score?.sets, sideNumber });
40258
40266
  const scoreType = matchUpType === SINGLES ? 'singles_score' : 'doubles_score';
40259
- return { [scoreType]: { ...getParticipantAttibutes({ matchUpId, participant }), ...scoreAttributes } };
40267
+ return { [scoreType]: { ...getParticipantAttibutes({ participant }), ...scoreAttributes } };
40260
40268
  });
40261
40269
  const matchType = matchUpType === SINGLES ? 'singles_match' : 'doubles_match';
40262
40270
  return { [matchType]: { match, order, childArray } };
40263
40271
  };
40264
40272
  const json = {
40265
- venue: { gameid: tournamentId, date, neutralGame, homeid, homename, visid, visname, officials: {}, rules: {} },
40273
+ venue: {
40274
+ tournament: teamParticipants?.length > 2 ? 'Y' : 'N',
40275
+ neutralgame: !homeTeam ? 'Y' : 'N',
40276
+ tournamentname: tournamentName,
40277
+ gameid: tournamentId,
40278
+ officials: {},
40279
+ rules: {},
40280
+ homename,
40281
+ visname,
40282
+ homeid,
40283
+ visid,
40284
+ date,
40285
+ },
40266
40286
  singles_matches: singles?.map(mapMatchUp),
40267
40287
  doubles_matches: doubles?.map(mapMatchUp),
40268
40288
  };
@@ -42326,7 +42346,13 @@ function removeDirectedLoser({ sourceMatchUpStatus, loserParticipantId, tourname
42326
42346
  }
42327
42347
  function removeDirectedBye({ inContextDrawMatchUps, tournamentRecord, drawDefinition, drawPosition, matchUpsMap, targetLink, event, }) {
42328
42348
  const structureId = targetLink.target.structureId;
42329
- clearDrawPosition({
42349
+ const stack = 'removeDirectedBye';
42350
+ pushGlobalLog({
42351
+ color: 'brightyellow',
42352
+ method: stack,
42353
+ drawPosition,
42354
+ });
42355
+ const result = clearDrawPosition({
42330
42356
  inContextDrawMatchUps,
42331
42357
  tournamentRecord,
42332
42358
  drawDefinition,
@@ -42335,7 +42361,7 @@ function removeDirectedBye({ inContextDrawMatchUps, tournamentRecord, drawDefini
42335
42361
  structureId,
42336
42362
  event,
42337
42363
  });
42338
- return { ...SUCCESS };
42364
+ return decorateResult({ result, stack });
42339
42365
  }
42340
42366
 
42341
42367
  function lastSetFormatIsTimed(inContextMatchUp) {
@@ -42979,24 +43005,27 @@ const keyColors = {
42979
43005
  };
42980
43006
  function removeDoubleExit(params) {
42981
43007
  const { inContextDrawMatchUps, appliedPolicies, drawDefinition, matchUpsMap, targetData, matchUp } = params;
43008
+ const { matchUpId } = matchUp;
42982
43009
  let { iteration = 0 } = params;
42983
43010
  iteration += 1;
42984
43011
  const stack = 'removeDoubleExit';
42985
43012
  pushGlobalLog({
42986
- method: stack,
42987
43013
  color: 'brightyellow',
43014
+ method: stack,
43015
+ matchUpId,
42988
43016
  iteration,
42989
43017
  keyColors,
42990
43018
  });
42991
- const { targetLinks: { loserTargetLink }, targetMatchUps: { loserMatchUp, winnerMatchUp, loserTargetDrawPosition }, } = targetData;
43019
+ const { targetMatchUps: { loserMatchUp, winnerMatchUp, loserTargetDrawPosition }, targetLinks: { loserTargetLink }, } = targetData;
42992
43020
  if (winnerMatchUp && winnerMatchUp.matchUpStatus !== BYE) {
42993
- const { stage, roundNumber, roundPosition } = winnerMatchUp;
43021
+ const { stage, roundNumber, roundPosition, structureName } = winnerMatchUp;
42994
43022
  pushGlobalLog({
42995
43023
  winner: 'winner',
42996
- stage,
42997
- roundNumber,
42998
43024
  roundPosition,
43025
+ structureName,
43026
+ roundNumber,
42999
43027
  keyColors,
43028
+ stage,
43000
43029
  });
43001
43030
  conditionallyRemoveDrawPosition({
43002
43031
  ...params,
@@ -43005,22 +43034,24 @@ function removeDoubleExit(params) {
43005
43034
  iteration,
43006
43035
  });
43007
43036
  }
43008
- if (loserMatchUp && loserMatchUp.matchUpStatus !== BYE) {
43037
+ const byePropagatedToLoserMatchUp = loserMatchUp?.matchUpStatus === BYE && (loserMatchUp?.feedRound || loserMatchUp?.roundNumber === 1);
43038
+ if (loserMatchUp && (loserMatchUp.matchUpStatus !== BYE || byePropagatedToLoserMatchUp)) {
43009
43039
  const inContextLoserMatchUp = inContextDrawMatchUps.find(({ matchUpId }) => matchUpId === loserMatchUp.matchUpId);
43010
43040
  const { structure: loserStructure } = findStructure({
43011
43041
  drawDefinition,
43012
43042
  structureId: inContextLoserMatchUp.structureId,
43013
43043
  });
43014
- const { stage, roundNumber, roundPosition, feedRound } = loserMatchUp;
43044
+ const { stage, roundNumber, roundPosition, feedRound, structureName } = loserMatchUp;
43015
43045
  pushGlobalLog({
43016
43046
  loser: 'loser',
43017
- stage,
43018
- roundNumber,
43019
43047
  roundPosition,
43048
+ structureName,
43049
+ roundNumber,
43020
43050
  keyColors,
43021
43051
  feedRound,
43052
+ stage,
43022
43053
  });
43023
- if (appliedPolicies?.progression?.doubleExitPropagateBye) {
43054
+ if (appliedPolicies?.progression?.doubleExitPropagateBye || byePropagatedToLoserMatchUp) {
43024
43055
  removeDirectedBye({
43025
43056
  drawPosition: loserTargetDrawPosition,
43026
43057
  targetLink: loserTargetLink,
@@ -43032,8 +43063,8 @@ function removeDoubleExit(params) {
43032
43063
  else {
43033
43064
  const result = conditionallyRemoveDrawPosition({
43034
43065
  ...params,
43035
- structure: loserStructure,
43036
43066
  targetMatchUp: loserMatchUp,
43067
+ structure: loserStructure,
43037
43068
  iteration,
43038
43069
  });
43039
43070
  if (result.error)
@@ -43045,7 +43076,7 @@ function removeDoubleExit(params) {
43045
43076
  function conditionallyRemoveDrawPosition(params) {
43046
43077
  const { inContextDrawMatchUps, appliedPolicies, drawDefinition, sourceMatchUp, targetMatchUp, matchUpsMap, structure, iteration, } = params;
43047
43078
  const stack = 'conditionallyRemoveDrawPosition';
43048
- pushGlobalLog({ method: stack });
43079
+ pushGlobalLog({ method: stack, structureName: structure?.structureName, iteration });
43049
43080
  const nextTargetData = positionTargets({
43050
43081
  matchUpId: targetMatchUp.matchUpId,
43051
43082
  inContextDrawMatchUps,
@@ -43085,15 +43116,16 @@ function conditionallyRemoveDrawPosition(params) {
43085
43116
  }
43086
43117
  }
43087
43118
  if (nextWinnerMatchUp && drawPositionToRemove) {
43088
- const { stage, roundNumber, roundPosition } = nextWinnerMatchUp;
43119
+ const { stage, roundNumber, roundPosition, structureName } = nextWinnerMatchUp;
43089
43120
  pushGlobalLog({
43090
43121
  method: 'removeDirectedWinner',
43091
43122
  drawPositionToRemove,
43092
- keyColors,
43093
43123
  color: 'brightgreen',
43094
- stage,
43095
- roundNumber,
43096
43124
  roundPosition,
43125
+ structureName,
43126
+ roundNumber,
43127
+ keyColors,
43128
+ stage,
43097
43129
  });
43098
43130
  removeDirectedWinner({
43099
43131
  winningDrawPosition: drawPositionToRemove,