tods-competition-factory 2.0.59 → 2.0.60
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/index.mjs +5 -5
- package/dist/tods-competition-factory.development.cjs.js +43 -33
- 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 +6 -6
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
function factoryVersion() {
|
|
6
|
-
return '2.0.
|
|
6
|
+
return '2.0.60';
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
function isFunction(obj) {
|
|
@@ -46,7 +46,7 @@ const hasAttributeValues = (a) => (o) => Object.keys(a).every((key) => o[key] ==
|
|
|
46
46
|
function undefinedToNull(obj, shallow) {
|
|
47
47
|
if (obj === undefined)
|
|
48
48
|
return null;
|
|
49
|
-
if (
|
|
49
|
+
if (!isObject(obj) || obj === null)
|
|
50
50
|
return obj;
|
|
51
51
|
const definedKeys = Object.keys(obj);
|
|
52
52
|
const notNull = (value) => (value === undefined ? null : value);
|
|
@@ -62,7 +62,7 @@ function countKeys(o) {
|
|
|
62
62
|
if (Array.isArray(o)) {
|
|
63
63
|
return o.length + o.map(countKeys).reduce((a, b) => a + b, 0);
|
|
64
64
|
}
|
|
65
|
-
else if (
|
|
65
|
+
else if (isObject(o) && o !== null) {
|
|
66
66
|
return (Object.keys(o).length +
|
|
67
67
|
Object.keys(o)
|
|
68
68
|
.map((k) => countKeys(o[k]))
|
|
@@ -20613,12 +20613,12 @@ const headToHeadTallyDirectives = [
|
|
|
20613
20613
|
const GEMScoreValueMap = {
|
|
20614
20614
|
matchUpsPct: 20,
|
|
20615
20615
|
tieMatchUpsPct: 16,
|
|
20616
|
-
setsPct: 12,
|
|
20617
|
-
gamesPct: 8,
|
|
20618
20616
|
pointsPct: 4,
|
|
20617
|
+
gamesPct: 8,
|
|
20618
|
+
setsPct: 12,
|
|
20619
20619
|
};
|
|
20620
20620
|
function getGroupOrder(params) {
|
|
20621
|
-
const { requireCompletion = true, participantResults, subOrderMap, tallyPolicy } = params;
|
|
20621
|
+
const { requireCompletion = true, participantResults, subOrderMap, tallyPolicy, } = params;
|
|
20622
20622
|
const report = [];
|
|
20623
20623
|
if (requireCompletion && !isComplete(params)) {
|
|
20624
20624
|
return {};
|
|
@@ -20643,16 +20643,20 @@ function getGroupOrder(params) {
|
|
|
20643
20643
|
attribute,
|
|
20644
20644
|
});
|
|
20645
20645
|
report.push({ attribute, groups: orderedTallyGroups });
|
|
20646
|
-
const
|
|
20646
|
+
const sortedTallyGroups = Object.keys(orderedTallyGroups)
|
|
20647
20647
|
.map((key) => parseFloat(key))
|
|
20648
20648
|
.sort((a, b) => b - a)
|
|
20649
|
-
.map((key) => orderedTallyGroups[key])
|
|
20650
|
-
|
|
20649
|
+
.map((key) => orderedTallyGroups[key]);
|
|
20650
|
+
const sortedOrder = sortedTallyGroups.map((participantIds) => {
|
|
20651
20651
|
const result = groupSubSort({ participantIds, ...params });
|
|
20652
20652
|
report.push(...(result.report ?? []));
|
|
20653
20653
|
return result.order;
|
|
20654
|
-
})
|
|
20655
|
-
|
|
20654
|
+
});
|
|
20655
|
+
const groupOrder = sortedOrder
|
|
20656
|
+
.map((order, oi) => order.map((o) => (o.resolved ? o : { ...o, subGroup: [oi].concat(...(o.subGroup ?? [])) })))
|
|
20657
|
+
.flat();
|
|
20658
|
+
let lastSubGroup;
|
|
20659
|
+
let subGroupCount = 0;
|
|
20656
20660
|
let groupPosition = 1;
|
|
20657
20661
|
let priorPositionResolution;
|
|
20658
20662
|
groupOrder.forEach((finishingPosition, index) => {
|
|
@@ -20662,13 +20666,20 @@ function getGroupOrder(params) {
|
|
|
20662
20666
|
groupPosition += 1;
|
|
20663
20667
|
}
|
|
20664
20668
|
priorPositionResolution = finishingPosition.resolved;
|
|
20669
|
+
const subGroup = parseInt(finishingPosition.subGroup?.join('') || 0);
|
|
20665
20670
|
if (finishingPosition.resolved) {
|
|
20666
20671
|
finishingPosition.position = index + 1;
|
|
20667
20672
|
groupPosition = finishingPosition.position;
|
|
20668
20673
|
}
|
|
20669
20674
|
else {
|
|
20675
|
+
if (lastSubGroup && subGroup > lastSubGroup) {
|
|
20676
|
+
groupPosition += subGroupCount;
|
|
20677
|
+
subGroupCount = 0;
|
|
20678
|
+
}
|
|
20670
20679
|
finishingPosition.position = groupPosition;
|
|
20680
|
+
subGroupCount += 1;
|
|
20671
20681
|
}
|
|
20682
|
+
lastSubGroup = subGroup;
|
|
20672
20683
|
});
|
|
20673
20684
|
const positions = groupOrder.map(({ position }) => position);
|
|
20674
20685
|
const positionsCount = instanceCount(positions);
|
|
@@ -20717,11 +20728,11 @@ function processAttribute({ disableHeadToHead, participantIds, matchUpFormat, ta
|
|
|
20717
20728
|
const report = [{ attribute, reversed, groups, idsFilter }];
|
|
20718
20729
|
let order;
|
|
20719
20730
|
if (Object.keys(groups).length > 1 && participantIds.length) {
|
|
20720
|
-
|
|
20731
|
+
const sortedTallyGroups = Object.keys(groups)
|
|
20721
20732
|
.map((key) => parseFloat(key))
|
|
20722
20733
|
.sort((a, b) => (reversed ? a - b : b - a))
|
|
20723
|
-
.map((key) => groups[key])
|
|
20724
|
-
|
|
20734
|
+
.map((key) => groups[key]);
|
|
20735
|
+
const sortedOrder = sortedTallyGroups.map((participantIds) => {
|
|
20725
20736
|
const result = groupSubSort({
|
|
20726
20737
|
participantResults,
|
|
20727
20738
|
disableHeadToHead,
|
|
@@ -20732,8 +20743,10 @@ function processAttribute({ disableHeadToHead, participantIds, matchUpFormat, ta
|
|
|
20732
20743
|
});
|
|
20733
20744
|
report.push(...(result.report ?? []));
|
|
20734
20745
|
return result.order;
|
|
20735
|
-
})
|
|
20736
|
-
|
|
20746
|
+
});
|
|
20747
|
+
order = sortedOrder
|
|
20748
|
+
.map((order, oi) => order.map((o) => (o.resolved ? o : { ...o, subGroup: [oi].concat(...(o.subGroup ?? [])) })))
|
|
20749
|
+
.flat();
|
|
20737
20750
|
}
|
|
20738
20751
|
return { order, report };
|
|
20739
20752
|
}
|
|
@@ -20749,11 +20762,11 @@ function groupSubSort({ participantResults, disableHeadToHead, participantIds, m
|
|
|
20749
20762
|
}
|
|
20750
20763
|
if (participantIds?.length === 2 &&
|
|
20751
20764
|
(!tallyPolicy?.headToHead || (!tallyPolicy.headToHead.disabled && !disableHeadToHead))) {
|
|
20752
|
-
const result =
|
|
20765
|
+
const result = getHeadToHeadWinner({ participantIds, participantResults });
|
|
20753
20766
|
if (result) {
|
|
20754
20767
|
const headToHeadWinner = result[0].participantId;
|
|
20755
20768
|
report.push({ attribute: 'head2Head', participantIds, headToHeadWinner });
|
|
20756
|
-
return { order:
|
|
20769
|
+
return { order: result, headToHeadWinner, report };
|
|
20757
20770
|
}
|
|
20758
20771
|
}
|
|
20759
20772
|
const directives = tallyPolicy?.tallyDirectives || headToHeadTallyDirectives;
|
|
@@ -20786,7 +20799,7 @@ function groupSubSort({ participantResults, disableHeadToHead, participantIds, m
|
|
|
20786
20799
|
report,
|
|
20787
20800
|
};
|
|
20788
20801
|
}
|
|
20789
|
-
function
|
|
20802
|
+
function getHeadToHeadWinner({ participantIds, participantResults }) {
|
|
20790
20803
|
if (!participantIds)
|
|
20791
20804
|
return;
|
|
20792
20805
|
if (participantResults[participantIds[0]].victories.includes(participantIds[1])) {
|
|
@@ -20998,16 +21011,13 @@ function getMatchUp$1({ matchUps, matchUpId }) {
|
|
|
20998
21011
|
return { matchUp };
|
|
20999
21012
|
}
|
|
21000
21013
|
|
|
21001
|
-
function findDrawMatchUp(
|
|
21002
|
-
|
|
21003
|
-
|
|
21004
|
-
|
|
21005
|
-
|
|
21006
|
-
if (typeof matchUpId !== 'string')
|
|
21007
|
-
return { error: INVALID_VALUES };
|
|
21014
|
+
function findDrawMatchUp(params) {
|
|
21015
|
+
const paramsCheck = checkRequiredParameters(params, [{ [DRAW_DEFINITION]: true, [MATCHUP_ID]: true }]);
|
|
21016
|
+
if (paramsCheck.error)
|
|
21017
|
+
return paramsCheck;
|
|
21018
|
+
const { tournamentParticipants, afterRecoveryTimes, contextProfile, drawDefinition, matchUpsMap, matchUpId, inContext, context, event, } = params;
|
|
21008
21019
|
const { structures = [] } = getDrawStructures({ drawDefinition });
|
|
21009
|
-
|
|
21010
|
-
contextContent = getContextContent({ contextProfile, drawDefinition });
|
|
21020
|
+
const contextContent = params.contextContent || (contextProfile && getContextContent({ contextProfile, drawDefinition }));
|
|
21011
21021
|
for (const structure of structures) {
|
|
21012
21022
|
const { matchUps } = getAllStructureMatchUps({
|
|
21013
21023
|
tournamentParticipants,
|
|
@@ -30547,13 +30557,13 @@ function validateScore({ existingMatchUpStatus, matchUpFormat, matchUpStatus, wi
|
|
|
30547
30557
|
[side1TiebreakScore, side2TiebreakScore],
|
|
30548
30558
|
[side1PointScore, side2PointScore],
|
|
30549
30559
|
]
|
|
30550
|
-
.filter((pair) => pair.some((value) => value
|
|
30560
|
+
.filter((pair) => pair.some((value) => ![undefined, null].includes(value)))
|
|
30551
30561
|
.every((pair) => pair.every((numericValue) => isConvertableInteger(numericValue)));
|
|
30552
30562
|
if (!numericValuePairs) {
|
|
30553
30563
|
return { error: INVALID_VALUES, info: 'non-numeric values' };
|
|
30554
30564
|
}
|
|
30555
30565
|
const numericValues = [setNumber, winningSide]
|
|
30556
|
-
.filter((value) => value
|
|
30566
|
+
.filter((value) => ![undefined, null].includes(value))
|
|
30557
30567
|
.every((numericValue) => isConvertableInteger(numericValue));
|
|
30558
30568
|
if (!numericValues) {
|
|
30559
30569
|
return { error: INVALID_VALUES, info: 'non-numeric values' };
|
|
@@ -46682,7 +46692,7 @@ function v2Scheduler({ schedulingProfileModifications, checkPotentialRequestConf
|
|
|
46682
46692
|
}
|
|
46683
46693
|
|
|
46684
46694
|
function clearScheduledMatchUps(params) {
|
|
46685
|
-
const { scheduleAttributes = ['scheduledDate', 'scheduledTime'], ignoreMatchUpStatuses = completedMatchUpStatuses, scheduledDates, venueIds, } = params;
|
|
46695
|
+
const { scheduleAttributes = ['scheduledDate', 'scheduledTime', 'courtOrder'], ignoreMatchUpStatuses = completedMatchUpStatuses, scheduledDates, venueIds, } = params;
|
|
46686
46696
|
const tournamentRecords = resolveTournamentRecords(params);
|
|
46687
46697
|
const tournamentIds = isObject(tournamentRecords)
|
|
46688
46698
|
? Object.values(tournamentRecords)
|
|
@@ -46707,7 +46717,7 @@ function clearScheduledMatchUps(params) {
|
|
|
46707
46717
|
}
|
|
46708
46718
|
return { ...SUCCESS, clearedScheduleCount };
|
|
46709
46719
|
}
|
|
46710
|
-
function clearSchedules({ scheduleAttributes = ['scheduledDate', 'scheduledTime'], ignoreMatchUpStatuses = completedMatchUpStatuses, tournamentRecord, scheduledDates, venueIds = [], }) {
|
|
46720
|
+
function clearSchedules({ scheduleAttributes = ['scheduledDate', 'scheduledTime', 'courtOrder'], ignoreMatchUpStatuses = completedMatchUpStatuses, tournamentRecord, scheduledDates, venueIds = [], }) {
|
|
46711
46721
|
if (typeof tournamentRecord !== 'object')
|
|
46712
46722
|
return { error: MISSING_TOURNAMENT_RECORD };
|
|
46713
46723
|
if (!Array.isArray(ignoreMatchUpStatuses) || !Array.isArray(venueIds)) {
|
|
@@ -46738,7 +46748,7 @@ function clearSchedules({ scheduleAttributes = ['scheduledDate', 'scheduledTime'
|
|
|
46738
46748
|
let modified = false;
|
|
46739
46749
|
matchUp.timeItems = (matchUp.timeItems ?? []).filter((timeItem) => {
|
|
46740
46750
|
const preserve = timeItem?.itemType &&
|
|
46741
|
-
![ALLOCATE_COURTS, ASSIGN_COURT, ASSIGN_VENUE, SCHEDULED_DATE, SCHEDULED_TIME].includes(timeItem?.itemType);
|
|
46751
|
+
![ALLOCATE_COURTS, ASSIGN_COURT, ASSIGN_VENUE, COURT_ORDER, SCHEDULED_DATE, SCHEDULED_TIME].includes(timeItem?.itemType);
|
|
46742
46752
|
if (!preserve)
|
|
46743
46753
|
modified = true;
|
|
46744
46754
|
return preserve;
|