tods-competition-factory 1.7.14 → 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 +52 -73
- package/dist/forge/generate.mjs.map +1 -1
- package/dist/forge/query.d.ts +2 -2
- package/dist/forge/query.mjs +9 -13
- package/dist/forge/query.mjs.map +1 -1
- package/dist/forge/transform.mjs +58 -73
- package/dist/forge/transform.mjs.map +1 -1
- package/dist/index.mjs +107 -126
- package/dist/index.mjs.map +1 -1
- package/dist/tods-competition-factory.development.cjs.js +157 -172
- 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/forge/generate.mjs
CHANGED
|
@@ -1864,19 +1864,15 @@ function findEvent({
|
|
|
1864
1864
|
}) {
|
|
1865
1865
|
const stack = "findEvent";
|
|
1866
1866
|
if (!tournamentRecord)
|
|
1867
|
-
return {
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
stack
|
|
1873
|
-
})
|
|
1874
|
-
};
|
|
1875
|
-
const events = tournamentRecord?.events || [];
|
|
1867
|
+
return decorateResult({
|
|
1868
|
+
result: { error: MISSING_TOURNAMENT_RECORD },
|
|
1869
|
+
stack
|
|
1870
|
+
});
|
|
1871
|
+
const events = tournamentRecord?.events ?? [];
|
|
1876
1872
|
if (drawId) {
|
|
1877
1873
|
let drawDefinition;
|
|
1878
1874
|
const event = events.find((event2) => {
|
|
1879
|
-
const drawDefinitions = event2?.drawDefinitions
|
|
1875
|
+
const drawDefinitions = event2?.drawDefinitions ?? [];
|
|
1880
1876
|
const targetDrawDefinition = drawDefinitions.find(
|
|
1881
1877
|
(drawDefinition2) => drawDefinition2.drawId === drawId
|
|
1882
1878
|
);
|
|
@@ -1935,7 +1931,7 @@ function addExtension(params) {
|
|
|
1935
1931
|
});
|
|
1936
1932
|
if (!params.element.extensions)
|
|
1937
1933
|
params.element.extensions = [];
|
|
1938
|
-
const creationTime = params
|
|
1934
|
+
const creationTime = params?.creationTime ?? true;
|
|
1939
1935
|
if (creationTime) {
|
|
1940
1936
|
const createdAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
1941
1937
|
Object.assign(params.extension, { createdAt });
|
|
@@ -2140,7 +2136,7 @@ function findCourt({
|
|
|
2140
2136
|
} else if (tournamentRecords) {
|
|
2141
2137
|
const linkedTournamentIds = getLinkedTournamentIds({
|
|
2142
2138
|
tournamentRecords
|
|
2143
|
-
}).linkedTournamentIds
|
|
2139
|
+
}).linkedTournamentIds ?? [];
|
|
2144
2140
|
const relevantIds = linkedTournamentIds[tournamentRecord.tournamentId];
|
|
2145
2141
|
for (const tournamentId of relevantIds) {
|
|
2146
2142
|
const record = tournamentRecords[tournamentId];
|
|
@@ -5352,8 +5348,8 @@ function getSeedGroups({
|
|
|
5352
5348
|
return {
|
|
5353
5349
|
seedGroups: void 0,
|
|
5354
5350
|
...decorateResult({
|
|
5355
|
-
result: { error: INVALID_VALUES },
|
|
5356
5351
|
context: { roundRobinGroupsCount },
|
|
5352
|
+
result: { error: INVALID_VALUES },
|
|
5357
5353
|
stack
|
|
5358
5354
|
})
|
|
5359
5355
|
};
|
|
@@ -11006,9 +11002,7 @@ function assignMatchUpDrawPosition({
|
|
|
11006
11002
|
return { ...SUCCESS };
|
|
11007
11003
|
} else {
|
|
11008
11004
|
return decorateResult({
|
|
11009
|
-
result: {
|
|
11010
|
-
error: DRAW_POSITION_ASSIGNED
|
|
11011
|
-
},
|
|
11005
|
+
result: { error: DRAW_POSITION_ASSIGNED },
|
|
11012
11006
|
context: { drawPosition },
|
|
11013
11007
|
stack
|
|
11014
11008
|
});
|
|
@@ -11347,7 +11341,7 @@ function removeSubsequentRoundsParticipant({
|
|
|
11347
11341
|
const positionAssignments = getPositionAssignments({
|
|
11348
11342
|
drawDefinition,
|
|
11349
11343
|
structureId
|
|
11350
|
-
}).positionAssignments
|
|
11344
|
+
}).positionAssignments ?? [];
|
|
11351
11345
|
relevantMatchUps?.forEach(
|
|
11352
11346
|
(matchUp) => removeDrawPosition({
|
|
11353
11347
|
drawPosition: targetDrawPosition,
|
|
@@ -11377,7 +11371,7 @@ function removeDrawPosition({
|
|
|
11377
11371
|
const initialDrawPositions = targetMatchUp.drawPositions?.slice();
|
|
11378
11372
|
const initialMatchUpStatus = targetMatchUp.matchUpStatus;
|
|
11379
11373
|
const initialWinningSide = targetMatchUp.winningSide;
|
|
11380
|
-
matchUpsMap = matchUpsMap
|
|
11374
|
+
matchUpsMap = matchUpsMap ?? getMatchUpsMap({ drawDefinition });
|
|
11381
11375
|
const mappedMatchUps = matchUpsMap.mappedMatchUps;
|
|
11382
11376
|
const matchUps = mappedMatchUps[structure.structureId].matchUps;
|
|
11383
11377
|
const { initialRoundNumber } = getInitialRoundNumber({
|
|
@@ -11385,7 +11379,7 @@ function removeDrawPosition({
|
|
|
11385
11379
|
matchUps
|
|
11386
11380
|
});
|
|
11387
11381
|
if (targetMatchUp.roundNumber && initialRoundNumber && targetMatchUp.roundNumber > initialRoundNumber) {
|
|
11388
|
-
const drawPositions = (targetMatchUp.drawPositions
|
|
11382
|
+
const drawPositions = (targetMatchUp.drawPositions ?? []).map(
|
|
11389
11383
|
(currentDrawPosition) => currentDrawPosition === drawPosition ? void 0 : currentDrawPosition
|
|
11390
11384
|
);
|
|
11391
11385
|
targetMatchUp.drawPositions = drawPositions;
|
|
@@ -11394,7 +11388,7 @@ function removeDrawPosition({
|
|
|
11394
11388
|
const inContextTargetMatchUp = inContextDrawMatchUps?.find(
|
|
11395
11389
|
(matchUp) => matchUp.matchUpId === targetMatchUp.matchUpId
|
|
11396
11390
|
);
|
|
11397
|
-
const sides = inContextTargetMatchUp?.sides
|
|
11391
|
+
const sides = inContextTargetMatchUp?.sides ?? [];
|
|
11398
11392
|
const drawPositionSideIndex = sides.reduce(
|
|
11399
11393
|
(index, side, i) => side.drawPosition === drawPosition ? i : index,
|
|
11400
11394
|
void 0
|
|
@@ -12823,11 +12817,7 @@ function positionByes({
|
|
|
12823
12817
|
}
|
|
12824
12818
|
|
|
12825
12819
|
function positionQualifiers(params) {
|
|
12826
|
-
|
|
12827
|
-
if (!structure)
|
|
12828
|
-
({ structure } = findStructure(params));
|
|
12829
|
-
if (!structureId)
|
|
12830
|
-
({ structureId } = structure);
|
|
12820
|
+
const structure = params.structure ?? findStructure(params).structure;
|
|
12831
12821
|
const stack = "positionQualifiers";
|
|
12832
12822
|
const qualifierDrawPositions = [];
|
|
12833
12823
|
if (structure.stage === CONSOLATION) {
|
|
@@ -16363,31 +16353,25 @@ function validateTieFormat(params) {
|
|
|
16363
16353
|
if (!params || !tieFormat || typeof tieFormat !== "object") {
|
|
16364
16354
|
errors.push("tieFormat must be an object");
|
|
16365
16355
|
return decorateResult({
|
|
16366
|
-
result: {
|
|
16367
|
-
|
|
16368
|
-
|
|
16369
|
-
stack
|
|
16370
|
-
}
|
|
16356
|
+
result: { error: INVALID_TIE_FORMAT },
|
|
16357
|
+
context: { tieFormat, errors },
|
|
16358
|
+
stack
|
|
16371
16359
|
});
|
|
16372
16360
|
}
|
|
16373
16361
|
if (typeof tieFormat.winCriteria !== "object") {
|
|
16374
16362
|
errors.push("tieFormat.winCriteria must be an object");
|
|
16375
16363
|
return decorateResult({
|
|
16376
|
-
result: {
|
|
16377
|
-
|
|
16378
|
-
|
|
16379
|
-
stack
|
|
16380
|
-
}
|
|
16364
|
+
result: { error: INVALID_TIE_FORMAT },
|
|
16365
|
+
context: { tieFormat, errors },
|
|
16366
|
+
stack
|
|
16381
16367
|
});
|
|
16382
16368
|
}
|
|
16383
16369
|
if (!Array.isArray(tieFormat.collectionDefinitions)) {
|
|
16384
16370
|
errors.push(mustBeAnArray("tieFormat.collectionDefinitions"));
|
|
16385
16371
|
return decorateResult({
|
|
16386
|
-
result: {
|
|
16387
|
-
|
|
16388
|
-
|
|
16389
|
-
stack
|
|
16390
|
-
}
|
|
16372
|
+
result: { error: INVALID_TIE_FORMAT },
|
|
16373
|
+
context: { tieFormat, errors },
|
|
16374
|
+
stack
|
|
16391
16375
|
});
|
|
16392
16376
|
}
|
|
16393
16377
|
let aggregateValueImperative;
|
|
@@ -16420,11 +16404,9 @@ function validateTieFormat(params) {
|
|
|
16420
16404
|
);
|
|
16421
16405
|
}
|
|
16422
16406
|
return decorateResult({
|
|
16423
|
-
|
|
16424
|
-
|
|
16425
|
-
|
|
16426
|
-
stack
|
|
16427
|
-
}
|
|
16407
|
+
context: { tieFormat, errors, aggregateValueImperative },
|
|
16408
|
+
result: { error: INVALID_TIE_FORMAT },
|
|
16409
|
+
stack
|
|
16428
16410
|
});
|
|
16429
16411
|
}
|
|
16430
16412
|
const collectionIds = tieFormat.collectionDefinitions.map(
|
|
@@ -16435,11 +16417,9 @@ function validateTieFormat(params) {
|
|
|
16435
16417
|
const result = { valid, errors };
|
|
16436
16418
|
if (!valid) {
|
|
16437
16419
|
return decorateResult({
|
|
16438
|
-
result: {
|
|
16439
|
-
|
|
16440
|
-
|
|
16441
|
-
stack
|
|
16442
|
-
}
|
|
16420
|
+
result: { error: INVALID_TIE_FORMAT },
|
|
16421
|
+
context: { tieFormat, errors },
|
|
16422
|
+
stack
|
|
16443
16423
|
});
|
|
16444
16424
|
}
|
|
16445
16425
|
return result;
|
|
@@ -17199,7 +17179,8 @@ function directLoser(params) {
|
|
|
17199
17179
|
if (result.error)
|
|
17200
17180
|
return decorateResult({ result, stack });
|
|
17201
17181
|
} else if (loserParticipantId && isFeedRound) {
|
|
17202
|
-
|
|
17182
|
+
unfilledTargetMatchUpDrawPositions.sort(numericSort);
|
|
17183
|
+
const fedDrawPosition = unfilledTargetMatchUpDrawPositions[0];
|
|
17203
17184
|
const result = assignDrawPosition({
|
|
17204
17185
|
participantId: loserParticipantId,
|
|
17205
17186
|
structureId: targetStructureId,
|
|
@@ -17464,7 +17445,7 @@ function generateAndPopulatePlayoffStructures(params) {
|
|
|
17464
17445
|
drawDefinition
|
|
17465
17446
|
});
|
|
17466
17447
|
if (!structure)
|
|
17467
|
-
return decorateResult({ result: { error: STRUCTURE_NOT_FOUND } });
|
|
17448
|
+
return decorateResult({ result: { error: STRUCTURE_NOT_FOUND }, stack });
|
|
17468
17449
|
if (structure.structureType === CONTAINER || structure.structures) {
|
|
17469
17450
|
return generateAndPopulateRRplayoffStructures({
|
|
17470
17451
|
sourceStructureId: structure.structureId,
|
|
@@ -19014,10 +18995,8 @@ function addParticipant({
|
|
|
19014
18995
|
});
|
|
19015
18996
|
} else if (participant.individualParticipantIds.length !== 2 && !pairOverride) {
|
|
19016
18997
|
return decorateResult({
|
|
19017
|
-
|
|
19018
|
-
|
|
19019
|
-
info: "PAIR must be 2 individualParticipantIds"
|
|
19020
|
-
},
|
|
18998
|
+
info: "PAIR must be 2 individualParticipantIds",
|
|
18999
|
+
result: { error: INVALID_PARTICIPANT_IDS },
|
|
19021
19000
|
stack
|
|
19022
19001
|
});
|
|
19023
19002
|
} else {
|
|
@@ -20933,14 +20912,14 @@ function addDrawDefinition(params) {
|
|
|
20933
20912
|
if (relevantFlight && !drawEntriesPresentInFlight) {
|
|
20934
20913
|
return decorateResult({
|
|
20935
20914
|
result: {
|
|
20936
|
-
error: INVALID_DRAW_DEFINITION
|
|
20937
|
-
|
|
20938
|
-
|
|
20939
|
-
|
|
20940
|
-
|
|
20941
|
-
|
|
20942
|
-
|
|
20943
|
-
|
|
20915
|
+
error: INVALID_DRAW_DEFINITION
|
|
20916
|
+
},
|
|
20917
|
+
context: {
|
|
20918
|
+
drawEntriesPresentInFlight,
|
|
20919
|
+
matchingEventEntries,
|
|
20920
|
+
relevantFlight
|
|
20921
|
+
},
|
|
20922
|
+
info: "Draw entries are not present in flight or do not match entryStatuses"
|
|
20944
20923
|
});
|
|
20945
20924
|
}
|
|
20946
20925
|
if (modifyEventEntries) {
|
|
@@ -20959,9 +20938,9 @@ function addDrawDefinition(params) {
|
|
|
20959
20938
|
if (eventEntries && !matchingEventEntries)
|
|
20960
20939
|
return decorateResult({
|
|
20961
20940
|
result: {
|
|
20962
|
-
|
|
20941
|
+
info: "Draw entries do not match event entryStatuses",
|
|
20963
20942
|
context: { matchingEventEntries, eventEntries },
|
|
20964
|
-
|
|
20943
|
+
error: INVALID_DRAW_DEFINITION
|
|
20965
20944
|
}
|
|
20966
20945
|
});
|
|
20967
20946
|
const flightNumbers = flightProfile?.flights?.map(
|
|
@@ -22574,6 +22553,7 @@ function getScaledEntries({
|
|
|
22574
22553
|
}
|
|
22575
22554
|
|
|
22576
22555
|
function prepareStage(params) {
|
|
22556
|
+
const stack = "prepareStage";
|
|
22577
22557
|
let { seedsCount } = params;
|
|
22578
22558
|
const preparedStructureIds = params.preparedStructureIds || [];
|
|
22579
22559
|
const {
|
|
@@ -22629,7 +22609,7 @@ function prepareStage(params) {
|
|
|
22629
22609
|
({ structureId: structureId2 }) => !preparedStructureIds.includes(structureId2)
|
|
22630
22610
|
);
|
|
22631
22611
|
if (!structure)
|
|
22632
|
-
return decorateResult({ result: { error: STRUCTURE_NOT_FOUND } });
|
|
22612
|
+
return decorateResult({ result: { error: STRUCTURE_NOT_FOUND }, stack });
|
|
22633
22613
|
const structureId = structure?.structureId;
|
|
22634
22614
|
const seedBlockInfo = structure ? getValidSeedBlocks({
|
|
22635
22615
|
provisionalPositioning,
|
|
@@ -22752,7 +22732,7 @@ function prepareStage(params) {
|
|
|
22752
22732
|
positionAssignments = result?.positionAssignments;
|
|
22753
22733
|
positioningReport = result?.positioningReport;
|
|
22754
22734
|
if (result.error) {
|
|
22755
|
-
return decorateResult({ result, stack
|
|
22735
|
+
return decorateResult({ result, stack });
|
|
22756
22736
|
}
|
|
22757
22737
|
}
|
|
22758
22738
|
return {
|
|
@@ -23035,10 +23015,8 @@ function generateDrawDefinition(params) {
|
|
|
23035
23015
|
if (policyDefinitions) {
|
|
23036
23016
|
if (typeof policyDefinitions !== "object") {
|
|
23037
23017
|
return decorateResult({
|
|
23038
|
-
|
|
23039
|
-
|
|
23040
|
-
error: INVALID_VALUES
|
|
23041
|
-
},
|
|
23018
|
+
info: "policyDefinitions must be an object",
|
|
23019
|
+
result: { error: INVALID_VALUES },
|
|
23042
23020
|
stack
|
|
23043
23021
|
});
|
|
23044
23022
|
} else {
|
|
@@ -23267,8 +23245,9 @@ function generateDrawDefinition(params) {
|
|
|
23267
23245
|
for (const roundTargetProfile of params.qualifyingProfiles) {
|
|
23268
23246
|
if (!Array.isArray(roundTargetProfile.structureProfiles))
|
|
23269
23247
|
return decorateResult({
|
|
23248
|
+
info: mustBeAnArray("structureProfiles"),
|
|
23270
23249
|
result: { error: MISSING_VALUE },
|
|
23271
|
-
|
|
23250
|
+
stack
|
|
23272
23251
|
});
|
|
23273
23252
|
roundTarget = roundTargetProfile.roundTarget || roundTarget;
|
|
23274
23253
|
const sortedStructureProfiles = roundTargetProfile.structureProfiles?.sort(sequenceSort) || [];
|