tods-competition-factory 1.8.46 → 1.9.0

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.
@@ -1214,7 +1214,7 @@ function isString(obj) {
1214
1214
  return typeof obj === "string";
1215
1215
  }
1216
1216
  function isObject(obj) {
1217
- return typeof obj === "object";
1217
+ return obj !== null && typeof obj === "object";
1218
1218
  }
1219
1219
  const extractAttributes = (accessor) => (element) => !accessor || typeof element !== "object" ? void 0 : Array.isArray(accessor) && accessor.map((a) => ({
1220
1220
  [a]: getAccessorValue({ element, accessor: a })?.value
@@ -2214,6 +2214,7 @@ const RESUME_TIME = "SCHEDULE.TIME.RESUME";
2214
2214
  const END_TIME = "SCHEDULE.TIME.END";
2215
2215
  const TIME_MODIFIERS = "SCHEDULE.TIME.MODIFIERS";
2216
2216
  const PUBLISH = "PUBLISH";
2217
+ const PUBLIC = "PUBLIC";
2217
2218
  const STATUS = "STATUS";
2218
2219
 
2219
2220
  function getTimeStamp(item) {
@@ -2436,8 +2437,10 @@ function getMatchUpScheduleDetails({
2436
2437
  scheduleVisibilityFilters,
2437
2438
  afterRecoveryTimes,
2438
2439
  tournamentRecord,
2440
+ usePublishState,
2439
2441
  scheduleTiming,
2440
2442
  matchUpFormat,
2443
+ publishStatus,
2441
2444
  matchUpType,
2442
2445
  matchUp,
2443
2446
  event
@@ -2554,15 +2557,36 @@ function getMatchUpScheduleDetails({
2554
2557
  });
2555
2558
  } else {
2556
2559
  schedule = definedAttributes({
2557
- time,
2560
+ milliseconds,
2558
2561
  startTime,
2559
2562
  endTime,
2560
- milliseconds
2563
+ time
2561
2564
  });
2562
2565
  }
2563
- const hasCompletedStatus = matchUp.matchUpStatus && completedMatchUpStatuses.includes(matchUp.matchUpStatus);
2564
2566
  const { scheduledDate } = scheduledMatchUpDate({ matchUp });
2565
2567
  const { scheduledTime } = scheduledMatchUpTime({ matchUp });
2568
+ if (usePublishState && publishStatus?.displaySettings?.draws) {
2569
+ const drawSettings = publishStatus.displaySettings.draws;
2570
+ const scheduleDetails = (drawSettings?.[matchUp.drawId] ?? drawSettings?.default)?.scheduleDetails;
2571
+ if (scheduleDetails) {
2572
+ const scheduleAttributes = (scheduleDetails.find(
2573
+ (details) => scheduledDate && details.dates?.includes(scheduledDate)
2574
+ ) ?? scheduleDetails.find((details) => !details.dates?.length))?.attributes;
2575
+ if (scheduleAttributes) {
2576
+ const template = Object.assign(
2577
+ {},
2578
+ ...Object.keys(schedule).map((key) => ({ [key]: true })),
2579
+ // overwrite with publishStatus attributes
2580
+ scheduleAttributes
2581
+ );
2582
+ schedule = attributeFilter({
2583
+ source: schedule,
2584
+ template
2585
+ });
2586
+ }
2587
+ }
2588
+ }
2589
+ const hasCompletedStatus = matchUp.matchUpStatus && completedMatchUpStatuses.includes(matchUp.matchUpStatus);
2566
2590
  const endDate = hasCompletedStatus && (extractDate(endTime) || extractDate(scheduledDate) || extractDate(scheduledTime)) || void 0;
2567
2591
  return { schedule, endDate };
2568
2592
  }
@@ -4505,6 +4529,7 @@ function getAllStructureMatchUps({
4505
4529
  policyDefinitions,
4506
4530
  tournamentRecord,
4507
4531
  seedAssignments,
4532
+ usePublishState,
4508
4533
  contextFilters,
4509
4534
  contextContent,
4510
4535
  matchUpFilters,
@@ -4512,6 +4537,7 @@ function getAllStructureMatchUps({
4512
4537
  scheduleTiming,
4513
4538
  contextProfile,
4514
4539
  drawDefinition,
4540
+ publishStatus,
4515
4541
  context = {},
4516
4542
  exitProfiles,
4517
4543
  matchUpsMap,
@@ -4620,6 +4646,8 @@ function getAllStructureMatchUps({
4620
4646
  roundNamingProfile,
4621
4647
  initialRoundOfPlay,
4622
4648
  appliedPolicies,
4649
+ usePublishState,
4650
+ publishStatus,
4623
4651
  isRoundRobin,
4624
4652
  roundProfile,
4625
4653
  matchUp,
@@ -4689,6 +4717,8 @@ function getAllStructureMatchUps({
4689
4717
  tieDrawPositions,
4690
4718
  appliedPolicies: appliedPolicies2,
4691
4719
  isCollectionBye,
4720
+ usePublishState: usePublishState2,
4721
+ publishStatus: publishStatus2,
4692
4722
  matchUpTieId,
4693
4723
  isRoundRobin: isRoundRobin2,
4694
4724
  roundProfile: roundProfile2,
@@ -4714,8 +4744,10 @@ function getAllStructureMatchUps({
4714
4744
  scheduleVisibilityFilters: scheduleVisibilityFilters2,
4715
4745
  afterRecoveryTimes,
4716
4746
  tournamentRecord,
4747
+ usePublishState: usePublishState2,
4717
4748
  scheduleTiming,
4718
4749
  matchUpFormat,
4750
+ publishStatus: publishStatus2,
4719
4751
  matchUpType,
4720
4752
  matchUp,
4721
4753
  event: event2
@@ -4838,7 +4870,7 @@ function getAllStructureMatchUps({
4838
4870
  Object.assign(matchUpWithContext, makeDeepCopy({ sides }, true, true));
4839
4871
  }
4840
4872
  if (tournamentParticipants && matchUpWithContext.sides) {
4841
- const participantAttributes = policyDefinitions?.[POLICY_TYPE_PARTICIPANT];
4873
+ const participantAttributes = appliedPolicies2?.[POLICY_TYPE_PARTICIPANT];
4842
4874
  const getMappedParticipant = (participantId) => {
4843
4875
  const participant = participantMap?.[participantId]?.participant;
4844
4876
  return participant && attributeFilter({
@@ -4954,6 +4986,8 @@ function getAllStructureMatchUps({
4954
4986
  additionalContext: additionalContext2,
4955
4987
  appliedPolicies: appliedPolicies2,
4956
4988
  isCollectionBye: isCollectionBye2,
4989
+ usePublishState: usePublishState2,
4990
+ publishStatus: publishStatus2,
4957
4991
  matchUpTieId: matchUpTieId2,
4958
4992
  isRoundRobin: isRoundRobin2,
4959
4993
  roundProfile: roundProfile2,
@@ -5866,6 +5900,64 @@ function getSeedPattern(seedingProfile) {
5866
5900
  return seedingProfile.positioning;
5867
5901
  }
5868
5902
 
5903
+ function getTimeItem({
5904
+ returnPreviousValues,
5905
+ itemSubTypes,
5906
+ itemType,
5907
+ element
5908
+ }) {
5909
+ if (!element)
5910
+ return { error: MISSING_VALUE, info: ELEMENT_REQUIRED };
5911
+ if (itemSubTypes && !Array.isArray(itemSubTypes))
5912
+ return { error: INVALID_VALUES, context: { itemSubTypes } };
5913
+ if (!Array.isArray(element.timeItems))
5914
+ return { error: MISSING_TIME_ITEMS };
5915
+ const filteredSorted = element.timeItems.filter((timeItem2) => timeItem2?.itemType === itemType).filter(
5916
+ (timeItem2) => !itemSubTypes?.length || itemSubTypes.some(
5917
+ (subType) => timeItem2?.itemSubTypes?.includes(subType)
5918
+ )
5919
+ ).sort((a, b) => {
5920
+ const aDate = new Date(a.createdAt || void 0).getTime();
5921
+ const bDate = new Date(b.createdAt || void 0).getTime();
5922
+ return aDate - bDate;
5923
+ });
5924
+ const timeItem = filteredSorted.pop();
5925
+ if (timeItem) {
5926
+ const result = { timeItem, ...SUCCESS };
5927
+ if (returnPreviousValues)
5928
+ Object.assign(result, { previousItems: filteredSorted });
5929
+ return result;
5930
+ } else {
5931
+ return { info: NOT_FOUND };
5932
+ }
5933
+ }
5934
+ function getEventTimeItem({
5935
+ returnPreviousValues,
5936
+ itemSubTypes,
5937
+ itemType,
5938
+ event
5939
+ }) {
5940
+ if (!event)
5941
+ return { error: MISSING_EVENT };
5942
+ if (!event.timeItems)
5943
+ return { info: NOT_FOUND };
5944
+ const { timeItem, previousItems, info } = getTimeItem({
5945
+ returnPreviousValues,
5946
+ element: event,
5947
+ itemSubTypes,
5948
+ itemType
5949
+ });
5950
+ return timeItem && { timeItem, previousItems } || { info };
5951
+ }
5952
+
5953
+ function getEventPublishStatus({ event, status = PUBLIC }) {
5954
+ const itemType = `${PUBLISH}.${STATUS}`;
5955
+ return getEventTimeItem({
5956
+ itemType,
5957
+ event
5958
+ })?.timeItem?.itemValue?.[status];
5959
+ }
5960
+
5869
5961
  function addParticipantGroupings({
5870
5962
  participantsProfile,
5871
5963
  participants = [],
@@ -7724,38 +7816,6 @@ function addIndividualParticipants({ participantMap, template }) {
7724
7816
  }
7725
7817
  }
7726
7818
 
7727
- function getTimeItem({
7728
- returnPreviousValues,
7729
- itemSubTypes,
7730
- itemType,
7731
- element
7732
- }) {
7733
- if (!element)
7734
- return { error: MISSING_VALUE, info: ELEMENT_REQUIRED };
7735
- if (itemSubTypes && !Array.isArray(itemSubTypes))
7736
- return { error: INVALID_VALUES, context: { itemSubTypes } };
7737
- if (!Array.isArray(element.timeItems))
7738
- return { error: MISSING_TIME_ITEMS };
7739
- const filteredSorted = element.timeItems.filter((timeItem2) => timeItem2?.itemType === itemType).filter(
7740
- (timeItem2) => !itemSubTypes?.length || itemSubTypes.some(
7741
- (subType) => timeItem2?.itemSubTypes?.includes(subType)
7742
- )
7743
- ).sort((a, b) => {
7744
- const aDate = new Date(a.createdAt || void 0).getTime();
7745
- const bDate = new Date(b.createdAt || void 0).getTime();
7746
- return aDate - bDate;
7747
- });
7748
- const timeItem = filteredSorted.pop();
7749
- if (timeItem) {
7750
- const result = { timeItem, ...SUCCESS };
7751
- if (returnPreviousValues)
7752
- Object.assign(result, { previousItems: filteredSorted });
7753
- return result;
7754
- } else {
7755
- return { info: NOT_FOUND };
7756
- }
7757
- }
7758
-
7759
7819
  const typeMap = {
7760
7820
  [GROUP]: "groupParticipantIds",
7761
7821
  [PAIR]: "pairParticipantIds",
@@ -8483,11 +8543,13 @@ function getStructureMatchUps({
8483
8543
  afterRecoveryTimes,
8484
8544
  policyDefinitions,
8485
8545
  tournamentRecord,
8546
+ usePublishState,
8486
8547
  matchUpFilters,
8487
8548
  contextFilters,
8488
8549
  contextContent,
8489
8550
  participantMap,
8490
8551
  scheduleTiming,
8552
+ publishStatus,
8491
8553
  contextProfile,
8492
8554
  drawDefinition,
8493
8555
  exitProfiles,
@@ -8508,13 +8570,15 @@ function getStructureMatchUps({
8508
8570
  afterRecoveryTimes,
8509
8571
  policyDefinitions,
8510
8572
  tournamentRecord,
8511
- drawDefinition,
8573
+ usePublishState,
8512
8574
  matchUpFilters,
8513
8575
  contextFilters,
8514
- contextProfile,
8515
8576
  contextContent,
8516
8577
  participantMap,
8517
8578
  scheduleTiming,
8579
+ publishStatus,
8580
+ contextProfile,
8581
+ drawDefinition,
8518
8582
  exitProfiles,
8519
8583
  matchUpsMap,
8520
8584
  structure,
@@ -8610,12 +8674,14 @@ function getDrawMatchUps(params) {
8610
8674
  afterRecoveryTimes,
8611
8675
  policyDefinitions,
8612
8676
  tournamentRecord,
8677
+ usePublishState,
8613
8678
  contextFilters,
8614
- contextProfile,
8615
- drawDefinition,
8616
8679
  matchUpFilters,
8617
8680
  scheduleTiming,
8618
8681
  participantMap,
8682
+ publishStatus,
8683
+ contextProfile,
8684
+ drawDefinition,
8619
8685
  nextMatchUps,
8620
8686
  inContext,
8621
8687
  context,
@@ -8670,9 +8736,11 @@ function getDrawMatchUps(params) {
8670
8736
  afterRecoveryTimes,
8671
8737
  policyDefinitions,
8672
8738
  tournamentRecord,
8739
+ usePublishState,
8740
+ contextContent,
8673
8741
  participantMap,
8674
8742
  scheduleTiming,
8675
- contextContent,
8743
+ publishStatus,
8676
8744
  contextProfile,
8677
8745
  drawDefinition,
8678
8746
  exitProfiles,
@@ -16496,8 +16564,7 @@ function tieFormatGenderValidityCheck(params) {
16496
16564
  context: { gender },
16497
16565
  stack
16498
16566
  });
16499
- const eventType = params.eventType ?? params.referenceEvent?.eventType;
16500
- if (referenceGender === MIXED && (eventType !== TEAM$2 || gender === ANY || gender === MIXED && matchUpType !== TypeEnum.Doubles)) {
16567
+ if (referenceGender === MIXED && (gender === ANY || gender === MIXED && matchUpType !== TypeEnum.Doubles)) {
16501
16568
  return decorateResult({
16502
16569
  result: { error: INVALID_GENDER, valid: false },
16503
16570
  info: mixedGenderError,
@@ -16888,7 +16955,6 @@ function validateTieFormat(params) {
16888
16955
  const { valid: valid2, errors: collectionDefinitionErrors } = validateCollectionDefinition({
16889
16956
  referenceCategory: params.category,
16890
16957
  referenceGender: params.gender,
16891
- eventType: params.eventType,
16892
16958
  collectionDefinition,
16893
16959
  checkCollectionIds,
16894
16960
  checkCategory,
@@ -16940,7 +17006,6 @@ function validateCollectionDefinition({
16940
17006
  checkGender = true,
16941
17007
  referenceCategory,
16942
17008
  referenceGender,
16943
- eventType,
16944
17009
  event
16945
17010
  }) {
16946
17011
  referenceGender = referenceGender ?? event?.gender;
@@ -17008,7 +17073,6 @@ function validateCollectionDefinition({
17008
17073
  }
17009
17074
  if (checkGender) {
17010
17075
  const result = tieFormatGenderValidityCheck({
17011
- eventType: eventType ?? event?.eventType,
17012
17076
  referenceGender,
17013
17077
  matchUpType,
17014
17078
  gender
@@ -17041,12 +17105,10 @@ function validateCollectionDefinition({
17041
17105
  return { valid: true };
17042
17106
  }
17043
17107
  function checkTieFormat({
17044
- tieFormat,
17045
- eventType
17108
+ tieFormat
17046
17109
  }) {
17047
17110
  const result = validateTieFormat({
17048
17111
  checkCollectionIds: false,
17049
- eventType,
17050
17112
  tieFormat
17051
17113
  });
17052
17114
  if (result.error)
@@ -17273,7 +17335,7 @@ function generateTieMatchUpScore(params) {
17273
17335
  const tieFormat = resolveTieFormat({ matchUp, drawDefinition, structure, event })?.tieFormat || params?.tieFormat;
17274
17336
  if (!tieFormat)
17275
17337
  return { error: MISSING_TIE_FORMAT };
17276
- const result = validateTieFormat({ tieFormat, eventType: event?.eventType });
17338
+ const result = validateTieFormat({ tieFormat });
17277
17339
  if (result.error)
17278
17340
  return result;
17279
17341
  const collectionDefinitions = tieFormat?.collectionDefinitions || [];
@@ -18246,14 +18308,14 @@ function generateAndPopulatePlayoffStructures(params) {
18246
18308
  };
18247
18309
  }
18248
18310
 
18311
+ function getDrawPublishStatus({ drawDetails, drawId }) {
18312
+ const details = drawDetails?.[drawId]?.publishingDetail;
18313
+ return details?.published;
18314
+ }
18315
+
18249
18316
  function getEventPublishStatuses({ event }) {
18250
- const itemType = `${PUBLISH}.${STATUS}`;
18251
- const { timeItem } = getTimeItem({
18252
- element: event,
18253
- itemType
18254
- });
18255
- if (timeItem?.itemValue?.PUBLIC) {
18256
- const { drawIds: publishedDrawIds = [], seeding } = timeItem.itemValue.PUBLIC || {};
18317
+ const eventPubStatus = getEventPublishStatus({ event });
18318
+ if (eventPubStatus) {
18257
18319
  const publishedSeeding = {
18258
18320
  published: void 0,
18259
18321
  // seeding can be present for all entries in an event when no flights have been defined
@@ -18261,9 +18323,13 @@ function getEventPublishStatuses({ event }) {
18261
18323
  drawIds: []
18262
18324
  // seeding can be specific to drawIds
18263
18325
  };
18264
- if (seeding) {
18265
- Object.assign(publishedSeeding, timeItem.itemValue.PUBLIC.seeding);
18326
+ if (eventPubStatus.seeding) {
18327
+ Object.assign(publishedSeeding, eventPubStatus.seeding);
18266
18328
  }
18329
+ const { drawDetails, drawIds } = eventPubStatus;
18330
+ const publishedDrawIds = drawDetails && Object.keys(drawDetails).filter(
18331
+ (drawId) => getDrawPublishStatus({ drawDetails, drawId })
18332
+ ) || drawIds || [];
18267
18333
  return {
18268
18334
  publishedDrawIds,
18269
18335
  publishedSeeding
@@ -18386,6 +18452,10 @@ function getEventSeedAssignments({
18386
18452
  return eventSeedAssignments;
18387
18453
  }
18388
18454
 
18455
+ function stringSort(a, b) {
18456
+ return (a || "").localeCompare(b || "");
18457
+ }
18458
+
18389
18459
  function processEventEntry({
18390
18460
  convertExtensions,
18391
18461
  seedAssignments,
@@ -19257,7 +19327,7 @@ function getParticipantEntries(params) {
19257
19327
  const itemIsPrior = consideredMinutes >= scheduledMinutes;
19258
19328
  const timeOverlap = scheduledMinutesDifference && !isNaN(scheduledMinutesDifference) ? minutesDifference <= scheduledMinutesDifference : itemIsPrior && timeStringMinutes(consideredItem.scheduledTime) < timeStringMinutes(notBeforeTime);
19259
19329
  if (timeOverlap && !(bothPotential && sameDraw) && itemIsPrior) {
19260
- const key = [scheduleItem.matchUpId, consideredItem.matchUpId].sort().join("|");
19330
+ const key = [scheduleItem.matchUpId, consideredItem.matchUpId].sort(stringSort).join("|");
19261
19331
  participantAggregator.scheduleConflicts[key] = {
19262
19332
  priorScheduledMatchUpId: scheduleItem.matchUpId,
19263
19333
  matchUpIdWithConflict: consideredItem.matchUpId
@@ -20155,8 +20225,7 @@ function generateVoluntaryConsolation$1(params) {
20155
20225
  return { error: INVALID_DRAW_SIZE };
20156
20226
  let { tieFormat, matchUpType } = params;
20157
20227
  if (tieFormat) {
20158
- const eventType = params.event?.eventType;
20159
- const result2 = validateTieFormat({ tieFormat, eventType });
20228
+ const result2 = validateTieFormat({ tieFormat });
20160
20229
  if (result2.error)
20161
20230
  return result2;
20162
20231
  }
@@ -20392,10 +20461,6 @@ function addAdHocMatchUps({
20392
20461
  return { ...SUCCESS };
20393
20462
  }
20394
20463
 
20395
- function stringSort(a, b) {
20396
- return (a || "").localeCompare(b || "");
20397
- }
20398
-
20399
20464
  function generateCandidate({
20400
20465
  maxIterations = 4e3,
20401
20466
  // cap the processing intensity of the candidate generator
@@ -21258,8 +21323,7 @@ function generateDrawTypeAndModifyDrawDefinition(params) {
21258
21323
  const drawDefinition = modifyOriginal ? params.drawDefinition : makeDeepCopy(params.drawDefinition, false, true);
21259
21324
  let { tieFormat, matchUpType } = params;
21260
21325
  if (tieFormat) {
21261
- const eventType = params.event?.eventType;
21262
- const result2 = validateTieFormat({ tieFormat, eventType });
21326
+ const result2 = validateTieFormat({ tieFormat });
21263
21327
  if (result2.error)
21264
21328
  return result2;
21265
21329
  }
@@ -23744,8 +23808,7 @@ function generateDrawDefinition(params) {
23744
23808
  const result = validateTieFormat({
23745
23809
  gender: event?.gender,
23746
23810
  enforceGender,
23747
- tieFormat,
23748
- event
23811
+ tieFormat
23749
23812
  });
23750
23813
  if (result.error)
23751
23814
  return decorateResult({ result, stack });
@@ -23764,10 +23827,7 @@ function generateDrawDefinition(params) {
23764
23827
  const equivalentInScope = matchUpFormat && event?.matchUpFormat === matchUpFormat || event?.tieFormat && tieFormat && JSON.stringify(event.tieFormat) === JSON.stringify(tieFormat);
23765
23828
  if (!equivalentInScope) {
23766
23829
  if (tieFormat) {
23767
- const result = checkTieFormat({
23768
- eventType: event.eventType,
23769
- tieFormat
23770
- });
23830
+ const result = checkTieFormat({ tieFormat });
23771
23831
  if (result.error)
23772
23832
  return decorateResult({ result, stack });
23773
23833
  drawDefinition.tieFormat = result.tieFormat ?? tieFormat;
@@ -24098,7 +24158,7 @@ function generateDrawDefinition(params) {
24098
24158
  drawDefinition.links.push(link);
24099
24159
  }
24100
24160
  drawDefinition.drawName = params.drawName ?? (drawType && constantToString(drawType));
24101
- if (typeof voluntaryConsolation === "object") {
24161
+ if (typeof voluntaryConsolation === "object" && drawSize >= 4) {
24102
24162
  addVoluntaryConsolationStructure({
24103
24163
  ...voluntaryConsolation,
24104
24164
  tournamentRecord,