tods-competition-factory 1.8.30 → 1.8.32
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 +2 -0
- package/dist/forge/generate.mjs +167 -36
- package/dist/forge/generate.mjs.map +1 -1
- package/dist/forge/query.d.ts +33 -2
- package/dist/forge/query.mjs +248 -74
- package/dist/forge/query.mjs.map +1 -1
- package/dist/forge/transform.mjs +152 -33
- package/dist/forge/transform.mjs.map +1 -1
- package/dist/index.mjs +264 -78
- package/dist/index.mjs.map +1 -1
- package/dist/tods-competition-factory.development.cjs.js +291 -105
- 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
|
@@ -6849,13 +6849,12 @@ function getProjectedDualWinningSide({
|
|
|
6849
6849
|
|
|
6850
6850
|
function addParticipantGroupings({
|
|
6851
6851
|
participantsProfile,
|
|
6852
|
-
participants = []
|
|
6852
|
+
participants = [],
|
|
6853
|
+
deepCopy
|
|
6854
|
+
// will skip deepCopy only if false
|
|
6853
6855
|
}) {
|
|
6854
|
-
const
|
|
6855
|
-
|
|
6856
|
-
participantsProfile?.convertExtensions,
|
|
6857
|
-
true
|
|
6858
|
-
);
|
|
6856
|
+
const groupMap = /* @__PURE__ */ new Map();
|
|
6857
|
+
const participantsWithGroupings = deepCopy !== false ? makeDeepCopy(participants, participantsProfile?.convertExtensions, true) : participants;
|
|
6859
6858
|
const teamParticipants = participantsWithGroupings.filter(
|
|
6860
6859
|
(participant) => participant.participantType === TEAM
|
|
6861
6860
|
);
|
|
@@ -6878,6 +6877,11 @@ function addParticipantGroupings({
|
|
|
6878
6877
|
(individualParticipantId) => {
|
|
6879
6878
|
if (individualParticipantId === participantId && !participant.teamParticipantIds?.includes(team.participantId)) {
|
|
6880
6879
|
participant.teamParticipantIds.push(team.participantId);
|
|
6880
|
+
if (!groupMap.get(team.participantId))
|
|
6881
|
+
groupMap.set(team.participantId, {
|
|
6882
|
+
participantName: team.participantName,
|
|
6883
|
+
participantId: team.participantId
|
|
6884
|
+
});
|
|
6881
6885
|
participant.teams.push({
|
|
6882
6886
|
participantRoleResponsibilities: team.participantRoleResponsibilities,
|
|
6883
6887
|
participantOtherName: team.participantOtherName,
|
|
@@ -6915,7 +6919,7 @@ function addParticipantGroupings({
|
|
|
6915
6919
|
});
|
|
6916
6920
|
}
|
|
6917
6921
|
});
|
|
6918
|
-
return participantsWithGroupings;
|
|
6922
|
+
return { participantsWithGroupings, groupInfo: Object.fromEntries(groupMap) };
|
|
6919
6923
|
}
|
|
6920
6924
|
|
|
6921
6925
|
const extractor = (object) => (attr) => object[attr];
|
|
@@ -7610,13 +7614,14 @@ function getDrawMatchUps(params) {
|
|
|
7610
7614
|
event
|
|
7611
7615
|
});
|
|
7612
7616
|
}
|
|
7617
|
+
let groupInfo;
|
|
7613
7618
|
if (!tournamentParticipants?.length && tournamentRecord) {
|
|
7614
7619
|
tournamentParticipants = tournamentRecord?.participants;
|
|
7615
7620
|
if ((inContext || participantsProfile?.withGroupings) && tournamentParticipants?.length) {
|
|
7616
|
-
tournamentParticipants = addParticipantGroupings({
|
|
7621
|
+
({ participantsWithGroupings: tournamentParticipants, groupInfo } = addParticipantGroupings({
|
|
7617
7622
|
participants: tournamentParticipants,
|
|
7618
7623
|
participantsProfile
|
|
7619
|
-
});
|
|
7624
|
+
}));
|
|
7620
7625
|
}
|
|
7621
7626
|
}
|
|
7622
7627
|
const { structures } = getDrawStructures({ drawDefinition });
|
|
@@ -7677,14 +7682,15 @@ function getDrawMatchUps(params) {
|
|
|
7677
7682
|
}
|
|
7678
7683
|
return matchUps;
|
|
7679
7684
|
};
|
|
7680
|
-
const
|
|
7685
|
+
const drawMatchUpsResult = {
|
|
7681
7686
|
abandonedMatchUps: applyFilter(allAbandonedMatchUps),
|
|
7682
7687
|
completedMatchUps: applyFilter(allCompletedMatchUps),
|
|
7683
7688
|
upcomingMatchUps: applyFilter(allUpcomingMatchUps),
|
|
7684
7689
|
pendingMatchUps: applyFilter(allPendingMatchUps),
|
|
7685
7690
|
byeMatchUps: applyFilter(allByeMatchUps),
|
|
7686
7691
|
matchUpsMap,
|
|
7687
|
-
...SUCCESS
|
|
7692
|
+
...SUCCESS,
|
|
7693
|
+
groupInfo
|
|
7688
7694
|
};
|
|
7689
7695
|
if (nextMatchUps) {
|
|
7690
7696
|
const nextFilter = typeof nextMatchUps === "object" || {
|
|
@@ -7707,7 +7713,7 @@ function getDrawMatchUps(params) {
|
|
|
7707
7713
|
drawDefinition
|
|
7708
7714
|
});
|
|
7709
7715
|
}
|
|
7710
|
-
return
|
|
7716
|
+
return drawMatchUpsResult;
|
|
7711
7717
|
}
|
|
7712
7718
|
|
|
7713
7719
|
function analyzeScore({
|
|
@@ -10196,11 +10202,13 @@ function hydrateParticipants({
|
|
|
10196
10202
|
participants.forEach(
|
|
10197
10203
|
(participant) => addNationalityCode({ participant, ...participantsProfile })
|
|
10198
10204
|
);
|
|
10205
|
+
let groupInfo;
|
|
10199
10206
|
if ((inContext || participantsProfile?.withGroupings) && participants?.length) {
|
|
10200
|
-
participants = addParticipantGroupings({
|
|
10207
|
+
({ participantsWithGroupings: participants, groupInfo } = addParticipantGroupings({
|
|
10201
10208
|
participantsProfile,
|
|
10209
|
+
deepCopy: false,
|
|
10202
10210
|
participants
|
|
10203
|
-
});
|
|
10211
|
+
}));
|
|
10204
10212
|
}
|
|
10205
10213
|
if (participantsProfile?.withScaleValues && participants?.length) {
|
|
10206
10214
|
for (const participant of participants) {
|
|
@@ -10209,7 +10217,7 @@ function hydrateParticipants({
|
|
|
10209
10217
|
participant.ratings = ratings;
|
|
10210
10218
|
}
|
|
10211
10219
|
}
|
|
10212
|
-
return { participants };
|
|
10220
|
+
return { participants, groupInfo };
|
|
10213
10221
|
}
|
|
10214
10222
|
|
|
10215
10223
|
function allTournamentMatchUps(params) {
|
|
@@ -10317,8 +10325,13 @@ function allDrawMatchUps(params) {
|
|
|
10317
10325
|
surfaceCategory: event?.surfaceCategory ?? tournamentRecord?.surfaceCategory,
|
|
10318
10326
|
endDate: event?.endDate
|
|
10319
10327
|
};
|
|
10328
|
+
let groupInfo;
|
|
10320
10329
|
if (!tournamentParticipants?.length && !participantMap && tournamentRecord) {
|
|
10321
|
-
({
|
|
10330
|
+
({
|
|
10331
|
+
participants: tournamentParticipants = [],
|
|
10332
|
+
participantMap,
|
|
10333
|
+
groupInfo
|
|
10334
|
+
} = hydrateParticipants({
|
|
10322
10335
|
participantsProfile,
|
|
10323
10336
|
useParticipantMap,
|
|
10324
10337
|
policyDefinitions,
|
|
@@ -10336,7 +10349,7 @@ function allDrawMatchUps(params) {
|
|
|
10336
10349
|
event
|
|
10337
10350
|
});
|
|
10338
10351
|
}
|
|
10339
|
-
|
|
10352
|
+
const allDrawMatchUpsResult = getAllDrawMatchUps({
|
|
10340
10353
|
context: additionalContext,
|
|
10341
10354
|
tournamentAppliedPolicies,
|
|
10342
10355
|
scheduleVisibilityFilters,
|
|
@@ -10355,6 +10368,7 @@ function allDrawMatchUps(params) {
|
|
|
10355
10368
|
inContext,
|
|
10356
10369
|
event
|
|
10357
10370
|
});
|
|
10371
|
+
return { ...allDrawMatchUpsResult, groupInfo };
|
|
10358
10372
|
}
|
|
10359
10373
|
function allEventMatchUps(params) {
|
|
10360
10374
|
let { participants = [], contextContent, participantMap } = params;
|
|
@@ -10401,6 +10415,7 @@ function allEventMatchUps(params) {
|
|
|
10401
10415
|
event
|
|
10402
10416
|
});
|
|
10403
10417
|
}
|
|
10418
|
+
let groupInfo;
|
|
10404
10419
|
if (!participants?.length && !participantMap && tournamentRecord) {
|
|
10405
10420
|
const hydratedParticipantResult = hydrateParticipants({
|
|
10406
10421
|
participantsProfile,
|
|
@@ -10412,6 +10427,7 @@ function allEventMatchUps(params) {
|
|
|
10412
10427
|
});
|
|
10413
10428
|
participantMap = hydratedParticipantResult.participantMap;
|
|
10414
10429
|
participants = hydratedParticipantResult.participants ?? [];
|
|
10430
|
+
groupInfo = hydratedParticipantResult.groupInfo;
|
|
10415
10431
|
}
|
|
10416
10432
|
const drawDefinitions = event.drawDefinitions ?? [];
|
|
10417
10433
|
const scheduleTiming = getScheduleTiming({
|
|
@@ -10443,7 +10459,7 @@ function allEventMatchUps(params) {
|
|
|
10443
10459
|
return matchUps2 ?? [];
|
|
10444
10460
|
}
|
|
10445
10461
|
);
|
|
10446
|
-
return { matchUps };
|
|
10462
|
+
return { matchUps, groupInfo };
|
|
10447
10463
|
}
|
|
10448
10464
|
|
|
10449
10465
|
function addFinishingRounds({
|
|
@@ -13573,10 +13589,89 @@ function getSeedGroups({
|
|
|
13573
13589
|
}
|
|
13574
13590
|
}
|
|
13575
13591
|
|
|
13592
|
+
function getDivisions({ size }) {
|
|
13593
|
+
const divisions = [size];
|
|
13594
|
+
let division = size;
|
|
13595
|
+
while (division / 2 === Math.floor(division / 2)) {
|
|
13596
|
+
division = division / 2;
|
|
13597
|
+
divisions.push(division);
|
|
13598
|
+
}
|
|
13599
|
+
if (!divisions.includes(1))
|
|
13600
|
+
divisions.push(1);
|
|
13601
|
+
divisions.sort(numericSort);
|
|
13602
|
+
divisions.reverse();
|
|
13603
|
+
return divisions;
|
|
13604
|
+
}
|
|
13605
|
+
function getSubBlock({ blockPattern, index }) {
|
|
13606
|
+
let i = 0;
|
|
13607
|
+
for (const subBlock of blockPattern) {
|
|
13608
|
+
if (i === index)
|
|
13609
|
+
return subBlock;
|
|
13610
|
+
let j = 0;
|
|
13611
|
+
while (j < subBlock.length) {
|
|
13612
|
+
if (i === index)
|
|
13613
|
+
return subBlock;
|
|
13614
|
+
i += 1;
|
|
13615
|
+
j++;
|
|
13616
|
+
}
|
|
13617
|
+
}
|
|
13618
|
+
}
|
|
13619
|
+
function generateBlockPattern({
|
|
13620
|
+
positioning,
|
|
13621
|
+
size
|
|
13622
|
+
}) {
|
|
13623
|
+
const divisions = getDivisions({ size });
|
|
13624
|
+
const divisionGroupings = [];
|
|
13625
|
+
const selected = [];
|
|
13626
|
+
const firstMember = (arr) => arr[0];
|
|
13627
|
+
const lastMember = (arr) => arr[arr.length - 1];
|
|
13628
|
+
const getMember = (arr, i) => (positioning === CLUSTER && i % 2 ? lastMember(arr) : firstMember(arr)) || firstMember(arr);
|
|
13629
|
+
const noneSelected = (chunk, i) => {
|
|
13630
|
+
if (chunk.every((member) => !selected.includes(member))) {
|
|
13631
|
+
const member = getMember(chunk, i);
|
|
13632
|
+
selected.push(member);
|
|
13633
|
+
return member;
|
|
13634
|
+
}
|
|
13635
|
+
};
|
|
13636
|
+
const notSelected = (chunk) => {
|
|
13637
|
+
const notSelected2 = chunk.filter((member) => !selected.includes(member));
|
|
13638
|
+
if (notSelected2.length) {
|
|
13639
|
+
selected.push(...notSelected2);
|
|
13640
|
+
return notSelected2;
|
|
13641
|
+
}
|
|
13642
|
+
};
|
|
13643
|
+
const select = (chunk, i) => {
|
|
13644
|
+
const member = getMember(chunk, i);
|
|
13645
|
+
if (!selected.includes(member)) {
|
|
13646
|
+
selected.push(member);
|
|
13647
|
+
return member;
|
|
13648
|
+
}
|
|
13649
|
+
};
|
|
13650
|
+
const range = generateRange(1, size + 1);
|
|
13651
|
+
for (const division of divisions) {
|
|
13652
|
+
if (division === 1) {
|
|
13653
|
+
const chunks = chunkArray(range, 2);
|
|
13654
|
+
const positions = chunks.map(noneSelected).filter(Boolean);
|
|
13655
|
+
if (positions.length)
|
|
13656
|
+
divisionGroupings.push(positions);
|
|
13657
|
+
const lastPositions = chunks.flatMap(notSelected).filter(Boolean);
|
|
13658
|
+
if (lastPositions.length)
|
|
13659
|
+
divisionGroupings.push(lastPositions);
|
|
13660
|
+
} else {
|
|
13661
|
+
const chunks = chunkArray(range, division);
|
|
13662
|
+
const positions = chunks.map(select).filter(Boolean);
|
|
13663
|
+
if (positions.length)
|
|
13664
|
+
divisionGroupings.push(positions);
|
|
13665
|
+
}
|
|
13666
|
+
}
|
|
13667
|
+
return { divisions, divisionGroupings };
|
|
13668
|
+
}
|
|
13669
|
+
|
|
13576
13670
|
function getValidSeedBlocks({
|
|
13577
13671
|
provisionalPositioning,
|
|
13578
13672
|
returnAllProxies,
|
|
13579
13673
|
appliedPolicies,
|
|
13674
|
+
seedingProfile,
|
|
13580
13675
|
drawDefinition,
|
|
13581
13676
|
allPositions,
|
|
13582
13677
|
structure
|
|
@@ -13610,7 +13705,7 @@ function getValidSeedBlocks({
|
|
|
13610
13705
|
}).filter((f) => f.length).reverse();
|
|
13611
13706
|
const firstRoundDrawPositions = uniqueDrawPositionsByRound.pop();
|
|
13612
13707
|
const firstRoundDrawPositionOffset = firstRoundDrawPositions && Math.min(...firstRoundDrawPositions) - 1 || 0;
|
|
13613
|
-
|
|
13708
|
+
seedingProfile = seedingProfile ?? appliedPolicies?.seeding?.seedingProfile;
|
|
13614
13709
|
const baseDrawSize = firstRoundDrawPositions?.length || 0;
|
|
13615
13710
|
const seedRangeDrawPositionBlocks = uniqueDrawPositionsByRound.filter(
|
|
13616
13711
|
(block) => block.filter((drawPosition) => drawPosition <= seedsCount).length
|
|
@@ -13649,12 +13744,14 @@ function getValidSeedBlocks({
|
|
|
13649
13744
|
);
|
|
13650
13745
|
({ validSeedBlocks } = getSeedBlockPattern({
|
|
13651
13746
|
drawPositionBlocks: drawPositionChunks,
|
|
13747
|
+
nonRandom: seedingProfile?.nonRandom,
|
|
13652
13748
|
positioning,
|
|
13653
13749
|
seedGroups
|
|
13654
13750
|
}));
|
|
13655
13751
|
}
|
|
13656
13752
|
} else if (isContainer) {
|
|
13657
13753
|
const result = getContainerBlocks({
|
|
13754
|
+
nonRandom: seedingProfile?.nonRandom,
|
|
13658
13755
|
seedingProfile,
|
|
13659
13756
|
structure
|
|
13660
13757
|
});
|
|
@@ -13704,7 +13801,7 @@ function getValidSeedBlocks({
|
|
|
13704
13801
|
isFeedIn
|
|
13705
13802
|
};
|
|
13706
13803
|
}
|
|
13707
|
-
function getContainerBlocks({ seedingProfile, structure }) {
|
|
13804
|
+
function getContainerBlocks({ seedingProfile, structure, nonRandom }) {
|
|
13708
13805
|
const containedStructures = structure.structures || [];
|
|
13709
13806
|
const roundRobinGroupsCount = containedStructures.length;
|
|
13710
13807
|
const positionAssignments = getPositionAssignments({
|
|
@@ -13724,26 +13821,48 @@ function getContainerBlocks({ seedingProfile, structure }) {
|
|
|
13724
13821
|
return getSeedBlockPattern({
|
|
13725
13822
|
drawPositionBlocks,
|
|
13726
13823
|
positioning,
|
|
13727
|
-
seedGroups
|
|
13824
|
+
seedGroups,
|
|
13825
|
+
nonRandom
|
|
13728
13826
|
});
|
|
13729
13827
|
}
|
|
13730
|
-
function getSeedBlockPattern({
|
|
13828
|
+
function getSeedBlockPattern({
|
|
13829
|
+
drawPositionBlocks,
|
|
13830
|
+
positioning,
|
|
13831
|
+
seedGroups,
|
|
13832
|
+
nonRandom
|
|
13833
|
+
}) {
|
|
13731
13834
|
const validSeedBlocks = [];
|
|
13732
|
-
const
|
|
13733
|
-
|
|
13835
|
+
const { divisionGroupings } = generateBlockPattern({
|
|
13836
|
+
size: seedGroups.length,
|
|
13837
|
+
positioning
|
|
13838
|
+
});
|
|
13734
13839
|
const assignedPositions = [];
|
|
13735
13840
|
seedGroups.forEach((seedGroup, i) => {
|
|
13736
|
-
|
|
13737
|
-
|
|
13738
|
-
|
|
13841
|
+
const relativePositions = getSubBlock({
|
|
13842
|
+
blockPattern: divisionGroupings,
|
|
13843
|
+
index: i
|
|
13844
|
+
});
|
|
13739
13845
|
seedGroup.forEach((seedNumber, j) => {
|
|
13740
13846
|
const blockIndex = i % 2 ? drawPositionBlocks.length - j - 1 : j;
|
|
13741
|
-
const
|
|
13742
|
-
|
|
13743
|
-
|
|
13744
|
-
|
|
13745
|
-
|
|
13746
|
-
|
|
13847
|
+
const block = drawPositionBlocks[blockIndex].slice();
|
|
13848
|
+
let consideredDrawPositions = block.filter(
|
|
13849
|
+
(drawPosition2, i2) => relativePositions.includes(i2 + 1) && drawPosition2
|
|
13850
|
+
);
|
|
13851
|
+
if (positioning !== WATERFALL) {
|
|
13852
|
+
consideredDrawPositions = nonRandom ? consideredDrawPositions : shuffleArray(consideredDrawPositions);
|
|
13853
|
+
} else if (i % 2) {
|
|
13854
|
+
consideredDrawPositions.reverse();
|
|
13855
|
+
}
|
|
13856
|
+
const drawPosition = consideredDrawPositions.find(
|
|
13857
|
+
(drawPosition2) => !assignedPositions.includes(drawPosition2)
|
|
13858
|
+
);
|
|
13859
|
+
if (drawPosition) {
|
|
13860
|
+
assignedPositions.push(drawPosition);
|
|
13861
|
+
validSeedBlocks.push({
|
|
13862
|
+
seedNumbers: [seedNumber],
|
|
13863
|
+
drawPositions: [drawPosition]
|
|
13864
|
+
});
|
|
13865
|
+
}
|
|
13747
13866
|
});
|
|
13748
13867
|
});
|
|
13749
13868
|
return { validSeedBlocks };
|