tods-competition-factory 0.331.0 → 0.332.0

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.
@@ -1627,6 +1627,8 @@ function treeMatchUps({
1627
1627
  });
1628
1628
  if (roundLimit) {
1629
1629
  matchUps = matchUps.filter((matchUp) => matchUp.roundNumber <= roundLimit);
1630
+ } else {
1631
+ roundLimit = roundNumber - 1;
1630
1632
  }
1631
1633
  return { matchUps, roundsCount, roundLimit };
1632
1634
  }
@@ -2320,6 +2322,21 @@ function getTargetMatchUp({
2320
2322
  };
2321
2323
  }
2322
2324
 
2325
+ function decorateResult({ result, stack, context, info }) {
2326
+ if (!result.stack)
2327
+ result.stack = [];
2328
+ if (stack) {
2329
+ result.stack.push(stack);
2330
+ }
2331
+ if (info && result.error) {
2332
+ result.error.info = info;
2333
+ }
2334
+ if (typeof context === "object" && Object.keys(context).length) {
2335
+ result = Object.assign(result, definedAttributes(context));
2336
+ }
2337
+ return result;
2338
+ }
2339
+
2323
2340
  function getRoundLinks({ drawDefinition, roundNumber, structureId }) {
2324
2341
  if (!drawDefinition)
2325
2342
  return { error: MISSING_DRAW_DEFINITION };
@@ -2340,12 +2357,20 @@ function getTargetLink({
2340
2357
  linkType,
2341
2358
  source
2342
2359
  }) {
2360
+ var _a;
2343
2361
  const result = source.find((link) => {
2344
- var _a, _b;
2345
- const positionCondition = !((_a = link.source) == null ? void 0 : _a.finishingPositions) || !finishingPositions || overlap(finishingPositions, (_b = link.source) == null ? void 0 : _b.finishingPositions);
2362
+ var _a2, _b;
2363
+ const positionCondition = !((_a2 = link.source) == null ? void 0 : _a2.finishingPositions) || !finishingPositions || overlap(finishingPositions, (_b = link.source) == null ? void 0 : _b.finishingPositions);
2346
2364
  const condition = linkCondition === link.linkCondition;
2347
2365
  return condition && positionCondition && link.linkType === linkType;
2348
2366
  });
2367
+ if ([WINNER, LOSER].includes(result == null ? void 0 : result.linkType) && !((_a = result == null ? void 0 : result.source) == null ? void 0 : _a.roundNumber)) {
2368
+ return decorateResult({
2369
+ result: { error: INVALID_VALUES },
2370
+ stack: "getTargetLink",
2371
+ context: result
2372
+ });
2373
+ }
2349
2374
  return result;
2350
2375
  }
2351
2376
  function getStructureLinks({
@@ -2868,21 +2893,6 @@ function getExitProfiles({ drawDefinition }) {
2868
2893
  }
2869
2894
  }
2870
2895
 
2871
- function decorateResult({ result, stack, context, info }) {
2872
- if (!result.stack)
2873
- result.stack = [];
2874
- if (stack) {
2875
- result.stack.push(stack);
2876
- }
2877
- if (info && result.error) {
2878
- result.error.info = info;
2879
- }
2880
- if (typeof context === "object" && Object.keys(context).length) {
2881
- result = Object.assign(result, definedAttributes(context));
2882
- }
2883
- return result;
2884
- }
2885
-
2886
2896
  function matchUpIsComplete({ matchUp }) {
2887
2897
  return completedMatchUpStatuses.includes(matchUp == null ? void 0 : matchUp.matchUpStatus) || (matchUp == null ? void 0 : matchUp.winningSide);
2888
2898
  }
@@ -18813,6 +18823,8 @@ function generateDrawStructuresAndLinks(params = {}) {
18813
18823
  targetEntryRound,
18814
18824
  linkType
18815
18825
  })) == null ? void 0 : _e.link);
18826
+ if (link == null ? void 0 : link.error)
18827
+ return link;
18816
18828
  if (link) {
18817
18829
  links.push(link);
18818
18830
  }