tods-competition-factory 1.4.2 → 1.4.3
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/dist/index.mjs +55 -31
- package/dist/index.mjs.map +1 -1
- package/dist/tods-competition-factory.development.cjs.js +32 -7
- 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 +2 -2
package/dist/index.mjs
CHANGED
|
@@ -321,7 +321,7 @@ const matchUpFormatCode = {
|
|
|
321
321
|
};
|
|
322
322
|
|
|
323
323
|
function factoryVersion() {
|
|
324
|
-
return "1.4.
|
|
324
|
+
return "1.4.3";
|
|
325
325
|
}
|
|
326
326
|
|
|
327
327
|
function getObjectTieFormat(obj) {
|
|
@@ -36488,6 +36488,10 @@ const POLICY_MATCHUP_ACTIONS_DEFAULT = {
|
|
|
36488
36488
|
// disabledActions: [] => no actions are disabled
|
|
36489
36489
|
}
|
|
36490
36490
|
],
|
|
36491
|
+
participants: {
|
|
36492
|
+
enforceGender: true
|
|
36493
|
+
// disallow placing FEMALEs in MALE events and vice versa
|
|
36494
|
+
},
|
|
36491
36495
|
processCodes: {
|
|
36492
36496
|
substitution: ["RANKING.IGNORE", "RATING.IGNORE"]
|
|
36493
36497
|
}
|
|
@@ -36621,7 +36625,7 @@ function matchUpActions$2({
|
|
|
36621
36625
|
matchUpId,
|
|
36622
36626
|
event
|
|
36623
36627
|
}) {
|
|
36624
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
|
|
36628
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
36625
36629
|
if (!drawDefinition)
|
|
36626
36630
|
return { error: MISSING_DRAW_DEFINITION };
|
|
36627
36631
|
if (!matchUpId)
|
|
@@ -36644,6 +36648,7 @@ function matchUpActions$2({
|
|
|
36644
36648
|
event
|
|
36645
36649
|
});
|
|
36646
36650
|
Object.assign(appliedPolicies, specifiedPolicyDefinitions || {});
|
|
36651
|
+
const matchUpActionsPolicy = (appliedPolicies == null ? void 0 : appliedPolicies[POLICY_TYPE_MATCHUP_ACTIONS]) || POLICY_MATCHUP_ACTIONS_DEFAULT[POLICY_TYPE_MATCHUP_ACTIONS];
|
|
36647
36652
|
const { enabledStructures } = getEnabledStructures({
|
|
36648
36653
|
actionType: MATCHUP_ACTION,
|
|
36649
36654
|
appliedPolicies,
|
|
@@ -36847,7 +36852,7 @@ function matchUpActions$2({
|
|
|
36847
36852
|
if (isCollectionMatchUp) {
|
|
36848
36853
|
const assignedGender = inContextMatchUp.gender === MIXED && inContextMatchUp.sideNumber && inContextMatchUp.sides.filter(({ particiapntId }) => particiapntId).length === 1 && ((_l = (_k = (_j = inContextMatchUp.sides.find((side2) => side2.participant)) == null ? void 0 : _j.participant) == null ? void 0 : _k.person) == null ? void 0 : _l.sex);
|
|
36849
36854
|
const matchUpType = inContextMatchUp.matchUpType;
|
|
36850
|
-
const gender = inContextMatchUp.gender;
|
|
36855
|
+
const gender = ((_m = matchUpActionsPolicy == null ? void 0 : matchUpActionsPolicy.participants) == null ? void 0 : _m.enforceGender) ? inContextMatchUp.gender : void 0;
|
|
36851
36856
|
const allParticipants = inContextMatchUp.sides.flatMap(
|
|
36852
36857
|
(side2) => {
|
|
36853
36858
|
var _a2;
|
|
@@ -36875,7 +36880,7 @@ function matchUpActions$2({
|
|
|
36875
36880
|
participants: available2,
|
|
36876
36881
|
sideNumber: i + 1
|
|
36877
36882
|
}));
|
|
36878
|
-
const availableParticipantIds = sideNumber ? (
|
|
36883
|
+
const availableParticipantIds = sideNumber ? (_n = availableIndividualParticipants[sideNumber - 1]) == null ? void 0 : _n.map(getParticipantId) : availableIndividualParticipants.map((available2, i) => ({
|
|
36879
36884
|
participants: available2 == null ? void 0 : available2.map(getParticipantId),
|
|
36880
36885
|
sideNumber: i + 1
|
|
36881
36886
|
}));
|
|
@@ -36901,7 +36906,7 @@ function matchUpActions$2({
|
|
|
36901
36906
|
}
|
|
36902
36907
|
if (
|
|
36903
36908
|
// isInComplete && // TODO: determine whether removal should be disallowed for completed matchUps => policy consideration?
|
|
36904
|
-
(existingParticipantIds == null ? void 0 : existingParticipantIds.length) && (!scoreHasValue(matchUp) || ((
|
|
36909
|
+
(existingParticipantIds == null ? void 0 : existingParticipantIds.length) && (!scoreHasValue(matchUp) || ((_o = side == null ? void 0 : side.substitutions) == null ? void 0 : _o.length))
|
|
36905
36910
|
) {
|
|
36906
36911
|
validActions.push({
|
|
36907
36912
|
method: REMOVE_TEAM_POSITION_METHOD,
|
|
@@ -36929,10 +36934,10 @@ function matchUpActions$2({
|
|
|
36929
36934
|
}
|
|
36930
36935
|
});
|
|
36931
36936
|
}
|
|
36932
|
-
if (isAvailableAction({ policyActions, action: REMOVE_SUBSTITUTION }) && ((
|
|
36933
|
-
const sideIndividualParticipantIds = ((
|
|
36937
|
+
if (isAvailableAction({ policyActions, action: REMOVE_SUBSTITUTION }) && ((_p = side == null ? void 0 : side.substitutions) == null ? void 0 : _p.length)) {
|
|
36938
|
+
const sideIndividualParticipantIds = ((_q = side.participant) == null ? void 0 : _q.participantType) === INDIVIDUAL && [
|
|
36934
36939
|
side.participantId
|
|
36935
|
-
] || ((
|
|
36940
|
+
] || ((_r = side.participant) == null ? void 0 : _r.participantType) === PAIR && side.participant.individualParticipantIds || [];
|
|
36936
36941
|
const substitutedParticipantIds = side.substitutions.map((sub) => sub.participantId).filter((id) => sideIndividualParticipantIds.includes(id));
|
|
36937
36942
|
if (!participantId || substitutedParticipantIds.includes(participantId)) {
|
|
36938
36943
|
validActions.push({
|
|
@@ -51158,7 +51163,7 @@ function updateTieFormat({
|
|
|
51158
51163
|
matchUp,
|
|
51159
51164
|
event
|
|
51160
51165
|
}) {
|
|
51161
|
-
var _a;
|
|
51166
|
+
var _a, _b;
|
|
51162
51167
|
const stack = "updateTieFormat";
|
|
51163
51168
|
let modifiedStructuresCount = 0;
|
|
51164
51169
|
let modifiedCount = 0;
|
|
@@ -51220,7 +51225,10 @@ function updateTieFormat({
|
|
|
51220
51225
|
});
|
|
51221
51226
|
} else if (structure) {
|
|
51222
51227
|
const inheritedTieFormat = drawDefaultTieFormat || eventDefaultTieFormat;
|
|
51223
|
-
const modified = processStructure({
|
|
51228
|
+
const modified = (_b = processStructure({
|
|
51229
|
+
inheritedTieFormat,
|
|
51230
|
+
structure
|
|
51231
|
+
})) == null ? void 0 : _b.modifiedCount;
|
|
51224
51232
|
modifiedStructuresCount += modified;
|
|
51225
51233
|
structure.tieFormat = tieFormat;
|
|
51226
51234
|
modifiedCount += 1;
|
|
@@ -51238,12 +51246,16 @@ function updateTieFormat({
|
|
|
51238
51246
|
}
|
|
51239
51247
|
return __spreadProps$Y(__spreadValues$1N({}, SUCCESS), { modifiedCount, modifiedStructuresCount, tieFormat });
|
|
51240
51248
|
function processDrawDefinition({ drawDefinition: drawDefinition2 }) {
|
|
51249
|
+
var _a2;
|
|
51241
51250
|
const modifiedStructureIds = [];
|
|
51242
51251
|
for (const structure2 of drawDefinition2.structures || []) {
|
|
51243
51252
|
if (structure2.tieFormat)
|
|
51244
51253
|
continue;
|
|
51245
51254
|
const inheritedTieFormat = eventDefaultTieFormat;
|
|
51246
|
-
const modifiedCount2 = processStructure({
|
|
51255
|
+
const modifiedCount2 = (_a2 = processStructure({
|
|
51256
|
+
inheritedTieFormat,
|
|
51257
|
+
structure: structure2
|
|
51258
|
+
})) == null ? void 0 : _a2.modifiedCount;
|
|
51247
51259
|
if (modifiedCount2) {
|
|
51248
51260
|
modifiedStructuresCount += modifiedCount2;
|
|
51249
51261
|
modifiedStructureIds.push(structure2.structureId);
|
|
@@ -51257,7 +51269,7 @@ function updateTieFormat({
|
|
|
51257
51269
|
return modifiedStructureIds.length;
|
|
51258
51270
|
}
|
|
51259
51271
|
function processStructure({ inheritedTieFormat, structure: structure2 }) {
|
|
51260
|
-
var _a2,
|
|
51272
|
+
var _a2, _b2;
|
|
51261
51273
|
let modifiedCount2 = 0;
|
|
51262
51274
|
const structureMatchUps = ((_a2 = getAllStructureMatchUps({
|
|
51263
51275
|
matchUpFilters: { matchUpTypes: [TEAM$2] },
|
|
@@ -51266,7 +51278,7 @@ function updateTieFormat({
|
|
|
51266
51278
|
for (const matchUp2 of structureMatchUps) {
|
|
51267
51279
|
let modified = false;
|
|
51268
51280
|
const tieMatchUpsMap = instanceCount(
|
|
51269
|
-
(
|
|
51281
|
+
(_b2 = matchUp2.tieMatchUps) == null ? void 0 : _b2.map(({ collectionId }) => collectionId)
|
|
51270
51282
|
);
|
|
51271
51283
|
if (!mapsCheck(collectionMap, tieMatchUpsMap)) {
|
|
51272
51284
|
if (inheritedTieFormat) {
|
|
@@ -51293,7 +51305,7 @@ function updateTieFormat({
|
|
|
51293
51305
|
});
|
|
51294
51306
|
}
|
|
51295
51307
|
}
|
|
51296
|
-
return modifiedCount2;
|
|
51308
|
+
return { modifiedCount: modifiedCount2 };
|
|
51297
51309
|
}
|
|
51298
51310
|
}
|
|
51299
51311
|
|
|
@@ -57032,7 +57044,7 @@ var __spreadValues$12 = (a, b) => {
|
|
|
57032
57044
|
};
|
|
57033
57045
|
var __spreadProps$y = (a, b) => __defProps$y(a, __getOwnPropDescs$y(b));
|
|
57034
57046
|
function replaceTieMatchUpParticipantId(params) {
|
|
57035
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
57047
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
57036
57048
|
const matchUpContext = getTieMatchUpContext(params);
|
|
57037
57049
|
if (matchUpContext.error)
|
|
57038
57050
|
return matchUpContext;
|
|
@@ -57088,13 +57100,19 @@ function replaceTieMatchUpParticipantId(params) {
|
|
|
57088
57100
|
event
|
|
57089
57101
|
});
|
|
57090
57102
|
const matchUpActionsPolicy = (appliedPolicies == null ? void 0 : appliedPolicies[POLICY_TYPE_MATCHUP_ACTIONS]) || POLICY_MATCHUP_ACTIONS_DEFAULT[POLICY_TYPE_MATCHUP_ACTIONS];
|
|
57091
|
-
const
|
|
57103
|
+
const newParticipant = targetParticipants.find(
|
|
57104
|
+
({ participantId }) => participantId === newParticipantId
|
|
57105
|
+
);
|
|
57106
|
+
if (((_b = matchUpActionsPolicy == null ? void 0 : matchUpActionsPolicy.participants) == null ? void 0 : _b.enforceGender) && [MALE, FEMALE].includes(inContextTieMatchUp.gender) && inContextTieMatchUp.gender !== ((_c = newParticipant.person) == null ? void 0 : _c.sex)) {
|
|
57107
|
+
return { error: INVALID_PARTICIPANT, info: "Gender mismatch" };
|
|
57108
|
+
}
|
|
57109
|
+
const substitutionProcessCodes = (_d = matchUpActionsPolicy == null ? void 0 : matchUpActionsPolicy.processCodes) == null ? void 0 : _d.substitution;
|
|
57092
57110
|
const { extension } = findExtension$2({
|
|
57093
57111
|
element: drawDefinition,
|
|
57094
57112
|
name: LINEUPS
|
|
57095
57113
|
});
|
|
57096
57114
|
const lineUps = (extension == null ? void 0 : extension.value) || {};
|
|
57097
|
-
if (!((
|
|
57115
|
+
if (!((_e = dualMatchUp.sides) == null ? void 0 : _e.length)) {
|
|
57098
57116
|
const extractSideDetail = ({
|
|
57099
57117
|
displaySideNumber,
|
|
57100
57118
|
drawPosition,
|
|
@@ -57120,15 +57138,15 @@ function replaceTieMatchUpParticipantId(params) {
|
|
|
57120
57138
|
stack
|
|
57121
57139
|
});
|
|
57122
57140
|
}
|
|
57123
|
-
const allTieIndividualParticipantIds = (
|
|
57141
|
+
const allTieIndividualParticipantIds = (_f = inContextTieMatchUp.sides) == null ? void 0 : _f.flatMap(
|
|
57124
57142
|
({ participant }) => (participant == null ? void 0 : participant.individualParticipantIds) || (participant == null ? void 0 : participant.participantId) || []
|
|
57125
57143
|
);
|
|
57126
57144
|
if (allTieIndividualParticipantIds.includes(newParticipantId)) {
|
|
57127
57145
|
return decorateResult({ result: { error: EXISTING_PARTICIPANT }, stack });
|
|
57128
57146
|
}
|
|
57129
|
-
const teamParticipantId = (
|
|
57147
|
+
const teamParticipantId = (_h = (_g = inContextDualMatchUp.sides) == null ? void 0 : _g.find(
|
|
57130
57148
|
({ sideNumber }) => sideNumber === side.sideNumber
|
|
57131
|
-
)) == null ? void 0 :
|
|
57149
|
+
)) == null ? void 0 : _h.participantId;
|
|
57132
57150
|
const teamLineUp = dualMatchUpSide.lineUp;
|
|
57133
57151
|
const newParticipantIdInLineUp = teamLineUp == null ? void 0 : teamLineUp.find(
|
|
57134
57152
|
({ participantId }) => newParticipantId === participantId
|
|
@@ -57229,13 +57247,13 @@ function replaceTieMatchUpParticipantId(params) {
|
|
|
57229
57247
|
});
|
|
57230
57248
|
if (result2.error)
|
|
57231
57249
|
return decorateResult({ result: result2, stack });
|
|
57232
|
-
participantAdded = (
|
|
57250
|
+
participantAdded = (_i = result2.participant) == null ? void 0 : _i.participantId;
|
|
57233
57251
|
}
|
|
57234
57252
|
result = getPairedParticipant({
|
|
57235
57253
|
participantIds: existingIndividualParticipantIds,
|
|
57236
57254
|
tournamentRecord: tournamentRecord2
|
|
57237
57255
|
});
|
|
57238
|
-
const existingPairParticipantId = (
|
|
57256
|
+
const existingPairParticipantId = (_j = result.participant) == null ? void 0 : _j.participantId;
|
|
57239
57257
|
if (existingPairParticipantId) {
|
|
57240
57258
|
const result2 = deleteParticipants({
|
|
57241
57259
|
participantIds: [existingPairParticipantId],
|
|
@@ -57245,7 +57263,7 @@ function replaceTieMatchUpParticipantId(params) {
|
|
|
57245
57263
|
participantRemoved = existingPairParticipantId;
|
|
57246
57264
|
}
|
|
57247
57265
|
}
|
|
57248
|
-
if (substitution || ((
|
|
57266
|
+
if (substitution || ((_k = side.substitutions) == null ? void 0 : _k.length) === 1) {
|
|
57249
57267
|
if (substitution) {
|
|
57250
57268
|
const processCodes = tieMatchUp.processCodes || [];
|
|
57251
57269
|
if (substitutionProcessCodes)
|
|
@@ -57574,13 +57592,13 @@ var __spreadValues$$ = (a, b) => {
|
|
|
57574
57592
|
};
|
|
57575
57593
|
var __spreadProps$w = (a, b) => __defProps$w(a, __getOwnPropDescs$w(b));
|
|
57576
57594
|
function assignTieMatchUpParticipantId(params) {
|
|
57577
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
57595
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
57578
57596
|
const matchUpContext = getTieMatchUpContext(params);
|
|
57579
57597
|
if (matchUpContext.error)
|
|
57580
57598
|
return matchUpContext;
|
|
57581
57599
|
const stack = "assignTieMatchUpParticipantId";
|
|
57582
57600
|
let teamParticipantId = params.teamParticipantId;
|
|
57583
|
-
const { tournamentRecord, drawDefinition, participantId } = params;
|
|
57601
|
+
const { tournamentRecord, drawDefinition, participantId, event } = params;
|
|
57584
57602
|
if (!participantId) {
|
|
57585
57603
|
return decorateResult({ result: { error: MISSING_PARTICIPANT_ID }, stack });
|
|
57586
57604
|
}
|
|
@@ -57618,7 +57636,13 @@ function assignTieMatchUpParticipantId(params) {
|
|
|
57618
57636
|
if (!participantToAssign) {
|
|
57619
57637
|
return decorateResult({ result: { error: PARTICIPANT_NOT_FOUND }, stack });
|
|
57620
57638
|
}
|
|
57621
|
-
|
|
57639
|
+
const { appliedPolicies } = getAppliedPolicies({
|
|
57640
|
+
tournamentRecord,
|
|
57641
|
+
drawDefinition,
|
|
57642
|
+
event
|
|
57643
|
+
});
|
|
57644
|
+
const matchUpActionsPolicy = (appliedPolicies == null ? void 0 : appliedPolicies[POLICY_TYPE_MATCHUP_ACTIONS]) || POLICY_MATCHUP_ACTIONS_DEFAULT[POLICY_TYPE_MATCHUP_ACTIONS];
|
|
57645
|
+
if (((_c = matchUpActionsPolicy == null ? void 0 : matchUpActionsPolicy.participants) == null ? void 0 : _c.enforceGender) && [MALE, FEMALE].includes(inContextTieMatchUp.gender) && inContextTieMatchUp.gender !== ((_d = participantToAssign.person) == null ? void 0 : _d.sex)) {
|
|
57622
57646
|
return { error: INVALID_PARTICIPANT, info: "Gender mismatch" };
|
|
57623
57647
|
}
|
|
57624
57648
|
const { individualParticipantIds, participantType } = participantToAssign;
|
|
@@ -57642,19 +57666,19 @@ function assignTieMatchUpParticipantId(params) {
|
|
|
57642
57666
|
(assignment) => assignment.participantId === (participantTeam == null ? void 0 : participantTeam.participantId)
|
|
57643
57667
|
);
|
|
57644
57668
|
const teamDrawPosition = teamAssignment == null ? void 0 : teamAssignment.drawPosition;
|
|
57645
|
-
const teamSide = (
|
|
57669
|
+
const teamSide = (_e = inContextTieMatchUp.sides) == null ? void 0 : _e.find(
|
|
57646
57670
|
({ drawPosition }) => drawPosition === teamDrawPosition
|
|
57647
57671
|
);
|
|
57648
57672
|
const sideNumber = params.sideNumber || (teamSide == null ? void 0 : teamSide.sideNumber);
|
|
57649
57673
|
if (!tieFormat) {
|
|
57650
57674
|
return { error: MISSING_TIE_FORMAT };
|
|
57651
57675
|
}
|
|
57652
|
-
const collectionDefinition = (
|
|
57676
|
+
const collectionDefinition = (_f = tieFormat.collectionDefinitions) == null ? void 0 : _f.find(
|
|
57653
57677
|
(collectionDefinition2) => collectionDefinition2.collectionId === collectionId
|
|
57654
57678
|
);
|
|
57655
57679
|
if (!collectionDefinition)
|
|
57656
57680
|
return { error: MISSING_COLLECTION_DEFINITION };
|
|
57657
|
-
if (!((
|
|
57681
|
+
if (!((_g = dualMatchUp.sides) == null ? void 0 : _g.length)) {
|
|
57658
57682
|
const { extension } = findExtension$2({
|
|
57659
57683
|
element: drawDefinition,
|
|
57660
57684
|
name: LINEUPS
|
|
@@ -57678,10 +57702,10 @@ function assignTieMatchUpParticipantId(params) {
|
|
|
57678
57702
|
const tieMatchUpSide = inContextTieMatchUp.sides.find(
|
|
57679
57703
|
(side) => side.sideNumber === sideNumber
|
|
57680
57704
|
);
|
|
57681
|
-
const lineUp = (dualMatchUpSide == null ? void 0 : dualMatchUpSide.lineUp) || ((
|
|
57705
|
+
const lineUp = (dualMatchUpSide == null ? void 0 : dualMatchUpSide.lineUp) || ((_h = getTeamLineUp({
|
|
57682
57706
|
participantId: teamParticipantId,
|
|
57683
57707
|
drawDefinition
|
|
57684
|
-
})) == null ? void 0 :
|
|
57708
|
+
})) == null ? void 0 : _h.lineUp);
|
|
57685
57709
|
const targetAssignments = lineUp == null ? void 0 : lineUp.filter(
|
|
57686
57710
|
(participantAssignment) => {
|
|
57687
57711
|
var _a2;
|