ballrush-core 0.6.5 → 0.6.7

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.
@@ -15,6 +15,7 @@ export declare class Achievement {
15
15
  private description;
16
16
  private translations;
17
17
  private icon;
18
+ private iconUrl;
18
19
  private algorithm;
19
20
  private isActive;
20
21
  private createdAt;
@@ -28,6 +29,7 @@ export declare class Achievement {
28
29
  description: string;
29
30
  translations?: AchievementTranslations;
30
31
  icon: string;
32
+ iconUrl?: string;
31
33
  algorithm: string;
32
34
  isActive?: boolean;
33
35
  createdAt?: Date;
@@ -41,6 +43,7 @@ export declare class Achievement {
41
43
  getTranslations(): AchievementTranslations;
42
44
  getTranslation(language: string): AchievementTranslation | undefined;
43
45
  getIcon(): string;
46
+ getIconUrl(): string | undefined;
44
47
  getAlgorithm(): string;
45
48
  getIsActive(): boolean;
46
49
  getCreatedAt(): Date;
@@ -51,6 +54,7 @@ export declare class Achievement {
51
54
  addTranslation(language: string, translation: AchievementTranslation): void;
52
55
  removeTranslation(language: string): void;
53
56
  setIcon(icon: string): void;
57
+ setIconUrl(url: string | undefined): void;
54
58
  setAlgorithm(algorithm: string): void;
55
59
  setIsActive(isActive: boolean): void;
56
60
  /**
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Achievement = void 0;
4
4
  class Achievement {
5
- constructor(achievementId, type, scope, title, description, translations, icon, algorithm, isActive, createdAt, updatedAt) {
5
+ constructor(achievementId, type, scope, title, description, translations, icon, iconUrl, algorithm, isActive, createdAt, updatedAt) {
6
6
  this.achievementId = achievementId;
7
7
  this.type = type;
8
8
  this.scope = scope;
@@ -10,6 +10,7 @@ class Achievement {
10
10
  this.description = description;
11
11
  this.translations = translations;
12
12
  this.icon = icon;
13
+ this.iconUrl = iconUrl;
13
14
  this.algorithm = algorithm;
14
15
  this.isActive = isActive;
15
16
  this.createdAt = createdAt;
@@ -38,7 +39,7 @@ class Achievement {
38
39
  throw new Error("Achievement creation failed: algorithm is required");
39
40
  }
40
41
  const now = new Date();
41
- return new Achievement(params.achievementId, params.type, params.scope, params.title, params.description, params.translations ?? {}, params.icon, params.algorithm, params.isActive ?? true, params.createdAt ?? now, params.updatedAt ?? now);
42
+ return new Achievement(params.achievementId, params.type, params.scope, params.title, params.description, params.translations ?? {}, params.icon, params.iconUrl, params.algorithm, params.isActive ?? true, params.createdAt ?? now, params.updatedAt ?? now);
42
43
  }
43
44
  // ---- GETTERS
44
45
  getAchievementId() {
@@ -65,6 +66,9 @@ class Achievement {
65
66
  getIcon() {
66
67
  return this.icon;
67
68
  }
69
+ getIconUrl() {
70
+ return this.iconUrl;
71
+ }
68
72
  getAlgorithm() {
69
73
  return this.algorithm;
70
74
  }
@@ -117,6 +121,10 @@ class Achievement {
117
121
  this.icon = icon;
118
122
  this.updatedAt = new Date();
119
123
  }
124
+ setIconUrl(url) {
125
+ this.iconUrl = url;
126
+ this.updatedAt = new Date();
127
+ }
120
128
  setAlgorithm(algorithm) {
121
129
  if (!algorithm) {
122
130
  throw new Error("algorithm cannot be empty");
@@ -4,17 +4,25 @@ export declare class User {
4
4
  private readonly firstName;
5
5
  private readonly username?;
6
6
  private language;
7
+ private avatarUrl?;
8
+ private telegramAvatarId?;
7
9
  private constructor();
8
10
  static create(params: {
9
11
  userId: number;
10
12
  firstName: string;
11
13
  username?: string;
12
14
  language?: LanguageType;
15
+ avatarUrl?: string;
16
+ telegramAvatarId?: string;
13
17
  }): User;
14
18
  getUserId(): number;
15
19
  getFirstName(): string;
16
20
  getUsername(): string | undefined;
17
21
  getLanguage(): LanguageType;
18
22
  setLanguage(language: LanguageType): void;
23
+ getAvatarUrl(): string | undefined;
24
+ setAvatarUrl(url: string): void;
25
+ getTelegramAvatarId(): string | undefined;
26
+ setTelegramAvatarId(id: string): void;
19
27
  getFullName(): string;
20
28
  }
@@ -2,11 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.User = void 0;
4
4
  class User {
5
- constructor(userId, firstName, username, language = "ru") {
5
+ constructor(userId, firstName, username, language = "ru", avatarUrl, telegramAvatarId) {
6
6
  this.userId = userId;
7
7
  this.firstName = firstName;
8
8
  this.username = username;
9
9
  this.language = language;
10
+ this.avatarUrl = avatarUrl;
11
+ this.telegramAvatarId = telegramAvatarId;
10
12
  }
11
13
  static create(params) {
12
14
  if (!params.userId) {
@@ -15,7 +17,7 @@ class User {
15
17
  if (!params.firstName) {
16
18
  throw new Error(`User creation failed: missing firstName (userId=${params.userId ?? 'N/A'})`);
17
19
  }
18
- return new User(params.userId, params.firstName, params.username, params.language ?? "ru");
20
+ return new User(params.userId, params.firstName, params.username, params.language ?? "ru", params.avatarUrl, params.telegramAvatarId);
19
21
  }
20
22
  getUserId() {
21
23
  return this.userId;
@@ -32,6 +34,18 @@ class User {
32
34
  setLanguage(language) {
33
35
  this.language = language;
34
36
  }
37
+ getAvatarUrl() {
38
+ return this.avatarUrl;
39
+ }
40
+ setAvatarUrl(url) {
41
+ this.avatarUrl = url;
42
+ }
43
+ getTelegramAvatarId() {
44
+ return this.telegramAvatarId;
45
+ }
46
+ setTelegramAvatarId(id) {
47
+ this.telegramAvatarId = id;
48
+ }
35
49
  getFullName() {
36
50
  return this.username
37
51
  ? `${this.firstName} (${this.username})`
@@ -9,6 +9,7 @@ export interface AchievementDoc {
9
9
  description: string;
10
10
  translations: AchievementTranslations;
11
11
  icon: string;
12
+ iconUrl?: string;
12
13
  algorithm: string;
13
14
  isActive: boolean;
14
15
  createdAt: Date;
@@ -37,6 +37,10 @@ function createAchievementSchema() {
37
37
  type: String,
38
38
  required: true,
39
39
  },
40
+ iconUrl: {
41
+ type: String,
42
+ required: false,
43
+ },
40
44
  algorithm: {
41
45
  type: String,
42
46
  required: true,
@@ -5,6 +5,8 @@ export interface UserDoc {
5
5
  language: LanguageType;
6
6
  userId: number;
7
7
  username?: string;
8
+ avatarUrl?: string;
9
+ telegramAvatarId?: string;
8
10
  }
9
11
  export declare function createUserSchema(): Schema<UserDoc, import("mongoose").Model<UserDoc, any, any, any, import("mongoose").Document<unknown, any, UserDoc> & UserDoc & {
10
12
  _id: import("mongoose").Types.ObjectId;
@@ -8,6 +8,8 @@ function createUserSchema() {
8
8
  username: { type: String },
9
9
  userId: { type: Number, required: true, unique: true, index: true },
10
10
  language: { type: String, enum: ["ru", "en", "ua"], default: "ru" },
11
+ avatarUrl: { type: String },
12
+ telegramAvatarId: { type: String },
11
13
  });
12
14
  return UserSchema;
13
15
  }
@@ -12,6 +12,7 @@ function toDomain(doc) {
12
12
  description: doc.description,
13
13
  translations: doc.translations,
14
14
  icon: doc.icon,
15
+ iconUrl: doc.iconUrl,
15
16
  algorithm: doc.algorithm,
16
17
  isActive: doc.isActive,
17
18
  createdAt: doc.createdAt,
@@ -27,6 +28,7 @@ function toDoc(achievement) {
27
28
  description: achievement.getDescription(),
28
29
  translations: achievement.getTranslations(),
29
30
  icon: achievement.getIcon(),
31
+ iconUrl: achievement.getIconUrl(),
30
32
  algorithm: achievement.getAlgorithm(),
31
33
  isActive: achievement.getIsActive(),
32
34
  createdAt: achievement.getCreatedAt(),
@@ -8,7 +8,9 @@ function toDomain(doc) {
8
8
  firstName: doc.firstName,
9
9
  username: doc.username,
10
10
  userId: doc.userId,
11
- language: doc.language
11
+ language: doc.language,
12
+ avatarUrl: doc.avatarUrl,
13
+ telegramAvatarId: doc.telegramAvatarId,
12
14
  });
13
15
  }
14
16
  function toDoc(user) {
@@ -17,5 +19,7 @@ function toDoc(user) {
17
19
  username: user.getUsername(),
18
20
  userId: user.getUserId(),
19
21
  language: user.getLanguage(),
22
+ avatarUrl: user.getAvatarUrl(),
23
+ telegramAvatarId: user.getTelegramAvatarId(),
20
24
  };
21
25
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ballrush-core",
3
- "version": "0.6.5",
3
+ "version": "0.6.7",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.js",