tods-competition-factory 2.1.4 → 2.1.5
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 +8 -5
- package/dist/tods-competition-factory.d.ts +22 -8
- package/dist/tods-competition-factory.development.cjs.js +117 -20
- 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 +3 -3
|
@@ -2679,13 +2679,6 @@ declare function luckyLoserDrawPositionAssignment(params: any): ResultType | {
|
|
|
2679
2679
|
};
|
|
2680
2680
|
};
|
|
2681
2681
|
|
|
2682
|
-
declare function alternateDrawPositionAssignment(params: any): ResultType | {
|
|
2683
|
-
error: {
|
|
2684
|
-
message: string;
|
|
2685
|
-
code: string;
|
|
2686
|
-
};
|
|
2687
|
-
};
|
|
2688
|
-
|
|
2689
2682
|
type ShiftRoundsArgs = {
|
|
2690
2683
|
drawDefinition: DrawDefinition;
|
|
2691
2684
|
targetRoundNumber: number;
|
|
@@ -2718,6 +2711,19 @@ declare function qualifierDrawPositionAssignment(params: any): ResultType | {
|
|
|
2718
2711
|
};
|
|
2719
2712
|
};
|
|
2720
2713
|
|
|
2714
|
+
declare function alternateDrawPositionAssignment({ alternateParticipantId, tournamentRecord, drawDefinition, drawPosition, structureId, }: {
|
|
2715
|
+
alternateParticipantId: any;
|
|
2716
|
+
tournamentRecord: any;
|
|
2717
|
+
drawDefinition: any;
|
|
2718
|
+
drawPosition: any;
|
|
2719
|
+
structureId: any;
|
|
2720
|
+
}): ResultType | {
|
|
2721
|
+
error: {
|
|
2722
|
+
message: string;
|
|
2723
|
+
code: string;
|
|
2724
|
+
};
|
|
2725
|
+
};
|
|
2726
|
+
|
|
2721
2727
|
declare function removeDrawPositionAssignment(params: any): ResultType & {
|
|
2722
2728
|
participantId?: string;
|
|
2723
2729
|
};
|
|
@@ -4951,6 +4957,13 @@ declare function generateFlightProfile(params: GenerateFlightProfileArgs): {
|
|
|
4951
4957
|
error?: ErrorType;
|
|
4952
4958
|
};
|
|
4953
4959
|
|
|
4960
|
+
declare function generateStatCrew(params: any): (ResultType & {
|
|
4961
|
+
valid?: boolean | undefined;
|
|
4962
|
+
}) | {
|
|
4963
|
+
success: boolean;
|
|
4964
|
+
xml: any;
|
|
4965
|
+
};
|
|
4966
|
+
|
|
4954
4967
|
type GenerateLineUpsArgs = {
|
|
4955
4968
|
useDefaultEventRanking?: boolean;
|
|
4956
4969
|
tournamentRecord: Tournament;
|
|
@@ -5048,10 +5061,11 @@ declare const index$g_generateFlightProfile: typeof generateFlightProfile;
|
|
|
5048
5061
|
declare const index$g_generateLineUps: typeof generateLineUps;
|
|
5049
5062
|
declare const index$g_generateQualifyingStructure: typeof generateQualifyingStructure;
|
|
5050
5063
|
declare const index$g_generateSeedingScaleItems: typeof generateSeedingScaleItems;
|
|
5064
|
+
declare const index$g_generateStatCrew: typeof generateStatCrew;
|
|
5051
5065
|
declare const index$g_generateVoluntaryConsolation: typeof generateVoluntaryConsolation;
|
|
5052
5066
|
declare const index$g_roundRobinGroups: typeof roundRobinGroups;
|
|
5053
5067
|
declare namespace index$g {
|
|
5054
|
-
export { index$g_drawMatic as drawMatic, garman$1 as garman, index$g_generateAdHocMatchUps as generateAdHocMatchUps, index$g_generateAdHocRounds as generateAdHocRounds, index$g_generateAndPopulatePlayoffStructures as generateAndPopulatePlayoffStructures, index$g_generateCourts as generateCourts, index$g_generateDrawDefinition as generateDrawDefinition, index$g_generateDrawMaticRound as generateDrawMaticRound, index$g_generateDrawStructuresAndLinks as generateDrawStructuresAndLinks, index$g_generateDrawTypeAndModifyDrawDefinition as generateDrawTypeAndModifyDrawDefinition, index$g_generateFlightProfile as generateFlightProfile, index$g_generateLineUps as generateLineUps, index$g_generateQualifyingStructure as generateQualifyingStructure, index$g_generateSeedingScaleItems as generateSeedingScaleItems, index$g_generateVoluntaryConsolation as generateVoluntaryConsolation, index$g_roundRobinGroups as roundRobinGroups };
|
|
5068
|
+
export { index$g_drawMatic as drawMatic, garman$1 as garman, index$g_generateAdHocMatchUps as generateAdHocMatchUps, index$g_generateAdHocRounds as generateAdHocRounds, index$g_generateAndPopulatePlayoffStructures as generateAndPopulatePlayoffStructures, index$g_generateCourts as generateCourts, index$g_generateDrawDefinition as generateDrawDefinition, index$g_generateDrawMaticRound as generateDrawMaticRound, index$g_generateDrawStructuresAndLinks as generateDrawStructuresAndLinks, index$g_generateDrawTypeAndModifyDrawDefinition as generateDrawTypeAndModifyDrawDefinition, index$g_generateFlightProfile as generateFlightProfile, index$g_generateLineUps as generateLineUps, index$g_generateQualifyingStructure as generateQualifyingStructure, index$g_generateSeedingScaleItems as generateSeedingScaleItems, index$g_generateStatCrew as generateStatCrew, index$g_generateVoluntaryConsolation as generateVoluntaryConsolation, index$g_roundRobinGroups as roundRobinGroups };
|
|
5055
5069
|
}
|
|
5056
5070
|
|
|
5057
5071
|
declare function isValidMatchUpFormat({ matchUpFormat }: {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
function factoryVersion() {
|
|
6
|
-
return '2.1.
|
|
6
|
+
return '2.1.5';
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
function isFunction(obj) {
|
|
@@ -5790,6 +5790,10 @@ function getParticipantMap({ withIndividualParticipants, convertExtensions, tour
|
|
|
5790
5790
|
for (const participant of tournamentRecord.participants ?? []) {
|
|
5791
5791
|
const participantCopy = makeDeepCopy(participant, convertExtensions, internalUse);
|
|
5792
5792
|
const { participantId, individualParticipantIds, participantType } = participantCopy;
|
|
5793
|
+
if (!participantMap[participantId]) {
|
|
5794
|
+
missingParticipantIds.push(participantId);
|
|
5795
|
+
continue;
|
|
5796
|
+
}
|
|
5793
5797
|
Object.assign(participantMap[participantId].participant, participantCopy);
|
|
5794
5798
|
if (individualParticipantIds) {
|
|
5795
5799
|
const result = processIndividualParticipantIds({
|
|
@@ -12903,7 +12907,7 @@ function addDrawEntries$1(params) {
|
|
|
12903
12907
|
}
|
|
12904
12908
|
return notAdded;
|
|
12905
12909
|
}, []);
|
|
12906
|
-
if (duplicateEntries.length && suppressDuplicateEntries) {
|
|
12910
|
+
if (duplicateEntries.length && !suppressDuplicateEntries) {
|
|
12907
12911
|
return decorateResult({
|
|
12908
12912
|
context: { eventId, drawId, duplicateEntries },
|
|
12909
12913
|
result: { error: DUPLICATE_ENTRY },
|
|
@@ -15415,22 +15419,6 @@ function luckyLoserDrawPositionAssignment(params) {
|
|
|
15415
15419
|
return luckyLoserDrawPositionAssignment$1(params);
|
|
15416
15420
|
}
|
|
15417
15421
|
|
|
15418
|
-
function alternateDrawPositionAssignment$1({ alternateParticipantId, tournamentRecord, drawDefinition, drawPosition, structureId, }) {
|
|
15419
|
-
return positionParticipantAction({
|
|
15420
|
-
positionActionName: 'alternateDrawPositionAssignment',
|
|
15421
|
-
participantIdAttributeName: 'alternateParticipantid',
|
|
15422
|
-
participantId: alternateParticipantId,
|
|
15423
|
-
tournamentRecord,
|
|
15424
|
-
drawDefinition,
|
|
15425
|
-
drawPosition,
|
|
15426
|
-
structureId,
|
|
15427
|
-
});
|
|
15428
|
-
}
|
|
15429
|
-
|
|
15430
|
-
function alternateDrawPositionAssignment(params) {
|
|
15431
|
-
return alternateDrawPositionAssignment$1(params);
|
|
15432
|
-
}
|
|
15433
|
-
|
|
15434
15422
|
function modifyMappedMatchUps({ params, modMap, structure }) {
|
|
15435
15423
|
const { tournamentRecord, drawDefinition, event } = params;
|
|
15436
15424
|
for (const matchUp of structure.matchUps) {
|
|
@@ -15616,6 +15604,18 @@ function qualifierDrawPositionAssignment(params) {
|
|
|
15616
15604
|
return qualifierDrawPositionAssignment$1(params);
|
|
15617
15605
|
}
|
|
15618
15606
|
|
|
15607
|
+
function alternateDrawPositionAssignment({ alternateParticipantId, tournamentRecord, drawDefinition, drawPosition, structureId, }) {
|
|
15608
|
+
return positionParticipantAction({
|
|
15609
|
+
positionActionName: 'alternateDrawPositionAssignment',
|
|
15610
|
+
participantIdAttributeName: 'alternateParticipantid',
|
|
15611
|
+
participantId: alternateParticipantId,
|
|
15612
|
+
tournamentRecord,
|
|
15613
|
+
drawDefinition,
|
|
15614
|
+
drawPosition,
|
|
15615
|
+
structureId,
|
|
15616
|
+
});
|
|
15617
|
+
}
|
|
15618
|
+
|
|
15619
15619
|
function modifySeedAssignment({ validation = true, tournamentRecord, drawDefinition, participantId, structureId, seedValue, event, }) {
|
|
15620
15620
|
if (!drawDefinition)
|
|
15621
15621
|
return { error: MISSING_DRAW_DEFINITION };
|
|
@@ -40182,6 +40182,94 @@ function generateFlightProfile(params) {
|
|
|
40182
40182
|
}
|
|
40183
40183
|
}
|
|
40184
40184
|
|
|
40185
|
+
function jsonToXml({ json, tagName }) {
|
|
40186
|
+
const childArrays = Object.keys(json)
|
|
40187
|
+
.filter((key) => Array.isArray(json[key]))
|
|
40188
|
+
.map((key) => ({ key, value: json[key].filter((v) => typeof v === 'object' && Object.keys(v).length === 1) }));
|
|
40189
|
+
const childObjects = Object.keys(json)
|
|
40190
|
+
.filter((key) => typeof json[key] === 'object' && !Array.isArray(json[key]))
|
|
40191
|
+
.map((key) => ({ key, value: json[key] }));
|
|
40192
|
+
const attributes = Object.keys(json)
|
|
40193
|
+
.filter((key) => ['string', 'number'].includes(typeof json[key]))
|
|
40194
|
+
.map((key) => ({ key, value: json[key] }));
|
|
40195
|
+
return generateTag({ tagName, attributes, childArrays, childObjects });
|
|
40196
|
+
}
|
|
40197
|
+
function generateTag(params) {
|
|
40198
|
+
const { tagName, attributes = [], childArrays = [], childObjects } = params;
|
|
40199
|
+
const carriageReturn = '\r\n';
|
|
40200
|
+
const arrayChild = (v) => {
|
|
40201
|
+
const key = Object.keys(v)[0];
|
|
40202
|
+
const value = v[key];
|
|
40203
|
+
return { key, value };
|
|
40204
|
+
};
|
|
40205
|
+
const arrayValues = childArrays
|
|
40206
|
+
?.map(({ key, value }) => generateTag({ tagName: key, childObjects: value.map(arrayChild) }))
|
|
40207
|
+
.join('\r\n');
|
|
40208
|
+
const childValues = childObjects
|
|
40209
|
+
?.map(({ key, value }) => jsonToXml({ tagName: key, json: value ?? [] }))
|
|
40210
|
+
.join('\r\n');
|
|
40211
|
+
const attributeString = attributes?.map(({ key, value }) => `${key}="${value}"`).join(' ');
|
|
40212
|
+
const attributeValue = attributeString ? ` ${attributeString}` : '';
|
|
40213
|
+
if (tagName === 'childArray')
|
|
40214
|
+
return childValues;
|
|
40215
|
+
const objectsTag = childValues?.length ? `${carriageReturn}${childValues}${carriageReturn}` : '';
|
|
40216
|
+
const arraysTag = arrayValues?.length ? `${carriageReturn}${arrayValues}${carriageReturn}` : '';
|
|
40217
|
+
return `<${tagName}${attributeValue}>${objectsTag}${arraysTag}</${tagName}>`;
|
|
40218
|
+
}
|
|
40219
|
+
|
|
40220
|
+
function generateStatCrew(params) {
|
|
40221
|
+
const paramsCheck = checkRequiredParameters(params, [{ [TOURNAMENT_RECORD]: true }]);
|
|
40222
|
+
if (paramsCheck.error)
|
|
40223
|
+
return paramsCheck;
|
|
40224
|
+
const { tournamentRecord } = params;
|
|
40225
|
+
const { startDate, tournamentId } = tournamentRecord;
|
|
40226
|
+
const teamParticipants = tournamentRecord.participants.filter((participant) => participant.participantType === TEAM);
|
|
40227
|
+
const homeTeam = teamParticipants?.find((team) => team.participantRoleResponsibilities?.includes('Home'));
|
|
40228
|
+
const awayTeams = teamParticipants?.filter((team) => team.participantId !== homeTeam?.participantId);
|
|
40229
|
+
const date = formatDate(startDate, '/', 'MDY');
|
|
40230
|
+
const neutralGame = !homeTeam ? 'Y' : 'N';
|
|
40231
|
+
const homename = homeTeam?.participantName || awayTeams?.[1]?.participantName;
|
|
40232
|
+
const homeid = homeTeam?.participantId || awayTeams?.[1]?.participantId;
|
|
40233
|
+
const visname = awayTeams?.[0]?.participantName;
|
|
40234
|
+
const visid = awayTeams?.[0]?.participantId;
|
|
40235
|
+
const matchUps = allTournamentMatchUps({ tournamentRecord }).matchUps;
|
|
40236
|
+
const singles = matchUps?.filter((matchUp) => matchUp.matchUpType === SINGLES);
|
|
40237
|
+
const doubles = matchUps?.filter((matchUp) => matchUp.matchUpType === DOUBLES);
|
|
40238
|
+
const getScoreAttributes = ({ sets, sideNumber }) => Object.assign({}, ...(sets?.map((set) => {
|
|
40239
|
+
const { setNumber, side1Score, side2Score, side1TiebreakScore, side2TiebreakScore } = set;
|
|
40240
|
+
const setKey = `set_${setNumber}`;
|
|
40241
|
+
const tbKey = `tie_${setNumber}`;
|
|
40242
|
+
const setValue = sideNumber === 1 ? side1Score : side2Score;
|
|
40243
|
+
const tieValue = sideNumber === 1 ? side1TiebreakScore : side2TiebreakScore;
|
|
40244
|
+
return { [setKey]: setValue, [tbKey]: tieValue };
|
|
40245
|
+
}) ?? []));
|
|
40246
|
+
const getParticipantAttibutes = ({ matchUpId, participant }) => {
|
|
40247
|
+
const name = !participant.individualParticipants ? participant.participantName : undefined;
|
|
40248
|
+
const name_1 = participant.individualParticipants?.[0]?.participantName;
|
|
40249
|
+
const name_2 = participant.individualParticipants?.[1]?.participantName;
|
|
40250
|
+
const vh = matchUpId === homeid ? 'H' : 'V';
|
|
40251
|
+
return definedAttributes({ vh, name, name_1, name_2 });
|
|
40252
|
+
};
|
|
40253
|
+
const mapMatchUp = (matchUp) => {
|
|
40254
|
+
const { collectionPosition: match, orderOfFinish: order, matchUpId, matchUpType, sides } = matchUp;
|
|
40255
|
+
const childArray = sides?.map((side) => {
|
|
40256
|
+
const { sideNumber, participant } = side;
|
|
40257
|
+
const scoreAttributes = getScoreAttributes({ sets: matchUp.score?.sets, sideNumber });
|
|
40258
|
+
const scoreType = matchUpType === SINGLES ? 'singles_score' : 'doubles_score';
|
|
40259
|
+
return { [scoreType]: { ...getParticipantAttibutes({ matchUpId, participant }), ...scoreAttributes } };
|
|
40260
|
+
});
|
|
40261
|
+
const matchType = matchUpType === SINGLES ? 'singles_match' : 'doubles_match';
|
|
40262
|
+
return { [matchType]: { match, order, childArray } };
|
|
40263
|
+
};
|
|
40264
|
+
const json = {
|
|
40265
|
+
venue: { gameid: tournamentId, date, neutralGame, homeid, homename, visid, visname, officials: {}, rules: {} },
|
|
40266
|
+
singles_matches: singles?.map(mapMatchUp),
|
|
40267
|
+
doubles_matches: doubles?.map(mapMatchUp),
|
|
40268
|
+
};
|
|
40269
|
+
const xml = jsonToXml({ json, tagName: 'tngame' });
|
|
40270
|
+
return { xml, ...SUCCESS };
|
|
40271
|
+
}
|
|
40272
|
+
|
|
40185
40273
|
const ASC = 'ASC';
|
|
40186
40274
|
const ASCENDING = 'ASC';
|
|
40187
40275
|
const DESC = 'DESC';
|
|
@@ -40717,6 +40805,7 @@ var index$b = {
|
|
|
40717
40805
|
generateLineUps: generateLineUps,
|
|
40718
40806
|
generateQualifyingStructure: generateQualifyingStructure,
|
|
40719
40807
|
generateSeedingScaleItems: generateSeedingScaleItems,
|
|
40808
|
+
generateStatCrew: generateStatCrew,
|
|
40720
40809
|
generateVoluntaryConsolation: generateVoluntaryConsolation,
|
|
40721
40810
|
roundRobinGroups: roundRobinGroups
|
|
40722
40811
|
};
|
|
@@ -45024,7 +45113,7 @@ function resetAdHocMatchUps(params) {
|
|
|
45024
45113
|
return { ...SUCCESS };
|
|
45025
45114
|
}
|
|
45026
45115
|
|
|
45027
|
-
function setOrderOfFinish$1({ drawDefinition, finishingOrder }) {
|
|
45116
|
+
function setOrderOfFinish$1({ tournamentRecord, drawDefinition, finishingOrder }) {
|
|
45028
45117
|
if (!drawDefinition)
|
|
45029
45118
|
return { error: MISSING_DRAW_DEFINITION };
|
|
45030
45119
|
const stack = 'setOrderOfFinish';
|
|
@@ -45125,7 +45214,15 @@ function setOrderOfFinish$1({ drawDefinition, finishingOrder }) {
|
|
|
45125
45214
|
});
|
|
45126
45215
|
if (result.error)
|
|
45127
45216
|
return decorateResult({ result, stack });
|
|
45128
|
-
result.completedMatchUps?.forEach((matchUp) =>
|
|
45217
|
+
result.completedMatchUps?.forEach((matchUp) => {
|
|
45218
|
+
matchUp.orderOfFinish = valuesMap[matchUp.matchUpId];
|
|
45219
|
+
modifyMatchUpNotice({
|
|
45220
|
+
tournamentId: tournamentRecord.tournamentId,
|
|
45221
|
+
context: 'setOrderOfFinish',
|
|
45222
|
+
drawDefinition,
|
|
45223
|
+
matchUp,
|
|
45224
|
+
});
|
|
45225
|
+
});
|
|
45129
45226
|
}
|
|
45130
45227
|
return { ...SUCCESS };
|
|
45131
45228
|
}
|