@armoyu/core 1.0.0 → 1.0.1

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.
Files changed (81) hide show
  1. package/dist/api/ApiClient.d.ts +49 -11
  2. package/dist/api/ApiClient.js +137 -33
  3. package/dist/api/ArmoyuApi.d.ts +38 -0
  4. package/dist/api/ArmoyuApi.js +66 -0
  5. package/dist/armoyu-core.bundle.js +1 -0
  6. package/dist/index.d.ts +11 -1
  7. package/dist/index.js +9 -2
  8. package/dist/models/auth/User.js +17 -22
  9. package/dist/models/core/Rule.d.ts +23 -0
  10. package/dist/models/core/Rule.js +39 -0
  11. package/dist/models/index.d.ts +1 -0
  12. package/dist/models/index.js +1 -0
  13. package/dist/models/social/Post.js +15 -15
  14. package/dist/services/AuthService.d.ts +11 -10
  15. package/dist/services/AuthService.js +56 -27
  16. package/dist/services/BaseService.d.ts +10 -0
  17. package/dist/services/BaseService.js +27 -0
  18. package/dist/services/BlogService.d.ts +16 -0
  19. package/dist/services/BlogService.js +54 -0
  20. package/dist/services/BotService.d.ts +28 -0
  21. package/dist/services/BotService.js +92 -0
  22. package/dist/services/ForumService.d.ts +19 -0
  23. package/dist/services/ForumService.js +64 -0
  24. package/dist/services/RuleService.d.ts +28 -0
  25. package/dist/services/RuleService.js +90 -0
  26. package/dist/services/ShopService.d.ts +20 -0
  27. package/dist/services/ShopService.js +53 -0
  28. package/dist/services/SocialService.d.ts +8 -7
  29. package/dist/services/SocialService.js +26 -21
  30. package/dist/services/SupportService.d.ts +16 -0
  31. package/dist/services/SupportService.js +54 -0
  32. package/dist/services/UserService.d.ts +12 -7
  33. package/dist/services/UserService.js +35 -18
  34. package/package.json +27 -21
  35. package/src/api/ApiClient.ts +0 -57
  36. package/src/index.ts +0 -24
  37. package/src/models/auth/Role.ts +0 -26
  38. package/src/models/auth/Session.ts +0 -50
  39. package/src/models/auth/User.ts +0 -111
  40. package/src/models/community/Classroom.ts +0 -34
  41. package/src/models/community/Event.ts +0 -32
  42. package/src/models/community/Faculty.ts +0 -30
  43. package/src/models/community/Forum.ts +0 -42
  44. package/src/models/community/Giveaway.ts +0 -39
  45. package/src/models/community/Group.ts +0 -78
  46. package/src/models/community/School.ts +0 -51
  47. package/src/models/community/SchoolTeam.ts +0 -49
  48. package/src/models/community/Station.ts +0 -145
  49. package/src/models/community/Survey.ts +0 -53
  50. package/src/models/community/SurveyAnswer.ts +0 -26
  51. package/src/models/community/Team.ts +0 -24
  52. package/src/models/community/Workplace.ts +0 -32
  53. package/src/models/content/Game.ts +0 -39
  54. package/src/models/content/Media.ts +0 -30
  55. package/src/models/content/Mod.ts +0 -38
  56. package/src/models/content/News.ts +0 -43
  57. package/src/models/content/Project.ts +0 -49
  58. package/src/models/core/PlatformStats.ts +0 -74
  59. package/src/models/core/SystemSettings.ts +0 -59
  60. package/src/models/index.ts +0 -37
  61. package/src/models/shop/CartItem.ts +0 -31
  62. package/src/models/shop/Order.ts +0 -48
  63. package/src/models/shop/Product.ts +0 -61
  64. package/src/models/social/Chat.ts +0 -47
  65. package/src/models/social/ChatMessage.ts +0 -30
  66. package/src/models/social/Comment.ts +0 -38
  67. package/src/models/social/Group.ts +0 -63
  68. package/src/models/social/Leaderboard.ts +0 -57
  69. package/src/models/social/Note.ts +0 -28
  70. package/src/models/social/Notification.ts +0 -99
  71. package/src/models/social/NotificationSender.ts +0 -36
  72. package/src/models/social/Post.ts +0 -75
  73. package/src/models/social/Story.ts +0 -30
  74. package/src/models/social/SupportTicket.ts +0 -38
  75. package/src/models/store/StoreItem.ts +0 -32
  76. package/src/services/AuthService.ts +0 -91
  77. package/src/services/SocialService.ts +0 -92
  78. package/src/services/SocketService.ts +0 -112
  79. package/src/services/UserService.ts +0 -69
  80. package/src/types/stats.ts +0 -17
  81. package/tsconfig.json +0 -16
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ForumService = void 0;
4
+ const BaseService_1 = require("./BaseService");
5
+ class ForumService extends BaseService_1.BaseService {
6
+ /**
7
+ * Get all forum categories.
8
+ */
9
+ async getCategories() {
10
+ try {
11
+ const response = await this.client.get('/community/forums/categories');
12
+ return this.handleResponse(response);
13
+ }
14
+ catch (error) {
15
+ console.error('[ForumService] Failed to fetch categories:', error);
16
+ return [];
17
+ }
18
+ }
19
+ /**
20
+ * Get topics for a specific category.
21
+ */
22
+ async getTopics(categoryId, page = 1) {
23
+ try {
24
+ const response = await this.client.get(`/community/forums/categories/${categoryId}/topics`, {
25
+ params: { page }
26
+ });
27
+ return this.handleResponse(response);
28
+ }
29
+ catch (error) {
30
+ console.error(`[ForumService] Failed to fetch topics for category ${categoryId}:`, error);
31
+ return [];
32
+ }
33
+ }
34
+ /**
35
+ * Create a new topic in a category.
36
+ */
37
+ async createTopic(categoryId, title, content) {
38
+ try {
39
+ const response = await this.client.post(`/community/forums/categories/${categoryId}/topics`, {
40
+ title,
41
+ content
42
+ });
43
+ return this.handleResponse(response);
44
+ }
45
+ catch (error) {
46
+ console.error('[ForumService] Topic creation failed:', error);
47
+ throw error;
48
+ }
49
+ }
50
+ /**
51
+ * Delete a topic by its ID.
52
+ */
53
+ async deleteTopic(topicId) {
54
+ try {
55
+ const response = await this.client.delete(`/community/forums/topics/${topicId}`);
56
+ this.handleResponse(response);
57
+ }
58
+ catch (error) {
59
+ console.error(`[ForumService] Failed to delete topic ${topicId}:`, error);
60
+ throw error;
61
+ }
62
+ }
63
+ }
64
+ exports.ForumService = ForumService;
@@ -0,0 +1,28 @@
1
+ import { BaseService } from './BaseService';
2
+ import { Rule } from '../models/core/Rule';
3
+ import { HttpMethod } from '../api/ApiClient';
4
+ /**
5
+ * Service for handling ARMOYU Rule-related API interactions.
6
+ */
7
+ export declare class RuleService extends BaseService {
8
+ /**
9
+ * Universal method to call rule endpoints with standardized prefix.
10
+ */
11
+ call<T>(path: string, method?: HttpMethod, body?: any): Promise<T>;
12
+ /**
13
+ * Fetches the list of rules for a specific bot/context.
14
+ */
15
+ getRules(botId?: string): Promise<Rule[]>;
16
+ /**
17
+ * Create a new rule.
18
+ */
19
+ createRule(botId: string | undefined, text: string, penalty?: string): Promise<Rule>;
20
+ /**
21
+ * Update an existing rule.
22
+ */
23
+ updateRule(botId: string | undefined, ruleId: number, data: Partial<Rule>): Promise<Rule>;
24
+ /**
25
+ * Delete a rule by its ID.
26
+ */
27
+ deleteRule(botId: string | undefined, ruleId: number): Promise<boolean>;
28
+ }
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RuleService = void 0;
4
+ const BaseService_1 = require("./BaseService");
5
+ const Rule_1 = require("../models/core/Rule");
6
+ const ApiClient_1 = require("../api/ApiClient");
7
+ /**
8
+ * Service for handling ARMOYU Rule-related API interactions.
9
+ */
10
+ class RuleService extends BaseService_1.BaseService {
11
+ /**
12
+ * Universal method to call rule endpoints with standardized prefix.
13
+ */
14
+ async call(path, method = ApiClient_1.HttpMethod.GET, body) {
15
+ const normalizedPath = path.startsWith('/') ? path : '/' + path;
16
+ // /0/0 represents the category/sub-path for bot rules
17
+ const endpoint = `/0/0${normalizedPath}`;
18
+ try {
19
+ switch (method) {
20
+ case ApiClient_1.HttpMethod.GET:
21
+ return await this.client.get(endpoint);
22
+ case ApiClient_1.HttpMethod.POST:
23
+ return await this.client.post(endpoint, body);
24
+ case ApiClient_1.HttpMethod.PUT:
25
+ return await this.client.put(endpoint, body);
26
+ case ApiClient_1.HttpMethod.PATCH:
27
+ return await this.client.patch(endpoint, body);
28
+ case ApiClient_1.HttpMethod.DELETE:
29
+ return await this.client.delete(endpoint);
30
+ default:
31
+ return await this.client.get(endpoint);
32
+ }
33
+ }
34
+ catch (error) {
35
+ console.error(`[RuleService] Request to ${path} failed:`, error);
36
+ throw error;
37
+ }
38
+ }
39
+ /**
40
+ * Fetches the list of rules for a specific bot/context.
41
+ */
42
+ async getRules(botId = '0') {
43
+ try {
44
+ const response = await this.call(`/kurallar/${botId}`, ApiClient_1.HttpMethod.POST);
45
+ const rulesData = this.handleResponse(response);
46
+ if (Array.isArray(rulesData)) {
47
+ return rulesData.map((r) => Rule_1.Rule.fromJSON(r));
48
+ }
49
+ return [];
50
+ }
51
+ catch (error) {
52
+ console.error('[RuleService] getRules failed:', error);
53
+ return [];
54
+ }
55
+ }
56
+ /**
57
+ * Create a new rule.
58
+ */
59
+ async createRule(botId = '0', text, penalty = '') {
60
+ const body = {
61
+ kuralicerik: text,
62
+ cezabaslangic: penalty
63
+ };
64
+ const response = await this.call(`/kurallar/${botId}/ekle`, ApiClient_1.HttpMethod.POST, body);
65
+ const result = this.handleResponse(response);
66
+ return Rule_1.Rule.fromJSON(result);
67
+ }
68
+ /**
69
+ * Update an existing rule.
70
+ */
71
+ async updateRule(botId = '0', ruleId, data) {
72
+ const body = {};
73
+ if (data.text)
74
+ body.kuralicerik = data.text;
75
+ if (data.penalty)
76
+ body.cezabaslangic = data.penalty;
77
+ const response = await this.call(`/kurallar/${botId}/duzenle/${ruleId}`, ApiClient_1.HttpMethod.POST, body);
78
+ const result = this.handleResponse(response);
79
+ return Rule_1.Rule.fromJSON(result);
80
+ }
81
+ /**
82
+ * Delete a rule by its ID.
83
+ */
84
+ async deleteRule(botId = '0', ruleId) {
85
+ const response = await this.call(`/kurallar/${botId}/sil/${ruleId}`, ApiClient_1.HttpMethod.POST);
86
+ const result = this.handleResponse(response);
87
+ return !!result;
88
+ }
89
+ }
90
+ exports.RuleService = RuleService;
@@ -0,0 +1,20 @@
1
+ import { Product } from '../models/shop/Product';
2
+ import { Order } from '../models/shop/Order';
3
+ import { BaseService } from './BaseService';
4
+ export declare class ShopService extends BaseService {
5
+ /**
6
+ * Get all products with optional filters.
7
+ */
8
+ getProducts(category?: string, searchTerm?: string): Promise<Product[]>;
9
+ /**
10
+ * Get detailed information for a specific product.
11
+ */
12
+ getProductDetails(productId: string): Promise<Product | null>;
13
+ /**
14
+ * Create a new purchase order.
15
+ */
16
+ createOrder(items: {
17
+ productId: number;
18
+ quantity: number;
19
+ }[]): Promise<Order>;
20
+ }
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ShopService = void 0;
4
+ const Product_1 = require("../models/shop/Product");
5
+ const Order_1 = require("../models/shop/Order");
6
+ const BaseService_1 = require("./BaseService");
7
+ class ShopService extends BaseService_1.BaseService {
8
+ /**
9
+ * Get all products with optional filters.
10
+ */
11
+ async getProducts(category, searchTerm) {
12
+ try {
13
+ const response = await this.client.get('/shop/products', {
14
+ params: { category, q: searchTerm }
15
+ });
16
+ const icerik = this.handleResponse(response);
17
+ return icerik.products.map(p => Product_1.Product.fromJSON(p));
18
+ }
19
+ catch (error) {
20
+ console.error('[ShopService] Failed to fetch products:', error);
21
+ return [];
22
+ }
23
+ }
24
+ /**
25
+ * Get detailed information for a specific product.
26
+ */
27
+ async getProductDetails(productId) {
28
+ try {
29
+ const response = await this.client.get(`/shop/products/${productId}`);
30
+ const icerik = this.handleResponse(response);
31
+ return Product_1.Product.fromJSON(icerik);
32
+ }
33
+ catch (error) {
34
+ console.error(`[ShopService] Failed to fetch product ${productId}:`, error);
35
+ return null;
36
+ }
37
+ }
38
+ /**
39
+ * Create a new purchase order.
40
+ */
41
+ async createOrder(items) {
42
+ try {
43
+ const response = await this.client.post('/shop/orders', { items });
44
+ const icerik = this.handleResponse(response);
45
+ return Order_1.Order.fromJSON(icerik.order);
46
+ }
47
+ catch (error) {
48
+ console.error('[ShopService] Order creation failed:', error);
49
+ throw error;
50
+ }
51
+ }
52
+ }
53
+ exports.ShopService = ShopService;
@@ -1,28 +1,29 @@
1
1
  import { Post } from '../models/social/Post';
2
2
  import { Notification } from '../models/social/Notification';
3
- export declare class SocialService {
3
+ import { BaseService } from './BaseService';
4
+ export declare class SocialService extends BaseService {
4
5
  /**
5
6
  * Fetch the social feed (posts from follows/groups).
6
7
  */
7
- static getFeed(page?: number): Promise<Post[]>;
8
+ getFeed(page?: number): Promise<Post[]>;
8
9
  /**
9
10
  * Create a new post.
10
11
  */
11
- static createPost(content: string, media?: any[]): Promise<Post | null>;
12
+ createPost(content: string, media?: any[]): Promise<Post | null>;
12
13
  /**
13
14
  * Like or unlike a post.
14
15
  */
15
- static toggleLike(postId: string): Promise<boolean>;
16
+ toggleLike(postId: string): Promise<boolean>;
16
17
  /**
17
18
  * Add a comment to a post.
18
19
  */
19
- static addComment(postId: string, content: string): Promise<any>;
20
+ addComment(postId: string, content: string): Promise<any>;
20
21
  /**
21
22
  * Get user notifications.
22
23
  */
23
- static getNotifications(): Promise<Notification[]>;
24
+ getNotifications(): Promise<Notification[]>;
24
25
  /**
25
26
  * Mark a notification as read.
26
27
  */
27
- static markNotificationAsRead(notificationId: string): Promise<void>;
28
+ markNotificationAsRead(notificationId: string): Promise<void>;
28
29
  }
@@ -1,18 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SocialService = void 0;
4
- const ApiClient_1 = require("../api/ApiClient");
5
4
  const Post_1 = require("../models/social/Post");
6
5
  const Notification_1 = require("../models/social/Notification");
6
+ const BaseService_1 = require("./BaseService");
7
7
  const SocketService_1 = require("./SocketService");
8
- class SocialService {
8
+ class SocialService extends BaseService_1.BaseService {
9
9
  /**
10
10
  * Fetch the social feed (posts from follows/groups).
11
11
  */
12
- static async getFeed(page = 1) {
12
+ async getFeed(page = 1) {
13
13
  try {
14
- const response = await ApiClient_1.ApiClient.get(`/social/feed?page=${page}`);
15
- return response.map(p => Post_1.Post.fromJSON(p));
14
+ const response = await this.client.get(`/0/0/sosyal/liste/${page}/`);
15
+ const icerik = this.handleResponse(response);
16
+ return icerik.map(p => Post_1.Post.fromJSON(p));
16
17
  }
17
18
  catch (error) {
18
19
  console.error('[SocialService] Fetching feed failed:', error);
@@ -22,11 +23,12 @@ class SocialService {
22
23
  /**
23
24
  * Create a new post.
24
25
  */
25
- static async createPost(content, media) {
26
+ async createPost(content, media) {
26
27
  try {
27
- const response = await ApiClient_1.ApiClient.post('/social/posts', { content, media });
28
- const post = Post_1.Post.fromJSON(response);
29
- // Notify via socket
28
+ const response = await this.client.post('/social/posts', { content, media });
29
+ const icerik = this.handleResponse(response);
30
+ const post = Post_1.Post.fromJSON(icerik);
31
+ // Notify via socket if connected
30
32
  SocketService_1.socketService.emit('post', post);
31
33
  return post;
32
34
  }
@@ -38,12 +40,13 @@ class SocialService {
38
40
  /**
39
41
  * Like or unlike a post.
40
42
  */
41
- static async toggleLike(postId) {
43
+ async toggleLike(postId) {
42
44
  try {
43
- const response = await ApiClient_1.ApiClient.post(`/social/posts/${postId}/like`, {});
45
+ const response = await this.client.post(`/social/posts/${postId}/like`, {});
46
+ const icerik = this.handleResponse(response);
44
47
  // Emit socket event for real-time update
45
- SocketService_1.socketService.emit('post_like', { postId, liked: response.liked });
46
- return response.liked;
48
+ SocketService_1.socketService.emit('post_like', { postId, liked: icerik.liked });
49
+ return icerik.liked;
47
50
  }
48
51
  catch (error) {
49
52
  console.error('[SocialService] Toggle like failed:', error);
@@ -53,10 +56,10 @@ class SocialService {
53
56
  /**
54
57
  * Add a comment to a post.
55
58
  */
56
- static async addComment(postId, content) {
59
+ async addComment(postId, content) {
57
60
  try {
58
- const response = await ApiClient_1.ApiClient.post(`/social/posts/${postId}/comments`, { content });
59
- return response;
61
+ const response = await this.client.post(`/social/posts/${postId}/comments`, { content });
62
+ return this.handleResponse(response);
60
63
  }
61
64
  catch (error) {
62
65
  console.error('[SocialService] Adding comment failed:', error);
@@ -66,10 +69,11 @@ class SocialService {
66
69
  /**
67
70
  * Get user notifications.
68
71
  */
69
- static async getNotifications() {
72
+ async getNotifications() {
70
73
  try {
71
- const response = await ApiClient_1.ApiClient.get('/social/notifications');
72
- return response.map(n => Notification_1.Notification.fromJSON(n));
74
+ const response = await this.client.get('/social/notifications');
75
+ const icerik = this.handleResponse(response);
76
+ return icerik.map(n => Notification_1.Notification.fromJSON(n));
73
77
  }
74
78
  catch (error) {
75
79
  console.error('[SocialService] Fetching notifications failed:', error);
@@ -79,9 +83,10 @@ class SocialService {
79
83
  /**
80
84
  * Mark a notification as read.
81
85
  */
82
- static async markNotificationAsRead(notificationId) {
86
+ async markNotificationAsRead(notificationId) {
83
87
  try {
84
- await ApiClient_1.ApiClient.post(`/social/notifications/${notificationId}/read`, {});
88
+ const response = await this.client.post(`/social/notifications/${notificationId}/read`, {});
89
+ this.handleResponse(response);
85
90
  }
86
91
  catch (error) {
87
92
  console.error('[SocialService] Marking notification as read failed:', error);
@@ -0,0 +1,16 @@
1
+ import { SupportTicket } from '../models/social/SupportTicket';
2
+ import { BaseService } from './BaseService';
3
+ export declare class SupportService extends BaseService {
4
+ /**
5
+ * Create a new support ticket.
6
+ */
7
+ createTicket(subject: string, message: string, category: string): Promise<SupportTicket>;
8
+ /**
9
+ * Get all tickets for the authenticated user.
10
+ */
11
+ getMyTickets(): Promise<SupportTicket[]>;
12
+ /**
13
+ * Get a single ticket details and its messages.
14
+ */
15
+ getTicketDetails(ticketId: string): Promise<SupportTicket | null>;
16
+ }
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SupportService = void 0;
4
+ const SupportTicket_1 = require("../models/social/SupportTicket");
5
+ const BaseService_1 = require("./BaseService");
6
+ class SupportService extends BaseService_1.BaseService {
7
+ /**
8
+ * Create a new support ticket.
9
+ */
10
+ async createTicket(subject, message, category) {
11
+ try {
12
+ const response = await this.client.post('/social/support/tickets', {
13
+ subject,
14
+ message,
15
+ category
16
+ });
17
+ const icerik = this.handleResponse(response);
18
+ return SupportTicket_1.SupportTicket.fromJSON(icerik.ticket);
19
+ }
20
+ catch (error) {
21
+ console.error('[SupportService] Failed to create ticket:', error);
22
+ throw error;
23
+ }
24
+ }
25
+ /**
26
+ * Get all tickets for the authenticated user.
27
+ */
28
+ async getMyTickets() {
29
+ try {
30
+ const response = await this.client.get('/social/support/my-tickets');
31
+ const icerik = this.handleResponse(response);
32
+ return icerik.tickets.map(t => SupportTicket_1.SupportTicket.fromJSON(t));
33
+ }
34
+ catch (error) {
35
+ console.error('[SupportService] Failed to fetch user tickets:', error);
36
+ return [];
37
+ }
38
+ }
39
+ /**
40
+ * Get a single ticket details and its messages.
41
+ */
42
+ async getTicketDetails(ticketId) {
43
+ try {
44
+ const response = await this.client.get(`/social/support/tickets/${ticketId}`);
45
+ const icerik = this.handleResponse(response);
46
+ return SupportTicket_1.SupportTicket.fromJSON(icerik);
47
+ }
48
+ catch (error) {
49
+ console.error(`[SupportService] Failed to fetch ticket ${ticketId}:`, error);
50
+ return null;
51
+ }
52
+ }
53
+ }
54
+ exports.SupportService = SupportService;
@@ -1,23 +1,28 @@
1
1
  import { User } from '../models/auth/User';
2
- export declare class UserService {
2
+ import { BaseService } from './BaseService';
3
+ export declare class UserService extends BaseService {
4
+ constructor(client: any);
3
5
  /**
4
6
  * Search for users based on a query string.
5
7
  */
6
- static search(query: string): Promise<User[]>;
8
+ search(query: string): Promise<User[]>;
7
9
  /**
8
- * Get a specific user's public profile.
10
+ * Get a specific user's public profile using the bot API.
11
+ */
12
+ getUserByUsername(username: string): Promise<User | null>;
13
+ /**
14
+ * Get a specific user's public profile (Legacy API).
9
15
  */
10
- static getProfile(username: string): Promise<User | null>;
11
16
  /**
12
17
  * Follow or unfollow a user.
13
18
  */
14
- static toggleFollow(userId: string): Promise<boolean>;
19
+ toggleFollow(userId: string): Promise<boolean>;
15
20
  /**
16
21
  * Get a user's friends list.
17
22
  */
18
- static getFriends(userId: string): Promise<User[]>;
23
+ getFriends(userId: string): Promise<User[]>;
19
24
  /**
20
25
  * Update the current user's profile information.
21
26
  */
22
- static updateProfile(data: Partial<User>): Promise<User | null>;
27
+ updateProfile(data: Partial<User>): Promise<User | null>;
23
28
  }
@@ -1,16 +1,23 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.UserService = void 0;
4
- const ApiClient_1 = require("../api/ApiClient");
5
4
  const User_1 = require("../models/auth/User");
6
- class UserService {
5
+ const BaseService_1 = require("./BaseService");
6
+ class UserService extends BaseService_1.BaseService {
7
+ constructor(client) {
8
+ super(client);
9
+ console.log('[UserService] Initialized with methods:', Object.getOwnPropertyNames(UserService.prototype));
10
+ }
7
11
  /**
8
12
  * Search for users based on a query string.
9
13
  */
10
- static async search(query) {
14
+ async search(query) {
11
15
  try {
12
- const response = await ApiClient_1.ApiClient.get(`/users/search?q=${encodeURIComponent(query)}`);
13
- return Array.isArray(response) ? response.map((u) => User_1.User.fromJSON(u)) : [];
16
+ const response = await this.client.get(`/users/search`, {
17
+ params: { q: query }
18
+ });
19
+ const icerik = this.handleResponse(response);
20
+ return Array.isArray(icerik) ? icerik.map((u) => User_1.User.fromJSON(u)) : [];
14
21
  }
15
22
  catch (error) {
16
23
  console.error('[UserService] User search failed:', error);
@@ -18,25 +25,33 @@ class UserService {
18
25
  }
19
26
  }
20
27
  /**
21
- * Get a specific user's public profile.
28
+ * Get a specific user's public profile using the bot API.
22
29
  */
23
- static async getProfile(username) {
30
+ async getUserByUsername(username) {
31
+ console.log('[UserService] Getting profile for:', username);
24
32
  try {
25
- const response = await ApiClient_1.ApiClient.get(`/users/${username}`);
26
- return response ? User_1.User.fromJSON(response) : null;
33
+ const formData = new FormData();
34
+ formData.append('oyuncubakusername', username);
35
+ const response = await this.client.post('/0/0/0/', formData);
36
+ const icerik = this.handleResponse(response);
37
+ return icerik ? User_1.User.fromJSON(icerik) : null;
27
38
  }
28
39
  catch (error) {
29
40
  console.error(`[UserService] Fetching profile for ${username} failed:`, error);
30
41
  return null;
31
42
  }
32
43
  }
44
+ /**
45
+ * Get a specific user's public profile (Legacy API).
46
+ */
33
47
  /**
34
48
  * Follow or unfollow a user.
35
49
  */
36
- static async toggleFollow(userId) {
50
+ async toggleFollow(userId) {
37
51
  try {
38
- const response = await ApiClient_1.ApiClient.post(`/users/${userId}/follow`, {});
39
- return response.following;
52
+ const response = await this.client.post(`/users/${userId}/follow`, {});
53
+ const icerik = this.handleResponse(response);
54
+ return icerik.following;
40
55
  }
41
56
  catch (error) {
42
57
  console.error('[UserService] Toggle follow failed:', error);
@@ -46,10 +61,11 @@ class UserService {
46
61
  /**
47
62
  * Get a user's friends list.
48
63
  */
49
- static async getFriends(userId) {
64
+ async getFriends(userId) {
50
65
  try {
51
- const response = await ApiClient_1.ApiClient.get(`/users/${userId}/friends`);
52
- return Array.isArray(response) ? response.map((u) => User_1.User.fromJSON(u)) : [];
66
+ const response = await this.client.get(`/users/${userId}/friends`);
67
+ const icerik = this.handleResponse(response);
68
+ return Array.isArray(icerik) ? icerik.map((u) => User_1.User.fromJSON(u)) : [];
53
69
  }
54
70
  catch (error) {
55
71
  console.error('[UserService] Get friends failed:', error);
@@ -59,10 +75,11 @@ class UserService {
59
75
  /**
60
76
  * Update the current user's profile information.
61
77
  */
62
- static async updateProfile(data) {
78
+ async updateProfile(data) {
63
79
  try {
64
- const response = await ApiClient_1.ApiClient.post('/users/me/update', data);
65
- return response ? User_1.User.fromJSON(response) : null;
80
+ const response = await this.client.post('/users/me/update', data);
81
+ const icerik = this.handleResponse(response);
82
+ return icerik ? User_1.User.fromJSON(icerik) : null;
66
83
  }
67
84
  catch (error) {
68
85
  console.error('[UserService] Update profile failed:', error);
package/package.json CHANGED
@@ -1,21 +1,27 @@
1
- {
2
- "name": "@armoyu/core",
3
- "version": "1.0.0",
4
- "description": "Core business logic, models, and services for ARMOYU platforms.",
5
- "main": "dist/index.js",
6
- "module": "dist/index.js",
7
- "types": "dist/index.d.ts",
8
- "publishConfig": {
9
- "access": "public"
10
- },
11
- "scripts": {
12
- "build": "tsc",
13
- "dev": "tsc --watch"
14
- },
15
- "dependencies": {
16
- "socket.io-client": "^4.8.1"
17
- },
18
- "devDependencies": {
19
- "typescript": "^5.0.0"
20
- }
21
- }
1
+ {
2
+ "name": "@armoyu/core",
3
+ "version": "1.0.1",
4
+ "description": "Core business logic, models, and services for ARMOYU platforms.",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "publishConfig": {
9
+ "access": "public"
10
+ },
11
+ "files": [
12
+ "dist/"
13
+ ],
14
+ "scripts": {
15
+ "build": "tsc",
16
+ "dev": "cd examples/console && npm run dev",
17
+ "build:bundle": "esbuild src/index.ts --bundle --outfile=dist/armoyu-core.bundle.js --platform=browser --global-name=ArmoyuCore --minify",
18
+ "build:watch": "tsc --watch"
19
+ },
20
+ "dependencies": {
21
+ "socket.io-client": "^4.8.1"
22
+ },
23
+ "devDependencies": {
24
+ "esbuild": "^0.28.0",
25
+ "typescript": "^5.0.0"
26
+ }
27
+ }