tods-competition-factory 0.200.0 → 0.201.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.
@@ -249,7 +249,7 @@ const matchUpFormatCode = {
249
249
  };
250
250
 
251
251
  function factoryVersion() {
252
- return '0.200.0';
252
+ return '0.201.2';
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
 
@@ -11995,9 +11997,9 @@ function targetByRoundOutcome({
11995
11997
  source
11996
11998
  }
11997
11999
  } = getRoundLinks({
11998
- drawDefinition,
11999
12000
  roundNumber: matchUp.roundNumber,
12000
- structureId: structure.structureId
12001
+ structureId: structure.structureId,
12002
+ drawDefinition
12001
12003
  });
12002
12004
  const winnerTargetLink = getTargetLink({
12003
12005
  source,
@@ -12027,6 +12029,14 @@ function targetByRoundOutcome({
12027
12029
  const useBruteForce = winnerTargetLink && !winnerMatchUp || loserTargetLink && !loserMatchUp;
12028
12030
 
12029
12031
  if (useBruteForce) {
12032
+ if (getDevContext({
12033
+ qualifying: true
12034
+ })) {
12035
+ console.log({
12036
+ useBruteForce
12037
+ });
12038
+ }
12039
+
12030
12040
  const {
12031
12041
  roundPosition: sourceRoundPosition
12032
12042
  } = matchUp;
@@ -12063,11 +12073,26 @@ function targetByRoundOutcome({
12063
12073
  targetLink: winnerTargetLink
12064
12074
  }));
12065
12075
  }
12076
+
12077
+ if (getDevContext({
12078
+ qualifying: true
12079
+ })) {
12080
+ console.log(sourceRoundPosition, sourceRoundMatchUpCount, winnerTargetLink, winnerMatchUp);
12081
+ }
12066
12082
  }
12067
12083
 
12068
12084
  if (!winnerMatchUp) {
12069
12085
  // if there is no winnerTargetLink then find targetMatchUp in next round
12070
12086
  structureMatchUps = structureMatchUps || inContextDrawMatchUps.filter(matchUp => matchUp.structureId === structure.structureId);
12087
+
12088
+ if (getDevContext({
12089
+ qualifying: true
12090
+ })) {
12091
+ console.log('no winner matcnUp', {
12092
+ structureMatchUps
12093
+ });
12094
+ }
12095
+
12071
12096
  ({
12072
12097
  matchUp: winnerMatchUp
12073
12098
  } = nextRoundMatchUp({
@@ -12343,7 +12368,7 @@ function getNextToBePlayedMatchUp({
12343
12368
 
12344
12369
  function getUpcomingInfo({
12345
12370
  upcomingMatchUp
12346
- } = {}) {
12371
+ }) {
12347
12372
  if (!upcomingMatchUp) return;
12348
12373
  return (({
12349
12374
  matchUpId,
@@ -12478,12 +12503,17 @@ function getStructureMatchUps({
12478
12503
  */
12479
12504
 
12480
12505
  function getAllDrawMatchUps(params) {
12481
- if (!params.drawDefinition) return {
12482
- error: MISSING_DRAW_DEFINITION
12483
- };
12506
+ const stack = 'getAllDrawMatchUps';
12484
12507
  Object.assign(params, {
12485
12508
  requireParticipants: false
12486
12509
  });
12510
+ const result = getDrawMatchUps({ ...params,
12511
+ contextProfile: params.contextProfile
12512
+ });
12513
+ if (result.error) return decorateResult({
12514
+ result,
12515
+ stack
12516
+ });
12487
12517
  const {
12488
12518
  abandonedMatchUps,
12489
12519
  completedMatchUps,
@@ -12491,7 +12521,7 @@ function getAllDrawMatchUps(params) {
12491
12521
  pendingMatchUps,
12492
12522
  byeMatchUps,
12493
12523
  matchUpsMap
12494
- } = getDrawMatchUps(params);
12524
+ } = result;
12495
12525
  const matchUps = [].concat(...abandonedMatchUps, ...completedMatchUps, ...upcomingMatchUps, ...pendingMatchUps, ...byeMatchUps);
12496
12526
  return {
12497
12527
  matchUps,
@@ -15406,7 +15436,7 @@ function getMatchUpFormatMap({
15406
15436
  }
15407
15437
  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
15438
  'winnerMatchUpId', 'loserMatchUpId', 'matchUpDuration', 'winningSide'];
15409
- function removeExtraneousAttributes(matchUps, matchUpFormatMap = {}) {
15439
+ function removeExtraneousAttributes(matchUps, matchUpFormatMap) {
15410
15440
  for (const matchUp of matchUps) {
15411
15441
  const {
15412
15442
  structureId,
@@ -17707,7 +17737,7 @@ function tournamentRelevantSchedulingIds({
17707
17737
  tournamentRecord = {},
17708
17738
  tournamentMap = {},
17709
17739
  requireCourts
17710
- } = {}) {
17740
+ }) {
17711
17741
  const drawIds = [];
17712
17742
  const eventIds = [];
17713
17743
  const structureIds = [];
@@ -17775,7 +17805,7 @@ function tournamentRelevantSchedulingIds({
17775
17805
  }
17776
17806
  function getAllRelevantSchedulingIds({
17777
17807
  tournamentRecords = {}
17778
- } = {}) {
17808
+ }) {
17779
17809
  const records = tournamentRecords && Object.values(tournamentRecords) || [];
17780
17810
  const tournamentsMap = {};
17781
17811
  const {
@@ -23552,7 +23582,7 @@ function noDownstreamDependencies(params) {
23552
23582
 
23553
23583
  const removeDirected = ({
23554
23584
  removeScore
23555
- } = {}) => {
23585
+ }) => {
23556
23586
  let connectedStructures;
23557
23587
  const {
23558
23588
  structure,
@@ -23652,6 +23682,11 @@ function isActiveDownstream(params) {
23652
23682
  },
23653
23683
  targetLinks
23654
23684
  } = targetData;
23685
+ if (getDevContext({
23686
+ qualifying: true
23687
+ })) console.log({
23688
+ targetData
23689
+ });
23655
23690
  const loserMatchUpWalkover = [WALKOVER$2].includes(loserMatchUp === null || loserMatchUp === void 0 ? void 0 : loserMatchUp.matchUpStatus);
23656
23691
  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
23692
 
@@ -23894,6 +23929,9 @@ function setMatchUpStatus$2(params) {
23894
23929
  const targetData = positionTargets({
23895
23930
  matchUpId: matchUpTieId || matchUpId,
23896
23931
  // get targets for TEAM matchUp if tieMatchUp
23932
+ useTargetMatchUpIds: getDevContext({
23933
+ useTargetMatchUpIds: true
23934
+ }),
23897
23935
  inContextDrawMatchUps,
23898
23936
  drawDefinition
23899
23937
  });
@@ -24044,9 +24082,16 @@ function winningSideWithDownstreamDependencies(params) {
24044
24082
  if (winningSide === matchUp.winningSide || matchUpTieId && !dualWinningSideChange) {
24045
24083
  return applyMatchUpValues(params);
24046
24084
  } else {
24047
- return {
24048
- error: CANNOT_CHANGE_WINNING_SIDE
24049
- };
24085
+ return decorateResult({
24086
+ result: {
24087
+ error: CANNOT_CHANGE_WINNING_SIDE
24088
+ },
24089
+ stack: 'winningSideWithDownstreamDependencies',
24090
+ context: {
24091
+ winningSide,
24092
+ matchUp
24093
+ }
24094
+ });
24050
24095
  }
24051
24096
  }
24052
24097
 
@@ -24625,7 +24670,7 @@ function deletionMessage({
24625
24670
  function validTimePeriod({
24626
24671
  startTime,
24627
24672
  endTime
24628
- } = {}) {
24673
+ }) {
24629
24674
  if (!timeValidation.test(startTime) || !timeValidation.test(endTime)) return false;
24630
24675
  const [startHour, startMinute] = startTime.split(':');
24631
24676
  const [endHour, endMinute] = endTime.split(':');
@@ -40255,7 +40300,10 @@ function positionParticipantAction(params) {
40255
40300
  matchUpsMap,
40256
40301
  event
40257
40302
  });
40258
- if (!result.success) return result;
40303
+ if (!result.success) return decorateResult({
40304
+ result,
40305
+ stack
40306
+ });
40259
40307
  return successNotice({
40260
40308
  removedParticipantId
40261
40309
  });
@@ -40283,9 +40331,14 @@ function positionParticipantAction(params) {
40283
40331
  drawDefinition,
40284
40332
  positionAction
40285
40333
  });
40286
- return { ...SUCCESS,
40287
- removedParticipantId
40288
- };
40334
+ return decorateResult({
40335
+ result: { ...SUCCESS,
40336
+ context: {
40337
+ removedParticipantId
40338
+ },
40339
+ stack
40340
+ }
40341
+ });
40289
40342
  }
40290
40343
  }
40291
40344
 
@@ -40451,7 +40504,7 @@ function getAssignedParticipantIds({
40451
40504
 
40452
40505
  function refreshEntryPositions({
40453
40506
  entries = []
40454
- } = {}) {
40507
+ }) {
40455
40508
  const stagedEntries = entries.filter(Boolean).reduce((stages, entry) => {
40456
40509
  const {
40457
40510
  entryStage,
@@ -45013,7 +45066,7 @@ function newDrawDefinition({
45013
45066
  drawId = UUID(),
45014
45067
  matchUpType,
45015
45068
  drawType
45016
- } = {}) {
45069
+ }) {
45017
45070
  const drawDefinition = definitionTemplate();
45018
45071
  return Object.assign(drawDefinition, {
45019
45072
  drawId,
@@ -45335,7 +45388,7 @@ function getState$1({
45335
45388
  convertExtensions,
45336
45389
  removeExtensions,
45337
45390
  tournamentId
45338
- } = {}) {
45391
+ }) {
45339
45392
  if (typeof tournamentId !== 'string') return {};
45340
45393
  const tournamentRecord = getTournamentRecord(tournamentId);
45341
45394
  return {
@@ -46198,7 +46251,7 @@ function getState({
46198
46251
  convertExtensions,
46199
46252
  removeExtensions,
46200
46253
  tournamentId
46201
- } = {}) {
46254
+ }) {
46202
46255
  if (typeof tournamentId !== 'string') return {};
46203
46256
  const tournamentRecord = getTournamentRecord(tournamentId);
46204
46257
  return {
@@ -56793,7 +56846,7 @@ function generatePersons({
56793
56846
  count = 1,
56794
56847
  category,
56795
56848
  sex
56796
- } = {}) {
56849
+ }) {
56797
56850
  if (isNaN(count)) return {
56798
56851
  error: INVALID_VALUES
56799
56852
  };
@@ -56974,7 +57027,7 @@ var namesData = [
56974
57027
  function nameMocks({
56975
57028
  nameRoot = 'TEAM',
56976
57029
  count = 1
56977
- } = {}) {
57030
+ }) {
56978
57031
  const shuffledTeamNames = shuffleArray(namesData);
56979
57032
  const names = shuffledTeamNames.slice(0, count);
56980
57033
 
@@ -57348,7 +57401,7 @@ var citiesData = [
57348
57401
  function cityMocks({
57349
57402
  count = 1,
57350
57403
  participantsCount = 32
57351
- } = {}) {
57404
+ }) {
57352
57405
  const shuffledCities = shuffleArray(citiesData);
57353
57406
  const candidateCities = shuffledCities.slice(0, count); // the following ensures that all of the generated items are used at least once
57354
57407
 
@@ -57360,7 +57413,7 @@ function cityMocks({
57360
57413
  function stateMocks({
57361
57414
  count = 1,
57362
57415
  participantsCount = 32
57363
- } = {}) {
57416
+ }) {
57364
57417
  const shuffledStates = shuffleArray(statesData);
57365
57418
  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
57366
57419
 
@@ -57372,7 +57425,7 @@ function stateMocks({
57372
57425
  function postalCodeMocks({
57373
57426
  count = 1,
57374
57427
  participantsCount = 32
57375
- } = {}) {
57428
+ }) {
57376
57429
  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
57377
57430
 
57378
57431
  const postalCodes = generateRange(0, participantsCount).map(i => i < count ? candidatePostalCodes[i] : randomMember(candidatePostalCodes));
@@ -60011,14 +60064,17 @@ function generateVenues({
60011
60064
  if (result.error) return result;
60012
60065
  venueIds.push(venueId);
60013
60066
  const dates = dateRange(startDate, endDate);
60014
- dateAvailability = !Array.isArray(dateAvailability) && dates.map(date => ({
60067
+ const generatedDateAvailability = !Array.isArray(dateAvailability) && [{
60068
+ startTime,
60069
+ endTime
60070
+ }].concat(dates.map(date => ({
60015
60071
  date: formatDate(date),
60016
60072
  startTime,
60017
60073
  endTime
60018
- })) || dateAvailability;
60074
+ })));
60019
60075
  result = addCourts$1({
60076
+ dateAvailability: dateAvailability || generatedDateAvailability,
60020
60077
  tournamentRecord,
60021
- dateAvailability,
60022
60078
  courtTimings,
60023
60079
  courtsCount,
60024
60080
  courtNames,