tods-competition-factory 1.8.38 → 1.8.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.
package/dist/index.mjs CHANGED
@@ -2404,7 +2404,7 @@ const matchUpFormatCode = {
2404
2404
  };
2405
2405
 
2406
2406
  function factoryVersion() {
2407
- return "1.8.38";
2407
+ return "1.8.40";
2408
2408
  }
2409
2409
 
2410
2410
  function getObjectTieFormat(obj) {
@@ -20760,6 +20760,8 @@ function getDrawDefinition$1({
20760
20760
  }
20761
20761
 
20762
20762
  function bulkScheduleMatchUps$1({
20763
+ scheduleCompletedMatchUps = false,
20764
+ scheduleByeMatchUps = false,
20763
20765
  errorOnAnachronism = false,
20764
20766
  checkChronology = true,
20765
20767
  matchUpDependencies,
@@ -20789,11 +20791,13 @@ function bulkScheduleMatchUps$1({
20789
20791
  })?.matchUps ?? [];
20790
20792
  }
20791
20793
  const drawIdMap = inContextMatchUps.reduce((drawIdMap2, matchUp) => {
20792
- const { matchUpId, drawId } = matchUp;
20793
- if (drawIdMap2[drawId]) {
20794
- drawIdMap2[drawId].push(matchUpId);
20795
- } else {
20796
- drawIdMap2[drawId] = [matchUpId];
20794
+ const { matchUpId, drawId, matchUpStatus } = matchUp;
20795
+ if ((scheduleByeMatchUps || matchUpStatus !== BYE) && (scheduleCompletedMatchUps || !completedMatchUpStatuses.includes(matchUpStatus))) {
20796
+ if (drawIdMap2[drawId]) {
20797
+ drawIdMap2[drawId].push(matchUpId);
20798
+ } else {
20799
+ drawIdMap2[drawId] = [matchUpId];
20800
+ }
20797
20801
  }
20798
20802
  return drawIdMap2;
20799
20803
  }, {});
@@ -20838,6 +20842,8 @@ function bulkScheduleMatchUps$1({
20838
20842
  }
20839
20843
 
20840
20844
  function bulkScheduleMatchUps({
20845
+ scheduleCompletedMatchUps = false,
20846
+ scheduleByeMatchUps = false,
20841
20847
  errorOnAnachronism,
20842
20848
  matchUpContextIds,
20843
20849
  tournamentRecords,
@@ -20865,6 +20871,8 @@ function bulkScheduleMatchUps({
20865
20871
  if (matchUpIds?.length || tournamentMatchUpDetails?.length) {
20866
20872
  const result = bulkScheduleMatchUps$1({
20867
20873
  matchUpDetails: tournamentMatchUpDetails,
20874
+ scheduleCompletedMatchUps,
20875
+ scheduleByeMatchUps,
20868
20876
  matchUpDependencies,
20869
20877
  errorOnAnachronism,
20870
20878
  tournamentRecords,
@@ -27584,6 +27592,7 @@ function getParticipantEntries(params) {
27584
27592
  continue;
27585
27593
  const {
27586
27594
  drawDefinitions = [],
27595
+ extensions = [],
27587
27596
  eventType,
27588
27597
  eventName,
27589
27598
  category,
@@ -27598,7 +27607,9 @@ function getParticipantEntries(params) {
27598
27607
  if (publishStatuses)
27599
27608
  eventsPublishStatuses[eventId] = publishStatuses;
27600
27609
  if (withEvents || withSeeding || withRankingProfile) {
27610
+ const extensionConversions = convertExtensions ? Object.assign({}, ...extensionsToAttributes(extensions)) : {};
27601
27611
  derivedEventInfo[eventId] = {
27612
+ ...extensionConversions,
27602
27613
  eventName,
27603
27614
  eventType,
27604
27615
  category,
@@ -32549,10 +32560,14 @@ function processAlreadyScheduledMatchUps({
32549
32560
  minutesMap,
32550
32561
  matchUps
32551
32562
  }) {
32563
+ const byeScheduledMatchUpIds = [];
32552
32564
  if (!dateScheduledMatchUpIds) {
32553
32565
  dateScheduledMatchUps = matchUps?.filter((matchUp) => {
32554
32566
  const schedule = matchUp.schedule || {};
32555
- return hasSchedule({ schedule }) && (!scheduleDate || matchUp.schedule.scheduledDate === scheduleDate);
32567
+ const isByeMatchUp = matchUp.matchUpStatus === BYE;
32568
+ if (isByeMatchUp)
32569
+ byeScheduledMatchUpIds.push(matchUp.matchUpId);
32570
+ return !isByeMatchUp && hasSchedule({ schedule }) && (!scheduleDate || matchUp.schedule.scheduledDate === scheduleDate);
32556
32571
  });
32557
32572
  dateScheduledMatchUpIds = dateScheduledMatchUps.map(getMatchUpId);
32558
32573
  }
@@ -32584,7 +32599,12 @@ function processAlreadyScheduledMatchUps({
32584
32599
  });
32585
32600
  }
32586
32601
  }
32587
- return { clearDate, dateScheduledMatchUpIds, dateScheduledMatchUps };
32602
+ return {
32603
+ dateScheduledMatchUpIds,
32604
+ byeScheduledMatchUpIds,
32605
+ dateScheduledMatchUps,
32606
+ clearDate
32607
+ };
32588
32608
  }
32589
32609
 
32590
32610
  function getGroupedRounds({
@@ -32722,7 +32742,7 @@ function generateBookings({
32722
32742
  });
32723
32743
  }
32724
32744
  const relevantMatchUps = dateScheduledMatchUps?.filter(
32725
- (matchUp) => !venueIds.length || venueIds.includes(matchUp.schedule.venueId)
32745
+ (matchUp) => (!venueIds.length || venueIds.includes(matchUp.schedule.venueId)) && matchUp.matchUpStatus !== BYE
32726
32746
  );
32727
32747
  const bookings = relevantMatchUps?.map(({ eventId, schedule, matchUpFormat }) => {
32728
32748
  const { event, scheduleTiming } = eventDetails[eventId];
@@ -32839,6 +32859,7 @@ function getVenueSchedulingDetails({
32839
32859
  }) {
32840
32860
  const venueScheduledRoundDetails = {};
32841
32861
  const allDateScheduledMatchUpIds = [];
32862
+ const allDateScheduledByeMatchUpIds = [];
32842
32863
  const allDateMatchUpIds = [];
32843
32864
  for (const venue of venues) {
32844
32865
  const { rounds = [], venueId } = venue;
@@ -32888,8 +32909,10 @@ function getVenueSchedulingDetails({
32888
32909
  minutesMap,
32889
32910
  matchUps
32890
32911
  });
32891
- const clearDate = processResult.clearDate;
32892
32912
  ({ dateScheduledMatchUpIds, dateScheduledMatchUps } = processResult);
32913
+ const { byeScheduledMatchUpIds, clearDate } = processResult;
32914
+ if (byeScheduledMatchUpIds?.length)
32915
+ allDateScheduledByeMatchUpIds.push(...byeScheduledMatchUpIds);
32893
32916
  const { matchUpsToSchedule, matchUpMap } = getMatchUpsToSchedule({
32894
32917
  matchUpPotentialParticipantIds,
32895
32918
  scheduleCompletedMatchUps,
@@ -32920,6 +32943,7 @@ function getVenueSchedulingDetails({
32920
32943
  }
32921
32944
  }
32922
32945
  return {
32946
+ allDateScheduledByeMatchUpIds,
32923
32947
  allDateScheduledMatchUpIds,
32924
32948
  venueScheduledRoundDetails,
32925
32949
  allDateMatchUpIds
@@ -33495,6 +33519,7 @@ function proScheduler({
33495
33519
  }
33496
33520
  });
33497
33521
  const {
33522
+ allDateScheduledByeMatchUpIds,
33498
33523
  allDateScheduledMatchUpIds,
33499
33524
  venueScheduledRoundDetails,
33500
33525
  allDateMatchUpIds
@@ -33776,6 +33801,7 @@ function proScheduler({
33776
33801
  getMatchUpId
33777
33802
  );
33778
33803
  }
33804
+ if (!dryRun && allDateScheduledByeMatchUpIds?.length) ;
33779
33805
  for (const venue of dateSchedulingProfile.venues) {
33780
33806
  for (const round of venue.rounds) {
33781
33807
  const matchUpIds = (round.matchUps ?? []).map(
@@ -34960,7 +34986,7 @@ function getRoundProfile(matchUps) {
34960
34986
  ({ winningSide, matchUpStatus }) => winningSide || completedMatchUpStatuses.includes(matchUpStatus)
34961
34987
  ).length || 0;
34962
34988
  const scheduledCount = matchUps.filter(
34963
- ({ schedule }) => schedule?.scheduledDate && schedule?.scheduledTime
34989
+ ({ schedule, matchUpStatus }) => schedule?.scheduledDate && schedule?.scheduledTime && matchUpStatus !== BYE
34964
34990
  ).length || 0;
34965
34991
  const consideredCount = matchUpsCount - byeCount;
34966
34992
  const isComplete = consideredCount === completedCount;
@@ -58154,7 +58180,8 @@ function deleteFlightAndFlightDraw({
58154
58180
  tournamentRecord,
58155
58181
  auditData,
58156
58182
  drawId,
58157
- event
58183
+ event,
58184
+ force
58158
58185
  }) {
58159
58186
  if (!tournamentRecord)
58160
58187
  return { error: MISSING_TOURNAMENT_RECORD };
@@ -58191,7 +58218,8 @@ function deleteFlightAndFlightDraw({
58191
58218
  tournamentRecord,
58192
58219
  autoPublish,
58193
58220
  auditData,
58194
- event
58221
+ event,
58222
+ force
58195
58223
  });
58196
58224
  if (result.error)
58197
58225
  return result;
@@ -59415,7 +59443,11 @@ function generateDrawDefinition(params) {
59415
59443
  tournamentRecord,
59416
59444
  event
59417
59445
  }).appliedPolicies ?? {};
59418
- const policyDefinitions = params.policyDefinitions ?? {};
59446
+ const policyDefinitions = makeDeepCopy(
59447
+ params.policyDefinitions ?? {},
59448
+ false,
59449
+ true
59450
+ );
59419
59451
  const drawTypeCoercion = params.drawTypeCoercion ?? policyDefinitions?.[POLICY_TYPE_DRAWS]?.drawTypeCoercion ?? appliedPolicies?.[POLICY_TYPE_DRAWS]?.drawTypeCoercion ?? true;
59420
59452
  const drawType = drawTypeCoercion && params.drawSize === 2 && DrawTypeEnum.SingleElimination || params.drawType || DrawTypeEnum.SingleElimination;
59421
59453
  const seedingPolicy = policyDefinitions?.[POLICY_TYPE_SEEDING] ?? appliedPolicies?.[POLICY_TYPE_SEEDING];