tods-competition-factory 1.8.7 → 1.8.9
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.
- package/dist/forge/generate.d.ts +10 -0
- package/dist/forge/generate.mjs +10 -1
- package/dist/forge/generate.mjs.map +1 -1
- package/dist/forge/query.d.ts +10 -0
- package/dist/forge/query.mjs +5 -1
- package/dist/forge/query.mjs.map +1 -1
- package/dist/forge/transform.d.ts +10 -0
- package/dist/forge/transform.mjs +9 -0
- package/dist/forge/transform.mjs.map +1 -1
- package/dist/forge/utilities.mjs.map +1 -1
- package/dist/index.mjs +87 -9
- package/dist/index.mjs.map +1 -1
- package/dist/tods-competition-factory.development.cjs.js +95 -25
- package/dist/tods-competition-factory.development.cjs.js.map +1 -1
- package/dist/tods-competition-factory.production.cjs.min.js +1 -1
- package/dist/tods-competition-factory.production.cjs.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -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.
|
|
2906
|
+
return '1.8.9';
|
|
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({
|
|
@@ -39509,11 +39519,15 @@ function getRounds(_a) {
|
|
|
39509
39519
|
return eventId === round.eventId;
|
|
39510
39520
|
})
|
|
39511
39521
|
: undefined;
|
|
39512
|
-
var
|
|
39513
|
-
|
|
39514
|
-
|
|
39515
|
-
|
|
39516
|
-
|
|
39522
|
+
var startDate = (event === null || event === void 0 ? void 0 : event.startDate) || (tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.startDate);
|
|
39523
|
+
var endDate = (event === null || event === void 0 ? void 0 : event.endDate) || (tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.endDate);
|
|
39524
|
+
var validStartDate = !scheduleDate ||
|
|
39525
|
+
!startDate ||
|
|
39526
|
+
new Date(scheduleDate) >= new Date(startDate);
|
|
39527
|
+
var validEndDate = !scheduleDate ||
|
|
39528
|
+
!endDate ||
|
|
39529
|
+
new Date(scheduleDate) <= new Date(endDate);
|
|
39530
|
+
var validDate = validStartDate && validEndDate;
|
|
39517
39531
|
var validVenue = !venueId || (event === null || event === void 0 ? void 0 : event.validVenueIds.includes(venueId));
|
|
39518
39532
|
var keepRound = keepComplete && keepScheduled && validVenue && validDate;
|
|
39519
39533
|
if (!keepRound)
|
|
@@ -45828,7 +45842,7 @@ function getAvoidanceConflicts(_a) {
|
|
|
45828
45842
|
}
|
|
45829
45843
|
|
|
45830
45844
|
function getSwapOptions(_a) {
|
|
45831
|
-
var positionedParticipants = _a.positionedParticipants, potentialDrawPositions = _a.potentialDrawPositions,
|
|
45845
|
+
var positionedParticipants = _a.positionedParticipants, potentialDrawPositions = _a.potentialDrawPositions, drawPositionGroups = _a.drawPositionGroups, avoidanceConflicts = _a.avoidanceConflicts, isRoundRobin = _a.isRoundRobin;
|
|
45832
45846
|
return avoidanceConflicts
|
|
45833
45847
|
.map(function (conflict) {
|
|
45834
45848
|
var drawPositions = conflict.map(function (c) { return c.drawPosition; });
|
|
@@ -58311,28 +58325,84 @@ function setTournamentStatus(_a) {
|
|
|
58311
58325
|
return __assign({}, SUCCESS);
|
|
58312
58326
|
}
|
|
58313
58327
|
|
|
58314
|
-
// TODO: ability to add onlineResources to other items, e.g. organisations, participants, persons, venues, courts
|
|
58315
58328
|
function addOnlineResource(_a) {
|
|
58316
|
-
var
|
|
58329
|
+
var _b, _c, _d, _e, _f, _g;
|
|
58330
|
+
var tournamentRecord = _a.tournamentRecord, onlineResource = _a.onlineResource, organisationId = _a.organisationId, participantId = _a.participantId, personId = _a.personId, courtId = _a.courtId, venueId = _a.venueId;
|
|
58317
58331
|
if (!tournamentRecord)
|
|
58318
58332
|
return { error: MISSING_TOURNAMENT_RECORD };
|
|
58319
|
-
if (!onlineResource)
|
|
58333
|
+
if (!isObject(onlineResource))
|
|
58320
58334
|
return { error: MISSING_VALUE };
|
|
58321
|
-
if (
|
|
58322
|
-
|
|
58323
|
-
|
|
58324
|
-
|
|
58335
|
+
if (intersection(Object.keys(onlineResource), [
|
|
58336
|
+
'resourceSubType',
|
|
58337
|
+
'resourceType',
|
|
58338
|
+
'identifier',
|
|
58339
|
+
]).length !== 3)
|
|
58340
|
+
return decorateResult({
|
|
58341
|
+
result: { error: INVALID_OBJECT },
|
|
58342
|
+
context: { onlineResource: onlineResource },
|
|
58343
|
+
});
|
|
58344
|
+
if (organisationId) {
|
|
58345
|
+
if (((_b = tournamentRecord.parentOrganisation) === null || _b === void 0 ? void 0 : _b.parentOrganisationId) !==
|
|
58346
|
+
organisationId) {
|
|
58347
|
+
return decorateResult({ result: { error: NOT_FOUND } });
|
|
58348
|
+
}
|
|
58349
|
+
if (!tournamentRecord.parentOrganisation.onlineResources)
|
|
58350
|
+
tournamentRecord.parentOrganisation.onlineResources = [];
|
|
58351
|
+
tournamentRecord.parentOrganisation.onlineResources.push(onlineResource);
|
|
58352
|
+
}
|
|
58353
|
+
else if (participantId || personId) {
|
|
58354
|
+
var participant = ((_c = tournamentRecord.participants) !== null && _c !== void 0 ? _c : []).find(function (p) {
|
|
58355
|
+
var _a;
|
|
58356
|
+
return (personId && ((_a = p.person) === null || _a === void 0 ? void 0 : _a.personId) === personId) ||
|
|
58357
|
+
p.participantId === participantId;
|
|
58358
|
+
});
|
|
58359
|
+
if (!participant) {
|
|
58360
|
+
if (personId) {
|
|
58361
|
+
return decorateResult({ result: { error: NOT_FOUND } });
|
|
58362
|
+
}
|
|
58363
|
+
else {
|
|
58364
|
+
return decorateResult({ result: { error: PARTICIPANT_NOT_FOUND } });
|
|
58365
|
+
}
|
|
58366
|
+
}
|
|
58367
|
+
if (personId) {
|
|
58368
|
+
if (((_d = participant.person) === null || _d === void 0 ? void 0 : _d.personId) !== personId) {
|
|
58369
|
+
// both personId and participantId were provided and person does not match found participant
|
|
58370
|
+
return decorateResult({ result: { error: INVALID_PARTICIPANT } });
|
|
58371
|
+
}
|
|
58372
|
+
if (!participant.person.onlineResources)
|
|
58373
|
+
participant.person.onlineResources = [];
|
|
58374
|
+
participant.person.onlineResources.push(onlineResource);
|
|
58375
|
+
}
|
|
58376
|
+
else {
|
|
58377
|
+
if (!participant.onlineResources)
|
|
58378
|
+
participant.onlineResources = [];
|
|
58379
|
+
participant.onlineResources.push(onlineResource);
|
|
58380
|
+
}
|
|
58381
|
+
}
|
|
58382
|
+
else if (courtId) {
|
|
58383
|
+
var court = (_f = ((_e = tournamentRecord.venues) !== null && _e !== void 0 ? _e : [])
|
|
58384
|
+
.filter(function (v) { return !venueId || v.venueId === venueId; })
|
|
58385
|
+
.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];
|
|
58386
|
+
if (!court)
|
|
58387
|
+
return decorateResult({ result: { error: COURT_NOT_FOUND } });
|
|
58388
|
+
if (!court.onlineResources)
|
|
58389
|
+
court.onlineResources = [];
|
|
58390
|
+
court.onlineResources.push(onlineResource);
|
|
58391
|
+
}
|
|
58392
|
+
else if (venueId) {
|
|
58393
|
+
var venue = ((_g = tournamentRecord.venues) !== null && _g !== void 0 ? _g : []).find(function (v) { return v.venueId === venueId; });
|
|
58394
|
+
if (!venue)
|
|
58395
|
+
return decorateResult({ result: { error: VENUE_NOT_FOUND } });
|
|
58396
|
+
if (!venue.onlineResources)
|
|
58397
|
+
venue.onlineResources = [];
|
|
58398
|
+
venue.onlineResources.push(onlineResource);
|
|
58399
|
+
}
|
|
58400
|
+
else {
|
|
58401
|
+
if (!tournamentRecord.onlineResources)
|
|
58402
|
+
tournamentRecord.onlineResources = [];
|
|
58403
|
+
tournamentRecord.onlineResources.push(onlineResource);
|
|
58404
|
+
}
|
|
58325
58405
|
return __assign({}, SUCCESS);
|
|
58326
|
-
/**
|
|
58327
|
-
[
|
|
58328
|
-
{
|
|
58329
|
-
identifier:
|
|
58330
|
-
resourceSubType: 'IMAGE',
|
|
58331
|
-
name: 'tournamentImage',
|
|
58332
|
-
resourceType: 'URL',
|
|
58333
|
-
},
|
|
58334
|
-
];
|
|
58335
|
-
*/
|
|
58336
58406
|
}
|
|
58337
58407
|
|
|
58338
58408
|
function analyzeDraws(_a) {
|
|
@@ -62336,7 +62406,7 @@ function modifyDrawDefinition(_a) {
|
|
|
62336
62406
|
var _b;
|
|
62337
62407
|
var tournamentRecord = _a.tournamentRecord, drawDefinition = _a.drawDefinition, drawUpdates = _a.drawUpdates, drawId = _a.drawId, event = _a.event;
|
|
62338
62408
|
if (!isObject(drawUpdates))
|
|
62339
|
-
return { error:
|
|
62409
|
+
return { error: INVALID_VALUES };
|
|
62340
62410
|
var flightProfile = getFlightProfile({ event: event }).flightProfile;
|
|
62341
62411
|
var nameResult = drawUpdates.drawName &&
|
|
62342
62412
|
modifyDrawName({
|