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.
@@ -911,7 +911,7 @@ 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
@@ -2921,8 +2921,10 @@ function getMatchUpScheduleDetails({
2921
2921
  scheduleVisibilityFilters,
2922
2922
  afterRecoveryTimes,
2923
2923
  tournamentRecord,
2924
+ usePublishState,
2924
2925
  scheduleTiming,
2925
2926
  matchUpFormat,
2927
+ publishStatus,
2926
2928
  matchUpType,
2927
2929
  matchUp,
2928
2930
  event
@@ -3039,15 +3041,36 @@ function getMatchUpScheduleDetails({
3039
3041
  });
3040
3042
  } else {
3041
3043
  schedule = definedAttributes({
3042
- time,
3044
+ milliseconds,
3043
3045
  startTime,
3044
3046
  endTime,
3045
- milliseconds
3047
+ time
3046
3048
  });
3047
3049
  }
3048
- const hasCompletedStatus = matchUp.matchUpStatus && completedMatchUpStatuses.includes(matchUp.matchUpStatus);
3049
3050
  const { scheduledDate } = scheduledMatchUpDate({ matchUp });
3050
3051
  const { scheduledTime } = scheduledMatchUpTime({ matchUp });
3052
+ if (usePublishState && publishStatus?.displaySettings?.draws) {
3053
+ const drawSettings = publishStatus.displaySettings.draws;
3054
+ const scheduleDetails = (drawSettings?.[matchUp.drawId] ?? drawSettings?.default)?.scheduleDetails;
3055
+ if (scheduleDetails) {
3056
+ const scheduleAttributes = (scheduleDetails.find(
3057
+ (details) => scheduledDate && details.dates?.includes(scheduledDate)
3058
+ ) ?? scheduleDetails.find((details) => !details.dates?.length))?.attributes;
3059
+ if (scheduleAttributes) {
3060
+ const template = Object.assign(
3061
+ {},
3062
+ ...Object.keys(schedule).map((key) => ({ [key]: true })),
3063
+ // overwrite with publishStatus attributes
3064
+ scheduleAttributes
3065
+ );
3066
+ schedule = attributeFilter({
3067
+ source: schedule,
3068
+ template
3069
+ });
3070
+ }
3071
+ }
3072
+ }
3073
+ const hasCompletedStatus = matchUp.matchUpStatus && completedMatchUpStatuses.includes(matchUp.matchUpStatus);
3051
3074
  const endDate = hasCompletedStatus && (extractDate(endTime) || extractDate(scheduledDate) || extractDate(scheduledTime)) || void 0;
3052
3075
  return { schedule, endDate };
3053
3076
  }
@@ -4572,6 +4595,7 @@ function getAllStructureMatchUps({
4572
4595
  policyDefinitions,
4573
4596
  tournamentRecord,
4574
4597
  seedAssignments,
4598
+ usePublishState,
4575
4599
  contextFilters,
4576
4600
  contextContent,
4577
4601
  matchUpFilters,
@@ -4579,6 +4603,7 @@ function getAllStructureMatchUps({
4579
4603
  scheduleTiming,
4580
4604
  contextProfile,
4581
4605
  drawDefinition,
4606
+ publishStatus,
4582
4607
  context = {},
4583
4608
  exitProfiles,
4584
4609
  matchUpsMap,
@@ -4687,6 +4712,8 @@ function getAllStructureMatchUps({
4687
4712
  roundNamingProfile,
4688
4713
  initialRoundOfPlay,
4689
4714
  appliedPolicies,
4715
+ usePublishState,
4716
+ publishStatus,
4690
4717
  isRoundRobin,
4691
4718
  roundProfile,
4692
4719
  matchUp,
@@ -4756,6 +4783,8 @@ function getAllStructureMatchUps({
4756
4783
  tieDrawPositions,
4757
4784
  appliedPolicies: appliedPolicies2,
4758
4785
  isCollectionBye,
4786
+ usePublishState: usePublishState2,
4787
+ publishStatus: publishStatus2,
4759
4788
  matchUpTieId,
4760
4789
  isRoundRobin: isRoundRobin2,
4761
4790
  roundProfile: roundProfile2,
@@ -4781,8 +4810,10 @@ function getAllStructureMatchUps({
4781
4810
  scheduleVisibilityFilters: scheduleVisibilityFilters2,
4782
4811
  afterRecoveryTimes,
4783
4812
  tournamentRecord,
4813
+ usePublishState: usePublishState2,
4784
4814
  scheduleTiming,
4785
4815
  matchUpFormat,
4816
+ publishStatus: publishStatus2,
4786
4817
  matchUpType,
4787
4818
  matchUp,
4788
4819
  event: event2
@@ -4905,7 +4936,7 @@ function getAllStructureMatchUps({
4905
4936
  Object.assign(matchUpWithContext, makeDeepCopy({ sides }, true, true));
4906
4937
  }
4907
4938
  if (tournamentParticipants && matchUpWithContext.sides) {
4908
- const participantAttributes = policyDefinitions?.[POLICY_TYPE_PARTICIPANT];
4939
+ const participantAttributes = appliedPolicies2?.[POLICY_TYPE_PARTICIPANT];
4909
4940
  const getMappedParticipant = (participantId) => {
4910
4941
  const participant = participantMap?.[participantId]?.participant;
4911
4942
  return participant && attributeFilter({
@@ -5021,6 +5052,8 @@ function getAllStructureMatchUps({
5021
5052
  additionalContext: additionalContext2,
5022
5053
  appliedPolicies: appliedPolicies2,
5023
5054
  isCollectionBye: isCollectionBye2,
5055
+ usePublishState: usePublishState2,
5056
+ publishStatus: publishStatus2,
5024
5057
  matchUpTieId: matchUpTieId2,
5025
5058
  isRoundRobin: isRoundRobin2,
5026
5059
  roundProfile: roundProfile2,
@@ -5150,8 +5183,7 @@ function tieFormatGenderValidityCheck(params) {
5150
5183
  context: { gender },
5151
5184
  stack
5152
5185
  });
5153
- const eventType = params.eventType ?? params.referenceEvent?.eventType;
5154
- if (referenceGender === MIXED && (eventType !== TEAM$2 || gender === ANY || gender === MIXED && matchUpType !== TypeEnum.Doubles)) {
5186
+ if (referenceGender === MIXED && (gender === ANY || gender === MIXED && matchUpType !== TypeEnum.Doubles)) {
5155
5187
  return decorateResult({
5156
5188
  result: { error: INVALID_GENDER, valid: false },
5157
5189
  info: mixedGenderError,
@@ -5542,7 +5574,6 @@ function validateTieFormat(params) {
5542
5574
  const { valid: valid2, errors: collectionDefinitionErrors } = validateCollectionDefinition({
5543
5575
  referenceCategory: params.category,
5544
5576
  referenceGender: params.gender,
5545
- eventType: params.eventType,
5546
5577
  collectionDefinition,
5547
5578
  checkCollectionIds,
5548
5579
  checkCategory,
@@ -5594,7 +5625,6 @@ function validateCollectionDefinition({
5594
5625
  checkGender = true,
5595
5626
  referenceCategory,
5596
5627
  referenceGender,
5597
- eventType,
5598
5628
  event
5599
5629
  }) {
5600
5630
  referenceGender = referenceGender ?? event?.gender;
@@ -5662,7 +5692,6 @@ function validateCollectionDefinition({
5662
5692
  }
5663
5693
  if (checkGender) {
5664
5694
  const result = tieFormatGenderValidityCheck({
5665
- eventType: eventType ?? event?.eventType,
5666
5695
  referenceGender,
5667
5696
  matchUpType,
5668
5697
  gender
@@ -6891,7 +6920,7 @@ function generateTieMatchUpScore(params) {
6891
6920
  const tieFormat = resolveTieFormat({ matchUp, drawDefinition, structure, event })?.tieFormat || params?.tieFormat;
6892
6921
  if (!tieFormat)
6893
6922
  return { error: MISSING_TIE_FORMAT };
6894
- const result = validateTieFormat({ tieFormat, eventType: event?.eventType });
6923
+ const result = validateTieFormat({ tieFormat });
6895
6924
  if (result.error)
6896
6925
  return result;
6897
6926
  const collectionDefinitions = tieFormat?.collectionDefinitions || [];
@@ -7671,11 +7700,13 @@ function getStructureMatchUps({
7671
7700
  afterRecoveryTimes,
7672
7701
  policyDefinitions,
7673
7702
  tournamentRecord,
7703
+ usePublishState,
7674
7704
  matchUpFilters,
7675
7705
  contextFilters,
7676
7706
  contextContent,
7677
7707
  participantMap,
7678
7708
  scheduleTiming,
7709
+ publishStatus,
7679
7710
  contextProfile,
7680
7711
  drawDefinition,
7681
7712
  exitProfiles,
@@ -7696,13 +7727,15 @@ function getStructureMatchUps({
7696
7727
  afterRecoveryTimes,
7697
7728
  policyDefinitions,
7698
7729
  tournamentRecord,
7699
- drawDefinition,
7730
+ usePublishState,
7700
7731
  matchUpFilters,
7701
7732
  contextFilters,
7702
- contextProfile,
7703
7733
  contextContent,
7704
7734
  participantMap,
7705
7735
  scheduleTiming,
7736
+ publishStatus,
7737
+ contextProfile,
7738
+ drawDefinition,
7706
7739
  exitProfiles,
7707
7740
  matchUpsMap,
7708
7741
  structure,
@@ -7798,12 +7831,14 @@ function getDrawMatchUps(params) {
7798
7831
  afterRecoveryTimes,
7799
7832
  policyDefinitions,
7800
7833
  tournamentRecord,
7834
+ usePublishState,
7801
7835
  contextFilters,
7802
- contextProfile,
7803
- drawDefinition,
7804
7836
  matchUpFilters,
7805
7837
  scheduleTiming,
7806
7838
  participantMap,
7839
+ publishStatus,
7840
+ contextProfile,
7841
+ drawDefinition,
7807
7842
  nextMatchUps,
7808
7843
  inContext,
7809
7844
  context,
@@ -7858,9 +7893,11 @@ function getDrawMatchUps(params) {
7858
7893
  afterRecoveryTimes,
7859
7894
  policyDefinitions,
7860
7895
  tournamentRecord,
7896
+ usePublishState,
7897
+ contextContent,
7861
7898
  participantMap,
7862
7899
  scheduleTiming,
7863
- contextContent,
7900
+ publishStatus,
7864
7901
  contextProfile,
7865
7902
  drawDefinition,
7866
7903
  exitProfiles,
@@ -8280,6 +8317,38 @@ function modifyRoundRobinMatchUpsStatus({
8280
8317
  });
8281
8318
  }
8282
8319
 
8320
+ function getTimeItem({
8321
+ returnPreviousValues,
8322
+ itemSubTypes,
8323
+ itemType,
8324
+ element
8325
+ }) {
8326
+ if (!element)
8327
+ return { error: MISSING_VALUE, info: ELEMENT_REQUIRED };
8328
+ if (itemSubTypes && !Array.isArray(itemSubTypes))
8329
+ return { error: INVALID_VALUES, context: { itemSubTypes } };
8330
+ if (!Array.isArray(element.timeItems))
8331
+ return { error: MISSING_TIME_ITEMS };
8332
+ const filteredSorted = element.timeItems.filter((timeItem2) => timeItem2?.itemType === itemType).filter(
8333
+ (timeItem2) => !itemSubTypes?.length || itemSubTypes.some(
8334
+ (subType) => timeItem2?.itemSubTypes?.includes(subType)
8335
+ )
8336
+ ).sort((a, b) => {
8337
+ const aDate = new Date(a.createdAt || void 0).getTime();
8338
+ const bDate = new Date(b.createdAt || void 0).getTime();
8339
+ return aDate - bDate;
8340
+ });
8341
+ const timeItem = filteredSorted.pop();
8342
+ if (timeItem) {
8343
+ const result = { timeItem, ...SUCCESS };
8344
+ if (returnPreviousValues)
8345
+ Object.assign(result, { previousItems: filteredSorted });
8346
+ return result;
8347
+ } else {
8348
+ return { info: NOT_FOUND };
8349
+ }
8350
+ }
8351
+
8283
8352
  const countries = [
8284
8353
  {
8285
8354
  ioc: "",
@@ -10063,38 +10132,6 @@ function addIndividualParticipants({ participantMap, template }) {
10063
10132
  }
10064
10133
  }
10065
10134
 
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
10135
  const typeMap = {
10099
10136
  [GROUP]: "groupParticipantIds",
10100
10137
  [PAIR]: "pairParticipantIds",