tods-competition-factory 1.8.7 → 1.8.8

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.
@@ -1217,6 +1217,10 @@ var INVALID_OBJECT = {
1217
1217
  message: 'Invalid object',
1218
1218
  code: 'ERR_INVALID_OBJECT',
1219
1219
  };
1220
+ var INVALID_GENDER = {
1221
+ message: 'Invalid gender',
1222
+ code: 'ERR_INVALID_GENDER',
1223
+ };
1220
1224
  var INVALID_CATEGORY = {
1221
1225
  message: 'Invalid category',
1222
1226
  code: 'ERR_INVALID_CATEGORY',
@@ -1334,6 +1338,7 @@ var errorConditionConstants = {
1334
1338
  INVALID_ENTRIES: INVALID_ENTRIES,
1335
1339
  INVALID_EVENT_TYPE: INVALID_EVENT_TYPE,
1336
1340
  INVALID_GAME_SCORES: INVALID_GAME_SCORES,
1341
+ INVALID_GENDER: INVALID_GENDER,
1337
1342
  INVALID_MATCHUP_FORMAT: INVALID_MATCHUP_FORMAT,
1338
1343
  INVALID_MATCHUP_STATUS: INVALID_MATCHUP_STATUS,
1339
1344
  INVALID_MATCHUP_STATUS_BYE: INVALID_MATCHUP_STATUS_BYE,
@@ -2898,7 +2903,7 @@ var matchUpFormatCode = {
2898
2903
  };
2899
2904
 
2900
2905
  function factoryVersion() {
2901
- return '1.8.7';
2906
+ return '1.8.8';
2902
2907
  }
2903
2908
 
2904
2909
  function getObjectTieFormat(obj) {
@@ -3922,6 +3927,11 @@ function validateCollectionDefinition(_a) {
3922
3927
  [GenderEnum.Male, GenderEnum.Female].includes(referenceGender) &&
3923
3928
  referenceGender !== gender) {
3924
3929
  errors.push("Invalid gender: ".concat(gender));
3930
+ return decorateResult({
3931
+ context: { referenceGender: referenceGender, gender: gender },
3932
+ result: { error: INVALID_GENDER },
3933
+ stack: stack,
3934
+ });
3925
3935
  }
3926
3936
  if (checkCategory && referenceCategory && category) {
3927
3937
  var result = categoryCanContain({
@@ -45828,7 +45838,7 @@ function getAvoidanceConflicts(_a) {
45828
45838
  }
45829
45839
 
45830
45840
  function getSwapOptions(_a) {
45831
- var positionedParticipants = _a.positionedParticipants, potentialDrawPositions = _a.potentialDrawPositions, avoidanceConflicts = _a.avoidanceConflicts, drawPositionGroups = _a.drawPositionGroups, isRoundRobin = _a.isRoundRobin;
45841
+ var positionedParticipants = _a.positionedParticipants, potentialDrawPositions = _a.potentialDrawPositions, drawPositionGroups = _a.drawPositionGroups, avoidanceConflicts = _a.avoidanceConflicts, isRoundRobin = _a.isRoundRobin;
45832
45842
  return avoidanceConflicts
45833
45843
  .map(function (conflict) {
45834
45844
  var drawPositions = conflict.map(function (c) { return c.drawPosition; });
@@ -58311,28 +58321,84 @@ function setTournamentStatus(_a) {
58311
58321
  return __assign({}, SUCCESS);
58312
58322
  }
58313
58323
 
58314
- // TODO: ability to add onlineResources to other items, e.g. organisations, participants, persons, venues, courts
58315
58324
  function addOnlineResource(_a) {
58316
- var tournamentRecord = _a.tournamentRecord, onlineResource = _a.onlineResource;
58325
+ var _b, _c, _d, _e, _f, _g;
58326
+ var tournamentRecord = _a.tournamentRecord, onlineResource = _a.onlineResource, organisationId = _a.organisationId, participantId = _a.participantId, personId = _a.personId, courtId = _a.courtId, venueId = _a.venueId;
58317
58327
  if (!tournamentRecord)
58318
58328
  return { error: MISSING_TOURNAMENT_RECORD };
58319
- if (!onlineResource)
58329
+ if (!isObject(onlineResource))
58320
58330
  return { error: MISSING_VALUE };
58321
- if (!tournamentRecord.onlineResources)
58322
- tournamentRecord.onlineResources = [];
58323
- // TODO: onlineResource validation
58324
- tournamentRecord.onlineResources.push(onlineResource);
58331
+ if (intersection(Object.keys(onlineResource), [
58332
+ 'resourceSubType',
58333
+ 'resourceType',
58334
+ 'identifier',
58335
+ ]).length !== 3)
58336
+ return decorateResult({
58337
+ result: { error: INVALID_OBJECT },
58338
+ context: { onlineResource: onlineResource },
58339
+ });
58340
+ if (organisationId) {
58341
+ if (((_b = tournamentRecord.parentOrganisation) === null || _b === void 0 ? void 0 : _b.parentOrganisationId) !==
58342
+ organisationId) {
58343
+ return decorateResult({ result: { error: NOT_FOUND } });
58344
+ }
58345
+ if (!tournamentRecord.parentOrganisation.onlineResources)
58346
+ tournamentRecord.parentOrganisation.onlineResources = [];
58347
+ tournamentRecord.parentOrganisation.onlineResources.push(onlineResource);
58348
+ }
58349
+ else if (participantId || personId) {
58350
+ var participant = ((_c = tournamentRecord.participants) !== null && _c !== void 0 ? _c : []).find(function (p) {
58351
+ var _a;
58352
+ return (personId && ((_a = p.person) === null || _a === void 0 ? void 0 : _a.personId) === personId) ||
58353
+ p.participantId === participantId;
58354
+ });
58355
+ if (!participant) {
58356
+ if (personId) {
58357
+ return decorateResult({ result: { error: NOT_FOUND } });
58358
+ }
58359
+ else {
58360
+ return decorateResult({ result: { error: PARTICIPANT_NOT_FOUND } });
58361
+ }
58362
+ }
58363
+ if (personId) {
58364
+ if (((_d = participant.person) === null || _d === void 0 ? void 0 : _d.personId) !== personId) {
58365
+ // both personId and participantId were provided and person does not match found participant
58366
+ return decorateResult({ result: { error: INVALID_PARTICIPANT } });
58367
+ }
58368
+ if (!participant.person.onlineResources)
58369
+ participant.person.onlineResources = [];
58370
+ participant.person.onlineResources.push(onlineResource);
58371
+ }
58372
+ else {
58373
+ if (!participant.onlineResources)
58374
+ participant.onlineResources = [];
58375
+ participant.onlineResources.push(onlineResource);
58376
+ }
58377
+ }
58378
+ else if (courtId) {
58379
+ var court = (_f = ((_e = tournamentRecord.venues) !== null && _e !== void 0 ? _e : [])
58380
+ .filter(function (v) { return !venueId || v.venueId === venueId; })
58381
+ .flatMap(function (v) { var _a; return ((_a = v.courts) !== null && _a !== void 0 ? _a : []).filter(function (c) { return c.courtId === courtId; }); })) === null || _f === void 0 ? void 0 : _f[0];
58382
+ if (!court)
58383
+ return decorateResult({ result: { error: COURT_NOT_FOUND } });
58384
+ if (!court.onlineResources)
58385
+ court.onlineResources = [];
58386
+ court.onlineResources.push(onlineResource);
58387
+ }
58388
+ else if (venueId) {
58389
+ var venue = ((_g = tournamentRecord.venues) !== null && _g !== void 0 ? _g : []).find(function (v) { return v.venueId === venueId; });
58390
+ if (!venue)
58391
+ return decorateResult({ result: { error: VENUE_NOT_FOUND } });
58392
+ if (!venue.onlineResources)
58393
+ venue.onlineResources = [];
58394
+ venue.onlineResources.push(onlineResource);
58395
+ }
58396
+ else {
58397
+ if (!tournamentRecord.onlineResources)
58398
+ tournamentRecord.onlineResources = [];
58399
+ tournamentRecord.onlineResources.push(onlineResource);
58400
+ }
58325
58401
  return __assign({}, SUCCESS);
58326
- /**
58327
- [
58328
- {
58329
- identifier:
58330
- resourceSubType: 'IMAGE',
58331
- name: 'tournamentImage',
58332
- resourceType: 'URL',
58333
- },
58334
- ];
58335
- */
58336
58402
  }
58337
58403
 
58338
58404
  function analyzeDraws(_a) {