tods-competition-factory 1.7.5 → 1.7.7
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 +41 -16
- package/dist/forge/generate.mjs.map +1 -1
- package/dist/forge/query.mjs +22 -14
- package/dist/forge/query.mjs.map +1 -1
- package/dist/forge/transform.mjs +22 -14
- package/dist/forge/transform.mjs.map +1 -1
- package/dist/forge/utilities.mjs.map +1 -1
- package/dist/index.mjs +247 -81
- package/dist/index.mjs.map +1 -1
- package/dist/tods-competition-factory.development.cjs.js +275 -87
- 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
package/dist/forge/generate.mjs
CHANGED
|
@@ -1349,7 +1349,8 @@ const WIN_RATIO$1 = "winRatio";
|
|
|
1349
1349
|
|
|
1350
1350
|
const add = (a, b) => (a || 0) + (b || 0);
|
|
1351
1351
|
function getBand(spread, bandProfiles) {
|
|
1352
|
-
|
|
1352
|
+
const spreadValue = Array.isArray(spread) ? spread[0] : spread;
|
|
1353
|
+
return isNaN(spreadValue) && WALKOVER || spreadValue <= bandProfiles[DECISIVE] && DECISIVE || spreadValue <= bandProfiles[ROUTINE] && ROUTINE || COMPETITIVE;
|
|
1353
1354
|
}
|
|
1354
1355
|
function getScoreComponents({ score }) {
|
|
1355
1356
|
const sets = score?.sets || [];
|
|
@@ -1380,7 +1381,7 @@ function gamesPercent(scoreComponents) {
|
|
|
1380
1381
|
return Math.round(minGames / maxGames * 100);
|
|
1381
1382
|
}
|
|
1382
1383
|
function pctSpread(pcts) {
|
|
1383
|
-
return pcts.map(gamesPercent).sort().map((p) => p.toFixed(2));
|
|
1384
|
+
return pcts.map(gamesPercent).sort().map((p) => parseFloat(p.toFixed(2)));
|
|
1384
1385
|
}
|
|
1385
1386
|
|
|
1386
1387
|
function findPolicy({
|
|
@@ -1407,6 +1408,7 @@ const POLICY_TYPE_MATCHUP_ACTIONS = "matchUpActions";
|
|
|
1407
1408
|
const POLICY_TYPE_ROUND_NAMING = "roundNaming";
|
|
1408
1409
|
const POLICY_TYPE_PARTICIPANT = "participant";
|
|
1409
1410
|
const POLICY_TYPE_SCHEDULING = "scheduling";
|
|
1411
|
+
const POLICY_TYPE_DISPLAY = "display";
|
|
1410
1412
|
const POLICY_TYPE_SCORING = "scoring";
|
|
1411
1413
|
const POLICY_TYPE_SEEDING = "seeding";
|
|
1412
1414
|
const POLICY_TYPE_FEED_IN = "feedIn";
|
|
@@ -1415,15 +1417,15 @@ const POLICY_TYPE_DRAWS = "draws";
|
|
|
1415
1417
|
const POLICY_COMPETITIVE_BANDS_DEFAULT = {
|
|
1416
1418
|
[POLICY_TYPE_COMPETITIVE_BANDS]: {
|
|
1417
1419
|
policyName: "Competitive Bands Default",
|
|
1418
|
-
|
|
1420
|
+
profileBands: {
|
|
1419
1421
|
[DECISIVE]: 20,
|
|
1420
1422
|
[ROUTINE]: 50
|
|
1421
1423
|
}
|
|
1422
1424
|
}
|
|
1423
1425
|
};
|
|
1424
1426
|
|
|
1425
|
-
function
|
|
1426
|
-
|
|
1427
|
+
function getMatchUpCompetitiveProfile({
|
|
1428
|
+
profileBands,
|
|
1427
1429
|
tournamentRecord,
|
|
1428
1430
|
matchUp
|
|
1429
1431
|
}) {
|
|
@@ -1432,15 +1434,16 @@ function getMatchUpCompetitiveness({
|
|
|
1432
1434
|
const { score, winningSide } = matchUp;
|
|
1433
1435
|
if (!winningSide)
|
|
1434
1436
|
return { error: INVALID_VALUES };
|
|
1435
|
-
const policy = !
|
|
1437
|
+
const policy = !profileBands && tournamentRecord && findPolicy({
|
|
1436
1438
|
policyType: POLICY_TYPE_COMPETITIVE_BANDS,
|
|
1437
1439
|
tournamentRecord
|
|
1438
1440
|
}).policy;
|
|
1439
|
-
const bandProfiles =
|
|
1441
|
+
const bandProfiles = profileBands || policy?.profileBands || POLICY_COMPETITIVE_BANDS_DEFAULT[POLICY_TYPE_COMPETITIVE_BANDS].profileBands;
|
|
1440
1442
|
const scoreComponents = getScoreComponents({ score });
|
|
1441
1443
|
const spread = pctSpread([scoreComponents]);
|
|
1442
1444
|
const competitiveness = getBand(spread, bandProfiles);
|
|
1443
|
-
|
|
1445
|
+
const pctSpreadValue = Array.isArray(spread) ? spread[0] : spread;
|
|
1446
|
+
return { ...SUCCESS, competitiveness, pctSpread: pctSpreadValue };
|
|
1444
1447
|
}
|
|
1445
1448
|
|
|
1446
1449
|
function findMatchupFormatAverageTimes(params) {
|
|
@@ -4259,6 +4262,9 @@ function isAdHoc({ drawDefinition, structure }) {
|
|
|
4259
4262
|
const POLICY_ROUND_NAMING_DEFAULT = {
|
|
4260
4263
|
[POLICY_TYPE_ROUND_NAMING]: {
|
|
4261
4264
|
policyName: "Round Naming Default",
|
|
4265
|
+
namingConventions: {
|
|
4266
|
+
round: "Round"
|
|
4267
|
+
},
|
|
4262
4268
|
abbreviatedRoundNamingMap: {
|
|
4263
4269
|
// key is matchUpsCount for the round
|
|
4264
4270
|
1: "F",
|
|
@@ -4298,6 +4304,9 @@ function getRoundContextProfile({
|
|
|
4298
4304
|
const roundNamingMap = roundNamingPolicy?.roundNamingMap || defaultRoundNamingPolicy.roundNamingMap || {};
|
|
4299
4305
|
const abbreviatedRoundNamingMap = roundNamingPolicy?.abbreviatedRoundNamingMap || defaultRoundNamingPolicy.abbreviatedRoundNamingMap || {};
|
|
4300
4306
|
const roundNamePrefix = roundNamingPolicy?.affixes || defaultRoundNamingPolicy.affixes;
|
|
4307
|
+
const roundNumberAffix = roundNamePrefix.roundNumber || defaultRoundNamingPolicy.affixes.roundNumber;
|
|
4308
|
+
const namingConventions = roundNamingPolicy?.namingConventions || defaultRoundNamingPolicy.namingConventions;
|
|
4309
|
+
const roundNameFallback = namingConventions.round;
|
|
4301
4310
|
const stageInitial = stage && stage !== MAIN && stage[0];
|
|
4302
4311
|
const stageConstants = roundNamingPolicy?.stageConstants;
|
|
4303
4312
|
const stageConstant = stage && stageConstants?.[stage] || stageInitial;
|
|
@@ -4306,8 +4315,8 @@ function getRoundContextProfile({
|
|
|
4306
4315
|
Object.assign(
|
|
4307
4316
|
roundNamingProfile,
|
|
4308
4317
|
...roundProfileKeys.map((key) => {
|
|
4309
|
-
const roundName =
|
|
4310
|
-
const abbreviatedRoundName =
|
|
4318
|
+
const roundName = `${roundNameFallback} ${key}`;
|
|
4319
|
+
const abbreviatedRoundName = `${roundNumberAffix}${key}`;
|
|
4311
4320
|
return { [key]: { roundName, abbreviatedRoundName } };
|
|
4312
4321
|
})
|
|
4313
4322
|
);
|
|
@@ -4654,7 +4663,7 @@ function getAllStructureMatchUps({
|
|
|
4654
4663
|
...collectionDefinition.category
|
|
4655
4664
|
} : context?.category;
|
|
4656
4665
|
const processCodes = matchUp.processCodes?.length && matchUp.processCodes || collectionDefinition?.processCodes?.length && collectionDefinition?.processCodes || structure?.processCodes?.length && structure?.processCodes || drawDefinition?.processCodes?.length && drawDefinition?.processCodes || event2?.processCodes?.length && event2?.processCodes || tournamentRecord?.processCodes;
|
|
4657
|
-
const
|
|
4666
|
+
const competitiveProfile = contextProfile?.withCompetitiveness && getMatchUpCompetitiveProfile({ ...contextContent, matchUp });
|
|
4658
4667
|
const finishingPositionRange = matchUp.finishingPositionRange || additionalContext.finishingPositionRange;
|
|
4659
4668
|
const onlyDefined = (obj) => definedAttributes(obj, void 0, true);
|
|
4660
4669
|
const matchUpWithContext = {
|
|
@@ -4670,7 +4679,7 @@ function getAllStructureMatchUps({
|
|
|
4670
4679
|
finishingPositionRange,
|
|
4671
4680
|
abbreviatedRoundName,
|
|
4672
4681
|
drawPositionsRange,
|
|
4673
|
-
|
|
4682
|
+
competitiveProfile,
|
|
4674
4683
|
structureName,
|
|
4675
4684
|
stageSequence,
|
|
4676
4685
|
drawPositions,
|
|
@@ -19746,6 +19755,10 @@ function addAdHocMatchUps({
|
|
|
19746
19755
|
return { ...SUCCESS };
|
|
19747
19756
|
}
|
|
19748
19757
|
|
|
19758
|
+
function stringSort(a, b) {
|
|
19759
|
+
return (a || "").localeCompare(b || "");
|
|
19760
|
+
}
|
|
19761
|
+
|
|
19749
19762
|
function generateCandidate({
|
|
19750
19763
|
maxIterations = 4e3,
|
|
19751
19764
|
// cap the processing intensity of the candidate generator
|
|
@@ -19880,7 +19893,7 @@ function roundCandidate({
|
|
|
19880
19893
|
return { value: candidateValue, participantIdPairings, maxDelta, maxDiff };
|
|
19881
19894
|
}
|
|
19882
19895
|
function pairingHash(id1, id2) {
|
|
19883
|
-
return [id1, id2].sort().join("|");
|
|
19896
|
+
return [id1, id2].sort(stringSort).join("|");
|
|
19884
19897
|
}
|
|
19885
19898
|
|
|
19886
19899
|
function getPairingsData({ participantIds }) {
|
|
@@ -19945,13 +19958,19 @@ const UTR = "UTR";
|
|
|
19945
19958
|
const WTN = "WTN";
|
|
19946
19959
|
|
|
19947
19960
|
const ratingsParameters = {
|
|
19948
|
-
[ELO]: {
|
|
19961
|
+
[ELO]: {
|
|
19962
|
+
defaultInitialization: 1500,
|
|
19963
|
+
decimalsCount: 0,
|
|
19964
|
+
range: [0, 3e3],
|
|
19965
|
+
ascending: true
|
|
19966
|
+
},
|
|
19949
19967
|
[NTRP]: {
|
|
19950
19968
|
accessors: ["ntrpRating", "dntrpRatingHundredths"],
|
|
19951
19969
|
attributes: { ustaRatingType: "" },
|
|
19952
19970
|
accessor: "dntrpRatingHundredths",
|
|
19953
19971
|
defaultInitialization: 3,
|
|
19954
19972
|
decimalsCount: 1,
|
|
19973
|
+
ascending: true,
|
|
19955
19974
|
range: [1, 7]
|
|
19956
19975
|
},
|
|
19957
19976
|
[UTR]: {
|
|
@@ -19959,6 +19978,7 @@ const ratingsParameters = {
|
|
|
19959
19978
|
accessors: ["utrRating"],
|
|
19960
19979
|
accessor: "utrRating",
|
|
19961
19980
|
decimalsCount: 2,
|
|
19981
|
+
ascending: true,
|
|
19962
19982
|
range: [1, 16]
|
|
19963
19983
|
},
|
|
19964
19984
|
[WTN]: {
|
|
@@ -19966,6 +19986,7 @@ const ratingsParameters = {
|
|
|
19966
19986
|
accessors: ["wtnRating", "confidence"],
|
|
19967
19987
|
defaultInitialization: 23,
|
|
19968
19988
|
accessor: "wtnRating",
|
|
19989
|
+
ascending: false,
|
|
19969
19990
|
decimalsCount: 2,
|
|
19970
19991
|
range: [40, 1]
|
|
19971
19992
|
}
|
|
@@ -20983,7 +21004,10 @@ function addDrawDefinition(params) {
|
|
|
20983
21004
|
return { ...SUCCESS, modifiedEventEntryStatusCount };
|
|
20984
21005
|
}
|
|
20985
21006
|
|
|
20986
|
-
function attachPolicies({
|
|
21007
|
+
function attachPolicies({
|
|
21008
|
+
drawDefinition,
|
|
21009
|
+
policyDefinitions
|
|
21010
|
+
}) {
|
|
20987
21011
|
if (!drawDefinition) {
|
|
20988
21012
|
return { error: MISSING_DRAW_DEFINITION };
|
|
20989
21013
|
}
|
|
@@ -20993,8 +21017,9 @@ function attachPolicies({ drawDefinition, policyDefinitions }) {
|
|
|
20993
21017
|
if (!drawDefinition.extensions)
|
|
20994
21018
|
drawDefinition.extensions = [];
|
|
20995
21019
|
const appliedPolicies = getAppliedPolicies({ drawDefinition })?.appliedPolicies ?? {};
|
|
21020
|
+
const validReplacements = [POLICY_TYPE_ROUND_NAMING, POLICY_TYPE_DISPLAY];
|
|
20996
21021
|
const applied = Object.keys(policyDefinitions).every((policyType) => {
|
|
20997
|
-
if (!appliedPolicies[policyType]) {
|
|
21022
|
+
if (!appliedPolicies[policyType] || validReplacements.includes(policyType)) {
|
|
20998
21023
|
appliedPolicies[policyType] = policyDefinitions[policyType];
|
|
20999
21024
|
return true;
|
|
21000
21025
|
} else {
|