tods-competition-factory 2.0.31 → 2.0.32

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.
@@ -3357,11 +3357,15 @@ type TimeItemResult = {
3357
3357
  };
3358
3358
  type TimeItemArgs = {
3359
3359
  returnPreviousValues?: boolean;
3360
+ tournamentRecord?: Tournament;
3361
+ drawDefinition?: DrawDefinition;
3360
3362
  itemSubTypes?: string[];
3363
+ participantId?: string;
3361
3364
  itemType: string;
3365
+ event?: Event$1;
3362
3366
  element: any;
3363
3367
  };
3364
- declare function getTimeItem({ returnPreviousValues, itemSubTypes, itemType, element, }: TimeItemArgs): TimeItemResult & ResultType;
3368
+ declare function getTimeItem(params: TimeItemArgs): TimeItemResult & ResultType;
3365
3369
  declare function getDrawDefinitionTimeItem({ returnPreviousValues, drawDefinition, itemSubTypes, itemType }: {
3366
3370
  returnPreviousValues: any;
3367
3371
  drawDefinition: any;
@@ -4229,10 +4233,7 @@ declare function deleteFlightProfileAndFlightDraws({ autoPublish, tournamentReco
4229
4233
  error?: ErrorType | undefined;
4230
4234
  info?: any;
4231
4235
  } | {
4232
- error: {
4233
- message: string;
4234
- code: string;
4235
- };
4236
+ error: any;
4236
4237
  };
4237
4238
 
4238
4239
  type ModifyEventMatchUpFormatTimingArgs = {
@@ -4327,10 +4328,7 @@ declare function deleteFlightAndFlightDraw({ autoPublish, tournamentRecord, audi
4327
4328
  event: any;
4328
4329
  force: any;
4329
4330
  }): ResultType | {
4330
- error: {
4331
- message: string;
4332
- code: string;
4333
- };
4331
+ error: any;
4334
4332
  } | {
4335
4333
  success: boolean;
4336
4334
  error?: undefined;
@@ -4418,10 +4416,7 @@ type DeleteDrawDefinitionArgs = {
4418
4416
  event?: Event$1;
4419
4417
  };
4420
4418
  declare function deleteDrawDefinitions(params: DeleteDrawDefinitionArgs): ResultType | {
4421
- error: {
4422
- message: string;
4423
- code: string;
4424
- };
4419
+ error: any;
4425
4420
  };
4426
4421
 
4427
4422
  type AssignSeedPositionsArgs = {
@@ -4563,12 +4558,14 @@ type ModifyEventArgs = {
4563
4558
  eventUpdates: {
4564
4559
  eventType?: EventTypeUnion;
4565
4560
  gender?: GenderUnion;
4561
+ startDate?: string;
4562
+ endDate?: string;
4566
4563
  eventName?: string;
4567
4564
  };
4568
4565
  eventId: string;
4569
4566
  event: Event$1;
4570
4567
  };
4571
- declare function modifyEvent({ tournamentRecord, eventUpdates, eventId, event }: ModifyEventArgs): ResultType;
4568
+ declare function modifyEvent(params: ModifyEventArgs): ResultType;
4572
4569
 
4573
4570
  type AddFlightArgs = {
4574
4571
  qualifyingPositions?: number;
@@ -6295,44 +6292,7 @@ declare function modifyParticipantsSignInStatus({ tournamentRecord, participantI
6295
6292
  tournamentRecord: any;
6296
6293
  participantIds: any;
6297
6294
  signInState: any;
6298
- }): {
6299
- participant?: Participant | undefined;
6300
- tournamentId?: string | undefined;
6301
- error?: ErrorType | undefined;
6302
- } | {
6303
- error: {
6304
- message: string;
6305
- code: string;
6306
- };
6307
- info?: undefined;
6308
- } | {
6309
- error: {
6310
- message: string;
6311
- code: string;
6312
- };
6313
- info: string;
6314
- } | {
6315
- error: {
6316
- message: string;
6317
- code: string;
6318
- };
6319
- signInState: any;
6320
- context?: undefined;
6321
- } | {
6322
- error: {
6323
- message: string;
6324
- code: string;
6325
- };
6326
- context: {
6327
- invalidParticipantIds: any[];
6328
- };
6329
- signInState?: undefined;
6330
- } | {
6331
- success: boolean;
6332
- error?: undefined;
6333
- signInState?: undefined;
6334
- context?: undefined;
6335
- };
6295
+ }): any;
6336
6296
 
6337
6297
  type AddIndividualParticipantIdsType = {
6338
6298
  individualParticipantIds: string[];
@@ -7922,26 +7882,7 @@ declare function generateVirtualCourts(params: any): {
7922
7882
  courts?: undefined;
7923
7883
  };
7924
7884
 
7925
- declare function removeMatchUpCourtAssignment(params: any): {
7926
- error: {
7927
- message: string;
7928
- code: string;
7929
- };
7930
- info?: undefined;
7931
- } | {
7932
- error: {
7933
- message: string;
7934
- code: string;
7935
- };
7936
- info: string;
7937
- } | {
7938
- matchUp?: HydratedMatchUp | undefined;
7939
- structure?: Structure | undefined;
7940
- error?: ErrorType | undefined;
7941
- } | {
7942
- error?: ErrorType | undefined;
7943
- success?: boolean | undefined;
7944
- };
7885
+ declare function removeMatchUpCourtAssignment(params: any): any;
7945
7886
 
7946
7887
  type ProAutoScheduleArgs = {
7947
7888
  tournamentRecords: {
@@ -8013,38 +7954,7 @@ type AllocateTeamMatchUpCourtsArgs = {
8013
7954
  matchUpId: string;
8014
7955
  courtIds: any;
8015
7956
  };
8016
- declare function allocateTeamMatchUpCourts({ removePriorValues, tournamentRecords, tournamentRecord, drawDefinition, disableNotice, courtDayDate, matchUpId, courtIds, }: AllocateTeamMatchUpCourtsArgs): {
8017
- error: {
8018
- message: string;
8019
- code: string;
8020
- };
8021
- info?: undefined;
8022
- } | {
8023
- error: {
8024
- message: string;
8025
- code: string;
8026
- };
8027
- info: string;
8028
- } | {
8029
- success: boolean;
8030
- error?: undefined;
8031
- info?: undefined;
8032
- } | {
8033
- matchUp?: HydratedMatchUp | undefined;
8034
- structure?: Structure | undefined;
8035
- error?: ErrorType | undefined;
8036
- } | (ResultType & {
8037
- venues?: HydratedVenue[] | undefined;
8038
- courts?: HydratedCourt[] | undefined;
8039
- }) | {
8040
- error: {
8041
- message: string;
8042
- code: string;
8043
- };
8044
- context: {
8045
- courtIds: any;
8046
- };
8047
- };
7957
+ declare function allocateTeamMatchUpCourts({ removePriorValues, tournamentRecords, tournamentRecord, drawDefinition, disableNotice, courtDayDate, matchUpId, courtIds, }: AllocateTeamMatchUpCourtsArgs): any;
8048
7958
 
8049
7959
  declare function scheduleMatchUps(params: any): (ResultType & {
8050
7960
  valid?: boolean | undefined;
@@ -8305,27 +8215,7 @@ type AssignMatchUpVenueArgs = {
8305
8215
  matchUpId: string;
8306
8216
  venueId?: string;
8307
8217
  };
8308
- declare function assignMatchUpVenue({ removePriorValues, tournamentRecords, tournamentRecord, drawDefinition, disableNotice, matchUpId, venueId, }: AssignMatchUpVenueArgs): {
8309
- success?: boolean | undefined;
8310
- venue?: Venue | undefined;
8311
- error?: ErrorType | undefined;
8312
- } | {
8313
- error: {
8314
- message: string;
8315
- code: string;
8316
- };
8317
- info?: undefined;
8318
- } | {
8319
- error: {
8320
- message: string;
8321
- code: string;
8322
- };
8323
- info: string;
8324
- } | {
8325
- success: boolean;
8326
- error?: undefined;
8327
- info?: undefined;
8328
- };
8218
+ declare function assignMatchUpVenue({ removePriorValues, tournamentRecords, tournamentRecord, drawDefinition, disableNotice, matchUpId, venueId, }: AssignMatchUpVenueArgs): any;
8329
8219
 
8330
8220
  declare function validateSchedulingProfile({ tournamentRecords, schedulingProfile }: {
8331
8221
  tournamentRecords: any;
@@ -8405,120 +8295,24 @@ declare function addMatchUpScheduledDate({ scheduledDate: dateToSchedule, remove
8405
8295
  }): ResultType;
8406
8296
  declare function addMatchUpCourtOrder({ removePriorValues, tournamentRecord, drawDefinition, disableNotice, courtOrder, matchUpId, }: AddScheduleAttributeArgs & {
8407
8297
  courtOrder?: number;
8408
- }): {
8409
- error: {
8410
- message: string;
8411
- code: string;
8412
- };
8413
- info?: undefined;
8414
- } | {
8415
- error: {
8416
- message: string;
8417
- code: string;
8418
- };
8419
- info: string;
8420
- } | {
8421
- success: boolean;
8422
- error?: undefined;
8423
- info?: undefined;
8424
- };
8298
+ }): any;
8425
8299
  declare function addMatchUpOfficial({ removePriorValues, tournamentRecord, drawDefinition, disableNotice, participantId, officialType, matchUpId, }: AddScheduleAttributeArgs & {
8426
8300
  participantId?: string;
8427
8301
  officialType?: string;
8428
- }): {
8429
- error: {
8430
- message: string;
8431
- code: string;
8432
- };
8433
- info?: undefined;
8434
- } | {
8435
- error: {
8436
- message: string;
8437
- code: string;
8438
- };
8439
- info: string;
8440
- } | {
8441
- success: boolean;
8442
- error?: undefined;
8443
- info?: undefined;
8444
- };
8302
+ }): any;
8445
8303
  declare function addMatchUpStartTime({ removePriorValues, tournamentRecord, drawDefinition, disableNotice, matchUpId, startTime, event, }: AddScheduleAttributeArgs & {
8446
8304
  startTime?: string;
8447
- }): {
8448
- error: {
8449
- message: string;
8450
- code: string;
8451
- };
8452
- info?: undefined;
8453
- } | {
8454
- error: {
8455
- message: string;
8456
- code: string;
8457
- };
8458
- info: string;
8459
- } | {
8460
- success: boolean;
8461
- error?: undefined;
8462
- info?: undefined;
8463
- };
8305
+ }): any;
8464
8306
  declare function addMatchUpEndTime({ validateTimeSeries, removePriorValues, tournamentRecord, drawDefinition, disableNotice, matchUpId, endTime, event, }: AddScheduleAttributeArgs & {
8465
8307
  validateTimeSeries?: boolean;
8466
8308
  endTime?: string;
8467
- }): {
8468
- error: {
8469
- message: string;
8470
- code: string;
8471
- };
8472
- info?: undefined;
8473
- } | {
8474
- error: {
8475
- message: string;
8476
- code: string;
8477
- };
8478
- info: string;
8479
- } | {
8480
- success: boolean;
8481
- error?: undefined;
8482
- info?: undefined;
8483
- };
8309
+ }): any;
8484
8310
  declare function addMatchUpStopTime({ removePriorValues, tournamentRecord, drawDefinition, disableNotice, matchUpId, stopTime, event, }: AddScheduleAttributeArgs & {
8485
8311
  stopTime?: string;
8486
- }): {
8487
- error: {
8488
- message: string;
8489
- code: string;
8490
- };
8491
- info?: undefined;
8492
- } | {
8493
- error: {
8494
- message: string;
8495
- code: string;
8496
- };
8497
- info: string;
8498
- } | {
8499
- success: boolean;
8500
- error?: undefined;
8501
- info?: undefined;
8502
- };
8312
+ }): any;
8503
8313
  declare function addMatchUpResumeTime({ removePriorValues, tournamentRecord, drawDefinition, disableNotice, resumeTime, matchUpId, event, }: AddScheduleAttributeArgs & {
8504
8314
  resumeTime?: string;
8505
- }): {
8506
- error: {
8507
- message: string;
8508
- code: string;
8509
- };
8510
- info?: undefined;
8511
- } | {
8512
- error: {
8513
- message: string;
8514
- code: string;
8515
- };
8516
- info: string;
8517
- } | {
8518
- success: boolean;
8519
- error?: undefined;
8520
- info?: undefined;
8521
- };
8315
+ }): any;
8522
8316
 
8523
8317
  declare const mutate$4_addMatchUpCourtOrder: typeof addMatchUpCourtOrder;
8524
8318
  declare const mutate$4_addMatchUpEndTime: typeof addMatchUpEndTime;
@@ -9281,29 +9075,17 @@ declare function setTournamentEndDate({ tournamentRecord, endDate }: {
9281
9075
  };
9282
9076
 
9283
9077
  type AddTimeItemArgs = {
9078
+ tournamentRecord?: Tournament;
9079
+ drawDefinition?: DrawDefinition;
9284
9080
  removePriorValues?: boolean;
9285
9081
  duplicateValues?: boolean;
9082
+ participantId?: string;
9286
9083
  creationTime?: boolean;
9287
9084
  timeItem: TimeItem;
9085
+ event?: Event$1;
9288
9086
  element: any;
9289
9087
  };
9290
- declare function addTimeItem(params: AddTimeItemArgs): {
9291
- error: {
9292
- message: string;
9293
- code: string;
9294
- };
9295
- info?: undefined;
9296
- } | {
9297
- error: {
9298
- message: string;
9299
- code: string;
9300
- };
9301
- info: string;
9302
- } | {
9303
- success: boolean;
9304
- error?: undefined;
9305
- info?: undefined;
9306
- };
9088
+ declare function addTimeItem(params: AddTimeItemArgs): any;
9307
9089
  type AddParticipantTimeItemArgs = {
9308
9090
  tournamentRecord: Tournament;
9309
9091
  removePriorValues?: boolean;
@@ -9312,61 +9094,9 @@ type AddParticipantTimeItemArgs = {
9312
9094
  participantId: string;
9313
9095
  timeItem: TimeItem;
9314
9096
  };
9315
- declare function addParticipantTimeItem({ creationTime, removePriorValues, tournamentRecord, duplicateValues, participantId, timeItem, }: AddParticipantTimeItemArgs): {
9316
- participant?: Participant | undefined;
9317
- tournamentId?: string | undefined;
9318
- error?: ErrorType | undefined;
9319
- } | {
9320
- error: {
9321
- message: string;
9322
- code: string;
9323
- };
9324
- info?: undefined;
9325
- } | {
9326
- error: {
9327
- message: string;
9328
- code: string;
9329
- };
9330
- info: string;
9331
- } | {
9332
- success: boolean;
9333
- error?: undefined;
9334
- info?: undefined;
9335
- };
9336
- declare function addTournamentTimeItem(params: any): {
9337
- error: {
9338
- message: string;
9339
- code: string;
9340
- };
9341
- info?: undefined;
9342
- } | {
9343
- error: {
9344
- message: string;
9345
- code: string;
9346
- };
9347
- info: string;
9348
- } | {
9349
- success: boolean;
9350
- error?: undefined;
9351
- info?: undefined;
9352
- };
9353
- declare function addEventTimeItem(params: any): {
9354
- error: {
9355
- message: string;
9356
- code: string;
9357
- };
9358
- info?: undefined;
9359
- } | {
9360
- error: {
9361
- message: string;
9362
- code: string;
9363
- };
9364
- info: string;
9365
- } | {
9366
- success: boolean;
9367
- error?: undefined;
9368
- info?: undefined;
9369
- };
9097
+ declare function addParticipantTimeItem({ creationTime, removePriorValues, tournamentRecord, duplicateValues, participantId, timeItem, }: AddParticipantTimeItemArgs): any;
9098
+ declare function addTournamentTimeItem(params: any): any;
9099
+ declare function addEventTimeItem(params: any): any;
9370
9100
 
9371
9101
  type AddExtensionArgs = {
9372
9102
  tournamentRecord?: Tournament;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  function factoryVersion() {
6
- return '2.0.31';
6
+ return '2.0.32';
7
7
  }
8
8
 
9
9
  function isFunction(obj) {
@@ -5607,9 +5607,23 @@ function findTournamentParticipant(params) {
5607
5607
  return { error: PARTICIPANT_NOT_FOUND };
5608
5608
  }
5609
5609
 
5610
- function getTimeItem({ returnPreviousValues, itemSubTypes, itemType, element, }) {
5611
- if (!element)
5612
- return { error: MISSING_VALUE, info: ELEMENT_REQUIRED };
5610
+ function deriveElement(params) {
5611
+ const { tournamentRecord, participantId } = params;
5612
+ if (participantId) {
5613
+ const result = findTournamentParticipant({ tournamentRecord, participantId });
5614
+ return result.participant ?? result;
5615
+ }
5616
+ const element = params.element || params.drawDefinition || params.event || params.tournamentRecord;
5617
+ if (element)
5618
+ return element;
5619
+ return { error: MISSING_VALUE };
5620
+ }
5621
+
5622
+ function getTimeItem(params) {
5623
+ const { returnPreviousValues, itemSubTypes, itemType } = params;
5624
+ const element = deriveElement(params);
5625
+ if (element.error)
5626
+ return element;
5613
5627
  if (itemSubTypes && !Array.isArray(itemSubTypes))
5614
5628
  return { error: INVALID_VALUES, context: { itemSubTypes } };
5615
5629
  if (!Array.isArray(element.timeItems))
@@ -17653,50 +17667,44 @@ function resequenceStructures({ drawDefinition }) {
17653
17667
  }
17654
17668
 
17655
17669
  function addTimeItem(params) {
17656
- const { duplicateValues = true, creationTime = true, removePriorValues, timeItem, element } = params;
17670
+ const { duplicateValues = true, creationTime = true, removePriorValues, timeItem } = params;
17657
17671
  if (!timeItem)
17658
17672
  return { error: MISSING_TIME_ITEM };
17659
- if (!element)
17660
- return { error: MISSING_VALUE, info: ELEMENT_REQUIRED };
17661
- const timeItemAttributes = timeItem && Object.keys(timeItem);
17662
- const requiredAttributes = ['itemType', 'itemValue'];
17663
- const validTimeItem = requiredAttributes.filter((attribute) => timeItemAttributes.includes(attribute)).length ===
17664
- requiredAttributes.length;
17673
+ const element = deriveElement(params);
17674
+ if (element.error)
17675
+ return element;
17676
+ const validTimeItem = isObject(timeItem) && isString(timeItem.itemType) && Object.keys(timeItem).includes('itemValue');
17665
17677
  if (!validTimeItem)
17666
17678
  return { error: INVALID_TIME_ITEM };
17667
17679
  if (!element.timeItems) {
17668
17680
  element.timeItems = [];
17669
17681
  }
17670
- else {
17671
- const { itemType, itemSubTypes, itemValue } = timeItem;
17672
- const existingTimeItem = itemType &&
17673
- getTimeItem({
17674
- itemSubTypes,
17675
- itemType,
17676
- element,
17677
- })?.timeItem;
17678
- if (existingTimeItem &&
17679
- JSON.stringify(existingTimeItem?.itemValue) === JSON.stringify(itemValue) &&
17680
- !duplicateValues) {
17681
- return { ...SUCCESS };
17682
- }
17682
+ else if (hasEquivalentTimeItem({ element, duplicateValues, timeItem })) {
17683
+ return { ...SUCCESS };
17683
17684
  }
17684
- if (timeItem.itemSubTypes && !timeItem.itemSubTypes.length) {
17685
+ if (timeItem.itemSubTypes && !timeItem.itemSubTypes.length)
17685
17686
  delete timeItem.itemSubTypes;
17686
- }
17687
17687
  if (creationTime) {
17688
17688
  const createdAt = new Date().toISOString();
17689
17689
  Object.assign(timeItem, { createdAt });
17690
17690
  }
17691
- if (removePriorValues) {
17691
+ if (removePriorValues)
17692
17692
  element.timeItems = element.timeItems.filter(({ itemType }) => timeItem.itemType !== itemType);
17693
- }
17694
17693
  const doNotAdd = removePriorValues && !timeItem.itemValue;
17695
- if (!doNotAdd) {
17694
+ if (!doNotAdd)
17696
17695
  element.timeItems.push(timeItem);
17697
- }
17698
17696
  return { ...SUCCESS };
17699
17697
  }
17698
+ function hasEquivalentTimeItem({ element, duplicateValues, timeItem }) {
17699
+ const { itemType, itemSubTypes, itemValue } = timeItem;
17700
+ const existingTimeItem = itemType &&
17701
+ getTimeItem({
17702
+ itemSubTypes,
17703
+ itemType,
17704
+ element,
17705
+ })?.timeItem;
17706
+ return (existingTimeItem && JSON.stringify(existingTimeItem?.itemValue) === JSON.stringify(itemValue) && !duplicateValues);
17707
+ }
17700
17708
  function addParticipantTimeItem({ creationTime = true, removePriorValues, tournamentRecord, duplicateValues, participantId, timeItem, }) {
17701
17709
  if (!tournamentRecord)
17702
17710
  return { error: MISSING_TOURNAMENT_RECORD };
@@ -39167,25 +39175,25 @@ function deleteEvents({ removePairParticipants, tournamentRecord, eventIds }) {
39167
39175
  return { ...SUCCESS };
39168
39176
  }
39169
39177
 
39170
- function modifyEvent({ tournamentRecord, eventUpdates, eventId, event }) {
39178
+ function modifyEvent(params) {
39179
+ const paramsCheck = checkRequiredParameters(params, [
39180
+ { tournamentRecord: true, eventId: true, event: true },
39181
+ { eventUpdates: true, _ofType: OBJECT },
39182
+ ]);
39183
+ if (paramsCheck.error)
39184
+ return paramsCheck;
39185
+ const { tournamentRecord, eventUpdates, event } = params;
39171
39186
  const stack = 'modifyEvent';
39172
- if (!tournamentRecord)
39173
- return decorateResult({
39174
- result: { error: MISSING_TOURNAMENT_RECORD },
39175
- stack,
39176
- });
39177
- if (!isString(eventId))
39178
- return decorateResult({
39179
- result: { error: MISSING_EVENT },
39180
- context: { eventId },
39181
- stack,
39182
- });
39183
- if (!isObject(eventUpdates))
39184
- return decorateResult({
39185
- result: { error: INVALID_VALUES },
39186
- context: { eventUpdates },
39187
- stack,
39187
+ if (eventUpdates.startDate || eventUpdates.endDate) {
39188
+ const result = setEventDates({
39189
+ startDate: eventUpdates.startDate,
39190
+ endDate: eventUpdates.endDate,
39191
+ tournamentRecord,
39192
+ event,
39188
39193
  });
39194
+ if (result.error)
39195
+ return decorateResult({ result, stack });
39196
+ }
39189
39197
  const enteredParticipantIds = event?.entries
39190
39198
  ?.filter(({ entryStatus }) => {
39191
39199
  const status = entryStatus;