ballrush-core 0.12.0 → 0.13.0
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/domain/event-template.d.ts +7 -2
- package/dist/domain/event-template.js +7 -2
- package/dist/domain/event.d.ts +6 -1
- package/dist/domain/event.js +12 -2
- package/dist/mongo/schemas/event-template.schema.d.ts +2 -1
- package/dist/mongo/schemas/event-template.schema.js +2 -0
- package/dist/mongo/schemas/event.schema.d.ts +2 -1
- package/dist/mongo/schemas/event.schema.js +6 -0
- package/dist/ports/events.repository.d.ts +2 -1
- package/dist/repositories/mongo/event-template.mapper.js +3 -0
- package/dist/repositories/mongo/event.mapper.js +3 -0
- package/dist/types/shared.d.ts +2 -0
- package/dist/types/shared.js +2 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ParticipantEvent } from "../types";
|
|
1
|
+
import { GameMode, ParticipantEvent } from "../types";
|
|
2
2
|
export declare class EventTemplate {
|
|
3
3
|
private templateId;
|
|
4
4
|
private groupId;
|
|
@@ -15,8 +15,9 @@ export declare class EventTemplate {
|
|
|
15
15
|
private defaultParticipants;
|
|
16
16
|
private maxPlayers;
|
|
17
17
|
private createdAt;
|
|
18
|
+
private gameMode;
|
|
18
19
|
constructor(templateId: number, groupId: number, adminId: number, description: string, title: string, preViewImg: string, options: string[], autoPost: boolean, defaultTime: string, defaultDayOfWeek: number, // 0..6
|
|
19
|
-
defaultLocation: string, defaultDuration: string, defaultParticipants: ParticipantEvent[], maxPlayers: number, createdAt: Date);
|
|
20
|
+
defaultLocation: string, defaultDuration: string, defaultParticipants: ParticipantEvent[], maxPlayers: number, createdAt: Date, gameMode?: GameMode);
|
|
20
21
|
static create(p: {
|
|
21
22
|
templateId: number;
|
|
22
23
|
groupId: number;
|
|
@@ -33,6 +34,7 @@ export declare class EventTemplate {
|
|
|
33
34
|
defaultParticipants?: ParticipantEvent[];
|
|
34
35
|
maxPlayers: number;
|
|
35
36
|
createdAt?: Date;
|
|
37
|
+
gameMode?: GameMode;
|
|
36
38
|
}): EventTemplate;
|
|
37
39
|
getTemplateId(): number;
|
|
38
40
|
getGroupId(): number;
|
|
@@ -49,6 +51,7 @@ export declare class EventTemplate {
|
|
|
49
51
|
getDefaultParticipants(): ParticipantEvent[];
|
|
50
52
|
getMaxPlayers(): number;
|
|
51
53
|
getCreatedAt(): Date;
|
|
54
|
+
getGameMode(): GameMode;
|
|
52
55
|
setGroupId(groupId: number): void;
|
|
53
56
|
setAdminId(adminId: number): void;
|
|
54
57
|
setDescription(description: string): void;
|
|
@@ -62,6 +65,7 @@ export declare class EventTemplate {
|
|
|
62
65
|
setDefaultDuration(duration: string): void;
|
|
63
66
|
setDefaultParticipants(participants: ParticipantEvent[]): void;
|
|
64
67
|
setMaxPlayers(n: number): void;
|
|
68
|
+
setGameMode(mode: GameMode): void;
|
|
65
69
|
addDefaultParticipant(p: ParticipantEvent): void;
|
|
66
70
|
removeDefaultParticipant(userId: number): void;
|
|
67
71
|
toObject(): {
|
|
@@ -80,5 +84,6 @@ export declare class EventTemplate {
|
|
|
80
84
|
defaultParticipants: ParticipantEvent[];
|
|
81
85
|
maxPlayers: number;
|
|
82
86
|
createdAt: Date;
|
|
87
|
+
gameMode: GameMode;
|
|
83
88
|
};
|
|
84
89
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.EventTemplate = void 0;
|
|
4
|
+
const types_1 = require("../types");
|
|
4
5
|
class EventTemplate {
|
|
5
6
|
constructor(templateId, groupId, adminId, description, title, preViewImg, options, autoPost, defaultTime, defaultDayOfWeek, // 0..6
|
|
6
|
-
defaultLocation, defaultDuration, defaultParticipants, maxPlayers, createdAt) {
|
|
7
|
+
defaultLocation, defaultDuration, defaultParticipants, maxPlayers, createdAt, gameMode = types_1.DEFAULT_GAME_MODE) {
|
|
7
8
|
this.templateId = templateId;
|
|
8
9
|
this.groupId = groupId;
|
|
9
10
|
this.adminId = adminId;
|
|
@@ -19,13 +20,14 @@ class EventTemplate {
|
|
|
19
20
|
this.defaultParticipants = defaultParticipants;
|
|
20
21
|
this.maxPlayers = maxPlayers;
|
|
21
22
|
this.createdAt = createdAt;
|
|
23
|
+
this.gameMode = gameMode;
|
|
22
24
|
}
|
|
23
25
|
static create(p) {
|
|
24
26
|
if (!p.title)
|
|
25
27
|
throw new Error("Title is required");
|
|
26
28
|
if (p.maxPlayers < 1)
|
|
27
29
|
throw new Error("maxPlayers must be >= 1");
|
|
28
|
-
return new EventTemplate(p.templateId, p.groupId, p.adminId, p.description, p.title, p.preViewImg, [...p.options], p.autoPost ?? false, p.defaultTime, p.defaultDayOfWeek, p.defaultLocation, p.defaultDuration, [...(p.defaultParticipants ?? [])], p.maxPlayers, p.createdAt ?? new Date());
|
|
30
|
+
return new EventTemplate(p.templateId, p.groupId, p.adminId, p.description, p.title, p.preViewImg, [...p.options], p.autoPost ?? false, p.defaultTime, p.defaultDayOfWeek, p.defaultLocation, p.defaultDuration, [...(p.defaultParticipants ?? [])], p.maxPlayers, p.createdAt ?? new Date(), p.gameMode ?? types_1.DEFAULT_GAME_MODE);
|
|
29
31
|
}
|
|
30
32
|
// ---- GETTERS
|
|
31
33
|
getTemplateId() { return this.templateId; }
|
|
@@ -43,6 +45,7 @@ class EventTemplate {
|
|
|
43
45
|
getDefaultParticipants() { return this.defaultParticipants; }
|
|
44
46
|
getMaxPlayers() { return this.maxPlayers; }
|
|
45
47
|
getCreatedAt() { return this.createdAt; }
|
|
48
|
+
getGameMode() { return this.gameMode; }
|
|
46
49
|
// ---- SETTERS
|
|
47
50
|
setGroupId(groupId) { this.groupId = groupId; }
|
|
48
51
|
setAdminId(adminId) { this.adminId = adminId; }
|
|
@@ -57,6 +60,7 @@ class EventTemplate {
|
|
|
57
60
|
setDefaultDuration(duration) { this.defaultDuration = duration; }
|
|
58
61
|
setDefaultParticipants(participants) { this.defaultParticipants = participants; }
|
|
59
62
|
setMaxPlayers(n) { this.maxPlayers = n; }
|
|
63
|
+
setGameMode(mode) { this.gameMode = mode; }
|
|
60
64
|
addDefaultParticipant(p) {
|
|
61
65
|
this.defaultParticipants = [...this.defaultParticipants, p];
|
|
62
66
|
}
|
|
@@ -80,6 +84,7 @@ class EventTemplate {
|
|
|
80
84
|
defaultParticipants: this.defaultParticipants,
|
|
81
85
|
maxPlayers: this.maxPlayers,
|
|
82
86
|
createdAt: this.createdAt,
|
|
87
|
+
gameMode: this.gameMode,
|
|
83
88
|
};
|
|
84
89
|
}
|
|
85
90
|
}
|
package/dist/domain/event.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EventStatus, Match, ParticipantEvent, Team } from "../types";
|
|
1
|
+
import { EventStatus, GameMode, Match, ParticipantEvent, Team } from "../types";
|
|
2
2
|
export declare class Event {
|
|
3
3
|
private readonly eventId;
|
|
4
4
|
private readonly groupId;
|
|
@@ -11,6 +11,7 @@ export declare class Event {
|
|
|
11
11
|
private readonly createdBy;
|
|
12
12
|
private isRatingApplied;
|
|
13
13
|
private seasonId;
|
|
14
|
+
private gameMode;
|
|
14
15
|
private reportMessageId?;
|
|
15
16
|
private status;
|
|
16
17
|
private constructor();
|
|
@@ -28,6 +29,7 @@ export declare class Event {
|
|
|
28
29
|
reportMessageId?: number;
|
|
29
30
|
isRatingApplied?: boolean;
|
|
30
31
|
status?: EventStatus;
|
|
32
|
+
gameMode?: GameMode;
|
|
31
33
|
}): Event;
|
|
32
34
|
getEventId(): number;
|
|
33
35
|
getGroupId(): number;
|
|
@@ -42,6 +44,9 @@ export declare class Event {
|
|
|
42
44
|
getCreatedBy(): number;
|
|
43
45
|
getStatus(): EventStatus;
|
|
44
46
|
getIsRatingApplied(): boolean;
|
|
47
|
+
getGameMode(): GameMode;
|
|
48
|
+
canChangeGameMode(): boolean;
|
|
49
|
+
setGameMode(mode: GameMode): void;
|
|
45
50
|
reschedule(newDate: Date): void;
|
|
46
51
|
attachMessage(messageId: number): void;
|
|
47
52
|
attachReportMessage(reportMessageId: number): void;
|
package/dist/domain/event.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Event = void 0;
|
|
4
|
+
const types_1 = require("../types");
|
|
4
5
|
class Event {
|
|
5
|
-
constructor(eventId, groupId, messageId, templateId, date, participants, teams, matches, createdBy, isRatingApplied, seasonId, reportMessageId, status = "active") {
|
|
6
|
+
constructor(eventId, groupId, messageId, templateId, date, participants, teams, matches, createdBy, isRatingApplied, seasonId, gameMode, reportMessageId, status = "active") {
|
|
6
7
|
this.eventId = eventId;
|
|
7
8
|
this.groupId = groupId;
|
|
8
9
|
this.messageId = messageId;
|
|
@@ -14,6 +15,7 @@ class Event {
|
|
|
14
15
|
this.createdBy = createdBy;
|
|
15
16
|
this.isRatingApplied = isRatingApplied;
|
|
16
17
|
this.seasonId = seasonId;
|
|
18
|
+
this.gameMode = gameMode;
|
|
17
19
|
this.reportMessageId = reportMessageId;
|
|
18
20
|
this.status = status;
|
|
19
21
|
}
|
|
@@ -21,7 +23,7 @@ class Event {
|
|
|
21
23
|
if (!params.seasonId) {
|
|
22
24
|
throw new Error("Event must have a season ID");
|
|
23
25
|
}
|
|
24
|
-
return new Event(params.eventId, params.groupId, params.messageId ?? 0, params.templateId, params.date, params.participants ?? [], params.teams ?? [], params.matches ?? [], params.createdBy, params.isRatingApplied ?? false, params.seasonId, params.reportMessageId, params.status ?? "active");
|
|
26
|
+
return new Event(params.eventId, params.groupId, params.messageId ?? 0, params.templateId, params.date, params.participants ?? [], params.teams ?? [], params.matches ?? [], params.createdBy, params.isRatingApplied ?? false, params.seasonId, params.gameMode ?? types_1.DEFAULT_GAME_MODE, params.reportMessageId, params.status ?? "active");
|
|
25
27
|
}
|
|
26
28
|
getEventId() { return this.eventId; }
|
|
27
29
|
getGroupId() { return this.groupId; }
|
|
@@ -36,6 +38,14 @@ class Event {
|
|
|
36
38
|
getCreatedBy() { return this.createdBy; }
|
|
37
39
|
getStatus() { return this.status; }
|
|
38
40
|
getIsRatingApplied() { return this.isRatingApplied; }
|
|
41
|
+
getGameMode() { return this.gameMode; }
|
|
42
|
+
canChangeGameMode() { return this.matches.length === 0; }
|
|
43
|
+
setGameMode(mode) {
|
|
44
|
+
if (!this.canChangeGameMode()) {
|
|
45
|
+
throw new Error("Cannot change game mode after the first match score has been entered");
|
|
46
|
+
}
|
|
47
|
+
this.gameMode = mode;
|
|
48
|
+
}
|
|
39
49
|
reschedule(newDate) {
|
|
40
50
|
this.date = newDate;
|
|
41
51
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Schema } from "mongoose";
|
|
2
|
-
import { ParticipantEvent } from "../../types";
|
|
2
|
+
import { GameMode, ParticipantEvent } from "../../types";
|
|
3
3
|
export interface EventTemplateDoc {
|
|
4
4
|
templateId: number;
|
|
5
5
|
groupId: number;
|
|
@@ -15,6 +15,7 @@ export interface EventTemplateDoc {
|
|
|
15
15
|
defaultDuration: string;
|
|
16
16
|
defaultParticipants: ParticipantEvent[];
|
|
17
17
|
maxPlayers: number;
|
|
18
|
+
gameMode: GameMode;
|
|
18
19
|
createdAt: Date;
|
|
19
20
|
}
|
|
20
21
|
export declare function createEventTemplateSchema(): Schema<EventTemplateDoc, import("mongoose").Model<EventTemplateDoc, any, any, any, import("mongoose").Document<unknown, any, EventTemplateDoc, any, {}> & EventTemplateDoc & {
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createEventTemplateSchema = createEventTemplateSchema;
|
|
4
4
|
const mongoose_1 = require("mongoose");
|
|
5
|
+
const types_1 = require("../../types");
|
|
5
6
|
function createEventTemplateSchema() {
|
|
6
7
|
const DefaultParticipantSchema = new mongoose_1.Schema({
|
|
7
8
|
userId: { type: Number, required: true },
|
|
@@ -24,6 +25,7 @@ function createEventTemplateSchema() {
|
|
|
24
25
|
defaultDuration: { type: String, required: true },
|
|
25
26
|
defaultParticipants: { type: [DefaultParticipantSchema], default: [] },
|
|
26
27
|
maxPlayers: { type: Number, required: true, min: 1 },
|
|
28
|
+
gameMode: { type: String, enum: ["first_to_2", "timed_7min"], default: types_1.DEFAULT_GAME_MODE },
|
|
27
29
|
createdAt: { type: Date, default: Date.now },
|
|
28
30
|
});
|
|
29
31
|
return schema;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Schema } from "mongoose";
|
|
2
|
-
import { EventStatus, Match, MatchEvent, ParticipantEvent, Team } from "../../types";
|
|
2
|
+
import { EventStatus, GameMode, Match, MatchEvent, ParticipantEvent, Team } from "../../types";
|
|
3
3
|
export interface EventDoc {
|
|
4
4
|
eventId: number;
|
|
5
5
|
groupId: number;
|
|
@@ -13,6 +13,7 @@ export interface EventDoc {
|
|
|
13
13
|
seasonId: string;
|
|
14
14
|
status: EventStatus;
|
|
15
15
|
isRatingApplied: boolean;
|
|
16
|
+
gameMode: GameMode;
|
|
16
17
|
reportMessageId?: number;
|
|
17
18
|
}
|
|
18
19
|
export declare function createParticipantEventSchema(): Schema<ParticipantEvent, import("mongoose").Model<ParticipantEvent, any, any, any, import("mongoose").Document<unknown, any, ParticipantEvent, any, {}> & ParticipantEvent & {
|
|
@@ -6,6 +6,7 @@ exports.createMatchEventSchema = createMatchEventSchema;
|
|
|
6
6
|
exports.createMatchSchema = createMatchSchema;
|
|
7
7
|
exports.createEventSchema = createEventSchema;
|
|
8
8
|
const mongoose_1 = require("mongoose");
|
|
9
|
+
const types_1 = require("../../types");
|
|
9
10
|
function createParticipantEventSchema() {
|
|
10
11
|
return new mongoose_1.Schema({
|
|
11
12
|
userId: { type: Number, required: true },
|
|
@@ -57,6 +58,11 @@ function createEventSchema() {
|
|
|
57
58
|
matches: { type: [MatchSchema], default: [] },
|
|
58
59
|
isRatingApplied: { type: Boolean },
|
|
59
60
|
reportMessageId: { type: Number },
|
|
61
|
+
gameMode: {
|
|
62
|
+
type: String,
|
|
63
|
+
enum: ["first_to_2", "timed_7min"],
|
|
64
|
+
default: types_1.DEFAULT_GAME_MODE,
|
|
65
|
+
},
|
|
60
66
|
status: {
|
|
61
67
|
type: String,
|
|
62
68
|
enum: ["active", "in_progress", "completed"],
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Event } from "../domain/event";
|
|
2
|
-
import { ParticipantEvent, Team, Match, EventStatus } from "../types";
|
|
2
|
+
import { ParticipantEvent, Team, Match, EventStatus, GameMode } from "../types";
|
|
3
3
|
export type EventWrite = {
|
|
4
4
|
eventId: number;
|
|
5
5
|
groupId: number;
|
|
@@ -14,6 +14,7 @@ export type EventWrite = {
|
|
|
14
14
|
seasonId: string;
|
|
15
15
|
isRatingApplied?: boolean;
|
|
16
16
|
reportMessageId?: number;
|
|
17
|
+
gameMode?: GameMode;
|
|
17
18
|
};
|
|
18
19
|
export interface EventsRepository {
|
|
19
20
|
create(eventData: Event): Promise<Event>;
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.toDomain = toDomain;
|
|
4
4
|
exports.toDoc = toDoc;
|
|
5
5
|
const event_template_1 = require("../../domain/event-template");
|
|
6
|
+
const types_1 = require("../../types");
|
|
6
7
|
function toDomain(doc) {
|
|
7
8
|
return event_template_1.EventTemplate.create({
|
|
8
9
|
templateId: doc.templateId,
|
|
@@ -25,6 +26,7 @@ function toDomain(doc) {
|
|
|
25
26
|
})),
|
|
26
27
|
maxPlayers: doc.maxPlayers,
|
|
27
28
|
createdAt: new Date(doc.createdAt),
|
|
29
|
+
gameMode: doc.gameMode ?? types_1.DEFAULT_GAME_MODE,
|
|
28
30
|
});
|
|
29
31
|
}
|
|
30
32
|
;
|
|
@@ -44,6 +46,7 @@ function toDoc(entity) {
|
|
|
44
46
|
defaultDuration: entity.getDefaultDuration(),
|
|
45
47
|
defaultParticipants: entity.getDefaultParticipants(),
|
|
46
48
|
maxPlayers: entity.getMaxPlayers(),
|
|
49
|
+
gameMode: entity.getGameMode(),
|
|
47
50
|
createdAt: entity.getCreatedAt(),
|
|
48
51
|
};
|
|
49
52
|
}
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.toDomain = toDomain;
|
|
4
4
|
exports.toDoc = toDoc;
|
|
5
5
|
const event_1 = require("../../domain/event");
|
|
6
|
+
const types_1 = require("../../types");
|
|
6
7
|
function toDomain(doc) {
|
|
7
8
|
return event_1.Event.create({
|
|
8
9
|
eventId: doc.eventId,
|
|
@@ -18,6 +19,7 @@ function toDomain(doc) {
|
|
|
18
19
|
seasonId: doc.seasonId,
|
|
19
20
|
reportMessageId: doc.reportMessageId,
|
|
20
21
|
status: doc.status,
|
|
22
|
+
gameMode: doc.gameMode ?? types_1.DEFAULT_GAME_MODE,
|
|
21
23
|
});
|
|
22
24
|
}
|
|
23
25
|
function toDoc(event) {
|
|
@@ -35,5 +37,6 @@ function toDoc(event) {
|
|
|
35
37
|
seasonId: event.getSeasonId(),
|
|
36
38
|
isRatingApplied: event.getIsRatingApplied(),
|
|
37
39
|
reportMessageId: event.getReportMessageId(),
|
|
40
|
+
gameMode: event.getGameMode(),
|
|
38
41
|
};
|
|
39
42
|
}
|
package/dist/types/shared.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export type EventStatus = "active" | "in_progress" | "completed";
|
|
2
2
|
export type LanguageType = "en" | "ru" | "ua";
|
|
3
3
|
export type DayOfWeek = "Monday" | "Tuesday" | "Wednesday" | "Thursday" | "Friday" | "Saturday" | "Sunday";
|
|
4
|
+
export type GameMode = "first_to_2" | "timed_7min";
|
|
5
|
+
export declare const DEFAULT_GAME_MODE: GameMode;
|
|
4
6
|
export interface ParticipantBase {
|
|
5
7
|
userId: number;
|
|
6
8
|
}
|
package/dist/types/shared.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RatingSource = exports.PlayerPosition = void 0;
|
|
3
|
+
exports.RatingSource = exports.PlayerPosition = exports.DEFAULT_GAME_MODE = void 0;
|
|
4
|
+
exports.DEFAULT_GAME_MODE = "first_to_2";
|
|
4
5
|
var PlayerPosition;
|
|
5
6
|
(function (PlayerPosition) {
|
|
6
7
|
PlayerPosition["FW"] = "FW";
|