tods-competition-factory 0.145.2 → 0.148.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.
@@ -249,7 +249,7 @@ const matchUpFormatCode = {
249
249
  };
250
250
 
251
251
  function factoryVersion() {
252
- return '0.145.2';
252
+ return '0.148.0';
253
253
  }
254
254
 
255
255
  function isPowerOf2(n) {
@@ -8793,62 +8793,227 @@ function getAllStructureMatchUps({
8793
8793
  }
8794
8794
  }
8795
8795
 
8796
- function addParticipantGroupings({
8797
- participants = []
8796
+ const ADD_DRAW_DEFINITION = 'addDrawDefinition';
8797
+ const ADD_MATCHUPS = 'addMatchUps';
8798
+ const ADD_PARTICIPANTS = 'addParticipants';
8799
+ const ADD_VENUE = 'addVenue';
8800
+ const AUDIT = 'audit';
8801
+ const DELETED_DRAW_IDS = 'deletedDrawIds';
8802
+ const DELETE_PARTICIPANTS = 'deleteParticipants';
8803
+ const DELETE_VENUE = 'deleteVenue';
8804
+ const DELETED_MATCHUP_IDS = 'deletedMatchUpIds';
8805
+ const MODIFY_DRAW_DEFINITION = 'modifyDrawDefinition';
8806
+ const MODIFY_MATCHUP = 'modifyMatchUp';
8807
+ const MODIFY_PARTICIPANTS = 'modifyParticipants';
8808
+ const MODIFY_VENUE = 'modifyVenue';
8809
+ const PUBLISH_EVENT = 'publishEvent';
8810
+ const UNPUBLISH_EVENT = 'unPublishEvent';
8811
+ const PUBLISH_EVENT_SEEDING = 'publishEventSeeding';
8812
+ const UNPUBLISH_EVENT_SEEDING = 'unPublishEventSeeding';
8813
+ const topicConstants = {
8814
+ ADD_DRAW_DEFINITION,
8815
+ ADD_MATCHUPS,
8816
+ ADD_PARTICIPANTS,
8817
+ ADD_VENUE,
8818
+ AUDIT,
8819
+ DELETED_DRAW_IDS,
8820
+ DELETE_PARTICIPANTS,
8821
+ DELETE_VENUE,
8822
+ DELETED_MATCHUP_IDS,
8823
+ MODIFY_DRAW_DEFINITION,
8824
+ MODIFY_MATCHUP,
8825
+ MODIFY_PARTICIPANTS,
8826
+ MODIFY_VENUE,
8827
+ PUBLISH_EVENT,
8828
+ UNPUBLISH_EVENT,
8829
+ PUBLISH_EVENT_SEEDING,
8830
+ UNPUBLISH_EVENT_SEEDING
8831
+ };
8832
+
8833
+ function drawUpdatedAt(drawDefinition, structureIds) {
8834
+ var _drawDefinition$struc;
8835
+
8836
+ if (!drawDefinition) return;
8837
+ let updatedAt = Date.now();
8838
+
8839
+ if (updatedAt === drawDefinition.updatedAt) {
8840
+ updatedAt += 1;
8841
+ }
8842
+
8843
+ const relevantStructureIds = structureIds === null || structureIds === void 0 ? void 0 : structureIds.filter(Boolean);
8844
+ drawDefinition.updatedAt = updatedAt;
8845
+ (_drawDefinition$struc = drawDefinition.structures) === null || _drawDefinition$struc === void 0 ? void 0 : _drawDefinition$struc.forEach(structure => {
8846
+ if (!(relevantStructureIds !== null && relevantStructureIds !== void 0 && relevantStructureIds.length) || relevantStructureIds !== null && relevantStructureIds !== void 0 && relevantStructureIds.includes(structure.structureId)) {
8847
+ structure.updatedAt = updatedAt;
8848
+ }
8849
+ });
8850
+ }
8851
+
8852
+ function addMatchUpsNotice({
8853
+ drawDefinition,
8854
+ matchUps,
8855
+ tournamentId
8798
8856
  }) {
8799
- const participantsWithGroupings = makeDeepCopy(participants, true, true);
8800
- const teamParticipants = participantsWithGroupings.filter(participant => participant.participantType === TEAM$1);
8801
- const groupParticipants = participantsWithGroupings.filter(participant => participant.participantType === GROUP); // should pairParticipants only consider those that are in the same event as current draw?
8802
- // TODO: this requires access to the parent event which is not currently in scope
8857
+ drawUpdatedAt(drawDefinition);
8858
+ addNotice({
8859
+ topic: ADD_MATCHUPS,
8860
+ payload: {
8861
+ matchUps,
8862
+ tournamentId
8863
+ }
8864
+ });
8865
+ }
8866
+ function deleteMatchUpsNotice({
8867
+ drawDefinition,
8868
+ tournamentId,
8869
+ matchUpIds,
8870
+ action
8871
+ }) {
8872
+ drawUpdatedAt(drawDefinition);
8873
+ addNotice({
8874
+ topic: DELETED_MATCHUP_IDS,
8875
+ payload: {
8876
+ tournamentId,
8877
+ matchUpIds,
8878
+ action
8879
+ }
8880
+ });
8881
+ }
8882
+ function modifyMatchUpNotice({
8883
+ drawDefinition,
8884
+ matchUp,
8885
+ tournamentId
8886
+ }) {
8887
+ const structureId = matchUp.structureId;
8888
+ modifyDrawNotice({
8889
+ drawDefinition,
8890
+ structureIds: [structureId]
8891
+ });
8892
+ addNotice({
8893
+ topic: MODIFY_MATCHUP,
8894
+ payload: {
8895
+ matchUp,
8896
+ tournamentId
8897
+ },
8898
+ key: matchUp.matchUpId
8899
+ });
8900
+ }
8901
+ function addDrawNotice({
8902
+ drawDefinition
8903
+ }) {
8904
+ drawUpdatedAt(drawDefinition);
8905
+ addNotice({
8906
+ topic: ADD_DRAW_DEFINITION,
8907
+ payload: {
8908
+ drawDefinition
8909
+ },
8910
+ key: drawDefinition.drawId
8911
+ });
8912
+ }
8913
+ function deleteDrawNotice({
8914
+ drawId
8915
+ }) {
8916
+ addNotice({
8917
+ topic: DELETED_DRAW_IDS,
8918
+ payload: {
8919
+ drawId
8920
+ }
8921
+ });
8922
+ }
8923
+ function modifyDrawNotice({
8924
+ drawDefinition,
8925
+ structureIds
8926
+ }) {
8927
+ drawUpdatedAt(drawDefinition, structureIds);
8928
+ addNotice({
8929
+ topic: MODIFY_DRAW_DEFINITION,
8930
+ payload: {
8931
+ drawDefinition
8932
+ },
8933
+ key: drawDefinition.drawId
8934
+ });
8935
+ }
8803
8936
 
8804
- const pairParticipants = participantsWithGroupings.filter(participant => participant.participantType === PAIR$1);
8805
- participantsWithGroupings.forEach(participant => {
8806
- if (participant.participantType === INDIVIDUAL$1) {
8807
- const {
8808
- participantId
8809
- } = participant;
8810
- participant.groupParticipantIds = [];
8811
- participant.teamParticipantIds = [];
8812
- participant.pairParticipantIds = [];
8813
- participant.groups = [];
8814
- participant.teams = [];
8815
- teamParticipants.forEach(team => {
8816
- ((team === null || team === void 0 ? void 0 : team.individualParticipantIds) || []).forEach(individualParticipantId => {
8817
- if (individualParticipantId === participantId && !participant.teamParticipantIds.includes(team.participantId)) {
8818
- participant.teamParticipantIds.push(team.participantId);
8819
- participant.teams.push({
8820
- participantRoleResponsibilities: team.participantRoleResponsibilities,
8821
- participantOtherName: team.participantOtherName,
8822
- participantName: team.participantName,
8823
- participantId: team.participantId,
8824
- teamId: team.teamId
8825
- });
8826
- }
8827
- });
8828
- });
8829
- pairParticipants.forEach(pair => {
8830
- ((pair === null || pair === void 0 ? void 0 : pair.individualParticipantIds) || []).forEach(individualParticipantId => {
8831
- if (individualParticipantId === participantId && !participant.pairParticipantIds.includes(pair.participantId)) {
8832
- participant.pairParticipantIds.push(pair.participantId);
8833
- }
8834
- });
8835
- });
8836
- groupParticipants.forEach(group => {
8837
- ((group === null || group === void 0 ? void 0 : group.individualParticipantIds) || []).forEach(individualParticipantId => {
8838
- if (individualParticipantId === participantId && !participant.groupParticipantIds.includes(group.participantId)) {
8839
- participant.groupParticipantIds.push(group.participantId);
8840
- participant.groups.push({
8841
- participantRoleResponsibilities: group.participantRoleResponsibilities,
8842
- participantOtherName: group.participantOtherName,
8843
- participantName: group.participantName,
8844
- participantId: group.participantId
8845
- });
8846
- }
8847
- });
8937
+ function updateTieFormat({
8938
+ tournamentRecord,
8939
+ drawDefinition,
8940
+ structure,
8941
+ tieFormat,
8942
+ eventId,
8943
+ matchUp,
8944
+ event
8945
+ }) {
8946
+ if (event && eventId) {
8947
+ event.tieFormat = tieFormat;
8948
+ } else if (matchUp) {
8949
+ matchUp.tieFormat = tieFormat;
8950
+ modifyMatchUpNotice({
8951
+ tournamentId: tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.tournamentId,
8952
+ drawDefinition,
8953
+ matchUp
8954
+ });
8955
+ } else if (structure) {
8956
+ updateStructureMatchUps$1({
8957
+ tournamentRecord,
8958
+ drawDefinition,
8959
+ structure,
8960
+ tieFormat
8961
+ });
8962
+ modifyDrawNotice({
8963
+ drawDefinition,
8964
+ structureIds: [structure.structureId]
8965
+ });
8966
+ } else if (drawDefinition) {
8967
+ drawDefinition.tieFormat = tieFormat;
8968
+ const modifiedStructureIds = [];
8969
+
8970
+ for (const structure of drawDefinition.structures || []) {
8971
+ updateStructureMatchUps$1({
8972
+ tournamentRecord,
8973
+ drawDefinition,
8974
+ structure,
8975
+ tieFormat
8848
8976
  });
8977
+ modifiedStructureIds.push(structure.structureId);
8849
8978
  }
8850
- });
8851
- return participantsWithGroupings;
8979
+
8980
+ modifyDrawNotice({
8981
+ drawDefinition,
8982
+ structureIds: modifiedStructureIds
8983
+ });
8984
+ } else {
8985
+ return {
8986
+ error: MISSING_DRAW_DEFINITION
8987
+ };
8988
+ }
8989
+ }
8990
+
8991
+ function updateStructureMatchUps$1({
8992
+ tournamentRecord,
8993
+ drawDefinition,
8994
+ structure,
8995
+ tieFormat
8996
+ }) {
8997
+ var _getAllStructureMatch;
8998
+
8999
+ const matchUps = (_getAllStructureMatch = getAllStructureMatchUps({
9000
+ matchUpFilters: {
9001
+ matchUpTypes: [TEAM$3]
9002
+ },
9003
+ structure
9004
+ })) === null || _getAllStructureMatch === void 0 ? void 0 : _getAllStructureMatch.matchUps; // all team matchUps in the structure which do not have tieFormats should have matchUps added
9005
+
9006
+ const targetMatchUps = matchUps.filter(matchUp => matchUp.matchUpStatus !== COMPLETED);
9007
+
9008
+ for (const matchUp of targetMatchUps) {
9009
+ // don't update matchUps which are already COMPLETED
9010
+ matchUp.tieFormat = tieFormat;
9011
+ modifyMatchUpNotice({
9012
+ tournamentId: tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.tournamentId,
9013
+ drawDefinition,
9014
+ matchUp
9015
+ });
9016
+ }
8852
9017
  }
8853
9018
 
8854
9019
  /*
@@ -8922,6 +9087,155 @@ function findMatchUp$1({
8922
9087
  };
8923
9088
  }
8924
9089
 
9090
+ function getTieFormat$1({
9091
+ drawDefinition,
9092
+ structureId,
9093
+ matchUpId,
9094
+ eventId,
9095
+ event
9096
+ }) {
9097
+ if ((matchUpId || structureId) && !drawDefinition) return {
9098
+ error: MISSING_DRAW_DEFINITION
9099
+ };
9100
+ let error, matchUp, structure, tieFormat;
9101
+
9102
+ if (eventId && event !== null && event !== void 0 && event.tieFormat) {
9103
+ tieFormat = event.tieFormat;
9104
+ } else if (matchUpId) {
9105
+ var _structure;
9106
+
9107
+ ({
9108
+ error,
9109
+ matchUp,
9110
+ structure
9111
+ } = findMatchUp$1({
9112
+ drawDefinition,
9113
+ matchUpId
9114
+ }));
9115
+ if (error) return {
9116
+ error
9117
+ };
9118
+ tieFormat = matchUp.tieFormat || ((_structure = structure) === null || _structure === void 0 ? void 0 : _structure.tieFormat) || (drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.tieFormat);
9119
+ } else if (drawDefinition && structureId) {
9120
+ var _structure2;
9121
+
9122
+ const result = findStructure({
9123
+ drawDefinition,
9124
+ structureId
9125
+ });
9126
+ structure = result === null || result === void 0 ? void 0 : result.structure;
9127
+ tieFormat = ((_structure2 = structure) === null || _structure2 === void 0 ? void 0 : _structure2.tieFormat) || drawDefinition.tieFormat;
9128
+ } else {
9129
+ tieFormat = drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.tieFormat;
9130
+ }
9131
+
9132
+ if (!tieFormat) return {
9133
+ error: MISSING_TIE_FORMAT
9134
+ };
9135
+ return {
9136
+ tieFormat,
9137
+ matchUp,
9138
+ structure
9139
+ };
9140
+ }
9141
+
9142
+ function orderCollectionDefinitions({
9143
+ tournamentRecord,
9144
+ drawDefinition,
9145
+ structureId,
9146
+ matchUpId,
9147
+ orderMap,
9148
+ eventId,
9149
+ event
9150
+ }) {
9151
+ let result = getTieFormat$1({
9152
+ drawDefinition,
9153
+ structureId,
9154
+ matchUpId,
9155
+ eventId,
9156
+ event
9157
+ });
9158
+ if (result.error) return result;
9159
+ const {
9160
+ matchUp,
9161
+ structure,
9162
+ tieFormat: existingTieFormat
9163
+ } = result;
9164
+ const tieFormat = makeDeepCopy(existingTieFormat, false, true);
9165
+ tieFormat.collectionDefinitions.forEach(collectionDefinition => {
9166
+ const collectionOrder = orderMap[collectionDefinition.collectionId];
9167
+ if (collectionOrder) collectionDefinition.collectionOrder = collectionOrder;
9168
+ });
9169
+ tieFormat.collectionDefinitions.sort((a, b) => a.collectionOrder - b.collectionOrder);
9170
+ return updateTieFormat({
9171
+ tournamentRecord,
9172
+ drawDefinition,
9173
+ structure,
9174
+ tieFormat,
9175
+ eventId,
9176
+ matchUp,
9177
+ event
9178
+ });
9179
+ }
9180
+
9181
+ function addParticipantGroupings({
9182
+ participants = []
9183
+ }) {
9184
+ const participantsWithGroupings = makeDeepCopy(participants, true, true);
9185
+ const teamParticipants = participantsWithGroupings.filter(participant => participant.participantType === TEAM$1);
9186
+ const groupParticipants = participantsWithGroupings.filter(participant => participant.participantType === GROUP); // should pairParticipants only consider those that are in the same event as current draw?
9187
+ // TODO: this requires access to the parent event which is not currently in scope
9188
+
9189
+ const pairParticipants = participantsWithGroupings.filter(participant => participant.participantType === PAIR$1);
9190
+ participantsWithGroupings.forEach(participant => {
9191
+ if (participant.participantType === INDIVIDUAL$1) {
9192
+ const {
9193
+ participantId
9194
+ } = participant;
9195
+ participant.groupParticipantIds = [];
9196
+ participant.teamParticipantIds = [];
9197
+ participant.pairParticipantIds = [];
9198
+ participant.groups = [];
9199
+ participant.teams = [];
9200
+ teamParticipants.forEach(team => {
9201
+ ((team === null || team === void 0 ? void 0 : team.individualParticipantIds) || []).forEach(individualParticipantId => {
9202
+ if (individualParticipantId === participantId && !participant.teamParticipantIds.includes(team.participantId)) {
9203
+ participant.teamParticipantIds.push(team.participantId);
9204
+ participant.teams.push({
9205
+ participantRoleResponsibilities: team.participantRoleResponsibilities,
9206
+ participantOtherName: team.participantOtherName,
9207
+ participantName: team.participantName,
9208
+ participantId: team.participantId,
9209
+ teamId: team.teamId
9210
+ });
9211
+ }
9212
+ });
9213
+ });
9214
+ pairParticipants.forEach(pair => {
9215
+ ((pair === null || pair === void 0 ? void 0 : pair.individualParticipantIds) || []).forEach(individualParticipantId => {
9216
+ if (individualParticipantId === participantId && !participant.pairParticipantIds.includes(pair.participantId)) {
9217
+ participant.pairParticipantIds.push(pair.participantId);
9218
+ }
9219
+ });
9220
+ });
9221
+ groupParticipants.forEach(group => {
9222
+ ((group === null || group === void 0 ? void 0 : group.individualParticipantIds) || []).forEach(individualParticipantId => {
9223
+ if (individualParticipantId === participantId && !participant.groupParticipantIds.includes(group.participantId)) {
9224
+ participant.groupParticipantIds.push(group.participantId);
9225
+ participant.groups.push({
9226
+ participantRoleResponsibilities: group.participantRoleResponsibilities,
9227
+ participantOtherName: group.participantOtherName,
9228
+ participantName: group.participantName,
9229
+ participantId: group.participantId
9230
+ });
9231
+ }
9232
+ });
9233
+ });
9234
+ }
9235
+ });
9236
+ return participantsWithGroupings;
9237
+ }
9238
+
8925
9239
  // ISO- 3166-1 alpha-2
8926
9240
  function countryToFlag(isoCode) {
8927
9241
  return isoCode && typeof String.fromCodePoint !== 'undefined' ? isoCode.toUpperCase().replace(/./g, char => String.fromCodePoint(char.charCodeAt(0) + 127397)) : isoCode;
@@ -11763,199 +12077,6 @@ function calculateWinCriteria({
11763
12077
  };
11764
12078
  }
11765
12079
 
11766
- function getTieFormat$1({
11767
- drawDefinition,
11768
- structureId,
11769
- matchUpId,
11770
- eventId,
11771
- event
11772
- }) {
11773
- if ((matchUpId || structureId) && !drawDefinition) return {
11774
- error: MISSING_DRAW_DEFINITION
11775
- };
11776
- let error, matchUp, structure, tieFormat;
11777
-
11778
- if (eventId && event !== null && event !== void 0 && event.tieFormat) {
11779
- tieFormat = event.tieFormat;
11780
- } else if (matchUpId) {
11781
- var _structure;
11782
-
11783
- ({
11784
- error,
11785
- matchUp,
11786
- structure
11787
- } = findMatchUp$1({
11788
- drawDefinition,
11789
- matchUpId
11790
- }));
11791
- if (error) return {
11792
- error
11793
- };
11794
- tieFormat = matchUp.tieFormat || ((_structure = structure) === null || _structure === void 0 ? void 0 : _structure.tieFormat) || (drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.tieFormat);
11795
- } else if (drawDefinition && structureId) {
11796
- var _structure2;
11797
-
11798
- const result = findStructure({
11799
- drawDefinition,
11800
- structureId
11801
- });
11802
- structure = result === null || result === void 0 ? void 0 : result.structure;
11803
- tieFormat = ((_structure2 = structure) === null || _structure2 === void 0 ? void 0 : _structure2.tieFormat) || drawDefinition.tieFormat;
11804
- } else {
11805
- tieFormat = drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.tieFormat;
11806
- }
11807
-
11808
- if (!tieFormat) return {
11809
- error: MISSING_TIE_FORMAT
11810
- };
11811
- return {
11812
- tieFormat,
11813
- matchUp,
11814
- structure
11815
- };
11816
- }
11817
-
11818
- const ADD_DRAW_DEFINITION = 'addDrawDefinition';
11819
- const ADD_MATCHUPS = 'addMatchUps';
11820
- const ADD_PARTICIPANTS = 'addParticipants';
11821
- const ADD_VENUE = 'addVenue';
11822
- const AUDIT = 'audit';
11823
- const DELETED_DRAW_IDS = 'deletedDrawIds';
11824
- const DELETE_PARTICIPANTS = 'deleteParticipants';
11825
- const DELETE_VENUE = 'deleteVenue';
11826
- const DELETED_MATCHUP_IDS = 'deletedMatchUpIds';
11827
- const MODIFY_DRAW_DEFINITION = 'modifyDrawDefinition';
11828
- const MODIFY_MATCHUP = 'modifyMatchUp';
11829
- const MODIFY_PARTICIPANTS = 'modifyParticipants';
11830
- const MODIFY_VENUE = 'modifyVenue';
11831
- const PUBLISH_EVENT = 'publishEvent';
11832
- const UNPUBLISH_EVENT = 'unPublishEvent';
11833
- const PUBLISH_EVENT_SEEDING = 'publishEventSeeding';
11834
- const UNPUBLISH_EVENT_SEEDING = 'unPublishEventSeeding';
11835
- const topicConstants = {
11836
- ADD_DRAW_DEFINITION,
11837
- ADD_MATCHUPS,
11838
- ADD_PARTICIPANTS,
11839
- ADD_VENUE,
11840
- AUDIT,
11841
- DELETED_DRAW_IDS,
11842
- DELETE_PARTICIPANTS,
11843
- DELETE_VENUE,
11844
- DELETED_MATCHUP_IDS,
11845
- MODIFY_DRAW_DEFINITION,
11846
- MODIFY_MATCHUP,
11847
- MODIFY_PARTICIPANTS,
11848
- MODIFY_VENUE,
11849
- PUBLISH_EVENT,
11850
- UNPUBLISH_EVENT,
11851
- PUBLISH_EVENT_SEEDING,
11852
- UNPUBLISH_EVENT_SEEDING
11853
- };
11854
-
11855
- function drawUpdatedAt(drawDefinition, structureIds) {
11856
- var _drawDefinition$struc;
11857
-
11858
- if (!drawDefinition) return;
11859
- let updatedAt = Date.now();
11860
-
11861
- if (updatedAt === drawDefinition.updatedAt) {
11862
- updatedAt += 1;
11863
- }
11864
-
11865
- const relevantStructureIds = structureIds === null || structureIds === void 0 ? void 0 : structureIds.filter(Boolean);
11866
- drawDefinition.updatedAt = updatedAt;
11867
- (_drawDefinition$struc = drawDefinition.structures) === null || _drawDefinition$struc === void 0 ? void 0 : _drawDefinition$struc.forEach(structure => {
11868
- if (!(relevantStructureIds !== null && relevantStructureIds !== void 0 && relevantStructureIds.length) || relevantStructureIds !== null && relevantStructureIds !== void 0 && relevantStructureIds.includes(structure.structureId)) {
11869
- structure.updatedAt = updatedAt;
11870
- }
11871
- });
11872
- }
11873
-
11874
- function addMatchUpsNotice({
11875
- drawDefinition,
11876
- matchUps,
11877
- tournamentId
11878
- }) {
11879
- drawUpdatedAt(drawDefinition);
11880
- addNotice({
11881
- topic: ADD_MATCHUPS,
11882
- payload: {
11883
- matchUps,
11884
- tournamentId
11885
- }
11886
- });
11887
- }
11888
- function deleteMatchUpsNotice({
11889
- drawDefinition,
11890
- tournamentId,
11891
- matchUpIds,
11892
- action
11893
- }) {
11894
- drawUpdatedAt(drawDefinition);
11895
- addNotice({
11896
- topic: DELETED_MATCHUP_IDS,
11897
- payload: {
11898
- tournamentId,
11899
- matchUpIds,
11900
- action
11901
- }
11902
- });
11903
- }
11904
- function modifyMatchUpNotice({
11905
- drawDefinition,
11906
- matchUp,
11907
- tournamentId
11908
- }) {
11909
- const structureId = matchUp.structureId;
11910
- modifyDrawNotice({
11911
- drawDefinition,
11912
- structureIds: [structureId]
11913
- });
11914
- addNotice({
11915
- topic: MODIFY_MATCHUP,
11916
- payload: {
11917
- matchUp,
11918
- tournamentId
11919
- },
11920
- key: matchUp.matchUpId
11921
- });
11922
- }
11923
- function addDrawNotice({
11924
- drawDefinition
11925
- }) {
11926
- drawUpdatedAt(drawDefinition);
11927
- addNotice({
11928
- topic: ADD_DRAW_DEFINITION,
11929
- payload: {
11930
- drawDefinition
11931
- },
11932
- key: drawDefinition.drawId
11933
- });
11934
- }
11935
- function deleteDrawNotice({
11936
- drawId
11937
- }) {
11938
- addNotice({
11939
- topic: DELETED_DRAW_IDS,
11940
- payload: {
11941
- drawId
11942
- }
11943
- });
11944
- }
11945
- function modifyDrawNotice({
11946
- drawDefinition,
11947
- structureIds
11948
- }) {
11949
- drawUpdatedAt(drawDefinition, structureIds);
11950
- addNotice({
11951
- topic: MODIFY_DRAW_DEFINITION,
11952
- payload: {
11953
- drawDefinition
11954
- },
11955
- key: drawDefinition.drawId
11956
- });
11957
- }
11958
-
11959
12080
  // all child matchUps need to be checked for collectionAssignments which need to be removed when collectionDefinition.collectionIds are removed
11960
12081
  /*
11961
12082
  * collectionDefinition will be removed from an event tieFormat (if present)
@@ -12111,6 +12232,7 @@ function removeCollectionDefinition({
12111
12232
 
12112
12233
  function modifyCollectionDefinition({
12113
12234
  tournamentRecord,
12235
+ collectionOrder,
12114
12236
  collectionName,
12115
12237
  drawDefinition,
12116
12238
  matchUpFormat,
@@ -12120,7 +12242,7 @@ function modifyCollectionDefinition({
12120
12242
  eventId,
12121
12243
  event
12122
12244
  }) {
12123
- if (!matchUpFormat && !collectionName) return {
12245
+ if (!matchUpFormat && !collectionName && !collectionOrder) return {
12124
12246
  error: MISSING_VALUE
12125
12247
  };
12126
12248
  if (matchUpFormat && !isValid(matchUpFormat)) return {
@@ -12149,78 +12271,16 @@ function modifyCollectionDefinition({
12149
12271
  };
12150
12272
  if (collectionName) collectionDefinition.collectionName = collectionName;
12151
12273
  if (matchUpFormat) collectionDefinition.matchUpFormat = matchUpFormat;
12152
-
12153
- if (event && eventId) {
12154
- event.tieFormatt = tieFormat;
12155
- } else if (matchUp) {
12156
- matchUp.tieFormat = tieFormat;
12157
- modifyMatchUpNotice({
12158
- tournamentId: tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.tournamentId,
12159
- drawDefinition,
12160
- matchUp
12161
- });
12162
- } else if (structure) {
12163
- updateStructureMatchUps$1({
12164
- tournamentRecord,
12165
- drawDefinition,
12166
- structure,
12167
- tieFormat
12168
- });
12169
- modifyDrawNotice({
12170
- drawDefinition,
12171
- structureIds: [structureId]
12172
- });
12173
- } else if (drawDefinition) {
12174
- drawDefinition.tieFormat = tieFormat;
12175
- const modifiedStructureIds = [];
12176
-
12177
- for (const structure of drawDefinition.structures || []) {
12178
- updateStructureMatchUps$1({
12179
- tournamentRecord,
12180
- drawDefinition,
12181
- structure,
12182
- tieFormat
12183
- });
12184
- modifiedStructureIds.push(structureId);
12185
- }
12186
-
12187
- modifyDrawNotice({
12188
- drawDefinition,
12189
- structureIds: modifiedStructureIds
12190
- });
12191
- } else {
12192
- return {
12193
- error: MISSING_DRAW_DEFINITION
12194
- };
12195
- }
12196
- }
12197
-
12198
- function updateStructureMatchUps$1({
12199
- tournamentRecord,
12200
- drawDefinition,
12201
- structure,
12202
- tieFormat
12203
- }) {
12204
- var _getAllStructureMatch;
12205
-
12206
- const matchUps = (_getAllStructureMatch = getAllStructureMatchUps({
12207
- matchUpFilters: {
12208
- matchUpTypes: [TEAM$3]
12209
- },
12210
- structure
12211
- })) === null || _getAllStructureMatch === void 0 ? void 0 : _getAllStructureMatch.matchUps; // all team matchUps in the structure which do not have tieFormats should have matchUps added
12212
-
12213
- const targetMatchUps = matchUps.filter(matchUp => matchUp.matchUpStatus !== COMPLETED);
12214
-
12215
- for (const matchUp of targetMatchUps) {
12216
- // don't update matchUps which are already COMPLETED
12217
- matchUp.tieFormat = tieFormat;
12218
- modifyMatchUpNotice({
12219
- tournamentId: tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.tournamentId,
12220
- drawDefinition,
12221
- matchUp
12222
- });
12223
- }
12274
+ if (collectionOrder) collectionDefinition.collectionOrder = collectionOrder;
12275
+ return updateTieFormat({
12276
+ tournamentRecord,
12277
+ drawDefinition,
12278
+ structure,
12279
+ tieFormat,
12280
+ eventId,
12281
+ matchUp,
12282
+ event
12283
+ });
12224
12284
  }
12225
12285
 
12226
12286
  function generateTieMatchUps({
@@ -12516,8 +12576,9 @@ function scoreHasValue({
12516
12576
  const scoreGovernor = {
12517
12577
  stringifyMatchUpFormat: stringify,
12518
12578
  isValidMatchUpFormat: isValid,
12519
- removeCollectionDefinition,
12520
12579
  modifyCollectionDefinition,
12580
+ orderCollectionDefinitions,
12581
+ removeCollectionDefinition,
12521
12582
  parseMatchUpFormat: parse,
12522
12583
  generateTieMatchUpScore,
12523
12584
  tallyParticipantResults,
@@ -20903,9 +20964,9 @@ function assignDrawPosition$1({
20903
20964
  });
20904
20965
  }
20905
20966
 
20906
- positionAssignment.participantId = participantId; // if not stageSequence 1 propagate seedAssignments
20967
+ positionAssignment.participantId = participantId;
20907
20968
 
20908
- if ((structure === null || structure === void 0 ? void 0 : structure.stageSequence) !== 1) {
20969
+ if ((structure === null || structure === void 0 ? void 0 : structure.stageSequence) > 1 || [CONSOLATION, PLAY_OFF].includes(structure.stage)) {
20909
20970
  const targetStage = structure.stage === QUALIFYING ? QUALIFYING : MAIN;
20910
20971
  const seedAssignments = drawDefinition.structures.find(structure => structure.stage === targetStage && structure.stageSequence === 1).seedAssignments || [];
20911
20972
  const assignment = seedAssignments.find(assignment => assignment.participantId === participantId);
@@ -31620,7 +31681,7 @@ const competitionEngine = function () {
31620
31681
  });
31621
31682
  const elapsed = Date.now() - start;
31622
31683
  const devContext = getDevContext();
31623
- if (devContext.perf && (isNaN(devContext.perf) || elapsed > devContext.perf)) console.log('ce:', {
31684
+ if (devContext.perf !== undefined && (isNaN(devContext.perf) || elapsed > devContext.perf)) console.log('ce:', {
31624
31685
  methodName,
31625
31686
  elapsed
31626
31687
  });
@@ -46545,11 +46606,8 @@ function removeCollectionAssignments({
46545
46606
  }
46546
46607
 
46547
46608
  function validateLineUp({
46548
- lineUp,
46549
- tieFormat
46609
+ lineUp
46550
46610
  }) {
46551
- var _tieFormat$collection;
46552
-
46553
46611
  let errors = [];
46554
46612
 
46555
46613
  if (!Array.isArray(lineUp)) {
@@ -46561,9 +46619,6 @@ function validateLineUp({
46561
46619
  };
46562
46620
  }
46563
46621
 
46564
- const collectionIds = (tieFormat === null || tieFormat === void 0 ? void 0 : (_tieFormat$collection = tieFormat.collectionDefinitions) === null || _tieFormat$collection === void 0 ? void 0 : _tieFormat$collection.map(({
46565
- collectionId
46566
- }) => collectionId)) || [];
46567
46622
  const validItems = lineUp.every(item => {
46568
46623
  if (typeof item !== 'object') {
46569
46624
  errors.push(`lineUp entries must be objects`);
@@ -46597,8 +46652,7 @@ function validateLineUp({
46597
46652
  }
46598
46653
 
46599
46654
  const {
46600
- collectionPosition,
46601
- collectionId
46655
+ collectionPosition
46602
46656
  } = collectionAssignment;
46603
46657
 
46604
46658
  if (typeof collectionPosition !== 'number') {
@@ -46606,11 +46660,6 @@ function validateLineUp({
46606
46660
  return false;
46607
46661
  }
46608
46662
 
46609
- if (!collectionIds.includes(collectionId)) {
46610
- errors.push('Invalid collectionId');
46611
- return false;
46612
- }
46613
-
46614
46663
  return true;
46615
46664
  });
46616
46665
  });
@@ -50115,8 +50164,9 @@ function resetScorecard(params) {
50115
50164
  }
50116
50165
 
50117
50166
  const eventGovernor = {
50118
- removeCollectionDefinition,
50119
50167
  modifyCollectionDefinition,
50168
+ orderCollectionDefinitions,
50169
+ removeCollectionDefinition,
50120
50170
  addCollectionDefinition,
50121
50171
  resetScorecard,
50122
50172
  addEvent,
@@ -50694,7 +50744,7 @@ const tournamentEngine = function () {
50694
50744
  });
50695
50745
  const elapsed = Date.now() - start;
50696
50746
  const devContext = getDevContext();
50697
- if (devContext.perf && (isNaN(devContext.perf) || elapsed > devContext.perf)) console.log('te:', {
50747
+ if (devContext.perf !== undefined && (isNaN(devContext.perf) || elapsed > devContext.perf)) console.log('te:', {
50698
50748
  methodName,
50699
50749
  elapsed
50700
50750
  });