tods-competition-factory 1.8.25 → 1.8.26

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.
@@ -1601,7 +1601,9 @@ type AutomatedPositioningArgs = {
1601
1601
  };
1602
1602
  declare function automatedPositioning({ applyPositioning, tournamentRecord, drawDefinition, seedingProfile, structureId, placeByes, seedsOnly, drawSize, event, }: AutomatedPositioningArgs): (ResultType & {
1603
1603
  positionAssignments?: PositionAssignment[] | undefined;
1604
- positioningReport?: any;
1604
+ positioningReport?: {
1605
+ [key: string]: any;
1606
+ } | undefined;
1605
1607
  success?: boolean | undefined;
1606
1608
  conflicts?: any[] | undefined;
1607
1609
  }) | {
@@ -1627,6 +1629,9 @@ type AutomatedPlayoffPositioningArgs = {
1627
1629
  };
1628
1630
  declare function automatedPlayoffPositioning(params: AutomatedPlayoffPositioningArgs): {
1629
1631
  structurePositionAssignments?: StructurePositionAssignmentType[];
1632
+ positioningReports?: {
1633
+ [key: string]: any;
1634
+ }[];
1630
1635
  success?: boolean;
1631
1636
  error?: ErrorType;
1632
1637
  };
@@ -846,18 +846,21 @@ function cycleMutationStatus() {
846
846
  return status;
847
847
  }
848
848
  function addNotice$1({ topic, payload, key }) {
849
- syncGlobalState.modified = true;
850
849
  if (typeof topic !== "string" || typeof payload !== "object") {
851
850
  return;
852
851
  }
853
- if (syncGlobalState.disableNotifications || !syncGlobalState.subscriptions[topic])
852
+ if (!syncGlobalState.disableNotifications)
853
+ syncGlobalState.modified = true;
854
+ if (syncGlobalState.disableNotifications || !syncGlobalState.subscriptions[topic]) {
854
855
  return;
856
+ }
855
857
  if (key) {
856
858
  syncGlobalState.notices = syncGlobalState.notices.filter(
857
859
  (notice) => !(notice.topic === topic && notice.key === key)
858
860
  );
859
861
  }
860
862
  syncGlobalState.notices.push({ topic, payload, key });
863
+ return { ...SUCCESS };
861
864
  }
862
865
  function getNotices({ topic }) {
863
866
  const notices = syncGlobalState.notices.filter((notice) => notice.topic === topic).map((notice) => notice.payload);
@@ -3100,41 +3103,6 @@ function getMatchUpType(params) {
3100
3103
  return { matchUpType };
3101
3104
  }
3102
3105
 
3103
- function modifyEntryProfile({
3104
- drawDefinition,
3105
- attributes
3106
- }) {
3107
- let { extension } = findDrawDefinitionExtension({
3108
- name: ENTRY_PROFILE,
3109
- drawDefinition
3110
- });
3111
- const entryProfile = extension?.value || {};
3112
- attributes.forEach((attribute) => {
3113
- Object.keys(attribute).forEach((key) => {
3114
- if (!entryProfile[key]) {
3115
- entryProfile[key] = attribute[key];
3116
- } else {
3117
- Object.assign(entryProfile[key], attribute[key]);
3118
- }
3119
- });
3120
- });
3121
- extension = {
3122
- name: ENTRY_PROFILE,
3123
- value: entryProfile
3124
- };
3125
- addDrawDefinitionExtension({ drawDefinition, extension });
3126
- return { entryProfile };
3127
- }
3128
-
3129
- function getEntryProfile({ drawDefinition }) {
3130
- const { extension } = findDrawDefinitionExtension({
3131
- name: ENTRY_PROFILE,
3132
- drawDefinition
3133
- });
3134
- const entryProfile = extension?.value || {};
3135
- return { entryProfile };
3136
- }
3137
-
3138
3106
  const MAIN = "MAIN";
3139
3107
  const QUALIFYING = "QUALIFYING";
3140
3108
  const CONSOLATION = "CONSOLATION";
@@ -3328,6 +3296,118 @@ function getDrawStructures({
3328
3296
  }
3329
3297
  }
3330
3298
 
3299
+ function getAllPositionedParticipantIds({
3300
+ drawDefinition
3301
+ }) {
3302
+ if (!drawDefinition)
3303
+ return { error: MISSING_DRAW_DEFINITION };
3304
+ const stagePositionedParticipantIds = {};
3305
+ const allPositionedParticipantIds = (drawDefinition.structures || []).map((structure) => {
3306
+ const stage = structure.stage;
3307
+ if (!stagePositionedParticipantIds[stage])
3308
+ stagePositionedParticipantIds[stage] = [];
3309
+ const { positionAssignments } = getPositionAssignments({ structure });
3310
+ const particiapntIds = positionAssignments?.map(extractAttributes("participantId")).filter(Boolean) ?? [];
3311
+ stagePositionedParticipantIds[stage].push(...particiapntIds);
3312
+ return particiapntIds;
3313
+ }).flat();
3314
+ return { allPositionedParticipantIds, stagePositionedParticipantIds };
3315
+ }
3316
+ function getPositionAssignments({
3317
+ drawDefinition,
3318
+ structureId,
3319
+ structure
3320
+ }) {
3321
+ let error, positionAssignments = [];
3322
+ if (!structure) {
3323
+ if (!drawDefinition) {
3324
+ return { positionAssignments, error: MISSING_DRAW_DEFINITION };
3325
+ }
3326
+ ({ structure, error } = findStructure({ drawDefinition, structureId }));
3327
+ if (error)
3328
+ return { positionAssignments, error };
3329
+ }
3330
+ if (structure.structures) {
3331
+ positionAssignments = [].concat(
3332
+ ...structure.structures.map((structure2) => {
3333
+ return getPositionAssignments({ structure: structure2 }).positionAssignments;
3334
+ })
3335
+ );
3336
+ } else if (structure.positionAssignments) {
3337
+ positionAssignments = structure.positionAssignments;
3338
+ } else {
3339
+ error = MISSING_POSITION_ASSIGNMENTS;
3340
+ }
3341
+ return { positionAssignments, error };
3342
+ }
3343
+ function structureAssignedDrawPositions({
3344
+ drawDefinition,
3345
+ structureId,
3346
+ structure
3347
+ }) {
3348
+ const positionAssignments = getPositionAssignments({
3349
+ drawDefinition,
3350
+ structureId,
3351
+ structure
3352
+ })?.positionAssignments || [];
3353
+ const assignedPositions = positionAssignments?.filter((assignment) => {
3354
+ return assignment.participantId ?? assignment.bye ?? assignment.qualifier;
3355
+ });
3356
+ const allPositionsAssigned = positionAssignments && positionAssignments?.length === assignedPositions?.length;
3357
+ const unassignedPositions = positionAssignments?.filter((assignment) => {
3358
+ return !assignment.participantId && !assignment.bye && !assignment.qualifier;
3359
+ });
3360
+ const byePositions = positionAssignments?.filter((assignment) => {
3361
+ return !assignment.participantId && assignment.bye;
3362
+ });
3363
+ const qualifierPositions = positionAssignments?.filter((assignment) => {
3364
+ return !assignment.participantId && assignment.qualifier;
3365
+ });
3366
+ return {
3367
+ allPositionsAssigned,
3368
+ positionAssignments,
3369
+ unassignedPositions,
3370
+ assignedPositions,
3371
+ qualifierPositions,
3372
+ byePositions
3373
+ };
3374
+ }
3375
+
3376
+ function modifyEntryProfile({
3377
+ drawDefinition,
3378
+ attributes
3379
+ }) {
3380
+ let { extension } = findDrawDefinitionExtension({
3381
+ name: ENTRY_PROFILE,
3382
+ drawDefinition
3383
+ });
3384
+ const entryProfile = extension?.value || {};
3385
+ attributes.forEach((attribute) => {
3386
+ Object.keys(attribute).forEach((key) => {
3387
+ if (!entryProfile[key]) {
3388
+ entryProfile[key] = attribute[key];
3389
+ } else {
3390
+ Object.assign(entryProfile[key], attribute[key]);
3391
+ }
3392
+ });
3393
+ });
3394
+ extension = {
3395
+ name: ENTRY_PROFILE,
3396
+ value: entryProfile
3397
+ };
3398
+ addDrawDefinitionExtension({ drawDefinition, extension });
3399
+ return { entryProfile };
3400
+ }
3401
+
3402
+ function getEntryProfile({ drawDefinition }) {
3403
+ const { extension } = findDrawDefinitionExtension({
3404
+ name: ENTRY_PROFILE,
3405
+ drawDefinition
3406
+ });
3407
+ const entryProfile = extension?.value || {};
3408
+ return { entryProfile };
3409
+ }
3410
+
3331
3411
  const ALTERNATE = EntryStatusEnum.Alternate;
3332
3412
  const CONFIRMED = EntryStatusEnum.Confirmed;
3333
3413
  const DIRECT_ACCEPTANCE = EntryStatusEnum.DirectAcceptance;
@@ -3515,6 +3595,7 @@ function getStageDirectEntriesCount({ stage, drawDefinition }) {
3515
3595
 
3516
3596
  function getStructureSeedAssignments({
3517
3597
  provisionalPositioning,
3598
+ returnAllProxies,
3518
3599
  drawDefinition,
3519
3600
  structureId,
3520
3601
  structure
@@ -3523,6 +3604,9 @@ function getStructureSeedAssignments({
3523
3604
  if (!structure) {
3524
3605
  ({ structure, error } = findStructure({ drawDefinition, structureId }));
3525
3606
  }
3607
+ const positionAssignments = getPositionAssignments({
3608
+ structure
3609
+ }).positionAssignments;
3526
3610
  if (error || !structure)
3527
3611
  return { seedAssignments: [], error: STRUCTURE_NOT_FOUND };
3528
3612
  if (!structureId)
@@ -3536,18 +3620,22 @@ function getStructureSeedAssignments({
3536
3620
  structureId,
3537
3621
  stage
3538
3622
  });
3539
- const seedProxies = entries ? entries.filter((entry) => entry.placementGroup === 1).sort((a, b) => {
3623
+ const proxiedEntries = entries ? entries.filter((entry) => entry.placementGroup === 1).sort((a, b) => {
3540
3624
  return a.GEMscore < b.GEMscore && 1 || a.GEMscore > b.GEMscore && -1 || 0;
3541
3625
  }).map((entry, index) => {
3542
3626
  const seedNumber = index + 1;
3543
3627
  return {
3544
3628
  participantId: entry.participantId,
3545
3629
  seedValue: seedNumber,
3546
- seedNumber,
3547
- seedProxy: true
3630
+ seedProxy: true,
3548
3631
  // flag so that proxy seeding information doesn't get used externally
3632
+ seedNumber
3549
3633
  };
3550
3634
  }) : [];
3635
+ const seedProxies = proxiedEntries?.slice(
3636
+ 0,
3637
+ returnAllProxies ? proxiedEntries.length : positionAssignments.length / 2
3638
+ );
3551
3639
  if (seedProxies.length) {
3552
3640
  seedAssignments = seedProxies;
3553
3641
  } else if (structure.seedAssignments) {
@@ -3556,7 +3644,13 @@ function getStructureSeedAssignments({
3556
3644
  error = MISSING_SEED_ASSIGNMENTS;
3557
3645
  }
3558
3646
  const seedLimit = structure.seedLimit || structure?.positionAssignments?.length;
3559
- return { seedAssignments, seedLimit, stage, stageSequence, error };
3647
+ return {
3648
+ seedAssignments,
3649
+ stageSequence,
3650
+ seedLimit,
3651
+ stage,
3652
+ error
3653
+ };
3560
3654
  }
3561
3655
 
3562
3656
  function getExitProfiles({ drawDefinition }) {
@@ -3835,83 +3929,6 @@ function getSourceDrawPositionRanges({
3835
3929
  return { sourceDrawPositionRanges };
3836
3930
  }
3837
3931
 
3838
- function getAllPositionedParticipantIds({
3839
- drawDefinition
3840
- }) {
3841
- if (!drawDefinition)
3842
- return { error: MISSING_DRAW_DEFINITION };
3843
- const stagePositionedParticipantIds = {};
3844
- const allPositionedParticipantIds = (drawDefinition.structures || []).map((structure) => {
3845
- const stage = structure.stage;
3846
- if (!stagePositionedParticipantIds[stage])
3847
- stagePositionedParticipantIds[stage] = [];
3848
- const { positionAssignments } = getPositionAssignments({ structure });
3849
- const particiapntIds = positionAssignments?.map(extractAttributes("participantId")).filter(Boolean) ?? [];
3850
- stagePositionedParticipantIds[stage].push(...particiapntIds);
3851
- return particiapntIds;
3852
- }).flat();
3853
- return { allPositionedParticipantIds, stagePositionedParticipantIds };
3854
- }
3855
- function getPositionAssignments({
3856
- drawDefinition,
3857
- structureId,
3858
- structure
3859
- }) {
3860
- let error, positionAssignments = [];
3861
- if (!structure) {
3862
- if (!drawDefinition) {
3863
- return { positionAssignments, error: MISSING_DRAW_DEFINITION };
3864
- }
3865
- ({ structure, error } = findStructure({ drawDefinition, structureId }));
3866
- if (error)
3867
- return { positionAssignments, error };
3868
- }
3869
- if (structure.structures) {
3870
- positionAssignments = [].concat(
3871
- ...structure.structures.map((structure2) => {
3872
- return getPositionAssignments({ structure: structure2 }).positionAssignments;
3873
- })
3874
- );
3875
- } else if (structure.positionAssignments) {
3876
- positionAssignments = structure.positionAssignments;
3877
- } else {
3878
- error = MISSING_POSITION_ASSIGNMENTS;
3879
- }
3880
- return { positionAssignments, error };
3881
- }
3882
- function structureAssignedDrawPositions({
3883
- drawDefinition,
3884
- structureId,
3885
- structure
3886
- }) {
3887
- const positionAssignments = getPositionAssignments({
3888
- drawDefinition,
3889
- structureId,
3890
- structure
3891
- })?.positionAssignments || [];
3892
- const assignedPositions = positionAssignments?.filter((assignment) => {
3893
- return assignment.participantId ?? assignment.bye ?? assignment.qualifier;
3894
- });
3895
- const allPositionsAssigned = positionAssignments && positionAssignments?.length === assignedPositions?.length;
3896
- const unassignedPositions = positionAssignments?.filter((assignment) => {
3897
- return !assignment.participantId && !assignment.bye && !assignment.qualifier;
3898
- });
3899
- const byePositions = positionAssignments?.filter((assignment) => {
3900
- return !assignment.participantId && assignment.bye;
3901
- });
3902
- const qualifierPositions = positionAssignments?.filter((assignment) => {
3903
- return !assignment.participantId && assignment.qualifier;
3904
- });
3905
- return {
3906
- allPositionsAssigned,
3907
- positionAssignments,
3908
- unassignedPositions,
3909
- assignedPositions,
3910
- qualifierPositions,
3911
- byePositions
3912
- };
3913
- }
3914
-
3915
3932
  function getOrderedDrawPositions({
3916
3933
  drawPositions,
3917
3934
  roundProfile,
@@ -5393,6 +5410,7 @@ function getSeedGroups({
5393
5410
 
5394
5411
  function getValidSeedBlocks({
5395
5412
  provisionalPositioning,
5413
+ returnAllProxies,
5396
5414
  appliedPolicies,
5397
5415
  drawDefinition,
5398
5416
  allPositions,
@@ -5408,6 +5426,7 @@ function getValidSeedBlocks({
5408
5426
  });
5409
5427
  const { seedAssignments } = getStructureSeedAssignments({
5410
5428
  provisionalPositioning,
5429
+ returnAllProxies,
5411
5430
  drawDefinition,
5412
5431
  structure
5413
5432
  });
@@ -5642,6 +5661,7 @@ function getNextSeedBlock(params) {
5642
5661
  } = params;
5643
5662
  const { structure } = findStructure({ drawDefinition, structureId });
5644
5663
  const { seedAssignments } = getStructureSeedAssignments({
5664
+ returnAllProxies: params.returnAllProxies,
5645
5665
  provisionalPositioning,
5646
5666
  drawDefinition,
5647
5667
  structure
@@ -5653,6 +5673,7 @@ function getNextSeedBlock(params) {
5653
5673
  const assignedDrawPositions = positionsWithParticipants?.map((assignment) => assignment.drawPosition).filter(Boolean);
5654
5674
  const { appliedPolicies } = getAppliedPolicies({ drawDefinition });
5655
5675
  const validSeedBlocks = seedBlockInfo?.validSeedBlocks || structure && getValidSeedBlocks({
5676
+ returnAllProxies: params.returnAllProxies,
5656
5677
  provisionalPositioning,
5657
5678
  appliedPolicies,
5658
5679
  drawDefinition,
@@ -11934,8 +11955,7 @@ function randomUnseededSeparation({
11934
11955
  structureId,
11935
11956
  avoidance,
11936
11957
  drawSize,
11937
- entries,
11938
- // entries for the specific stage of drawDefinition
11958
+ // entries, // entries for the specific stage of drawDefinition
11939
11959
  event
11940
11960
  }) {
11941
11961
  if (!avoidance) {
@@ -11973,10 +11993,11 @@ function randomUnseededSeparation({
11973
11993
  const isRoundRobin = structure?.structureType === CONTAINER;
11974
11994
  const params = isRoundRobin ? { structure, matchUps, allDrawPositions, roundsToSeparate } : { matchUps, allDrawPositions, roundsToSeparate };
11975
11995
  const { drawPositionGroups, drawPositionChunks } = isRoundRobin ? roundRobinParticipantGroups(params) : eliminationParticipantGroups(params);
11976
- const idCollections = {};
11977
- idCollections.groupParticipants = participants.filter((participant) => participant.participantType === GROUP).map((participant) => participant.participantId);
11978
- idCollections.teamParticipants = participants.filter((participant) => participant.participantType === TEAM).map((participant) => participant.participantId);
11979
- idCollections.pairParticipants = participants.filter((participant) => participant.participantType === PAIR).map((participant) => participant.participantId);
11996
+ const idCollections = {
11997
+ groupParticipants: participants.filter((participant) => participant.participantType === GROUP).map((participant) => participant.participantId),
11998
+ teamParticipants: participants.filter((participant) => participant.participantType === TEAM).map((participant) => participant.participantId),
11999
+ pairParticipants: participants.filter((participant) => participant.participantType === PAIR).map((participant) => participant.participantId)
12000
+ };
11980
12001
  const allGroups = getAttributeGroupings({
11981
12002
  targetParticipantIds: unseededParticipantIds,
11982
12003
  policyAttributes,
@@ -12037,8 +12058,8 @@ function randomUnseededSeparation({
12037
12058
  policyAttributes,
12038
12059
  idCollections,
12039
12060
  allGroups,
12040
- drawSize,
12041
- entries
12061
+ drawSize
12062
+ // entries,
12042
12063
  })
12043
12064
  );
12044
12065
  const candidates = noPairPriorityCandidates.concat(...pairedPriorityCandidates).filter((candidate2) => !candidate2.errors?.length);
@@ -12471,11 +12492,11 @@ function getSeedOrderByePositions({
12471
12492
  const strictSeedOrderByePositions = getOrderedByePositions({
12472
12493
  orderedSeedDrawPositions: orderedSortedFirstRoundSeededDrawPositions,
12473
12494
  relevantMatchUps
12474
- }).slice(0, positionedSeeds.length);
12495
+ }).slice(0, byesToPlace);
12475
12496
  const blockSeedOrderByePositions = getOrderedByePositions({
12476
12497
  orderedSeedDrawPositions: blockSortedRandomDrawPositions,
12477
12498
  relevantMatchUps
12478
- }).slice(0, positionedSeeds.length);
12499
+ }).slice(0, byesToPlace);
12479
12500
  return {
12480
12501
  strictSeedOrderByePositions,
12481
12502
  blockSeedOrderByePositions,
@@ -13157,7 +13178,6 @@ function automatedPositioning$1({
13157
13178
  event
13158
13179
  }) : void 0;
13159
13180
  if (result2?.error) {
13160
- console.log("positionByes", { result: result2 });
13161
13181
  return handleErrorCondition(result2);
13162
13182
  }
13163
13183
  unseededByePositions = result2?.unseededByePositions;
@@ -13315,6 +13335,7 @@ function automatedPlayoffPositioning(params) {
13315
13335
  );
13316
13336
  const structurePositionAssignments = [];
13317
13337
  const participants = tournamentRecord?.participants;
13338
+ const positioningReports = [];
13318
13339
  if (playoffStructures) {
13319
13340
  for (const structure of playoffStructures) {
13320
13341
  const { structureId: playoffStructureId } = structure;
@@ -13336,9 +13357,11 @@ function automatedPlayoffPositioning(params) {
13336
13357
  structureId: playoffStructureId
13337
13358
  });
13338
13359
  }
13360
+ if (result.positioningReport)
13361
+ positioningReports.push(result.positioningReport);
13339
13362
  }
13340
13363
  }
13341
- return { ...SUCCESS, structurePositionAssignments };
13364
+ return { ...SUCCESS, structurePositionAssignments, positioningReports };
13342
13365
  }
13343
13366
 
13344
13367
  function getStructureRoundProfile({