tods-competition-factory 2.1.29 → 2.2.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.
@@ -2387,6 +2387,7 @@ type GroupsMatchUpsResult = {
2387
2387
  abandonedMatchUps?: HydratedMatchUp[];
2388
2388
  completedMatchUps?: HydratedMatchUp[];
2389
2389
  upcomingMatchUps?: HydratedMatchUp[];
2390
+ participants?: HydratedParticipant[];
2390
2391
  pendingMatchUps?: HydratedMatchUp[];
2391
2392
  byeMatchUps?: HydratedMatchUp[];
2392
2393
  matchUpsMap?: MatchUpsMap;
@@ -5585,6 +5586,9 @@ type CompetitionScheduleMatchUpsArgs = {
5585
5586
  status?: string;
5586
5587
  };
5587
5588
  declare function competitionScheduleMatchUps(params: CompetitionScheduleMatchUpsArgs): {
5589
+ mappedParticipants?: {
5590
+ [key: string]: HydratedParticipant;
5591
+ };
5588
5592
  completedMatchUps?: HydratedMatchUp[];
5589
5593
  dateMatchUps?: HydratedMatchUp[];
5590
5594
  courtPrefix?: string;
@@ -5772,11 +5776,15 @@ type CompetitionMatchUpsArgs = {
5772
5776
  contextFilters?: MatchUpFilters;
5773
5777
  hydrateParticipants?: boolean;
5774
5778
  afterRecoveryTimes?: boolean;
5779
+ useParticipantMap?: boolean;
5775
5780
  usePublishState?: boolean;
5776
5781
  nextMatchUps?: boolean;
5777
5782
  inContext?: boolean;
5778
5783
  };
5779
- declare function getCompetitionMatchUps({ scheduleVisibilityFilters, hydrateParticipants, participantsProfile, tournamentRecords, policyDefinitions, usePublishState, matchUpFilters, contextFilters, nextMatchUps, inContext, }: CompetitionMatchUpsArgs): ResultType & {
5784
+ declare function getCompetitionMatchUps({ scheduleVisibilityFilters, hydrateParticipants, participantsProfile, tournamentRecords, useParticipantMap, policyDefinitions, usePublishState, matchUpFilters, contextFilters, nextMatchUps, inContext, }: CompetitionMatchUpsArgs): ResultType & {
5785
+ mappedParticipants?: {
5786
+ [key: string]: HydratedParticipant;
5787
+ };
5780
5788
  abandonedMatchUps?: HydratedMatchUp[];
5781
5789
  completedMatchUps?: HydratedMatchUp[];
5782
5790
  upcomingMatchUps?: HydratedMatchUp[];
@@ -6059,6 +6067,7 @@ declare function drawMatchUps({ participants: tournamentParticipants, tournament
6059
6067
  abandonedMatchUps?: HydratedMatchUp[] | undefined;
6060
6068
  completedMatchUps?: HydratedMatchUp[] | undefined;
6061
6069
  upcomingMatchUps?: HydratedMatchUp[] | undefined;
6070
+ participants?: HydratedParticipant[] | undefined;
6062
6071
  pendingMatchUps?: HydratedMatchUp[] | undefined;
6063
6072
  byeMatchUps?: HydratedMatchUp[] | undefined;
6064
6073
  matchUpsMap?: MatchUpsMap | undefined;
@@ -7292,6 +7301,7 @@ type GetEventDataArgs = {
7292
7301
  policyDefinitions?: PolicyDefinitions;
7293
7302
  allParticipantResults?: boolean;
7294
7303
  sortConfig?: StructureSortConfig;
7304
+ hydrateParticipants?: boolean;
7295
7305
  tournamentRecord: Tournament;
7296
7306
  usePublishState?: boolean;
7297
7307
  refreshResults?: boolean;
@@ -8129,6 +8139,9 @@ type ProAutoScheduleArgs = {
8129
8139
  scheduledDate: string;
8130
8140
  };
8131
8141
  declare function proAutoSchedule({ scheduleCompletedMatchUps, tournamentRecords, scheduledDate, matchUps, }: ProAutoScheduleArgs): {
8142
+ mappedParticipants?: {
8143
+ [key: string]: HydratedParticipant;
8144
+ } | undefined;
8132
8145
  completedMatchUps?: HydratedMatchUp[] | undefined;
8133
8146
  dateMatchUps?: HydratedMatchUp[] | undefined;
8134
8147
  courtPrefix?: string | undefined;
@@ -8151,6 +8164,9 @@ declare function proAutoSchedule({ scheduleCompletedMatchUps, tournamentRecords,
8151
8164
  } | {
8152
8165
  scheduled: HydratedMatchUp[];
8153
8166
  notScheduled: HydratedMatchUp[];
8167
+ mappedParticipants?: {
8168
+ [key: string]: HydratedParticipant;
8169
+ } | undefined;
8154
8170
  completedMatchUps?: HydratedMatchUp[] | undefined;
8155
8171
  dateMatchUps?: HydratedMatchUp[] | undefined;
8156
8172
  courtPrefix?: string | undefined;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  function factoryVersion() {
6
- return '2.1.29';
6
+ return '2.2.0';
7
7
  }
8
8
 
9
9
  const SINGLES_MATCHUP = 'SINGLES';
@@ -7780,7 +7780,7 @@ const membershipMap = {
7780
7780
  [GROUP]: 'groups',
7781
7781
  [TEAM]: 'teams',
7782
7782
  };
7783
- function getParticipantMap({ withIndividualParticipants, convertExtensions, tournamentRecord, withSignInStatus, withScaleValues, internalUse, withISO2, withIOC, }) {
7783
+ function getParticipantMap({ withIndividualParticipants, convertExtensions, tournamentRecord, withSignInStatus, withScaleValues, withGroupings, internalUse, withISO2, withIOC, }) {
7784
7784
  const missingParticipantIds = [];
7785
7785
  const participantMap = {};
7786
7786
  for (const participant of tournamentRecord.participants ?? []) {
@@ -7811,9 +7811,7 @@ function getParticipantMap({ withIndividualParticipants, convertExtensions, tour
7811
7811
  participantMap[participantId].participant.signedIn = signedIn(participantCopy);
7812
7812
  }
7813
7813
  if (withScaleValues) {
7814
- const { ratings, rankings, seedings } = getScaleValues({
7815
- participant: participantCopy,
7816
- });
7814
+ const { ratings, rankings, seedings } = getScaleValues({ participant: participantCopy });
7817
7815
  participantMap[participantId].participant.seedings = seedings;
7818
7816
  participantMap[participantId].participant.rankings = rankings;
7819
7817
  participantMap[participantId].participant.ratings = ratings;
@@ -7829,7 +7827,15 @@ function getParticipantMap({ withIndividualParticipants, convertExtensions, tour
7829
7827
  const template = isObject(withIndividualParticipants) ? withIndividualParticipants : undefined;
7830
7828
  addIndividualParticipants({ participantMap, template });
7831
7829
  }
7832
- return { missingParticipantIds, participantMap };
7830
+ let groupInfo;
7831
+ if (withGroupings) {
7832
+ groupInfo = addParticipantGroupings({
7833
+ participants: Object.values(participantMap).map(({ participant }) => participant),
7834
+ participantsProfile: { convertExtensions },
7835
+ deepCopy: false,
7836
+ }).groupInfo;
7837
+ }
7838
+ return { missingParticipantIds, participantMap, groupInfo };
7833
7839
  }
7834
7840
  function signedIn(participant) {
7835
7841
  const { timeItem } = getTimeItem({
@@ -7909,12 +7915,11 @@ function initializeParticipantId({ participantMap, participantId }) {
7909
7915
 
7910
7916
  function hydrateParticipants({ participantsProfile, useParticipantMap, tournamentRecord, contextProfile, inContext, }) {
7911
7917
  if (useParticipantMap) {
7912
- const participantMap = getParticipantMap({
7918
+ return getParticipantMap({
7913
7919
  ...participantsProfile,
7914
7920
  ...contextProfile,
7915
7921
  tournamentRecord,
7916
- })?.participantMap;
7917
- return { participantMap };
7922
+ });
7918
7923
  }
7919
7924
  let participants = makeDeepCopy(tournamentRecord.participants, false, true) || [];
7920
7925
  if (participantsProfile?.withIOC || participantsProfile?.withISO2)
@@ -10342,7 +10347,7 @@ function addMatchUpContext({ scheduleVisibilityFilters, sourceDrawPositionRanges
10342
10347
  });
10343
10348
  Object.assign(matchUpWithContext, makeDeepCopy({ sides }, true, true));
10344
10349
  }
10345
- if (tournamentParticipants && matchUpWithContext.sides && hydrateParticipants !== false) {
10350
+ if (tournamentParticipants && matchUpWithContext.sides) {
10346
10351
  const participantAttributes = appliedPolicies?.[POLICY_TYPE_PARTICIPANT];
10347
10352
  const getMappedParticipant = (participantId) => {
10348
10353
  const participant = participantMap?.[participantId]?.participant;
@@ -10365,15 +10370,23 @@ function addMatchUpContext({ scheduleVisibilityFilters, sourceDrawPositionRanges
10365
10370
  })
10366
10371
  : undefined), undefined, true);
10367
10372
  if (participant) {
10373
+ let entryStatus, entryStage;
10368
10374
  if (drawDefinition?.entries) {
10369
10375
  const entry = drawDefinition.entries.find((entry) => entry.participantId === side.participantId);
10370
10376
  const eEntry = event?.entries?.find((entry) => entry.participantId === side.participantId);
10371
- participant.entryStatus = entry?.entryStatus || eEntry?.entryStatus;
10377
+ entryStatus = entry?.entryStatus || eEntry?.entryStatus;
10378
+ participant.entryStatus = entryStatus;
10372
10379
  if (entry?.entryStage) {
10373
- participant.entryStage = entry.entryStage;
10380
+ entryStage = entry.entryStage;
10381
+ participant.entryStage = entryStage;
10374
10382
  }
10375
10383
  }
10376
- Object.assign(side, { participant });
10384
+ if (hydrateParticipants !== false) {
10385
+ Object.assign(side, { participant });
10386
+ }
10387
+ else {
10388
+ Object.assign(side, { participant: { entryStage, entryStatus } });
10389
+ }
10377
10390
  }
10378
10391
  }
10379
10392
  if (side?.participant?.individualParticipantIds?.length && !side.participant.individualParticipants?.length) {
@@ -10389,7 +10402,8 @@ function addMatchUpContext({ scheduleVisibilityFilters, sourceDrawPositionRanges
10389
10402
  })
10390
10403
  : undefined));
10391
10404
  });
10392
- Object.assign(side.participant, { individualParticipants });
10405
+ if (hydrateParticipants !== false)
10406
+ Object.assign(side.participant, { individualParticipants });
10393
10407
  }
10394
10408
  });
10395
10409
  if (!matchUpWithContext.matchUpType) {
@@ -14395,16 +14409,10 @@ function getParticipants(params) {
14395
14409
  const template = isObject(withIndividualParticipants) ? withIndividualParticipants : undefined;
14396
14410
  for (const participant of filteredParticipants) {
14397
14411
  for (const individualParticipantId of participant.individualParticipantIds ?? []) {
14398
- const mappedParticipant = participantMap[participant.participantId].participant;
14399
- if (!mappedParticipant?.individualParticipants)
14400
- mappedParticipant.individualParticipants = [];
14401
- if (!participant.individualParticipants) {
14412
+ if (!participant.individualParticipants)
14402
14413
  participant.individualParticipants = [];
14403
- }
14404
14414
  const source = ppMap.get(individualParticipantId);
14405
14415
  const individualParticipant = template ? attributeFilter({ template, source }) : source;
14406
- if (mappedParticipant?.individualParticipants)
14407
- mappedParticipant.individualParticipants.push(individualParticipant);
14408
14416
  participant.individualParticipants.push(individualParticipant);
14409
14417
  }
14410
14418
  }
@@ -17695,11 +17703,11 @@ function extractAttributeValues({ policyAttributes, idCollections, participants,
17695
17703
  }
17696
17704
 
17697
17705
  function getPositionedParticipants({ candidatePositionAssignments, participantsWithGroupings, policyAttributes, idCollections, }) {
17698
- const participantsMap = Object.assign({}, ...participantsWithGroupings.map((participant) => ({
17706
+ const mappedParticipants = Object.assign({}, ...participantsWithGroupings.map((participant) => ({
17699
17707
  [participant.participantId]: participant,
17700
17708
  })));
17701
17709
  return candidatePositionAssignments.map((assignment) => {
17702
- const participant = participantsMap[assignment.participantId];
17710
+ const participant = mappedParticipants[assignment.participantId];
17703
17711
  const { values } = extractAttributeValues({
17704
17712
  participants: participantsWithGroupings,
17705
17713
  policyAttributes,
@@ -34859,6 +34867,7 @@ function getDrawData(params) {
34859
34867
  const { matchUps, roundMatchUps, roundProfile } = getAllStructureMatchUps({
34860
34868
  seedAssignments: !structure?.seedAssignments?.length ? seedAssignments : undefined,
34861
34869
  context: { drawId: drawInfo.drawId, ...context },
34870
+ hydrateParticipants: params.hydrateParticipants,
34862
34871
  tournamentParticipants,
34863
34872
  policyDefinitions,
34864
34873
  tournamentRecord,
@@ -35047,6 +35056,7 @@ function getEventData(params) {
35047
35056
  structures,
35048
35057
  }))(getDrawData({
35049
35058
  allParticipantResults: params.allParticipantResults,
35059
+ hydrateParticipants: params.hydrateParticipants,
35050
35060
  context: { eventId, tournamentId, endDate },
35051
35061
  pressureRating: params.pressureRating,
35052
35062
  refreshResults: params.refreshResults,
@@ -36483,13 +36493,12 @@ function tournamentMatchUps(params) {
36483
36493
  if (!params?.tournamentRecord)
36484
36494
  return { error: MISSING_TOURNAMENT_RECORD };
36485
36495
  let contextContent = params.contextContent;
36486
- const { scheduleVisibilityFilters, participantsProfile, afterRecoveryTimes, policyDefinitions, useParticipantMap, tournamentRecord, inContext = true, usePublishState, contextFilters, matchUpFilters, contextProfile, nextMatchUps, context, } = params;
36496
+ const { scheduleVisibilityFilters, participantsProfile, afterRecoveryTimes, policyDefinitions, tournamentRecord, inContext = true, usePublishState, contextFilters, matchUpFilters, contextProfile, nextMatchUps, context, } = params;
36487
36497
  const tournamentId = params.tournamentId ?? tournamentRecord.tournamentId;
36488
36498
  const events = tournamentRecord?.events ?? [];
36489
36499
  const { participants, participantMap, groupInfo } = hydrateParticipants({
36490
36500
  participantsProfile,
36491
36501
  policyDefinitions,
36492
- useParticipantMap,
36493
36502
  tournamentRecord,
36494
36503
  contextProfile,
36495
36504
  inContext,
@@ -36546,10 +36555,10 @@ function tournamentMatchUps(params) {
36546
36555
  });
36547
36556
  return matchUps;
36548
36557
  }, { matchUpsCount: 0 });
36549
- return { ...eventsDrawMatchUpsResult, groupInfo };
36558
+ return { ...eventsDrawMatchUpsResult, groupInfo, participants };
36550
36559
  }
36551
36560
 
36552
- function getCompetitionMatchUps({ scheduleVisibilityFilters, hydrateParticipants, participantsProfile, tournamentRecords, policyDefinitions, usePublishState, matchUpFilters, contextFilters, nextMatchUps, inContext, }) {
36561
+ function getCompetitionMatchUps({ scheduleVisibilityFilters, hydrateParticipants, participantsProfile, tournamentRecords, useParticipantMap, policyDefinitions, usePublishState, matchUpFilters, contextFilters, nextMatchUps, inContext, }) {
36553
36562
  if (typeof tournamentRecords !== 'object' || !Object.keys(tournamentRecords).length)
36554
36563
  return { error: MISSING_TOURNAMENT_RECORDS };
36555
36564
  const tournamentIds = Object.keys(tournamentRecords);
@@ -36559,6 +36568,7 @@ function getCompetitionMatchUps({ scheduleVisibilityFilters, hydrateParticipants
36559
36568
  scheduleVisibilityFilters,
36560
36569
  hydrateParticipants,
36561
36570
  participantsProfile,
36571
+ useParticipantMap,
36562
36572
  policyDefinitions,
36563
36573
  tournamentRecord,
36564
36574
  usePublishState,
@@ -36568,22 +36578,28 @@ function getCompetitionMatchUps({ scheduleVisibilityFilters, hydrateParticipants
36568
36578
  inContext,
36569
36579
  });
36570
36580
  });
36581
+ const mappedParticipants = {};
36571
36582
  const groupInfo = {};
36572
36583
  const competitionMatchUpsResult = tournamentsMatchUps.reduce((groupings, matchUpGroupings) => {
36573
36584
  const keys = Object.keys(matchUpGroupings);
36574
36585
  keys.forEach((key) => {
36575
- if (Array.isArray(matchUpGroupings[key])) {
36586
+ if (key === 'groupInfo') {
36587
+ Object.assign(groupInfo, matchUpGroupings[key]);
36588
+ }
36589
+ else if (key === 'participants') {
36590
+ for (const participant of matchUpGroupings[key] ?? []) {
36591
+ mappedParticipants[participant.participantId] = participant;
36592
+ }
36593
+ }
36594
+ else if (Array.isArray(matchUpGroupings[key])) {
36576
36595
  if (!groupings[key])
36577
36596
  groupings[key] = [];
36578
36597
  groupings[key] = groupings[key].concat(matchUpGroupings[key]);
36579
36598
  }
36580
- if (key === 'groupInfo') {
36581
- Object.assign(groupInfo, matchUpGroupings[key]);
36582
- }
36583
36599
  });
36584
36600
  return groupings;
36585
36601
  }, {});
36586
- return { ...competitionMatchUpsResult, groupInfo };
36602
+ return { ...competitionMatchUpsResult, groupInfo, mappedParticipants };
36587
36603
  }
36588
36604
 
36589
36605
  function competitionScheduleMatchUps(params) {
@@ -36671,7 +36687,7 @@ function competitionScheduleMatchUps(params) {
36671
36687
  params.matchUpFilters.excludeMatchUpStatuses = [COMPLETED$1];
36672
36688
  }
36673
36689
  }
36674
- const { completedMatchUps, upcomingMatchUps, pendingMatchUps, groupInfo } = getCompetitionMatchUps({
36690
+ const { completedMatchUps, upcomingMatchUps, pendingMatchUps, groupInfo, mappedParticipants } = getCompetitionMatchUps({
36675
36691
  ...params,
36676
36692
  matchUpFilters: params.matchUpFilters,
36677
36693
  contextFilters: params.contextFilters,
@@ -36720,6 +36736,7 @@ function competitionScheduleMatchUps(params) {
36720
36736
  });
36721
36737
  const result = {
36722
36738
  completedMatchUps: alwaysReturnCompleted ? allCompletedMatchUps : completedMatchUps,
36739
+ mappedParticipants: params.hydrateParticipants ? undefined : mappedParticipants,
36723
36740
  dateMatchUps,
36724
36741
  courtsData,
36725
36742
  groupInfo,
@@ -53556,7 +53573,7 @@ function getAvgWTN({ eventType, matchUps, eventId, drawId }) {
53556
53573
  matchUpFormatCounts[matchUpFormat] = 0;
53557
53574
  matchUpFormatCounts[matchUpFormat] += 1;
53558
53575
  };
53559
- const participantsMap = matchUps
53576
+ const mappedParticipants = matchUps
53560
53577
  .filter((matchUp) => (eventId ? matchUp.eventId === eventId : matchUp.drawId === drawId))
53561
53578
  .reduce((participants, matchUp) => {
53562
53579
  countMatchUpFormat(matchUp);
@@ -53565,7 +53582,7 @@ function getAvgWTN({ eventType, matchUps, eventId, drawId }) {
53565
53582
  .forEach((participant) => (participants[participant.participantId] = participant));
53566
53583
  return participants;
53567
53584
  }, {});
53568
- const eventParticipants = Object.values(participantsMap);
53585
+ const eventParticipants = Object.values(mappedParticipants);
53569
53586
  const wtnRatings = eventParticipants
53570
53587
  .map((participant) => getDetailsWTN({ participant, eventType }))
53571
53588
  .filter(({ wtnRating }) => wtnRating);
@@ -53710,7 +53727,7 @@ function getStructureReports(params) {
53710
53727
  category: subType,
53711
53728
  categoryName,
53712
53729
  ageCategoryCode,
53713
- flightNumber: flightMap[drawId],
53730
+ flightNumber: flightMap?.[drawId],
53714
53731
  drawType,
53715
53732
  stage: s.stage,
53716
53733
  seedingBasis: seedingBasis ? JSON.stringify(seedingBasis) : undefined,