tods-competition-factory 1.6.23 → 1.6.24
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 +3 -1
- package/dist/forge/generate.mjs +2 -2
- package/dist/forge/generate.mjs.map +1 -1
- package/dist/forge/query.d.ts +3 -1
- package/dist/forge/query.mjs.map +1 -1
- package/dist/forge/transform.d.ts +3 -1
- package/dist/forge/transform.mjs.map +1 -1
- package/dist/forge/utilities.mjs.map +1 -1
- package/dist/index.mjs +64 -21
- package/dist/index.mjs.map +1 -1
- package/dist/tods-competition-factory.development.cjs.js +98 -42
- 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/index.mjs
CHANGED
|
@@ -329,7 +329,7 @@ const matchUpFormatCode = {
|
|
|
329
329
|
};
|
|
330
330
|
|
|
331
331
|
function factoryVersion() {
|
|
332
|
-
return "1.6.
|
|
332
|
+
return "1.6.24";
|
|
333
333
|
}
|
|
334
334
|
|
|
335
335
|
function getObjectTieFormat(obj) {
|
|
@@ -402,6 +402,9 @@ function unique(arr) {
|
|
|
402
402
|
function shuffleArray(arr) {
|
|
403
403
|
return arr.map((a) => [Math.random(), a]).sort((a, b) => a[0] - b[0]).map((a) => a[1]);
|
|
404
404
|
}
|
|
405
|
+
function numericSortValue(v) {
|
|
406
|
+
return isConvertableInteger(v) ? v : Infinity;
|
|
407
|
+
}
|
|
405
408
|
function instanceCount(values) {
|
|
406
409
|
return values.reduce((a, c) => {
|
|
407
410
|
if (!a[c])
|
|
@@ -3700,6 +3703,7 @@ const POLICY_TYPE_PARTICIPANT = "participant";
|
|
|
3700
3703
|
const POLICY_TYPE_PROGRESSION = "progression";
|
|
3701
3704
|
const POLICY_TYPE_SCHEDULING = "scheduling";
|
|
3702
3705
|
const POLICY_TYPE_AVOIDANCE = "avoidance";
|
|
3706
|
+
const POLICY_TYPE_DISPLAY = "display";
|
|
3703
3707
|
const POLICY_TYPE_SCORING = "scoring";
|
|
3704
3708
|
const POLICY_TYPE_SEEDING = "seeding";
|
|
3705
3709
|
const POLICY_TYPE_FEED_IN = "feedIn";
|
|
@@ -3717,6 +3721,7 @@ const policyConstants = {
|
|
|
3717
3721
|
POLICY_TYPE_PROGRESSION,
|
|
3718
3722
|
POLICY_TYPE_SCHEDULING,
|
|
3719
3723
|
POLICY_TYPE_AVOIDANCE,
|
|
3724
|
+
POLICY_TYPE_DISPLAY,
|
|
3720
3725
|
POLICY_TYPE_FEED_IN,
|
|
3721
3726
|
POLICY_TYPE_SCORING,
|
|
3722
3727
|
POLICY_TYPE_SEEDING,
|
|
@@ -36250,7 +36255,7 @@ function modifyVenue$1({
|
|
|
36250
36255
|
venue && validReplacementAttributes.forEach(
|
|
36251
36256
|
(attribute) => Object.assign(venue, { [attribute]: modifications[attribute] })
|
|
36252
36257
|
);
|
|
36253
|
-
const existingCourtIds = venue?.courts?.map((court) => court.courtId)
|
|
36258
|
+
const existingCourtIds = venue?.courts?.map((court) => court.courtId) ?? [];
|
|
36254
36259
|
const courtIdsToModify = modifications.courts?.map((court) => court.courtId) || [];
|
|
36255
36260
|
const courtIdsToDelete = existingCourtIds.filter(
|
|
36256
36261
|
(courtId) => !courtIdsToModify.includes(courtId)
|
|
@@ -36265,7 +36270,7 @@ function modifyVenue$1({
|
|
|
36265
36270
|
tournamentRecord,
|
|
36266
36271
|
venueMatchUps
|
|
36267
36272
|
});
|
|
36268
|
-
return result2.matchUps?.length
|
|
36273
|
+
return result2.matchUps?.length ?? 0;
|
|
36269
36274
|
}).reduce((a, b) => a + b);
|
|
36270
36275
|
if (venue && (!scheduleDeletionsCount || force)) {
|
|
36271
36276
|
venue.courts = venue.courts?.filter(
|
|
@@ -42341,6 +42346,27 @@ function deleteAdHocMatchUps$1({
|
|
|
42341
42346
|
return { ...SUCCESS };
|
|
42342
42347
|
}
|
|
42343
42348
|
|
|
42349
|
+
function setStructureOrder({ drawDefinition, orderMap }) {
|
|
42350
|
+
if (!drawDefinition)
|
|
42351
|
+
return { error: MISSING_DRAW_DEFINITION };
|
|
42352
|
+
if (typeof orderMap !== "object" || !Object.values(orderMap).every((val) => isConvertableInteger(val)))
|
|
42353
|
+
decorateResult({
|
|
42354
|
+
result: { error: INVALID_VALUES },
|
|
42355
|
+
context: { orderMap }
|
|
42356
|
+
});
|
|
42357
|
+
if (!drawDefinition.structures)
|
|
42358
|
+
drawDefinition.structures = [];
|
|
42359
|
+
drawDefinition.structures.forEach((structure) => {
|
|
42360
|
+
const structureOrder = orderMap[structure.structureId];
|
|
42361
|
+
if (structureOrder)
|
|
42362
|
+
structure.structureOrder = structureOrder;
|
|
42363
|
+
});
|
|
42364
|
+
drawDefinition.structures.sort(
|
|
42365
|
+
(a, b) => numericSortValue(a.structureOrder) - numericSortValue(b.structureOrder)
|
|
42366
|
+
);
|
|
42367
|
+
return { ...SUCCESS };
|
|
42368
|
+
}
|
|
42369
|
+
|
|
42344
42370
|
function renameStructures$1({ drawDefinition, structureDetails }) {
|
|
42345
42371
|
if (!isObject(structureDetails))
|
|
42346
42372
|
return { error: INVALID_VALUES };
|
|
@@ -42585,6 +42611,7 @@ const structureGovernor = {
|
|
|
42585
42611
|
generateAndPopulatePlayoffStructures,
|
|
42586
42612
|
attachPlayoffStructures: attachPlayoffStructures$1,
|
|
42587
42613
|
addPlayoffStructures: addPlayoffStructures$1,
|
|
42614
|
+
setStructureOrder,
|
|
42588
42615
|
renameStructures: renameStructures$1,
|
|
42589
42616
|
generateQualifyingStructure: generateQualifyingStructure$1,
|
|
42590
42617
|
attachQualifyingStructure: attachQualifyingStructure$1,
|
|
@@ -44537,8 +44564,9 @@ function eliminationSwap({
|
|
|
44537
44564
|
return { ...SUCCESS };
|
|
44538
44565
|
if (assignments.filter(({ qualifier }) => qualifier).length === 2)
|
|
44539
44566
|
return { ...SUCCESS };
|
|
44567
|
+
const isQualifierSwap = assignments.some(({ qualifier }) => qualifier);
|
|
44540
44568
|
const isByeSwap = assignments.some(({ bye }) => bye);
|
|
44541
|
-
if (isByeSwap) {
|
|
44569
|
+
if (isByeSwap && !isQualifierSwap) {
|
|
44542
44570
|
return swapParticipantIdWithBYE({
|
|
44543
44571
|
inContextDrawMatchUps,
|
|
44544
44572
|
tournamentRecord,
|
|
@@ -44549,7 +44577,7 @@ function eliminationSwap({
|
|
|
44549
44577
|
event
|
|
44550
44578
|
});
|
|
44551
44579
|
} else {
|
|
44552
|
-
return
|
|
44580
|
+
return eliminationPosiitonSwap({
|
|
44553
44581
|
inContextDrawMatchUps,
|
|
44554
44582
|
tournamentRecord,
|
|
44555
44583
|
drawDefinition,
|
|
@@ -44618,7 +44646,7 @@ function swapParticipantIdWithBYE({
|
|
|
44618
44646
|
return result;
|
|
44619
44647
|
return { ...SUCCESS };
|
|
44620
44648
|
}
|
|
44621
|
-
function
|
|
44649
|
+
function eliminationPosiitonSwap({
|
|
44622
44650
|
inContextDrawMatchUps,
|
|
44623
44651
|
tournamentRecord,
|
|
44624
44652
|
drawDefinition,
|
|
@@ -44679,8 +44707,9 @@ function roundRobinSwap({
|
|
|
44679
44707
|
structure,
|
|
44680
44708
|
event
|
|
44681
44709
|
});
|
|
44710
|
+
const isQualifierSwap = assignments.some(({ qualifier }) => qualifier);
|
|
44682
44711
|
const isByeSwap = assignments.some(({ bye }) => bye);
|
|
44683
|
-
if (isByeSwap) {
|
|
44712
|
+
if (isByeSwap && !isQualifierSwap) {
|
|
44684
44713
|
swapParticipantIdWithBYE({
|
|
44685
44714
|
inContextDrawMatchUps,
|
|
44686
44715
|
tournamentRecord,
|
|
@@ -44972,7 +45001,7 @@ function generateDrawMaticRound({
|
|
|
44972
45001
|
);
|
|
44973
45002
|
if (teamParticipants) {
|
|
44974
45003
|
for (const teamParticipant of teamParticipants) {
|
|
44975
|
-
const participantIds2 = teamParticipant.individualParticipantIds
|
|
45004
|
+
const participantIds2 = teamParticipant.individualParticipantIds ?? [];
|
|
44976
45005
|
const { uniquePairings: uniquePairings2 } = getPairingsData({ participantIds: participantIds2 });
|
|
44977
45006
|
for (const pairing of uniquePairings2) {
|
|
44978
45007
|
if (!valueObjects[pairing])
|
|
@@ -47305,7 +47334,7 @@ function getOrderedTieFormat({ tieFormat, orderMap }) {
|
|
|
47305
47334
|
collectionDefinition.collectionOrder = collectionOrder;
|
|
47306
47335
|
});
|
|
47307
47336
|
orderedTieFormat.collectionDefinitions.sort(
|
|
47308
|
-
(a, b) => a.collectionOrder - b.collectionOrder
|
|
47337
|
+
(a, b) => numericSortValue(a.collectionOrder) - numericSortValue(b.collectionOrder)
|
|
47309
47338
|
);
|
|
47310
47339
|
return orderedTieFormat;
|
|
47311
47340
|
}
|
|
@@ -47319,8 +47348,11 @@ function orderCollectionDefinitions({
|
|
|
47319
47348
|
matchUp,
|
|
47320
47349
|
event
|
|
47321
47350
|
}) {
|
|
47322
|
-
if (typeof orderMap !== "object")
|
|
47323
|
-
return {
|
|
47351
|
+
if (typeof orderMap !== "object" || !Object.values(orderMap).every((val) => isConvertableInteger(val)))
|
|
47352
|
+
return decorateResult({
|
|
47353
|
+
result: { error: INVALID_VALUES },
|
|
47354
|
+
context: { orderMap }
|
|
47355
|
+
});
|
|
47324
47356
|
if (eventId && event?.tieFormat) {
|
|
47325
47357
|
updateEventTieFormat({ tournamentRecord, event, orderMap });
|
|
47326
47358
|
} else if (matchUpId) {
|
|
@@ -48777,7 +48809,7 @@ function modifyTieFormat({
|
|
|
48777
48809
|
processedTieFormat = result2.tieFormat;
|
|
48778
48810
|
}
|
|
48779
48811
|
processedTieFormat.collectionDefinitions = processedTieFormat.collectionDefinitions.sort(
|
|
48780
|
-
(a, b) => (a.collectionOrder
|
|
48812
|
+
(a, b) => numericSortValue(a.collectionOrder) - numericSortValue(b.collectionOrder)
|
|
48781
48813
|
).map((def, i) => ({ ...def, collectionOrder: i + 1 }));
|
|
48782
48814
|
return { ...SUCCESS, processedTieFormat };
|
|
48783
48815
|
}
|
|
@@ -54189,6 +54221,7 @@ function removeTieMatchUpParticipantId(params) {
|
|
|
54189
54221
|
function getPositionAssignments({
|
|
54190
54222
|
tournamentRecord,
|
|
54191
54223
|
drawDefinition,
|
|
54224
|
+
stage = MAIN,
|
|
54192
54225
|
structureId,
|
|
54193
54226
|
structure
|
|
54194
54227
|
}) {
|
|
@@ -54196,6 +54229,11 @@ function getPositionAssignments({
|
|
|
54196
54229
|
return { error: MISSING_TOURNAMENT_RECORD };
|
|
54197
54230
|
if (!structure && !drawDefinition)
|
|
54198
54231
|
return { error: MISSING_DRAW_DEFINITION };
|
|
54232
|
+
if (!structure && !structureId && drawDefinition?.structures?.filter((structure2) => structure2.stage === stage).length === 1) {
|
|
54233
|
+
structure = drawDefinition.structures.find(
|
|
54234
|
+
(structure2) => structure2.stage === stage
|
|
54235
|
+
);
|
|
54236
|
+
}
|
|
54199
54237
|
if (!structure && !structureId)
|
|
54200
54238
|
return { error: MISSING_STRUCTURE_ID };
|
|
54201
54239
|
const { error, positionAssignments: assignments } = getPositionAssignments$1({
|
|
@@ -54203,7 +54241,11 @@ function getPositionAssignments({
|
|
|
54203
54241
|
structureId,
|
|
54204
54242
|
structure
|
|
54205
54243
|
});
|
|
54206
|
-
return {
|
|
54244
|
+
return {
|
|
54245
|
+
error,
|
|
54246
|
+
positionAssignments: assignments || [],
|
|
54247
|
+
structureId: structure?.structureId
|
|
54248
|
+
};
|
|
54207
54249
|
}
|
|
54208
54250
|
|
|
54209
54251
|
function deleteDrawDefinitions({
|
|
@@ -57158,7 +57200,7 @@ function prepareStage(params) {
|
|
|
57158
57200
|
stage
|
|
57159
57201
|
}));
|
|
57160
57202
|
}
|
|
57161
|
-
const scaledEntriesCount = scaledEntries?.length
|
|
57203
|
+
const scaledEntriesCount = scaledEntries?.length ?? 0;
|
|
57162
57204
|
if (scaledEntriesCount < seedsCount)
|
|
57163
57205
|
seedsCount = scaledEntriesCount;
|
|
57164
57206
|
scaledEntries?.filter(
|
|
@@ -57676,6 +57718,12 @@ function renameStructures(params) {
|
|
|
57676
57718
|
return renameStructures$1(params);
|
|
57677
57719
|
}
|
|
57678
57720
|
|
|
57721
|
+
function resetMatchUpLineUps(params) {
|
|
57722
|
+
if (!params.tournamentRecord)
|
|
57723
|
+
return { error: MISSING_TOURNAMENT_RECORD };
|
|
57724
|
+
return resetMatchUpLineUps$1(params);
|
|
57725
|
+
}
|
|
57726
|
+
|
|
57679
57727
|
function aggregateTieFormats({
|
|
57680
57728
|
tournamentRecord
|
|
57681
57729
|
}) {
|
|
@@ -57787,18 +57835,13 @@ function enableTieAutoCalc(params) {
|
|
|
57787
57835
|
return enableTieAutoCalc$1(params);
|
|
57788
57836
|
}
|
|
57789
57837
|
|
|
57790
|
-
function resetMatchUpLineUps(params) {
|
|
57791
|
-
if (!params.tournamentRecord)
|
|
57792
|
-
return { error: MISSING_TOURNAMENT_RECORD };
|
|
57793
|
-
return resetMatchUpLineUps$1(params);
|
|
57794
|
-
}
|
|
57795
|
-
|
|
57796
57838
|
const eventGovernor = {
|
|
57797
57839
|
generateQualifyingStructure,
|
|
57798
57840
|
attachQualifyingStructure,
|
|
57799
57841
|
attachPlayoffStructures,
|
|
57800
|
-
attachStructures,
|
|
57801
57842
|
addQualifyingStructure,
|
|
57843
|
+
setStructureOrder,
|
|
57844
|
+
attachStructures,
|
|
57802
57845
|
renameStructures,
|
|
57803
57846
|
disableTieAutoCalc,
|
|
57804
57847
|
enableTieAutoCalc,
|