tods-competition-factory 2.0.51 → 2.0.52

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.
@@ -3619,6 +3619,7 @@ type GenerateDrawMaticRoundArgs = {
3619
3619
  participantIds?: string[];
3620
3620
  dynamicRatings?: boolean;
3621
3621
  refreshDynamic?: boolean;
3622
+ minimizeDelta?: boolean;
3622
3623
  encounterValue?: number;
3623
3624
  sameTeamValue?: number;
3624
3625
  maxIterations?: number;
@@ -3639,6 +3640,7 @@ type DrawMaticRoundResult = {
3639
3640
  participantIdPairings?: string[][];
3640
3641
  candidatesCount?: number;
3641
3642
  outputScaleName?: string;
3643
+ deltaCandidate?: any;
3642
3644
  roundNumber?: number;
3643
3645
  matchUps?: MatchUp[];
3644
3646
  iterations?: number;
@@ -3646,7 +3648,7 @@ type DrawMaticRoundResult = {
3646
3648
  maxDelta?: number;
3647
3649
  maxDiff?: number;
3648
3650
  };
3649
- declare function generateDrawMaticRound({ encounterValue, sameTeamValue, maxIterations, updateParticipantRatings, generateMatchUps, ignoreLastRoundNumber, iterationMatchUps, tournamentRecord, dynamicRatings, refreshDynamic, participantIds, drawDefinition, adHocRatings, salted, roundNumber, structureId, matchUpIds, eventType, structure, scaleName, idPrefix, isMock, event, }: GenerateDrawMaticRoundArgs): ResultType & DrawMaticRoundResult;
3651
+ declare function generateDrawMaticRound(params: GenerateDrawMaticRoundArgs): ResultType & DrawMaticRoundResult;
3650
3652
 
3651
3653
  type GenerateVoluntaryConsolationArgs = {
3652
3654
  playoffAttributes?: PlayoffAttributes;
@@ -9020,6 +9022,19 @@ declare function setTournamentStatus({ tournamentRecord, status }: {
9020
9022
  info?: undefined;
9021
9023
  };
9022
9024
 
9025
+ type RemoveOnlineResourceArgs = {
9026
+ onlineResource: OnlineResource;
9027
+ drawDefinition?: DrawDefinition;
9028
+ tournamentRecord: Tournament;
9029
+ organisationId?: string;
9030
+ participantId?: string;
9031
+ personId?: string;
9032
+ courtId?: string;
9033
+ venueId?: string;
9034
+ event?: Event;
9035
+ };
9036
+ declare function removeOnlineResource(params: RemoveOnlineResourceArgs): ResultType;
9037
+
9023
9038
  type RemoveExtensionResult = {
9024
9039
  success?: boolean;
9025
9040
  error?: ErrorType;
@@ -9064,7 +9079,7 @@ type AddOnlineResourceArgs = {
9064
9079
  venueId?: string;
9065
9080
  event?: Event$1;
9066
9081
  };
9067
- declare function addOnlineResource({ tournamentRecord, onlineResource, organisationId, participantId, personId, courtId, venueId, }: AddOnlineResourceArgs): ResultType;
9082
+ declare function addOnlineResource(params: AddOnlineResourceArgs): ResultType;
9068
9083
 
9069
9084
  type AddExtensionArgs$1 = {
9070
9085
  tournamentRecords?: TournamentRecords;
@@ -9259,6 +9274,7 @@ declare const mutate$1_removeDrawDefinitionExtension: typeof removeDrawDefinitio
9259
9274
  declare const mutate$1_removeEventExtension: typeof removeEventExtension;
9260
9275
  declare const mutate$1_removeExtension: typeof removeExtension;
9261
9276
  declare const mutate$1_removeNotes: typeof removeNotes;
9277
+ declare const mutate$1_removeOnlineResource: typeof removeOnlineResource;
9262
9278
  declare const mutate$1_removeParticipantExtension: typeof removeParticipantExtension;
9263
9279
  declare const mutate$1_removeTournamentExtension: typeof removeTournamentExtension;
9264
9280
  declare const mutate$1_setTournamentCategories: typeof setTournamentCategories;
@@ -9269,7 +9285,7 @@ declare const mutate$1_setTournamentNotes: typeof setTournamentNotes;
9269
9285
  declare const mutate$1_setTournamentStartDate: typeof setTournamentStartDate;
9270
9286
  declare const mutate$1_setTournamentStatus: typeof setTournamentStatus;
9271
9287
  declare namespace mutate$1 {
9272
- export { mutate$1_addDrawDefinitionExtension as addDrawDefinitionExtension, mutate$1_addEventExtension as addEventExtension, mutate$1_addEventTimeItem as addEventTimeItem, mutate$1_addExtension as addExtension, mutate$1_addNotes as addNotes, mutate$1_addOnlineResource as addOnlineResource, mutate$1_addParticipantExtension as addParticipantExtension, mutate$1_addParticipantTimeItem as addParticipantTimeItem, mutate$1_addTimeItem as addTimeItem, mutate$1_addTournamentExtension as addTournamentExtension, mutate$1_addTournamentTimeItem as addTournamentTimeItem, mutate$1_removeDrawDefinitionExtension as removeDrawDefinitionExtension, mutate$1_removeEventExtension as removeEventExtension, mutate$1_removeExtension as removeExtension, mutate$1_removeNotes as removeNotes, mutate$1_removeParticipantExtension as removeParticipantExtension, mutate$1_removeTournamentExtension as removeTournamentExtension, mutate$1_setTournamentCategories as setTournamentCategories, mutate$1_setTournamentDates as setTournamentDates, mutate$1_setTournamentEndDate as setTournamentEndDate, mutate$1_setTournamentName as setTournamentName, mutate$1_setTournamentNotes as setTournamentNotes, mutate$1_setTournamentStartDate as setTournamentStartDate, mutate$1_setTournamentStatus as setTournamentStatus };
9288
+ export { mutate$1_addDrawDefinitionExtension as addDrawDefinitionExtension, mutate$1_addEventExtension as addEventExtension, mutate$1_addEventTimeItem as addEventTimeItem, mutate$1_addExtension as addExtension, mutate$1_addNotes as addNotes, mutate$1_addOnlineResource as addOnlineResource, mutate$1_addParticipantExtension as addParticipantExtension, mutate$1_addParticipantTimeItem as addParticipantTimeItem, mutate$1_addTimeItem as addTimeItem, mutate$1_addTournamentExtension as addTournamentExtension, mutate$1_addTournamentTimeItem as addTournamentTimeItem, mutate$1_removeDrawDefinitionExtension as removeDrawDefinitionExtension, mutate$1_removeEventExtension as removeEventExtension, mutate$1_removeExtension as removeExtension, mutate$1_removeNotes as removeNotes, mutate$1_removeOnlineResource as removeOnlineResource, mutate$1_removeParticipantExtension as removeParticipantExtension, mutate$1_removeTournamentExtension as removeTournamentExtension, mutate$1_setTournamentCategories as setTournamentCategories, mutate$1_setTournamentDates as setTournamentDates, mutate$1_setTournamentEndDate as setTournamentEndDate, mutate$1_setTournamentName as setTournamentName, mutate$1_setTournamentNotes as setTournamentNotes, mutate$1_setTournamentStartDate as setTournamentStartDate, mutate$1_setTournamentStatus as setTournamentStatus };
9273
9289
  }
9274
9290
 
9275
9291
  declare const index$4_addDrawDefinitionExtension: typeof addDrawDefinitionExtension;
@@ -9300,6 +9316,7 @@ declare const index$4_removeDrawDefinitionExtension: typeof removeDrawDefinition
9300
9316
  declare const index$4_removeEventExtension: typeof removeEventExtension;
9301
9317
  declare const index$4_removeExtension: typeof removeExtension;
9302
9318
  declare const index$4_removeNotes: typeof removeNotes;
9319
+ declare const index$4_removeOnlineResource: typeof removeOnlineResource;
9303
9320
  declare const index$4_removeParticipantExtension: typeof removeParticipantExtension;
9304
9321
  declare const index$4_removeTournamentExtension: typeof removeTournamentExtension;
9305
9322
  declare const index$4_setTournamentCategories: typeof setTournamentCategories;
@@ -9310,7 +9327,7 @@ declare const index$4_setTournamentNotes: typeof setTournamentNotes;
9310
9327
  declare const index$4_setTournamentStartDate: typeof setTournamentStartDate;
9311
9328
  declare const index$4_setTournamentStatus: typeof setTournamentStatus;
9312
9329
  declare namespace index$4 {
9313
- export { index$4_addDrawDefinitionExtension as addDrawDefinitionExtension, index$4_addEventExtension as addEventExtension, index$4_addEventTimeItem as addEventTimeItem, index$4_addExtension as addExtension, index$4_addNotes as addNotes, index$4_addOnlineResource as addOnlineResource, index$4_addParticipantExtension as addParticipantExtension, index$4_addParticipantTimeItem as addParticipantTimeItem, index$4_addTimeItem as addTimeItem, index$4_addTournamentExtension as addTournamentExtension, index$4_addTournamentTimeItem as addTournamentTimeItem, index$4_analyzeDraws as analyzeDraws, index$4_analyzeTournament as analyzeTournament, index$4_getAllowedDrawTypes as getAllowedDrawTypes, index$4_getAllowedMatchUpFormats as getAllowedMatchUpFormats, index$4_getAppliedPolicies as getAppliedPolicies, index$4_getCompetitionDateRange as getCompetitionDateRange, index$4_getCompetitionPenalties as getCompetitionPenalties, index$4_getPolicyDefinitions as getPolicyDefinitions, index$4_getTournamentInfo as getTournamentInfo, index$4_getTournamentPenalties as getTournamentPenalties, index$4_getTournamentPersons as getTournamentPersons, index$4_getTournamentStructures as getTournamentStructures, index$4_getTournamentTimeItem as getTournamentTimeItem, mutate$1 as mutate, query$4 as query, index$4_removeDrawDefinitionExtension as removeDrawDefinitionExtension, index$4_removeEventExtension as removeEventExtension, index$4_removeExtension as removeExtension, index$4_removeNotes as removeNotes, index$4_removeParticipantExtension as removeParticipantExtension, index$4_removeTournamentExtension as removeTournamentExtension, index$4_setTournamentCategories as setTournamentCategories, index$4_setTournamentDates as setTournamentDates, index$4_setTournamentEndDate as setTournamentEndDate, index$4_setTournamentName as setTournamentName, index$4_setTournamentNotes as setTournamentNotes, index$4_setTournamentStartDate as setTournamentStartDate, index$4_setTournamentStatus as setTournamentStatus };
9330
+ export { index$4_addDrawDefinitionExtension as addDrawDefinitionExtension, index$4_addEventExtension as addEventExtension, index$4_addEventTimeItem as addEventTimeItem, index$4_addExtension as addExtension, index$4_addNotes as addNotes, index$4_addOnlineResource as addOnlineResource, index$4_addParticipantExtension as addParticipantExtension, index$4_addParticipantTimeItem as addParticipantTimeItem, index$4_addTimeItem as addTimeItem, index$4_addTournamentExtension as addTournamentExtension, index$4_addTournamentTimeItem as addTournamentTimeItem, index$4_analyzeDraws as analyzeDraws, index$4_analyzeTournament as analyzeTournament, index$4_getAllowedDrawTypes as getAllowedDrawTypes, index$4_getAllowedMatchUpFormats as getAllowedMatchUpFormats, index$4_getAppliedPolicies as getAppliedPolicies, index$4_getCompetitionDateRange as getCompetitionDateRange, index$4_getCompetitionPenalties as getCompetitionPenalties, index$4_getPolicyDefinitions as getPolicyDefinitions, index$4_getTournamentInfo as getTournamentInfo, index$4_getTournamentPenalties as getTournamentPenalties, index$4_getTournamentPersons as getTournamentPersons, index$4_getTournamentStructures as getTournamentStructures, index$4_getTournamentTimeItem as getTournamentTimeItem, mutate$1 as mutate, query$4 as query, index$4_removeDrawDefinitionExtension as removeDrawDefinitionExtension, index$4_removeEventExtension as removeEventExtension, index$4_removeExtension as removeExtension, index$4_removeNotes as removeNotes, index$4_removeOnlineResource as removeOnlineResource, index$4_removeParticipantExtension as removeParticipantExtension, index$4_removeTournamentExtension as removeTournamentExtension, index$4_setTournamentCategories as setTournamentCategories, index$4_setTournamentDates as setTournamentDates, index$4_setTournamentEndDate as setTournamentEndDate, index$4_setTournamentName as setTournamentName, index$4_setTournamentNotes as setTournamentNotes, index$4_setTournamentStartDate as setTournamentStartDate, index$4_setTournamentStatus as setTournamentStatus };
9314
9331
  }
9315
9332
 
9316
9333
  declare const generate_generateCourts: typeof generateCourts;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  function factoryVersion() {
6
- return '2.0.51';
6
+ return '2.0.52';
7
7
  }
8
8
 
9
9
  function isFunction(obj) {
@@ -1783,6 +1783,10 @@ function decorateResult({ context, result, stack, info }) {
1783
1783
  return result ?? { success: true };
1784
1784
  }
1785
1785
 
1786
+ const RESOURCE_SUB_TYPE = 'resourceSubType';
1787
+ const RESOURCE_TYPE = 'resourceType';
1788
+ const IDENTIFIER = 'identifier';
1789
+
1786
1790
  const SINGLES$1 = 'SINGLES';
1787
1791
  const SINGLES_EVENT = 'SINGLES';
1788
1792
  const DOUBLES$1 = 'DOUBLES';
@@ -1807,6 +1811,7 @@ const eventConstants = {
1807
1811
  const TOURNAMENT_RECORDS = 'tournamentRecords';
1808
1812
  const POLICY_DEFINITIONS = 'policyDefinitions';
1809
1813
  const TOURNAMENT_RECORD = 'tournamentRecord';
1814
+ const ONLINE_RESOURCE = 'onlineResource';
1810
1815
  const DRAW_DEFINITION = 'drawDefinition';
1811
1816
  const MATCHUP_FORMAT = 'matchUpFormat';
1812
1817
  const PARTICIPANT_ID = 'participantId';
@@ -1849,6 +1854,7 @@ const ONE_OF = '_oneOf';
1849
1854
 
1850
1855
  const validators = {
1851
1856
  [EVENT_TYPE]: (value) => [SINGLES$1, DOUBLES$1, TEAM$2].includes(value),
1857
+ [ONLINE_RESOURCE]: (value) => intersection(Object.keys(value), [RESOURCE_SUB_TYPE, RESOURCE_TYPE, IDENTIFIER]).length === 3,
1852
1858
  };
1853
1859
  const errors = {
1854
1860
  [TOURNAMENT_RECORDS]: MISSING_TOURNAMENT_RECORDS,
@@ -1861,6 +1867,7 @@ const errors = {
1861
1867
  [STRUCTURE_ID]: MISSING_STRUCTURE_ID,
1862
1868
  [MATCHUP_IDS]: MISSING_MATCHUP_IDS,
1863
1869
  [PARTICIPANT]: MISSING_PARTICIPANT,
1870
+ [ONLINE_RESOURCE]: INVALID_OBJECT,
1864
1871
  [EVENT_TYPE]: INVALID_EVENT_TYPE,
1865
1872
  [STRUCTURES]: MISSING_STRUCTURES,
1866
1873
  [MATCHUP_ID]: MISSING_MATCHUP_ID,
@@ -1879,6 +1886,7 @@ const paramTypes = {
1879
1886
  [POLICY_DEFINITIONS]: OBJECT,
1880
1887
  [TOURNAMENT_RECORD]: OBJECT,
1881
1888
  [DRAW_DEFINITION]: OBJECT,
1889
+ [ONLINE_RESOURCE]: OBJECT,
1882
1890
  [SCHEDULE_DATES]: ARRAY,
1883
1891
  [PARTICIPANT]: OBJECT,
1884
1892
  [MATCHUP_IDS]: ARRAY,
@@ -27015,7 +27023,8 @@ function getSideRatings({ tournamentParticipants, adHocRatings, eventType, scale
27015
27023
  });
27016
27024
  }
27017
27025
 
27018
- function getPairings({ tournamentParticipants, adHocRatings = {}, possiblePairings, uniquePairings, maxIterations, deltaObjects, valueObjects, eventType, scaleName, salted, }) {
27026
+ function getPairings(params) {
27027
+ const { tournamentParticipants, adHocRatings = {}, possiblePairings, uniquePairings, maxIterations, minimizeDelta, deltaObjects, valueObjects, eventType, scaleName, salted, } = params;
27019
27028
  uniquePairings.forEach((pairing) => {
27020
27029
  const ratings = getSideRatings({
27021
27030
  tournamentParticipants,
@@ -27047,7 +27056,7 @@ function getPairings({ tournamentParticipants, adHocRatings = {}, possiblePairin
27047
27056
  deltaObjects,
27048
27057
  valueObjects,
27049
27058
  });
27050
- const { participantIdPairings } = candidate;
27059
+ const { participantIdPairings } = minimizeDelta ? deltaCandidate : candidate;
27051
27060
  return {
27052
27061
  participantIdPairings,
27053
27062
  candidatesCount,
@@ -27060,14 +27069,13 @@ function getPairings({ tournamentParticipants, adHocRatings = {}, possiblePairin
27060
27069
  const ENCOUNTER_VALUE = 100;
27061
27070
  const SAME_TEAM_VALUE = 100;
27062
27071
  const MAX_ITERATIONS = 4000;
27063
- function generateDrawMaticRound({ encounterValue = ENCOUNTER_VALUE, sameTeamValue = SAME_TEAM_VALUE, maxIterations = MAX_ITERATIONS, updateParticipantRatings, generateMatchUps = true, ignoreLastRoundNumber, iterationMatchUps, tournamentRecord, dynamicRatings, refreshDynamic, participantIds, drawDefinition, adHocRatings, salted = 0.5, roundNumber, structureId, matchUpIds, eventType, structure, scaleName, idPrefix, isMock, event, }) {
27072
+ function generateDrawMaticRound(params) {
27073
+ const { encounterValue = ENCOUNTER_VALUE, sameTeamValue = SAME_TEAM_VALUE, maxIterations = MAX_ITERATIONS, updateParticipantRatings, generateMatchUps = true, ignoreLastRoundNumber, iterationMatchUps, tournamentRecord, dynamicRatings, refreshDynamic, participantIds, drawDefinition, roundNumber, structureId, matchUpIds, eventType, scaleName, idPrefix, isMock, salted, event, } = params;
27064
27074
  if (!drawDefinition)
27065
27075
  return { error: MISSING_DRAW_DEFINITION };
27066
- if (!structure && !structureId)
27076
+ if (!params.structure && !structureId)
27067
27077
  return { error: STRUCTURE_NOT_FOUND };
27068
- if (!structure) {
27069
- structure = findStructure({ drawDefinition, structureId }).structure;
27070
- }
27078
+ const structure = params.structure || findStructure({ drawDefinition, structureId }).structure;
27071
27079
  if (!isObject(structure))
27072
27080
  return { error: MISSING_STRUCTURE };
27073
27081
  if (!participantIds?.length)
@@ -27107,14 +27115,15 @@ function generateDrawMaticRound({ encounterValue = ENCOUNTER_VALUE, sameTeamValu
27107
27115
  const { uniquePairings, possiblePairings, deltaObjects } = getPairingsData({
27108
27116
  participantIds,
27109
27117
  });
27110
- const params = {
27111
- adHocRatings: modifiedScaleValues || adHocRatings,
27118
+ const adHocRatings = Object.values(modifiedScaleValues).length ? modifiedScaleValues : params.adHocRatings;
27119
+ const paringParams = {
27112
27120
  tournamentParticipants,
27113
27121
  possiblePairings,
27114
- drawDefinition,
27115
27122
  participantIds,
27116
27123
  uniquePairings,
27124
+ drawDefinition,
27117
27125
  maxIterations,
27126
+ adHocRatings,
27118
27127
  deltaObjects,
27119
27128
  valueObjects,
27120
27129
  eventType,
@@ -27122,7 +27131,7 @@ function generateDrawMaticRound({ encounterValue = ENCOUNTER_VALUE, sameTeamValu
27122
27131
  structure,
27123
27132
  salted,
27124
27133
  };
27125
- const { candidatesCount, participantIdPairings, iterations, candidate } = getPairings(params);
27134
+ const { candidatesCount, participantIdPairings, deltaCandidate, iterations, candidate } = getPairings(paringParams);
27126
27135
  if (!candidatesCount)
27127
27136
  return { error: NO_CANDIDATES };
27128
27137
  let generatedRoundNumber;
@@ -27151,6 +27160,7 @@ function generateDrawMaticRound({ encounterValue = ENCOUNTER_VALUE, sameTeamValu
27151
27160
  participantIdPairings,
27152
27161
  modifiedScaleValues,
27153
27162
  candidatesCount,
27163
+ deltaCandidate,
27154
27164
  ...SUCCESS,
27155
27165
  iterations,
27156
27166
  matchUps,
@@ -47585,8 +47595,8 @@ function nameMocks({ nameRoot = 'TEAM', count = 1 } = {}) {
47585
47595
  }
47586
47596
 
47587
47597
  function generateParticipants(params) {
47588
- let { rankingRange, scaledParticipantsCount, } = params;
47589
- const { ratingsParameters: ratingsParameters$1 = ratingsParameters, valuesInstanceLimit, consideredDate, categories, category, nationalityCodesCount, nationalityCodeType, nationalityCodes, participantsCount = 32, participantType, personIds, idPrefix, uuids, personExtensions, addressProps, gendersCount, matchUpType, personData, sex, inContext, withISO2, withIOC, scaleAllParticipants, } = params;
47598
+ let { scaledParticipantsCount, rankingRange, } = params;
47599
+ const { ratingsParameters: ratingsParameters$1 = ratingsParameters, valuesInstanceLimit, ratingsValues = [], consideredDate, categories, category, nationalityCodesCount, nationalityCodeType, nationalityCodes, participantsCount = 32, participantType, personIds, idPrefix, uuids, personExtensions, addressProps, gendersCount, matchUpType, personData, sex, inContext, withISO2, withIOC, scaleAllParticipants, } = params;
47590
47600
  const doubles = participantType === PAIR || matchUpType === DOUBLES_MATCHUP;
47591
47601
  const team = participantType === TEAM || matchUpType === TEAM;
47592
47602
  if (rankingRange &&
@@ -47621,7 +47631,14 @@ function generateParticipants(params) {
47621
47631
  Object.assign(singlesRatings, result.singlesRatings);
47622
47632
  };
47623
47633
  if (isObject(category)) {
47624
- const result = genRatings({ category, scaledParticipantsCount, ratingsParameters: ratingsParameters$1, participantType, rankingRange });
47634
+ const result = genRatings({
47635
+ scaledParticipantsCount,
47636
+ ratingsParameters: ratingsParameters$1,
47637
+ participantType,
47638
+ ratingsValues,
47639
+ rankingRange,
47640
+ category,
47641
+ });
47625
47642
  assignResult(result);
47626
47643
  }
47627
47644
  if (Array.isArray(categories)) {
@@ -47630,6 +47647,7 @@ function generateParticipants(params) {
47630
47647
  scaledParticipantsCount,
47631
47648
  ratingsParameters: ratingsParameters$1,
47632
47649
  participantType,
47650
+ ratingsValues,
47633
47651
  rankingRange,
47634
47652
  category,
47635
47653
  });
@@ -47814,7 +47832,7 @@ function addScaleItem({ scaleValue: itemValue, participant, eventType, scaleType
47814
47832
  }
47815
47833
  }
47816
47834
  function genRatings(params) {
47817
- const { category, scaledParticipantsCount, ratingsParameters, participantType } = params;
47835
+ const { category, scaledParticipantsCount, ratingsParameters, participantType, ratingsValues = [] } = params;
47818
47836
  const rankingRange = category.rankingRange || params.rankingRange || [1, 1000];
47819
47837
  const doublesRankings = {}, singlesRankings = {}, singlesRatings = {}, doublesRatings = {};
47820
47838
  const { categoryName, ageCategoryCode, ratingType } = category;
@@ -47851,20 +47869,24 @@ function genRatings(params) {
47851
47869
  return generatedAttributes;
47852
47870
  };
47853
47871
  const inverted = range[0] > range[1];
47854
- const skew = inverted ? 2 : 0.5;
47872
+ const skew = inverted ? 2 : 0.7;
47855
47873
  const [min, max] = range.slice().sort();
47856
- const generateRatings = () => generateRange(0, 2000)
47857
- .map(() => skewedDistribution(min, max, skew, step, decimalsCount))
47858
- .filter((rating) => (!ratingMax || rating <= ratingMax) && (!ratingMin || rating >= ratingMin))
47859
- .slice(0, scaledParticipantsCount || randomInt(20, 30))
47860
- .map((scaleValue) => {
47861
- return !accessors
47862
- ? scaleValue
47863
- : Object.assign({}, ...accessors.map((accessor) => ({ [accessor]: scaleValue })), getAttributes(attributes));
47864
- });
47865
- singlesRatings[scaleName] = generateRatings();
47874
+ const generateRatings = () => {
47875
+ const ratingsBucket = generateRange(0, 2000)
47876
+ .map(() => skewedDistribution(min, max, skew, step, decimalsCount));
47877
+ return ratingsBucket
47878
+ .filter((rating) => (!ratingMax || rating <= ratingMax) && (!ratingMin || rating >= ratingMin))
47879
+ .slice(0, scaledParticipantsCount || randomInt(20, 30))
47880
+ .map((scaleValue) => {
47881
+ return !accessors
47882
+ ? scaleValue
47883
+ : Object.assign({}, ...accessors.map((accessor) => ({ [accessor]: scaleValue })), getAttributes(attributes));
47884
+ });
47885
+ };
47886
+ const generatedRatings = generateRatings();
47887
+ singlesRatings[scaleName] = [...ratingsValues, ...generatedRatings];
47866
47888
  if ([PAIR, TEAM].includes(participantType)) {
47867
- doublesRatings[scaleName] = generateRatings();
47889
+ doublesRatings[scaleName] = [...ratingsValues, ...generatedRatings];
47868
47890
  }
47869
47891
  }
47870
47892
  return { singlesRankings, doublesRankings, singlesRatings, doublesRatings };
@@ -55389,23 +55411,80 @@ function setTournamentStatus({ tournamentRecord, status }) {
55389
55411
  return { ...SUCCESS };
55390
55412
  }
55391
55413
 
55392
- function addOnlineResource({ tournamentRecord, onlineResource, organisationId, participantId, personId, courtId, venueId, }) {
55393
- if (!tournamentRecord)
55394
- return { error: MISSING_TOURNAMENT_RECORD };
55395
- if (!isObject(onlineResource))
55396
- return { error: MISSING_VALUE };
55397
- if (intersection(Object.keys(onlineResource), ['resourceSubType', 'resourceType', 'identifier']).length !== 3)
55398
- return decorateResult({
55399
- result: { error: INVALID_OBJECT },
55400
- context: { onlineResource },
55414
+ function removeOnlineResource(params) {
55415
+ const paramsCheck = checkRequiredParameters(params, [{ tournamentRecord: true, onlineResource: true }]);
55416
+ if (paramsCheck.error)
55417
+ return paramsCheck;
55418
+ const { tournamentRecord, onlineResource, organisationId, participantId, personId, courtId, venueId } = params;
55419
+ if (organisationId) {
55420
+ if (tournamentRecord.parentOrganisation?.parentOrganisationId !== organisationId) {
55421
+ return decorateResult({ result: { error: NOT_FOUND } });
55422
+ }
55423
+ removeResource({ element: tournamentRecord.parentOrganisation, onlineResource });
55424
+ }
55425
+ else if (participantId || personId) {
55426
+ const participant = (tournamentRecord.participants ?? []).find((p) => (personId && p.person?.personId === personId) || p.participantId === participantId);
55427
+ if (!participant) {
55428
+ if (personId) {
55429
+ return decorateResult({ result: { error: NOT_FOUND } });
55430
+ }
55431
+ else {
55432
+ return decorateResult({ result: { error: PARTICIPANT_NOT_FOUND } });
55433
+ }
55434
+ }
55435
+ if (personId) {
55436
+ if (participant.person?.personId !== personId) {
55437
+ return decorateResult({ result: { error: INVALID_PARTICIPANT } });
55438
+ }
55439
+ removeResource({ element: participant.person, onlineResource });
55440
+ }
55441
+ else {
55442
+ removeResource({ element: participant, onlineResource });
55443
+ }
55444
+ }
55445
+ else if (courtId) {
55446
+ const court = (tournamentRecord.venues ?? [])
55447
+ .filter((v) => !venueId || v.venueId === venueId)
55448
+ .flatMap((v) => (v.courts ?? []).filter((c) => c.courtId === courtId))?.[0];
55449
+ if (!court)
55450
+ return decorateResult({ result: { error: COURT_NOT_FOUND } });
55451
+ removeResource({ element: court, onlineResource });
55452
+ }
55453
+ else if (venueId) {
55454
+ const venue = (tournamentRecord.venues ?? []).find((v) => v.venueId === venueId);
55455
+ if (!venue)
55456
+ return decorateResult({ result: { error: VENUE_NOT_FOUND } });
55457
+ removeResource({ element: venue, onlineResource });
55458
+ }
55459
+ else {
55460
+ removeResource({ element: tournamentRecord, onlineResource });
55461
+ addNotice({
55462
+ payload: {
55463
+ onlineResources: tournamentRecord.onlineResources,
55464
+ tournamentId: tournamentRecord.tournamentId,
55465
+ },
55466
+ topic: MODIFY_TOURNAMENT_DETAIL,
55401
55467
  });
55468
+ }
55469
+ return { ...SUCCESS };
55470
+ }
55471
+ function removeResource({ element, onlineResource }) {
55472
+ const onlineResources = (element.onlineResources ?? []).filter((resource) => !(resource?.[RESOURCE_SUB_TYPE] === onlineResource[RESOURCE_SUB_TYPE] &&
55473
+ resource?.[RESOURCE_TYPE] === onlineResource[RESOURCE_TYPE] &&
55474
+ resource?.[IDENTIFIER] === onlineResource[IDENTIFIER]));
55475
+ element.onlineResources = onlineResources;
55476
+ }
55477
+
55478
+ function addOnlineResource(params) {
55479
+ const paramsCheck = checkRequiredParameters(params, [{ tournamentRecord: true, onlineResource: true }]);
55480
+ if (paramsCheck.error)
55481
+ return paramsCheck;
55482
+ const { tournamentRecord, onlineResource, organisationId, participantId, personId, courtId, venueId } = params;
55402
55483
  if (organisationId) {
55403
55484
  if (tournamentRecord.parentOrganisation?.parentOrganisationId !== organisationId) {
55404
55485
  return decorateResult({ result: { error: NOT_FOUND } });
55405
55486
  }
55406
- if (!tournamentRecord.parentOrganisation.onlineResources)
55407
- tournamentRecord.parentOrganisation.onlineResources = [];
55408
- tournamentRecord.parentOrganisation.onlineResources.push(onlineResource);
55487
+ mergeResource({ element: tournamentRecord.parentOrganisation, onlineResource });
55409
55488
  }
55410
55489
  else if (participantId || personId) {
55411
55490
  const participant = (tournamentRecord.participants ?? []).find((p) => (personId && p.person?.personId === personId) || p.participantId === participantId);
@@ -55421,14 +55500,10 @@ function addOnlineResource({ tournamentRecord, onlineResource, organisationId, p
55421
55500
  if (participant.person?.personId !== personId) {
55422
55501
  return decorateResult({ result: { error: INVALID_PARTICIPANT } });
55423
55502
  }
55424
- if (!participant.person.onlineResources)
55425
- participant.person.onlineResources = [];
55426
- participant.person.onlineResources.push(onlineResource);
55503
+ mergeResource({ element: participant.person, onlineResource });
55427
55504
  }
55428
55505
  else {
55429
- if (!participant.onlineResources)
55430
- participant.onlineResources = [];
55431
- participant.onlineResources.push(onlineResource);
55506
+ mergeResource({ element: participant, onlineResource });
55432
55507
  }
55433
55508
  }
55434
55509
  else if (courtId) {
@@ -55437,25 +55512,34 @@ function addOnlineResource({ tournamentRecord, onlineResource, organisationId, p
55437
55512
  .flatMap((v) => (v.courts ?? []).filter((c) => c.courtId === courtId))?.[0];
55438
55513
  if (!court)
55439
55514
  return decorateResult({ result: { error: COURT_NOT_FOUND } });
55440
- if (!court.onlineResources)
55441
- court.onlineResources = [];
55442
- court.onlineResources.push(onlineResource);
55515
+ mergeResource({ element: court, onlineResource });
55443
55516
  }
55444
55517
  else if (venueId) {
55445
55518
  const venue = (tournamentRecord.venues ?? []).find((v) => v.venueId === venueId);
55446
55519
  if (!venue)
55447
55520
  return decorateResult({ result: { error: VENUE_NOT_FOUND } });
55448
- if (!venue.onlineResources)
55449
- venue.onlineResources = [];
55450
- venue.onlineResources.push(onlineResource);
55521
+ mergeResource({ element: venue, onlineResource });
55451
55522
  }
55452
55523
  else {
55453
- if (!tournamentRecord.onlineResources)
55454
- tournamentRecord.onlineResources = [];
55455
- tournamentRecord.onlineResources.push(onlineResource);
55524
+ mergeResource({ element: tournamentRecord, onlineResource });
55525
+ addNotice({
55526
+ payload: {
55527
+ onlineResources: tournamentRecord.onlineResources,
55528
+ tournamentId: tournamentRecord.tournamentId,
55529
+ },
55530
+ topic: MODIFY_TOURNAMENT_DETAIL,
55531
+ });
55456
55532
  }
55457
55533
  return { ...SUCCESS };
55458
55534
  }
55535
+ function mergeResource({ element, onlineResource }) {
55536
+ const onlineResources = (element.onlineResources ?? []).filter((resource) => resource?.[RESOURCE_SUB_TYPE] !== onlineResource[RESOURCE_SUB_TYPE] &&
55537
+ resource?.[RESOURCE_TYPE] !== onlineResource[RESOURCE_TYPE] &&
55538
+ resource?.[IDENTIFIER] !== onlineResource[IDENTIFIER]);
55539
+ onlineResources.push(onlineResource);
55540
+ element.onlineResources = onlineResources;
55541
+ return { ...SUCCESS };
55542
+ }
55459
55543
 
55460
55544
  function setTournamentName({ tournamentRecord, promotionalName, tournamentName, formalName }) {
55461
55545
  if (!tournamentRecord)
@@ -55667,6 +55751,7 @@ var mutate$1 = {
55667
55751
  removeEventExtension: removeEventExtension,
55668
55752
  removeExtension: removeExtension,
55669
55753
  removeNotes: removeNotes,
55754
+ removeOnlineResource: removeOnlineResource,
55670
55755
  removeParticipantExtension: removeParticipantExtension,
55671
55756
  removeTournamentExtension: removeTournamentExtension,
55672
55757
  setTournamentCategories: setTournamentCategories,
@@ -55710,6 +55795,7 @@ var index$3 = {
55710
55795
  removeEventExtension: removeEventExtension,
55711
55796
  removeExtension: removeExtension,
55712
55797
  removeNotes: removeNotes,
55798
+ removeOnlineResource: removeOnlineResource,
55713
55799
  removeParticipantExtension: removeParticipantExtension,
55714
55800
  removeTournamentExtension: removeTournamentExtension,
55715
55801
  setTournamentCategories: setTournamentCategories,