tods-competition-factory 2.0.46 → 2.0.47

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.47';
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;
@@ -55392,15 +55392,32 @@ function setTournamentName({ tournamentRecord, promotionalName, tournamentName,
55392
55392
  function setTournamentNotes({ tournamentRecord, notes }) {
55393
55393
  if (!tournamentRecord)
55394
55394
  return { error: MISSING_TOURNAMENT_RECORD };
55395
- return addNotes({ element: tournamentRecord, notes });
55395
+ const result = notes ? addNotes({ element: tournamentRecord, notes }) : removeNotes({ element: tournamentRecord });
55396
+ if (result.error)
55397
+ return result;
55398
+ addNotice({
55399
+ topic: MODIFY_TOURNAMENT_DETAIL,
55400
+ payload: {
55401
+ parentOrganisation: tournamentRecord.parentOrganisation,
55402
+ tournamentId: tournamentRecord.tournamentId,
55403
+ notes: notes ?? '',
55404
+ },
55405
+ });
55406
+ return { ...SUCCESS };
55396
55407
  }
55397
55408
  function setTournamentCategories({ tournamentRecord, categories }) {
55398
55409
  if (!tournamentRecord)
55399
55410
  return { error: MISSING_TOURNAMENT_RECORD };
55400
- categories = (categories || []).filter((category) => {
55401
- return category.categoryName && category.type;
55402
- });
55411
+ categories = (categories || []).filter((category) => category.categoryName && category.type);
55403
55412
  tournamentRecord.tournamentCategories = categories;
55413
+ addNotice({
55414
+ topic: MODIFY_TOURNAMENT_DETAIL,
55415
+ payload: {
55416
+ parentOrganisation: tournamentRecord.parentOrganisation,
55417
+ tournamentId: tournamentRecord.tournamentId,
55418
+ categories,
55419
+ },
55420
+ });
55404
55421
  return { ...SUCCESS };
55405
55422
  }
55406
55423