tods-competition-factory 1.8.40 → 1.8.41

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
@@ -2404,7 +2404,7 @@ const matchUpFormatCode = {
2404
2404
  };
2405
2405
 
2406
2406
  function factoryVersion() {
2407
- return "1.8.40";
2407
+ return "1.8.41";
2408
2408
  }
2409
2409
 
2410
2410
  function getObjectTieFormat(obj) {
@@ -15218,6 +15218,10 @@ const JUNIOR = "JUNIOR";
15218
15218
  const WHEELCHAIR = "WHEELCHAIR";
15219
15219
  const POLICY_SCHEDULING_DEFAULT = {
15220
15220
  [POLICY_TYPE_SCHEDULING]: {
15221
+ allowModificationWhenMatchUpsScheduled: {
15222
+ courts: false,
15223
+ venues: false
15224
+ },
15221
15225
  defaultTimes: {
15222
15226
  averageTimes: [{ categoryNames: [], minutes: { default: 90 } }],
15223
15227
  recoveryTimes: [{ minutes: { [DOUBLES$1]: 30, default: 60 } }]
@@ -15503,6 +15507,10 @@ const POLICY_SCORING_USTA = {
15503
15507
  const POLICY_SCORING_DEFAULT = {
15504
15508
  [POLICY_TYPE_SCORING]: {
15505
15509
  defaultMatchUpFormat: FORMAT_STANDARD,
15510
+ allowDeletionWithScoresPresent: {
15511
+ drawDefinitions: false,
15512
+ structures: false
15513
+ },
15506
15514
  requireAllPositionsAssigned: false,
15507
15515
  processCodes: {
15508
15516
  incompleteAssignmentsOnDefault: ["RANKING.IGNORE"]
@@ -37402,7 +37410,11 @@ function deleteVenue$1({
37402
37410
  tournamentRecord,
37403
37411
  contextFilters
37404
37412
  }).matchUps ?? [];
37405
- if (!matchUpsToUnschedule.length || force) {
37413
+ const appliedPolicies = getAppliedPolicies({
37414
+ tournamentRecord
37415
+ })?.appliedPolicies;
37416
+ const allowModificationWhenMatchUpsScheduled = force || appliedPolicies?.[POLICY_TYPE_SCHEDULING]?.allowDeletionWithScoresPresent?.venues;
37417
+ if (!matchUpsToUnschedule.length || allowModificationWhenMatchUpsScheduled) {
37406
37418
  for (const matchUp of matchUpsToUnschedule) {
37407
37419
  const result = removeCourtAssignment({
37408
37420
  matchUpId: matchUp.matchUpId,
@@ -37614,7 +37626,6 @@ function getScheduledVenueMatchUps({
37614
37626
 
37615
37627
  function deleteCourt$1({
37616
37628
  tournamentRecord,
37617
- drawDefinition,
37618
37629
  disableNotice,
37619
37630
  courtId,
37620
37631
  force
@@ -37627,13 +37638,16 @@ function deleteCourt$1({
37627
37638
  tournamentRecord,
37628
37639
  courtId
37629
37640
  });
37630
- if (!matchUps?.length || force) {
37641
+ const appliedPolicies = getAppliedPolicies({
37642
+ tournamentRecord
37643
+ })?.appliedPolicies;
37644
+ const allowModificationWhenMatchUpsScheduled = force || appliedPolicies?.[POLICY_TYPE_SCHEDULING]?.allowDeletionWithScoresPresent?.courts;
37645
+ if (!matchUps?.length || allowModificationWhenMatchUpsScheduled) {
37631
37646
  for (const matchUp of matchUps ?? []) {
37632
37647
  const result2 = removeCourtAssignment({
37633
37648
  matchUpId: matchUp.matchUpId,
37634
37649
  drawId: matchUp.drawId,
37635
- tournamentRecord,
37636
- drawDefinition
37650
+ tournamentRecord
37637
37651
  });
37638
37652
  if (result2.error)
37639
37653
  return result2;
@@ -37822,6 +37836,10 @@ function modifyCourtAvailability({
37822
37836
  courtId
37823
37837
  });
37824
37838
  if (courtMatchUps?.length) {
37839
+ const appliedPolicies = getAppliedPolicies({
37840
+ tournamentRecord
37841
+ })?.appliedPolicies;
37842
+ force || appliedPolicies?.[POLICY_TYPE_SCHEDULING]?.allowDeletionWithScoresPresent?.courts;
37825
37843
  console.log("scheduled court matchUps", courtMatchUps.length);
37826
37844
  }
37827
37845
  if (court) {
@@ -38158,6 +38176,10 @@ function modifyVenue$1({
38158
38176
  return { error: INVALID_OBJECT };
38159
38177
  if (!venueId)
38160
38178
  return { error: MISSING_VENUE_ID };
38179
+ const appliedPolicies = getAppliedPolicies({
38180
+ tournamentRecord
38181
+ })?.appliedPolicies;
38182
+ const allowModificationWhenMatchUpsScheduled = force || appliedPolicies?.[POLICY_TYPE_SCHEDULING]?.allowDeletionWithScoresPresent?.venues;
38161
38183
  const { matchUps: venueMatchUps } = getScheduledVenueMatchUps({
38162
38184
  tournamentRecord,
38163
38185
  venueId
@@ -38200,7 +38222,7 @@ function modifyVenue$1({
38200
38222
  });
38201
38223
  return result2.matchUps?.length ?? 0;
38202
38224
  }).reduce((a, b) => a + b);
38203
- if (venue && (!scheduleDeletionsCount || force)) {
38225
+ if (venue && (!scheduleDeletionsCount || allowModificationWhenMatchUpsScheduled)) {
38204
38226
  venue.courts = venue.courts?.filter(
38205
38227
  (court) => courtIdsToModify.includes(court.courtId)
38206
38228
  );
@@ -44548,8 +44570,17 @@ function removeStructure({
44548
44570
  const scoresPresent = structureMatchUps.some(
44549
44571
  ({ score }) => scoreHasValue({ score })
44550
44572
  );
44551
- if (scoresPresent && !force)
44552
- return { error: SCORES_PRESENT };
44573
+ if (scoresPresent) {
44574
+ const appliedPolicies = getAppliedPolicies({
44575
+ tournamentRecord,
44576
+ drawDefinition,
44577
+ structure,
44578
+ event
44579
+ })?.appliedPolicies;
44580
+ const allowDeletionWithScoresPresent = force || appliedPolicies?.[POLICY_TYPE_SCORING]?.allowDeletionWithScoresPresent?.structures;
44581
+ if (!allowDeletionWithScoresPresent)
44582
+ return { error: SCORES_PRESENT };
44583
+ }
44553
44584
  const mainStageSequence1 = structures.find(
44554
44585
  ({ stage, stageSequence }) => stage === MAIN && stageSequence === 1
44555
44586
  );
@@ -56270,23 +56301,21 @@ function getPositionAssignments({
56270
56301
  };
56271
56302
  }
56272
56303
 
56273
- function deleteDrawDefinitions({
56274
- autoPublish = true,
56275
- policyDefinitions,
56276
- tournamentRecord,
56277
- drawIds = [],
56278
- auditData,
56279
- eventId,
56280
- event,
56281
- force
56282
- }) {
56283
- if (!tournamentRecord)
56304
+ function deleteDrawDefinitions(params) {
56305
+ if (!params.tournamentRecord)
56284
56306
  return { error: MISSING_TOURNAMENT_RECORD };
56285
56307
  const stack = "deleteDrawDefinitions";
56286
- if (!policyDefinitions) {
56287
- const { appliedPolicies } = getAppliedPolicies({ tournamentRecord, event });
56288
- policyDefinitions = appliedPolicies;
56289
- }
56308
+ let drawIds = params.drawIds ?? [];
56309
+ let event = params.event;
56310
+ const {
56311
+ autoPublish = true,
56312
+ tournamentRecord,
56313
+ auditData,
56314
+ eventId,
56315
+ force
56316
+ } = params;
56317
+ const { appliedPolicies } = getAppliedPolicies({ tournamentRecord, event });
56318
+ const policyDefinitions = { ...appliedPolicies, ...params.policyDefinitions };
56290
56319
  const drawId = Array.isArray(drawIds) ? drawIds[0] : void 0;
56291
56320
  if (!event) {
56292
56321
  const result = findEvent({ tournamentRecord, eventId, drawId });
@@ -56324,6 +56353,7 @@ function deleteDrawDefinitions({
56324
56353
  qualifier,
56325
56354
  bye
56326
56355
  }) => ({ bye, qualifier, drawPosition, participantId });
56356
+ const allowDeletionWithScoresPresent = force || appliedPolicies?.[POLICY_TYPE_SCORING]?.allowDeletionWithScoresPresent?.drawDefinitions;
56327
56357
  const drawIdsWithScoresPresent = [];
56328
56358
  const filteredDrawDefinitions = event.drawDefinitions.filter(
56329
56359
  (drawDefinition) => {
@@ -56332,7 +56362,7 @@ function deleteDrawDefinitions({
56332
56362
  const scoresPresent = matchUps.some(
56333
56363
  ({ score }) => scoreHasValue({ score })
56334
56364
  );
56335
- if (scoresPresent && !force) {
56365
+ if (scoresPresent && !allowDeletionWithScoresPresent) {
56336
56366
  drawIdsWithScoresPresent.push(drawDefinition.drawId);
56337
56367
  return true;
56338
56368
  }
@@ -58100,7 +58130,8 @@ function deleteFlightProfileAndFlightDraws({
58100
58130
  autoPublish = true,
58101
58131
  tournamentRecord,
58102
58132
  auditData,
58103
- event
58133
+ event,
58134
+ force
58104
58135
  }) {
58105
58136
  if (!tournamentRecord)
58106
58137
  return { error: MISSING_TOURNAMENT_RECORD };
@@ -58115,7 +58146,8 @@ function deleteFlightProfileAndFlightDraws({
58115
58146
  autoPublish,
58116
58147
  auditData,
58117
58148
  drawIds,
58118
- event
58149
+ event,
58150
+ force
58119
58151
  });
58120
58152
  if (result.error)
58121
58153
  return result;