tods-competition-factory 1.7.7 → 1.7.9
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 +26 -1
- package/dist/forge/generate.mjs +215 -167
- package/dist/forge/generate.mjs.map +1 -1
- package/dist/forge/query.mjs +139 -138
- package/dist/forge/query.mjs.map +1 -1
- package/dist/forge/transform.mjs +139 -88
- package/dist/forge/transform.mjs.map +1 -1
- package/dist/forge/utilities.d.ts +3 -2
- package/dist/forge/utilities.mjs +142 -76
- package/dist/forge/utilities.mjs.map +1 -1
- package/dist/index.mjs +335 -198
- package/dist/index.mjs.map +1 -1
- package/dist/tods-competition-factory.development.cjs.js +441 -311
- 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.d.ts
CHANGED
|
@@ -1276,6 +1276,28 @@ interface UnifiedVenueID {
|
|
|
1276
1276
|
venueId: string;
|
|
1277
1277
|
}
|
|
1278
1278
|
|
|
1279
|
+
/**
|
|
1280
|
+
*
|
|
1281
|
+
* @param {object} playoffAttributes - mapping of exitProfile to structure names, e.g. 0-1-1 for SOUTH
|
|
1282
|
+
* @param {string} playoffStructureNameBase - Root word for default playoff naming, e.g. 'Playoff' for 'Playoff 3-4'
|
|
1283
|
+
* @param {string} exitProfile - rounds at which a participant exited each structure, e.g. 0-1-1-1 for losing EAST, WEST, SOUTH
|
|
1284
|
+
* @param {boolean} exitProfileLimit - limit playoff rounds generated by the attributes present in playoffAttributes
|
|
1285
|
+
* @param {number} finishingPositionOffset - amount by which to offset finishingPositions, e.g. 2 for playing off 3-4
|
|
1286
|
+
* @param {number} finishingPositionLimit - highest value of possible finishing Positions to play off
|
|
1287
|
+
* @param {object} finishingPositionNaming - map of { [finishingPositionRange]: customName }
|
|
1288
|
+
* @param {number} roundOffsetLimit - how many rounds to play off (# of additional matchUps per participant)
|
|
1289
|
+
* @param {number} roundOffset - used internally to track generated structures; saved in structure attributes;
|
|
1290
|
+
* @param {number} stageSequence - what sequence within stage structures, e.g. WEST is stageSequence 2 in COMPASS
|
|
1291
|
+
* @param {string} stage - [QUALIFYING, MAIN, CONSOLATION, PLAY-OFF]
|
|
1292
|
+
*
|
|
1293
|
+
*/
|
|
1294
|
+
type NamingEntry = {
|
|
1295
|
+
[key: string]: {
|
|
1296
|
+
name: string;
|
|
1297
|
+
abbreviation: string;
|
|
1298
|
+
};
|
|
1299
|
+
};
|
|
1300
|
+
|
|
1279
1301
|
type HydratedParticipant = {
|
|
1280
1302
|
[key: string | number]: any;
|
|
1281
1303
|
} & Participant;
|
|
@@ -1349,13 +1371,16 @@ type RoundProfile = {
|
|
|
1349
1371
|
|
|
1350
1372
|
type GenerateAndPopulateArgs = {
|
|
1351
1373
|
addNameBaseToAttributeName?: boolean;
|
|
1374
|
+
finishingPositionNaming?: NamingEntry;
|
|
1352
1375
|
playoffStructureNameBase?: string;
|
|
1376
|
+
playoffAttributes?: NamingEntry;
|
|
1377
|
+
finishingPositionLimit?: number;
|
|
1353
1378
|
tournamentRecord?: Tournament;
|
|
1354
1379
|
drawDefinition: DrawDefinition;
|
|
1355
1380
|
roundProfiles?: RoundProfile[];
|
|
1356
1381
|
playoffPositions?: number[];
|
|
1382
|
+
roundOffsetLimit?: number;
|
|
1357
1383
|
exitProfileLimit?: boolean;
|
|
1358
|
-
playoffAttributes?: any;
|
|
1359
1384
|
roundNumbers?: number[];
|
|
1360
1385
|
structureId: string;
|
|
1361
1386
|
idPrefix?: string;
|
package/dist/forge/generate.mjs
CHANGED
|
@@ -503,6 +503,10 @@ const INVALID_STAGE = {
|
|
|
503
503
|
message: "Invalid stage",
|
|
504
504
|
code: "ERR_INVALID_STAGE"
|
|
505
505
|
};
|
|
506
|
+
const STAGE_SEQUENCE_LIMIT = {
|
|
507
|
+
message: "stageSequence limit",
|
|
508
|
+
code: "ERR_LIMIT_STAGE_SEQUENCE"
|
|
509
|
+
};
|
|
506
510
|
const MISSING_POSITION_ASSIGNMENTS = {
|
|
507
511
|
message: "Missing positionAssignments",
|
|
508
512
|
code: "ERR_MISSING_POSITION_ASSIGNMENTS"
|
|
@@ -724,6 +728,10 @@ const EXISTING_STAGE = {
|
|
|
724
728
|
message: "Existing stage",
|
|
725
729
|
code: "ERR_EXISTING_STAGE"
|
|
726
730
|
};
|
|
731
|
+
const EXISTING_STRUCTURE = {
|
|
732
|
+
message: "Existing structure",
|
|
733
|
+
code: "ERR_EXISTING_STRUCTURE"
|
|
734
|
+
};
|
|
727
735
|
|
|
728
736
|
const syncGlobalState = {
|
|
729
737
|
disableNotifications: false,
|
|
@@ -926,93 +934,6 @@ function getTopics() {
|
|
|
926
934
|
return _globalStateProvider.getTopics();
|
|
927
935
|
}
|
|
928
936
|
|
|
929
|
-
function isObject(obj) {
|
|
930
|
-
return typeof obj === "object";
|
|
931
|
-
}
|
|
932
|
-
const extractAttributes = (atz) => (o) => !atz || typeof o !== "object" ? void 0 : Array.isArray(atz) && atz.map((a) => ({ [a]: o[a] })) || typeof atz === "object" && Object.keys(atz).map((key) => ({ [key]: o[key] })) || typeof atz === "string" && getAttr(o, atz);
|
|
933
|
-
function getAttr(o, attr) {
|
|
934
|
-
const attrs = attr.split(".");
|
|
935
|
-
for (const a of attrs) {
|
|
936
|
-
o = o?.[a];
|
|
937
|
-
if (!o)
|
|
938
|
-
return;
|
|
939
|
-
}
|
|
940
|
-
return o;
|
|
941
|
-
}
|
|
942
|
-
function definedAttributes(obj, ignoreFalse, ignoreEmptyArrays, shallow) {
|
|
943
|
-
if (typeof obj !== "object" || obj === null)
|
|
944
|
-
return obj;
|
|
945
|
-
const deepCopy = deepCopyEnabled();
|
|
946
|
-
if (!deepCopy?.enabled)
|
|
947
|
-
shallow = true;
|
|
948
|
-
const ignoreValues = ["", void 0, null];
|
|
949
|
-
if (ignoreFalse)
|
|
950
|
-
ignoreValues.push(false);
|
|
951
|
-
const definedKeys = Object.keys(obj).filter(
|
|
952
|
-
(key) => !ignoreValues.includes(obj[key]) && (!ignoreEmptyArrays || (Array.isArray(obj[key]) ? obj[key].length : true))
|
|
953
|
-
);
|
|
954
|
-
return Object.assign(
|
|
955
|
-
{},
|
|
956
|
-
...definedKeys.map((key) => {
|
|
957
|
-
return Array.isArray(obj[key]) ? {
|
|
958
|
-
[key]: shallow ? obj[key] : obj[key].map((m) => definedAttributes(m))
|
|
959
|
-
} : { [key]: shallow ? obj[key] : definedAttributes(obj[key]) };
|
|
960
|
-
})
|
|
961
|
-
);
|
|
962
|
-
}
|
|
963
|
-
|
|
964
|
-
function attributeFilter(params) {
|
|
965
|
-
if (params === null)
|
|
966
|
-
return {};
|
|
967
|
-
const { source, template } = params || {};
|
|
968
|
-
if (!template)
|
|
969
|
-
return source;
|
|
970
|
-
const target = {};
|
|
971
|
-
attributeCopy(source, template, target);
|
|
972
|
-
return target;
|
|
973
|
-
function attributeCopy(valuesObject, templateObject, outputObject) {
|
|
974
|
-
if (!valuesObject || !templateObject)
|
|
975
|
-
return void 0;
|
|
976
|
-
const vKeys = Object.keys(valuesObject);
|
|
977
|
-
const oKeys = Object.keys(templateObject);
|
|
978
|
-
const orMap = Object.assign(
|
|
979
|
-
{},
|
|
980
|
-
...oKeys.filter((key) => key.indexOf("||")).map((key) => key.split("||").map((or) => ({ [or]: key }))).flat()
|
|
981
|
-
);
|
|
982
|
-
const allKeys = oKeys.concat(...Object.keys(orMap));
|
|
983
|
-
const wildcard = allKeys.includes("*");
|
|
984
|
-
for (const vKey of vKeys) {
|
|
985
|
-
if (allKeys.indexOf(vKey) >= 0 || wildcard) {
|
|
986
|
-
const templateKey = orMap[vKey] || vKey;
|
|
987
|
-
const tobj = templateObject[templateKey] || wildcard;
|
|
988
|
-
const vobj = valuesObject[vKey];
|
|
989
|
-
if (typeof tobj === "object" && typeof vobj !== "function" && !Array.isArray(tobj)) {
|
|
990
|
-
if (Array.isArray(vobj)) {
|
|
991
|
-
const mappedElements = vobj.map((arrayMember) => {
|
|
992
|
-
const target2 = {};
|
|
993
|
-
const result = attributeCopy(arrayMember, tobj, target2);
|
|
994
|
-
return result !== false ? target2 : void 0;
|
|
995
|
-
}).filter(Boolean);
|
|
996
|
-
outputObject[vKey] = mappedElements;
|
|
997
|
-
} else if (vobj) {
|
|
998
|
-
outputObject[vKey] = {};
|
|
999
|
-
attributeCopy(vobj, tobj, outputObject[vKey]);
|
|
1000
|
-
}
|
|
1001
|
-
} else {
|
|
1002
|
-
const value = valuesObject[vKey];
|
|
1003
|
-
const exclude = Array.isArray(tobj) && !tobj.includes(value);
|
|
1004
|
-
if (exclude)
|
|
1005
|
-
return false;
|
|
1006
|
-
if (templateObject[vKey] || wildcard && templateObject[vKey] !== false) {
|
|
1007
|
-
outputObject[vKey] = value;
|
|
1008
|
-
}
|
|
1009
|
-
}
|
|
1010
|
-
}
|
|
1011
|
-
}
|
|
1012
|
-
return void 0;
|
|
1013
|
-
}
|
|
1014
|
-
}
|
|
1015
|
-
|
|
1016
937
|
const validTimeString = /^((0[\d]|1[\d]|2[0-3]):[0-5][\d](:[0-5][\d])?)([.,][0-9]{3})?$/;
|
|
1017
938
|
const dateValidation = /^([\d]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][\d]|3[0-1]))([ T](0[\d]|1[\d]|2[0-3]):[0-5][\d](:[0-5][\d])?)?([.,][\d]{3})?Z?$/;
|
|
1018
939
|
|
|
@@ -1195,6 +1116,147 @@ function extensionsToAttributes(extensions) {
|
|
|
1195
1116
|
}).filter(Boolean);
|
|
1196
1117
|
}
|
|
1197
1118
|
|
|
1119
|
+
function getAccessorValue({ element, accessor }) {
|
|
1120
|
+
if (typeof accessor !== "string")
|
|
1121
|
+
return { values: [] };
|
|
1122
|
+
const targetElement = makeDeepCopy(element);
|
|
1123
|
+
const attributes = accessor.split(".");
|
|
1124
|
+
const values = [];
|
|
1125
|
+
let value;
|
|
1126
|
+
processKeys({ targetElement, attributes });
|
|
1127
|
+
const result = { value };
|
|
1128
|
+
if (values.length)
|
|
1129
|
+
result.values = values;
|
|
1130
|
+
return result;
|
|
1131
|
+
function processKeys({
|
|
1132
|
+
targetElement: targetElement2,
|
|
1133
|
+
attributes: attributes2 = [],
|
|
1134
|
+
significantCharacters
|
|
1135
|
+
}) {
|
|
1136
|
+
for (const [index, attribute] of attributes2.entries()) {
|
|
1137
|
+
if (targetElement2?.[attribute]) {
|
|
1138
|
+
const remainingKeys = attributes2.slice(index + 1);
|
|
1139
|
+
if (!remainingKeys.length) {
|
|
1140
|
+
if (!value)
|
|
1141
|
+
value = targetElement2[attribute];
|
|
1142
|
+
if (!values.includes(targetElement2[attribute])) {
|
|
1143
|
+
values.push(targetElement2[attribute]);
|
|
1144
|
+
}
|
|
1145
|
+
} else if (Array.isArray(targetElement2[attribute])) {
|
|
1146
|
+
const values2 = targetElement2[attribute];
|
|
1147
|
+
values2.forEach(
|
|
1148
|
+
(nestedTarget) => processKeys({
|
|
1149
|
+
targetElement: nestedTarget,
|
|
1150
|
+
attributes: remainingKeys
|
|
1151
|
+
})
|
|
1152
|
+
);
|
|
1153
|
+
} else {
|
|
1154
|
+
targetElement2 = targetElement2[attribute];
|
|
1155
|
+
checkValue({ targetElement: targetElement2, index });
|
|
1156
|
+
}
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
function checkValue({ targetElement: targetElement3, index }) {
|
|
1160
|
+
if (targetElement3 && index === attributes2.length - 1 && ["string", "number"].includes(typeof targetElement3)) {
|
|
1161
|
+
const extractedValue = significantCharacters ? targetElement3.slice(0, significantCharacters) : targetElement3;
|
|
1162
|
+
if (value) {
|
|
1163
|
+
if (!values.includes(extractedValue)) {
|
|
1164
|
+
values.push(extractedValue);
|
|
1165
|
+
}
|
|
1166
|
+
} else {
|
|
1167
|
+
value = extractedValue;
|
|
1168
|
+
values.push(extractedValue);
|
|
1169
|
+
}
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
|
|
1175
|
+
function isString(obj) {
|
|
1176
|
+
return typeof obj === "string";
|
|
1177
|
+
}
|
|
1178
|
+
function isObject(obj) {
|
|
1179
|
+
return typeof obj === "object";
|
|
1180
|
+
}
|
|
1181
|
+
const extractAttributes = (accessor) => (element) => !accessor || typeof element !== "object" ? void 0 : Array.isArray(accessor) && accessor.map((a) => ({
|
|
1182
|
+
[a]: getAccessorValue({ element, accessor: a })?.value
|
|
1183
|
+
})) || typeof accessor === "object" && Object.keys(accessor).map((key) => ({
|
|
1184
|
+
[key]: getAccessorValue({ element, accessor: key })?.value
|
|
1185
|
+
})) || (typeof accessor === "string" && getAccessorValue({ element, accessor }))?.value;
|
|
1186
|
+
function definedAttributes(obj, ignoreFalse, ignoreEmptyArrays, shallow) {
|
|
1187
|
+
if (typeof obj !== "object" || obj === null)
|
|
1188
|
+
return obj;
|
|
1189
|
+
const deepCopy = deepCopyEnabled();
|
|
1190
|
+
if (!deepCopy?.enabled)
|
|
1191
|
+
shallow = true;
|
|
1192
|
+
const ignoreValues = ["", void 0, null];
|
|
1193
|
+
if (ignoreFalse)
|
|
1194
|
+
ignoreValues.push(false);
|
|
1195
|
+
const definedKeys = Object.keys(obj).filter(
|
|
1196
|
+
(key) => !ignoreValues.includes(obj[key]) && (!ignoreEmptyArrays || (Array.isArray(obj[key]) ? obj[key].length : true))
|
|
1197
|
+
);
|
|
1198
|
+
return Object.assign(
|
|
1199
|
+
{},
|
|
1200
|
+
...definedKeys.map((key) => {
|
|
1201
|
+
return Array.isArray(obj[key]) ? {
|
|
1202
|
+
[key]: shallow ? obj[key] : obj[key].map((m) => definedAttributes(m))
|
|
1203
|
+
} : { [key]: shallow ? obj[key] : definedAttributes(obj[key]) };
|
|
1204
|
+
})
|
|
1205
|
+
);
|
|
1206
|
+
}
|
|
1207
|
+
|
|
1208
|
+
function attributeFilter(params) {
|
|
1209
|
+
if (params === null)
|
|
1210
|
+
return {};
|
|
1211
|
+
const { source, template } = params || {};
|
|
1212
|
+
if (!template)
|
|
1213
|
+
return source;
|
|
1214
|
+
const target = {};
|
|
1215
|
+
attributeCopy(source, template, target);
|
|
1216
|
+
return target;
|
|
1217
|
+
function attributeCopy(valuesObject, templateObject, outputObject) {
|
|
1218
|
+
if (!valuesObject || !templateObject)
|
|
1219
|
+
return void 0;
|
|
1220
|
+
const vKeys = Object.keys(valuesObject);
|
|
1221
|
+
const oKeys = Object.keys(templateObject);
|
|
1222
|
+
const orMap = Object.assign(
|
|
1223
|
+
{},
|
|
1224
|
+
...oKeys.filter((key) => key.indexOf("||")).map((key) => key.split("||").map((or) => ({ [or]: key }))).flat()
|
|
1225
|
+
);
|
|
1226
|
+
const allKeys = oKeys.concat(...Object.keys(orMap));
|
|
1227
|
+
const wildcard = allKeys.includes("*");
|
|
1228
|
+
for (const vKey of vKeys) {
|
|
1229
|
+
if (allKeys.indexOf(vKey) >= 0 || wildcard) {
|
|
1230
|
+
const templateKey = orMap[vKey] || vKey;
|
|
1231
|
+
const tobj = templateObject[templateKey] || wildcard;
|
|
1232
|
+
const vobj = valuesObject[vKey];
|
|
1233
|
+
if (typeof tobj === "object" && typeof vobj !== "function" && !Array.isArray(tobj)) {
|
|
1234
|
+
if (Array.isArray(vobj)) {
|
|
1235
|
+
const mappedElements = vobj.map((arrayMember) => {
|
|
1236
|
+
const target2 = {};
|
|
1237
|
+
const result = attributeCopy(arrayMember, tobj, target2);
|
|
1238
|
+
return result !== false ? target2 : void 0;
|
|
1239
|
+
}).filter(Boolean);
|
|
1240
|
+
outputObject[vKey] = mappedElements;
|
|
1241
|
+
} else if (vobj) {
|
|
1242
|
+
outputObject[vKey] = {};
|
|
1243
|
+
attributeCopy(vobj, tobj, outputObject[vKey]);
|
|
1244
|
+
}
|
|
1245
|
+
} else {
|
|
1246
|
+
const value = valuesObject[vKey];
|
|
1247
|
+
const exclude = Array.isArray(tobj) && !tobj.includes(value);
|
|
1248
|
+
if (exclude)
|
|
1249
|
+
return false;
|
|
1250
|
+
if (templateObject[vKey] || wildcard && templateObject[vKey] !== false) {
|
|
1251
|
+
outputObject[vKey] = value;
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1254
|
+
}
|
|
1255
|
+
}
|
|
1256
|
+
return void 0;
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1259
|
+
|
|
1198
1260
|
function numericSort(a, b) {
|
|
1199
1261
|
return a - b;
|
|
1200
1262
|
}
|
|
@@ -4256,7 +4318,7 @@ function isAdHoc({ drawDefinition, structure }) {
|
|
|
4256
4318
|
const hasDrawPosition = matchUps?.find(
|
|
4257
4319
|
(matchUp) => matchUp?.drawPositions?.length
|
|
4258
4320
|
);
|
|
4259
|
-
return !structure?.structures && !(drawDefinition?.drawType && drawDefinition.drawType !== AD_HOC) && !hasRoundPosition && !hasDrawPosition;
|
|
4321
|
+
return !structure?.structures && structure?.stage !== VOLUNTARY_CONSOLATION && !(drawDefinition?.drawType && drawDefinition.drawType !== AD_HOC) && !hasRoundPosition && !hasDrawPosition;
|
|
4260
4322
|
}
|
|
4261
4323
|
|
|
4262
4324
|
const POLICY_ROUND_NAMING_DEFAULT = {
|
|
@@ -4910,6 +4972,15 @@ function getNumericSeedValue(seedValue) {
|
|
|
4910
4972
|
return Infinity;
|
|
4911
4973
|
}
|
|
4912
4974
|
|
|
4975
|
+
function capitalizeFirst(str) {
|
|
4976
|
+
return !isString(str) ? str : str.split(" ").map(
|
|
4977
|
+
(name) => name.split("").map((c, i) => i ? c.toLowerCase() : c.toUpperCase()).join("")
|
|
4978
|
+
).join(" ");
|
|
4979
|
+
}
|
|
4980
|
+
function constantToString(str) {
|
|
4981
|
+
return !isString(str) ? str : capitalizeFirst(str.replace(/_/g, " "));
|
|
4982
|
+
}
|
|
4983
|
+
|
|
4913
4984
|
const structureTemplate = ({
|
|
4914
4985
|
finishingPosition = ROUND_OUTCOME,
|
|
4915
4986
|
qualifyingRoundNumber,
|
|
@@ -5022,7 +5093,7 @@ function groupRounds({ groupSize, drawPositionOffset }) {
|
|
|
5022
5093
|
}
|
|
5023
5094
|
|
|
5024
5095
|
function generateRoundRobin({
|
|
5025
|
-
structureName = MAIN,
|
|
5096
|
+
structureName = constantToString(MAIN),
|
|
5026
5097
|
stageSequence = 1,
|
|
5027
5098
|
structureOptions,
|
|
5028
5099
|
appliedPolicies,
|
|
@@ -14004,8 +14075,8 @@ function firstRoundLoserConsolation(params) {
|
|
|
14004
14075
|
};
|
|
14005
14076
|
const { matchUps } = staggeredEntry ? feedInMatchUps(mainParams) : treeMatchUps(mainParams);
|
|
14006
14077
|
const mainStructure = structureTemplate({
|
|
14078
|
+
structureName: structureName || constantToString(MAIN),
|
|
14007
14079
|
structureId: structureId || uuids?.pop(),
|
|
14008
|
-
structureName: structureName || MAIN,
|
|
14009
14080
|
stageSequence,
|
|
14010
14081
|
matchUpType,
|
|
14011
14082
|
matchUps,
|
|
@@ -14022,7 +14093,8 @@ function firstRoundLoserConsolation(params) {
|
|
|
14022
14093
|
matchUpType,
|
|
14023
14094
|
isMock
|
|
14024
14095
|
});
|
|
14025
|
-
const
|
|
14096
|
+
const consolation = constantToString(CONSOLATION);
|
|
14097
|
+
const consolationStructureName = params.consolationStructureName || (structureName ? `${structureName} ${consolation}` : consolation);
|
|
14026
14098
|
const consolationStructure = structureTemplate({
|
|
14027
14099
|
structureName: consolationStructureName,
|
|
14028
14100
|
matchUps: consolationMatchUps,
|
|
@@ -14100,8 +14172,9 @@ function feedInLinks({
|
|
|
14100
14172
|
|
|
14101
14173
|
function generateCurtisConsolation(params) {
|
|
14102
14174
|
const {
|
|
14175
|
+
structureName = constantToString(MAIN),
|
|
14176
|
+
playoffStructureNameBase,
|
|
14103
14177
|
finishingPositionOffset,
|
|
14104
|
-
structureName = MAIN,
|
|
14105
14178
|
stageSequence = 1,
|
|
14106
14179
|
structureNameMap,
|
|
14107
14180
|
staggeredEntry,
|
|
@@ -14139,6 +14212,7 @@ function generateCurtisConsolation(params) {
|
|
|
14139
14212
|
const { consolationStructure } = consolationFeedStructure({
|
|
14140
14213
|
idPrefix: idPrefix && `${idPrefix}-c${index}`,
|
|
14141
14214
|
structureId: uuids?.pop(),
|
|
14215
|
+
playoffStructureNameBase,
|
|
14142
14216
|
structureNameMap,
|
|
14143
14217
|
stageSequence: stageSequence2,
|
|
14144
14218
|
roundOffset,
|
|
@@ -14167,12 +14241,15 @@ function generateCurtisConsolation(params) {
|
|
|
14167
14241
|
matchUpType,
|
|
14168
14242
|
isMock
|
|
14169
14243
|
});
|
|
14244
|
+
const defaultName = constantToString(PLAY_OFF);
|
|
14245
|
+
const mappedStructureName = structureNameMap?.[defaultName] || defaultName;
|
|
14246
|
+
const structureName2 = playoffStructureNameBase ? `${playoffStructureNameBase} ${mappedStructureName}` : mappedStructureName;
|
|
14170
14247
|
const playoffStructure = structureTemplate({
|
|
14171
|
-
structureName: structureNameMap?.[PLAY_OFF] || PLAY_OFF,
|
|
14172
14248
|
structureId: uuids?.pop(),
|
|
14173
14249
|
matchUps: playoffMatchUps,
|
|
14174
14250
|
stageSequence: 2,
|
|
14175
14251
|
stage: PLAY_OFF,
|
|
14252
|
+
structureName: structureName2,
|
|
14176
14253
|
matchUpType
|
|
14177
14254
|
});
|
|
14178
14255
|
const playoffLink = {
|
|
@@ -14194,6 +14271,7 @@ function generateCurtisConsolation(params) {
|
|
|
14194
14271
|
return { structures, links, ...SUCCESS };
|
|
14195
14272
|
}
|
|
14196
14273
|
function consolationFeedStructure({
|
|
14274
|
+
playoffStructureNameBase,
|
|
14197
14275
|
stageSequence = 1,
|
|
14198
14276
|
structureNameMap,
|
|
14199
14277
|
roundOffset = 0,
|
|
@@ -14216,8 +14294,9 @@ function consolationFeedStructure({
|
|
|
14216
14294
|
isMock,
|
|
14217
14295
|
uuids
|
|
14218
14296
|
});
|
|
14219
|
-
const defaultName = `${CONSOLATION} ${index + 1}`;
|
|
14220
|
-
const
|
|
14297
|
+
const defaultName = `${constantToString(CONSOLATION)} ${index + 1}`;
|
|
14298
|
+
const mappedStructureName = structureNameMap?.[defaultName] || defaultName;
|
|
14299
|
+
const structureName = playoffStructureNameBase ? `${playoffStructureNameBase} ${mappedStructureName}` : mappedStructureName;
|
|
14221
14300
|
const consolationStructure = structureTemplate({
|
|
14222
14301
|
matchUps: consolationMatchUps,
|
|
14223
14302
|
stage: CONSOLATION,
|
|
@@ -14230,7 +14309,6 @@ function consolationFeedStructure({
|
|
|
14230
14309
|
}
|
|
14231
14310
|
|
|
14232
14311
|
function generatePlayoffStructures(params) {
|
|
14233
|
-
let { matchUpType } = params;
|
|
14234
14312
|
const {
|
|
14235
14313
|
finishingPositionOffset = 0,
|
|
14236
14314
|
addNameBaseToAttributeName,
|
|
@@ -14260,7 +14338,7 @@ function generatePlayoffStructures(params) {
|
|
|
14260
14338
|
const allMatchUps = [];
|
|
14261
14339
|
const structures = [];
|
|
14262
14340
|
const links = [];
|
|
14263
|
-
matchUpType = matchUpType || drawDefinition?.matchUpType;
|
|
14341
|
+
const matchUpType = params.matchUpType || drawDefinition?.matchUpType;
|
|
14264
14342
|
const finishingPositionsFrom = finishingPositionOffset + 1;
|
|
14265
14343
|
const finishingPositionsTo = finishingPositionOffset + drawSize;
|
|
14266
14344
|
const finishingPositionRange = `${finishingPositionsFrom}-${finishingPositionsTo}`;
|
|
@@ -14310,7 +14388,7 @@ function generatePlayoffStructures(params) {
|
|
|
14310
14388
|
if (playoffDrawPositions < 2)
|
|
14311
14389
|
return;
|
|
14312
14390
|
const childFinishingPositionOffset = drawSize / Math.pow(2, roundNumber) + finishingPositionOffset;
|
|
14313
|
-
if (childFinishingPositionOffset + 1 > finishingPositionLimit)
|
|
14391
|
+
if (finishingPositionLimit && childFinishingPositionOffset + 1 > finishingPositionLimit)
|
|
14314
14392
|
return;
|
|
14315
14393
|
const {
|
|
14316
14394
|
structures: childStructures,
|
|
@@ -14398,8 +14476,8 @@ function feedInChampionship(params) {
|
|
|
14398
14476
|
};
|
|
14399
14477
|
const { matchUps } = staggeredEntry ? feedInMatchUps(mainParams) : treeMatchUps(mainParams);
|
|
14400
14478
|
const mainStructure = structureTemplate({
|
|
14479
|
+
structureName: structureName || constantToString(MAIN),
|
|
14401
14480
|
structureId: structureId || uuids?.pop(),
|
|
14402
|
-
structureName: structureName || MAIN,
|
|
14403
14481
|
stageSequence,
|
|
14404
14482
|
matchUpType,
|
|
14405
14483
|
matchUps,
|
|
@@ -14423,9 +14501,9 @@ function feedInChampionship(params) {
|
|
|
14423
14501
|
});
|
|
14424
14502
|
if (drawSize > 2) {
|
|
14425
14503
|
const consolationStructure = structureTemplate({
|
|
14504
|
+
structureName: constantToString(CONSOLATION),
|
|
14426
14505
|
matchUps: consolationMatchUps,
|
|
14427
14506
|
structureId: uuids?.pop(),
|
|
14428
|
-
structureName: CONSOLATION,
|
|
14429
14507
|
stage: CONSOLATION,
|
|
14430
14508
|
stageSequence: 1,
|
|
14431
14509
|
matchUpType
|
|
@@ -14500,10 +14578,19 @@ function processPlayoffGroups({
|
|
|
14500
14578
|
if (positionsPlayedOff) {
|
|
14501
14579
|
finishingPositionOffset = Math.min(...positionsPlayedOff) - 1;
|
|
14502
14580
|
}
|
|
14503
|
-
const
|
|
14581
|
+
const playoffGroupParams = {
|
|
14582
|
+
addNameBaseToAttributeName: playoffGroup.addNameBaseToAttributeName,
|
|
14583
|
+
playoffStructureNameBase: playoffGroup.playoffStructureNameBase,
|
|
14584
|
+
finishingPositionNaming: playoffGroup.finishingPositionNaming,
|
|
14585
|
+
finishingPositionLimit: playoffGroup.finishingPositionLimit,
|
|
14504
14586
|
structureId: playoffGroup.structureId ?? uuids?.pop(),
|
|
14587
|
+
playoffAttributes: playoffGroup.playoffAttributes,
|
|
14505
14588
|
structureNameMap: playoffGroup.structureNameMap,
|
|
14506
14589
|
structureName: playoffGroup.structureName,
|
|
14590
|
+
sequenceLimit: playoffGroup.sequenceLimit
|
|
14591
|
+
};
|
|
14592
|
+
const params = {
|
|
14593
|
+
...playoffGroupParams,
|
|
14507
14594
|
idPrefix: idPrefix && `${idPrefix}-po`,
|
|
14508
14595
|
appliedPolicies: policyDefinitions,
|
|
14509
14596
|
finishingPositionOffset,
|
|
@@ -17351,8 +17438,11 @@ function generateAndPopulatePlayoffStructures(params) {
|
|
|
17351
17438
|
structureId: sourceStructureId,
|
|
17352
17439
|
addNameBaseToAttributeName,
|
|
17353
17440
|
playoffStructureNameBase,
|
|
17441
|
+
finishingPositionNaming,
|
|
17442
|
+
finishingPositionLimit,
|
|
17354
17443
|
playoffAttributes,
|
|
17355
17444
|
playoffPositions,
|
|
17445
|
+
roundOffsetLimit,
|
|
17356
17446
|
tournamentRecord,
|
|
17357
17447
|
exitProfileLimit,
|
|
17358
17448
|
roundProfiles,
|
|
@@ -17457,7 +17547,10 @@ function generateAndPopulatePlayoffStructures(params) {
|
|
|
17457
17547
|
drawSize,
|
|
17458
17548
|
idPrefix,
|
|
17459
17549
|
isMock,
|
|
17460
|
-
uuids
|
|
17550
|
+
uuids,
|
|
17551
|
+
finishingPositionNaming,
|
|
17552
|
+
finishingPositionLimit,
|
|
17553
|
+
roundOffsetLimit
|
|
17461
17554
|
});
|
|
17462
17555
|
if (result.error)
|
|
17463
17556
|
return decorateResult({ result, stack });
|
|
@@ -17731,56 +17824,6 @@ function participantScheduledMatchUps({
|
|
|
17731
17824
|
return { scheduledMatchUps };
|
|
17732
17825
|
}
|
|
17733
17826
|
|
|
17734
|
-
function getAccessorValue({ element, accessor }) {
|
|
17735
|
-
if (typeof accessor !== "string")
|
|
17736
|
-
return { values: [] };
|
|
17737
|
-
const targetElement = makeDeepCopy(element);
|
|
17738
|
-
const attributes = accessor.split(".");
|
|
17739
|
-
const values = [];
|
|
17740
|
-
let value;
|
|
17741
|
-
processKeys({ targetElement, attributes });
|
|
17742
|
-
const result = { value };
|
|
17743
|
-
if (values.length)
|
|
17744
|
-
result.values = values;
|
|
17745
|
-
return result;
|
|
17746
|
-
function processKeys({
|
|
17747
|
-
targetElement: targetElement2,
|
|
17748
|
-
attributes: attributes2 = [],
|
|
17749
|
-
significantCharacters
|
|
17750
|
-
}) {
|
|
17751
|
-
for (const [index, attribute] of attributes2.entries()) {
|
|
17752
|
-
if (targetElement2?.[attribute]) {
|
|
17753
|
-
if (Array.isArray(targetElement2[attribute])) {
|
|
17754
|
-
const values2 = targetElement2[attribute];
|
|
17755
|
-
const remainingKeys = attributes2.slice(index);
|
|
17756
|
-
values2.forEach(
|
|
17757
|
-
(nestedTarget) => processKeys({
|
|
17758
|
-
targetElement: nestedTarget,
|
|
17759
|
-
attributes: remainingKeys
|
|
17760
|
-
})
|
|
17761
|
-
);
|
|
17762
|
-
} else {
|
|
17763
|
-
targetElement2 = targetElement2[attribute];
|
|
17764
|
-
checkValue({ targetElement: targetElement2, index });
|
|
17765
|
-
}
|
|
17766
|
-
}
|
|
17767
|
-
}
|
|
17768
|
-
function checkValue({ targetElement: targetElement3, index }) {
|
|
17769
|
-
if (targetElement3 && index === attributes2.length - 1 && ["string", "number"].includes(typeof targetElement3)) {
|
|
17770
|
-
const extractedValue = significantCharacters ? targetElement3.slice(0, significantCharacters) : targetElement3;
|
|
17771
|
-
if (value) {
|
|
17772
|
-
if (!values.includes(extractedValue)) {
|
|
17773
|
-
values.push(extractedValue);
|
|
17774
|
-
}
|
|
17775
|
-
} else {
|
|
17776
|
-
value = extractedValue;
|
|
17777
|
-
values.push(extractedValue);
|
|
17778
|
-
}
|
|
17779
|
-
}
|
|
17780
|
-
}
|
|
17781
|
-
}
|
|
17782
|
-
}
|
|
17783
|
-
|
|
17784
17827
|
function participantScaleItem({
|
|
17785
17828
|
requireTimeStamp,
|
|
17786
17829
|
scaleAttributes,
|
|
@@ -19128,13 +19171,17 @@ function createGroupParticipant({
|
|
|
19128
19171
|
|
|
19129
19172
|
function generateRoundRobinWithPlayOff(params) {
|
|
19130
19173
|
const { drawDefinition, structureOptions, requireSequential } = params;
|
|
19131
|
-
const mainDrawProperties = {
|
|
19174
|
+
const mainDrawProperties = {
|
|
19175
|
+
structureName: constantToString(MAIN),
|
|
19176
|
+
...params,
|
|
19177
|
+
stage: MAIN
|
|
19178
|
+
};
|
|
19132
19179
|
const { structures, groupCount, groupSize } = generateRoundRobin(mainDrawProperties);
|
|
19133
19180
|
if (groupCount < 1) {
|
|
19134
19181
|
console.log(INVALID_CONFIGURATION);
|
|
19135
19182
|
}
|
|
19136
19183
|
const playoffGroups = structureOptions?.playoffGroups || [
|
|
19137
|
-
{ finishingPositions: [1], structureName: PLAY_OFF }
|
|
19184
|
+
{ finishingPositions: [1], structureName: constantToString(PLAY_OFF) }
|
|
19138
19185
|
];
|
|
19139
19186
|
const [mainStructure] = structures;
|
|
19140
19187
|
const { structures: playoffStructures, links } = processPlayoffGroups({
|
|
@@ -19252,7 +19299,7 @@ function generateDoubleElimination({
|
|
|
19252
19299
|
isMock
|
|
19253
19300
|
});
|
|
19254
19301
|
const mainStructure = structureTemplate({
|
|
19255
|
-
structureName: structureName || MAIN,
|
|
19302
|
+
structureName: structureName || constantToString(MAIN),
|
|
19256
19303
|
structureId: uuids?.pop(),
|
|
19257
19304
|
stageSequence: 1,
|
|
19258
19305
|
stage: MAIN,
|
|
@@ -19271,9 +19318,9 @@ function generateDoubleElimination({
|
|
|
19271
19318
|
uuids
|
|
19272
19319
|
});
|
|
19273
19320
|
const consolationStructure = structureTemplate({
|
|
19321
|
+
structureName: constantToString(BACKDRAW),
|
|
19274
19322
|
matchUps: consolationMatchUps,
|
|
19275
19323
|
structureId: uuids?.pop(),
|
|
19276
|
-
structureName: BACKDRAW,
|
|
19277
19324
|
stage: CONSOLATION,
|
|
19278
19325
|
stageSequence: 2,
|
|
19279
19326
|
matchUpType
|
|
@@ -19286,9 +19333,9 @@ function generateDoubleElimination({
|
|
|
19286
19333
|
isMock
|
|
19287
19334
|
});
|
|
19288
19335
|
const deciderStructure = structureTemplate({
|
|
19336
|
+
structureName: constantToString(DECIDER),
|
|
19289
19337
|
matchUps: deciderMatchUps,
|
|
19290
19338
|
structureId: uuids?.pop(),
|
|
19291
|
-
structureName: DECIDER,
|
|
19292
19339
|
stageSequence: 3,
|
|
19293
19340
|
stage: PLAY_OFF,
|
|
19294
19341
|
matchUpType
|
|
@@ -19410,11 +19457,12 @@ function getGenerators(params) {
|
|
|
19410
19457
|
const { appliedPolicies } = getAppliedPolicies(params);
|
|
19411
19458
|
const feedPolicy = params.policyDefinitions?.[POLICY_TYPE_FEED_IN] || appliedPolicies?.[POLICY_TYPE_FEED_IN];
|
|
19412
19459
|
params.skipRounds = params.skipRounds || drawSize <= 4 && (feedPolicy?.feedMainFinal ? 0 : 1) || 0;
|
|
19460
|
+
const main = constantToString(MAIN);
|
|
19413
19461
|
const singleElimination = () => {
|
|
19414
19462
|
const { matchUps } = treeMatchUps(params);
|
|
19415
19463
|
const structure = structureTemplate({
|
|
19416
|
-
structureName: structureName || MAIN,
|
|
19417
19464
|
structureId: structureId || uuids?.pop(),
|
|
19465
|
+
structureName: structureName || main,
|
|
19418
19466
|
stageSequence,
|
|
19419
19467
|
matchUpType,
|
|
19420
19468
|
matchUps,
|
|
@@ -19425,8 +19473,8 @@ function getGenerators(params) {
|
|
|
19425
19473
|
const generators = {
|
|
19426
19474
|
[AD_HOC]: () => {
|
|
19427
19475
|
const structure = structureTemplate({
|
|
19428
|
-
structureName: structureName || MAIN,
|
|
19429
19476
|
structureId: structureId || uuids?.pop(),
|
|
19477
|
+
structureName: structureName || main,
|
|
19430
19478
|
finishingPosition: WIN_RATIO,
|
|
19431
19479
|
stageSequence,
|
|
19432
19480
|
matchUps: [],
|
|
@@ -19438,8 +19486,8 @@ function getGenerators(params) {
|
|
|
19438
19486
|
[LUCKY_DRAW]: () => {
|
|
19439
19487
|
const { matchUps } = luckyDraw(params);
|
|
19440
19488
|
const structure = structureTemplate({
|
|
19441
|
-
structureName: structureName || MAIN,
|
|
19442
19489
|
structureId: structureId || uuids?.pop(),
|
|
19490
|
+
structureName: structureName || main,
|
|
19443
19491
|
stageSequence,
|
|
19444
19492
|
matchUpType,
|
|
19445
19493
|
matchUps,
|
|
@@ -19465,8 +19513,8 @@ function getGenerators(params) {
|
|
|
19465
19513
|
[FEED_IN$1]: () => {
|
|
19466
19514
|
const { matchUps } = feedInMatchUps({ drawSize, uuids, matchUpType });
|
|
19467
19515
|
const structure = structureTemplate({
|
|
19468
|
-
structureName: structureName || MAIN,
|
|
19469
19516
|
structureId: structureId || uuids?.pop(),
|
|
19517
|
+
structureName: structureName || main,
|
|
19470
19518
|
stageSequence,
|
|
19471
19519
|
matchUpType,
|
|
19472
19520
|
stage: MAIN,
|
|
@@ -19528,9 +19576,9 @@ function generateVoluntaryConsolation$1(params) {
|
|
|
19528
19576
|
return result2;
|
|
19529
19577
|
}
|
|
19530
19578
|
tieFormat = copyTieFormat(
|
|
19531
|
-
tieFormat
|
|
19579
|
+
tieFormat ?? resolveTieFormat({ drawDefinition })?.tieFormat
|
|
19532
19580
|
);
|
|
19533
|
-
matchUpType = matchUpType
|
|
19581
|
+
matchUpType = matchUpType ?? drawDefinition.matchUpType ?? TypeEnum.Singles;
|
|
19534
19582
|
const { structures: stageStructures } = getDrawStructures({
|
|
19535
19583
|
stageSequence: 1,
|
|
19536
19584
|
drawDefinition,
|
|
@@ -19538,14 +19586,14 @@ function generateVoluntaryConsolation$1(params) {
|
|
|
19538
19586
|
});
|
|
19539
19587
|
const structureCount = stageStructures.length;
|
|
19540
19588
|
if (structureCount > 1)
|
|
19541
|
-
return { error:
|
|
19589
|
+
return { error: STAGE_SEQUENCE_LIMIT };
|
|
19542
19590
|
if (stageStructures?.[0]?.matchUps?.length)
|
|
19543
|
-
return { error:
|
|
19591
|
+
return { error: EXISTING_STRUCTURE };
|
|
19544
19592
|
const structureId = stageStructures?.[0]?.structureId;
|
|
19545
19593
|
Object.assign(
|
|
19546
19594
|
params,
|
|
19547
19595
|
definedAttributes({
|
|
19548
|
-
structureName: params.structureName
|
|
19596
|
+
structureName: params.structureName ?? constantToString(VOLUNTARY_CONSOLATION),
|
|
19549
19597
|
structureId,
|
|
19550
19598
|
matchUpType,
|
|
19551
19599
|
tieFormat,
|
|
@@ -23267,7 +23315,7 @@ function generateDrawDefinition(params) {
|
|
|
23267
23315
|
}
|
|
23268
23316
|
} else if (structureId && generateQualifyingPlaceholder) {
|
|
23269
23317
|
const qualifyingStructure = structureTemplate({
|
|
23270
|
-
structureName: QUALIFYING,
|
|
23318
|
+
structureName: constantToString(QUALIFYING),
|
|
23271
23319
|
stage: QUALIFYING
|
|
23272
23320
|
});
|
|
23273
23321
|
const { link } = generateQualifyingLink({
|