tods-competition-factory 1.9.1 → 1.9.3

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)
@@ -12225,11 +12214,14 @@ function randomUnseededSeparation({
12225
12214
  idCollections,
12226
12215
  participants
12227
12216
  });
12217
+ if (allGroups.error) {
12218
+ return decorateResult({ result: allGroups, stack });
12219
+ }
12228
12220
  const participantIdGroups = Object.assign(
12229
12221
  {},
12230
12222
  ...unseededParticipantIds.map((participantId) => {
12231
12223
  const groups = Object.keys(allGroups).filter(
12232
- (key) => allGroups[key].includes(participantId)
12224
+ (key) => (allGroups[key] ?? []).includes(participantId)
12233
12225
  );
12234
12226
  return { [participantId]: groups };
12235
12227
  })
@@ -12427,7 +12419,7 @@ function positionUnseededParticipants({
12427
12419
  drawDefinition,
12428
12420
  event
12429
12421
  });
12430
- let avoidance = (appliedPolicies ?? {})[POLICY_TYPE_AVOIDANCE];
12422
+ let avoidance = appliedPolicies?.[POLICY_TYPE_AVOIDANCE];
12431
12423
  if (structure.stage === PLAY_OFF) {
12432
12424
  const groupings = entries.reduce((groupings2, entry) => {
12433
12425
  if (!groupings2[entry.groupingValue])
@@ -16437,11 +16429,10 @@ function modifyMatchUpScore({
16437
16429
  }
16438
16430
  if (Array.isArray(defaultedProcessCodes) && inContextMatchUp && !inContextMatchUp.sides?.every(({ participantId }) => participantId)) {
16439
16431
  if (matchUpStatus === DEFAULTED) {
16440
- if (matchUp.processCodes) {
16441
- matchUp.processCodes.push(...defaultedProcessCodes);
16442
- } else {
16443
- matchUp.processCodes = defaultedProcessCodes;
16444
- }
16432
+ matchUp.processCodes = unique([
16433
+ ...matchUp.processCodes ?? [],
16434
+ ...defaultedProcessCodes
16435
+ ]);
16445
16436
  } else {
16446
16437
  for (const processCode of defaultedProcessCodes || []) {
16447
16438
  const codeIndex = processCode && matchUp?.processCodes?.lastIndexOf(processCode);
@@ -21723,8 +21714,8 @@ function addDrawDefinition(params) {
21723
21714
  }
21724
21715
 
21725
21716
  function attachPolicies({
21726
- drawDefinition,
21727
- policyDefinitions
21717
+ policyDefinitions,
21718
+ drawDefinition
21728
21719
  }) {
21729
21720
  if (!drawDefinition) {
21730
21721
  return { error: MISSING_DRAW_DEFINITION };
@@ -23689,7 +23680,7 @@ function getScaleValue({
23689
23680
  return scaleAccessor && isObject(scaleValue) ? scaleValue[scaleAccessor] : scaleValue;
23690
23681
  }
23691
23682
 
23692
- const POLICY_SEEDING_USTA = {
23683
+ const POLICY_SEEDING_DEFAULT = {
23693
23684
  [POLICY_TYPE_SEEDING]: {
23694
23685
  validSeedPositions: { ignore: true },
23695
23686
  duplicateSeedNumbers: true,
@@ -23746,13 +23737,15 @@ function generateDrawDefinition(params) {
23746
23737
  if (params.seedingProfile) {
23747
23738
  if (!policyDefinitions[POLICY_TYPE_SEEDING]) {
23748
23739
  policyDefinitions[POLICY_TYPE_SEEDING] = {
23749
- ...POLICY_SEEDING_USTA[POLICY_TYPE_SEEDING]
23740
+ ...POLICY_SEEDING_DEFAULT[POLICY_TYPE_SEEDING]
23750
23741
  };
23751
23742
  }
23752
23743
  policyDefinitions[POLICY_TYPE_SEEDING].seedingProfile = seedingProfile;
23753
23744
  }
23754
23745
  const { participants, participantMap } = getParticipants({
23755
23746
  withIndividualParticipants: true,
23747
+ convertExtensions: true,
23748
+ internalUse: true,
23756
23749
  tournamentRecord
23757
23750
  });
23758
23751
  const enforceGender = params.enforceGender ?? policyDefinitions?.[POLICY_TYPE_MATCHUP_ACTIONS]?.participants?.enforceGender ?? appliedPolicies?.[POLICY_TYPE_MATCHUP_ACTIONS]?.participants?.enforceGender;
@@ -23863,6 +23856,10 @@ function generateDrawDefinition(params) {
23863
23856
  drawDefinition.matchUpType = matchUpType;
23864
23857
  }
23865
23858
  }
23859
+ const policiesToAttach = {
23860
+ [POLICY_TYPE_AVOIDANCE]: appliedPolicies[POLICY_TYPE_AVOIDANCE],
23861
+ ...POLICY_SEEDING_DEFAULT
23862
+ };
23866
23863
  if (policyDefinitions) {
23867
23864
  if (typeof policyDefinitions !== "object") {
23868
23865
  return decorateResult({
@@ -23871,7 +23868,6 @@ function generateDrawDefinition(params) {
23871
23868
  stack
23872
23869
  });
23873
23870
  } else {
23874
- const policiesToAttach = {};
23875
23871
  for (const key of Object.keys(policyDefinitions)) {
23876
23872
  if (JSON.stringify(appliedPolicies?.[key]) !== JSON.stringify(policyDefinitions[key])) {
23877
23873
  policiesToAttach[key] = policyDefinitions[key];
@@ -23882,10 +23878,11 @@ function generateDrawDefinition(params) {
23882
23878
  Object.assign(appliedPolicies, policiesToAttach);
23883
23879
  }
23884
23880
  }
23881
+ } else if (policiesToAttach.avoidance) {
23882
+ attachPolicies({ drawDefinition, policyDefinitions: policiesToAttach });
23885
23883
  }
23886
23884
  if (!appliedPolicies[POLICY_TYPE_SEEDING] && !policyDefinitions[POLICY_TYPE_SEEDING]) {
23887
- attachPolicies({ drawDefinition, policyDefinitions: POLICY_SEEDING_USTA });
23888
- Object.assign(appliedPolicies, POLICY_SEEDING_USTA);
23885
+ Object.assign(appliedPolicies, POLICY_SEEDING_DEFAULT);
23889
23886
  }
23890
23887
  let structureId = existingDrawDefinition?.structures?.find(
23891
23888
  (structure) => structure.stage === MAIN && structure.stageSequence === 1