tods-competition-factory 1.6.23 → 1.6.25
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 +67 -23
- package/dist/index.mjs.map +1 -1
- package/dist/tods-competition-factory.development.cjs.js +104 -47
- 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.25";
|
|
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
|
}
|
|
@@ -51035,8 +51067,8 @@ function unPublishEvent({
|
|
|
51035
51067
|
event
|
|
51036
51068
|
});
|
|
51037
51069
|
const itemValue = timeItem?.itemValue || { [status]: {} };
|
|
51038
|
-
delete itemValue[status].drawIds;
|
|
51039
51070
|
delete itemValue[status].structureIds;
|
|
51071
|
+
delete itemValue[status].drawIds;
|
|
51040
51072
|
const updatedTimeItem = { itemValue, itemType };
|
|
51041
51073
|
addEventTimeItem({ event, timeItem: updatedTimeItem, removePriorValues });
|
|
51042
51074
|
addNotice({
|
|
@@ -51428,8 +51460,9 @@ function publishEvent(params) {
|
|
|
51428
51460
|
if (structureIdsToAdd?.length) {
|
|
51429
51461
|
structureIds = unique(structureIds.push(...structureIdsToAdd));
|
|
51430
51462
|
}
|
|
51463
|
+
const existingStatusValue = timeItem?.itemValue?.[status];
|
|
51431
51464
|
const updatedTimeItem = {
|
|
51432
|
-
itemValue: { [status]: { drawIds, structureIds } },
|
|
51465
|
+
itemValue: { [status]: { ...existingStatusValue, drawIds, structureIds } },
|
|
51433
51466
|
itemType
|
|
51434
51467
|
};
|
|
51435
51468
|
addEventTimeItem({ event, timeItem: updatedTimeItem, removePriorValues });
|
|
@@ -54189,6 +54222,7 @@ function removeTieMatchUpParticipantId(params) {
|
|
|
54189
54222
|
function getPositionAssignments({
|
|
54190
54223
|
tournamentRecord,
|
|
54191
54224
|
drawDefinition,
|
|
54225
|
+
stage = MAIN,
|
|
54192
54226
|
structureId,
|
|
54193
54227
|
structure
|
|
54194
54228
|
}) {
|
|
@@ -54196,6 +54230,11 @@ function getPositionAssignments({
|
|
|
54196
54230
|
return { error: MISSING_TOURNAMENT_RECORD };
|
|
54197
54231
|
if (!structure && !drawDefinition)
|
|
54198
54232
|
return { error: MISSING_DRAW_DEFINITION };
|
|
54233
|
+
if (!structure && !structureId && drawDefinition?.structures?.filter((structure2) => structure2.stage === stage).length === 1) {
|
|
54234
|
+
structure = drawDefinition.structures.find(
|
|
54235
|
+
(structure2) => structure2.stage === stage
|
|
54236
|
+
);
|
|
54237
|
+
}
|
|
54199
54238
|
if (!structure && !structureId)
|
|
54200
54239
|
return { error: MISSING_STRUCTURE_ID };
|
|
54201
54240
|
const { error, positionAssignments: assignments } = getPositionAssignments$1({
|
|
@@ -54203,7 +54242,11 @@ function getPositionAssignments({
|
|
|
54203
54242
|
structureId,
|
|
54204
54243
|
structure
|
|
54205
54244
|
});
|
|
54206
|
-
return {
|
|
54245
|
+
return {
|
|
54246
|
+
error,
|
|
54247
|
+
positionAssignments: assignments || [],
|
|
54248
|
+
structureId: structure?.structureId
|
|
54249
|
+
};
|
|
54207
54250
|
}
|
|
54208
54251
|
|
|
54209
54252
|
function deleteDrawDefinitions({
|
|
@@ -57158,7 +57201,7 @@ function prepareStage(params) {
|
|
|
57158
57201
|
stage
|
|
57159
57202
|
}));
|
|
57160
57203
|
}
|
|
57161
|
-
const scaledEntriesCount = scaledEntries?.length
|
|
57204
|
+
const scaledEntriesCount = scaledEntries?.length ?? 0;
|
|
57162
57205
|
if (scaledEntriesCount < seedsCount)
|
|
57163
57206
|
seedsCount = scaledEntriesCount;
|
|
57164
57207
|
scaledEntries?.filter(
|
|
@@ -57676,6 +57719,12 @@ function renameStructures(params) {
|
|
|
57676
57719
|
return renameStructures$1(params);
|
|
57677
57720
|
}
|
|
57678
57721
|
|
|
57722
|
+
function resetMatchUpLineUps(params) {
|
|
57723
|
+
if (!params.tournamentRecord)
|
|
57724
|
+
return { error: MISSING_TOURNAMENT_RECORD };
|
|
57725
|
+
return resetMatchUpLineUps$1(params);
|
|
57726
|
+
}
|
|
57727
|
+
|
|
57679
57728
|
function aggregateTieFormats({
|
|
57680
57729
|
tournamentRecord
|
|
57681
57730
|
}) {
|
|
@@ -57787,18 +57836,13 @@ function enableTieAutoCalc(params) {
|
|
|
57787
57836
|
return enableTieAutoCalc$1(params);
|
|
57788
57837
|
}
|
|
57789
57838
|
|
|
57790
|
-
function resetMatchUpLineUps(params) {
|
|
57791
|
-
if (!params.tournamentRecord)
|
|
57792
|
-
return { error: MISSING_TOURNAMENT_RECORD };
|
|
57793
|
-
return resetMatchUpLineUps$1(params);
|
|
57794
|
-
}
|
|
57795
|
-
|
|
57796
57839
|
const eventGovernor = {
|
|
57797
57840
|
generateQualifyingStructure,
|
|
57798
57841
|
attachQualifyingStructure,
|
|
57799
57842
|
attachPlayoffStructures,
|
|
57800
|
-
attachStructures,
|
|
57801
57843
|
addQualifyingStructure,
|
|
57844
|
+
setStructureOrder,
|
|
57845
|
+
attachStructures,
|
|
57802
57846
|
renameStructures,
|
|
57803
57847
|
disableTieAutoCalc,
|
|
57804
57848
|
enableTieAutoCalc,
|