@lyxa.ai/marketing 1.0.50 → 1.0.52
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/lib/index.d.ts +47 -22
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/modules/tournament/config/config.router.d.ts +10 -10
- package/dist/lib/modules/tournament/config/config.validation.d.ts +36 -37
- package/dist/lib/modules/tournament/config/config.validation.d.ts.map +1 -1
- package/dist/lib/modules/tournament/config/config.validation.js +3 -4
- package/dist/lib/modules/tournament/config/config.validation.js.map +1 -1
- package/dist/lib/modules/tournament/match/events/evaluate-predictions.consumer.d.ts.map +1 -1
- package/dist/lib/modules/tournament/match/events/evaluate-predictions.consumer.js +6 -3
- package/dist/lib/modules/tournament/match/events/evaluate-predictions.consumer.js.map +1 -1
- package/dist/lib/modules/tournament/match/match.router.d.ts +4 -4
- package/dist/lib/modules/tournament/participant/participant.repository.d.ts +2 -0
- package/dist/lib/modules/tournament/participant/participant.repository.d.ts.map +1 -1
- package/dist/lib/modules/tournament/participant/participant.repository.js +8 -0
- package/dist/lib/modules/tournament/participant/participant.repository.js.map +1 -1
- package/dist/lib/modules/tournament/participant/participant.router.d.ts +27 -4
- package/dist/lib/modules/tournament/participant/participant.router.d.ts.map +1 -1
- package/dist/lib/modules/tournament/participant/participant.router.js +7 -0
- package/dist/lib/modules/tournament/participant/participant.router.js.map +1 -1
- package/dist/lib/modules/tournament/participant/participant.service.d.ts +2 -2
- package/dist/lib/modules/tournament/participant/participant.service.d.ts.map +1 -1
- package/dist/lib/modules/tournament/participant/participant.service.js +20 -6
- package/dist/lib/modules/tournament/participant/participant.service.js.map +1 -1
- package/dist/lib/modules/tournament/participant/participant.validation.d.ts +144 -36
- package/dist/lib/modules/tournament/participant/participant.validation.d.ts.map +1 -1
- package/dist/lib/modules/tournament/participant/participant.validation.js +10 -3
- package/dist/lib/modules/tournament/participant/participant.validation.js.map +1 -1
- package/dist/lib/modules/tournament/prediction/prediction.service.d.ts.map +1 -1
- package/dist/lib/modules/tournament/prediction/prediction.service.js +2 -0
- package/dist/lib/modules/tournament/prediction/prediction.service.js.map +1 -1
- package/dist/lib/modules/tournament/team/team.router.d.ts +4 -4
- package/dist/lib/modules/tournament/team/team.service.d.ts.map +1 -1
- package/dist/lib/modules/tournament/team/team.service.js +2 -0
- package/dist/lib/modules/tournament/team/team.service.js.map +1 -1
- package/dist/lib/modules/tournament/team/team.validation.d.ts +14 -14
- package/dist/lib/modules/tournament/tournament.router.d.ts +164 -138
- package/dist/lib/modules/tournament/tournament.router.d.ts.map +1 -1
- package/dist/lib/modules/tournament/tournament.router.js +7 -2
- package/dist/lib/modules/tournament/tournament.router.js.map +1 -1
- package/dist/lib/modules/tournament/tournament.service.d.ts +3 -1
- package/dist/lib/modules/tournament/tournament.service.d.ts.map +1 -1
- package/dist/lib/modules/tournament/tournament.service.js +17 -2
- package/dist/lib/modules/tournament/tournament.service.js.map +1 -1
- package/dist/lib/modules/tournament/tournament.types.d.ts +5 -3
- package/dist/lib/modules/tournament/tournament.types.d.ts.map +1 -1
- package/dist/lib/modules/tournament/tournament.types.js +7 -5
- package/dist/lib/modules/tournament/tournament.types.js.map +1 -1
- package/dist/lib/modules/tournament/tournament.validation.d.ts +15 -0
- package/dist/lib/modules/tournament/tournament.validation.d.ts.map +1 -1
- package/dist/lib/modules/tournament/tournament.validation.js +4 -1
- package/dist/lib/modules/tournament/tournament.validation.js.map +1 -1
- package/dist/types/index.d.ts +47 -22
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/modules/tournament/config/config.router.d.ts +10 -10
- package/dist/types/modules/tournament/config/config.validation.d.ts +36 -37
- package/dist/types/modules/tournament/config/config.validation.d.ts.map +1 -1
- package/dist/types/modules/tournament/match/events/evaluate-predictions.consumer.d.ts.map +1 -1
- package/dist/types/modules/tournament/match/match.router.d.ts +4 -4
- package/dist/types/modules/tournament/participant/participant.repository.d.ts +2 -0
- package/dist/types/modules/tournament/participant/participant.repository.d.ts.map +1 -1
- package/dist/types/modules/tournament/participant/participant.router.d.ts +27 -4
- package/dist/types/modules/tournament/participant/participant.router.d.ts.map +1 -1
- package/dist/types/modules/tournament/participant/participant.service.d.ts +2 -2
- package/dist/types/modules/tournament/participant/participant.service.d.ts.map +1 -1
- package/dist/types/modules/tournament/participant/participant.validation.d.ts +144 -36
- package/dist/types/modules/tournament/participant/participant.validation.d.ts.map +1 -1
- package/dist/types/modules/tournament/prediction/prediction.service.d.ts.map +1 -1
- package/dist/types/modules/tournament/team/team.router.d.ts +4 -4
- package/dist/types/modules/tournament/team/team.service.d.ts.map +1 -1
- package/dist/types/modules/tournament/team/team.validation.d.ts +14 -14
- package/dist/types/modules/tournament/tournament.router.d.ts +164 -138
- package/dist/types/modules/tournament/tournament.router.d.ts.map +1 -1
- package/dist/types/modules/tournament/tournament.service.d.ts +3 -1
- package/dist/types/modules/tournament/tournament.service.d.ts.map +1 -1
- package/dist/types/modules/tournament/tournament.types.d.ts +5 -3
- package/dist/types/modules/tournament/tournament.types.d.ts.map +1 -1
- package/dist/types/modules/tournament/tournament.validation.d.ts +15 -0
- package/dist/types/modules/tournament/tournament.validation.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -69,6 +69,14 @@ let TournamentParticipantRepository = class TournamentParticipantRepository {
|
|
|
69
69
|
.sort({ createdAt: -1 })
|
|
70
70
|
.lean();
|
|
71
71
|
}
|
|
72
|
+
async updateToJoined(userId, tournamentId, teamId) {
|
|
73
|
+
return this.participantModel
|
|
74
|
+
.findOneAndUpdate({ userId, tournamentId }, { $set: { status: 'joined', teamId } }, { new: true })
|
|
75
|
+
.lean();
|
|
76
|
+
}
|
|
77
|
+
async upsertStatus(userId, tournamentId, status) {
|
|
78
|
+
await this.participantModel.findOneAndUpdate({ userId, tournamentId }, { $setOnInsert: { userId, tournamentId, predictions: [] }, $set: { status } }, { upsert: true });
|
|
79
|
+
}
|
|
72
80
|
};
|
|
73
81
|
exports.TournamentParticipantRepository = TournamentParticipantRepository;
|
|
74
82
|
exports.TournamentParticipantRepository = TournamentParticipantRepository = __decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"participant.repository.js","sourceRoot":"/","sources":["modules/tournament/participant/participant.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA4C;AAE5C,sEAGmD;AAG5C,IAAM,+BAA+B,GAArC,MAAM,+BAA+B;IAChC,gBAAgB,CAAoC;IAE5D;QACI,IAAI,CAAC,gBAAgB,GAAG,mCAA0B,CAAC;IACvD,CAAC;IAED,KAAK,CAAC,yBAAyB,CAC3B,MAA+B,EAC/B,YAAqC;QAErC,OAAO,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC;IAC5E,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,KAAa;QACtB,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACtD,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC;IAC1B,CAAC;IAED,KAAK,CAAC,uBAAuB,CACzB,MAA+B,EAC/B,YAAqC;QAErC,OAAO,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,CAAC,IAAI,EAA0C,CAAC;IAClH,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAC,YAAqC;QACxD,OAAO,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC,IAAI,EAAqC,CAAC;IAClG,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,MAA+B;QAC5C,OAAO,IAAI,CAAC,gBAAgB;aACvB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;aACnB,IAAI,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC;aACvB,IAAI,EAA0C,CAAC;IACxD,CAAC;CACJ,CAAA;
|
|
1
|
+
{"version":3,"file":"participant.repository.js","sourceRoot":"/","sources":["modules/tournament/participant/participant.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA4C;AAE5C,sEAGmD;AAG5C,IAAM,+BAA+B,GAArC,MAAM,+BAA+B;IAChC,gBAAgB,CAAoC;IAE5D;QACI,IAAI,CAAC,gBAAgB,GAAG,mCAA0B,CAAC;IACvD,CAAC;IAED,KAAK,CAAC,yBAAyB,CAC3B,MAA+B,EAC/B,YAAqC;QAErC,OAAO,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC;IAC5E,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,KAAa;QACtB,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACtD,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC;IAC1B,CAAC;IAED,KAAK,CAAC,uBAAuB,CACzB,MAA+B,EAC/B,YAAqC;QAErC,OAAO,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,CAAC,IAAI,EAA0C,CAAC;IAClH,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAC,YAAqC;QACxD,OAAO,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC,IAAI,EAAqC,CAAC;IAClG,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,MAA+B;QAC5C,OAAO,IAAI,CAAC,gBAAgB;aACvB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;aACnB,IAAI,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC;aACvB,IAAI,EAA0C,CAAC;IACxD,CAAC;IAED,KAAK,CAAC,cAAc,CAChB,MAA+B,EAC/B,YAAqC,EACrC,MAA+B;QAE/B,OAAO,IAAI,CAAC,gBAAgB;aACvB,gBAAgB,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC;aACjG,IAAI,EAA0C,CAAC;IACxD,CAAC;IAED,KAAK,CAAC,YAAY,CACd,MAA+B,EAC/B,YAAqC,EACrC,MAAc;QAEd,MAAM,IAAI,CAAC,gBAAgB,CAAC,gBAAgB,CACxC,EAAE,MAAM,EAAE,YAAY,EAAE,EACxB,EAAE,YAAY,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,EAAE,EAC7E,EAAE,MAAM,EAAE,IAAI,EAAE,CACnB,CAAC;IACN,CAAC;CACJ,CAAA;AA1DY,0EAA+B;0CAA/B,+BAA+B;IAD3C,IAAA,gBAAO,GAAE;;GACG,+BAA+B,CA0D3C;AAEY,QAAA,+BAA+B,GAAG,gBAAS,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC","sourcesContent":["import Container, { Service } from 'typedi';\nimport { mongoose } from '@typegoose/typegoose';\nimport {\n TournamentParticipant as ParticipantModelType,\n TournamentParticipantModel,\n} from '@lyxa.ai/core/dist/libraries/mongo/models';\n\n@Service()\nexport class TournamentParticipantRepository {\n private participantModel: typeof TournamentParticipantModel;\n\n constructor() {\n this.participantModel = TournamentParticipantModel;\n }\n\n async existsByUserAndTournament(\n userId: mongoose.Types.ObjectId,\n tournamentId: mongoose.Types.ObjectId\n ): Promise<boolean> {\n return !!(await this.participantModel.exists({ userId, tournamentId }));\n }\n\n async create(input: object): Promise<ParticipantModelType> {\n const doc = await this.participantModel.create(input);\n return doc.toObject();\n }\n\n async findByUserAndTournament(\n userId: mongoose.Types.ObjectId,\n tournamentId: mongoose.Types.ObjectId\n ): Promise<ParticipantModelType | null> {\n return this.participantModel.findOne({ userId, tournamentId }).lean() as Promise<ParticipantModelType | null>;\n }\n\n async findByTournament(tournamentId: mongoose.Types.ObjectId): Promise<ParticipantModelType[]> {\n return this.participantModel.find({ tournamentId }).lean() as Promise<ParticipantModelType[]>;\n }\n\n async findByUser(userId: mongoose.Types.ObjectId): Promise<ParticipantModelType | null> {\n return this.participantModel\n .findOne({ userId })\n .sort({ createdAt: -1 })\n .lean() as Promise<ParticipantModelType | null>;\n }\n\n async updateToJoined(\n userId: mongoose.Types.ObjectId,\n tournamentId: mongoose.Types.ObjectId,\n teamId: mongoose.Types.ObjectId\n ): Promise<ParticipantModelType | null> {\n return this.participantModel\n .findOneAndUpdate({ userId, tournamentId }, { $set: { status: 'joined', teamId } }, { new: true })\n .lean() as Promise<ParticipantModelType | null>;\n }\n\n async upsertStatus(\n userId: mongoose.Types.ObjectId,\n tournamentId: mongoose.Types.ObjectId,\n status: string\n ): Promise<void> {\n await this.participantModel.findOneAndUpdate(\n { userId, tournamentId },\n { $setOnInsert: { userId, tournamentId, predictions: [] }, $set: { status } },\n { upsert: true }\n );\n }\n}\n\nexport const tournamentParticipantRepository = Container.get(TournamentParticipantRepository);"]}
|
|
@@ -24,16 +24,18 @@ export declare const participantRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
24
24
|
message: string;
|
|
25
25
|
success: boolean;
|
|
26
26
|
data?: {
|
|
27
|
+
status: "joined" | "seen";
|
|
27
28
|
_id: string | mongoose.Types.ObjectId;
|
|
28
29
|
tournamentId: string | mongoose.Types.ObjectId;
|
|
29
|
-
teamId: string | mongoose.Types.ObjectId;
|
|
30
30
|
createdAt?: Date | null | undefined;
|
|
31
|
+
teamId?: string | mongoose.Types.ObjectId | undefined;
|
|
31
32
|
} | {
|
|
32
33
|
documents: {
|
|
34
|
+
status: "joined" | "seen";
|
|
33
35
|
_id: string | mongoose.Types.ObjectId;
|
|
34
36
|
tournamentId: string | mongoose.Types.ObjectId;
|
|
35
|
-
teamId: string | mongoose.Types.ObjectId;
|
|
36
37
|
createdAt?: Date | null | undefined;
|
|
38
|
+
teamId?: string | mongoose.Types.ObjectId | undefined;
|
|
37
39
|
}[];
|
|
38
40
|
metadata?: {
|
|
39
41
|
page: number;
|
|
@@ -45,6 +47,25 @@ export declare const participantRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
45
47
|
};
|
|
46
48
|
meta: object;
|
|
47
49
|
}>;
|
|
50
|
+
markSeen: import("@trpc/server").TRPCMutationProcedure<{
|
|
51
|
+
input: {
|
|
52
|
+
tournamentId: string | mongoose.Types.ObjectId;
|
|
53
|
+
};
|
|
54
|
+
output: {
|
|
55
|
+
message: string;
|
|
56
|
+
success: boolean;
|
|
57
|
+
data?: {
|
|
58
|
+
documents: null[];
|
|
59
|
+
metadata?: {
|
|
60
|
+
page: number;
|
|
61
|
+
size: number;
|
|
62
|
+
totalElements: number;
|
|
63
|
+
totalPages: number;
|
|
64
|
+
} | undefined;
|
|
65
|
+
} | null | undefined;
|
|
66
|
+
};
|
|
67
|
+
meta: object;
|
|
68
|
+
}>;
|
|
48
69
|
getAll: import("@trpc/server").TRPCQueryProcedure<{
|
|
49
70
|
input: {
|
|
50
71
|
tournamentId: string | mongoose.Types.ObjectId;
|
|
@@ -53,12 +74,13 @@ export declare const participantRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
53
74
|
message: string;
|
|
54
75
|
success: boolean;
|
|
55
76
|
data?: {
|
|
77
|
+
status: "joined" | "seen";
|
|
56
78
|
_id: string | mongoose.Types.ObjectId;
|
|
57
79
|
userId: string | mongoose.Types.ObjectId;
|
|
58
80
|
tournamentId: string | mongoose.Types.ObjectId;
|
|
59
|
-
teamId: string | mongoose.Types.ObjectId;
|
|
60
81
|
createdAt?: Date | null | undefined;
|
|
61
82
|
updatedAt?: Date | null | undefined;
|
|
83
|
+
teamId?: string | mongoose.Types.ObjectId | undefined;
|
|
62
84
|
predictions?: {
|
|
63
85
|
_id: string | mongoose.Types.ObjectId;
|
|
64
86
|
matchId: string | mongoose.Types.ObjectId;
|
|
@@ -72,12 +94,13 @@ export declare const participantRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
72
94
|
}[] | undefined;
|
|
73
95
|
}[] | {
|
|
74
96
|
documents: {
|
|
97
|
+
status: "joined" | "seen";
|
|
75
98
|
_id: string | mongoose.Types.ObjectId;
|
|
76
99
|
userId: string | mongoose.Types.ObjectId;
|
|
77
100
|
tournamentId: string | mongoose.Types.ObjectId;
|
|
78
|
-
teamId: string | mongoose.Types.ObjectId;
|
|
79
101
|
createdAt?: Date | null | undefined;
|
|
80
102
|
updatedAt?: Date | null | undefined;
|
|
103
|
+
teamId?: string | mongoose.Types.ObjectId | undefined;
|
|
81
104
|
predictions?: {
|
|
82
105
|
_id: string | mongoose.Types.ObjectId;
|
|
83
106
|
matchId: string | mongoose.Types.ObjectId;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"participant.router.d.ts","sourceRoot":"/","sources":["modules/tournament/participant/participant.router.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"participant.router.d.ts","sourceRoot":"/","sources":["modules/tournament/participant/participant.router.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAgBhD,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8B5B,CAAC"}
|
|
@@ -17,6 +17,13 @@ exports.participantRouter = (0, trpc_1.createTRPCRouter)({
|
|
|
17
17
|
const result = await participant_service_1.participantService.join(new typegoose_1.mongoose.Types.ObjectId(ctx.entity?.id), input);
|
|
18
18
|
return (0, response_1.response)('Tournament joined successfully', result);
|
|
19
19
|
})),
|
|
20
|
+
markSeen: (0, auth_2.createAuthenticatedProcedure)({ entityTypes: [auth_1.AuthEntityType.USER] })
|
|
21
|
+
.input(participant_validation_1.MarkSeenTournamentSchema)
|
|
22
|
+
.output(participant_validation_1.MarkSeenTournamentResponseSchema)
|
|
23
|
+
.mutation(async ({ ctx, input }) => error_handler_1.ErrorHandler.wrapAsync(async () => {
|
|
24
|
+
await participant_service_1.participantService.markSeen(new typegoose_1.mongoose.Types.ObjectId(ctx.entity?.id), input);
|
|
25
|
+
return (0, response_1.response)('Tournament marked as seen', null);
|
|
26
|
+
})),
|
|
20
27
|
getAll: (0, auth_2.createAuthenticatedProcedure)({ entityTypes: [auth_1.AuthEntityType.CRM] })
|
|
21
28
|
.input(participant_validation_1.GetTournamentParticipantsSchema)
|
|
22
29
|
.output(participant_validation_1.TournamentParticipantListResponseSchema)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"participant.router.js","sourceRoot":"/","sources":["modules/tournament/participant/participant.router.ts"],"names":[],"mappings":";;;AAAA,oDAAgD;AAChD,4DAAqE;AACrE,4DAAmE;AACnE,6EAAkG;AAClG,8EAA0E;AAC1E,oEAAiE;AACjE,+DAAsE;AACtE,
|
|
1
|
+
{"version":3,"file":"participant.router.js","sourceRoot":"/","sources":["modules/tournament/participant/participant.router.ts"],"names":[],"mappings":";;;AAAA,oDAAgD;AAChD,4DAAqE;AACrE,4DAAmE;AACnE,6EAAkG;AAClG,8EAA0E;AAC1E,oEAAiE;AACjE,+DAAsE;AACtE,qEAOkC;AAErB,QAAA,iBAAiB,GAAG,IAAA,uBAAgB,EAAC;IACjD,IAAI,EAAE,IAAA,mCAA4B,EAAC,EAAE,WAAW,EAAE,CAAC,qBAAc,CAAC,IAAI,CAAC,EAAE,CAAC;SACxE,KAAK,CAAC,6CAAoB,CA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AG,MAAM,wCAAO,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QACxD,OAAO,IAAA,mBAAQ,EAAC,mCAAmC,EAAE,MAAM,CAAC,CAAC;IAC9D,CAAC,CAAC,CACF;CACF,CAAC,CAAC","sourcesContent":["import { mongoose } from '@typegoose/typegoose';\nimport { createTRPCRouter } from '@lyxa.ai/core/dist/libraries/trpc';\nimport { AuthEntityType } from '@lyxa.ai/core/dist/libraries/auth';\nimport { createAuthenticatedProcedure } from '@lyxa.ai/core/dist/libraries/trpc/middlewares/auth';\nimport { ErrorHandler } from '@lyxa.ai/core/dist/utilities/error-handler';\nimport { response } from '@lyxa.ai/core/dist/utilities/response';\nimport { participantService as service } from './participant.service';\nimport {\n\tJoinTournamentSchema,\n\tJoinTournamentResponseSchema,\n\tTournamentParticipantListResponseSchema,\n\tGetTournamentParticipantsSchema,\n\tMarkSeenTournamentSchema,\n\tMarkSeenTournamentResponseSchema,\n} from './participant.validation';\n\nexport const participantRouter = createTRPCRouter({\n\tjoin: createAuthenticatedProcedure({ entityTypes: [AuthEntityType.USER] })\n\t\t.input(JoinTournamentSchema)\n\t\t.output(JoinTournamentResponseSchema)\n\t\t.mutation(async ({ ctx, input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tconst result = await service.join(new mongoose.Types.ObjectId(ctx.entity?.id), input);\n\t\t\t\treturn response('Tournament joined successfully', result);\n\t\t\t})\n\t\t),\n\n\tmarkSeen: createAuthenticatedProcedure({ entityTypes: [AuthEntityType.USER] })\n\t\t.input(MarkSeenTournamentSchema)\n\t\t.output(MarkSeenTournamentResponseSchema)\n\t\t.mutation(async ({ ctx, input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tawait service.markSeen(new mongoose.Types.ObjectId(ctx.entity?.id), input);\n\t\t\t\treturn response('Tournament marked as seen', null);\n\t\t\t})\n\t\t),\n\n\tgetAll: createAuthenticatedProcedure({ entityTypes: [AuthEntityType.CRM] })\n\t\t.input(GetTournamentParticipantsSchema)\n\t\t.output(TournamentParticipantListResponseSchema)\n\t\t.query(async ({ input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tconst result = await service.getAll(input.tournamentId);\n\t\t\t\treturn response('Participants fetched successfully', result);\n\t\t\t})\n\t\t),\n});\n"]}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { mongoose } from '@typegoose/typegoose';
|
|
2
|
-
import { JoinTournamentInputDTO, TournamentParticipantOutputDTO } from './participant.validation';
|
|
2
|
+
import { JoinTournamentInputDTO, MarkSeenTournamentInputDTO, TournamentParticipantOutputDTO } from './participant.validation';
|
|
3
3
|
export declare class ParticipantService {
|
|
4
4
|
private repository;
|
|
5
5
|
private matchRepository;
|
|
6
6
|
constructor();
|
|
7
7
|
private ensureTeamExists;
|
|
8
|
-
private ensureNotAlreadyJoined;
|
|
9
8
|
join(userId: mongoose.Types.ObjectId, input: JoinTournamentInputDTO): Promise<TournamentParticipantOutputDTO>;
|
|
9
|
+
markSeen(userId: mongoose.Types.ObjectId, input: MarkSeenTournamentInputDTO): Promise<void>;
|
|
10
10
|
getByUserAndTournament(userId: mongoose.Types.ObjectId, tournamentId: mongoose.Types.ObjectId): Promise<TournamentParticipantOutputDTO>;
|
|
11
11
|
getAll(tournamentId: mongoose.Types.ObjectId): Promise<TournamentParticipantOutputDTO[]>;
|
|
12
12
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"participant.service.d.ts","sourceRoot":"/","sources":["modules/tournament/participant/participant.service.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"participant.service.d.ts","sourceRoot":"/","sources":["modules/tournament/participant/participant.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAG9C,OAAO,EACH,sBAAsB,EACtB,0BAA0B,EAC1B,8BAA8B,EACjC,MAAM,0BAA0B,CAAC;AAKlC,qBACa,kBAAkB;IAC3B,OAAO,CAAC,UAAU,CAAkC;IACpD,OAAO,CAAC,eAAe,CAA4B;;IAOnD,OAAO,CAAC,gBAAgB;IAKX,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAAC,8BAA8B,CAAC;IA2B7G,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,EAAE,0BAA0B,GAAG,OAAO,CAAC,IAAI,CAAC;IAU3F,sBAAsB,CAC/B,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAC/B,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GACtC,OAAO,CAAC,8BAA8B,CAAC;IAM7B,MAAM,CAAC,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,8BAA8B,EAAE,CAAC;CAKxG;AAED,eAAO,MAAM,kBAAkB,oBAAoC,CAAC"}
|
|
@@ -48,6 +48,7 @@ const server_1 = require("@trpc/server");
|
|
|
48
48
|
const error_common_1 = require("@lyxa.ai/core/dist/utilities/error-common");
|
|
49
49
|
const participant_repository_1 = require("./participant.repository");
|
|
50
50
|
const match_repository_1 = require("../match/match.repository");
|
|
51
|
+
const tournament_types_1 = require("../tournament.types");
|
|
51
52
|
let ParticipantService = class ParticipantService {
|
|
52
53
|
repository;
|
|
53
54
|
matchRepository;
|
|
@@ -60,27 +61,40 @@ let ParticipantService = class ParticipantService {
|
|
|
60
61
|
if (!exists)
|
|
61
62
|
throw (0, error_common_1.badRequestError)('Selected team does not exist in this tournament');
|
|
62
63
|
}
|
|
63
|
-
async ensureNotAlreadyJoined(userId, tournamentId) {
|
|
64
|
-
if (await this.repository.existsByUserAndTournament(userId, tournamentId)) {
|
|
65
|
-
throw (0, error_common_1.conflictError)('You have already joined this tournament');
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
64
|
async join(userId, input) {
|
|
69
65
|
const tournament = await this.matchRepository.findById(input.tournamentId);
|
|
70
66
|
if (!tournament)
|
|
71
67
|
throw (0, error_common_1.notFoundError)('Tournament not found');
|
|
72
68
|
this.ensureTeamExists(tournament, input.teamId);
|
|
73
|
-
await this.
|
|
69
|
+
const existing = await this.repository.findByUserAndTournament(userId, input.tournamentId);
|
|
70
|
+
if (existing?.status === tournament_types_1.TournamentParticipantStatus.JOINED)
|
|
71
|
+
throw (0, error_common_1.conflictError)('You have already joined this tournament');
|
|
72
|
+
if (existing) {
|
|
73
|
+
const updated = await this.repository.updateToJoined(userId, input.tournamentId, input.teamId);
|
|
74
|
+
if (!updated)
|
|
75
|
+
throw new server_1.TRPCError({ code: 'INTERNAL_SERVER_ERROR', message: 'Failed to join tournament' });
|
|
76
|
+
return updated;
|
|
77
|
+
}
|
|
74
78
|
const result = await this.repository.create({
|
|
75
79
|
userId,
|
|
76
80
|
tournamentId: input.tournamentId,
|
|
77
81
|
teamId: input.teamId,
|
|
82
|
+
status: tournament_types_1.TournamentParticipantStatus.JOINED,
|
|
78
83
|
predictions: [],
|
|
79
84
|
});
|
|
80
85
|
if (!result)
|
|
81
86
|
throw new server_1.TRPCError({ code: 'INTERNAL_SERVER_ERROR', message: 'Failed to join tournament' });
|
|
82
87
|
return result;
|
|
83
88
|
}
|
|
89
|
+
async markSeen(userId, input) {
|
|
90
|
+
const tournament = await this.matchRepository.findById(input.tournamentId);
|
|
91
|
+
if (!tournament)
|
|
92
|
+
throw (0, error_common_1.notFoundError)('Tournament not found');
|
|
93
|
+
const existing = await this.repository.findByUserAndTournament(userId, input.tournamentId);
|
|
94
|
+
if (existing)
|
|
95
|
+
return;
|
|
96
|
+
await this.repository.upsertStatus(userId, input.tournamentId, tournament_types_1.TournamentParticipantStatus.SEEN);
|
|
97
|
+
}
|
|
84
98
|
async getByUserAndTournament(userId, tournamentId) {
|
|
85
99
|
const participant = await this.repository.findByUserAndTournament(userId, tournamentId);
|
|
86
100
|
if (!participant)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"participant.service.js","sourceRoot":"/","sources":["modules/tournament/participant/participant.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"participant.service.js","sourceRoot":"/","sources":["modules/tournament/participant/participant.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA0C;AAC1C,yCAAuC;AAEvC,4EAAwG;AACxG,qEAAyE;AAMzE,gEAAoE;AAEpE,0DAAgE;AAGzD,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IACnB,UAAU,CAAkC;IAC5C,eAAe,CAA4B;IAEnD;QACI,IAAI,CAAC,UAAU,GAAG,gBAAS,CAAC,GAAG,CAAC,wDAA+B,CAAC,CAAC;QACjE,IAAI,CAAC,eAAe,GAAG,gBAAS,CAAC,GAAG,CAAC,4CAAyB,CAAC,CAAC;IACpE,CAAC;IAEO,gBAAgB,CAAC,UAA0B,EAAE,MAA+B;QAChF,MAAM,MAAM,GAAG,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;QACxF,IAAI,CAAC,MAAM;YAAE,MAAM,IAAA,8BAAe,EAAC,iDAAiD,CAAC,CAAC;IAC1F,CAAC;IAEM,KAAK,CAAC,IAAI,CAAC,MAA+B,EAAE,KAA6B;QAC5E,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QAC3E,IAAI,CAAC,UAAU;YAAE,MAAM,IAAA,4BAAa,EAAC,sBAAsB,CAAC,CAAC;QAE7D,IAAI,CAAC,gBAAgB,CAAC,UAAU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AAG,MAAM,IAAI,CAAC,UAAU,CAAC,uBAAuB,CAAC,MAAM,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC;QAC3F,IAAI,QAAQ;YAAE,OAAO;QAErB,MAAM,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC,YAAY,EAAE,8CAA2B,CAAC,IAAI,CAAC,CAAC;IACrG,CAAC;IAEM,KAAK,CAAC,sBAAsB,CAC/B,MAA+B,EAC/B,YAAqC;QAErC,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,uBAAuB,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;QACxF,IAAI,CAAC,WAAW;YAAE,MAAM,IAAA,4BAAa,EAAC,qCAAqC,CAAC,CAAC;QAC7E,OAAO,WAA6C,CAAC;IACzD,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,YAAqC;QACrD,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;QACrE,IAAI,CAAC,UAAU;YAAE,MAAM,IAAA,4BAAa,EAAC,sBAAsB,CAAC,CAAC;QAC7D,OAAO,IAAI,CAAC,UAAU,CAAC,gBAAgB,CAAC,YAAY,CAA8C,CAAC;IACvG,CAAC;CACJ,CAAA;AAjEY,gDAAkB;6BAAlB,kBAAkB;IAD9B,IAAA,gBAAO,GAAE;;GACG,kBAAkB,CAiE9B;AAEY,QAAA,kBAAkB,GAAG,gBAAS,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC","sourcesContent":["import Container, {Service} from 'typedi';\nimport {TRPCError} from '@trpc/server';\nimport {mongoose} from '@typegoose/typegoose';\nimport {badRequestError, conflictError, notFoundError} from '@lyxa.ai/core/dist/utilities/error-common';\nimport {TournamentParticipantRepository} from './participant.repository';\nimport {\n JoinTournamentInputDTO,\n MarkSeenTournamentInputDTO,\n TournamentParticipantOutputDTO,\n} from './participant.validation';\nimport {TournamentMatchRepository} from '../match/match.repository';\nimport {Tournament as TournamentType} from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport {TournamentParticipantStatus} from '../tournament.types';\n\n@Service()\nexport class ParticipantService {\n private repository: TournamentParticipantRepository;\n private matchRepository: TournamentMatchRepository;\n\n constructor() {\n this.repository = Container.get(TournamentParticipantRepository);\n this.matchRepository = Container.get(TournamentMatchRepository);\n }\n\n private ensureTeamExists(tournament: TournamentType, teamId: mongoose.Types.ObjectId) {\n const exists = tournament.teams.some(team => team._id.toString() === teamId.toString());\n if (!exists) throw badRequestError('Selected team does not exist in this tournament');\n }\n\n public async join(userId: mongoose.Types.ObjectId, input: JoinTournamentInputDTO): Promise<TournamentParticipantOutputDTO> {\n const tournament = await this.matchRepository.findById(input.tournamentId);\n if (!tournament) throw notFoundError('Tournament not found');\n\n this.ensureTeamExists(tournament, input.teamId);\n\n const existing = await this.repository.findByUserAndTournament(userId, input.tournamentId);\n if ((existing?.status as string) === TournamentParticipantStatus.JOINED) throw conflictError('You have already joined this tournament');\n\n if (existing) {\n const updated = await this.repository.updateToJoined(userId, input.tournamentId, input.teamId);\n if (!updated) throw new TRPCError({code: 'INTERNAL_SERVER_ERROR', message: 'Failed to join tournament'});\n return updated as TournamentParticipantOutputDTO;\n }\n\n const result = await this.repository.create({\n userId,\n tournamentId: input.tournamentId,\n teamId: input.teamId,\n status: TournamentParticipantStatus.JOINED,\n predictions: [],\n });\n if (!result) throw new TRPCError({ code: 'INTERNAL_SERVER_ERROR', message: 'Failed to join tournament' });\n\n return result as TournamentParticipantOutputDTO;\n }\n\n public async markSeen(userId: mongoose.Types.ObjectId, input: MarkSeenTournamentInputDTO): Promise<void> {\n const tournament = await this.matchRepository.findById(input.tournamentId);\n if (!tournament) throw notFoundError('Tournament not found');\n\n const existing = await this.repository.findByUserAndTournament(userId, input.tournamentId);\n if (existing) return;\n\n await this.repository.upsertStatus(userId, input.tournamentId, TournamentParticipantStatus.SEEN);\n }\n\n public async getByUserAndTournament(\n userId: mongoose.Types.ObjectId,\n tournamentId: mongoose.Types.ObjectId\n ): Promise<TournamentParticipantOutputDTO> {\n const participant = await this.repository.findByUserAndTournament(userId, tournamentId);\n if (!participant) throw notFoundError('You have not joined this tournament');\n return participant as TournamentParticipantOutputDTO;\n }\n\n public async getAll(tournamentId: mongoose.Types.ObjectId): Promise<TournamentParticipantOutputDTO[]> {\n const tournament = await this.matchRepository.findById(tournamentId);\n if (!tournament) throw notFoundError('Tournament not found');\n return this.repository.findByTournament(tournamentId) as Promise<TournamentParticipantOutputDTO[]>;\n }\n}\n\nexport const participantService = Container.get(ParticipantService);\n"]}
|