tods-competition-factory 7.24.0 → 7.26.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.
- package/README.md +1 -1
- package/dist/esm/assemblies/engines/parts/executeMethod.mjs +7 -9
- package/dist/esm/assemblies/engines/parts/paramsMiddleware.mjs +67 -28
- package/dist/esm/assemblies/generators/drawDefinitions/tieMatchUps.mjs +1 -1
- package/dist/esm/assemblies/generators/mocks/generatePersons.mjs +1 -1
- package/dist/esm/assemblies/generators/venues/generateCourts.mjs +1 -1
- package/dist/esm/assemblies/governors/queryGovernor/index.mjs +1 -0
- package/dist/esm/assemblies/governors/scheduleGovernor/index.mjs +1 -0
- package/dist/esm/assemblies/governors/scheduleGovernor/query.mjs +1 -0
- package/dist/esm/constants/actionMethodConstants.mjs +7 -1
- package/dist/esm/constants/matchUpActionConstants.mjs +25 -1
- package/dist/esm/global/state/globalState.mjs +0 -3
- package/dist/esm/helpers/parameters/checkRequiredParameters.mjs +4 -0
- package/dist/esm/helpers/parameters/entityIdMismatch.mjs +25 -0
- package/dist/esm/mutate/drawDefinitions/matchUpGovernor/removeDoubleExit.mjs +3 -2
- package/dist/esm/mutate/drawDefinitions/positionGovernor/doubleExitAdvancement.mjs +4 -1
- package/dist/esm/mutate/drawDefinitions/positionGovernor/releaseHoldersByeFromTarget.mjs +2 -0
- package/dist/esm/mutate/entries/addEventEntries.mjs +4 -0
- package/dist/esm/mutate/extensions/policies/attachPolicies.mjs +2 -1
- package/dist/esm/mutate/matchUps/drawPositions/assignDrawPositionBye.mjs +2 -0
- package/dist/esm/mutate/matchUps/drawPositions/awardStands.mjs +24 -0
- package/dist/esm/mutate/matchUps/drawPositions/drawPositionPlacement.mjs +1 -0
- package/dist/esm/mutate/matchUps/drawPositions/positionClear.mjs +7 -21
- package/dist/esm/mutate/matchUps/drawPositions/relabelLoserExit.mjs +3 -0
- package/dist/esm/mutate/matchUps/drawPositions/releaseAdvancedDrawPosition.mjs +11 -4
- package/dist/esm/mutate/matchUps/drawPositions/releaseLinkedWinnerAdvancement.mjs +5 -2
- package/dist/esm/mutate/matchUps/drawPositions/removeDirectedParticipants.mjs +3 -1
- package/dist/esm/mutate/matchUps/drawPositions/removeOnwardLoserPlacements.mjs +2 -0
- package/dist/esm/mutate/matchUps/drawPositions/removeSubsequentRoundsParticipant.mjs +12 -3
- package/dist/esm/mutate/matchUps/drawPositions/withdrawAwardsToEmptiedSeats.mjs +4 -2
- package/dist/esm/mutate/matchUps/lineUps/ensureSideLineUps.mjs +18 -23
- package/dist/esm/mutate/matchUps/matchUpStatus/applyWithdrawnExits.mjs +7 -27
- package/dist/esm/mutate/matchUps/matchUpStatus/indexPrecheck.mjs +1 -1
- package/dist/esm/mutate/matchUps/matchUpStatus/reconcileLinkAdvancements.mjs +2 -0
- package/dist/esm/mutate/matchUps/matchUpStatus/settleRederivedDoubleExits.mjs +13 -2
- package/dist/esm/mutate/matchUps/matchUpStatus/withdrawByeSeats.mjs +29 -0
- package/dist/esm/mutate/matchUps/outcome/apply.mjs +99 -32
- package/dist/esm/mutate/matchUps/outcome/decide.mjs +31 -2
- package/dist/esm/mutate/matchUps/outcome/differential.mjs +2 -1
- package/dist/esm/mutate/matchUps/outcome/direction.mjs +22 -5
- package/dist/esm/mutate/matchUps/outcome/indexOracle.mjs +6 -0
- package/dist/esm/mutate/matchUps/outcome/ops.mjs +35 -2
- package/dist/esm/mutate/matchUps/outcome/overlay.mjs +6 -1
- package/dist/esm/mutate/matchUps/outcome/plan.mjs +846 -122
- package/dist/esm/mutate/matchUps/outcome/settleWork.mjs +11 -3
- package/dist/esm/mutate/matchUps/outcome/shadow.mjs +12 -4
- package/dist/esm/mutate/matchUps/outcome/view.mjs +91 -11
- package/dist/esm/mutate/matchUps/schedule/bulkScheduleMatchUps.mjs +2 -1
- package/dist/esm/mutate/matchUps/schedule/bulkScheduleTournamentMatchUps.mjs +10 -3
- package/dist/esm/mutate/matchUps/schedule/pipeline/playedOrderGate.mjs +9 -8
- package/dist/esm/mutate/matchUps/schedule/pipeline/view.mjs +8 -8
- package/dist/esm/mutate/matchUps/schedule/scheduleItems/playedOrder.mjs +35 -83
- package/dist/esm/mutate/matchUps/schedule/scheduleItems/scheduleItems.mjs +37 -6
- package/dist/esm/mutate/matchUps/schedule/scheduleMatchUps/updateTimeAfterRecovery.mjs +1 -1
- package/dist/esm/package.json.mjs +1 -1
- package/dist/esm/query/drawDefinition/getDrawData.mjs +1 -1
- package/dist/esm/query/drawDefinition/matchUpActions/matchUpActions.mjs +26 -14
- package/dist/esm/query/drawDefinition/matchUpActions/scheduleMatchUpActions.mjs +87 -0
- package/dist/esm/query/drawDefinition/stageGetter.mjs +1 -1
- package/dist/esm/query/event/getCategoryAgeDetails.mjs +1 -1
- package/dist/esm/query/matchUp/addUpcomingMatchUps.mjs +4 -3
- package/dist/esm/query/matchUp/getMatchUpScheduleBounds.mjs +102 -0
- package/dist/esm/query/matchUp/getProjectedDualWinningSide.mjs +3 -2
- package/dist/esm/query/matchUp/positionTargets.mjs +2 -37
- package/dist/esm/query/matchUp/targetIndex.mjs +39 -0
- package/dist/esm/query/matchUps/addGoesTo.mjs +2 -1
- package/dist/esm/query/matchUps/getTargetMatchUp.mjs +1 -1
- package/dist/esm/query/matchUps/scheduling/recordedOrder.mjs +99 -0
- package/dist/esm/query/matchUps/scheduling/scheduleOrder.mjs +105 -0
- package/dist/esm/query/matchUps/structuralIndex.mjs +91 -24
- package/dist/esm/query/readModel/index.mjs +1 -0
- package/dist/esm/query/readModel/publicParticipant.mjs +69 -0
- package/dist/esm/query/readModel/readModelColumns.mjs +1 -0
- package/dist/esm/query/tournaments/getCompetitionDateRange.mjs +1 -1
- package/dist/schema/tournament.schema.json +25 -1
- package/dist/tods-competition-factory.d.cts +331 -84
- package/dist/tods-competition-factory.d.mts +331 -84
- package/dist/tods-competition-factory.d.ts +331 -84
- package/dist/tods-competition-factory.development.cjs.js +2960 -1366
- package/dist/tods-competition-factory.development.cjs.js.map +1 -1
- package/dist/tods-competition-factory.production.cjs.min.js +1 -1
- package/dist/tods-competition-factory.production.cjs.min.js.map +1 -1
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -142,7 +142,7 @@ Full documentation with interactive examples: **[courthive.github.io/competition
|
|
|
142
142
|
|
|
143
143
|
## Testing
|
|
144
144
|
|
|
145
|
-
**
|
|
145
|
+
**22,000+ tests** run on every change (21,000+ in the default suite, plus 1,500+ TEAM-competition arms), covering draw generation and exit propagation, scheduling, scoring, participants and entries, team competition, publishing and embargo, ranking points and ratings, officiating and sanctioning.
|
|
146
146
|
|
|
147
147
|
Beyond conventional unit and integration tests, the suite includes relational property suites (do/undo, idempotence, monotonicity), agreement oracles, and an at-scale randomized sweep with delta-debugging for exit propagation — added because full branch coverage of a propagation guard proved compatible with hundreds of wrong answers.
|
|
148
148
|
|
|
@@ -3,7 +3,7 @@ import { withContextExclusion } from '../../../query/matchUps/contextExclusion.m
|
|
|
3
3
|
import { checkMutationLock } from './checkMutationLock.mjs';
|
|
4
4
|
import { paramsMiddleware } from './paramsMiddleware.mjs';
|
|
5
5
|
import { makeDeepCopy } from '../../../tools/makeDeepCopy.mjs';
|
|
6
|
-
import { getTournamentId,
|
|
6
|
+
import { getTournamentId, getTournamentRecords, getInvokeObserver, getTournamentRecord, getDevContext, handleCaughtError } from '../../../global/state/globalState.mjs';
|
|
7
7
|
|
|
8
8
|
function executeFunction(engine, method, params, methodName, engineType, options) {
|
|
9
9
|
delete engine.success;
|
|
@@ -12,23 +12,21 @@ function executeFunction(engine, method, params, methodName, engineType, options
|
|
|
12
12
|
const tournamentId = getTournamentId();
|
|
13
13
|
if (params)
|
|
14
14
|
params.activeTournamentId = tournamentId;
|
|
15
|
-
const
|
|
16
|
-
const tournamentRecords = (typeof params?.tournamentRecord === 'object' && {
|
|
17
|
-
[params?.tournamentRecord.tournamentId]: params.tournamentRecord,
|
|
18
|
-
}) ||
|
|
19
|
-
getTournamentRecords();
|
|
15
|
+
const tournamentRecords = getTournamentRecords();
|
|
20
16
|
const observer = getInvokeObserver();
|
|
21
17
|
const paramsToLog = params && (observer || paramsMayBeLogged(methodName)) ? makeDeepCopy(params, undefined, true) : undefined;
|
|
22
18
|
observer?.({ phase: 'before', methodName, engineType, params: paramsToLog });
|
|
23
|
-
const result = resolve({ method, params, methodName, tournamentRecords,
|
|
19
|
+
const result = resolve({ method, params, methodName, tournamentRecords, tournamentId });
|
|
24
20
|
const elapsed = Date.now() - start;
|
|
25
21
|
engineLogging({ result, methodName, elapsed, params: paramsToLog, engineType, dryRun: options?.dryRun });
|
|
26
22
|
return result;
|
|
27
23
|
}
|
|
28
|
-
function resolve({ method, params, methodName, tournamentRecords,
|
|
29
|
-
const augmentedParams = params ? paramsMiddleware(tournamentRecords, params) : undefined;
|
|
24
|
+
function resolve({ method, params, methodName, tournamentRecords, tournamentId }) {
|
|
25
|
+
const augmentedParams = params ? paramsMiddleware(tournamentRecords, params, methodName) : undefined;
|
|
30
26
|
if (augmentedParams?.error)
|
|
31
27
|
return augmentedParams;
|
|
28
|
+
const resolved = augmentedParams;
|
|
29
|
+
const tournamentRecord = resolved?.tournamentRecord ?? getTournamentRecord(tournamentId);
|
|
32
30
|
const lockError = checkMutationLock(methodName, augmentedParams, tournamentRecord);
|
|
33
31
|
if (lockError)
|
|
34
32
|
return lockError;
|
|
@@ -1,36 +1,22 @@
|
|
|
1
|
+
import { entityIdMismatch } from '../../../helpers/parameters/entityIdMismatch.mjs';
|
|
1
2
|
import { getTournamentId } from '../../../global/state/globalState.mjs';
|
|
2
3
|
import { findEvent } from '../../../acquire/findEvent.mjs';
|
|
3
|
-
import {
|
|
4
|
+
import { isObject } from '../../../tools/objects.mjs';
|
|
5
|
+
import { MISSING_TOURNAMENT_RECORD, DRAW_DEFINITION_NOT_FOUND, EVENT_NOT_FOUND } from '../../../constants/errorConditionConstants.mjs';
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
const PAYLOADS = {
|
|
8
|
+
addDrawDefinition: 'drawDefinition',
|
|
9
|
+
addEvent: 'event',
|
|
10
|
+
};
|
|
11
|
+
function paramsMiddleware(tournamentRecords, params, methodName) {
|
|
6
12
|
if (params._middleware === false)
|
|
7
13
|
return params;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
if (
|
|
13
|
-
|
|
14
|
-
tournamentRecords,
|
|
15
|
-
drawId,
|
|
16
|
-
});
|
|
17
|
-
if (drawDefinition)
|
|
18
|
-
params.drawDefinition = drawDefinition;
|
|
19
|
-
if (tournamentId)
|
|
20
|
-
params.tournamentId = tournamentId;
|
|
21
|
-
if (event)
|
|
22
|
-
params.event = event;
|
|
23
|
-
}
|
|
24
|
-
if (params.eventId && !params.event) {
|
|
25
|
-
const { event, tournamentId } = findEvent({
|
|
26
|
-
eventId: params.eventId,
|
|
27
|
-
tournamentRecords,
|
|
28
|
-
});
|
|
29
|
-
if (!event)
|
|
30
|
-
return { error: EVENT_NOT_FOUND };
|
|
31
|
-
params.tournamentId = tournamentId;
|
|
32
|
-
params.event = event;
|
|
33
|
-
}
|
|
14
|
+
const payload = methodName ? PAYLOADS[methodName] : undefined;
|
|
15
|
+
const refusal = entityIdMismatch(payloadAside(params, payload)) ??
|
|
16
|
+
resolveRecord(tournamentRecords, params) ??
|
|
17
|
+
resolveDrawAndEvent(tournamentRecords, params, payload);
|
|
18
|
+
if (refusal)
|
|
19
|
+
return refusal;
|
|
34
20
|
const tournamentId = params.tournamentId ?? getTournamentId();
|
|
35
21
|
if (!tournamentId && params)
|
|
36
22
|
return params;
|
|
@@ -43,5 +29,58 @@ function paramsMiddleware(tournamentRecords, params) {
|
|
|
43
29
|
params.tournamentRecord = tournamentRecord;
|
|
44
30
|
return params;
|
|
45
31
|
}
|
|
32
|
+
function resolveRecord(tournamentRecords, params) {
|
|
33
|
+
if (isObject(params.tournamentRecord)) {
|
|
34
|
+
params.tournamentId ??= params.tournamentRecord?.tournamentId;
|
|
35
|
+
delete params.tournamentRecord;
|
|
36
|
+
if (!params.tournamentId)
|
|
37
|
+
return { error: MISSING_TOURNAMENT_RECORD };
|
|
38
|
+
}
|
|
39
|
+
if (params.tournamentId && !tournamentRecords[params.tournamentId])
|
|
40
|
+
return { error: MISSING_TOURNAMENT_RECORD };
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
function resolveDrawAndEvent(tournamentRecords, params, payload) {
|
|
44
|
+
const drawPassed = payload !== 'drawDefinition' && isObject(params.drawDefinition);
|
|
45
|
+
if (drawPassed) {
|
|
46
|
+
params.drawId ??= params.drawDefinition?.drawId;
|
|
47
|
+
delete params.drawDefinition;
|
|
48
|
+
}
|
|
49
|
+
const drawId = params.drawId || params.matchUp?.drawId;
|
|
50
|
+
const found = drawId ? findEvent({ tournamentRecords, drawId }) : undefined;
|
|
51
|
+
if (drawPassed && !found?.drawDefinition)
|
|
52
|
+
return { error: DRAW_DEFINITION_NOT_FOUND };
|
|
53
|
+
if (found?.drawDefinition)
|
|
54
|
+
params.drawDefinition = found.drawDefinition;
|
|
55
|
+
if (found?.tournamentId)
|
|
56
|
+
params.tournamentId = found.tournamentId;
|
|
57
|
+
if (found?.event) {
|
|
58
|
+
params.event = found.event;
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
return payload === 'event' ? undefined : resolveEvent(tournamentRecords, params);
|
|
62
|
+
}
|
|
63
|
+
function resolveEvent(tournamentRecords, params) {
|
|
64
|
+
if (isObject(params.event)) {
|
|
65
|
+
params.eventId ??= params.event?.eventId;
|
|
66
|
+
delete params.event;
|
|
67
|
+
if (!params.eventId)
|
|
68
|
+
return { error: EVENT_NOT_FOUND };
|
|
69
|
+
}
|
|
70
|
+
if (!params.eventId)
|
|
71
|
+
return undefined;
|
|
72
|
+
const { event, tournamentId } = findEvent({ eventId: params.eventId, tournamentRecords });
|
|
73
|
+
if (!event)
|
|
74
|
+
return { error: EVENT_NOT_FOUND };
|
|
75
|
+
params.tournamentId = tournamentId;
|
|
76
|
+
params.event = event;
|
|
77
|
+
return undefined;
|
|
78
|
+
}
|
|
79
|
+
function payloadAside(params, payload) {
|
|
80
|
+
if (!payload || !params[payload])
|
|
81
|
+
return params;
|
|
82
|
+
const { [payload]: _payload, ...rest } = params;
|
|
83
|
+
return rest;
|
|
84
|
+
}
|
|
46
85
|
|
|
47
86
|
export { paramsMiddleware };
|
|
@@ -20,7 +20,7 @@ function generateCollectionMatchUps({ collectionPositionOffset = 0, collectionDe
|
|
|
20
20
|
if (!isMock && !matchUp?.isMock)
|
|
21
21
|
return uuids?.pop() ?? UUID();
|
|
22
22
|
const collectionId = collectionDefinition?.collectionId;
|
|
23
|
-
return uuids?.pop() ?? `${matchUp?.matchUpId}-${collectionId}-TMU-${index + 1}`;
|
|
23
|
+
return uuids?.pop() ?? `${matchUp?.matchUpId}-${collectionId}-TMU-${collectionPositionOffset + index + 1}`;
|
|
24
24
|
};
|
|
25
25
|
return generateRange(0, numberToGenerate).map((index) => {
|
|
26
26
|
const collectionPosition = collectionPositionOffset + index + 1;
|
|
@@ -5,8 +5,8 @@ import { generatePersonData } from './generatePersonData.mjs';
|
|
|
5
5
|
import { coercedSex } from '../../../helpers/coercedSex.mjs';
|
|
6
6
|
import { isFemale } from '../../../validators/isFemale.mjs';
|
|
7
7
|
import { INVALID_VALUES } from '../../../constants/errorConditionConstants.mjs';
|
|
8
|
-
import { ensureInt } from '../../../tools/ensureInt.mjs';
|
|
9
8
|
import { dateFromDay } from '../../../tools/plainDate.mjs';
|
|
9
|
+
import { ensureInt } from '../../../tools/ensureInt.mjs';
|
|
10
10
|
import { isMale } from '../../../validators/isMale.mjs';
|
|
11
11
|
import { MALE, FEMALE } from '../../../constants/genderConstants.mjs';
|
|
12
12
|
import { countries } from '../../../fixtures/countryData.mjs';
|
|
@@ -2,11 +2,11 @@ import { checkRequiredParameters } from '../../../helpers/parameters/checkRequir
|
|
|
2
2
|
import { isString } from '../../../tools/objects.mjs';
|
|
3
3
|
import { SUCCESS } from '../../../constants/resultConstants.mjs';
|
|
4
4
|
import { MISSING_VALUE } from '../../../constants/errorConditionConstants.mjs';
|
|
5
|
-
import { isNumeric } from '../../../tools/math.mjs';
|
|
6
5
|
import { isValidDateString, generateDateRange } from '../../../tools/plainDate.mjs';
|
|
7
6
|
import { isTimeString } from '../../../tools/plainTime.mjs';
|
|
8
7
|
import { definedAttributes } from '../../../tools/definedAttributes.mjs';
|
|
9
8
|
import { generateRange } from '../../../tools/arrays.mjs';
|
|
9
|
+
import { isNumeric } from '../../../tools/math.mjs';
|
|
10
10
|
import { UUID } from '../../../tools/UUID.mjs';
|
|
11
11
|
import { VALIDATE } from '../../../constants/attributeConstants.mjs';
|
|
12
12
|
|
|
@@ -75,6 +75,7 @@ export { getParticipantRest, getParticipantsRest } from '../../../query/matchUps
|
|
|
75
75
|
export { isScheduleLocked, matchUpScheduleLocked } from '../../../query/matchUp/isScheduleLocked.mjs';
|
|
76
76
|
export { getScheduleProjection } from '../../../query/facilitySchedule/getScheduleProjection.mjs';
|
|
77
77
|
export { mergeFacilitySchedule } from '../../../query/facilitySchedule/mergeFacilitySchedule.mjs';
|
|
78
|
+
export { getMatchUpScheduleBounds } from '../../../query/matchUp/getMatchUpScheduleBounds.mjs';
|
|
78
79
|
export { getPersonRequests } from '../../../query/matchUps/scheduling/getPersonRequests.mjs';
|
|
79
80
|
export { getProfileRounds } from '../../../query/matchUps/scheduling/getProfileRounds.mjs';
|
|
80
81
|
export { getScenarioScheduleProjection } from '../../../query/matchUps/scheduling/getScenarioScheduleProjection.mjs';
|
|
@@ -27,6 +27,7 @@ export { findVenue } from '../../../query/venues/findVenue.mjs';
|
|
|
27
27
|
export { generateBookings } from '../../generators/scheduling/utils/generateBookings.mjs';
|
|
28
28
|
export { generateVirtualCourts } from '../../generators/scheduling/utils/generateVirtualCourts.mjs';
|
|
29
29
|
export { getMatchUpReadiness } from '../../../query/matchUps/scheduling/getMatchUpReadiness.mjs';
|
|
30
|
+
export { getMatchUpScheduleBounds } from '../../../query/matchUp/getMatchUpScheduleBounds.mjs';
|
|
30
31
|
export { getMatchUpsToSchedule } from '../../../mutate/matchUps/schedule/scheduleMatchUps/getMatchUpsToSchedule.mjs';
|
|
31
32
|
export { getParticipantRest, getParticipantsRest } from '../../../query/matchUps/scheduling/getParticipantRest.mjs';
|
|
32
33
|
export { getPersonRequests } from '../../../query/matchUps/scheduling/getPersonRequests.mjs';
|
|
@@ -6,6 +6,7 @@ export { getParticipantRest, getParticipantsRest } from '../../../query/matchUps
|
|
|
6
6
|
export { isScheduleLocked, matchUpScheduleLocked } from '../../../query/matchUp/isScheduleLocked.mjs';
|
|
7
7
|
export { getScheduleProjection } from '../../../query/facilitySchedule/getScheduleProjection.mjs';
|
|
8
8
|
export { mergeFacilitySchedule } from '../../../query/facilitySchedule/mergeFacilitySchedule.mjs';
|
|
9
|
+
export { getMatchUpScheduleBounds } from '../../../query/matchUp/getMatchUpScheduleBounds.mjs';
|
|
9
10
|
export { getPersonRequests } from '../../../query/matchUps/scheduling/getPersonRequests.mjs';
|
|
10
11
|
export { getProfileRounds } from '../../../query/matchUps/scheduling/getProfileRounds.mjs';
|
|
11
12
|
export { getScenarioScheduleProjection } from '../../../query/matchUps/scheduling/getScenarioScheduleProjection.mjs';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SUBSTITUTION_METHOD, SCHEDULE_METHOD, REPLACE_TEAM_POSITION_METHOD, REMOVE_TEAM_POSITION_METHOD, REMOVE_SIDE_METHOD, ASSIGN_TEAM_POSITION_METHOD, ASSIGN_SIDE_METHOD } from './matchUpActionConstants.mjs';
|
|
1
|
+
import { SUBSTITUTION_METHOD, REFEREE_METHOD, CHECK_IN_METHOD, SCOREKEEPER_METHOD, SCORE_METHOD, SCHEDULE_METHOD, SCHEDULE_LOCK_METHOD, SCHEDULE_ITEMS_METHOD, REPLACE_TEAM_POSITION_METHOD, REMOVE_TEAM_POSITION_METHOD, REMOVE_SIDE_METHOD, ASSIGN_TEAM_POSITION_METHOD, ASSIGN_SIDE_METHOD } from './matchUpActionConstants.mjs';
|
|
2
2
|
import { WITHDRAW_PARTICIPANT_METHOD, SWAP_PARTICIPANT_METHOD, SWAP_ADHOC_PARTICIPANT_METHOD, SEED_VALUE_METHOD, SEED_CASCADE_METHOD, REMOVE_SEED_METHOD, REMOVE_ASSIGNMENT_METHOD, QUALIFYING_PARTICIPANT_METHOD, MODIFY_PAIR_ASSIGNMENT_METHOD, LUCKY_PARTICIPANT_METHOD, ASSIGN_QUALIFIER_METHOD, ASSIGN_PARTICIPANT_METHOD, ASSIGN_BYE_METHOD, ALTERNATE_PARTICIPANT_METHOD, ADD_PENALTY_METHOD, ADD_NICKNAME_METHOD } from './positionActionConstants.mjs';
|
|
3
3
|
|
|
4
4
|
const actionMethodConstants = {
|
|
@@ -23,7 +23,13 @@ const actionMethodConstants = {
|
|
|
23
23
|
REMOVE_SIDE_METHOD,
|
|
24
24
|
REMOVE_TEAM_POSITION_METHOD,
|
|
25
25
|
REPLACE_TEAM_POSITION_METHOD,
|
|
26
|
+
SCHEDULE_ITEMS_METHOD,
|
|
27
|
+
SCHEDULE_LOCK_METHOD,
|
|
26
28
|
SCHEDULE_METHOD,
|
|
29
|
+
SCORE_METHOD,
|
|
30
|
+
SCOREKEEPER_METHOD,
|
|
31
|
+
CHECK_IN_METHOD,
|
|
32
|
+
REFEREE_METHOD,
|
|
27
33
|
SUBSTITUTION_METHOD,
|
|
28
34
|
};
|
|
29
35
|
|
|
@@ -8,9 +8,21 @@ const REMOVE_SUBSTITUTION = 'REMOVE_SUBSTITUTION';
|
|
|
8
8
|
const REPLACE_PARTICIPANT = 'REPLACE_PARTICIPANT';
|
|
9
9
|
const REMOVE_PARTICIPANT = 'REMOVE_PARTICIPANT';
|
|
10
10
|
const SCHEDULE_METHOD = 'setMatchUpStatus';
|
|
11
|
+
const SCHEDULE_ITEMS_METHOD = 'addMatchUpScheduleItems';
|
|
12
|
+
const SCHEDULE_LOCK_METHOD = 'setMatchUpScheduleLock';
|
|
13
|
+
const CHECK_IN_METHOD = 'toggleParticipantCheckInState';
|
|
14
|
+
const SCOREKEEPER_METHOD = 'assignMatchUpScorekeeper';
|
|
15
|
+
const REFEREE_METHOD = 'addMatchUpOfficial';
|
|
16
|
+
const SCORE_METHOD = 'setMatchUpStatus';
|
|
11
17
|
const CLEAR_SCORE = 'CLEAR_SCORE';
|
|
12
18
|
const SUBSTITUTION = 'SUBSTITUTION';
|
|
13
19
|
const SCHEDULE = 'SCHEDULE';
|
|
20
|
+
const SCHEDULE_DATE = 'SCHEDULE_DATE';
|
|
21
|
+
const SCHEDULE_TIME = 'SCHEDULE_TIME';
|
|
22
|
+
const SCHEDULE_LOCK = 'SCHEDULE_LOCK';
|
|
23
|
+
const CLEAR_SCHEDULE = 'CLEAR_SCHEDULE';
|
|
24
|
+
const SCOREKEEPER = 'SCOREKEEPER';
|
|
25
|
+
const CHECK_IN = 'CHECK_IN';
|
|
14
26
|
const EXIT = 'EXIT';
|
|
15
27
|
const PENALTY = 'PENALTY';
|
|
16
28
|
const REFEREE = 'REFEREE';
|
|
@@ -26,10 +38,22 @@ const matchUpActionConstants = {
|
|
|
26
38
|
SUBSTITUTION_METHOD,
|
|
27
39
|
REMOVE_SUBSTITUTION,
|
|
28
40
|
REMOVE_PARTICIPANT,
|
|
41
|
+
SCHEDULE_ITEMS_METHOD,
|
|
42
|
+
SCHEDULE_LOCK_METHOD,
|
|
43
|
+
SCOREKEEPER_METHOD,
|
|
44
|
+
CHECK_IN_METHOD,
|
|
45
|
+
REFEREE_METHOD,
|
|
29
46
|
SCHEDULE_METHOD,
|
|
47
|
+
SCORE_METHOD,
|
|
48
|
+
CLEAR_SCHEDULE,
|
|
49
|
+
SCHEDULE_DATE,
|
|
50
|
+
SCHEDULE_TIME,
|
|
51
|
+
SCHEDULE_LOCK,
|
|
30
52
|
CLEAR_SCORE,
|
|
31
53
|
SUBSTITUTION,
|
|
54
|
+
SCOREKEEPER,
|
|
32
55
|
SCHEDULE,
|
|
56
|
+
CHECK_IN,
|
|
33
57
|
EXIT,
|
|
34
58
|
PENALTY,
|
|
35
59
|
REFEREE,
|
|
@@ -39,4 +63,4 @@ const matchUpActionConstants = {
|
|
|
39
63
|
END,
|
|
40
64
|
};
|
|
41
65
|
|
|
42
|
-
export { ASSIGN_SIDE_METHOD, ASSIGN_TEAM_POSITION_METHOD, CLEAR_SCORE, END, EXIT, PENALTY, REFEREE, REMOVE_PARTICIPANT, REMOVE_SIDE_METHOD, REMOVE_SUBSTITUTION, REMOVE_TEAM_POSITION_METHOD, REPLACE_PARTICIPANT, REPLACE_TEAM_POSITION_METHOD, SCHEDULE, SCHEDULE_METHOD, SCORE, START, STATUS, SUBSTITUTION, SUBSTITUTION_METHOD, matchUpActionConstants };
|
|
66
|
+
export { ASSIGN_SIDE_METHOD, ASSIGN_TEAM_POSITION_METHOD, CHECK_IN, CHECK_IN_METHOD, CLEAR_SCHEDULE, CLEAR_SCORE, END, EXIT, PENALTY, REFEREE, REFEREE_METHOD, REMOVE_PARTICIPANT, REMOVE_SIDE_METHOD, REMOVE_SUBSTITUTION, REMOVE_TEAM_POSITION_METHOD, REPLACE_PARTICIPANT, REPLACE_TEAM_POSITION_METHOD, SCHEDULE, SCHEDULE_DATE, SCHEDULE_ITEMS_METHOD, SCHEDULE_LOCK, SCHEDULE_LOCK_METHOD, SCHEDULE_METHOD, SCHEDULE_TIME, SCORE, SCOREKEEPER, SCOREKEEPER_METHOD, SCORE_METHOD, START, STATUS, SUBSTITUTION, SUBSTITUTION_METHOD, matchUpActionConstants };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { isObject, isFunction } from '../../tools/objects.mjs';
|
|
2
2
|
import syncGlobalState from './syncGlobalState.mjs';
|
|
3
|
-
import { isNumeric } from '../../tools/math.mjs';
|
|
4
3
|
import { OUTCOME_PIPELINE_V1, outcomePipelineModes } from '../../constants/outcomePipelineConstants.mjs';
|
|
5
4
|
import { NATIVE, BRIDGE, LEGACY, schemaWriteModes } from '../../constants/schemaWriteModeConstants.mjs';
|
|
6
5
|
import { SUCCESS } from '../../constants/resultConstants.mjs';
|
|
@@ -446,8 +445,6 @@ function globalLog(log, engine) {
|
|
|
446
445
|
function setStateMethods(submittedMethods, traverse, maxDepth, global) {
|
|
447
446
|
if (!isObject(submittedMethods))
|
|
448
447
|
return { error: INVALID_VALUES };
|
|
449
|
-
if (!isNumeric)
|
|
450
|
-
maxDepth = 1;
|
|
451
448
|
const collectionFilter = Array.isArray(traverse) ? traverse : [];
|
|
452
449
|
const methods = {};
|
|
453
450
|
const attrWalker = (obj, depth = 0) => {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { decorateResult } from '../../functions/global/decorateResult.mjs';
|
|
2
2
|
import { validateTieFormat } from '../../validators/validateTieFormat.mjs';
|
|
3
3
|
import { isObject, isFunction, isString } from '../../tools/objects.mjs';
|
|
4
|
+
import { entityIdMismatch } from './entityIdMismatch.mjs';
|
|
4
5
|
import { intersection } from '../../tools/arrays.mjs';
|
|
5
6
|
import { RESOURCE_SUB_TYPE, RESOURCE_TYPE, IDENTIFIER } from '../../constants/resourceConstants.mjs';
|
|
6
7
|
import tieFormatDefaults from '../../assemblies/generators/templates/tieFormatDefaults.mjs';
|
|
@@ -69,6 +70,9 @@ const paramTypes = {
|
|
|
69
70
|
function checkRequiredParameters(params, requiredParams, stack) {
|
|
70
71
|
if (!params && !isObject(params))
|
|
71
72
|
return { error: INVALID_VALUES };
|
|
73
|
+
const mismatch = entityIdMismatch(params);
|
|
74
|
+
if (mismatch)
|
|
75
|
+
return mismatch;
|
|
72
76
|
if (!requiredParams?.length || params?._bypassParamCheck)
|
|
73
77
|
return { valid: true };
|
|
74
78
|
if (!Array.isArray(requiredParams))
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { decorateResult } from '../../functions/global/decorateResult.mjs';
|
|
2
|
+
import { INVALID_VALUES } from '../../constants/errorConditionConstants.mjs';
|
|
3
|
+
|
|
4
|
+
const ENTITIES = [
|
|
5
|
+
['tournamentRecord', 'tournamentId'],
|
|
6
|
+
['drawDefinition', 'drawId'],
|
|
7
|
+
['event', 'eventId'],
|
|
8
|
+
];
|
|
9
|
+
function entityIdMismatch(params) {
|
|
10
|
+
if (!params || typeof params !== 'object')
|
|
11
|
+
return undefined;
|
|
12
|
+
for (const [entity, idParam] of ENTITIES) {
|
|
13
|
+
const ownId = params[entity]?.[idParam];
|
|
14
|
+
const given = params[idParam];
|
|
15
|
+
if (ownId && given && ownId !== given)
|
|
16
|
+
return decorateResult({
|
|
17
|
+
result: { error: INVALID_VALUES },
|
|
18
|
+
info: `${idParam} ${given} does not match ${entity}.${idParam} ${ownId}`,
|
|
19
|
+
stack: 'entityIdMismatch',
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export { entityIdMismatch };
|
|
@@ -3,8 +3,9 @@ import { propagateUnfillableLoserBye } from '../../matchUps/drawPositions/propag
|
|
|
3
3
|
import { getWinningSideDrawPosition, getSideDrawPosition } from '../../../query/matchUps/getDrawPositionSides.mjs';
|
|
4
4
|
import { propagatesByeOnDoubleExit } from '../../matchUps/drawPositions/propagatesByeOnDoubleExit.mjs';
|
|
5
5
|
import { firstRoundFeedersWon } from '../../matchUps/drawPositions/drawPositionPlacement.mjs';
|
|
6
|
-
import { withdrawByeSeats } from '../../matchUps/matchUpStatus/applyWithdrawnExits.mjs';
|
|
7
6
|
import { getPairedPreviousMatchUp } from '../../../query/matchUps/getPairedPreviousMatchup.mjs';
|
|
7
|
+
import { withdrawByeSeats } from '../../matchUps/matchUpStatus/withdrawByeSeats.mjs';
|
|
8
|
+
import { clearDrawPosition } from '../../matchUps/drawPositions/positionClear.mjs';
|
|
8
9
|
import { byeSeatStands } from '../../matchUps/matchUpStatus/feederSendsNobody.mjs';
|
|
9
10
|
import { modifyMatchUpScore } from '../../matchUps/score/modifyMatchUpScore.mjs';
|
|
10
11
|
import { isExit, isAnyExit, isDoubleExit } from '../../../validators/isExit.mjs';
|
|
@@ -219,7 +220,7 @@ function withdrawExitFromByeChain({ inContextDrawMatchUps, withdrawnSourceIds, d
|
|
|
219
220
|
return decorateResult({ result, stack });
|
|
220
221
|
setSideExitProvenance({ provenance: unwound.provenance, matchUp: noContextTargetMatchUp });
|
|
221
222
|
if (unwound.winningSide === undefined && !isAnyExit(unwound.matchUpStatus)) {
|
|
222
|
-
withdrawByeSeats({ claimantMatchUpId: fromMatchUp.matchUpId, drawDefinition, matchUpsMap });
|
|
223
|
+
withdrawByeSeats({ clearDrawPosition, claimantMatchUpId: fromMatchUp.matchUpId, drawDefinition, matchUpsMap });
|
|
223
224
|
}
|
|
224
225
|
const fromTargets = positionTargets({
|
|
225
226
|
matchUpId: fromMatchUp.matchUpId,
|
|
@@ -4,7 +4,7 @@ import { assignDrawPositionBye, advanceDrawPosition } from '../../matchUps/drawP
|
|
|
4
4
|
import { getWinningSideDrawPosition, getDrawPositionSideNumber } from '../../../query/matchUps/getDrawPositionSides.mjs';
|
|
5
5
|
import { getPairedPreviousMatchUpIsDoubleExit } from '../../../query/matchUps/getPairedPreviousMatchUpIsDoubleExit.mjs';
|
|
6
6
|
import { propagateUnfillableLoserBye } from '../../matchUps/drawPositions/propagateUnfillableLoserBye.mjs';
|
|
7
|
-
import {
|
|
7
|
+
import { clearDrawPosition, drawPositionRemovals } from '../../matchUps/drawPositions/positionClear.mjs';
|
|
8
8
|
import { assignMatchUpDrawPosition, directWinner } from '../../matchUps/drawPositions/drawPositionPlacement.mjs';
|
|
9
9
|
import { propagatesByeOnDoubleExit } from '../../matchUps/drawPositions/propagatesByeOnDoubleExit.mjs';
|
|
10
10
|
import { getExitWinningSide } from '../matchUpGovernor/getExitWinningSide.mjs';
|
|
@@ -449,6 +449,7 @@ function withdrawStaleAdvances({ targetMatchUpDrawPositions, inContextDrawMatchU
|
|
|
449
449
|
if (!orphans.length)
|
|
450
450
|
return targetMatchUpDrawPositions;
|
|
451
451
|
withdrawOwnAdvancement({
|
|
452
|
+
clearDrawPosition,
|
|
452
453
|
fromRoundNumber: targetMatchUp.roundNumber,
|
|
453
454
|
structureId: targetMatchUp.structureId,
|
|
454
455
|
targetMatchUpDrawPositions,
|
|
@@ -496,6 +497,7 @@ function conditionallyAdvanceDrawPosition(params) {
|
|
|
496
497
|
if (sameStructure && overlap(sourceDrawPositions, targetMatchUpDrawPositions)) {
|
|
497
498
|
if (isDoubleExit(params.matchUpStatus))
|
|
498
499
|
withdrawOwnAdvancement({
|
|
500
|
+
clearDrawPosition,
|
|
499
501
|
fromRoundNumber: targetMatchUp.roundNumber,
|
|
500
502
|
structureId: targetMatchUp.structureId,
|
|
501
503
|
targetMatchUpDrawPositions,
|
|
@@ -1585,6 +1587,7 @@ function advanceByeToLoserMatchUp(params) {
|
|
|
1585
1587
|
loserTargetDrawPosition;
|
|
1586
1588
|
if (vacated && !vacated.participantId && !vacated.bye && awardedToVacated && loserMatchUp?.roundNumber) {
|
|
1587
1589
|
releaseAdvancedDrawPositionAcrossLinks({
|
|
1590
|
+
clearDrawPosition,
|
|
1588
1591
|
fromRoundNumber: loserMatchUp.roundNumber + 1,
|
|
1589
1592
|
drawPosition: loserTargetDrawPosition,
|
|
1590
1593
|
withdrawingExit: true,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { releaseAdvancedDrawPositionAcrossLinks } from '../../matchUps/drawPositions/releaseLinkedWinnerAdvancement.mjs';
|
|
2
2
|
import { setMatchUpDrawPositions } from '../../matchUps/drawPositions/setMatchUpDrawPositions.mjs';
|
|
3
|
+
import { clearDrawPosition } from '../../matchUps/drawPositions/positionClear.mjs';
|
|
3
4
|
import { getPositionAssignments } from '../../../query/drawDefinition/positionsGetter.mjs';
|
|
4
5
|
import { modifyMatchUpNotice } from '../../notifications/drawNotifications.mjs';
|
|
5
6
|
import { getSideExitProvenance, carriedExitStatus, clearSideExitProvenance, setSideExitProvenance, deriveExitStateFromProvenance } from '../../matchUps/matchUpStatus/sideExitProvenance.mjs';
|
|
@@ -34,6 +35,7 @@ function releaseHoldersByeFromTarget({ arrivalSideNumber, nextWinnerMatchUp, dra
|
|
|
34
35
|
const released = [holdersBye, ...(stored.drawPositions ?? [])];
|
|
35
36
|
for (const drawPosition of released.filter((position) => !!position)) {
|
|
36
37
|
releaseAdvancedDrawPositionAcrossLinks({
|
|
38
|
+
clearDrawPosition,
|
|
37
39
|
fromRoundNumber: (nextWinnerMatchUp.roundNumber ?? 0) + 1,
|
|
38
40
|
structureId: fromMatchUp.structureId,
|
|
39
41
|
tournamentRecord: params.tournamentRecord,
|
|
@@ -4,6 +4,7 @@ import { isMatchUpEventType } from '../../helpers/matchUpEventTypes/isMatchUpEve
|
|
|
4
4
|
import { getAppliedPolicies } from '../../query/extensions/getAppliedPolicies.mjs';
|
|
5
5
|
import { isRotatingPartnerDraw } from '../../validators/rotatingPartnerDraw.mjs';
|
|
6
6
|
import { addDrawEntries } from '../drawDefinitions/addDrawEntries.mjs';
|
|
7
|
+
import { entityIdMismatch } from '../../helpers/parameters/entityIdMismatch.mjs';
|
|
7
8
|
import { decorateResult } from '../../functions/global/decorateResult.mjs';
|
|
8
9
|
import { refreshEntryPositions } from './refreshEntryPositions.mjs';
|
|
9
10
|
import { isValidExtension } from '../../validators/isValidExtension.mjs';
|
|
@@ -230,6 +231,9 @@ function validateAddEventEntriesParams(params, stack) {
|
|
|
230
231
|
const participantIds = unique(params.participantIds ?? []);
|
|
231
232
|
if (!params.event)
|
|
232
233
|
return { error: MISSING_EVENT };
|
|
234
|
+
const mismatch = entityIdMismatch(params);
|
|
235
|
+
if (mismatch)
|
|
236
|
+
return mismatch;
|
|
233
237
|
if (!participantIds?.length) {
|
|
234
238
|
return decorateResult({
|
|
235
239
|
result: { error: MISSING_PARTICIPANT_IDS },
|
|
@@ -95,7 +95,8 @@ function policyAttachement(params, element) {
|
|
|
95
95
|
if (!isObject(policy))
|
|
96
96
|
return { error: INVALID_VALUES };
|
|
97
97
|
const { policyName, ...values } = policy;
|
|
98
|
-
|
|
98
|
+
const defined = Object.values(values).some((value) => value !== undefined);
|
|
99
|
+
if (!defined || (policyName && !isString(policyName)))
|
|
99
100
|
return { error: INVALID_VALUES };
|
|
100
101
|
appliedPolicies[policyType] = params.policyDefinitions[policyType];
|
|
101
102
|
applied.push(policyType);
|
|
@@ -6,6 +6,7 @@ import { matchUpHoldsScheduling, releaseByeScheduling } from '../schedule/byeSch
|
|
|
6
6
|
import { getDrawPositionSideNumber, getSideDrawPosition } from '../../../query/matchUps/getDrawPositionSides.mjs';
|
|
7
7
|
import { getStructureDrawPositionProfiles } from '../../../query/structure/getStructureDrawPositionProfiles.mjs';
|
|
8
8
|
import { getAllStructureMatchUps } from '../../../query/matchUps/getAllStructureMatchUps.mjs';
|
|
9
|
+
import { clearDrawPosition } from './positionClear.mjs';
|
|
9
10
|
import { getPositionAssignments } from '../../../query/drawDefinition/positionsGetter.mjs';
|
|
10
11
|
import { getInitialRoundNumber } from '../../../query/matchUps/getInitialRoundNumber.mjs';
|
|
11
12
|
import { isLuckyBasedDraw } from '../../../query/drawDefinition/isLuckyBasedDraw.mjs';
|
|
@@ -601,6 +602,7 @@ function releaseProducedExitReservation({ drawPositionToAdvance, drawDefinition,
|
|
|
601
602
|
});
|
|
602
603
|
for (const drawPosition of vacant) {
|
|
603
604
|
releaseAdvancedDrawPositionAcrossLinks({
|
|
605
|
+
clearDrawPosition,
|
|
604
606
|
fromRoundNumber: winnerMatchUp.roundNumber + 1,
|
|
605
607
|
withdrawingExit: true,
|
|
606
608
|
drawDefinition,
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { getSideDrawPosition } from '../../../query/matchUps/getDrawPositionSides.mjs';
|
|
2
|
+
import { cameDownLoserLink } from './cameDownLoserLink.mjs';
|
|
3
|
+
import { isDoubleExit } from '../../../validators/isExit.mjs';
|
|
4
|
+
|
|
5
|
+
function awardStands({ rederived, retained, positionAssignments, targetMatchUp, drawDefinition, structureId, }) {
|
|
6
|
+
const { winningSide } = rederived;
|
|
7
|
+
if (!winningSide)
|
|
8
|
+
return true;
|
|
9
|
+
const exitEntry = retained?.[3 - winningSide];
|
|
10
|
+
if (!isDoubleExit(exitEntry?.previousMatchUpStatus))
|
|
11
|
+
return true;
|
|
12
|
+
if (cameDownLoserLink({ drawDefinition, targetMatchUp, sourceMatchUpId: exitEntry?.sourceMatchUpId }))
|
|
13
|
+
return true;
|
|
14
|
+
const drawPosition = getSideDrawPosition({
|
|
15
|
+
matchUp: { ...targetMatchUp, sides: undefined },
|
|
16
|
+
sideNumber: winningSide,
|
|
17
|
+
drawDefinition,
|
|
18
|
+
structureId,
|
|
19
|
+
});
|
|
20
|
+
const assignment = positionAssignments.find((candidate) => candidate.drawPosition === drawPosition);
|
|
21
|
+
return !!(assignment?.participantId || assignment?.qualifier);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export { awardStands };
|
|
@@ -362,6 +362,7 @@ function replaceEarlierAdvance({ tournamentRecord, winnerMatchUpId, drawDefiniti
|
|
|
362
362
|
if (!positionAssignments?.some((entry) => entry.drawPosition === position && entry.participantId))
|
|
363
363
|
continue;
|
|
364
364
|
releaseAdvancedDrawPositionAcrossLinks({
|
|
365
|
+
clearDrawPosition,
|
|
365
366
|
fromRoundNumber: (stored.roundNumber ?? 0) + 1,
|
|
366
367
|
drawPosition: position,
|
|
367
368
|
tournamentRecord,
|
|
@@ -5,18 +5,18 @@ import { getDrawPositionSideNumber, getSideDrawPosition } from '../../../query/m
|
|
|
5
5
|
import { getStructureDrawPositionProfiles } from '../../../query/structure/getStructureDrawPositionProfiles.mjs';
|
|
6
6
|
import { setMatchUpDrawPositions } from './setMatchUpDrawPositions.mjs';
|
|
7
7
|
import { carriedEntryAt, bringCarryHome } from './carryHome.mjs';
|
|
8
|
-
import { cameDownLoserLink } from './cameDownLoserLink.mjs';
|
|
9
8
|
import { getAllStructureMatchUps } from '../../../query/matchUps/getAllStructureMatchUps.mjs';
|
|
10
9
|
import { byeSeatStands } from '../matchUpStatus/feederSendsNobody.mjs';
|
|
11
10
|
import { getInitialRoundNumber } from '../../../query/matchUps/getInitialRoundNumber.mjs';
|
|
12
11
|
import { getAppliedPolicies } from '../../../query/extensions/getAppliedPolicies.mjs';
|
|
13
|
-
import {
|
|
12
|
+
import { awardStands } from './awardStands.mjs';
|
|
14
13
|
import { getRoundMatchUps } from '../../../query/matchUps/getRoundMatchUps.mjs';
|
|
15
14
|
import { decorateResult } from '../../../functions/global/decorateResult.mjs';
|
|
16
15
|
import { getAllDrawMatchUps } from '../../../query/matchUps/drawMatchUps.mjs';
|
|
17
16
|
import { positionTargets } from '../../../query/matchUp/positionTargets.mjs';
|
|
18
17
|
import { getMatchUpsMap } from '../../../query/matchUps/getMatchUpsMap.mjs';
|
|
19
18
|
import { pushGlobalLog } from '../../../functions/global/globalLog.mjs';
|
|
19
|
+
import { isAnyExit, isExit } from '../../../validators/isExit.mjs';
|
|
20
20
|
import { matchUpsOf } from '../../../acquire/structureMembers.mjs';
|
|
21
21
|
import { findStructure } from '../../../acquire/findStructure.mjs';
|
|
22
22
|
import { ensureInt } from '../../../tools/ensureInt.mjs';
|
|
@@ -167,6 +167,7 @@ function drawPositionRemovals({ inContextDrawMatchUps, tournamentRecord, drawDef
|
|
|
167
167
|
if (!pairedDrawPosition || roundProfile?.[roundNumber + 1])
|
|
168
168
|
continue;
|
|
169
169
|
releaseLinkedWinnerAdvancement({
|
|
170
|
+
clearDrawPosition,
|
|
170
171
|
drawPosition: pairedDrawPosition,
|
|
171
172
|
tournamentRecord,
|
|
172
173
|
drawDefinition,
|
|
@@ -179,6 +180,7 @@ function drawPositionRemovals({ inContextDrawMatchUps, tournamentRecord, drawDef
|
|
|
179
180
|
}
|
|
180
181
|
if (clearedParticipantId) {
|
|
181
182
|
releaseAcrossWinnerLinks({
|
|
183
|
+
clearDrawPosition,
|
|
182
184
|
participantId: clearedParticipantId,
|
|
183
185
|
tournamentRecord,
|
|
184
186
|
drawDefinition,
|
|
@@ -266,6 +268,7 @@ function removeDrawPosition({ inContextDrawMatchUps, clearedParticipantId, posit
|
|
|
266
268
|
drawDefinition,
|
|
267
269
|
}));
|
|
268
270
|
releaseLinkedWinnerAdvancement({
|
|
271
|
+
clearDrawPosition,
|
|
269
272
|
participantId: clearedParticipantId,
|
|
270
273
|
roundNumber: targetMatchUp.roundNumber,
|
|
271
274
|
structureId: structure.structureId,
|
|
@@ -433,6 +436,7 @@ function releaseUndecidedAdvancements({ initialMatchUpStatus, initialDrawPositio
|
|
|
433
436
|
if (!advanced || advanced === drawPosition)
|
|
434
437
|
continue;
|
|
435
438
|
releaseAdvancedDrawPositionAcrossLinks({
|
|
439
|
+
clearDrawPosition,
|
|
436
440
|
structureId: structure.structureId,
|
|
437
441
|
fromRoundNumber: roundNumber + 1,
|
|
438
442
|
drawPosition: advanced,
|
|
@@ -515,24 +519,6 @@ function updateMatchUpStatusAfterRemoval({ initialDrawPositions, initialMatchUpS
|
|
|
515
519
|
}
|
|
516
520
|
return matchUpContainsBye;
|
|
517
521
|
}
|
|
518
|
-
function awardStands({ rederived, retained, positionAssignments, targetMatchUp, drawDefinition, structureId, }) {
|
|
519
|
-
const { winningSide } = rederived;
|
|
520
|
-
if (!winningSide)
|
|
521
|
-
return true;
|
|
522
|
-
const exitEntry = retained?.[3 - winningSide];
|
|
523
|
-
if (!isDoubleExit(exitEntry?.previousMatchUpStatus))
|
|
524
|
-
return true;
|
|
525
|
-
if (cameDownLoserLink({ drawDefinition, targetMatchUp, sourceMatchUpId: exitEntry?.sourceMatchUpId }))
|
|
526
|
-
return true;
|
|
527
|
-
const drawPosition = getSideDrawPosition({
|
|
528
|
-
matchUp: { ...targetMatchUp, sides: undefined },
|
|
529
|
-
sideNumber: winningSide,
|
|
530
|
-
drawDefinition,
|
|
531
|
-
structureId,
|
|
532
|
-
});
|
|
533
|
-
const assignment = positionAssignments.find((candidate) => candidate.drawPosition === drawPosition);
|
|
534
|
-
return !!(assignment?.participantId || assignment?.qualifier);
|
|
535
|
-
}
|
|
536
522
|
function sideFedFromPosition({ drawDefinition, targetMatchUp, drawPosition, structureId, }) {
|
|
537
523
|
const { roundNumber, roundPosition } = targetMatchUp;
|
|
538
524
|
if (!drawPosition || !roundNumber || !roundPosition || roundNumber < 2)
|
|
@@ -731,4 +717,4 @@ function advancedByOpponentsBye({ positionAssignments, targetMatchUp, drawPositi
|
|
|
731
717
|
positionAssignments.some((assignment) => assignment.drawPosition === position && assignment.bye));
|
|
732
718
|
}
|
|
733
719
|
|
|
734
|
-
export {
|
|
720
|
+
export { clearDrawPosition, drawPositionRemovals };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { removeOnwardLoserPlacements } from './removeOnwardLoserPlacements.mjs';
|
|
2
2
|
import { applyWithdrawnExits } from '../matchUpStatus/applyWithdrawnExits.mjs';
|
|
3
3
|
import { byeSeatsOwedTo } from '../matchUpStatus/feederSendsNobody.mjs';
|
|
4
|
+
import { clearDrawPosition } from './positionClear.mjs';
|
|
4
5
|
import { modifyMatchUpNotice } from '../../notifications/drawNotifications.mjs';
|
|
5
6
|
import { checkScoreHasValue } from '../../../query/matchUp/checkScoreHasValue.mjs';
|
|
6
7
|
import { isDoubleExit, isAnyExit, isExit } from '../../../validators/isExit.mjs';
|
|
@@ -103,6 +104,7 @@ function unawardProducedExit(args, standing, loserParticipantId) {
|
|
|
103
104
|
if (!stored || !drawPosition || !standing.roundNumber)
|
|
104
105
|
return;
|
|
105
106
|
releaseAdvancedDrawPositionAcrossLinks({
|
|
107
|
+
clearDrawPosition,
|
|
106
108
|
structureId: standing.structureId,
|
|
107
109
|
fromRoundNumber: standing.roundNumber + 1,
|
|
108
110
|
tournamentRecord: args.tournamentRecord,
|
|
@@ -113,6 +115,7 @@ function unawardProducedExit(args, standing, loserParticipantId) {
|
|
|
113
115
|
drawPosition,
|
|
114
116
|
});
|
|
115
117
|
releaseLinkedWinnerAdvancement({
|
|
118
|
+
clearDrawPosition,
|
|
116
119
|
participantId: loserParticipantId,
|
|
117
120
|
tournamentRecord: args.tournamentRecord,
|
|
118
121
|
structureId: standing.structureId,
|