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
package/dist/index.mjs
CHANGED
|
@@ -945,6 +945,10 @@ const INVALID_OBJECT = {
|
|
|
945
945
|
message: "Invalid object",
|
|
946
946
|
code: "ERR_INVALID_OBJECT"
|
|
947
947
|
};
|
|
948
|
+
const INVALID_GENDER = {
|
|
949
|
+
message: "Invalid gender",
|
|
950
|
+
code: "ERR_INVALID_GENDER"
|
|
951
|
+
};
|
|
948
952
|
const INVALID_CATEGORY = {
|
|
949
953
|
message: "Invalid category",
|
|
950
954
|
code: "ERR_INVALID_CATEGORY"
|
|
@@ -1062,6 +1066,7 @@ const errorConditionConstants = {
|
|
|
1062
1066
|
INVALID_ENTRIES,
|
|
1063
1067
|
INVALID_EVENT_TYPE,
|
|
1064
1068
|
INVALID_GAME_SCORES,
|
|
1069
|
+
INVALID_GENDER,
|
|
1065
1070
|
INVALID_MATCHUP_FORMAT,
|
|
1066
1071
|
INVALID_MATCHUP_STATUS,
|
|
1067
1072
|
INVALID_MATCHUP_STATUS_BYE,
|
|
@@ -2375,7 +2380,7 @@ const matchUpFormatCode = {
|
|
|
2375
2380
|
};
|
|
2376
2381
|
|
|
2377
2382
|
function factoryVersion() {
|
|
2378
|
-
return "1.8.
|
|
2383
|
+
return "1.8.9";
|
|
2379
2384
|
}
|
|
2380
2385
|
|
|
2381
2386
|
function getObjectTieFormat(obj) {
|
|
@@ -2938,6 +2943,11 @@ function validateCollectionDefinition({
|
|
|
2938
2943
|
}
|
|
2939
2944
|
if (checkGender && referenceGender && gender && [GenderEnum.Male, GenderEnum.Female].includes(referenceGender) && referenceGender !== gender) {
|
|
2940
2945
|
errors.push(`Invalid gender: ${gender}`);
|
|
2946
|
+
return decorateResult({
|
|
2947
|
+
context: { referenceGender, gender },
|
|
2948
|
+
result: { error: INVALID_GENDER },
|
|
2949
|
+
stack
|
|
2950
|
+
});
|
|
2941
2951
|
}
|
|
2942
2952
|
if (checkCategory && referenceCategory && category) {
|
|
2943
2953
|
const result = categoryCanContain({
|
|
@@ -36515,7 +36525,11 @@ function getRounds({
|
|
|
36515
36525
|
const keepComplete = !excludeCompletedRounds || !isComplete;
|
|
36516
36526
|
const keepScheduled = !excludeScheduledRounds || !isScheduled;
|
|
36517
36527
|
const event = venueId || scheduleDate ? events?.find(({ eventId }) => eventId === round.eventId) : void 0;
|
|
36518
|
-
const
|
|
36528
|
+
const startDate = event?.startDate || tournamentRecord?.startDate;
|
|
36529
|
+
const endDate = event?.endDate || tournamentRecord?.endDate;
|
|
36530
|
+
const validStartDate = !scheduleDate || !startDate || new Date(scheduleDate) >= new Date(startDate);
|
|
36531
|
+
const validEndDate = !scheduleDate || !endDate || new Date(scheduleDate) <= new Date(endDate);
|
|
36532
|
+
const validDate = validStartDate && validEndDate;
|
|
36519
36533
|
const validVenue = !venueId || event?.validVenueIds.includes(venueId);
|
|
36520
36534
|
const keepRound = keepComplete && keepScheduled && validVenue && validDate;
|
|
36521
36535
|
if (!keepRound)
|
|
@@ -42317,8 +42331,8 @@ function getAvoidanceConflicts({ isRoundRobin, groupedParticipants }) {
|
|
|
42317
42331
|
function getSwapOptions({
|
|
42318
42332
|
positionedParticipants,
|
|
42319
42333
|
potentialDrawPositions,
|
|
42320
|
-
avoidanceConflicts,
|
|
42321
42334
|
drawPositionGroups,
|
|
42335
|
+
avoidanceConflicts,
|
|
42322
42336
|
isRoundRobin
|
|
42323
42337
|
}) {
|
|
42324
42338
|
return avoidanceConflicts.map((conflict) => {
|
|
@@ -53798,15 +53812,79 @@ function setTournamentStatus({ tournamentRecord, status }) {
|
|
|
53798
53812
|
|
|
53799
53813
|
function addOnlineResource({
|
|
53800
53814
|
tournamentRecord,
|
|
53801
|
-
onlineResource
|
|
53815
|
+
onlineResource,
|
|
53816
|
+
organisationId,
|
|
53817
|
+
participantId,
|
|
53818
|
+
personId,
|
|
53819
|
+
courtId,
|
|
53820
|
+
venueId
|
|
53802
53821
|
}) {
|
|
53803
53822
|
if (!tournamentRecord)
|
|
53804
53823
|
return { error: MISSING_TOURNAMENT_RECORD };
|
|
53805
|
-
if (!onlineResource)
|
|
53824
|
+
if (!isObject(onlineResource))
|
|
53806
53825
|
return { error: MISSING_VALUE };
|
|
53807
|
-
if (
|
|
53808
|
-
|
|
53809
|
-
|
|
53826
|
+
if (intersection(Object.keys(onlineResource), [
|
|
53827
|
+
"resourceSubType",
|
|
53828
|
+
"resourceType",
|
|
53829
|
+
"identifier"
|
|
53830
|
+
]).length !== 3)
|
|
53831
|
+
return decorateResult({
|
|
53832
|
+
result: { error: INVALID_OBJECT },
|
|
53833
|
+
context: { onlineResource }
|
|
53834
|
+
});
|
|
53835
|
+
if (organisationId) {
|
|
53836
|
+
if (tournamentRecord.parentOrganisation?.parentOrganisationId !== organisationId) {
|
|
53837
|
+
return decorateResult({ result: { error: NOT_FOUND } });
|
|
53838
|
+
}
|
|
53839
|
+
if (!tournamentRecord.parentOrganisation.onlineResources)
|
|
53840
|
+
tournamentRecord.parentOrganisation.onlineResources = [];
|
|
53841
|
+
tournamentRecord.parentOrganisation.onlineResources.push(onlineResource);
|
|
53842
|
+
} else if (participantId || personId) {
|
|
53843
|
+
const participant = (tournamentRecord.participants ?? []).find(
|
|
53844
|
+
(p) => personId && p.person?.personId === personId || p.participantId === participantId
|
|
53845
|
+
);
|
|
53846
|
+
if (!participant) {
|
|
53847
|
+
if (personId) {
|
|
53848
|
+
return decorateResult({ result: { error: NOT_FOUND } });
|
|
53849
|
+
} else {
|
|
53850
|
+
return decorateResult({ result: { error: PARTICIPANT_NOT_FOUND } });
|
|
53851
|
+
}
|
|
53852
|
+
}
|
|
53853
|
+
if (personId) {
|
|
53854
|
+
if (participant.person?.personId !== personId) {
|
|
53855
|
+
return decorateResult({ result: { error: INVALID_PARTICIPANT } });
|
|
53856
|
+
}
|
|
53857
|
+
if (!participant.person.onlineResources)
|
|
53858
|
+
participant.person.onlineResources = [];
|
|
53859
|
+
participant.person.onlineResources.push(onlineResource);
|
|
53860
|
+
} else {
|
|
53861
|
+
if (!participant.onlineResources)
|
|
53862
|
+
participant.onlineResources = [];
|
|
53863
|
+
participant.onlineResources.push(onlineResource);
|
|
53864
|
+
}
|
|
53865
|
+
} else if (courtId) {
|
|
53866
|
+
const court = (tournamentRecord.venues ?? []).filter((v) => !venueId || v.venueId === venueId).flatMap(
|
|
53867
|
+
(v) => (v.courts ?? []).filter((c) => c.courtId === courtId)
|
|
53868
|
+
)?.[0];
|
|
53869
|
+
if (!court)
|
|
53870
|
+
return decorateResult({ result: { error: COURT_NOT_FOUND } });
|
|
53871
|
+
if (!court.onlineResources)
|
|
53872
|
+
court.onlineResources = [];
|
|
53873
|
+
court.onlineResources.push(onlineResource);
|
|
53874
|
+
} else if (venueId) {
|
|
53875
|
+
const venue = (tournamentRecord.venues ?? []).find(
|
|
53876
|
+
(v) => v.venueId === venueId
|
|
53877
|
+
);
|
|
53878
|
+
if (!venue)
|
|
53879
|
+
return decorateResult({ result: { error: VENUE_NOT_FOUND } });
|
|
53880
|
+
if (!venue.onlineResources)
|
|
53881
|
+
venue.onlineResources = [];
|
|
53882
|
+
venue.onlineResources.push(onlineResource);
|
|
53883
|
+
} else {
|
|
53884
|
+
if (!tournamentRecord.onlineResources)
|
|
53885
|
+
tournamentRecord.onlineResources = [];
|
|
53886
|
+
tournamentRecord.onlineResources.push(onlineResource);
|
|
53887
|
+
}
|
|
53810
53888
|
return { ...SUCCESS };
|
|
53811
53889
|
}
|
|
53812
53890
|
|
|
@@ -57570,7 +57648,7 @@ function modifyDrawDefinition({
|
|
|
57570
57648
|
event
|
|
57571
57649
|
}) {
|
|
57572
57650
|
if (!isObject(drawUpdates))
|
|
57573
|
-
return { error:
|
|
57651
|
+
return { error: INVALID_VALUES };
|
|
57574
57652
|
const flightProfile = getFlightProfile({ event }).flightProfile;
|
|
57575
57653
|
const nameResult = drawUpdates.drawName && modifyDrawName({
|
|
57576
57654
|
drawName: drawUpdates.drawName,
|