tods-competition-factory 1.7.6 → 1.7.8

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.
@@ -926,93 +926,6 @@ function getTopics() {
926
926
  return _globalStateProvider.getTopics();
927
927
  }
928
928
 
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
929
  const validTimeString = /^((0[\d]|1[\d]|2[0-3]):[0-5][\d](:[0-5][\d])?)([.,][0-9]{3})?$/;
1017
930
  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
931
 
@@ -1195,6 +1108,144 @@ function extensionsToAttributes(extensions) {
1195
1108
  }).filter(Boolean);
1196
1109
  }
1197
1110
 
1111
+ function getAccessorValue({ element, accessor }) {
1112
+ if (typeof accessor !== "string")
1113
+ return { values: [] };
1114
+ const targetElement = makeDeepCopy(element);
1115
+ const attributes = accessor.split(".");
1116
+ const values = [];
1117
+ let value;
1118
+ processKeys({ targetElement, attributes });
1119
+ const result = { value };
1120
+ if (values.length)
1121
+ result.values = values;
1122
+ return result;
1123
+ function processKeys({
1124
+ targetElement: targetElement2,
1125
+ attributes: attributes2 = [],
1126
+ significantCharacters
1127
+ }) {
1128
+ for (const [index, attribute] of attributes2.entries()) {
1129
+ if (targetElement2?.[attribute]) {
1130
+ const remainingKeys = attributes2.slice(index + 1);
1131
+ if (!remainingKeys.length) {
1132
+ if (!value)
1133
+ value = targetElement2[attribute];
1134
+ if (!values.includes(targetElement2[attribute])) {
1135
+ values.push(targetElement2[attribute]);
1136
+ }
1137
+ } else if (Array.isArray(targetElement2[attribute])) {
1138
+ const values2 = targetElement2[attribute];
1139
+ values2.forEach(
1140
+ (nestedTarget) => processKeys({
1141
+ targetElement: nestedTarget,
1142
+ attributes: remainingKeys
1143
+ })
1144
+ );
1145
+ } else {
1146
+ targetElement2 = targetElement2[attribute];
1147
+ checkValue({ targetElement: targetElement2, index });
1148
+ }
1149
+ }
1150
+ }
1151
+ function checkValue({ targetElement: targetElement3, index }) {
1152
+ if (targetElement3 && index === attributes2.length - 1 && ["string", "number"].includes(typeof targetElement3)) {
1153
+ const extractedValue = significantCharacters ? targetElement3.slice(0, significantCharacters) : targetElement3;
1154
+ if (value) {
1155
+ if (!values.includes(extractedValue)) {
1156
+ values.push(extractedValue);
1157
+ }
1158
+ } else {
1159
+ value = extractedValue;
1160
+ values.push(extractedValue);
1161
+ }
1162
+ }
1163
+ }
1164
+ }
1165
+ }
1166
+
1167
+ function isObject(obj) {
1168
+ return typeof obj === "object";
1169
+ }
1170
+ const extractAttributes = (accessor) => (element) => !accessor || typeof element !== "object" ? void 0 : Array.isArray(accessor) && accessor.map((a) => ({
1171
+ [a]: getAccessorValue({ element, accessor: a })?.value
1172
+ })) || typeof accessor === "object" && Object.keys(accessor).map((key) => ({
1173
+ [key]: getAccessorValue({ element, accessor: key })?.value
1174
+ })) || (typeof accessor === "string" && getAccessorValue({ element, accessor }))?.value;
1175
+ function definedAttributes(obj, ignoreFalse, ignoreEmptyArrays, shallow) {
1176
+ if (typeof obj !== "object" || obj === null)
1177
+ return obj;
1178
+ const deepCopy = deepCopyEnabled();
1179
+ if (!deepCopy?.enabled)
1180
+ shallow = true;
1181
+ const ignoreValues = ["", void 0, null];
1182
+ if (ignoreFalse)
1183
+ ignoreValues.push(false);
1184
+ const definedKeys = Object.keys(obj).filter(
1185
+ (key) => !ignoreValues.includes(obj[key]) && (!ignoreEmptyArrays || (Array.isArray(obj[key]) ? obj[key].length : true))
1186
+ );
1187
+ return Object.assign(
1188
+ {},
1189
+ ...definedKeys.map((key) => {
1190
+ return Array.isArray(obj[key]) ? {
1191
+ [key]: shallow ? obj[key] : obj[key].map((m) => definedAttributes(m))
1192
+ } : { [key]: shallow ? obj[key] : definedAttributes(obj[key]) };
1193
+ })
1194
+ );
1195
+ }
1196
+
1197
+ function attributeFilter(params) {
1198
+ if (params === null)
1199
+ return {};
1200
+ const { source, template } = params || {};
1201
+ if (!template)
1202
+ return source;
1203
+ const target = {};
1204
+ attributeCopy(source, template, target);
1205
+ return target;
1206
+ function attributeCopy(valuesObject, templateObject, outputObject) {
1207
+ if (!valuesObject || !templateObject)
1208
+ return void 0;
1209
+ const vKeys = Object.keys(valuesObject);
1210
+ const oKeys = Object.keys(templateObject);
1211
+ const orMap = Object.assign(
1212
+ {},
1213
+ ...oKeys.filter((key) => key.indexOf("||")).map((key) => key.split("||").map((or) => ({ [or]: key }))).flat()
1214
+ );
1215
+ const allKeys = oKeys.concat(...Object.keys(orMap));
1216
+ const wildcard = allKeys.includes("*");
1217
+ for (const vKey of vKeys) {
1218
+ if (allKeys.indexOf(vKey) >= 0 || wildcard) {
1219
+ const templateKey = orMap[vKey] || vKey;
1220
+ const tobj = templateObject[templateKey] || wildcard;
1221
+ const vobj = valuesObject[vKey];
1222
+ if (typeof tobj === "object" && typeof vobj !== "function" && !Array.isArray(tobj)) {
1223
+ if (Array.isArray(vobj)) {
1224
+ const mappedElements = vobj.map((arrayMember) => {
1225
+ const target2 = {};
1226
+ const result = attributeCopy(arrayMember, tobj, target2);
1227
+ return result !== false ? target2 : void 0;
1228
+ }).filter(Boolean);
1229
+ outputObject[vKey] = mappedElements;
1230
+ } else if (vobj) {
1231
+ outputObject[vKey] = {};
1232
+ attributeCopy(vobj, tobj, outputObject[vKey]);
1233
+ }
1234
+ } else {
1235
+ const value = valuesObject[vKey];
1236
+ const exclude = Array.isArray(tobj) && !tobj.includes(value);
1237
+ if (exclude)
1238
+ return false;
1239
+ if (templateObject[vKey] || wildcard && templateObject[vKey] !== false) {
1240
+ outputObject[vKey] = value;
1241
+ }
1242
+ }
1243
+ }
1244
+ }
1245
+ return void 0;
1246
+ }
1247
+ }
1248
+
1198
1249
  function numericSort(a, b) {
1199
1250
  return a - b;
1200
1251
  }
@@ -1349,7 +1400,8 @@ const WIN_RATIO$1 = "winRatio";
1349
1400
 
1350
1401
  const add = (a, b) => (a || 0) + (b || 0);
1351
1402
  function getBand(spread, bandProfiles) {
1352
- return isNaN(spread) && WALKOVER || spread <= bandProfiles[DECISIVE] && DECISIVE || spread <= bandProfiles[ROUTINE] && ROUTINE || COMPETITIVE;
1403
+ const spreadValue = Array.isArray(spread) ? spread[0] : spread;
1404
+ return isNaN(spreadValue) && WALKOVER || spreadValue <= bandProfiles[DECISIVE] && DECISIVE || spreadValue <= bandProfiles[ROUTINE] && ROUTINE || COMPETITIVE;
1353
1405
  }
1354
1406
  function getScoreComponents({ score }) {
1355
1407
  const sets = score?.sets || [];
@@ -1407,6 +1459,7 @@ const POLICY_TYPE_MATCHUP_ACTIONS = "matchUpActions";
1407
1459
  const POLICY_TYPE_ROUND_NAMING = "roundNaming";
1408
1460
  const POLICY_TYPE_PARTICIPANT = "participant";
1409
1461
  const POLICY_TYPE_SCHEDULING = "scheduling";
1462
+ const POLICY_TYPE_DISPLAY = "display";
1410
1463
  const POLICY_TYPE_SCORING = "scoring";
1411
1464
  const POLICY_TYPE_SEEDING = "seeding";
1412
1465
  const POLICY_TYPE_FEED_IN = "feedIn";
@@ -1440,7 +1493,8 @@ function getMatchUpCompetitiveProfile({
1440
1493
  const scoreComponents = getScoreComponents({ score });
1441
1494
  const spread = pctSpread([scoreComponents]);
1442
1495
  const competitiveness = getBand(spread, bandProfiles);
1443
- return { ...SUCCESS, competitiveness, pctSpread: spread };
1496
+ const pctSpreadValue = Array.isArray(spread) ? spread[0] : spread;
1497
+ return { ...SUCCESS, competitiveness, pctSpread: pctSpreadValue };
1444
1498
  }
1445
1499
 
1446
1500
  function findMatchupFormatAverageTimes(params) {
@@ -4253,12 +4307,15 @@ function isAdHoc({ drawDefinition, structure }) {
4253
4307
  const hasDrawPosition = matchUps?.find(
4254
4308
  (matchUp) => matchUp?.drawPositions?.length
4255
4309
  );
4256
- return !structure?.structures && !(drawDefinition?.drawType && drawDefinition.drawType !== AD_HOC) && !hasRoundPosition && !hasDrawPosition;
4310
+ return !structure?.structures && structure?.stage !== VOLUNTARY_CONSOLATION && !(drawDefinition?.drawType && drawDefinition.drawType !== AD_HOC) && !hasRoundPosition && !hasDrawPosition;
4257
4311
  }
4258
4312
 
4259
4313
  const POLICY_ROUND_NAMING_DEFAULT = {
4260
4314
  [POLICY_TYPE_ROUND_NAMING]: {
4261
4315
  policyName: "Round Naming Default",
4316
+ namingConventions: {
4317
+ round: "Round"
4318
+ },
4262
4319
  abbreviatedRoundNamingMap: {
4263
4320
  // key is matchUpsCount for the round
4264
4321
  1: "F",
@@ -4298,6 +4355,9 @@ function getRoundContextProfile({
4298
4355
  const roundNamingMap = roundNamingPolicy?.roundNamingMap || defaultRoundNamingPolicy.roundNamingMap || {};
4299
4356
  const abbreviatedRoundNamingMap = roundNamingPolicy?.abbreviatedRoundNamingMap || defaultRoundNamingPolicy.abbreviatedRoundNamingMap || {};
4300
4357
  const roundNamePrefix = roundNamingPolicy?.affixes || defaultRoundNamingPolicy.affixes;
4358
+ const roundNumberAffix = roundNamePrefix.roundNumber || defaultRoundNamingPolicy.affixes.roundNumber;
4359
+ const namingConventions = roundNamingPolicy?.namingConventions || defaultRoundNamingPolicy.namingConventions;
4360
+ const roundNameFallback = namingConventions.round;
4301
4361
  const stageInitial = stage && stage !== MAIN && stage[0];
4302
4362
  const stageConstants = roundNamingPolicy?.stageConstants;
4303
4363
  const stageConstant = stage && stageConstants?.[stage] || stageInitial;
@@ -4306,8 +4366,8 @@ function getRoundContextProfile({
4306
4366
  Object.assign(
4307
4367
  roundNamingProfile,
4308
4368
  ...roundProfileKeys.map((key) => {
4309
- const roundName = `Round ${key}`;
4310
- const abbreviatedRoundName = `R${key}`;
4369
+ const roundName = `${roundNameFallback} ${key}`;
4370
+ const abbreviatedRoundName = `${roundNumberAffix}${key}`;
4311
4371
  return { [key]: { roundName, abbreviatedRoundName } };
4312
4372
  })
4313
4373
  );
@@ -17722,56 +17782,6 @@ function participantScheduledMatchUps({
17722
17782
  return { scheduledMatchUps };
17723
17783
  }
17724
17784
 
17725
- function getAccessorValue({ element, accessor }) {
17726
- if (typeof accessor !== "string")
17727
- return { values: [] };
17728
- const targetElement = makeDeepCopy(element);
17729
- const attributes = accessor.split(".");
17730
- const values = [];
17731
- let value;
17732
- processKeys({ targetElement, attributes });
17733
- const result = { value };
17734
- if (values.length)
17735
- result.values = values;
17736
- return result;
17737
- function processKeys({
17738
- targetElement: targetElement2,
17739
- attributes: attributes2 = [],
17740
- significantCharacters
17741
- }) {
17742
- for (const [index, attribute] of attributes2.entries()) {
17743
- if (targetElement2?.[attribute]) {
17744
- if (Array.isArray(targetElement2[attribute])) {
17745
- const values2 = targetElement2[attribute];
17746
- const remainingKeys = attributes2.slice(index);
17747
- values2.forEach(
17748
- (nestedTarget) => processKeys({
17749
- targetElement: nestedTarget,
17750
- attributes: remainingKeys
17751
- })
17752
- );
17753
- } else {
17754
- targetElement2 = targetElement2[attribute];
17755
- checkValue({ targetElement: targetElement2, index });
17756
- }
17757
- }
17758
- }
17759
- function checkValue({ targetElement: targetElement3, index }) {
17760
- if (targetElement3 && index === attributes2.length - 1 && ["string", "number"].includes(typeof targetElement3)) {
17761
- const extractedValue = significantCharacters ? targetElement3.slice(0, significantCharacters) : targetElement3;
17762
- if (value) {
17763
- if (!values.includes(extractedValue)) {
17764
- values.push(extractedValue);
17765
- }
17766
- } else {
17767
- value = extractedValue;
17768
- values.push(extractedValue);
17769
- }
17770
- }
17771
- }
17772
- }
17773
- }
17774
-
17775
17785
  function participantScaleItem({
17776
17786
  requireTimeStamp,
17777
17787
  scaleAttributes,
@@ -20995,7 +21005,10 @@ function addDrawDefinition(params) {
20995
21005
  return { ...SUCCESS, modifiedEventEntryStatusCount };
20996
21006
  }
20997
21007
 
20998
- function attachPolicies({ drawDefinition, policyDefinitions }) {
21008
+ function attachPolicies({
21009
+ drawDefinition,
21010
+ policyDefinitions
21011
+ }) {
20999
21012
  if (!drawDefinition) {
21000
21013
  return { error: MISSING_DRAW_DEFINITION };
21001
21014
  }
@@ -21005,8 +21018,9 @@ function attachPolicies({ drawDefinition, policyDefinitions }) {
21005
21018
  if (!drawDefinition.extensions)
21006
21019
  drawDefinition.extensions = [];
21007
21020
  const appliedPolicies = getAppliedPolicies({ drawDefinition })?.appliedPolicies ?? {};
21021
+ const validReplacements = [POLICY_TYPE_ROUND_NAMING, POLICY_TYPE_DISPLAY];
21008
21022
  const applied = Object.keys(policyDefinitions).every((policyType) => {
21009
- if (!appliedPolicies[policyType]) {
21023
+ if (!appliedPolicies[policyType] || validReplacements.includes(policyType)) {
21010
21024
  appliedPolicies[policyType] = policyDefinitions[policyType];
21011
21025
  return true;
21012
21026
  } else {