tods-competition-factory 1.8.0 → 1.8.1

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/index.mjs CHANGED
@@ -333,7 +333,7 @@ const matchUpFormatCode = {
333
333
  };
334
334
 
335
335
  function factoryVersion() {
336
- return "1.8.0";
336
+ return "1.8.1";
337
337
  }
338
338
 
339
339
  function getObjectTieFormat(obj) {
@@ -2384,7 +2384,7 @@ function JSON2CSV(arrayOfJSON, config) {
2384
2384
  rowJoiner
2385
2385
  ) : rows.join(rowJoiner);
2386
2386
  }
2387
- function flattenJSON(obj, keyJoiner, path = []) {
2387
+ function flattenJSON(obj, keyJoiner = ".", path = []) {
2388
2388
  return typeof obj === "object" && Object.keys(obj).reduce((result, key) => {
2389
2389
  if (typeof obj[key] !== "object") {
2390
2390
  result[path.concat(key).join(keyJoiner)] = obj[key];
@@ -5067,8 +5067,8 @@ function removeExtension({
5067
5067
  }
5068
5068
  function addEventExtension({
5069
5069
  tournamentRecords,
5070
- eventId,
5071
- extension
5070
+ extension,
5071
+ eventId
5072
5072
  }) {
5073
5073
  if (typeof eventId !== "string")
5074
5074
  return { error: MISSING_EVENT };
@@ -34482,8 +34482,7 @@ function scheduleProfileRounds({
34482
34482
  clearScheduledMatchUps({ tournamentRecords, scheduledDates });
34483
34483
  }
34484
34484
  const { courts } = getVenuesAndCourts({
34485
- dates: scheduleDates,
34486
- ignoreDisabled: true,
34485
+ ignoreDisabled: false,
34487
34486
  tournamentRecords
34488
34487
  });
34489
34488
  const { matchUps } = allCompetitionMatchUps({
@@ -36804,7 +36803,9 @@ const POLICY_MATCHUP_ACTIONS_DEFAULT = {
36804
36803
  },
36805
36804
  processCodes: {
36806
36805
  substitution: ["RANKING.IGNORE", "RATING.IGNORE"]
36807
- }
36806
+ },
36807
+ substituteAfterCompleted: false,
36808
+ substituteWithoutScore: false
36808
36809
  }
36809
36810
  };
36810
36811
 
@@ -49191,11 +49192,17 @@ function validDefinitionKeys(definition) {
49191
49192
  }
49192
49193
  function newDrawDefinition({
49193
49194
  drawId = UUID(),
49195
+ processCodes,
49194
49196
  matchUpType,
49195
49197
  drawType
49196
49198
  }) {
49197
49199
  const drawDefinition = definitionTemplate();
49198
- return Object.assign(drawDefinition, { drawId, drawType, matchUpType });
49200
+ return Object.assign(drawDefinition, {
49201
+ processCodes,
49202
+ matchUpType,
49203
+ drawType,
49204
+ drawId
49205
+ });
49199
49206
  }
49200
49207
 
49201
49208
  let drawDefinition$1;
@@ -58210,7 +58217,11 @@ function generateDrawDefinition(params) {
58210
58217
  return decorateResult({ result: { error: INVALID_VALUES }, stack });
58211
58218
  if (existingDrawDefinition && drawType !== existingDrawDefinition.drawType)
58212
58219
  existingDrawDefinition.drawType = drawType;
58213
- let drawDefinition = existingDrawDefinition ?? newDrawDefinition({ drawType, drawId: params.drawId });
58220
+ let drawDefinition = existingDrawDefinition ?? newDrawDefinition({
58221
+ drawType,
58222
+ drawId: params.drawId,
58223
+ processCodes: params.processCodes
58224
+ });
58214
58225
  if (matchUpFormat || tieFormat) {
58215
58226
  const equivalentInScope = matchUpFormat && event?.matchUpFormat === matchUpFormat || event?.tieFormat && tieFormat && JSON.stringify(event.tieFormat) === JSON.stringify(tieFormat);
58216
58227
  if (!equivalentInScope) {
@@ -58696,10 +58707,24 @@ function modifyEvent({
58696
58707
  eventId,
58697
58708
  event
58698
58709
  }) {
58710
+ const stack = "modifyEvent";
58699
58711
  if (!tournamentRecord)
58700
- return { error: MISSING_TOURNAMENT_RECORD };
58701
- if (!isString(eventId) || !isObject(eventUpdates))
58702
- return { error: INVALID_VALUES };
58712
+ return decorateResult({
58713
+ result: { error: MISSING_TOURNAMENT_RECORD },
58714
+ stack
58715
+ });
58716
+ if (!isString(eventId))
58717
+ return decorateResult({
58718
+ result: { error: MISSING_EVENT },
58719
+ context: { eventId },
58720
+ stack
58721
+ });
58722
+ if (!isObject(eventUpdates))
58723
+ return decorateResult({
58724
+ result: { error: INVALID_VALUES },
58725
+ context: { eventUpdates },
58726
+ stack
58727
+ });
58703
58728
  const enteredParticipantIds = event?.entries?.filter(({ entryStatus }) => {
58704
58729
  const status = entryStatus;
58705
58730
  return [...STRUCTURE_SELECTED_STATUSES, ALTERNATE].includes(status);
@@ -58722,8 +58747,9 @@ function modifyEvent({
58722
58747
  const validGender = !enteredParticipantGenders.length || [MIXED, ANY].includes(eventUpdates.gender ?? "") || enteredParticipantGenders.length === 1 && enteredParticipantGenders[0] === eventUpdates.gender;
58723
58748
  if (eventUpdates.gender && !validGender)
58724
58749
  return decorateResult({
58725
- context: { gender: eventUpdates.gender },
58726
- result: { error: INVALID_VALUES }
58750
+ context: { gender: eventUpdates.gender, validGender },
58751
+ result: { error: INVALID_VALUES },
58752
+ stack
58727
58753
  });
58728
58754
  const validEventTypes = enteredParticipantTypes.includes(TEAM$1) && [TEAM$1] || enteredParticipantTypes.includes(INDIVIDUAL) && [SINGLES] || enteredParticipantTypes.includes(PAIR) && [DOUBLES] || [
58729
58755
  DOUBLES,
@@ -58733,8 +58759,9 @@ function modifyEvent({
58733
58759
  const validEventType = validEventTypes.includes(eventUpdates.eventType ?? "");
58734
58760
  if (eventUpdates.eventType && !validEventType)
58735
58761
  return decorateResult({
58736
- context: { participantType: eventUpdates.eventType },
58737
- result: { error: INVALID_VALUES }
58762
+ context: { participantType: eventUpdates.eventType, validEventType },
58763
+ result: { error: INVALID_VALUES },
58764
+ stack
58738
58765
  });
58739
58766
  if (eventUpdates.eventType)
58740
58767
  event.eventType = eventUpdates.eventType;
@@ -62615,6 +62642,7 @@ function generateEventWithFlights(params) {
62615
62642
  eventExtensions,
62616
62643
  surfaceCategory,
62617
62644
  tieFormatName,
62645
+ processCodes,
62618
62646
  discipline,
62619
62647
  eventLevel,
62620
62648
  timeItems,
@@ -62660,6 +62688,7 @@ function generateEventWithFlights(params) {
62660
62688
  const newEvent = {
62661
62689
  ...eventAttributes,
62662
62690
  surfaceCategory,
62691
+ processCodes,
62663
62692
  discipline,
62664
62693
  eventLevel,
62665
62694
  eventName,