tods-competition-factory 1.8.46 → 1.9.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.
@@ -911,13 +911,18 @@ function isString(obj) {
911
911
  return typeof obj === "string";
912
912
  }
913
913
  function isObject(obj) {
914
- return typeof obj === "object";
914
+ return obj !== null && typeof obj === "object";
915
915
  }
916
916
  const extractAttributes = (accessor) => (element) => !accessor || typeof element !== "object" ? void 0 : Array.isArray(accessor) && accessor.map((a) => ({
917
917
  [a]: getAccessorValue({ element, accessor: a })?.value
918
918
  })) || typeof accessor === "object" && Object.keys(accessor).map((key) => ({
919
919
  [key]: getAccessorValue({ element, accessor: key })?.value
920
920
  })) || (typeof accessor === "string" && getAccessorValue({ element, accessor }))?.value;
921
+ function getDefinedKeys(obj, ignoreValues, ignoreEmptyArrays) {
922
+ return Object.keys(obj).filter(
923
+ (key) => !ignoreValues.includes(obj[key]) && (!ignoreEmptyArrays || (Array.isArray(obj[key]) ? obj[key].length : true))
924
+ );
925
+ }
921
926
  function definedAttributes(obj, ignoreFalse, ignoreEmptyArrays, shallow) {
922
927
  if (typeof obj !== "object" || obj === null)
923
928
  return obj;
@@ -927,9 +932,7 @@ function definedAttributes(obj, ignoreFalse, ignoreEmptyArrays, shallow) {
927
932
  const ignoreValues = ["", void 0, null];
928
933
  if (ignoreFalse)
929
934
  ignoreValues.push(false);
930
- const definedKeys = Object.keys(obj).filter(
931
- (key) => !ignoreValues.includes(obj[key]) && (!ignoreEmptyArrays || (Array.isArray(obj[key]) ? obj[key].length : true))
932
- );
935
+ const definedKeys = getDefinedKeys(obj, ignoreValues, ignoreEmptyArrays);
933
936
  return Object.assign(
934
937
  {},
935
938
  ...definedKeys.map((key) => {
@@ -2921,8 +2924,10 @@ function getMatchUpScheduleDetails({
2921
2924
  scheduleVisibilityFilters,
2922
2925
  afterRecoveryTimes,
2923
2926
  tournamentRecord,
2927
+ usePublishState,
2924
2928
  scheduleTiming,
2925
2929
  matchUpFormat,
2930
+ publishStatus,
2926
2931
  matchUpType,
2927
2932
  matchUp,
2928
2933
  event
@@ -3039,15 +3044,36 @@ function getMatchUpScheduleDetails({
3039
3044
  });
3040
3045
  } else {
3041
3046
  schedule = definedAttributes({
3042
- time,
3047
+ milliseconds,
3043
3048
  startTime,
3044
3049
  endTime,
3045
- milliseconds
3050
+ time
3046
3051
  });
3047
3052
  }
3048
- const hasCompletedStatus = matchUp.matchUpStatus && completedMatchUpStatuses.includes(matchUp.matchUpStatus);
3049
3053
  const { scheduledDate } = scheduledMatchUpDate({ matchUp });
3050
3054
  const { scheduledTime } = scheduledMatchUpTime({ matchUp });
3055
+ if (usePublishState && publishStatus?.displaySettings?.draws) {
3056
+ const drawSettings = publishStatus.displaySettings.draws;
3057
+ const scheduleDetails = (drawSettings?.[matchUp.drawId] ?? drawSettings?.default)?.scheduleDetails;
3058
+ if (scheduleDetails) {
3059
+ const scheduleAttributes = (scheduleDetails.find(
3060
+ (details) => scheduledDate && details.dates?.includes(scheduledDate)
3061
+ ) ?? scheduleDetails.find((details) => !details.dates?.length))?.attributes;
3062
+ if (scheduleAttributes) {
3063
+ const template = Object.assign(
3064
+ {},
3065
+ ...Object.keys(schedule).map((key) => ({ [key]: true })),
3066
+ // overwrite with publishStatus attributes
3067
+ scheduleAttributes
3068
+ );
3069
+ schedule = attributeFilter({
3070
+ source: schedule,
3071
+ template
3072
+ });
3073
+ }
3074
+ }
3075
+ }
3076
+ const hasCompletedStatus = matchUp.matchUpStatus && completedMatchUpStatuses.includes(matchUp.matchUpStatus);
3051
3077
  const endDate = hasCompletedStatus && (extractDate(endTime) || extractDate(scheduledDate) || extractDate(scheduledTime)) || void 0;
3052
3078
  return { schedule, endDate };
3053
3079
  }
@@ -4572,6 +4598,7 @@ function getAllStructureMatchUps({
4572
4598
  policyDefinitions,
4573
4599
  tournamentRecord,
4574
4600
  seedAssignments,
4601
+ usePublishState,
4575
4602
  contextFilters,
4576
4603
  contextContent,
4577
4604
  matchUpFilters,
@@ -4579,6 +4606,7 @@ function getAllStructureMatchUps({
4579
4606
  scheduleTiming,
4580
4607
  contextProfile,
4581
4608
  drawDefinition,
4609
+ publishStatus,
4582
4610
  context = {},
4583
4611
  exitProfiles,
4584
4612
  matchUpsMap,
@@ -4687,6 +4715,8 @@ function getAllStructureMatchUps({
4687
4715
  roundNamingProfile,
4688
4716
  initialRoundOfPlay,
4689
4717
  appliedPolicies,
4718
+ usePublishState,
4719
+ publishStatus,
4690
4720
  isRoundRobin,
4691
4721
  roundProfile,
4692
4722
  matchUp,
@@ -4756,6 +4786,8 @@ function getAllStructureMatchUps({
4756
4786
  tieDrawPositions,
4757
4787
  appliedPolicies: appliedPolicies2,
4758
4788
  isCollectionBye,
4789
+ usePublishState: usePublishState2,
4790
+ publishStatus: publishStatus2,
4759
4791
  matchUpTieId,
4760
4792
  isRoundRobin: isRoundRobin2,
4761
4793
  roundProfile: roundProfile2,
@@ -4781,8 +4813,10 @@ function getAllStructureMatchUps({
4781
4813
  scheduleVisibilityFilters: scheduleVisibilityFilters2,
4782
4814
  afterRecoveryTimes,
4783
4815
  tournamentRecord,
4816
+ usePublishState: usePublishState2,
4784
4817
  scheduleTiming,
4785
4818
  matchUpFormat,
4819
+ publishStatus: publishStatus2,
4786
4820
  matchUpType,
4787
4821
  matchUp,
4788
4822
  event: event2
@@ -4905,7 +4939,7 @@ function getAllStructureMatchUps({
4905
4939
  Object.assign(matchUpWithContext, makeDeepCopy({ sides }, true, true));
4906
4940
  }
4907
4941
  if (tournamentParticipants && matchUpWithContext.sides) {
4908
- const participantAttributes = policyDefinitions?.[POLICY_TYPE_PARTICIPANT];
4942
+ const participantAttributes = appliedPolicies2?.[POLICY_TYPE_PARTICIPANT];
4909
4943
  const getMappedParticipant = (participantId) => {
4910
4944
  const participant = participantMap?.[participantId]?.participant;
4911
4945
  return participant && attributeFilter({
@@ -5021,6 +5055,8 @@ function getAllStructureMatchUps({
5021
5055
  additionalContext: additionalContext2,
5022
5056
  appliedPolicies: appliedPolicies2,
5023
5057
  isCollectionBye: isCollectionBye2,
5058
+ usePublishState: usePublishState2,
5059
+ publishStatus: publishStatus2,
5024
5060
  matchUpTieId: matchUpTieId2,
5025
5061
  isRoundRobin: isRoundRobin2,
5026
5062
  roundProfile: roundProfile2,
@@ -5150,8 +5186,7 @@ function tieFormatGenderValidityCheck(params) {
5150
5186
  context: { gender },
5151
5187
  stack
5152
5188
  });
5153
- const eventType = params.eventType ?? params.referenceEvent?.eventType;
5154
- if (referenceGender === MIXED && (eventType !== TEAM$2 || gender === ANY || gender === MIXED && matchUpType !== TypeEnum.Doubles)) {
5189
+ if (referenceGender === MIXED && (gender === ANY || gender === MIXED && matchUpType !== TypeEnum.Doubles)) {
5155
5190
  return decorateResult({
5156
5191
  result: { error: INVALID_GENDER, valid: false },
5157
5192
  info: mixedGenderError,
@@ -5542,7 +5577,6 @@ function validateTieFormat(params) {
5542
5577
  const { valid: valid2, errors: collectionDefinitionErrors } = validateCollectionDefinition({
5543
5578
  referenceCategory: params.category,
5544
5579
  referenceGender: params.gender,
5545
- eventType: params.eventType,
5546
5580
  collectionDefinition,
5547
5581
  checkCollectionIds,
5548
5582
  checkCategory,
@@ -5594,7 +5628,6 @@ function validateCollectionDefinition({
5594
5628
  checkGender = true,
5595
5629
  referenceCategory,
5596
5630
  referenceGender,
5597
- eventType,
5598
5631
  event
5599
5632
  }) {
5600
5633
  referenceGender = referenceGender ?? event?.gender;
@@ -5662,7 +5695,6 @@ function validateCollectionDefinition({
5662
5695
  }
5663
5696
  if (checkGender) {
5664
5697
  const result = tieFormatGenderValidityCheck({
5665
- eventType: eventType ?? event?.eventType,
5666
5698
  referenceGender,
5667
5699
  matchUpType,
5668
5700
  gender
@@ -6891,7 +6923,7 @@ function generateTieMatchUpScore(params) {
6891
6923
  const tieFormat = resolveTieFormat({ matchUp, drawDefinition, structure, event })?.tieFormat || params?.tieFormat;
6892
6924
  if (!tieFormat)
6893
6925
  return { error: MISSING_TIE_FORMAT };
6894
- const result = validateTieFormat({ tieFormat, eventType: event?.eventType });
6926
+ const result = validateTieFormat({ tieFormat });
6895
6927
  if (result.error)
6896
6928
  return result;
6897
6929
  const collectionDefinitions = tieFormat?.collectionDefinitions || [];
@@ -7671,11 +7703,13 @@ function getStructureMatchUps({
7671
7703
  afterRecoveryTimes,
7672
7704
  policyDefinitions,
7673
7705
  tournamentRecord,
7706
+ usePublishState,
7674
7707
  matchUpFilters,
7675
7708
  contextFilters,
7676
7709
  contextContent,
7677
7710
  participantMap,
7678
7711
  scheduleTiming,
7712
+ publishStatus,
7679
7713
  contextProfile,
7680
7714
  drawDefinition,
7681
7715
  exitProfiles,
@@ -7696,13 +7730,15 @@ function getStructureMatchUps({
7696
7730
  afterRecoveryTimes,
7697
7731
  policyDefinitions,
7698
7732
  tournamentRecord,
7699
- drawDefinition,
7733
+ usePublishState,
7700
7734
  matchUpFilters,
7701
7735
  contextFilters,
7702
- contextProfile,
7703
7736
  contextContent,
7704
7737
  participantMap,
7705
7738
  scheduleTiming,
7739
+ publishStatus,
7740
+ contextProfile,
7741
+ drawDefinition,
7706
7742
  exitProfiles,
7707
7743
  matchUpsMap,
7708
7744
  structure,
@@ -7798,12 +7834,14 @@ function getDrawMatchUps(params) {
7798
7834
  afterRecoveryTimes,
7799
7835
  policyDefinitions,
7800
7836
  tournamentRecord,
7837
+ usePublishState,
7801
7838
  contextFilters,
7802
- contextProfile,
7803
- drawDefinition,
7804
7839
  matchUpFilters,
7805
7840
  scheduleTiming,
7806
7841
  participantMap,
7842
+ publishStatus,
7843
+ contextProfile,
7844
+ drawDefinition,
7807
7845
  nextMatchUps,
7808
7846
  inContext,
7809
7847
  context,
@@ -7858,9 +7896,11 @@ function getDrawMatchUps(params) {
7858
7896
  afterRecoveryTimes,
7859
7897
  policyDefinitions,
7860
7898
  tournamentRecord,
7899
+ usePublishState,
7900
+ contextContent,
7861
7901
  participantMap,
7862
7902
  scheduleTiming,
7863
- contextContent,
7903
+ publishStatus,
7864
7904
  contextProfile,
7865
7905
  drawDefinition,
7866
7906
  exitProfiles,
@@ -8280,6 +8320,38 @@ function modifyRoundRobinMatchUpsStatus({
8280
8320
  });
8281
8321
  }
8282
8322
 
8323
+ function getTimeItem({
8324
+ returnPreviousValues,
8325
+ itemSubTypes,
8326
+ itemType,
8327
+ element
8328
+ }) {
8329
+ if (!element)
8330
+ return { error: MISSING_VALUE, info: ELEMENT_REQUIRED };
8331
+ if (itemSubTypes && !Array.isArray(itemSubTypes))
8332
+ return { error: INVALID_VALUES, context: { itemSubTypes } };
8333
+ if (!Array.isArray(element.timeItems))
8334
+ return { error: MISSING_TIME_ITEMS };
8335
+ const filteredSorted = element.timeItems.filter((timeItem2) => timeItem2?.itemType === itemType).filter(
8336
+ (timeItem2) => !itemSubTypes?.length || itemSubTypes.some(
8337
+ (subType) => timeItem2?.itemSubTypes?.includes(subType)
8338
+ )
8339
+ ).sort((a, b) => {
8340
+ const aDate = new Date(a.createdAt || void 0).getTime();
8341
+ const bDate = new Date(b.createdAt || void 0).getTime();
8342
+ return aDate - bDate;
8343
+ });
8344
+ const timeItem = filteredSorted.pop();
8345
+ if (timeItem) {
8346
+ const result = { timeItem, ...SUCCESS };
8347
+ if (returnPreviousValues)
8348
+ Object.assign(result, { previousItems: filteredSorted });
8349
+ return result;
8350
+ } else {
8351
+ return { info: NOT_FOUND };
8352
+ }
8353
+ }
8354
+
8283
8355
  const countries = [
8284
8356
  {
8285
8357
  ioc: "",
@@ -10063,38 +10135,6 @@ function addIndividualParticipants({ participantMap, template }) {
10063
10135
  }
10064
10136
  }
10065
10137
 
10066
- function getTimeItem({
10067
- returnPreviousValues,
10068
- itemSubTypes,
10069
- itemType,
10070
- element
10071
- }) {
10072
- if (!element)
10073
- return { error: MISSING_VALUE, info: ELEMENT_REQUIRED };
10074
- if (itemSubTypes && !Array.isArray(itemSubTypes))
10075
- return { error: INVALID_VALUES, context: { itemSubTypes } };
10076
- if (!Array.isArray(element.timeItems))
10077
- return { error: MISSING_TIME_ITEMS };
10078
- const filteredSorted = element.timeItems.filter((timeItem2) => timeItem2?.itemType === itemType).filter(
10079
- (timeItem2) => !itemSubTypes?.length || itemSubTypes.some(
10080
- (subType) => timeItem2?.itemSubTypes?.includes(subType)
10081
- )
10082
- ).sort((a, b) => {
10083
- const aDate = new Date(a.createdAt || void 0).getTime();
10084
- const bDate = new Date(b.createdAt || void 0).getTime();
10085
- return aDate - bDate;
10086
- });
10087
- const timeItem = filteredSorted.pop();
10088
- if (timeItem) {
10089
- const result = { timeItem, ...SUCCESS };
10090
- if (returnPreviousValues)
10091
- Object.assign(result, { previousItems: filteredSorted });
10092
- return result;
10093
- } else {
10094
- return { info: NOT_FOUND };
10095
- }
10096
- }
10097
-
10098
10138
  const typeMap = {
10099
10139
  [GROUP]: "groupParticipantIds",
10100
10140
  [PAIR]: "pairParticipantIds",
@@ -13012,18 +13052,14 @@ function conditionallyAdvanceDrawPosition(params) {
13012
13052
  } else {
13013
13053
  sourceSideNumber = 2;
13014
13054
  }
13015
- } else {
13016
- if (targetMatchUp.feedRound) {
13017
- if (sourceMatchUp.structureId === targetMatchUp.structureId) {
13018
- sourceSideNumber = 2;
13019
- } else {
13020
- sourceSideNumber = 1;
13021
- }
13055
+ } else if (targetMatchUp.feedRound) {
13056
+ if (sourceMatchUp.structureId === targetMatchUp.structureId) {
13057
+ sourceSideNumber = 2;
13022
13058
  } else {
13023
- if (walkoverWinningSide)
13024
- sourceSideNumber = 3 - walkoverWinningSide;
13059
+ sourceSideNumber = 1;
13025
13060
  }
13026
- }
13061
+ } else if (walkoverWinningSide)
13062
+ sourceSideNumber = 3 - walkoverWinningSide;
13027
13063
  }
13028
13064
  const sourceMatchUpStatus = params.matchUpStatus;
13029
13065
  const pairedMatchUpStatus = pairedPreviousMatchUp?.matchUpStatus;