tods-competition-factory 2.0.46 → 2.0.48

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.
@@ -6102,7 +6102,7 @@ type GenerateTournamentRecordArgs = {
6102
6102
  participantsProfile?: ParticipantsProfile;
6103
6103
  scheduleCompletedMatchUps?: boolean;
6104
6104
  tournamentExtensions?: Extension[];
6105
- policyDefinitions: PolicyDefinitions;
6105
+ policyDefinitions?: PolicyDefinitions;
6106
6106
  completeAllMatchUps?: boolean;
6107
6107
  tournamentAttributes?: any;
6108
6108
  ratingsParameters?: any;
@@ -9086,7 +9086,6 @@ declare function setTournamentNotes({ tournamentRecord, notes }: {
9086
9086
  };
9087
9087
  } | {
9088
9088
  success: boolean;
9089
- error?: undefined;
9090
9089
  };
9091
9090
  declare function setTournamentCategories({ tournamentRecord, categories }: {
9092
9091
  tournamentRecord: any;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  function factoryVersion() {
6
- return '2.0.46';
6
+ return '2.0.48';
7
7
  }
8
8
 
9
9
  function isFunction(obj) {
@@ -11921,7 +11921,7 @@ function getParticipantEntries(params) {
11921
11921
  const eventsPublishStatuses = {};
11922
11922
  const derivedEventInfo = {};
11923
11923
  const derivedDrawInfo = {};
11924
- const getRanking = ({ eventType, scaleNames, participantId }) => participantMap[participantId].participant?.rankings?.[eventType]?.find((ranking) => scaleNames.includes(ranking.scaleName))?.scaleValue;
11924
+ const getRanking = ({ eventType, scaleNames, participantId }) => participantMap[participantId]?.participant?.rankings?.[eventType]?.find((ranking) => scaleNames.includes(ranking.scaleName))?.scaleValue;
11925
11925
  for (const event of tournamentRecord?.events || []) {
11926
11926
  if (participantFilters?.eventIds && !participantFilters.eventIds.includes(event.eventId))
11927
11927
  continue;
@@ -12032,6 +12032,8 @@ function getParticipantEntries(params) {
12032
12032
  (eventPublishedSeeding?.published &&
12033
12033
  (eventPublishedSeeding?.drawIds?.length === 0 || eventPublishedSeeding?.drawIds?.includes(drawId)));
12034
12034
  for (const entry of relevantEntries) {
12035
+ if (!participantMap[entry.participantId])
12036
+ continue;
12035
12037
  const { entryStatus, entryStage, entryPosition, participantId } = entry;
12036
12038
  const ranking = getRanking({
12037
12039
  participantId,
@@ -12039,7 +12041,7 @@ function getParticipantEntries(params) {
12039
12041
  eventType,
12040
12042
  });
12041
12043
  const addParticipantDrawEntry = (id) => {
12042
- if (participantMap[id].draws?.[drawId])
12044
+ if (!participantMap[id] || participantMap[id].draws?.[drawId])
12043
12045
  return;
12044
12046
  const includeSeeding = withSeeding && seedingPublished;
12045
12047
  const seedAssignments = includeSeeding ? {} : undefined;
@@ -20887,21 +20889,19 @@ function findDrawMatchUp({ tournamentParticipants, afterRecoveryTimes, contextCo
20887
20889
  }
20888
20890
 
20889
20891
  function addNotes(params) {
20890
- if (typeof params !== 'object')
20892
+ if (!isObject(params) || !params.notes)
20891
20893
  return { error: MISSING_VALUE };
20892
- if (typeof params.element !== 'object')
20894
+ if (!isObject(params.element))
20893
20895
  return { error: INVALID_VALUES };
20894
- if (!params.notes)
20895
- return { error: MISSING_VALUE };
20896
- if (typeof params.notes !== 'string' && !params.notes?.testing)
20896
+ if (!isString(params.notes) && !params.notes?.testing)
20897
20897
  return { error: INVALID_VALUES };
20898
20898
  Object.assign(params.element, { notes: params.notes });
20899
20899
  return { ...SUCCESS };
20900
20900
  }
20901
20901
  function removeNotes(params) {
20902
- if (typeof params !== 'object')
20902
+ if (!isObject(params))
20903
20903
  return { error: MISSING_VALUE };
20904
- if (typeof params.element !== 'object')
20904
+ if (!isObject(params.element))
20905
20905
  return { error: INVALID_VALUES };
20906
20906
  if (params.element.notes)
20907
20907
  delete params.element.notes;
@@ -34189,7 +34189,9 @@ function getDrawData(params) {
34189
34189
  drawPosition,
34190
34190
  };
34191
34191
  });
34192
- if (matchUps.length && ((!participantResults?.length && params.allParticipantResults) || refreshResults)) {
34192
+ if (matchUps.length &&
34193
+ ((!participantResults?.length && params.allParticipantResults) ||
34194
+ (refreshResults && !structure.structures))) {
34193
34195
  const { subOrderMap } = createSubOrderMap({ positionAssignments });
34194
34196
  const result = tallyParticipantResults({
34195
34197
  matchUpFormat: structure.matchUpFormat,
@@ -40967,10 +40969,10 @@ function modifyParticipant(params) {
40967
40969
  newValues.contacts = contacts;
40968
40970
  if (onlineResources)
40969
40971
  newValues.onlineResources = onlineResources;
40970
- if (participantName && typeof participantName === 'string')
40971
- newValues.participantName = participantName;
40972
- if (participantOtherName && typeof participantOtherName === 'string')
40972
+ if (participantOtherName && isString(participantOtherName))
40973
40973
  newValues.participantOtherName = participantOtherName;
40974
+ if (participantName && isString(participantName))
40975
+ newValues.participantName = participantName;
40974
40976
  if (Array.isArray(individualParticipantIds)) {
40975
40977
  const { participants: individualParticipants } = getParticipants({
40976
40978
  participantFilters: { participantTypes: [INDIVIDUAL] },
@@ -40978,7 +40980,7 @@ function modifyParticipant(params) {
40978
40980
  });
40979
40981
  const allIndividualParticipantIds = individualParticipants?.map(getParticipantId);
40980
40982
  if (allIndividualParticipantIds) {
40981
- const updatedIndividualParticipantIds = individualParticipantIds.filter((participantId) => typeof participantId === 'string' && allIndividualParticipantIds.includes(participantId));
40983
+ const updatedIndividualParticipantIds = individualParticipantIds.filter((participantId) => isString(participantId) && allIndividualParticipantIds.includes(participantId));
40982
40984
  if ([GROUP, TEAM$1].includes(participantType || existingParticipant.participantType) ||
40983
40985
  (participantType === PAIR && (updatedIndividualParticipantIds.length === 2 || pairOverride))) {
40984
40986
  newValues.individualParticipantIds = updatedIndividualParticipantIds;
@@ -41040,23 +41042,22 @@ function generatePairParticipantName$1({ individualParticipants, newValues }) {
41040
41042
  }
41041
41043
  function updatePerson({ updateParticipantName, existingParticipant, newValues, person }) {
41042
41044
  const newPersonValues = {};
41043
- const { standardFamilyName, standardGivenName, nationalityCode, personId, sex } = person;
41045
+ const { standardFamilyName, standardGivenName, nationalityCode, personId, birthdate, tennisId, sex } = person;
41044
41046
  if (sex && Object.keys(genderConstants).includes(sex))
41045
41047
  newPersonValues.sex = sex;
41046
41048
  let personNameModified;
41047
- if (personId && typeof personId === 'string') {
41049
+ if (isString(personId))
41048
41050
  newPersonValues.personId = personId;
41049
- }
41050
41051
  if (nationalityCode &&
41051
- typeof nationalityCode === 'string' &&
41052
+ isString(nationalityCode) &&
41052
41053
  (validNationalityCode(nationalityCode) || nationalityCode === '')) {
41053
41054
  newPersonValues.nationalityCode = nationalityCode;
41054
41055
  }
41055
- if (standardFamilyName && typeof standardFamilyName === 'string' && standardFamilyName.length > 1) {
41056
+ if (standardFamilyName && typeof isString(standardFamilyName) && standardFamilyName.length > 1) {
41056
41057
  newPersonValues.standardFamilyName = standardFamilyName;
41057
41058
  personNameModified = true;
41058
41059
  }
41059
- if (standardGivenName && typeof standardGivenName === 'string' && standardGivenName.length > 1) {
41060
+ if (standardGivenName && typeof isString(standardGivenName) && standardGivenName.length > 1) {
41060
41061
  newPersonValues.standardGivenName = standardGivenName;
41061
41062
  personNameModified = true;
41062
41063
  }
@@ -41064,6 +41065,12 @@ function updatePerson({ updateParticipantName, existingParticipant, newValues, p
41064
41065
  const participantName = `${newPersonValues.standardGivenName} ${newPersonValues.standardFamilyName}`;
41065
41066
  newValues.participantName = participantName;
41066
41067
  }
41068
+ if (birthdate && isValidDateString(birthdate)) {
41069
+ newPersonValues.birthdate = birthdate;
41070
+ }
41071
+ if (tennisId && isString(tennisId)) {
41072
+ newPersonValues.tennisId = tennisId;
41073
+ }
41067
41074
  Object.assign(existingParticipant.person, newPersonValues);
41068
41075
  }
41069
41076
  function validNationalityCode(code) {
@@ -47716,13 +47723,13 @@ function generateParticipants(params) {
47716
47723
  participantType: INDIVIDUAL,
47717
47724
  participantName,
47718
47725
  person: {
47719
- addresses: [address],
47720
47726
  personId: personId || (personIds?.length && personIds[participantIndex]) || UUID(),
47727
+ birthDate: isValidDateString(birthDate) ? birthDate : undefined,
47728
+ addresses: [address],
47721
47729
  standardFamilyName,
47722
47730
  standardGivenName,
47723
47731
  nationalityCode,
47724
47732
  extensions,
47725
- birthDate: isValidDateString(birthDate) ? birthDate : undefined,
47726
47733
  sex,
47727
47734
  },
47728
47735
  });
@@ -55392,15 +55399,32 @@ function setTournamentName({ tournamentRecord, promotionalName, tournamentName,
55392
55399
  function setTournamentNotes({ tournamentRecord, notes }) {
55393
55400
  if (!tournamentRecord)
55394
55401
  return { error: MISSING_TOURNAMENT_RECORD };
55395
- return addNotes({ element: tournamentRecord, notes });
55402
+ const result = notes ? addNotes({ element: tournamentRecord, notes }) : removeNotes({ element: tournamentRecord });
55403
+ if (result.error)
55404
+ return result;
55405
+ addNotice({
55406
+ topic: MODIFY_TOURNAMENT_DETAIL,
55407
+ payload: {
55408
+ parentOrganisation: tournamentRecord.parentOrganisation,
55409
+ tournamentId: tournamentRecord.tournamentId,
55410
+ notes: notes ?? '',
55411
+ },
55412
+ });
55413
+ return { ...SUCCESS };
55396
55414
  }
55397
55415
  function setTournamentCategories({ tournamentRecord, categories }) {
55398
55416
  if (!tournamentRecord)
55399
55417
  return { error: MISSING_TOURNAMENT_RECORD };
55400
- categories = (categories || []).filter((category) => {
55401
- return category.categoryName && category.type;
55402
- });
55418
+ categories = (categories || []).filter((category) => category.categoryName && category.type);
55403
55419
  tournamentRecord.tournamentCategories = categories;
55420
+ addNotice({
55421
+ topic: MODIFY_TOURNAMENT_DETAIL,
55422
+ payload: {
55423
+ parentOrganisation: tournamentRecord.parentOrganisation,
55424
+ tournamentId: tournamentRecord.tournamentId,
55425
+ categories,
55426
+ },
55427
+ });
55404
55428
  return { ...SUCCESS };
55405
55429
  }
55406
55430