tods-competition-factory 0.199.2 → 0.201.1

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.199.2';
252
+ return '0.201.1';
253
253
  }
254
254
 
255
255
  function decorateResult({
@@ -267,7 +267,7 @@ function decorateResult({
267
267
  result.error.info = info;
268
268
  }
269
269
 
270
- if (typeof context === 'object') {
270
+ if (typeof context === 'object' && Object.keys(context).length) {
271
271
  result = Object.assign(result, context);
272
272
  }
273
273
 
@@ -303,7 +303,7 @@ function isConvertableInteger(n) {
303
303
  return Number.isSafeInteger(typeof n === 'string' ? +n : n);
304
304
  } // produces an approximated normal distribution between 0 and max
305
305
 
306
- function weightedRandom(max = 1, weight = 3, round = true) {
306
+ function weightedRandom(max = 1, weight, round = true) {
307
307
  let num = 0;
308
308
 
309
309
  for (let i = 0; i < weight; i++) {
@@ -4027,7 +4027,7 @@ function getHighTiebreakValue({
4027
4027
  lowValue = 0,
4028
4028
  NoAD = false,
4029
4029
  tiebreakTo
4030
- } = {}) {
4030
+ }) {
4031
4031
  const winBy = NoAD ? 1 : 2;
4032
4032
 
4033
4033
  if (lowValue + 1 >= tiebreakTo) {
@@ -5562,7 +5562,7 @@ function findCategoryTiming({
5562
5562
  function findMatchupFormatAverageTimes({
5563
5563
  matchUpAverageTimes,
5564
5564
  matchUpFormat
5565
- } = {}) {
5565
+ }) {
5566
5566
  // first find all matchUpAverageTime definitions which include matchUpFormats...
5567
5567
  // ... that either exactly match or start with the target matchUpFormat.
5568
5568
  const codeMatches = (matchUpAverageTimes === null || matchUpAverageTimes === void 0 ? void 0 : matchUpAverageTimes.map(({
@@ -5586,7 +5586,7 @@ function findMatchupFormatRecoveryTimes({
5586
5586
  matchUpRecoveryTimes,
5587
5587
  averageMinutes,
5588
5588
  matchUpFormat
5589
- } = {}) {
5589
+ }) {
5590
5590
  var _matchUpRecoveryTimes;
5591
5591
 
5592
5592
  return matchUpRecoveryTimes === null || matchUpRecoveryTimes === void 0 ? void 0 : (_matchUpRecoveryTimes = matchUpRecoveryTimes.find(({
@@ -7102,7 +7102,7 @@ function getRoundMatchUps$1({
7102
7102
 
7103
7103
  function getMatchUpType({
7104
7104
  matchUp = {}
7105
- } = {}) {
7105
+ }) {
7106
7106
  var _matchUp$sides;
7107
7107
 
7108
7108
  let matchUpType = matchUp.matchUpType;
@@ -7465,7 +7465,7 @@ function isValidExtension(extension) {
7465
7465
  function addExtension$1({
7466
7466
  element,
7467
7467
  extension
7468
- } = {}) {
7468
+ }) {
7469
7469
  if (!element) return {
7470
7470
  error: MISSING_VALUE
7471
7471
  };
@@ -7496,7 +7496,7 @@ function addExtension$1({
7496
7496
  function removeExtension$1({
7497
7497
  element,
7498
7498
  name
7499
- } = {}) {
7499
+ }) {
7500
7500
  if (!element) return {
7501
7501
  error: MISSING_VALUE
7502
7502
  };
@@ -9379,7 +9379,9 @@ function getAllStructureMatchUps({
9379
9379
  });
9380
9380
  }
9381
9381
 
9382
- if (contextProfile !== null && contextProfile !== void 0 && contextProfile.inferGender && !matchUpWithContext.gender && ((_matchUpWithContext$s = matchUpWithContext.sides) === null || _matchUpWithContext$s === void 0 ? void 0 : _matchUpWithContext$s.length) === 2 && matchUpWithContext.matchUpType !== TEAM$2) {
9382
+ const inferGender = (contextProfile === null || contextProfile === void 0 ? void 0 : contextProfile.inferGender) && !matchUpWithContext.gender && ((_matchUpWithContext$s = matchUpWithContext.sides) === null || _matchUpWithContext$s === void 0 ? void 0 : _matchUpWithContext$s.length) === 2 && matchUpWithContext.matchUpType !== TEAM$2; // if (contextProfile) console.log({ contextProfile, inferGender });
9383
+
9384
+ if (inferGender) {
9383
9385
  const sideGenders = matchUpWithContext.sides.map(side => {
9384
9386
  var _side$participant2, _side$participant2$pe, _side$individualParti;
9385
9387
 
@@ -12343,7 +12345,7 @@ function getNextToBePlayedMatchUp({
12343
12345
 
12344
12346
  function getUpcomingInfo({
12345
12347
  upcomingMatchUp
12346
- } = {}) {
12348
+ }) {
12347
12349
  if (!upcomingMatchUp) return;
12348
12350
  return (({
12349
12351
  matchUpId,
@@ -12478,12 +12480,17 @@ function getStructureMatchUps({
12478
12480
  */
12479
12481
 
12480
12482
  function getAllDrawMatchUps(params) {
12481
- if (!params.drawDefinition) return {
12482
- error: MISSING_DRAW_DEFINITION
12483
- };
12483
+ const stack = 'getAllDrawMatchUps';
12484
12484
  Object.assign(params, {
12485
12485
  requireParticipants: false
12486
12486
  });
12487
+ const result = getDrawMatchUps({ ...params,
12488
+ contextProfile: params.contextProfile
12489
+ });
12490
+ if (result.error) return decorateResult({
12491
+ result,
12492
+ stack
12493
+ });
12487
12494
  const {
12488
12495
  abandonedMatchUps,
12489
12496
  completedMatchUps,
@@ -12491,7 +12498,7 @@ function getAllDrawMatchUps(params) {
12491
12498
  pendingMatchUps,
12492
12499
  byeMatchUps,
12493
12500
  matchUpsMap
12494
- } = getDrawMatchUps(params);
12501
+ } = result;
12495
12502
  const matchUps = [].concat(...abandonedMatchUps, ...completedMatchUps, ...upcomingMatchUps, ...pendingMatchUps, ...byeMatchUps);
12496
12503
  return {
12497
12504
  matchUps,
@@ -15406,7 +15413,7 @@ function getMatchUpFormatMap({
15406
15413
  }
15407
15414
  const baseAttributeKeys = ['collectionId', 'collectionPosition', 'drawPositions', 'extensions', 'finishingPositionRange', 'finishingRound', 'isMock', 'matchUpId', 'matchUpStatus', 'matchUpStatusCodes', 'orderOfFinish', 'processCodes', 'roundNumber', 'tieFormat', 'tieMatchUps', 'roundPosition', 'score', 'sides', // can be removed only if drawPositions is present and is not a TEAM matchUp
15408
15415
  'winnerMatchUpId', 'loserMatchUpId', 'matchUpDuration', 'winningSide'];
15409
- function removeExtraneousAttributes(matchUps, matchUpFormatMap = {}) {
15416
+ function removeExtraneousAttributes(matchUps, matchUpFormatMap) {
15410
15417
  for (const matchUp of matchUps) {
15411
15418
  const {
15412
15419
  structureId,
@@ -17707,7 +17714,7 @@ function tournamentRelevantSchedulingIds({
17707
17714
  tournamentRecord = {},
17708
17715
  tournamentMap = {},
17709
17716
  requireCourts
17710
- } = {}) {
17717
+ }) {
17711
17718
  const drawIds = [];
17712
17719
  const eventIds = [];
17713
17720
  const structureIds = [];
@@ -17775,7 +17782,7 @@ function tournamentRelevantSchedulingIds({
17775
17782
  }
17776
17783
  function getAllRelevantSchedulingIds({
17777
17784
  tournamentRecords = {}
17778
- } = {}) {
17785
+ }) {
17779
17786
  const records = tournamentRecords && Object.values(tournamentRecords) || [];
17780
17787
  const tournamentsMap = {};
17781
17788
  const {
@@ -23552,7 +23559,7 @@ function noDownstreamDependencies(params) {
23552
23559
 
23553
23560
  const removeDirected = ({
23554
23561
  removeScore
23555
- } = {}) => {
23562
+ }) => {
23556
23563
  let connectedStructures;
23557
23564
  const {
23558
23565
  structure,
@@ -23652,6 +23659,11 @@ function isActiveDownstream(params) {
23652
23659
  },
23653
23660
  targetLinks
23654
23661
  } = targetData;
23662
+ if (getDevContext({
23663
+ qualifying: true
23664
+ })) console.log({
23665
+ targetData
23666
+ });
23655
23667
  const loserMatchUpWalkover = [WALKOVER$2].includes(loserMatchUp === null || loserMatchUp === void 0 ? void 0 : loserMatchUp.matchUpStatus);
23656
23668
  const winnerDrawPositionsCount = (winnerMatchUp === null || winnerMatchUp === void 0 ? void 0 : (_winnerMatchUp$drawPo = winnerMatchUp.drawPositions) === null || _winnerMatchUp$drawPo === void 0 ? void 0 : _winnerMatchUp$drawPo.filter(Boolean).length) || 0;
23657
23669
 
@@ -24044,9 +24056,16 @@ function winningSideWithDownstreamDependencies(params) {
24044
24056
  if (winningSide === matchUp.winningSide || matchUpTieId && !dualWinningSideChange) {
24045
24057
  return applyMatchUpValues(params);
24046
24058
  } else {
24047
- return {
24048
- error: CANNOT_CHANGE_WINNING_SIDE
24049
- };
24059
+ return decorateResult({
24060
+ result: {
24061
+ error: CANNOT_CHANGE_WINNING_SIDE
24062
+ },
24063
+ stack: 'winningSideWithDownstreamDependencies',
24064
+ context: {
24065
+ winningSide,
24066
+ matchUp
24067
+ }
24068
+ });
24050
24069
  }
24051
24070
  }
24052
24071
 
@@ -24625,7 +24644,7 @@ function deletionMessage({
24625
24644
  function validTimePeriod({
24626
24645
  startTime,
24627
24646
  endTime
24628
- } = {}) {
24647
+ }) {
24629
24648
  if (!timeValidation.test(startTime) || !timeValidation.test(endTime)) return false;
24630
24649
  const [startHour, startMinute] = startTime.split(':');
24631
24650
  const [endHour, endMinute] = endTime.split(':');
@@ -40166,6 +40185,7 @@ function positionParticipantAction(params) {
40166
40185
  structureId,
40167
40186
  event
40168
40187
  } = params;
40188
+ const stack = 'positionParticipantAction';
40169
40189
  if (!drawDefinition) return {
40170
40190
  error: MISSING_DRAW_DEFINITION
40171
40191
  };
@@ -40206,6 +40226,7 @@ function positionParticipantAction(params) {
40206
40226
  const positionAssignment = positionAssignments.find(assignment => assignment.drawPosition === drawPosition);
40207
40227
 
40208
40228
  if (positionAssignment !== null && positionAssignment !== void 0 && positionAssignment.participantId) {
40229
+ const removedParticipantId = positionAssignment.participantId;
40209
40230
  let result = assignDrawPosition$1({
40210
40231
  inContextDrawMatchUps,
40211
40232
  tournamentRecord,
@@ -40217,13 +40238,14 @@ function positionParticipantAction(params) {
40217
40238
  });
40218
40239
 
40219
40240
  if (!result.success) {
40220
- console.log({
40221
- result
40241
+ return decorateResult({
40242
+ result,
40243
+ stack
40222
40244
  });
40223
40245
  }
40224
40246
 
40225
40247
  return successNotice({
40226
- removedParticipantId: positionAssignment.participantId
40248
+ removedParticipantId
40227
40249
  });
40228
40250
  }
40229
40251
 
@@ -40236,7 +40258,10 @@ function positionParticipantAction(params) {
40236
40258
  matchUpsMap,
40237
40259
  event
40238
40260
  });
40239
- if (result.error) return result;
40261
+ if (result.error) return decorateResult({
40262
+ result,
40263
+ stack
40264
+ });
40240
40265
  const removedParticipantId = result.participantId;
40241
40266
  result = assignDrawPosition$1({
40242
40267
  inContextDrawMatchUps,
@@ -40249,7 +40274,10 @@ function positionParticipantAction(params) {
40249
40274
  matchUpsMap,
40250
40275
  event
40251
40276
  });
40252
- if (!result.success) return result;
40277
+ if (!result.success) return decorateResult({
40278
+ result,
40279
+ stack
40280
+ });
40253
40281
  return successNotice({
40254
40282
  removedParticipantId
40255
40283
  });
@@ -40277,9 +40305,14 @@ function positionParticipantAction(params) {
40277
40305
  drawDefinition,
40278
40306
  positionAction
40279
40307
  });
40280
- return { ...SUCCESS,
40281
- removedParticipantId
40282
- };
40308
+ return decorateResult({
40309
+ result: { ...SUCCESS,
40310
+ context: {
40311
+ removedParticipantId
40312
+ },
40313
+ stack
40314
+ }
40315
+ });
40283
40316
  }
40284
40317
  }
40285
40318
 
@@ -40445,7 +40478,7 @@ function getAssignedParticipantIds({
40445
40478
 
40446
40479
  function refreshEntryPositions({
40447
40480
  entries = []
40448
- } = {}) {
40481
+ }) {
40449
40482
  const stagedEntries = entries.filter(Boolean).reduce((stages, entry) => {
40450
40483
  const {
40451
40484
  entryStage,
@@ -45007,7 +45040,7 @@ function newDrawDefinition({
45007
45040
  drawId = UUID(),
45008
45041
  matchUpType,
45009
45042
  drawType
45010
- } = {}) {
45043
+ }) {
45011
45044
  const drawDefinition = definitionTemplate();
45012
45045
  return Object.assign(drawDefinition, {
45013
45046
  drawId,
@@ -45329,7 +45362,7 @@ function getState$1({
45329
45362
  convertExtensions,
45330
45363
  removeExtensions,
45331
45364
  tournamentId
45332
- } = {}) {
45365
+ }) {
45333
45366
  if (typeof tournamentId !== 'string') return {};
45334
45367
  const tournamentRecord = getTournamentRecord(tournamentId);
45335
45368
  return {
@@ -46192,7 +46225,7 @@ function getState({
46192
46225
  convertExtensions,
46193
46226
  removeExtensions,
46194
46227
  tournamentId
46195
- } = {}) {
46228
+ }) {
46196
46229
  if (typeof tournamentId !== 'string') return {};
46197
46230
  const tournamentRecord = getTournamentRecord(tournamentId);
46198
46231
  return {
@@ -51568,7 +51601,7 @@ function luckyLoserDrawPositionAssignment(params) {
51568
51601
  }
51569
51602
 
51570
51603
  function qualifierDrawPositionAssignment$1({
51571
- qualifierParticipantId,
51604
+ qualifyingParticipantId,
51572
51605
  tournamentRecord,
51573
51606
  drawDefinition,
51574
51607
  drawPosition,
@@ -51576,7 +51609,7 @@ function qualifierDrawPositionAssignment$1({
51576
51609
  }) {
51577
51610
  return positionParticipantAction({
51578
51611
  positionActionName: 'qualifierDrawPositionAssignment',
51579
- participantId: qualifierParticipantId,
51612
+ participantId: qualifyingParticipantId,
51580
51613
  isQualifierPoasition: true,
51581
51614
  tournamentRecord,
51582
51615
  drawDefinition,
@@ -56787,7 +56820,7 @@ function generatePersons({
56787
56820
  count = 1,
56788
56821
  category,
56789
56822
  sex
56790
- } = {}) {
56823
+ }) {
56791
56824
  if (isNaN(count)) return {
56792
56825
  error: INVALID_VALUES
56793
56826
  };
@@ -56968,7 +57001,7 @@ var namesData = [
56968
57001
  function nameMocks({
56969
57002
  nameRoot = 'TEAM',
56970
57003
  count = 1
56971
- } = {}) {
57004
+ }) {
56972
57005
  const shuffledTeamNames = shuffleArray(namesData);
56973
57006
  const names = shuffledTeamNames.slice(0, count);
56974
57007
 
@@ -57342,7 +57375,7 @@ var citiesData = [
57342
57375
  function cityMocks({
57343
57376
  count = 1,
57344
57377
  participantsCount = 32
57345
- } = {}) {
57378
+ }) {
57346
57379
  const shuffledCities = shuffleArray(citiesData);
57347
57380
  const candidateCities = shuffledCities.slice(0, count); // the following ensures that all of the generated items are used at least once
57348
57381
 
@@ -57354,7 +57387,7 @@ function cityMocks({
57354
57387
  function stateMocks({
57355
57388
  count = 1,
57356
57389
  participantsCount = 32
57357
- } = {}) {
57390
+ }) {
57358
57391
  const shuffledStates = shuffleArray(statesData);
57359
57392
  const candidateStates = shuffledStates.slice(0, count).map(state => Object.keys(state)).flat(); // the following ensures that all of the generated items are used at least once
57360
57393
 
@@ -57366,7 +57399,7 @@ function stateMocks({
57366
57399
  function postalCodeMocks({
57367
57400
  count = 1,
57368
57401
  participantsCount = 32
57369
- } = {}) {
57402
+ }) {
57370
57403
  const candidatePostalCodes = generateRange(0, count).map(() => generateRange(0, 5).map(() => randomInt(0, 9)).join('')); // the following ensures that all of the generated items are used at least once
57371
57404
 
57372
57405
  const postalCodes = generateRange(0, participantsCount).map(i => i < count ? candidatePostalCodes[i] : randomMember(candidatePostalCodes));
@@ -60005,14 +60038,17 @@ function generateVenues({
60005
60038
  if (result.error) return result;
60006
60039
  venueIds.push(venueId);
60007
60040
  const dates = dateRange(startDate, endDate);
60008
- dateAvailability = !Array.isArray(dateAvailability) && dates.map(date => ({
60041
+ const generatedDateAvailability = !Array.isArray(dateAvailability) && [{
60042
+ startTime,
60043
+ endTime
60044
+ }].concat(dates.map(date => ({
60009
60045
  date: formatDate(date),
60010
60046
  startTime,
60011
60047
  endTime
60012
- })) || dateAvailability;
60048
+ })));
60013
60049
  result = addCourts$1({
60050
+ dateAvailability: dateAvailability || generatedDateAvailability,
60014
60051
  tournamentRecord,
60015
- dateAvailability,
60016
60052
  courtTimings,
60017
60053
  courtsCount,
60018
60054
  courtNames,