tods-competition-factory 7.1.1 → 7.3.1
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/generators/mocks/processLeagueProfiles.mjs +2 -1
- package/dist/esm/assemblies/governors/scoreGovernor/index.mjs +2 -1
- package/dist/esm/assemblies/governors/scoreGovernor/query.mjs +2 -1
- package/dist/esm/constants/matchUpStatusConstants.mjs +1 -1
- package/dist/esm/fixtures/policies/POLICY_PROGRESSION_DEFAULT.mjs +1 -1
- package/dist/esm/mutate/drawDefinitions/matchUpGovernor/{matchUpStatusCodes.mjs → recordSourceSideProvenance.mjs} +3 -14
- package/dist/esm/mutate/drawDefinitions/matchUpGovernor/removeDoubleExit.mjs +31 -9
- package/dist/esm/mutate/drawDefinitions/positionGovernor/doubleExitAdvancement.mjs +311 -64
- package/dist/esm/mutate/drawDefinitions/resetDrawDefinition.mjs +7 -0
- package/dist/esm/mutate/matchUps/drawPositions/assignDrawPositionBye.mjs +8 -12
- package/dist/esm/mutate/matchUps/drawPositions/directParticipants.mjs +1 -0
- package/dist/esm/mutate/matchUps/drawPositions/drawPositionPlacement.mjs +41 -24
- package/dist/esm/mutate/matchUps/drawPositions/positionClear.mjs +27 -4
- package/dist/esm/mutate/matchUps/drawPositions/progressExitStatus.mjs +20 -13
- package/dist/esm/mutate/matchUps/drawPositions/propagateUnfillableLoserBye.mjs +77 -0
- package/dist/esm/mutate/matchUps/drawPositions/propagatesByeOnDoubleExit.mjs +5 -0
- package/dist/esm/mutate/matchUps/drawPositions/releaseAdvancedDrawPosition.mjs +22 -1
- package/dist/esm/mutate/matchUps/drawPositions/removeDirectedParticipants.mjs +5 -4
- package/dist/esm/mutate/matchUps/drawPositions/removeSubsequentRoundsParticipant.mjs +4 -3
- package/dist/esm/mutate/matchUps/matchUpStatus/applyWithdrawnExits.mjs +1 -0
- package/dist/esm/mutate/matchUps/matchUpStatus/reconcileDecider.mjs +101 -0
- package/dist/esm/mutate/matchUps/matchUpStatus/reconcileStaleExitOrigins.mjs +65 -0
- package/dist/esm/mutate/matchUps/matchUpStatus/setMatchUpStatus.mjs +50 -16
- package/dist/esm/mutate/matchUps/matchUpStatus/sideExitProvenance.mjs +112 -45
- package/dist/esm/mutate/matchUps/matchUpStatus/sideStatusCodes.mjs +36 -0
- package/dist/esm/mutate/matchUps/score/modifyMatchUpScore.mjs +21 -3
- package/dist/esm/package.json.mjs +1 -1
- package/dist/esm/query/drawDefinition/getDrawInconsistencies.mjs +5 -4
- package/dist/esm/query/drawDefinition/getStructureInconsistencies.mjs +106 -12
- package/dist/esm/query/drawDefinition/isActiveDownstream.mjs +2 -2
- package/dist/esm/query/event/getEventInconsistencies.mjs +2 -2
- package/dist/esm/query/integrity/inconsistency.mjs +4 -1
- package/dist/esm/query/matchUp/analyzeMatchUp.mjs +29 -2
- package/dist/esm/query/matchUp/checkSetIsComplete.mjs +2 -1
- package/dist/esm/query/matchUp/getComplement.mjs +19 -1
- package/dist/esm/query/matchUp/retainScoreForFormat.mjs +57 -0
- package/dist/esm/query/matchUps/getDrawPositionSides.mjs +11 -1
- package/dist/esm/query/matchUps/scheduling/getMatchUpReadiness.mjs +8 -0
- package/dist/esm/query/tournaments/getTournamentInconsistencies.mjs +2 -2
- package/dist/esm/validators/validateMatchUpScore.mjs +9 -4
- package/dist/tods-competition-factory.d.cts +58 -22
- package/dist/tods-competition-factory.d.mts +58 -22
- package/dist/tods-competition-factory.d.ts +58 -22
- package/dist/tods-competition-factory.development.cjs.js +1510 -605
- 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 +29 -26
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
|
-
**13,
|
|
145
|
+
**13,700+ tests** 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
|
|
|
@@ -6,13 +6,14 @@ import { isNumeric } from '../../../tools/math.mjs';
|
|
|
6
6
|
import { ANY, MALE, OTHER, MIXED, FEMALE } from '../../../constants/genderConstants.mjs';
|
|
7
7
|
import tieFormatDefaults from '../templates/tieFormatDefaults.mjs';
|
|
8
8
|
import { AD_HOC, DOUBLE_ROUND_ROBIN, MAIN } from '../../../constants/drawDefinitionConstants.mjs';
|
|
9
|
+
import '../../../helpers/keyValueScore/constants.mjs';
|
|
9
10
|
import '../../../mutate/matchUps/schedule/byeScheduling.mjs';
|
|
10
11
|
import { TEAM } from '../../../constants/participantConstants.mjs';
|
|
11
12
|
import { DIRECT_ACCEPTANCE } from '../../../constants/entryStatusValues.mjs';
|
|
12
13
|
import { UUID } from '../../../tools/UUID.mjs';
|
|
13
|
-
import '../../../helpers/keyValueScore/constants.mjs';
|
|
14
14
|
import { COMPETITOR } from '../../../constants/participantRoleValues.mjs';
|
|
15
15
|
import '../../../types/tournamentTypes.mjs';
|
|
16
|
+
import '../../../mutate/matchUps/matchUpStatus/sideStatusCodes.mjs';
|
|
16
17
|
import '../../../query/drawDefinition/predictDrawCompetitiveBands.mjs';
|
|
17
18
|
import { generateDrawDefinition } from '../drawDefinitions/generateDrawDefinition/generateDrawDefinition.mjs';
|
|
18
19
|
import { addParticipants } from '../../../mutate/participants/addParticipants.mjs';
|
|
@@ -23,9 +23,9 @@ export { deduceMatchUpFormat } from '../../../query/scoring/deduceMatchUpFormat.
|
|
|
23
23
|
export { generateScoreString } from '../../generators/matchUps/generateScoreString.mjs';
|
|
24
24
|
export { generateTieMatchUpScore } from '../../generators/tieMatchUpScore/generateTieMatchUpScore.mjs';
|
|
25
25
|
export { getEpisodes } from '../../../query/scoring/getEpisodes.mjs';
|
|
26
|
+
export { getMaxSetScore, getSetComplement, getTiebreakComplement } from '../../../query/matchUp/getComplement.mjs';
|
|
26
27
|
export { getScore } from '../../../query/scoring/getScore.mjs';
|
|
27
28
|
export { getScoreboard } from '../../../query/scoring/getScoreboard.mjs';
|
|
28
|
-
export { getSetComplement, getTiebreakComplement } from '../../../query/matchUp/getComplement.mjs';
|
|
29
29
|
export { getWinner } from '../../../query/scoring/getWinner.mjs';
|
|
30
30
|
export { inferServeSide } from '../../../mutate/scoring/serveSideCalculator.mjs';
|
|
31
31
|
export { isComplete } from '../../../query/scoring/isComplete.mjs';
|
|
@@ -34,6 +34,7 @@ export { keyValueScore } from '../../../helpers/keyValueScore/keyValueScore.mjs'
|
|
|
34
34
|
export { parse as parseMatchUpFormat } from '../../../helpers/matchUpFormatCode/parse.mjs';
|
|
35
35
|
export { parseScoreString } from '../../../tools/parseScoreString.mjs';
|
|
36
36
|
export { resolvePointValue } from '../../../mutate/scoring/resolvePointValue.mjs';
|
|
37
|
+
export { retainScoreForFormat } from '../../../query/matchUp/retainScoreForFormat.mjs';
|
|
37
38
|
export { reverseScore } from '../../generators/score/reverseScore.mjs';
|
|
38
39
|
export { stringify as stringifyMatchUpFormat } from '../../../helpers/matchUpFormatCode/stringify.mjs';
|
|
39
40
|
export { toStatObjects } from '../../../query/scoring/statistics/toStatObjects.mjs';
|
|
@@ -2,7 +2,8 @@ export { validateMatchUpScore, validateSetScore } from '../../../validators/vali
|
|
|
2
2
|
export { isValidMatchUpFormat } from '../../../validators/isValidMatchUpFormat.mjs';
|
|
3
3
|
export { validateTieFormat } from '../../../validators/validateTieFormat.mjs';
|
|
4
4
|
export { validateScore } from '../../../validators/validateScore.mjs';
|
|
5
|
-
export { getSetComplement, getTiebreakComplement } from '../../../query/matchUp/getComplement.mjs';
|
|
5
|
+
export { getMaxSetScore, getSetComplement, getTiebreakComplement } from '../../../query/matchUp/getComplement.mjs';
|
|
6
|
+
export { retainScoreForFormat } from '../../../query/matchUp/retainScoreForFormat.mjs';
|
|
6
7
|
export { checkScoreHasValue } from '../../../query/matchUp/checkScoreHasValue.mjs';
|
|
7
8
|
export { checkSetIsComplete } from '../../../query/matchUp/checkSetIsComplete.mjs';
|
|
8
9
|
export { analyzeScore } from '../../../query/matchUp/analyzeScore.mjs';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ABANDONED, AWAITING_RESULT, CANCELLED, CHALLENGED, DEAD_RUBBER, IN_PROGRESS, INCOMPLETE, NOT_PLAYED, SUSPENDED, TO_BE_PLAYED, COMPLETED, DEFAULTED, DOUBLE_WALKOVER, DOUBLE_DEFAULT, RETIRED, WALKOVER, BYE } from './matchUpStatusValues.mjs';
|
|
2
2
|
|
|
3
3
|
const recoveryTimeRequiredMatchUpStatuses = [
|
|
4
4
|
AWAITING_RESULT,
|
|
@@ -2,7 +2,7 @@ import { POLICY_TYPE_PROGRESSION } from '../../constants/policyConstants.mjs';
|
|
|
2
2
|
|
|
3
3
|
const POLICY_PROGRESSION_DEFAULT = {
|
|
4
4
|
[POLICY_TYPE_PROGRESSION]: {
|
|
5
|
-
doubleExitPropagateBye:
|
|
5
|
+
doubleExitPropagateBye: true,
|
|
6
6
|
autoPlaceQualifiers: false,
|
|
7
7
|
autoReplaceQualifiers: false,
|
|
8
8
|
autoRemoveQualifiers: false,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { mergeSideExitProvenance, producedExitStatus } from '../../matchUps/matchUpStatus/sideExitProvenance.mjs';
|
|
2
2
|
import { getPairedPreviousMatchUp } from '../../../query/matchUps/getPairedPreviousMatchup.mjs';
|
|
3
3
|
import { definedAttributes } from '../../../tools/definedAttributes.mjs';
|
|
4
4
|
import { TO_BE_PLAYED } from '../../../constants/matchUpStatusValues.mjs';
|
|
5
5
|
|
|
6
|
-
function
|
|
6
|
+
function recordSourceSideProvenance({ inContextDrawMatchUps, sourceMatchUpStatus, sourceMatchUpId, matchUpsMap, matchUp, }) {
|
|
7
7
|
const sourceMatchUp = inContextDrawMatchUps.find((matchUp) => matchUp.matchUpId === sourceMatchUpId);
|
|
8
8
|
const { pairedPreviousMatchUp } = getPairedPreviousMatchUp({
|
|
9
9
|
structureId: sourceMatchUp?.structureId,
|
|
@@ -18,17 +18,6 @@ function updateMatchUpStatusCodes({ inContextDrawMatchUps, sourceMatchUpStatus,
|
|
|
18
18
|
(sourceMatchUp?.roundPosition < pairedMatchUp?.roundPosition && 1) || 2
|
|
19
19
|
:
|
|
20
20
|
(sourceMatchUp.structureId === pairedMatchUp?.structureId && 2) || 1;
|
|
21
|
-
matchUp.matchUpStatusCodes = (matchUp.matchUpStatusCodes ?? []).map((code) => {
|
|
22
|
-
const value = typeof code === 'object' && code !== null ? code : { code: code ?? undefined };
|
|
23
|
-
if (value.sideNumber === sourceSideNumber) {
|
|
24
|
-
return {
|
|
25
|
-
...value,
|
|
26
|
-
matchUpStatus: producedExitStatus(sourceMatchUpStatus),
|
|
27
|
-
previousMatchUpStatus: sourceMatchUpStatus,
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
return value;
|
|
31
|
-
});
|
|
32
21
|
if (sourceMatchUpStatus && sourceMatchUpStatus !== TO_BE_PLAYED) {
|
|
33
22
|
mergeSideExitProvenance({
|
|
34
23
|
matchUp,
|
|
@@ -44,4 +33,4 @@ function updateMatchUpStatusCodes({ inContextDrawMatchUps, sourceMatchUpStatus,
|
|
|
44
33
|
}
|
|
45
34
|
}
|
|
46
35
|
|
|
47
|
-
export {
|
|
36
|
+
export { recordSourceSideProvenance };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { withdrawByeClaim, withdrawByeClaimsFrom, byeClaimSurvives,
|
|
1
|
+
import { withdrawByeClaim, withdrawByeClaimsFrom, byeClaimSurvives, getSideExitProvenance, retainPolicyCodes, setSideExitProvenance, retainForeignProvenance, deriveExitStateFromProvenance } from '../../matchUps/matchUpStatus/sideExitProvenance.mjs';
|
|
2
2
|
import { removeDirectedBye, removeDirectedWinner } from '../../matchUps/drawPositions/removeDirectedParticipants.mjs';
|
|
3
|
+
import { propagatesByeOnDoubleExit } from '../../matchUps/drawPositions/propagatesByeOnDoubleExit.mjs';
|
|
3
4
|
import { getPairedPreviousMatchUp } from '../../../query/matchUps/getPairedPreviousMatchup.mjs';
|
|
4
5
|
import { modifyMatchUpScore } from '../../matchUps/score/modifyMatchUpScore.mjs';
|
|
5
6
|
import { decorateResult } from '../../../functions/global/decorateResult.mjs';
|
|
@@ -98,7 +99,7 @@ function removeDoubleExit(params) {
|
|
|
98
99
|
if (anotherClaimSurvives) {
|
|
99
100
|
return decorateResult({ result: { ...SUCCESS }, stack });
|
|
100
101
|
}
|
|
101
|
-
if (appliedPolicies
|
|
102
|
+
if (propagatesByeOnDoubleExit(appliedPolicies) || byePropagatedToLoserMatchUp) {
|
|
102
103
|
removeDirectedBye({
|
|
103
104
|
drawPosition: loserTargetDrawPosition,
|
|
104
105
|
targetLink: loserTargetLink,
|
|
@@ -133,7 +134,7 @@ function removeDoubleExit(params) {
|
|
|
133
134
|
return decorateResult({ result: { ...SUCCESS }, stack });
|
|
134
135
|
}
|
|
135
136
|
function carriesWithdrawnOrigin(matchUp, withdrawnSourceIds) {
|
|
136
|
-
const provenance =
|
|
137
|
+
const provenance = getSideExitProvenance({ matchUp });
|
|
137
138
|
if (!provenance)
|
|
138
139
|
return false;
|
|
139
140
|
return [1, 2].some((sideNumber) => {
|
|
@@ -150,6 +151,10 @@ function withdrawExitFromByeChain({ inContextDrawMatchUps, withdrawnSourceIds, d
|
|
|
150
151
|
if (!noContextTargetMatchUp || !carriesWithdrawnOrigin(noContextTargetMatchUp, withdrawnSourceIds)) {
|
|
151
152
|
return { ...SUCCESS };
|
|
152
153
|
}
|
|
154
|
+
const priorWinningSide = noContextTargetMatchUp.winningSide;
|
|
155
|
+
const advancedDrawPosition = priorWinningSide
|
|
156
|
+
? (noContextTargetMatchUp.drawPositions ?? [])[priorWinningSide - 1]
|
|
157
|
+
: undefined;
|
|
153
158
|
const unwound = getUnwoundState({
|
|
154
159
|
pairedPreviousDoubleExit: false,
|
|
155
160
|
noContextTargetMatchUp,
|
|
@@ -166,7 +171,7 @@ function withdrawExitFromByeChain({ inContextDrawMatchUps, withdrawnSourceIds, d
|
|
|
166
171
|
keyColors,
|
|
167
172
|
});
|
|
168
173
|
const result = modifyMatchUpScore({
|
|
169
|
-
matchUpStatusCodes:
|
|
174
|
+
matchUpStatusCodes: retainPolicyCodes(noContextTargetMatchUp),
|
|
170
175
|
removeWinningSide: unwound.winningSide === undefined,
|
|
171
176
|
matchUpStatus: unwound.matchUpStatus,
|
|
172
177
|
matchUpId: fromMatchUp.matchUpId,
|
|
@@ -191,6 +196,23 @@ function withdrawExitFromByeChain({ inContextDrawMatchUps, withdrawnSourceIds, d
|
|
|
191
196
|
const nextWinnerMatchUp = targetMatchUps?.winnerMatchUp;
|
|
192
197
|
if (!nextWinnerMatchUp?.matchUpId)
|
|
193
198
|
return { ...SUCCESS };
|
|
199
|
+
if (advancedDrawPosition && nextWinnerMatchUp.structureId === fromMatchUp.structureId) {
|
|
200
|
+
pushGlobalLog({
|
|
201
|
+
method: 'withdrawExitFromByeChain',
|
|
202
|
+
decision: 'take_back_advanced_winner',
|
|
203
|
+
nextWinnerMatchUpId: nextWinnerMatchUp.matchUpId,
|
|
204
|
+
advancedDrawPosition,
|
|
205
|
+
color: 'brightcyan',
|
|
206
|
+
keyColors,
|
|
207
|
+
});
|
|
208
|
+
removeDirectedWinner({
|
|
209
|
+
winningDrawPosition: advancedDrawPosition,
|
|
210
|
+
winnerMatchUp: nextWinnerMatchUp,
|
|
211
|
+
inContextDrawMatchUps,
|
|
212
|
+
drawDefinition,
|
|
213
|
+
matchUpsMap,
|
|
214
|
+
});
|
|
215
|
+
}
|
|
194
216
|
return withdrawExitFromByeChain({
|
|
195
217
|
fromMatchUp: nextWinnerMatchUp,
|
|
196
218
|
inContextDrawMatchUps,
|
|
@@ -287,7 +309,7 @@ function conditionallyRemoveDrawPosition(params) {
|
|
|
287
309
|
if (result.error)
|
|
288
310
|
return decorateResult({ result, stack });
|
|
289
311
|
const carriesSomethingOfThisCascade = carriesWithdrawnOrigin(noContextTargetMatchUp, withdrawnSourceIds);
|
|
290
|
-
const holdsProvenance = !!
|
|
312
|
+
const holdsProvenance = !!getSideExitProvenance({ matchUp: noContextTargetMatchUp });
|
|
291
313
|
if (holdsProvenance && !carriesSomethingOfThisCascade) {
|
|
292
314
|
pushGlobalLog({
|
|
293
315
|
method: stack,
|
|
@@ -308,7 +330,7 @@ function conditionallyRemoveDrawPosition(params) {
|
|
|
308
330
|
const removeScore = !pairedPreviousDoubleExit;
|
|
309
331
|
result = modifyMatchUpScore({
|
|
310
332
|
...params,
|
|
311
|
-
matchUpStatusCodes:
|
|
333
|
+
matchUpStatusCodes: retainPolicyCodes(noContextTargetMatchUp),
|
|
312
334
|
removeWinningSide: unwound.winningSide === undefined,
|
|
313
335
|
matchUpId: targetMatchUp.matchUpId,
|
|
314
336
|
matchUp: noContextTargetMatchUp,
|
|
@@ -363,10 +385,10 @@ function getUnwoundState({ pairedPreviousDoubleExit, noContextTargetMatchUp, wit
|
|
|
363
385
|
if (noContextTargetMatchUp.matchUpStatus === BYE) {
|
|
364
386
|
return {
|
|
365
387
|
matchUpStatus: BYE,
|
|
366
|
-
provenance: retainForeignProvenance(
|
|
388
|
+
provenance: retainForeignProvenance(getSideExitProvenance({ matchUp: noContextTargetMatchUp }), withdrawnSourceIds),
|
|
367
389
|
};
|
|
368
390
|
}
|
|
369
|
-
const retained = retainForeignProvenance(
|
|
391
|
+
const retained = retainForeignProvenance(getSideExitProvenance({ matchUp: noContextTargetMatchUp }), withdrawnSourceIds);
|
|
370
392
|
if (pairedPreviousDoubleExit) {
|
|
371
393
|
return {
|
|
372
394
|
matchUpStatus: [DOUBLE_DEFAULT, DEFAULTED].includes(noContextTargetMatchUp?.matchUpStatus) ? DEFAULTED : WALKOVER,
|
|
@@ -376,7 +398,7 @@ function getUnwoundState({ pairedPreviousDoubleExit, noContextTargetMatchUp, wit
|
|
|
376
398
|
if (targetDrawPositionIsBye({ drawDefinition, noContextTargetMatchUp, targetMatchUp })) {
|
|
377
399
|
return {
|
|
378
400
|
matchUpStatus: BYE,
|
|
379
|
-
provenance: retainForeignProvenance(
|
|
401
|
+
provenance: retainForeignProvenance(getSideExitProvenance({ matchUp: noContextTargetMatchUp }), withdrawnSourceIds),
|
|
380
402
|
};
|
|
381
403
|
}
|
|
382
404
|
if (isDoubleExit(noContextTargetMatchUp?.matchUpStatus)) {
|