tods-competition-factory 1.8.3 → 1.8.5
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 +322 -51
- package/dist/forge/generate.mjs.map +1 -1
- package/dist/forge/query.d.ts +2 -1
- package/dist/forge/query.mjs +42 -23
- package/dist/forge/query.mjs.map +1 -1
- package/dist/forge/transform.mjs +282 -28
- package/dist/forge/transform.mjs.map +1 -1
- package/dist/forge/utilities.mjs +175 -0
- package/dist/forge/utilities.mjs.map +1 -1
- package/dist/index.mjs +553 -379
- package/dist/index.mjs.map +1 -1
- package/dist/tods-competition-factory.development.cjs.js +633 -444
- 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 +5 -5
package/dist/forge/query.d.ts
CHANGED
|
@@ -1634,8 +1634,9 @@ declare function isValid(matchUpFormat: string): boolean;
|
|
|
1634
1634
|
type ParsedFormat = {
|
|
1635
1635
|
finalSetFormat?: any;
|
|
1636
1636
|
simplified?: boolean;
|
|
1637
|
+
exactly?: number;
|
|
1637
1638
|
setFormat?: any;
|
|
1638
|
-
bestOf
|
|
1639
|
+
bestOf?: number;
|
|
1639
1640
|
};
|
|
1640
1641
|
declare function parse(matchUpFormatCode: string): ParsedFormat | undefined;
|
|
1641
1642
|
|
package/dist/forge/query.mjs
CHANGED
|
@@ -498,6 +498,9 @@ function addNotice(notice) {
|
|
|
498
498
|
function getTournamentId() {
|
|
499
499
|
return _globalStateProvider.getTournamentId();
|
|
500
500
|
}
|
|
501
|
+
function getProvider() {
|
|
502
|
+
return _globalStateProvider;
|
|
503
|
+
}
|
|
501
504
|
|
|
502
505
|
const validDateString = /^[\d]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][\d]|3[0-1])$/;
|
|
503
506
|
const validTimeString = /^((0[\d]|1[\d]|2[0-3]):[0-5][\d](:[0-5][\d])?)([.,][0-9]{3})?$/;
|
|
@@ -629,6 +632,13 @@ function sameDay(date1, date2) {
|
|
|
629
632
|
}
|
|
630
633
|
|
|
631
634
|
function makeDeepCopy(sourceObject, convertExtensions, internalUse, removeExtensions, iteration = 0) {
|
|
635
|
+
if (getProvider().makeDeepCopy)
|
|
636
|
+
return getProvider().makeDeepCopy(
|
|
637
|
+
sourceObject,
|
|
638
|
+
convertExtensions,
|
|
639
|
+
internalUse,
|
|
640
|
+
removeExtensions
|
|
641
|
+
);
|
|
632
642
|
const deepCopy = deepCopyEnabled();
|
|
633
643
|
const { stringify, toJSON, ignore, modulate } = deepCopy || {};
|
|
634
644
|
if (!deepCopy?.enabled && !internalUse || typeof sourceObject !== "object" || typeof sourceObject === "function" || sourceObject === null || typeof deepCopy?.threshold === "number" && iteration >= deepCopy.threshold) {
|
|
@@ -4548,10 +4558,10 @@ function addUpcomingMatchUps({ drawDefinition, inContextDrawMatchUps }) {
|
|
|
4548
4558
|
if (structure?.finishingPosition === WIN_RATIO$1) {
|
|
4549
4559
|
const { roundNumber } = inContextMatchUp;
|
|
4550
4560
|
const nextRoundNumber = roundNumber && ensureInt(roundNumber) + 1;
|
|
4551
|
-
const matchUps = structure.matchUps
|
|
4561
|
+
const matchUps = structure.matchUps ?? [];
|
|
4552
4562
|
const { roundMatchUps } = getRoundMatchUps({ matchUps });
|
|
4553
4563
|
if (nextRoundNumber && roundMatchUps?.[nextRoundNumber]) {
|
|
4554
|
-
const sidesTo = drawPositions.sort().map((drawPosition, index) => {
|
|
4564
|
+
const sidesTo = [...drawPositions].sort(numericSort).map((drawPosition, index) => {
|
|
4555
4565
|
const nextRoundMatchUp = roundMatchUps[nextRoundNumber].find(
|
|
4556
4566
|
(matchUp) => matchUp.drawPositions?.includes(drawPosition)
|
|
4557
4567
|
);
|
|
@@ -6127,7 +6137,7 @@ function parse(matchUpFormatCode) {
|
|
|
6127
6137
|
setFormat,
|
|
6128
6138
|
bestOf: 1
|
|
6129
6139
|
};
|
|
6130
|
-
if (
|
|
6140
|
+
if (setFormat)
|
|
6131
6141
|
return parsedFormat;
|
|
6132
6142
|
}
|
|
6133
6143
|
if (type === SET)
|
|
@@ -6137,16 +6147,23 @@ function parse(matchUpFormatCode) {
|
|
|
6137
6147
|
}
|
|
6138
6148
|
function setsMatch(formatstring) {
|
|
6139
6149
|
const parts = formatstring.split("-");
|
|
6140
|
-
const
|
|
6150
|
+
const setsCount = getNumber$1(parts[0].slice(3));
|
|
6151
|
+
const bestOf = setsCount === 1 || setsCount % 2 !== 0 ? setsCount : void 0;
|
|
6152
|
+
const exactly = setsCount !== 1 && setsCount % 2 === 0 ? setsCount : void 0;
|
|
6141
6153
|
const setFormat = parts && parseSetFormat(parts[1]);
|
|
6142
6154
|
const finalSetFormat = parts && parseSetFormat(parts[2]);
|
|
6143
|
-
const
|
|
6155
|
+
const timed = setFormat && setFormat.timed || finalSetFormat && finalSetFormat.timed;
|
|
6156
|
+
const validSetsCount = bestOf && bestOf < 6 || timed && exactly;
|
|
6144
6157
|
const validFinalSet = !parts[2] || finalSetFormat;
|
|
6145
6158
|
const validSetsFormat = setFormat;
|
|
6146
|
-
const result = {
|
|
6159
|
+
const result = definedAttributes({
|
|
6160
|
+
setFormat,
|
|
6161
|
+
exactly,
|
|
6162
|
+
bestOf
|
|
6163
|
+
});
|
|
6147
6164
|
if (finalSetFormat)
|
|
6148
6165
|
result.finalSetFormat = finalSetFormat;
|
|
6149
|
-
if (
|
|
6166
|
+
if (validSetsCount && validSetsFormat && validFinalSet)
|
|
6150
6167
|
return result;
|
|
6151
6168
|
}
|
|
6152
6169
|
function parseSetFormat(formatstring) {
|
|
@@ -6436,10 +6453,10 @@ function getOrderedDrawPositions({
|
|
|
6436
6453
|
const pairedDrawPositions = targetRoundProfile?.pairedDrawPositions;
|
|
6437
6454
|
const displayOrder = pairedDrawPositions?.find(
|
|
6438
6455
|
(pair) => overlap(pair || [], drawPositions.filter(Boolean))
|
|
6439
|
-
)
|
|
6456
|
+
) ?? unassignedDrawPositions;
|
|
6440
6457
|
const isFeedRound = targetRoundProfile?.feedRound;
|
|
6441
6458
|
if (allNumeric(drawPositions)) {
|
|
6442
|
-
const orderedDrawPositions = drawPositions.sort(numericSort);
|
|
6459
|
+
const orderedDrawPositions = [...drawPositions].sort(numericSort);
|
|
6443
6460
|
return {
|
|
6444
6461
|
orderedDrawPositions: orderedDrawPositions.length === 2 ? orderedDrawPositions : displayOrder,
|
|
6445
6462
|
displayOrder: isFeedRound ? orderedDrawPositions : displayOrder
|
|
@@ -7163,7 +7180,7 @@ function getAllStructureMatchUps({
|
|
|
7163
7180
|
matchUp,
|
|
7164
7181
|
event: event2
|
|
7165
7182
|
}) {
|
|
7166
|
-
additionalContext = additionalContext
|
|
7183
|
+
additionalContext = additionalContext ?? {};
|
|
7167
7184
|
const tieFormat = resolveTieFormat({
|
|
7168
7185
|
drawDefinition,
|
|
7169
7186
|
structure,
|
|
@@ -7174,7 +7191,7 @@ function getAllStructureMatchUps({
|
|
|
7174
7191
|
const collectionDefinition = matchUp.collectionId && collectionDefinitions?.find(
|
|
7175
7192
|
(definition) => definition.collectionId === matchUp.collectionId
|
|
7176
7193
|
);
|
|
7177
|
-
const matchUpFormat = matchUp.collectionId ? collectionDefinition?.matchUpFormat : matchUp.matchUpFormat
|
|
7194
|
+
const matchUpFormat = matchUp.collectionId ? collectionDefinition?.matchUpFormat : matchUp.matchUpFormat ?? structure?.matchUpFormat ?? drawDefinition?.matchUpFormat ?? event2?.matchUpFormat;
|
|
7178
7195
|
const matchUpType = matchUp.matchUpType || collectionDefinition?.matchUpType || structure?.matchUpType || drawDefinition?.matchUpType || event2?.eventType !== TEAM && event2?.eventType;
|
|
7179
7196
|
const matchUpStatus = isCollectionBye ? BYE : matchUp.matchUpStatus;
|
|
7180
7197
|
const { schedule, endDate } = getMatchUpScheduleDetails({
|
|
@@ -7189,7 +7206,7 @@ function getAllStructureMatchUps({
|
|
|
7189
7206
|
});
|
|
7190
7207
|
const drawPositions = tieDrawPositions ?? matchUp.drawPositions ?? [];
|
|
7191
7208
|
const { collectionPosition, collectionId, roundPosition } = matchUp;
|
|
7192
|
-
const roundNumber = matchUp.roundNumber
|
|
7209
|
+
const roundNumber = matchUp.roundNumber ?? additionalContext.roundNumber;
|
|
7193
7210
|
const drawPositionCollectionAssignment = collectionId ? getDrawPositionCollectionAssignment({
|
|
7194
7211
|
tournamentParticipants,
|
|
7195
7212
|
positionAssignments,
|
|
@@ -7215,7 +7232,7 @@ function getAllStructureMatchUps({
|
|
|
7215
7232
|
} : context?.category;
|
|
7216
7233
|
const processCodes = matchUp.processCodes?.length && matchUp.processCodes || collectionDefinition?.processCodes?.length && collectionDefinition?.processCodes || structure?.processCodes?.length && structure?.processCodes || drawDefinition?.processCodes?.length && drawDefinition?.processCodes || event2?.processCodes?.length && event2?.processCodes || tournamentRecord?.processCodes;
|
|
7217
7234
|
const competitiveProfile = contextProfile?.withCompetitiveness && getMatchUpCompetitiveProfile({ ...contextContent, matchUp });
|
|
7218
|
-
const finishingPositionRange = matchUp.finishingPositionRange
|
|
7235
|
+
const finishingPositionRange = matchUp.finishingPositionRange ?? additionalContext.finishingPositionRange;
|
|
7219
7236
|
const onlyDefined = (obj) => definedAttributes(obj, void 0, true);
|
|
7220
7237
|
const matchUpWithContext = {
|
|
7221
7238
|
...onlyDefined(context),
|
|
@@ -7223,7 +7240,7 @@ function getAllStructureMatchUps({
|
|
|
7223
7240
|
matchUpFormat: matchUp.matchUpType === TEAM ? void 0 : matchUpFormat,
|
|
7224
7241
|
tieFormat: matchUp.matchUpType !== TEAM ? void 0 : tieFormat,
|
|
7225
7242
|
roundOfPlay: stage !== QUALIFYING && isConvertableInteger(initialRoundOfPlay2) && initialRoundOfPlay2 + (roundNumber || 0),
|
|
7226
|
-
endDate: matchUp.endDate
|
|
7243
|
+
endDate: matchUp.endDate ?? endDate,
|
|
7227
7244
|
gender: collectionDefinition?.gender,
|
|
7228
7245
|
discipline: event2?.discipline,
|
|
7229
7246
|
category: matchUpCategory,
|
|
@@ -8328,9 +8345,7 @@ function getEligibleVoluntaryConsolationParticipants({
|
|
|
8328
8345
|
function stringify(matchUpFormatObject, preserveRedundant) {
|
|
8329
8346
|
if (typeof matchUpFormatObject !== "object")
|
|
8330
8347
|
return;
|
|
8331
|
-
if (matchUpFormatObject.
|
|
8332
|
-
return timedSetFormat(matchUpFormatObject);
|
|
8333
|
-
if (matchUpFormatObject.bestOf && matchUpFormatObject.setFormat)
|
|
8348
|
+
if ((matchUpFormatObject.bestOf || matchUpFormatObject.exactly) && matchUpFormatObject.setFormat)
|
|
8334
8349
|
return getSetFormat(matchUpFormatObject, preserveRedundant);
|
|
8335
8350
|
return void 0;
|
|
8336
8351
|
}
|
|
@@ -8346,11 +8361,13 @@ function timedSetFormat(matchUpFormatObject) {
|
|
|
8346
8361
|
return value;
|
|
8347
8362
|
}
|
|
8348
8363
|
function getSetFormat(matchUpFormatObject, preserveRedundant) {
|
|
8349
|
-
const bestOfValue = getNumber(matchUpFormatObject.bestOf);
|
|
8350
|
-
|
|
8364
|
+
const bestOfValue = getNumber(matchUpFormatObject.bestOf) || void 0;
|
|
8365
|
+
const exactly = getNumber(matchUpFormatObject.exactly) || void 0;
|
|
8366
|
+
const setLimit = bestOfValue || exactly;
|
|
8367
|
+
if (matchUpFormatObject.setFormat?.timed && matchUpFormatObject.simplified && setLimit === 1) {
|
|
8351
8368
|
return timedSetFormat(matchUpFormatObject.setFormat);
|
|
8352
8369
|
}
|
|
8353
|
-
const
|
|
8370
|
+
const setLimitCode = setLimit && `${SET}${setLimit}` || "";
|
|
8354
8371
|
const setCountValue = stringifySet(
|
|
8355
8372
|
matchUpFormatObject.setFormat,
|
|
8356
8373
|
preserveRedundant
|
|
@@ -8360,11 +8377,11 @@ function getSetFormat(matchUpFormatObject, preserveRedundant) {
|
|
|
8360
8377
|
matchUpFormatObject.finalSetFormat,
|
|
8361
8378
|
preserveRedundant
|
|
8362
8379
|
);
|
|
8363
|
-
const finalSetCode =
|
|
8380
|
+
const finalSetCode = setLimit && setLimit > 1 && finalSetCountValue && setCountValue !== finalSetCountValue && // don't include final set code if equivalent to other sets
|
|
8364
8381
|
`F:${finalSetCountValue}` || "";
|
|
8365
|
-
const valid =
|
|
8382
|
+
const valid = setLimitCode && setCountValue;
|
|
8366
8383
|
if (valid) {
|
|
8367
|
-
return [
|
|
8384
|
+
return [setLimitCode, setCode, finalSetCode].filter((f) => f).join("-");
|
|
8368
8385
|
}
|
|
8369
8386
|
return void 0;
|
|
8370
8387
|
}
|
|
@@ -9205,6 +9222,8 @@ const POLICY_MATCHUP_ACTIONS_DEFAULT = {
|
|
|
9205
9222
|
}
|
|
9206
9223
|
],
|
|
9207
9224
|
participants: {
|
|
9225
|
+
enforceCategory: true,
|
|
9226
|
+
// validate collectionDefinition.category against event.category
|
|
9208
9227
|
enforceGender: true
|
|
9209
9228
|
// disallow placing FEMALEs in MALE events and vice versa
|
|
9210
9229
|
},
|