tods-competition-factory 1.7.13 → 1.7.15
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.mjs +63 -82
- package/dist/forge/generate.mjs.map +1 -1
- package/dist/forge/query.d.ts +4 -3
- package/dist/forge/query.mjs +17 -20
- package/dist/forge/query.mjs.map +1 -1
- package/dist/forge/transform.mjs +61 -75
- package/dist/forge/transform.mjs.map +1 -1
- package/dist/index.mjs +557 -369
- package/dist/index.mjs.map +1 -1
- package/dist/tods-competition-factory.development.cjs.js +594 -419
- 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 +2 -2
package/dist/forge/transform.mjs
CHANGED
|
@@ -975,28 +975,6 @@ function UUID() {
|
|
|
975
975
|
lut[d3 & 255] + lut[d3 >> 8 & 255] + lut[d3 >> 16 & 255] + lut[d3 >> 24 & 255];
|
|
976
976
|
}
|
|
977
977
|
|
|
978
|
-
function decorateResult({
|
|
979
|
-
context,
|
|
980
|
-
result,
|
|
981
|
-
stack,
|
|
982
|
-
info
|
|
983
|
-
}) {
|
|
984
|
-
if (result && !Array.isArray(result?.stack))
|
|
985
|
-
result.stack = [];
|
|
986
|
-
if (result && Array.isArray(result?.stack) && typeof stack === "string") {
|
|
987
|
-
result.stack.push(stack);
|
|
988
|
-
}
|
|
989
|
-
if (info && result?.error)
|
|
990
|
-
result.error.info = info;
|
|
991
|
-
if (result && typeof context === "object" && Object.keys(context).length) {
|
|
992
|
-
Object.assign(result, definedAttributes(context));
|
|
993
|
-
}
|
|
994
|
-
if (result && !result?.error && !result?.success) {
|
|
995
|
-
Object.assign(result, { ...SUCCESS });
|
|
996
|
-
}
|
|
997
|
-
return result ?? { success: true };
|
|
998
|
-
}
|
|
999
|
-
|
|
1000
978
|
const RANKING = "RANKING";
|
|
1001
979
|
const RATING = "RATING";
|
|
1002
980
|
const SCALE = "SCALE";
|
|
@@ -1068,6 +1046,29 @@ function findParticipant({
|
|
|
1068
1046
|
return participant;
|
|
1069
1047
|
}
|
|
1070
1048
|
|
|
1049
|
+
function decorateResult({
|
|
1050
|
+
context,
|
|
1051
|
+
result,
|
|
1052
|
+
stack,
|
|
1053
|
+
info
|
|
1054
|
+
}) {
|
|
1055
|
+
if (result && !Array.isArray(result?.stack))
|
|
1056
|
+
result.stack = [];
|
|
1057
|
+
if (result && Array.isArray(result?.stack) && typeof stack === "string") {
|
|
1058
|
+
result.stack.push(stack);
|
|
1059
|
+
}
|
|
1060
|
+
if (result && info) {
|
|
1061
|
+
result.info = info;
|
|
1062
|
+
}
|
|
1063
|
+
if (result && typeof context === "object" && Object.keys(context).length) {
|
|
1064
|
+
Object.assign(result, definedAttributes(context));
|
|
1065
|
+
}
|
|
1066
|
+
if (result && !result?.error && !result?.success) {
|
|
1067
|
+
Object.assign(result, { ...SUCCESS });
|
|
1068
|
+
}
|
|
1069
|
+
return result ?? { success: true };
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1071
1072
|
const stack = "extensionQueries";
|
|
1072
1073
|
function findExtension$1({
|
|
1073
1074
|
element,
|
|
@@ -1141,19 +1142,15 @@ function findEvent({
|
|
|
1141
1142
|
}) {
|
|
1142
1143
|
const stack = "findEvent";
|
|
1143
1144
|
if (!tournamentRecord)
|
|
1144
|
-
return {
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
stack
|
|
1150
|
-
})
|
|
1151
|
-
};
|
|
1152
|
-
const events = tournamentRecord?.events || [];
|
|
1145
|
+
return decorateResult({
|
|
1146
|
+
result: { error: MISSING_TOURNAMENT_RECORD },
|
|
1147
|
+
stack
|
|
1148
|
+
});
|
|
1149
|
+
const events = tournamentRecord?.events ?? [];
|
|
1153
1150
|
if (drawId) {
|
|
1154
1151
|
let drawDefinition;
|
|
1155
1152
|
const event = events.find((event2) => {
|
|
1156
|
-
const drawDefinitions = event2?.drawDefinitions
|
|
1153
|
+
const drawDefinitions = event2?.drawDefinitions ?? [];
|
|
1157
1154
|
const targetDrawDefinition = drawDefinitions.find(
|
|
1158
1155
|
(drawDefinition2) => drawDefinition2.drawId === drawId
|
|
1159
1156
|
);
|
|
@@ -1346,7 +1343,7 @@ function addExtension$1(params) {
|
|
|
1346
1343
|
});
|
|
1347
1344
|
if (!params.element.extensions)
|
|
1348
1345
|
params.element.extensions = [];
|
|
1349
|
-
const creationTime = params
|
|
1346
|
+
const creationTime = params?.creationTime ?? true;
|
|
1350
1347
|
if (creationTime) {
|
|
1351
1348
|
const createdAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
1352
1349
|
Object.assign(params.extension, { createdAt });
|
|
@@ -1727,34 +1724,28 @@ function validateTieFormat(params) {
|
|
|
1727
1724
|
const tieFormat = params?.tieFormat;
|
|
1728
1725
|
const stack = "validateTieFormat";
|
|
1729
1726
|
const errors = [];
|
|
1730
|
-
if (typeof tieFormat !== "object") {
|
|
1727
|
+
if (!params || !tieFormat || typeof tieFormat !== "object") {
|
|
1731
1728
|
errors.push("tieFormat must be an object");
|
|
1732
1729
|
return decorateResult({
|
|
1733
|
-
result: {
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
stack
|
|
1737
|
-
}
|
|
1730
|
+
result: { error: INVALID_TIE_FORMAT },
|
|
1731
|
+
context: { tieFormat, errors },
|
|
1732
|
+
stack
|
|
1738
1733
|
});
|
|
1739
1734
|
}
|
|
1740
1735
|
if (typeof tieFormat.winCriteria !== "object") {
|
|
1741
1736
|
errors.push("tieFormat.winCriteria must be an object");
|
|
1742
1737
|
return decorateResult({
|
|
1743
|
-
result: {
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
stack
|
|
1747
|
-
}
|
|
1738
|
+
result: { error: INVALID_TIE_FORMAT },
|
|
1739
|
+
context: { tieFormat, errors },
|
|
1740
|
+
stack
|
|
1748
1741
|
});
|
|
1749
1742
|
}
|
|
1750
1743
|
if (!Array.isArray(tieFormat.collectionDefinitions)) {
|
|
1751
1744
|
errors.push(mustBeAnArray("tieFormat.collectionDefinitions"));
|
|
1752
1745
|
return decorateResult({
|
|
1753
|
-
result: {
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
stack
|
|
1757
|
-
}
|
|
1746
|
+
result: { error: INVALID_TIE_FORMAT },
|
|
1747
|
+
context: { tieFormat, errors },
|
|
1748
|
+
stack
|
|
1758
1749
|
});
|
|
1759
1750
|
}
|
|
1760
1751
|
let aggregateValueImperative;
|
|
@@ -1787,11 +1778,9 @@ function validateTieFormat(params) {
|
|
|
1787
1778
|
);
|
|
1788
1779
|
}
|
|
1789
1780
|
return decorateResult({
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
stack
|
|
1794
|
-
}
|
|
1781
|
+
context: { tieFormat, errors, aggregateValueImperative },
|
|
1782
|
+
result: { error: INVALID_TIE_FORMAT },
|
|
1783
|
+
stack
|
|
1795
1784
|
});
|
|
1796
1785
|
}
|
|
1797
1786
|
const collectionIds = tieFormat.collectionDefinitions.map(
|
|
@@ -1802,11 +1791,9 @@ function validateTieFormat(params) {
|
|
|
1802
1791
|
const result = { valid, errors };
|
|
1803
1792
|
if (!valid) {
|
|
1804
1793
|
return decorateResult({
|
|
1805
|
-
result: {
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
stack
|
|
1809
|
-
}
|
|
1794
|
+
result: { error: INVALID_TIE_FORMAT },
|
|
1795
|
+
context: { tieFormat, errors },
|
|
1796
|
+
stack
|
|
1810
1797
|
});
|
|
1811
1798
|
}
|
|
1812
1799
|
return result;
|
|
@@ -1865,7 +1852,7 @@ function validateCollectionDefinition({
|
|
|
1865
1852
|
errors.push(`collectionValue is not type number: ${collectionValue}`);
|
|
1866
1853
|
}
|
|
1867
1854
|
if (collectionValueProfiles) {
|
|
1868
|
-
const result =
|
|
1855
|
+
const result = validateCollectionValueProfiles({
|
|
1869
1856
|
collectionValueProfiles,
|
|
1870
1857
|
matchUpCount
|
|
1871
1858
|
});
|
|
@@ -1886,7 +1873,7 @@ function validateCollectionDefinition({
|
|
|
1886
1873
|
return { errors, error: INVALID_OBJECT };
|
|
1887
1874
|
return { valid: true };
|
|
1888
1875
|
}
|
|
1889
|
-
function
|
|
1876
|
+
function validateCollectionValueProfiles({
|
|
1890
1877
|
collectionValueProfiles,
|
|
1891
1878
|
matchUpCount
|
|
1892
1879
|
}) {
|
|
@@ -3816,7 +3803,7 @@ function findCourt({
|
|
|
3816
3803
|
} else if (tournamentRecords) {
|
|
3817
3804
|
const linkedTournamentIds = getLinkedTournamentIds({
|
|
3818
3805
|
tournamentRecords
|
|
3819
|
-
}).linkedTournamentIds
|
|
3806
|
+
}).linkedTournamentIds ?? [];
|
|
3820
3807
|
const relevantIds = linkedTournamentIds[tournamentRecord.tournamentId];
|
|
3821
3808
|
for (const tournamentId of relevantIds) {
|
|
3822
3809
|
const record = tournamentRecords[tournamentId];
|
|
@@ -10831,7 +10818,7 @@ function removeSubsequentRoundsParticipant({
|
|
|
10831
10818
|
const positionAssignments = getPositionAssignments({
|
|
10832
10819
|
drawDefinition,
|
|
10833
10820
|
structureId
|
|
10834
|
-
}).positionAssignments
|
|
10821
|
+
}).positionAssignments ?? [];
|
|
10835
10822
|
relevantMatchUps?.forEach(
|
|
10836
10823
|
(matchUp) => removeDrawPosition({
|
|
10837
10824
|
drawPosition: targetDrawPosition,
|
|
@@ -10861,7 +10848,7 @@ function removeDrawPosition({
|
|
|
10861
10848
|
const initialDrawPositions = targetMatchUp.drawPositions?.slice();
|
|
10862
10849
|
const initialMatchUpStatus = targetMatchUp.matchUpStatus;
|
|
10863
10850
|
const initialWinningSide = targetMatchUp.winningSide;
|
|
10864
|
-
matchUpsMap = matchUpsMap
|
|
10851
|
+
matchUpsMap = matchUpsMap ?? getMatchUpsMap({ drawDefinition });
|
|
10865
10852
|
const mappedMatchUps = matchUpsMap.mappedMatchUps;
|
|
10866
10853
|
const matchUps = mappedMatchUps[structure.structureId].matchUps;
|
|
10867
10854
|
const { initialRoundNumber } = getInitialRoundNumber({
|
|
@@ -10869,7 +10856,7 @@ function removeDrawPosition({
|
|
|
10869
10856
|
matchUps
|
|
10870
10857
|
});
|
|
10871
10858
|
if (targetMatchUp.roundNumber && initialRoundNumber && targetMatchUp.roundNumber > initialRoundNumber) {
|
|
10872
|
-
const drawPositions = (targetMatchUp.drawPositions
|
|
10859
|
+
const drawPositions = (targetMatchUp.drawPositions ?? []).map(
|
|
10873
10860
|
(currentDrawPosition) => currentDrawPosition === drawPosition ? void 0 : currentDrawPosition
|
|
10874
10861
|
);
|
|
10875
10862
|
targetMatchUp.drawPositions = drawPositions;
|
|
@@ -10878,7 +10865,7 @@ function removeDrawPosition({
|
|
|
10878
10865
|
const inContextTargetMatchUp = inContextDrawMatchUps?.find(
|
|
10879
10866
|
(matchUp) => matchUp.matchUpId === targetMatchUp.matchUpId
|
|
10880
10867
|
);
|
|
10881
|
-
const sides = inContextTargetMatchUp?.sides
|
|
10868
|
+
const sides = inContextTargetMatchUp?.sides ?? [];
|
|
10882
10869
|
const drawPositionSideIndex = sides.reduce(
|
|
10883
10870
|
(index, side, i) => side.drawPosition === drawPosition ? i : index,
|
|
10884
10871
|
void 0
|
|
@@ -12456,9 +12443,7 @@ function assignMatchUpDrawPosition({
|
|
|
12456
12443
|
return { ...SUCCESS };
|
|
12457
12444
|
} else {
|
|
12458
12445
|
return decorateResult({
|
|
12459
|
-
result: {
|
|
12460
|
-
error: DRAW_POSITION_ASSIGNED
|
|
12461
|
-
},
|
|
12446
|
+
result: { error: DRAW_POSITION_ASSIGNED },
|
|
12462
12447
|
context: { drawPosition },
|
|
12463
12448
|
stack
|
|
12464
12449
|
});
|
|
@@ -13166,8 +13151,8 @@ function getSeedGroups({
|
|
|
13166
13151
|
return {
|
|
13167
13152
|
seedGroups: void 0,
|
|
13168
13153
|
...decorateResult({
|
|
13169
|
-
result: { error: INVALID_VALUES },
|
|
13170
13154
|
context: { roundRobinGroupsCount },
|
|
13155
|
+
result: { error: INVALID_VALUES },
|
|
13171
13156
|
stack
|
|
13172
13157
|
})
|
|
13173
13158
|
};
|
|
@@ -14194,7 +14179,8 @@ function directLoser(params) {
|
|
|
14194
14179
|
if (result.error)
|
|
14195
14180
|
return decorateResult({ result, stack });
|
|
14196
14181
|
} else if (loserParticipantId && isFeedRound) {
|
|
14197
|
-
|
|
14182
|
+
unfilledTargetMatchUpDrawPositions.sort(numericSort);
|
|
14183
|
+
const fedDrawPosition = unfilledTargetMatchUpDrawPositions[0];
|
|
14198
14184
|
const result = assignDrawPosition({
|
|
14199
14185
|
participantId: loserParticipantId,
|
|
14200
14186
|
structureId: targetStructureId,
|
|
@@ -16080,7 +16066,7 @@ function setMatchUpStatus$2(params) {
|
|
|
16080
16066
|
drawDefinition
|
|
16081
16067
|
});
|
|
16082
16068
|
if (score && matchUp.matchUpType !== TEAM$2 && !disableScoreValidation) {
|
|
16083
|
-
const matchUpFormat = matchUp.matchUpFormat
|
|
16069
|
+
const matchUpFormat = matchUp.matchUpFormat ?? structure?.matchUpFormat ?? drawDefinition?.matchUpFormat ?? event?.matchUpFormat;
|
|
16084
16070
|
const result2 = validateScore({
|
|
16085
16071
|
existingMatchUpStatus: matchUp.matchUpStatus,
|
|
16086
16072
|
matchUpFormat,
|
|
@@ -16101,9 +16087,9 @@ function setMatchUpStatus$2(params) {
|
|
|
16101
16087
|
).every((assignment) => assignment.participantId);
|
|
16102
16088
|
if (matchUpStatus && particicipantsRequiredMatchUpStatuses.includes(matchUpStatus) && !bothSideParticipants) {
|
|
16103
16089
|
return decorateResult({
|
|
16104
|
-
result: { error: INVALID_MATCHUP_STATUS },
|
|
16105
16090
|
info: "present in participantRequiredMatchUpStatuses",
|
|
16106
|
-
context: { matchUpStatus, bothSideParticipants }
|
|
16091
|
+
context: { matchUpStatus, bothSideParticipants },
|
|
16092
|
+
result: { error: INVALID_MATCHUP_STATUS }
|
|
16107
16093
|
});
|
|
16108
16094
|
}
|
|
16109
16095
|
const appliedPolicies = getAppliedPolicies({
|
|
@@ -16226,8 +16212,8 @@ function winningSideWithDownstreamDependencies(params) {
|
|
|
16226
16212
|
return applyMatchUpValues(params);
|
|
16227
16213
|
} else {
|
|
16228
16214
|
return decorateResult({
|
|
16229
|
-
result: { error: CANNOT_CHANGE_WINNING_SIDE },
|
|
16230
16215
|
stack: "winningSideWithDownstreamDependencies",
|
|
16216
|
+
result: { error: CANNOT_CHANGE_WINNING_SIDE },
|
|
16231
16217
|
context: { winningSide, matchUp }
|
|
16232
16218
|
});
|
|
16233
16219
|
}
|