tods-competition-factory 2.0.59 → 2.1.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.
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  function factoryVersion() {
6
- return '2.0.59';
6
+ return '2.1.0';
7
7
  }
8
8
 
9
9
  function isFunction(obj) {
@@ -46,7 +46,7 @@ const hasAttributeValues = (a) => (o) => Object.keys(a).every((key) => o[key] ==
46
46
  function undefinedToNull(obj, shallow) {
47
47
  if (obj === undefined)
48
48
  return null;
49
- if (typeof obj !== 'object' || obj === null)
49
+ if (!isObject(obj) || obj === null)
50
50
  return obj;
51
51
  const definedKeys = Object.keys(obj);
52
52
  const notNull = (value) => (value === undefined ? null : value);
@@ -62,7 +62,7 @@ function countKeys(o) {
62
62
  if (Array.isArray(o)) {
63
63
  return o.length + o.map(countKeys).reduce((a, b) => a + b, 0);
64
64
  }
65
- else if (typeof o === 'object' && o !== null) {
65
+ else if (isObject(o) && o !== null) {
66
66
  return (Object.keys(o).length +
67
67
  Object.keys(o)
68
68
  .map((k) => countKeys(o[k]))
@@ -446,6 +446,10 @@ const MISSING_VALUE = {
446
446
  message: 'Missing value',
447
447
  code: 'ERR_MISSING_VALUE',
448
448
  };
449
+ const MISSING_BIRTH_DATE = {
450
+ message: 'Missing birthdate',
451
+ code: 'ERR_MISSING_BIRTH_DATE',
452
+ };
449
453
  const MISSING_DATE = {
450
454
  message: 'Missing date',
451
455
  code: 'ERR_MISSING_DATE',
@@ -506,6 +510,10 @@ const CANNOT_REMOVE_PARTICIPANTS = {
506
510
  message: 'Cannot remove participants',
507
511
  code: 'ERR_UNCHANGED_CANNOT_REMOVE_PARTICIPANTS',
508
512
  };
513
+ const CATEGORY_MISMATCH = {
514
+ message: 'Participant category mismatch',
515
+ code: 'ERR_CATEGORY_MISMATCH',
516
+ };
509
517
  const CANNOT_CHANGE_WINNING_SIDE = {
510
518
  message: 'Cannot change winningSide',
511
519
  code: 'ERR_UNCHANGED_CANNOT_CHANGE_WINNING_SIDE',
@@ -818,6 +826,7 @@ const errorConditionConstants = {
818
826
  CANNOT_MODIFY_PARTICIPANT_TYPE,
819
827
  CANNOT_REMOVE_MAIN_STRUCTURE,
820
828
  CANNOT_REMOVE_PARTICIPANTS,
829
+ CATEGORY_MISMATCH,
821
830
  COURT_EXISTS,
822
831
  COURT_NOT_FOUND,
823
832
  DRAW_DEFINITION_NOT_FOUND,
@@ -900,6 +909,7 @@ const errorConditionConstants = {
900
909
  MISSING_ASSIGNMENTS,
901
910
  MISSING_ASYNC_STATE_PROVIDER,
902
911
  MISSING_AVOIDANCE_POLICY,
912
+ MISSING_BIRTH_DATE,
903
913
  MISSING_COLLECTION_DEFINITION,
904
914
  MISSING_COURT_ID,
905
915
  MISSING_COURTS_INFO,
@@ -3414,9 +3424,11 @@ const MUTATIONS = 'mutations';
3414
3424
  const PUBLISH_EVENT = 'publishEvent';
3415
3425
  const PUBLISH_EVENT_SEEDING = 'publishEventSeeding';
3416
3426
  const PUBLISH_ORDER_OF_PLAY = 'publishOrderOfPlay';
3427
+ const PUBLISH_PARTICIPANTS = 'publishParticipants';
3417
3428
  const UNPUBLISH_EVENT = 'unPublishEvent';
3418
3429
  const UNPUBLISH_EVENT_SEEDING = 'unPublishEventSeeding';
3419
3430
  const UNPUBLISH_ORDER_OF_PLAY = 'unPublishOrderOfPlay';
3431
+ const UNPUBLISH_PARTICIPANTS = 'unPublishParticipants';
3420
3432
  const UPDATE_INCONTEXT_MATCHUP = 'updateInContextMatchUp';
3421
3433
  const topicConstants = {
3422
3434
  ADD_DRAW_DEFINITION,
@@ -3443,6 +3455,7 @@ const topicConstants = {
3443
3455
  PUBLISH_EVENT_SEEDING,
3444
3456
  PUBLISH_EVENT,
3445
3457
  PUBLISH_ORDER_OF_PLAY,
3458
+ PUBLISH_PARTICIPANTS,
3446
3459
  UNPUBLISH_EVENT_SEEDING,
3447
3460
  UNPUBLISH_EVENT,
3448
3461
  UNPUBLISH_ORDER_OF_PLAY,
@@ -11537,12 +11550,16 @@ function addScheduleItem(params) {
11537
11550
  }
11538
11551
  }
11539
11552
 
11540
- function getTournamentPublishStatus({ tournamentRecord, status = PUBLIC }) {
11553
+ function getTournamentPublishStatus(params) {
11554
+ const paramsCheck = checkRequiredParameters(params, [{ [TOURNAMENT_RECORD]: true }]);
11555
+ if (paramsCheck.error)
11556
+ return paramsCheck;
11557
+ const { tournamentRecord, status = PUBLIC } = params;
11541
11558
  const itemType = `${PUBLISH}.${STATUS$1}`;
11542
- return getTournamentTimeItem({
11559
+ return makeDeepCopy(getTournamentTimeItem({
11543
11560
  tournamentRecord,
11544
11561
  itemType,
11545
- })?.timeItem?.itemValue?.[status];
11562
+ })?.timeItem?.itemValue?.[status], false, true);
11546
11563
  }
11547
11564
 
11548
11565
  function isValidTournamentRecord(tournamentRecord) {
@@ -11637,6 +11654,8 @@ function getPublishState(params) {
11637
11654
  if (tournamentRecord) {
11638
11655
  const pubStatus = getTournamentPublishStatus({ tournamentRecord });
11639
11656
  publishState.tournament = pubStatus ?? {};
11657
+ if (pubStatus?.orderOfPlay?.published || pubStatus?.participants?.published)
11658
+ tournamentPublished = true;
11640
11659
  publishState.tournament.status = { published: tournamentPublished, publishedEventIds };
11641
11660
  }
11642
11661
  return { ...SUCCESS, publishState };
@@ -20613,12 +20632,12 @@ const headToHeadTallyDirectives = [
20613
20632
  const GEMScoreValueMap = {
20614
20633
  matchUpsPct: 20,
20615
20634
  tieMatchUpsPct: 16,
20616
- setsPct: 12,
20617
- gamesPct: 8,
20618
20635
  pointsPct: 4,
20636
+ gamesPct: 8,
20637
+ setsPct: 12,
20619
20638
  };
20620
20639
  function getGroupOrder(params) {
20621
- const { requireCompletion = true, participantResults, subOrderMap, tallyPolicy } = params;
20640
+ const { requireCompletion = true, participantResults, subOrderMap, tallyPolicy, } = params;
20622
20641
  const report = [];
20623
20642
  if (requireCompletion && !isComplete(params)) {
20624
20643
  return {};
@@ -20643,16 +20662,20 @@ function getGroupOrder(params) {
20643
20662
  attribute,
20644
20663
  });
20645
20664
  report.push({ attribute, groups: orderedTallyGroups });
20646
- const groupOrder = Object.keys(orderedTallyGroups)
20665
+ const sortedTallyGroups = Object.keys(orderedTallyGroups)
20647
20666
  .map((key) => parseFloat(key))
20648
20667
  .sort((a, b) => b - a)
20649
- .map((key) => orderedTallyGroups[key])
20650
- .map((participantIds) => {
20668
+ .map((key) => orderedTallyGroups[key]);
20669
+ const sortedOrder = sortedTallyGroups.map((participantIds) => {
20651
20670
  const result = groupSubSort({ participantIds, ...params });
20652
20671
  report.push(...(result.report ?? []));
20653
20672
  return result.order;
20654
- })
20655
- .flat(Infinity);
20673
+ });
20674
+ const groupOrder = sortedOrder
20675
+ .map((order, oi) => order.map((o) => (o.resolved ? o : { ...o, subGroup: [oi].concat(...(o.subGroup ?? [])) })))
20676
+ .flat();
20677
+ let lastSubGroup;
20678
+ let subGroupCount = 0;
20656
20679
  let groupPosition = 1;
20657
20680
  let priorPositionResolution;
20658
20681
  groupOrder.forEach((finishingPosition, index) => {
@@ -20662,13 +20685,20 @@ function getGroupOrder(params) {
20662
20685
  groupPosition += 1;
20663
20686
  }
20664
20687
  priorPositionResolution = finishingPosition.resolved;
20688
+ const subGroup = parseInt(finishingPosition.subGroup?.join('') || 0);
20665
20689
  if (finishingPosition.resolved) {
20666
20690
  finishingPosition.position = index + 1;
20667
20691
  groupPosition = finishingPosition.position;
20668
20692
  }
20669
20693
  else {
20694
+ if (lastSubGroup && subGroup > lastSubGroup) {
20695
+ groupPosition += subGroupCount;
20696
+ subGroupCount = 0;
20697
+ }
20670
20698
  finishingPosition.position = groupPosition;
20699
+ subGroupCount += 1;
20671
20700
  }
20701
+ lastSubGroup = subGroup;
20672
20702
  });
20673
20703
  const positions = groupOrder.map(({ position }) => position);
20674
20704
  const positionsCount = instanceCount(positions);
@@ -20717,11 +20747,11 @@ function processAttribute({ disableHeadToHead, participantIds, matchUpFormat, ta
20717
20747
  const report = [{ attribute, reversed, groups, idsFilter }];
20718
20748
  let order;
20719
20749
  if (Object.keys(groups).length > 1 && participantIds.length) {
20720
- order = Object.keys(groups)
20750
+ const sortedTallyGroups = Object.keys(groups)
20721
20751
  .map((key) => parseFloat(key))
20722
20752
  .sort((a, b) => (reversed ? a - b : b - a))
20723
- .map((key) => groups[key])
20724
- .map((participantIds) => {
20753
+ .map((key) => groups[key]);
20754
+ const sortedOrder = sortedTallyGroups.map((participantIds) => {
20725
20755
  const result = groupSubSort({
20726
20756
  participantResults,
20727
20757
  disableHeadToHead,
@@ -20732,8 +20762,10 @@ function processAttribute({ disableHeadToHead, participantIds, matchUpFormat, ta
20732
20762
  });
20733
20763
  report.push(...(result.report ?? []));
20734
20764
  return result.order;
20735
- })
20736
- .flat(Infinity);
20765
+ });
20766
+ order = sortedOrder
20767
+ .map((order, oi) => order.map((o) => (o.resolved ? o : { ...o, subGroup: [oi].concat(...(o.subGroup ?? [])) })))
20768
+ .flat();
20737
20769
  }
20738
20770
  return { order, report };
20739
20771
  }
@@ -20749,11 +20781,11 @@ function groupSubSort({ participantResults, disableHeadToHead, participantIds, m
20749
20781
  }
20750
20782
  if (participantIds?.length === 2 &&
20751
20783
  (!tallyPolicy?.headToHead || (!tallyPolicy.headToHead.disabled && !disableHeadToHead))) {
20752
- const result = headToHeadWinner({ participantIds, participantResults });
20784
+ const result = getHeadToHeadWinner({ participantIds, participantResults });
20753
20785
  if (result) {
20754
20786
  const headToHeadWinner = result[0].participantId;
20755
20787
  report.push({ attribute: 'head2Head', participantIds, headToHeadWinner });
20756
- return { order: [result], headToHeadWinner, report };
20788
+ return { order: result, headToHeadWinner, report };
20757
20789
  }
20758
20790
  }
20759
20791
  const directives = tallyPolicy?.tallyDirectives || headToHeadTallyDirectives;
@@ -20786,7 +20818,7 @@ function groupSubSort({ participantResults, disableHeadToHead, participantIds, m
20786
20818
  report,
20787
20819
  };
20788
20820
  }
20789
- function headToHeadWinner({ participantIds, participantResults }) {
20821
+ function getHeadToHeadWinner({ participantIds, participantResults }) {
20790
20822
  if (!participantIds)
20791
20823
  return;
20792
20824
  if (participantResults[participantIds[0]].victories.includes(participantIds[1])) {
@@ -20998,16 +21030,13 @@ function getMatchUp$1({ matchUps, matchUpId }) {
20998
21030
  return { matchUp };
20999
21031
  }
21000
21032
 
21001
- function findDrawMatchUp({ tournamentParticipants, afterRecoveryTimes, contextContent, contextProfile, drawDefinition, matchUpsMap, matchUpId, inContext, context, event, }) {
21002
- if (!drawDefinition)
21003
- return { error: MISSING_DRAW_DEFINITION };
21004
- if (!matchUpId)
21005
- return { error: MISSING_MATCHUP_ID };
21006
- if (typeof matchUpId !== 'string')
21007
- return { error: INVALID_VALUES };
21033
+ function findDrawMatchUp(params) {
21034
+ const paramsCheck = checkRequiredParameters(params, [{ [DRAW_DEFINITION]: true, [MATCHUP_ID]: true }]);
21035
+ if (paramsCheck.error)
21036
+ return paramsCheck;
21037
+ const { tournamentParticipants, afterRecoveryTimes, contextProfile, drawDefinition, matchUpsMap, matchUpId, inContext, context, event, } = params;
21008
21038
  const { structures = [] } = getDrawStructures({ drawDefinition });
21009
- if (contextProfile && !contextContent)
21010
- contextContent = getContextContent({ contextProfile, drawDefinition });
21039
+ const contextContent = params.contextContent || (contextProfile && getContextContent({ contextProfile, drawDefinition }));
21011
21040
  for (const structure of structures) {
21012
21041
  const { matchUps } = getAllStructureMatchUps({
21013
21042
  tournamentParticipants,
@@ -21865,30 +21894,9 @@ function validateTieFormat(params) {
21865
21894
  const event = params?.event;
21866
21895
  const stack = 'validateTieFormat';
21867
21896
  const errors = [];
21868
- if (!params || !tieFormat || typeof tieFormat !== 'object') {
21869
- errors.push('tieFormat must be an object');
21870
- return decorateResult({
21871
- result: { error: INVALID_TIE_FORMAT },
21872
- context: { tieFormat, errors },
21873
- stack,
21874
- });
21875
- }
21876
- if (typeof tieFormat.winCriteria !== 'object') {
21877
- errors.push('tieFormat.winCriteria must be an object');
21878
- return decorateResult({
21879
- result: { error: INVALID_TIE_FORMAT },
21880
- context: { tieFormat, errors },
21881
- stack,
21882
- });
21883
- }
21884
- if (!Array.isArray(tieFormat.collectionDefinitions)) {
21885
- errors.push(mustBeAnArray('tieFormat.collectionDefinitions'));
21886
- return decorateResult({
21887
- result: { error: INVALID_TIE_FORMAT },
21888
- context: { tieFormat, errors },
21889
- stack,
21890
- });
21891
- }
21897
+ const paramsCheck = checkParams$1({ ...params, stack });
21898
+ if (paramsCheck?.error)
21899
+ return paramsCheck;
21892
21900
  let aggregateValueImperative;
21893
21901
  const validCollections = tieFormat.collectionDefinitions.every((collectionDefinition) => {
21894
21902
  const { setValue, scoreValue, collectionValue } = collectionDefinition;
@@ -21941,6 +21949,31 @@ function validateTieFormat(params) {
21941
21949
  }
21942
21950
  return result;
21943
21951
  }
21952
+ function checkParams$1(params) {
21953
+ const { tieFormat, stack } = params;
21954
+ if (!params || !tieFormat || !isObject(tieFormat)) {
21955
+ return decorateResult({
21956
+ result: { error: INVALID_TIE_FORMAT },
21957
+ context: { tieFormat, message: 'tieformat must be an object' },
21958
+ stack,
21959
+ });
21960
+ }
21961
+ if (!isObject(tieFormat.winCriteria)) {
21962
+ return decorateResult({
21963
+ result: { error: INVALID_TIE_FORMAT },
21964
+ context: { tieFormat, message: 'tieformat.winCritiera must be an object' },
21965
+ stack,
21966
+ });
21967
+ }
21968
+ if (!Array.isArray(tieFormat.collectionDefinitions)) {
21969
+ return decorateResult({
21970
+ result: { error: INVALID_TIE_FORMAT },
21971
+ context: { tieFormat, message: 'collectionDefinitions must be an array' },
21972
+ stack,
21973
+ });
21974
+ }
21975
+ return { ...SUCCESS };
21976
+ }
21944
21977
 
21945
21978
  function generateTieMatchUpScore(params) {
21946
21979
  const { sideAdjustments = [0, 0], separator = '-', drawDefinition, matchUpsMap, structure, matchUp, event, } = params;
@@ -30547,13 +30580,13 @@ function validateScore({ existingMatchUpStatus, matchUpFormat, matchUpStatus, wi
30547
30580
  [side1TiebreakScore, side2TiebreakScore],
30548
30581
  [side1PointScore, side2PointScore],
30549
30582
  ]
30550
- .filter((pair) => pair.some((value) => value !== undefined))
30583
+ .filter((pair) => pair.some((value) => ![undefined, null].includes(value)))
30551
30584
  .every((pair) => pair.every((numericValue) => isConvertableInteger(numericValue)));
30552
30585
  if (!numericValuePairs) {
30553
30586
  return { error: INVALID_VALUES, info: 'non-numeric values' };
30554
30587
  }
30555
30588
  const numericValues = [setNumber, winningSide]
30556
- .filter((value) => value !== undefined)
30589
+ .filter((value) => ![undefined, null].includes(value))
30557
30590
  .every((numericValue) => isConvertableInteger(numericValue));
30558
30591
  if (!numericValues) {
30559
30592
  return { error: INVALID_VALUES, info: 'non-numeric values' };
@@ -33644,6 +33677,7 @@ function getTournamentInfo(params) {
33644
33677
  eventInfo.push(info);
33645
33678
  }
33646
33679
  }
33680
+ tournamentInfo.publishState = publishState?.tournament;
33647
33681
  tournamentInfo.eventInfo = eventInfo;
33648
33682
  return {
33649
33683
  tournamentInfo: makeDeepCopy(tournamentInfo, false, true),
@@ -34598,6 +34632,7 @@ var query$5 = {
34598
34632
  getEventData: getEventData,
34599
34633
  getEventPublishStatus: getEventPublishStatus,
34600
34634
  getPublishState: getPublishState,
34635
+ getTournamentPublishStatus: getTournamentPublishStatus,
34601
34636
  getVenueData: getVenueData
34602
34637
  };
34603
34638
 
@@ -35981,11 +36016,9 @@ function competitionScheduleMatchUps(params) {
35981
36016
  const getResult = getSchedulingProfile(params);
35982
36017
  const schedulingProfile = getResult.schedulingProfile;
35983
36018
  const { sortDateMatchUps = true, courtCompletedMatchUps, alwaysReturnCompleted, activeTournamentId, tournamentRecords, withCourtGridRows, minCourtGridRows, usePublishState, status = PUBLIC, sortCourtsData, } = params;
36019
+ const tournamentId = activeTournamentId ?? getTournamentId() ?? Object.keys(tournamentRecords)[0];
35984
36020
  const tournamentPublishStatus = usePublishState
35985
- ? getTournamentTimeItem({
35986
- tournamentRecord: tournamentRecords[activeTournamentId ?? getTournamentId() ?? Object.keys(tournamentRecords)[0]],
35987
- itemType: `${PUBLISH}.${STATUS$1}`,
35988
- }).timeItem?.itemValue?.[status]
36021
+ ? getTournamentPublishStatus({ tournamentRecord: tournamentRecords[tournamentId], status })
35989
36022
  : undefined;
35990
36023
  const allCompletedMatchUps = alwaysReturnCompleted
35991
36024
  ? getCompetitionMatchUps({
@@ -35997,7 +36030,7 @@ function competitionScheduleMatchUps(params) {
35997
36030
  contextFilters: params.contextFilters,
35998
36031
  }).completedMatchUps
35999
36032
  : [];
36000
- if (usePublishState && (!tournamentPublishStatus || !Object.keys(tournamentPublishStatus).length)) {
36033
+ if (usePublishState && !tournamentPublishStatus?.orderOfPlay?.published) {
36001
36034
  return {
36002
36035
  completedMatchUps: allCompletedMatchUps,
36003
36036
  dateMatchUps: [],
@@ -37335,6 +37368,7 @@ var index$f = {
37335
37368
  getTournamentInfo: getTournamentInfo,
37336
37369
  getTournamentPenalties: getTournamentPenalties,
37337
37370
  getTournamentPersons: getTournamentPersons,
37371
+ getTournamentPublishStatus: getTournamentPublishStatus,
37338
37372
  getTournamentStructures: getTournamentStructures,
37339
37373
  getTournamentTimeItem: getTournamentTimeItem,
37340
37374
  getValidGroupSizes: getValidGroupSizes,
@@ -39532,8 +39566,86 @@ function modifyEvent(params) {
39532
39566
  ]);
39533
39567
  if (paramsCheck.error)
39534
39568
  return paramsCheck;
39535
- const { tournamentRecord, eventUpdates, event } = params;
39569
+ const { eventUpdates, event } = params;
39536
39570
  const stack = 'modifyEvent';
39571
+ const enteredParticipants = getEnteredParticipants(params);
39572
+ const participantsProfile = getParticipantsProfile({ enteredParticipants });
39573
+ const { enteredParticipantGenders, enteredParticipantTypes } = participantsProfile;
39574
+ const genderResult = checkGenderUpdates({ enteredParticipantGenders, eventUpdates, stack });
39575
+ if (genderResult.error)
39576
+ return genderResult;
39577
+ const eventTypeResult = checkEventType({ enteredParticipantTypes, eventUpdates, stack });
39578
+ if (eventTypeResult.error)
39579
+ return eventTypeResult;
39580
+ const categoryResult = checkCategoryUpdates({ ...params, ...participantsProfile, enteredParticipants, stack });
39581
+ if (categoryResult.error)
39582
+ return categoryResult;
39583
+ const dateResult = dateUpdates({ ...params, stack });
39584
+ if (dateResult.error)
39585
+ return dateResult;
39586
+ if (eventUpdates.eventType)
39587
+ event.eventType = eventUpdates.eventType;
39588
+ if (eventUpdates.eventName)
39589
+ event.eventName = eventUpdates.eventName;
39590
+ if (eventUpdates.gender)
39591
+ event.gender = eventUpdates.gender;
39592
+ return { ...SUCCESS };
39593
+ }
39594
+ function checkCategoryUpdates(params) {
39595
+ const category = params.eventUpdates?.category;
39596
+ if (!category)
39597
+ return { ...SUCCESS };
39598
+ const categoryCheck = validateCategory({ category });
39599
+ if (categoryCheck.error)
39600
+ return categoryCheck;
39601
+ if (params.event.eventType === TEAM$2) {
39602
+ const drawTieFormats = params.event?.drawDefinitions?.map((draw) => getObjectTieFormat(draw)) ?? [];
39603
+ const eventTieFormat = getObjectTieFormat(params.event);
39604
+ const eventMatchUps = allEventMatchUps(params)?.matchUps ?? [];
39605
+ const matchUpTieFormats = eventMatchUps.map((matchUp) => getObjectTieFormat(matchUp)) ?? [];
39606
+ const tieFormats = [eventTieFormat, ...drawTieFormats, ...matchUpTieFormats].filter(Boolean);
39607
+ const validCategory = tieFormats.every((tieFormat) => tieFormat.collectionDefinitions.every((cd) => !cd.category || categoryCanContain({ category: params.eventUpdates.category, childCategory: cd.category })));
39608
+ if (!validCategory)
39609
+ return decorateResult({ result: { error: INVALID_CATEGORY }, stack: params.stack });
39610
+ }
39611
+ if (params.enteredParticipants?.length) {
39612
+ const startDate = params.eventUpdates.startDate || params.event.startDate || params.tournamentRecord.startDate;
39613
+ const endDate = params.eventUpdates.endDate || params.event.endDate || params.tournamentRecord.endDate;
39614
+ const individualParticpants = params.enteredParticipants
39615
+ .map((p) => (p.participantType === INDIVIDUAL ? p : p.individualParticpants ?? []))
39616
+ .flat();
39617
+ const startAgeDetails = getCategoryAgeDetails({ category, consideredDate: startDate });
39618
+ const endAgeDetails = getCategoryAgeDetails({ category, consideredDate: endDate });
39619
+ if (startAgeDetails?.ageMinDate ||
39620
+ startAgeDetails?.ageMaxDate ||
39621
+ endAgeDetails?.ageMinDate ||
39622
+ endAgeDetails?.ageMaxDate) {
39623
+ for (const individualParticipant of individualParticpants) {
39624
+ const birthDate = individualParticipant.person?.birthDate;
39625
+ if (!birthDate)
39626
+ return decorateResult({ result: { error: MISSING_BIRTH_DATE }, stack: params.stack });
39627
+ const birthTime = new Date(birthDate).getTime();
39628
+ if (startAgeDetails.ageMinDate || startAgeDetails.ageMaxDate) {
39629
+ const minTime = new Date(startAgeDetails.ageMinDate).getTime();
39630
+ const maxTime = new Date(startAgeDetails.ageMaxDate).getTime();
39631
+ if (birthTime < minTime || birthTime > maxTime) {
39632
+ return decorateResult({ result: { error: CATEGORY_MISMATCH }, stack: params.stack });
39633
+ }
39634
+ }
39635
+ if (endAgeDetails.ageMin || endAgeDetails.ageMax) {
39636
+ const minTime = new Date(endAgeDetails.ageMinDate).getTime();
39637
+ const maxTime = new Date(endAgeDetails.ageMaxDate).getTime();
39638
+ if (birthTime < minTime || birthTime > maxTime) {
39639
+ return decorateResult({ result: { error: CATEGORY_MISMATCH }, stack: params.stack });
39640
+ }
39641
+ }
39642
+ }
39643
+ }
39644
+ }
39645
+ return { ...SUCCESS };
39646
+ }
39647
+ function dateUpdates(params) {
39648
+ const { tournamentRecord, eventUpdates, event, stack } = params;
39537
39649
  if (eventUpdates.startDate || eventUpdates.endDate) {
39538
39650
  const result = setEventDates({
39539
39651
  startDate: eventUpdates.startDate,
@@ -39544,19 +39656,25 @@ function modifyEvent(params) {
39544
39656
  if (result.error)
39545
39657
  return decorateResult({ result, stack });
39546
39658
  }
39659
+ return { ...SUCCESS };
39660
+ }
39661
+ function getEnteredParticipants(params) {
39662
+ const { tournamentRecord, event } = params;
39547
39663
  const enteredParticipantIds = event?.entries
39548
39664
  ?.filter(({ entryStatus }) => {
39549
39665
  const status = entryStatus;
39550
39666
  return [...STRUCTURE_SELECTED_STATUSES, ALTERNATE].includes(status);
39551
39667
  })
39552
39668
  .map(({ participantId }) => participantId) ?? [];
39553
- const enteredParticipants = enteredParticipantIds
39669
+ return enteredParticipantIds
39554
39670
  ? getParticipants({
39555
39671
  participantFilters: { participantIds: enteredParticipantIds },
39556
39672
  withIndividualParticipants: true,
39557
39673
  tournamentRecord,
39558
39674
  }).participants ?? []
39559
39675
  : [];
39676
+ }
39677
+ function getParticipantsProfile({ enteredParticipants }) {
39560
39678
  const genderAccumulator = [];
39561
39679
  const enteredParticipantTypes = enteredParticipants.reduce((types, participant) => {
39562
39680
  const genders = participant.person?.sex
@@ -39566,32 +39684,32 @@ function modifyEvent(params) {
39566
39684
  return !types.includes(participant.participantType) ? types.concat(participant.participantType) : types;
39567
39685
  }, []);
39568
39686
  const enteredParticipantGenders = unique(genderAccumulator);
39687
+ return { enteredParticipantTypes, enteredParticipantGenders };
39688
+ }
39689
+ function checkGenderUpdates({ enteredParticipantGenders, eventUpdates, stack }) {
39569
39690
  const validGender = !enteredParticipantGenders.length ||
39570
39691
  [MIXED, ANY].includes(eventUpdates.gender ?? '') ||
39571
39692
  (enteredParticipantGenders.length === 1 && enteredParticipantGenders[0] === eventUpdates.gender);
39572
- if (eventUpdates.gender && !validGender)
39573
- return decorateResult({
39693
+ return eventUpdates.gender && !validGender
39694
+ ? decorateResult({
39574
39695
  context: { gender: eventUpdates.gender, validGender },
39575
- result: { error: INVALID_VALUES },
39696
+ result: { error: INVALID_GENDER },
39576
39697
  stack,
39577
- });
39698
+ })
39699
+ : { ...SUCCESS };
39700
+ }
39701
+ function checkEventType({ enteredParticipantTypes, eventUpdates, stack }) {
39578
39702
  const validEventTypes = (enteredParticipantTypes.includes(TEAM$2) && [TEAM$2]) ||
39579
39703
  (enteredParticipantTypes.includes(INDIVIDUAL) && [SINGLES$1]) ||
39580
39704
  (enteredParticipantTypes.includes(PAIR) && [DOUBLES$1]) || [DOUBLES$1, SINGLES$1, TEAM$2];
39581
39705
  const validEventType = validEventTypes.includes(eventUpdates.eventType ?? '');
39582
- if (eventUpdates.eventType && !validEventType)
39583
- return decorateResult({
39706
+ return eventUpdates.eventType && !validEventType
39707
+ ? decorateResult({
39584
39708
  context: { participantType: eventUpdates.eventType, validEventType },
39585
- result: { error: INVALID_VALUES },
39709
+ result: { error: INVALID_EVENT_TYPE },
39586
39710
  stack,
39587
- });
39588
- if (eventUpdates.eventType)
39589
- event.eventType = eventUpdates.eventType;
39590
- if (eventUpdates.eventName)
39591
- event.eventName = eventUpdates.eventName;
39592
- if (eventUpdates.gender)
39593
- event.gender = eventUpdates.gender;
39594
- return { ...SUCCESS };
39711
+ })
39712
+ : { ...SUCCESS };
39595
39713
  }
39596
39714
 
39597
39715
  function addFlight({ qualifyingPositions, drawEntries = [], drawName, drawId, event, stage, }) {
@@ -46682,7 +46800,7 @@ function v2Scheduler({ schedulingProfileModifications, checkPotentialRequestConf
46682
46800
  }
46683
46801
 
46684
46802
  function clearScheduledMatchUps(params) {
46685
- const { scheduleAttributes = ['scheduledDate', 'scheduledTime'], ignoreMatchUpStatuses = completedMatchUpStatuses, scheduledDates, venueIds, } = params;
46803
+ const { scheduleAttributes = ['scheduledDate', 'scheduledTime', 'courtOrder'], ignoreMatchUpStatuses = completedMatchUpStatuses, scheduledDates, venueIds, } = params;
46686
46804
  const tournamentRecords = resolveTournamentRecords(params);
46687
46805
  const tournamentIds = isObject(tournamentRecords)
46688
46806
  ? Object.values(tournamentRecords)
@@ -46707,7 +46825,7 @@ function clearScheduledMatchUps(params) {
46707
46825
  }
46708
46826
  return { ...SUCCESS, clearedScheduleCount };
46709
46827
  }
46710
- function clearSchedules({ scheduleAttributes = ['scheduledDate', 'scheduledTime'], ignoreMatchUpStatuses = completedMatchUpStatuses, tournamentRecord, scheduledDates, venueIds = [], }) {
46828
+ function clearSchedules({ scheduleAttributes = ['scheduledDate', 'scheduledTime', 'courtOrder'], ignoreMatchUpStatuses = completedMatchUpStatuses, tournamentRecord, scheduledDates, venueIds = [], }) {
46711
46829
  if (typeof tournamentRecord !== 'object')
46712
46830
  return { error: MISSING_TOURNAMENT_RECORD };
46713
46831
  if (!Array.isArray(ignoreMatchUpStatuses) || !Array.isArray(venueIds)) {
@@ -46738,7 +46856,7 @@ function clearSchedules({ scheduleAttributes = ['scheduledDate', 'scheduledTime'
46738
46856
  let modified = false;
46739
46857
  matchUp.timeItems = (matchUp.timeItems ?? []).filter((timeItem) => {
46740
46858
  const preserve = timeItem?.itemType &&
46741
- ![ALLOCATE_COURTS, ASSIGN_COURT, ASSIGN_VENUE, SCHEDULED_DATE, SCHEDULED_TIME].includes(timeItem?.itemType);
46859
+ ![ALLOCATE_COURTS, ASSIGN_COURT, ASSIGN_VENUE, COURT_ORDER, SCHEDULED_DATE, SCHEDULED_TIME].includes(timeItem?.itemType);
46742
46860
  if (!preserve)
46743
46861
  modified = true;
46744
46862
  return preserve;
@@ -51786,39 +51904,58 @@ function unPublishEventSeeding({ removePriorValues = true, seedingScaleNames, to
51786
51904
  return { ...SUCCESS };
51787
51905
  }
51788
51906
 
51789
- function unPublishOrderOfPlay(params) {
51790
- const tournamentRecords = params?.tournamentRecords ??
51791
- (params?.tournamentRecord && {
51792
- [params.tournamentRecord.tournamentId]: params.tournamentRecord,
51793
- }) ??
51794
- {};
51907
+ function unPublishParticipants(params) {
51908
+ const tournamentRecords = resolveTournamentRecords(params);
51795
51909
  if (!Object.keys(tournamentRecords).length)
51796
51910
  return { error: MISSING_TOURNAMENT_RECORDS };
51797
51911
  for (const tournamentRecord of Object.values(tournamentRecords)) {
51798
- const result = unPublishOOP({
51799
- tournamentRecord,
51800
- ...params,
51801
- });
51912
+ const result = unpublish({ tournamentRecord, ...params });
51802
51913
  if (result.error)
51803
51914
  return result;
51804
51915
  }
51805
51916
  return { ...SUCCESS };
51806
51917
  }
51807
- function unPublishOOP({ removePriorValues = true, tournamentRecord, status = PUBLIC }) {
51918
+ function unpublish({ removePriorValues = true, tournamentRecord, status = PUBLIC }) {
51808
51919
  if (!tournamentRecord)
51809
51920
  return { error: MISSING_TOURNAMENT_RECORD };
51810
51921
  const itemType = `${PUBLISH}.${STATUS$1}`;
51811
- const { timeItem } = getTimeItem({
51922
+ const { timeItem } = getTimeItem({ element: tournamentRecord, itemType });
51923
+ const itemValue = timeItem?.itemValue || { [status]: {} };
51924
+ if (itemValue[status])
51925
+ delete itemValue[status].participants;
51926
+ const updatedTimeItem = { itemValue, itemType };
51927
+ addTimeItem({
51928
+ timeItem: updatedTimeItem,
51812
51929
  element: tournamentRecord,
51813
- itemType,
51930
+ removePriorValues,
51814
51931
  });
51932
+ addNotice({
51933
+ payload: { tournamentId: tournamentRecord.tournamentId },
51934
+ topic: UNPUBLISH_PARTICIPANTS,
51935
+ });
51936
+ return { ...SUCCESS };
51937
+ }
51938
+
51939
+ function unPublishOrderOfPlay(params) {
51940
+ const tournamentRecords = resolveTournamentRecords(params);
51941
+ if (!Object.keys(tournamentRecords).length)
51942
+ return { error: MISSING_TOURNAMENT_RECORDS };
51943
+ for (const tournamentRecord of Object.values(tournamentRecords)) {
51944
+ const result = unPublishOOP({ tournamentRecord, ...params });
51945
+ if (result.error)
51946
+ return result;
51947
+ }
51948
+ return { ...SUCCESS };
51949
+ }
51950
+ function unPublishOOP({ removePriorValues = true, tournamentRecord, status = PUBLIC }) {
51951
+ if (!tournamentRecord)
51952
+ return { error: MISSING_TOURNAMENT_RECORD };
51953
+ const itemType = `${PUBLISH}.${STATUS$1}`;
51954
+ const { timeItem } = getTimeItem({ element: tournamentRecord, itemType });
51815
51955
  const itemValue = timeItem?.itemValue || { [status]: {} };
51816
51956
  if (itemValue[status])
51817
51957
  delete itemValue[status].orderOfPlay;
51818
- const updatedTimeItem = {
51819
- itemValue,
51820
- itemType,
51821
- };
51958
+ const updatedTimeItem = { itemValue, itemType };
51822
51959
  addTimeItem({
51823
51960
  timeItem: updatedTimeItem,
51824
51961
  element: tournamentRecord,
@@ -51833,34 +51970,56 @@ function unPublishOOP({ removePriorValues = true, tournamentRecord, status = PUB
51833
51970
  return { ...SUCCESS };
51834
51971
  }
51835
51972
 
51836
- function publishOrderOfPlay(params) {
51973
+ function publishParticipants(params) {
51837
51974
  const tournamentRecords = resolveTournamentRecords(params);
51838
51975
  if (!Object.keys(tournamentRecords).length)
51839
51976
  return { error: MISSING_TOURNAMENT_RECORDS };
51840
51977
  for (const tournamentRecord of Object.values(tournamentRecords)) {
51841
- const result = publishOOP({
51842
- tournamentRecord,
51843
- ...params,
51844
- });
51978
+ const result = publish({ tournamentRecord, ...params });
51845
51979
  if (result.error)
51846
51980
  return result;
51847
51981
  }
51848
51982
  return { ...SUCCESS };
51849
51983
  }
51850
- function publishOOP({ scheduledDates = [], removePriorValues, tournamentRecord, status = PUBLIC, eventIds = [] }) {
51984
+ function publish({ removePriorValues, tournamentRecord, status = PUBLIC }) {
51851
51985
  if (!tournamentRecord)
51852
51986
  return { error: MISSING_TOURNAMENT_RECORD };
51853
51987
  const itemType = `${PUBLISH}.${STATUS$1}`;
51854
- const { timeItem } = getTimeItem({
51988
+ const { timeItem } = getTimeItem({ element: tournamentRecord, itemType });
51989
+ const itemValue = timeItem?.itemValue || { [status]: {} };
51990
+ itemValue[status].participants = { published: true };
51991
+ const updatedTimeItem = { itemValue, itemType };
51992
+ addTimeItem({
51993
+ timeItem: updatedTimeItem,
51855
51994
  element: tournamentRecord,
51856
- itemType,
51995
+ removePriorValues,
51857
51996
  });
51997
+ addNotice({
51998
+ payload: { tournamentId: tournamentRecord.tournamentId },
51999
+ topic: PUBLISH_PARTICIPANTS,
52000
+ });
52001
+ return { ...SUCCESS };
52002
+ }
52003
+
52004
+ function publishOrderOfPlay(params) {
52005
+ const tournamentRecords = resolveTournamentRecords(params);
52006
+ if (!Object.keys(tournamentRecords).length)
52007
+ return { error: MISSING_TOURNAMENT_RECORDS };
52008
+ for (const tournamentRecord of Object.values(tournamentRecords)) {
52009
+ const result = publishOOP({ tournamentRecord, ...params });
52010
+ if (result.error)
52011
+ return result;
52012
+ }
52013
+ return { ...SUCCESS };
52014
+ }
52015
+ function publishOOP({ scheduledDates = [], removePriorValues, tournamentRecord, status = PUBLIC, eventIds = [] }) {
52016
+ if (!tournamentRecord)
52017
+ return { error: MISSING_TOURNAMENT_RECORD };
52018
+ const itemType = `${PUBLISH}.${STATUS$1}`;
52019
+ const { timeItem } = getTimeItem({ element: tournamentRecord, itemType });
51858
52020
  const itemValue = timeItem?.itemValue || { [status]: {} };
51859
52021
  itemValue[status].orderOfPlay = { published: true, scheduledDates, eventIds };
51860
- const updatedTimeItem = {
51861
- itemValue,
51862
- itemType,
51863
- };
52022
+ const updatedTimeItem = { itemValue, itemType };
51864
52023
  addTimeItem({
51865
52024
  timeItem: updatedTimeItem,
51866
52025
  element: tournamentRecord,
@@ -51918,10 +52077,12 @@ var mutate$4 = {
51918
52077
  publishEvent: publishEvent,
51919
52078
  publishEventSeeding: publishEventSeeding,
51920
52079
  publishOrderOfPlay: publishOrderOfPlay,
52080
+ publishParticipants: publishParticipants,
51921
52081
  setEventDisplay: setEventDisplay,
51922
52082
  unPublishEvent: unPublishEvent,
51923
52083
  unPublishEventSeeding: unPublishEventSeeding,
51924
- unPublishOrderOfPlay: unPublishOrderOfPlay
52084
+ unPublishOrderOfPlay: unPublishOrderOfPlay,
52085
+ unPublishParticipants: unPublishParticipants
51925
52086
  };
51926
52087
 
51927
52088
  var index$7 = {
@@ -51933,16 +52094,19 @@ var index$7 = {
51933
52094
  getEventData: getEventData,
51934
52095
  getEventPublishStatus: getEventPublishStatus,
51935
52096
  getPublishState: getPublishState,
52097
+ getTournamentPublishStatus: getTournamentPublishStatus,
51936
52098
  getVenueData: getVenueData,
51937
52099
  mutate: mutate$4,
51938
52100
  publishEvent: publishEvent,
51939
52101
  publishEventSeeding: publishEventSeeding,
51940
52102
  publishOrderOfPlay: publishOrderOfPlay,
52103
+ publishParticipants: publishParticipants,
51941
52104
  query: query$5,
51942
52105
  setEventDisplay: setEventDisplay,
51943
52106
  unPublishEvent: unPublishEvent,
51944
52107
  unPublishEventSeeding: unPublishEventSeeding,
51945
- unPublishOrderOfPlay: unPublishOrderOfPlay
52108
+ unPublishOrderOfPlay: unPublishOrderOfPlay,
52109
+ unPublishParticipants: unPublishParticipants
51946
52110
  };
51947
52111
 
51948
52112
  function getParticipantStats({ withCompetitiveProfiles, opponentParticipantId, withIndividualStats, teamParticipantId, tournamentRecord, withScaleValues, tallyPolicy, matchUps, }) {