tods-competition-factory 2.1.3 → 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 +26 -12
- package/dist/tods-competition-factory.development.cjs.js +151 -32
- 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 +6 -6
|
@@ -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 }: {
|
|
@@ -6787,6 +6801,7 @@ type GetParticipantsArgs = {
|
|
|
6787
6801
|
scheduleAnalysis?: ScheduleAnalysis;
|
|
6788
6802
|
policyDefinitions?: PolicyDefinitions;
|
|
6789
6803
|
withPotentialMatchUps?: boolean;
|
|
6804
|
+
returnParticipantMap?: boolean;
|
|
6790
6805
|
contextProfile?: ContextProfile;
|
|
6791
6806
|
tournamentRecord: Tournament;
|
|
6792
6807
|
withRankingProfile?: boolean;
|
|
@@ -6796,6 +6811,7 @@ type GetParticipantsArgs = {
|
|
|
6796
6811
|
withTeamMatchUps?: boolean;
|
|
6797
6812
|
withScaleValues?: boolean;
|
|
6798
6813
|
usePublishState?: boolean;
|
|
6814
|
+
returnMatchUps?: boolean;
|
|
6799
6815
|
withStatistics?: boolean;
|
|
6800
6816
|
withOpponents?: boolean;
|
|
6801
6817
|
withMatchUps?: boolean;
|
|
@@ -6812,6 +6828,7 @@ declare function getParticipants(params: GetParticipantsArgs): {
|
|
|
6812
6828
|
};
|
|
6813
6829
|
participantIdsWithConflicts?: string[];
|
|
6814
6830
|
participants?: HydratedParticipant[];
|
|
6831
|
+
missingParticipantIds?: string[];
|
|
6815
6832
|
participantMap?: ParticipantMap;
|
|
6816
6833
|
derivedEventInfo?: any;
|
|
6817
6834
|
derivedDrawInfo?: any;
|
|
@@ -7373,10 +7390,7 @@ declare function analyzeTournament({ tournamentRecord }: {
|
|
|
7373
7390
|
code: string;
|
|
7374
7391
|
};
|
|
7375
7392
|
} | {
|
|
7376
|
-
analysis:
|
|
7377
|
-
isDual: boolean;
|
|
7378
|
-
drawsAnalysis: any;
|
|
7379
|
-
};
|
|
7393
|
+
analysis: any;
|
|
7380
7394
|
success: boolean;
|
|
7381
7395
|
error?: undefined;
|
|
7382
7396
|
};
|
|
@@ -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) {
|
|
@@ -174,6 +174,10 @@ const DRAW_POSITION_ACTIVE = {
|
|
|
174
174
|
message: 'drawPosition is active',
|
|
175
175
|
code: 'ERR_ACTIVE_DRAW_POSITION',
|
|
176
176
|
};
|
|
177
|
+
const DRAW_POSITION_OCCUPIED = {
|
|
178
|
+
message: 'drawPosition is occupied',
|
|
179
|
+
code: 'ERR_OCCUPIED_DRAW_POSITION',
|
|
180
|
+
};
|
|
177
181
|
const INVALID_DRAW_POSITION = {
|
|
178
182
|
message: 'Invlid drawPosition',
|
|
179
183
|
code: 'ERR_INVALID_DRAW_POSITION',
|
|
@@ -5697,7 +5701,7 @@ function getTimeItem(params) {
|
|
|
5697
5701
|
const bDate = new Date(b.createdAt || undefined).getTime();
|
|
5698
5702
|
return aDate - bDate;
|
|
5699
5703
|
});
|
|
5700
|
-
const timeItem = filteredSorted.pop();
|
|
5704
|
+
const timeItem = makeDeepCopy(filteredSorted.pop(), false, true);
|
|
5701
5705
|
if (timeItem) {
|
|
5702
5706
|
const result = { timeItem, ...SUCCESS };
|
|
5703
5707
|
if (returnPreviousValues)
|
|
@@ -5777,6 +5781,7 @@ const membershipMap = {
|
|
|
5777
5781
|
[TEAM]: 'teams',
|
|
5778
5782
|
};
|
|
5779
5783
|
function getParticipantMap({ withIndividualParticipants, convertExtensions, tournamentRecord, withSignInStatus, withScaleValues, internalUse, withISO2, withIOC, }) {
|
|
5784
|
+
const missingParticipantIds = [];
|
|
5780
5785
|
const participantMap = {};
|
|
5781
5786
|
for (const participant of tournamentRecord.participants ?? []) {
|
|
5782
5787
|
const participantId = participant?.participantId;
|
|
@@ -5785,15 +5790,22 @@ function getParticipantMap({ withIndividualParticipants, convertExtensions, tour
|
|
|
5785
5790
|
for (const participant of tournamentRecord.participants ?? []) {
|
|
5786
5791
|
const participantCopy = makeDeepCopy(participant, convertExtensions, internalUse);
|
|
5787
5792
|
const { participantId, individualParticipantIds, participantType } = participantCopy;
|
|
5793
|
+
if (!participantMap[participantId]) {
|
|
5794
|
+
missingParticipantIds.push(participantId);
|
|
5795
|
+
continue;
|
|
5796
|
+
}
|
|
5788
5797
|
Object.assign(participantMap[participantId].participant, participantCopy);
|
|
5789
5798
|
if (individualParticipantIds) {
|
|
5790
|
-
processIndividualParticipantIds({
|
|
5799
|
+
const result = processIndividualParticipantIds({
|
|
5791
5800
|
individualParticipantIds,
|
|
5792
5801
|
participantCopy,
|
|
5793
5802
|
participantMap,
|
|
5794
5803
|
participantType,
|
|
5795
5804
|
participantId,
|
|
5796
5805
|
});
|
|
5806
|
+
if (result.missingParticipantIds.length) {
|
|
5807
|
+
missingParticipantIds.push(...result.missingParticipantIds);
|
|
5808
|
+
}
|
|
5797
5809
|
}
|
|
5798
5810
|
if (withSignInStatus) {
|
|
5799
5811
|
participantMap[participantId].participant.signedIn = signedIn(participantCopy);
|
|
@@ -5817,7 +5829,7 @@ function getParticipantMap({ withIndividualParticipants, convertExtensions, tour
|
|
|
5817
5829
|
const template = isObject(withIndividualParticipants) ? withIndividualParticipants : undefined;
|
|
5818
5830
|
addIndividualParticipants({ participantMap, template });
|
|
5819
5831
|
}
|
|
5820
|
-
return { participantMap };
|
|
5832
|
+
return { missingParticipantIds, participantMap };
|
|
5821
5833
|
}
|
|
5822
5834
|
function signedIn(participant) {
|
|
5823
5835
|
const { timeItem } = getTimeItem({
|
|
@@ -5827,8 +5839,13 @@ function signedIn(participant) {
|
|
|
5827
5839
|
return timeItem?.itemValue === SIGNED_IN;
|
|
5828
5840
|
}
|
|
5829
5841
|
function processIndividualParticipantIds({ individualParticipantIds, participantCopy, participantMap, participantType, participantId, }) {
|
|
5842
|
+
const missingParticipantIds = [];
|
|
5830
5843
|
for (const individualParticipantId of individualParticipantIds) {
|
|
5831
|
-
const individualParticipant = participantMap[individualParticipantId]
|
|
5844
|
+
const individualParticipant = participantMap[individualParticipantId]?.participant;
|
|
5845
|
+
if (!individualParticipant) {
|
|
5846
|
+
missingParticipantIds.push(individualParticipantId);
|
|
5847
|
+
continue;
|
|
5848
|
+
}
|
|
5832
5849
|
individualParticipant[typeMap[participantType]].push(participantId);
|
|
5833
5850
|
if ([TEAM, GROUP].includes(participantType)) {
|
|
5834
5851
|
const { participantRoleResponsibilities, participantOtherName, participantName, participantId, teamId } = participantCopy;
|
|
@@ -5847,6 +5864,7 @@ function processIndividualParticipantIds({ individualParticipantIds, participant
|
|
|
5847
5864
|
participantMap[individualParticipantId].pairIdMap[partnerParticipantId] = participantId;
|
|
5848
5865
|
}
|
|
5849
5866
|
}
|
|
5867
|
+
return { missingParticipantIds };
|
|
5850
5868
|
}
|
|
5851
5869
|
function initializeParticipantId({ participantMap, participantId }) {
|
|
5852
5870
|
if (participantMap[participantId])
|
|
@@ -12520,7 +12538,7 @@ function getParticipants(params) {
|
|
|
12520
12538
|
if (withMatchUps || withRankingProfile) {
|
|
12521
12539
|
getMatchUpDependencies({ tournamentRecord });
|
|
12522
12540
|
}
|
|
12523
|
-
|
|
12541
|
+
const mapResult = getParticipantMap({
|
|
12524
12542
|
convertExtensions,
|
|
12525
12543
|
tournamentRecord,
|
|
12526
12544
|
withSignInStatus,
|
|
@@ -12529,6 +12547,7 @@ function getParticipants(params) {
|
|
|
12529
12547
|
withISO2,
|
|
12530
12548
|
withIOC,
|
|
12531
12549
|
});
|
|
12550
|
+
let { participantMap } = mapResult;
|
|
12532
12551
|
const entriesResult = getParticipantEntries({
|
|
12533
12552
|
withMatchUps: withMatchUps ?? withRankingProfile,
|
|
12534
12553
|
withEvents: withEvents ?? withRankingProfile,
|
|
@@ -12600,15 +12619,16 @@ function getParticipants(params) {
|
|
|
12600
12619
|
? filteredParticipants.map((source) => attributeFilter({ source, template }))
|
|
12601
12620
|
: filteredParticipants;
|
|
12602
12621
|
return {
|
|
12622
|
+
participantMap: params.returnParticipantMap !== false ? participantMap : undefined,
|
|
12623
|
+
mappedMatchUps: params.returnMatchUps !== false ? mappedMatchUps : undefined,
|
|
12624
|
+
matchUps: params.returnMatchUps !== false ? matchUps : undefined,
|
|
12625
|
+
missingParticipantIds: mapResult.missingParticipantIds,
|
|
12603
12626
|
participantIdsWithConflicts,
|
|
12604
12627
|
eventsPublishStatuses,
|
|
12605
12628
|
derivedEventInfo,
|
|
12606
12629
|
derivedDrawInfo,
|
|
12607
|
-
mappedMatchUps,
|
|
12608
|
-
participantMap,
|
|
12609
12630
|
participants,
|
|
12610
12631
|
...SUCCESS,
|
|
12611
|
-
matchUps,
|
|
12612
12632
|
};
|
|
12613
12633
|
}
|
|
12614
12634
|
|
|
@@ -12887,7 +12907,7 @@ function addDrawEntries$1(params) {
|
|
|
12887
12907
|
}
|
|
12888
12908
|
return notAdded;
|
|
12889
12909
|
}, []);
|
|
12890
|
-
if (duplicateEntries.length && suppressDuplicateEntries) {
|
|
12910
|
+
if (duplicateEntries.length && !suppressDuplicateEntries) {
|
|
12891
12911
|
return decorateResult({
|
|
12892
12912
|
context: { eventId, drawId, duplicateEntries },
|
|
12893
12913
|
result: { error: DUPLICATE_ENTRY },
|
|
@@ -15399,22 +15419,6 @@ function luckyLoserDrawPositionAssignment(params) {
|
|
|
15399
15419
|
return luckyLoserDrawPositionAssignment$1(params);
|
|
15400
15420
|
}
|
|
15401
15421
|
|
|
15402
|
-
function alternateDrawPositionAssignment$1({ alternateParticipantId, tournamentRecord, drawDefinition, drawPosition, structureId, }) {
|
|
15403
|
-
return positionParticipantAction({
|
|
15404
|
-
positionActionName: 'alternateDrawPositionAssignment',
|
|
15405
|
-
participantIdAttributeName: 'alternateParticipantid',
|
|
15406
|
-
participantId: alternateParticipantId,
|
|
15407
|
-
tournamentRecord,
|
|
15408
|
-
drawDefinition,
|
|
15409
|
-
drawPosition,
|
|
15410
|
-
structureId,
|
|
15411
|
-
});
|
|
15412
|
-
}
|
|
15413
|
-
|
|
15414
|
-
function alternateDrawPositionAssignment(params) {
|
|
15415
|
-
return alternateDrawPositionAssignment$1(params);
|
|
15416
|
-
}
|
|
15417
|
-
|
|
15418
15422
|
function modifyMappedMatchUps({ params, modMap, structure }) {
|
|
15419
15423
|
const { tournamentRecord, drawDefinition, event } = params;
|
|
15420
15424
|
for (const matchUp of structure.matchUps) {
|
|
@@ -15600,6 +15604,18 @@ function qualifierDrawPositionAssignment(params) {
|
|
|
15600
15604
|
return qualifierDrawPositionAssignment$1(params);
|
|
15601
15605
|
}
|
|
15602
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
|
+
|
|
15603
15619
|
function modifySeedAssignment({ validation = true, tournamentRecord, drawDefinition, participantId, structureId, seedValue, event, }) {
|
|
15604
15620
|
if (!drawDefinition)
|
|
15605
15621
|
return { error: MISSING_DRAW_DEFINITION };
|
|
@@ -22395,9 +22411,10 @@ function directLoser(params) {
|
|
|
22395
22411
|
return decorateResult({ result, stack });
|
|
22396
22412
|
}
|
|
22397
22413
|
else {
|
|
22414
|
+
const error = !targetDrawPositionIsUnfilled ? DRAW_POSITION_OCCUPIED : INVALID_DRAW_POSITION;
|
|
22398
22415
|
return decorateResult({
|
|
22399
|
-
|
|
22400
|
-
|
|
22416
|
+
context: { loserDrawPosition, loserTargetLink, targetDrawPositionIsUnfilled },
|
|
22417
|
+
result: { error },
|
|
22401
22418
|
stack,
|
|
22402
22419
|
});
|
|
22403
22420
|
}
|
|
@@ -33674,11 +33691,12 @@ function getTournamentInfo(params) {
|
|
|
33674
33691
|
notes,
|
|
33675
33692
|
updatedAt,
|
|
33676
33693
|
}))(tournamentRecord);
|
|
33677
|
-
const
|
|
33694
|
+
const participantResult = getParticipants({
|
|
33678
33695
|
participantFilters: { participantRoles: [ADMINISTRATION, OFFICIAL, MEDIA, MEDICAL, SECURITY] },
|
|
33679
33696
|
policyDefinitions: POLICY_PRIVACY_STAFF,
|
|
33680
33697
|
tournamentRecord,
|
|
33681
|
-
})
|
|
33698
|
+
});
|
|
33699
|
+
const tournamentContacts = participantResult?.participants ?? [];
|
|
33682
33700
|
if (tournamentContacts)
|
|
33683
33701
|
tournamentInfo.tournamentContacts = tournamentContacts;
|
|
33684
33702
|
const publishState = getPublishState({ tournamentRecord })?.publishState;
|
|
@@ -33774,6 +33792,10 @@ function analyzeTournament({ tournamentRecord }) {
|
|
|
33774
33792
|
isDual: checkIsDual(tournamentRecord),
|
|
33775
33793
|
drawsAnalysis,
|
|
33776
33794
|
};
|
|
33795
|
+
const participantResult = getParticipants({ tournamentRecord });
|
|
33796
|
+
if (participantResult.missingParticipantIds?.length) {
|
|
33797
|
+
analysis.missingParticipantIds = participantResult.missingParticipantIds;
|
|
33798
|
+
}
|
|
33777
33799
|
return { ...SUCCESS, analysis };
|
|
33778
33800
|
}
|
|
33779
33801
|
|
|
@@ -40160,6 +40182,94 @@ function generateFlightProfile(params) {
|
|
|
40160
40182
|
}
|
|
40161
40183
|
}
|
|
40162
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
|
+
|
|
40163
40273
|
const ASC = 'ASC';
|
|
40164
40274
|
const ASCENDING = 'ASC';
|
|
40165
40275
|
const DESC = 'DESC';
|
|
@@ -40695,6 +40805,7 @@ var index$b = {
|
|
|
40695
40805
|
generateLineUps: generateLineUps,
|
|
40696
40806
|
generateQualifyingStructure: generateQualifyingStructure,
|
|
40697
40807
|
generateSeedingScaleItems: generateSeedingScaleItems,
|
|
40808
|
+
generateStatCrew: generateStatCrew,
|
|
40698
40809
|
generateVoluntaryConsolation: generateVoluntaryConsolation,
|
|
40699
40810
|
roundRobinGroups: roundRobinGroups
|
|
40700
40811
|
};
|
|
@@ -45002,7 +45113,7 @@ function resetAdHocMatchUps(params) {
|
|
|
45002
45113
|
return { ...SUCCESS };
|
|
45003
45114
|
}
|
|
45004
45115
|
|
|
45005
|
-
function setOrderOfFinish$1({ drawDefinition, finishingOrder }) {
|
|
45116
|
+
function setOrderOfFinish$1({ tournamentRecord, drawDefinition, finishingOrder }) {
|
|
45006
45117
|
if (!drawDefinition)
|
|
45007
45118
|
return { error: MISSING_DRAW_DEFINITION };
|
|
45008
45119
|
const stack = 'setOrderOfFinish';
|
|
@@ -45103,7 +45214,15 @@ function setOrderOfFinish$1({ drawDefinition, finishingOrder }) {
|
|
|
45103
45214
|
});
|
|
45104
45215
|
if (result.error)
|
|
45105
45216
|
return decorateResult({ result, stack });
|
|
45106
|
-
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
|
+
});
|
|
45107
45226
|
}
|
|
45108
45227
|
return { ...SUCCESS };
|
|
45109
45228
|
}
|