tods-competition-factory 1.9.0 → 1.9.2

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.
@@ -908,7 +908,6 @@ function handleCaughtError({
908
908
  const globalState = {
909
909
  tournamentFactoryVersion: "0.0.0",
910
910
  timers: { default: { elapsedTime: 0 } },
911
- iterators: { makeDeepCopy: 0 },
912
911
  deepCopyAttributes: {
913
912
  stringify: [],
914
913
  ignore: [],
@@ -928,9 +927,6 @@ function getDevContext(contextCriteria) {
928
927
  ) && globalState.devContext;
929
928
  }
930
929
  }
931
- function setDeepCopyIterations(value) {
932
- globalState.iterators.makeDeepCopy = value;
933
- }
934
930
  function disableNotifications() {
935
931
  _globalStateProvider.disableNotifications();
936
932
  }
@@ -1103,13 +1099,6 @@ function makeDeepCopy(sourceObject, convertExtensions, internalUse, removeExtens
1103
1099
  if (!deepCopy?.enabled && !internalUse || typeof sourceObject !== "object" || typeof sourceObject === "function" || sourceObject === null || typeof deepCopy?.threshold === "number" && iteration >= deepCopy.threshold) {
1104
1100
  return sourceObject;
1105
1101
  }
1106
- const devContext = getDevContext({ makeDeepCopy: true });
1107
- if (devContext) {
1108
- setDeepCopyIterations(iteration);
1109
- if (typeof devContext === "object" && (iteration > (devContext.iterationThreshold || 15) || devContext.firstIteration && iteration === 0) && devContext.log && (!devContext.notInternalUse || devContext.notInternalUse && !internalUse)) {
1110
- console.log({ devContext, iteration, internalUse }, sourceObject);
1111
- }
1112
- }
1113
1102
  const targetObject = Array.isArray(sourceObject) ? [] : {};
1114
1103
  const sourceObjectKeys = Object.keys(sourceObject).filter(
1115
1104
  (key) => !internalUse || !ignore || Array.isArray(ignore) && !ignore.includes(key) || typeof ignore === "function" && !ignore(key)
@@ -1221,6 +1210,11 @@ const extractAttributes = (accessor) => (element) => !accessor || typeof element
1221
1210
  })) || typeof accessor === "object" && Object.keys(accessor).map((key) => ({
1222
1211
  [key]: getAccessorValue({ element, accessor: key })?.value
1223
1212
  })) || (typeof accessor === "string" && getAccessorValue({ element, accessor }))?.value;
1213
+ function getDefinedKeys(obj, ignoreValues, ignoreEmptyArrays) {
1214
+ return Object.keys(obj).filter(
1215
+ (key) => !ignoreValues.includes(obj[key]) && (!ignoreEmptyArrays || (Array.isArray(obj[key]) ? obj[key].length : true))
1216
+ );
1217
+ }
1224
1218
  function definedAttributes(obj, ignoreFalse, ignoreEmptyArrays, shallow) {
1225
1219
  if (typeof obj !== "object" || obj === null)
1226
1220
  return obj;
@@ -1230,9 +1224,7 @@ function definedAttributes(obj, ignoreFalse, ignoreEmptyArrays, shallow) {
1230
1224
  const ignoreValues = ["", void 0, null];
1231
1225
  if (ignoreFalse)
1232
1226
  ignoreValues.push(false);
1233
- const definedKeys = Object.keys(obj).filter(
1234
- (key) => !ignoreValues.includes(obj[key]) && (!ignoreEmptyArrays || (Array.isArray(obj[key]) ? obj[key].length : true))
1235
- );
1227
+ const definedKeys = getDefinedKeys(obj, ignoreValues, ignoreEmptyArrays);
1236
1228
  return Object.assign(
1237
1229
  {},
1238
1230
  ...definedKeys.map((key) => {
@@ -16434,11 +16426,10 @@ function modifyMatchUpScore({
16434
16426
  }
16435
16427
  if (Array.isArray(defaultedProcessCodes) && inContextMatchUp && !inContextMatchUp.sides?.every(({ participantId }) => participantId)) {
16436
16428
  if (matchUpStatus === DEFAULTED) {
16437
- if (matchUp.processCodes) {
16438
- matchUp.processCodes.push(...defaultedProcessCodes);
16439
- } else {
16440
- matchUp.processCodes = defaultedProcessCodes;
16441
- }
16429
+ matchUp.processCodes = unique([
16430
+ ...matchUp.processCodes ?? [],
16431
+ ...defaultedProcessCodes
16432
+ ]);
16442
16433
  } else {
16443
16434
  for (const processCode of defaultedProcessCodes || []) {
16444
16435
  const codeIndex = processCode && matchUp?.processCodes?.lastIndexOf(processCode);
@@ -20922,10 +20913,11 @@ function generateQualifyingStructures({
20922
20913
  for (const structureProfile of (structureProfiles || []).sort(
20923
20914
  sequenceSort
20924
20915
  )) {
20925
- let drawSize = structureProfile.drawSize || coerceEven(structureProfile.participantsCount);
20916
+ let drawSize = coerceEven(
20917
+ structureProfile.drawSize || structureProfile.participantsCount
20918
+ );
20926
20919
  const {
20927
20920
  qualifyingRoundNumber,
20928
- qualifyingPositions,
20929
20921
  structureOptions,
20930
20922
  matchUpFormat,
20931
20923
  structureName,
@@ -20933,6 +20925,7 @@ function generateQualifyingStructures({
20933
20925
  drawType
20934
20926
  } = structureProfile;
20935
20927
  const matchUpType = structureProfile.matchUpType;
20928
+ const qualifyingPositions = structureProfile.qualifyingPositions || deriveQualifyingPositions({ drawSize, qualifyingRoundNumber });
20936
20929
  let roundLimit, structure, matchUps;
20937
20930
  if (!isConvertableInteger(drawSize)) {
20938
20931
  return decorateResult({
@@ -21039,6 +21032,15 @@ function generateQualifyingStructures({
21039
21032
  links
21040
21033
  };
21041
21034
  }
21035
+ function deriveQualifyingPositions({ drawSize, qualifyingRoundNumber }) {
21036
+ let qualifyingPositions = drawSize;
21037
+ let divisionsCount = 0;
21038
+ while (divisionsCount < qualifyingRoundNumber) {
21039
+ qualifyingPositions = Math.floor(qualifyingPositions / 2);
21040
+ divisionsCount += 1;
21041
+ }
21042
+ return qualifyingPositions;
21043
+ }
21042
21044
 
21043
21045
  function generateDrawStructuresAndLinks(params) {
21044
21046
  const {