ballrush-core 0.2.5 → 0.3.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/group.d.ts +5 -1
- package/dist/domain/group.js +7 -2
- package/dist/mongo/schemas/group.schema.d.ts +2 -1
- package/dist/mongo/schemas/group.schema.js +1 -0
- package/dist/mongo/schemas/user.schema.js +1 -1
- package/dist/ports/groups.repository.d.ts +2 -0
- package/dist/repositories/mongo/group.mapper.js +2 -0
- package/dist/types/shared.d.ts +1 -1
- package/package.json +1 -1
package/dist/domain/group.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { ParticipantGroup, PlayerPosition } from "../types";
|
|
1
|
+
import { ParticipantGroup, PlayerPosition, LanguageType } from "../types";
|
|
2
2
|
export declare class Group {
|
|
3
3
|
private readonly groupId;
|
|
4
4
|
private readonly groupName;
|
|
5
5
|
private participants;
|
|
6
6
|
private timezone;
|
|
7
7
|
private isMessageLast;
|
|
8
|
+
private language;
|
|
8
9
|
private constructor();
|
|
9
10
|
static create(params: {
|
|
10
11
|
groupId: number;
|
|
@@ -12,16 +13,19 @@ export declare class Group {
|
|
|
12
13
|
participants?: ParticipantGroup[];
|
|
13
14
|
timezone?: string;
|
|
14
15
|
isMessageLast?: boolean;
|
|
16
|
+
language?: LanguageType;
|
|
15
17
|
}): Group;
|
|
16
18
|
getGroupId(): number;
|
|
17
19
|
getGroupName(): string;
|
|
18
20
|
getTimezone(): string;
|
|
19
21
|
getIsMessageLast(): boolean;
|
|
22
|
+
getLanguage(): LanguageType;
|
|
20
23
|
getParticipants(): ParticipantGroup[];
|
|
21
24
|
getAdmins(): ParticipantGroup[];
|
|
22
25
|
getAdminIds(): number[];
|
|
23
26
|
setTimezone(tz: string): void;
|
|
24
27
|
setIsMessageLast(v: boolean): void;
|
|
28
|
+
setLanguage(language: LanguageType): void;
|
|
25
29
|
addAdmin(userId: number): void;
|
|
26
30
|
removeAdmin(userId: number): void;
|
|
27
31
|
addParticipant(userId: number, isAdmin?: boolean, initialRating?: number): boolean;
|
package/dist/domain/group.js
CHANGED
|
@@ -4,22 +4,24 @@ exports.Group = void 0;
|
|
|
4
4
|
const types_1 = require("../types");
|
|
5
5
|
const utils_1 = require("../utils");
|
|
6
6
|
class Group {
|
|
7
|
-
constructor(groupId, groupName, participants, timezone = "UTC+0", isMessageLast = false) {
|
|
7
|
+
constructor(groupId, groupName, participants, timezone = "UTC+0", isMessageLast = false, language = "en") {
|
|
8
8
|
this.groupId = groupId;
|
|
9
9
|
this.groupName = groupName;
|
|
10
10
|
this.participants = participants;
|
|
11
11
|
this.timezone = timezone;
|
|
12
12
|
this.isMessageLast = isMessageLast;
|
|
13
|
+
this.language = language;
|
|
13
14
|
}
|
|
14
15
|
static create(params) {
|
|
15
16
|
if (!params.groupName)
|
|
16
17
|
throw new Error("Group name is required");
|
|
17
|
-
return new Group(params.groupId, params.groupName, (params.participants ?? []).map(p => ({ ...p, ratingHistory: [...p.ratingHistory] })), params.timezone ?? "UTC+0", params.isMessageLast ?? false);
|
|
18
|
+
return new Group(params.groupId, params.groupName, (params.participants ?? []).map(p => ({ ...p, ratingHistory: [...p.ratingHistory] })), params.timezone ?? "UTC+0", params.isMessageLast ?? false, params.language ?? "en");
|
|
18
19
|
}
|
|
19
20
|
getGroupId() { return this.groupId; }
|
|
20
21
|
getGroupName() { return this.groupName; }
|
|
21
22
|
getTimezone() { return this.timezone; }
|
|
22
23
|
getIsMessageLast() { return this.isMessageLast; }
|
|
24
|
+
getLanguage() { return this.language; }
|
|
23
25
|
getParticipants() { return this.participants; }
|
|
24
26
|
getAdmins() {
|
|
25
27
|
return this.participants.filter(p => p.isAdmin);
|
|
@@ -33,6 +35,9 @@ class Group {
|
|
|
33
35
|
setIsMessageLast(v) {
|
|
34
36
|
this.isMessageLast = v;
|
|
35
37
|
}
|
|
38
|
+
setLanguage(language) {
|
|
39
|
+
this.language = language;
|
|
40
|
+
}
|
|
36
41
|
addAdmin(userId) {
|
|
37
42
|
const p = this.participants.find(x => x.userId === userId);
|
|
38
43
|
if (p) {
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { Schema } from "mongoose";
|
|
2
|
-
import { ParticipantGroup, RatingPoint } from "../../types";
|
|
2
|
+
import { ParticipantGroup, RatingPoint, LanguageType } from "../../types";
|
|
3
3
|
export interface GroupDoc {
|
|
4
4
|
groupId: number;
|
|
5
5
|
groupName: string;
|
|
6
6
|
participants: ParticipantGroup[];
|
|
7
7
|
timezone: string;
|
|
8
8
|
isMessageLast: boolean;
|
|
9
|
+
language: LanguageType;
|
|
9
10
|
}
|
|
10
11
|
export declare function createRatingPointSchema(): Schema<RatingPoint, import("mongoose").Model<RatingPoint, any, any, any, import("mongoose").Document<unknown, any, RatingPoint> & RatingPoint & {
|
|
11
12
|
_id: import("mongoose").Types.ObjectId;
|
|
@@ -27,6 +27,7 @@ function createGroupSchema() {
|
|
|
27
27
|
participants: { type: [ParticipantSchema], default: [] },
|
|
28
28
|
timezone: { type: String, default: "UTC+0" },
|
|
29
29
|
isMessageLast: { type: Boolean, default: false },
|
|
30
|
+
language: { type: String, enum: ['en', 'ru', 'ua'], default: 'en' },
|
|
30
31
|
});
|
|
31
32
|
return GroupSchema;
|
|
32
33
|
}
|
|
@@ -7,7 +7,7 @@ function createUserSchema() {
|
|
|
7
7
|
firstName: { type: String, required: true },
|
|
8
8
|
username: { type: String },
|
|
9
9
|
userId: { type: Number, required: true, unique: true, index: true },
|
|
10
|
-
language: { type: String, enum: ["ru", "en"], default: "ru" },
|
|
10
|
+
language: { type: String, enum: ["ru", "en", "ua"], default: "ru" },
|
|
11
11
|
});
|
|
12
12
|
return UserSchema;
|
|
13
13
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Group } from "../domain/group";
|
|
2
|
+
import { LanguageType } from "../types";
|
|
2
3
|
export type GroupWrite = {
|
|
3
4
|
groupId: number;
|
|
4
5
|
groupName: string;
|
|
@@ -13,6 +14,7 @@ export type GroupWrite = {
|
|
|
13
14
|
}>;
|
|
14
15
|
timezone: string;
|
|
15
16
|
isMessageLast: boolean;
|
|
17
|
+
language: LanguageType;
|
|
16
18
|
};
|
|
17
19
|
export interface GroupsRepository {
|
|
18
20
|
create(groupData: Group): Promise<Group>;
|
|
@@ -10,6 +10,7 @@ function toDomain(doc) {
|
|
|
10
10
|
participants: doc.participants,
|
|
11
11
|
timezone: doc.timezone,
|
|
12
12
|
isMessageLast: doc.isMessageLast,
|
|
13
|
+
language: doc.language,
|
|
13
14
|
});
|
|
14
15
|
}
|
|
15
16
|
function toDoc(group) {
|
|
@@ -19,5 +20,6 @@ function toDoc(group) {
|
|
|
19
20
|
participants: group.getParticipants(),
|
|
20
21
|
timezone: group.getTimezone(),
|
|
21
22
|
isMessageLast: group.getIsMessageLast(),
|
|
23
|
+
language: group.getLanguage(),
|
|
22
24
|
};
|
|
23
25
|
}
|
package/dist/types/shared.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type EventStatus = "active" | "in_progress" | "completed";
|
|
2
|
-
export type LanguageType = "en" | "ru";
|
|
2
|
+
export type LanguageType = "en" | "ru" | "ua";
|
|
3
3
|
export type DayOfWeek = "Monday" | "Tuesday" | "Wednesday" | "Thursday" | "Friday" | "Saturday" | "Sunday";
|
|
4
4
|
export interface ParticipantBase {
|
|
5
5
|
userId: number;
|