tods-competition-factory 2.0.45 → 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.45';
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;
@@ -55357,15 +55357,15 @@ function setTournamentName({ tournamentRecord, promotionalName, tournamentName,
55357
55357
  return { error: MISSING_TOURNAMENT_RECORD };
55358
55358
  const tournamentId = tournamentRecord.tournamentId;
55359
55359
  const detailUpdates = { tournamentId };
55360
- if (tournamentName) {
55360
+ if (tournamentName && tournamentName !== tournamentRecord.tournamentName) {
55361
55361
  tournamentRecord.tournamentName = tournamentName;
55362
55362
  detailUpdates.tournamentName = tournamentName;
55363
55363
  }
55364
- if (promotionalName) {
55364
+ if (promotionalName && promotionalName !== tournamentRecord.promotionalName) {
55365
55365
  tournamentRecord.promotionalName = promotionalName;
55366
55366
  detailUpdates.promotionalName = promotionalName;
55367
55367
  }
55368
- if (formalName) {
55368
+ if (formalName && formalName !== tournamentRecord.formalName) {
55369
55369
  tournamentRecord.formalName = formalName;
55370
55370
  detailUpdates.formalName = formalName;
55371
55371
  }
@@ -55378,22 +55378,46 @@ function setTournamentName({ tournamentRecord, promotionalName, tournamentName,
55378
55378
  detailUpdates.formalName = '';
55379
55379
  }
55380
55380
  if (Object.keys(detailUpdates).length > 1) {
55381
- addNotice({ topic: MODIFY_TOURNAMENT_DETAIL, payload: { tournamentId, ...detailUpdates } });
55381
+ addNotice({
55382
+ topic: MODIFY_TOURNAMENT_DETAIL,
55383
+ payload: {
55384
+ parentOrganisation: tournamentRecord.parentOrganisation,
55385
+ tournamentId,
55386
+ ...detailUpdates,
55387
+ },
55388
+ });
55382
55389
  }
55383
55390
  return { ...SUCCESS };
55384
55391
  }
55385
55392
  function setTournamentNotes({ tournamentRecord, notes }) {
55386
55393
  if (!tournamentRecord)
55387
55394
  return { error: MISSING_TOURNAMENT_RECORD };
55388
- 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 };
55389
55407
  }
55390
55408
  function setTournamentCategories({ tournamentRecord, categories }) {
55391
55409
  if (!tournamentRecord)
55392
55410
  return { error: MISSING_TOURNAMENT_RECORD };
55393
- categories = (categories || []).filter((category) => {
55394
- return category.categoryName && category.type;
55395
- });
55411
+ categories = (categories || []).filter((category) => category.categoryName && category.type);
55396
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
+ });
55397
55421
  return { ...SUCCESS };
55398
55422
  }
55399
55423
 
@@ -55475,7 +55499,12 @@ function setTournamentDates(params) {
55475
55499
  const unscheduledMatchUpIds = checkScheduling && removeInvalidScheduling({ tournamentRecord })?.unscheduledMatchUpIds;
55476
55500
  updateCourtAvailability({ tournamentRecord });
55477
55501
  addNotice({
55478
- payload: { tournamentId: tournamentRecord.tournamentId, startDate, endDate },
55502
+ payload: {
55503
+ parentOrganisation: tournamentRecord.parentOrganisation,
55504
+ tournamentId: tournamentRecord.tournamentId,
55505
+ startDate,
55506
+ endDate,
55507
+ },
55479
55508
  topic: MODIFY_TOURNAMENT_DETAIL,
55480
55509
  });
55481
55510
  return { ...SUCCESS, unscheduledMatchUpIds, datesAdded, datesRemoved };