@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
@@ -1,32 +0,0 @@
1
- /**
2
- * Represents a Store Item (Mağaza Eşyası/Ürün) in the aramizdakioyuncu.com platform.
3
- */
4
- export class StoreItem {
5
- id: string = '';
6
- name: string = '';
7
- category: string = '';
8
- price: string = '';
9
- image: string = '';
10
- isFeatured: boolean = false;
11
- badge: string = '';
12
-
13
- constructor(data: Partial<StoreItem>) {
14
- Object.assign(this, data);
15
- }
16
-
17
- /**
18
- * Instantiates a StoreItem object from a JSON object.
19
- */
20
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
21
- static fromJSON(json: Record<string, any>): StoreItem {
22
- return new StoreItem({
23
- id: json.id || '',
24
- name: json.name || json.title || '',
25
- category: json.category || '',
26
- price: json.price || '',
27
- image: json.image || '',
28
- isFeatured: json.isFeatured || false,
29
- badge: json.badge || '',
30
- });
31
- }
32
- }
@@ -1,91 +0,0 @@
1
- import { ApiClient } from '../api/ApiClient';
2
- import { User } from '../models/auth/User';
3
- import { Session } from '../models/auth/Session';
4
-
5
-
6
- export class AuthService {
7
- private static currentUser: User | null = null;
8
- private static session: Session | null = null;
9
-
10
- /**
11
- * Authenticate a user with username and password.
12
- */
13
- static async login(username: string, password: string): Promise<{ user: User; session: Session }> {
14
- try {
15
- const response = await ApiClient.post<{ user: any; session: any }>('/auth/login', {
16
- username,
17
- password
18
- });
19
-
20
- this.currentUser = User.fromJSON(response.user);
21
- this.session = Session.fromJSON(response.session);
22
-
23
- // Store token in localStorage if available
24
- if (typeof window !== 'undefined' && this.session.token) {
25
- localStorage.setItem('armoyu_token', this.session.token);
26
- }
27
-
28
- return { user: this.currentUser, session: this.session };
29
- } catch (error) {
30
- console.error('[AuthService] Login failed:', error);
31
- throw error;
32
- }
33
- }
34
-
35
- /**
36
- * Register a new user.
37
- */
38
- static async register(data: any): Promise<{ user: User }> {
39
- try {
40
- const response = await ApiClient.post<{ user: any }>('/auth/register', data);
41
- return { user: User.fromJSON(response.user) };
42
- } catch (error) {
43
- console.error('[AuthService] Registration failed:', error);
44
- throw error;
45
- }
46
- }
47
-
48
- /**
49
- * Logout the current user.
50
- */
51
- static async logout(): Promise<void> {
52
- try {
53
- await ApiClient.post('/auth/logout', {});
54
- } catch (error) {
55
- console.error('[AuthService] Logout API call failed:', error);
56
- } finally {
57
- this.currentUser = null;
58
- this.session = null;
59
- if (typeof window !== 'undefined') {
60
- localStorage.removeItem('armoyu_token');
61
- }
62
- }
63
- }
64
-
65
- /**
66
- * Get the currently authenticated user's profile.
67
- */
68
- static async me(): Promise<User | null> {
69
- try {
70
- if (this.currentUser) return this.currentUser;
71
-
72
- const response = await ApiClient.get<{ user: any }>('/auth/me');
73
- this.currentUser = User.fromJSON(response.user);
74
- return this.currentUser;
75
- } catch (error) {
76
- return null;
77
- }
78
- }
79
-
80
- static getCurrentUser(): User | null {
81
- return this.currentUser;
82
- }
83
-
84
- static getSession(): Session | null {
85
- return this.session;
86
- }
87
-
88
- static isAuthenticated(): boolean {
89
- return !!this.currentUser;
90
- }
91
- }
@@ -1,92 +0,0 @@
1
- import { ApiClient } from '../api/ApiClient';
2
- import { Post } from '../models/social/Post';
3
- import { Notification } from '../models/social/Notification';
4
- import { socketService } from './SocketService';
5
-
6
-
7
- export class SocialService {
8
- /**
9
- * Fetch the social feed (posts from follows/groups).
10
- */
11
- static async getFeed(page: number = 1): Promise<Post[]> {
12
- try {
13
- const response = await ApiClient.get<any[]>(`/social/feed?page=${page}`);
14
- return response.map(p => Post.fromJSON(p));
15
- } catch (error) {
16
- console.error('[SocialService] Fetching feed failed:', error);
17
- return [];
18
- }
19
- }
20
-
21
- /**
22
- * Create a new post.
23
- */
24
- static async createPost(content: string, media?: any[]): Promise<Post | null> {
25
- try {
26
- const response = await ApiClient.post<any>('/social/posts', { content, media });
27
- const post = Post.fromJSON(response);
28
-
29
- // Notify via socket
30
- socketService.emit('post', post);
31
-
32
- return post;
33
- } catch (error) {
34
- console.error('[SocialService] Creating post failed:', error);
35
- return null;
36
- }
37
- }
38
-
39
- /**
40
- * Like or unlike a post.
41
- */
42
- static async toggleLike(postId: string): Promise<boolean> {
43
- try {
44
- const response = await ApiClient.post<{ liked: boolean }>(`/social/posts/${postId}/like`, {});
45
-
46
- // Emit socket event for real-time update
47
- socketService.emit('post_like', { postId, liked: response.liked });
48
-
49
- return response.liked;
50
- } catch (error) {
51
- console.error('[SocialService] Toggle like failed:', error);
52
- return false;
53
- }
54
- }
55
-
56
- /**
57
- * Add a comment to a post.
58
- */
59
- static async addComment(postId: string, content: string): Promise<any> {
60
- try {
61
- const response = await ApiClient.post<any>(`/social/posts/${postId}/comments`, { content });
62
- return response;
63
- } catch (error) {
64
- console.error('[SocialService] Adding comment failed:', error);
65
- return null;
66
- }
67
- }
68
-
69
- /**
70
- * Get user notifications.
71
- */
72
- static async getNotifications(): Promise<Notification[]> {
73
- try {
74
- const response = await ApiClient.get<any[]>('/social/notifications');
75
- return response.map(n => Notification.fromJSON(n));
76
- } catch (error) {
77
- console.error('[SocialService] Fetching notifications failed:', error);
78
- return [];
79
- }
80
- }
81
-
82
- /**
83
- * Mark a notification as read.
84
- */
85
- static async markNotificationAsRead(notificationId: string): Promise<void> {
86
- try {
87
- await ApiClient.post(`/social/notifications/${notificationId}/read`, {});
88
- } catch (error) {
89
- console.error('[SocialService] Marking notification as read failed:', error);
90
- }
91
- }
92
- }
@@ -1,112 +0,0 @@
1
- export type SocketEvent =
2
- | 'message'
3
- | 'status'
4
- | 'typing'
5
- | 'notification'
6
- | 'post'
7
- | 'post_like'
8
- | 'post_repost_count'
9
- | 'connect'
10
- | 'disconnect';
11
-
12
- type SocketListener = (data: unknown) => void;
13
-
14
- /**
15
- * A production-ready WebSocket service for the ARMOYU platform.
16
- * Connects to the standalone armoyu-socket-server.
17
- */
18
- class SocketService {
19
- private socket: unknown = null;
20
- public isConnected: boolean = false;
21
- private listeners: Map<SocketEvent, SocketListener[]> = new Map();
22
- private socketUrl: string = 'https://socket.armoyu.com';
23
-
24
- constructor() {
25
- // Initialize only on the client side
26
- if (typeof window !== 'undefined') {
27
- this.connect();
28
- }
29
- }
30
-
31
- setSocketUrl(url: string) {
32
- this.socketUrl = url;
33
- }
34
-
35
- private async connect() {
36
- try {
37
- // Dynamic import to avoid SSR issues
38
- const { io } = await import('socket.io-client');
39
- console.log('[SocketService] Connecting to socket server...');
40
-
41
- const sock = io(this.socketUrl, {
42
- transports: ['websocket'],
43
- reconnection: true,
44
- reconnectionAttempts: 10,
45
- });
46
-
47
- this.socket = sock;
48
-
49
- sock.on('connect', () => {
50
- console.log('[SocketService] Connected! ID:', sock.id);
51
- this.isConnected = true;
52
- this.emitInternal('connect', { status: 'online', socketId: sock.id });
53
- });
54
-
55
- sock.on('disconnect', () => {
56
- console.log('[SocketService] Disconnected.');
57
- this.isConnected = false;
58
- this.emitInternal('disconnect', { status: 'offline' });
59
- });
60
-
61
- const events: SocketEvent[] = [
62
- 'message',
63
- 'typing',
64
- 'notification',
65
- 'status',
66
- 'post',
67
- 'post_like',
68
- 'post_repost_count',
69
- ];
70
-
71
- events.forEach((event) => {
72
- sock.on(event, (data: unknown) => {
73
- this.emitInternal(event, data);
74
- });
75
- });
76
- } catch (err) {
77
- console.error('[SocketService] Connection failed:', err);
78
- }
79
- }
80
-
81
- private emitInternal(event: SocketEvent, data: unknown) {
82
- const handlers = this.listeners.get(event) || [];
83
- handlers.forEach((cb) => cb(data));
84
- }
85
-
86
- on(event: SocketEvent, callback: SocketListener): () => void {
87
- if (!this.listeners.has(event)) {
88
- this.listeners.set(event, []);
89
- }
90
- this.listeners.get(event)!.push(callback);
91
-
92
- if (event === 'connect' && this.isConnected) {
93
- callback({ status: 'online', alreadyConnected: true });
94
- }
95
-
96
- return () => {
97
- const cbs = this.listeners.get(event) || [];
98
- this.listeners.set(event, cbs.filter((cb) => cb !== callback));
99
- };
100
- }
101
-
102
- emit(event: SocketEvent, data: unknown) {
103
- const sock = this.socket as { connected: boolean; emit: (e: string, d: unknown) => void } | null;
104
- if (sock && (this.isConnected || sock.connected)) {
105
- sock.emit(event, data);
106
- } else {
107
- console.warn(`[SocketService] Cannot emit '${event}', not connected.`);
108
- }
109
- }
110
- }
111
-
112
- export const socketService = new SocketService();
@@ -1,69 +0,0 @@
1
- import { ApiClient } from '../api/ApiClient';
2
- import { User } from '../models/auth/User';
3
-
4
- export class UserService {
5
- /**
6
- * Search for users based on a query string.
7
- */
8
- static async search(query: string): Promise<User[]> {
9
- try {
10
- const response = await ApiClient.get<any[]>(`/users/search?q=${encodeURIComponent(query)}`);
11
- return Array.isArray(response) ? response.map((u: any) => User.fromJSON(u)) : [];
12
- } catch (error) {
13
- console.error('[UserService] User search failed:', error);
14
- return [];
15
- }
16
- }
17
-
18
- /**
19
- * Get a specific user's public profile.
20
- */
21
- static async getProfile(username: string): Promise<User | null> {
22
- try {
23
- const response = await ApiClient.get<any>(`/users/${username}`);
24
- return response ? User.fromJSON(response) : null;
25
- } catch (error) {
26
- console.error(`[UserService] Fetching profile for ${username} failed:`, error);
27
- return null;
28
- }
29
- }
30
-
31
- /**
32
- * Follow or unfollow a user.
33
- */
34
- static async toggleFollow(userId: string): Promise<boolean> {
35
- try {
36
- const response = await ApiClient.post<{ following: boolean }>(`/users/${userId}/follow`, {});
37
- return response.following;
38
- } catch (error) {
39
- console.error('[UserService] Toggle follow failed:', error);
40
- return false;
41
- }
42
- }
43
-
44
- /**
45
- * Get a user's friends list.
46
- */
47
- static async getFriends(userId: string): Promise<User[]> {
48
- try {
49
- const response = await ApiClient.get<any[]>(`/users/${userId}/friends`);
50
- return Array.isArray(response) ? response.map((u: any) => User.fromJSON(u)) : [];
51
- } catch (error) {
52
- console.error('[UserService] Get friends failed:', error);
53
- return [];
54
- }
55
- }
56
-
57
- /**
58
- * Update the current user's profile information.
59
- */
60
- static async updateProfile(data: Partial<User>): Promise<User | null> {
61
- try {
62
- const response = await ApiClient.post<any>('/users/me/update', data);
63
- return response ? User.fromJSON(response) : null;
64
- } catch (error) {
65
- console.error('[UserService] Update profile failed:', error);
66
- return null;
67
- }
68
- }
69
- }
@@ -1,17 +0,0 @@
1
- /**
2
- * Global Statistics Interface
3
- * Bu arayüz, sitemizin genelindeki tüm sayısal verileri tutmak için tasarlanmıştır.
4
- * İlerleyen aşamalarda bu veriler backend API üzerinden dinamik olarak beslenecektir.
5
- */
6
- export interface GlobalStats {
7
- totalPlayers: number;
8
- malePlayers: number;
9
- femalePlayers: number;
10
- totalForums: number;
11
- totalPolls: number;
12
- activeUsers24h: number;
13
- totalMatchesPlayed: number;
14
- totalGuilds: number;
15
- monthlyVisitors: number;
16
- totalNews: number;
17
- }
package/tsconfig.json DELETED
@@ -1,16 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2019",
4
- "module": "CommonJS",
5
- "moduleResolution": "Node",
6
- "declaration": true,
7
- "outDir": "./dist",
8
- "rootDir": "./src",
9
- "strict": true,
10
- "esModuleInterop": true,
11
- "skipLibCheck": true
12
- },
13
- "include": [
14
- "src"
15
- ]
16
- }