@armoyu/core 1.0.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/api/ApiClient.d.ts +16 -0
- package/dist/api/ApiClient.d.ts.map +1 -0
- package/dist/api/ApiClient.js +50 -0
- package/dist/api/ApiClient.js.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -0
- package/dist/models/auth/Role.d.ts +14 -0
- package/dist/models/auth/Role.d.ts.map +1 -0
- package/dist/models/auth/Role.js +28 -0
- package/dist/models/auth/Role.js.map +1 -0
- package/dist/models/auth/Session.d.ts +23 -0
- package/dist/models/auth/Session.d.ts.map +1 -0
- package/dist/models/auth/Session.js +43 -0
- package/dist/models/auth/Session.js.map +1 -0
- package/dist/models/auth/User.d.ts +52 -0
- package/dist/models/auth/User.d.ts.map +1 -0
- package/dist/models/auth/User.js +98 -0
- package/dist/models/auth/User.js.map +1 -0
- package/dist/models/community/Classroom.d.ts +18 -0
- package/dist/models/community/Classroom.d.ts.map +1 -0
- package/dist/models/community/Classroom.js +35 -0
- package/dist/models/community/Classroom.js.map +1 -0
- package/dist/models/community/Event.d.ts +26 -0
- package/dist/models/community/Event.d.ts.map +1 -0
- package/dist/models/community/Event.js +34 -0
- package/dist/models/community/Event.js.map +1 -0
- package/dist/models/community/Faculty.d.ts +16 -0
- package/dist/models/community/Faculty.d.ts.map +1 -0
- package/dist/models/community/Faculty.js +31 -0
- package/dist/models/community/Faculty.js.map +1 -0
- package/dist/models/community/Forum.d.ts +25 -0
- package/dist/models/community/Forum.d.ts.map +1 -0
- package/dist/models/community/Forum.js +37 -0
- package/dist/models/community/Forum.js.map +1 -0
- package/dist/models/community/Giveaway.d.ts +21 -0
- package/dist/models/community/Giveaway.d.ts.map +1 -0
- package/dist/models/community/Giveaway.js +40 -0
- package/dist/models/community/Giveaway.js.map +1 -0
- package/dist/models/community/Group.d.ts +37 -0
- package/dist/models/community/Group.d.ts.map +1 -0
- package/dist/models/community/Group.js +77 -0
- package/dist/models/community/Group.js.map +1 -0
- package/dist/models/community/School.d.ts +27 -0
- package/dist/models/community/School.d.ts.map +1 -0
- package/dist/models/community/School.js +50 -0
- package/dist/models/community/School.js.map +1 -0
- package/dist/models/community/SchoolTeam.d.ts +26 -0
- package/dist/models/community/SchoolTeam.d.ts.map +1 -0
- package/dist/models/community/SchoolTeam.js +43 -0
- package/dist/models/community/SchoolTeam.js.map +1 -0
- package/dist/models/community/Station.d.ts +68 -0
- package/dist/models/community/Station.d.ts.map +1 -0
- package/dist/models/community/Station.js +130 -0
- package/dist/models/community/Station.js.map +1 -0
- package/dist/models/community/Survey.d.ts +26 -0
- package/dist/models/community/Survey.d.ts.map +1 -0
- package/dist/models/community/Survey.js +53 -0
- package/dist/models/community/Survey.js.map +1 -0
- package/dist/models/community/SurveyAnswer.d.ts +14 -0
- package/dist/models/community/SurveyAnswer.d.ts.map +1 -0
- package/dist/models/community/SurveyAnswer.js +28 -0
- package/dist/models/community/SurveyAnswer.js.map +1 -0
- package/dist/models/community/Team.d.ts +12 -0
- package/dist/models/community/Team.d.ts.map +1 -0
- package/dist/models/community/Team.js +26 -0
- package/dist/models/community/Team.js.map +1 -0
- package/dist/models/community/Workplace.d.ts +17 -0
- package/dist/models/community/Workplace.d.ts.map +1 -0
- package/dist/models/community/Workplace.js +34 -0
- package/dist/models/community/Workplace.js.map +1 -0
- package/dist/models/content/Game.d.ts +18 -0
- package/dist/models/content/Game.d.ts.map +1 -0
- package/dist/models/content/Game.js +41 -0
- package/dist/models/content/Game.js.map +1 -0
- package/dist/models/content/Media.d.ts +16 -0
- package/dist/models/content/Media.d.ts.map +1 -0
- package/dist/models/content/Media.js +32 -0
- package/dist/models/content/Media.js.map +1 -0
- package/dist/models/content/Mod.d.ts +20 -0
- package/dist/models/content/Mod.d.ts.map +1 -0
- package/dist/models/content/Mod.js +39 -0
- package/dist/models/content/Mod.js.map +1 -0
- package/dist/models/content/News.d.ts +23 -0
- package/dist/models/content/News.d.ts.map +1 -0
- package/dist/models/content/News.js +43 -0
- package/dist/models/content/News.js.map +1 -0
- package/dist/models/content/Project.d.ts +26 -0
- package/dist/models/content/Project.d.ts.map +1 -0
- package/dist/models/content/Project.js +45 -0
- package/dist/models/content/Project.js.map +1 -0
- package/dist/models/core/PlatformStats.d.ts +41 -0
- package/dist/models/core/PlatformStats.d.ts.map +1 -0
- package/dist/models/core/PlatformStats.js +61 -0
- package/dist/models/core/PlatformStats.js.map +1 -0
- package/dist/models/core/SystemSettings.d.ts +33 -0
- package/dist/models/core/SystemSettings.d.ts.map +1 -0
- package/dist/models/core/SystemSettings.js +42 -0
- package/dist/models/core/SystemSettings.js.map +1 -0
- package/dist/models/index.d.ts +37 -0
- package/dist/models/index.d.ts.map +1 -0
- package/dist/models/index.js +53 -0
- package/dist/models/index.js.map +1 -0
- package/dist/models/shop/CartItem.d.ts +13 -0
- package/dist/models/shop/CartItem.d.ts.map +1 -0
- package/dist/models/shop/CartItem.js +27 -0
- package/dist/models/shop/CartItem.js.map +1 -0
- package/dist/models/shop/Order.d.ts +19 -0
- package/dist/models/shop/Order.d.ts.map +1 -0
- package/dist/models/shop/Order.js +40 -0
- package/dist/models/shop/Order.js.map +1 -0
- package/dist/models/shop/Product.d.ts +19 -0
- package/dist/models/shop/Product.d.ts.map +1 -0
- package/dist/models/shop/Product.js +52 -0
- package/dist/models/shop/Product.js.map +1 -0
- package/dist/models/social/Chat.d.ts +25 -0
- package/dist/models/social/Chat.d.ts.map +1 -0
- package/dist/models/social/Chat.js +48 -0
- package/dist/models/social/Chat.js.map +1 -0
- package/dist/models/social/ChatMessage.d.ts +16 -0
- package/dist/models/social/ChatMessage.d.ts.map +1 -0
- package/dist/models/social/ChatMessage.js +31 -0
- package/dist/models/social/ChatMessage.js.map +1 -0
- package/dist/models/social/Comment.d.ts +20 -0
- package/dist/models/social/Comment.d.ts.map +1 -0
- package/dist/models/social/Comment.js +38 -0
- package/dist/models/social/Comment.js.map +1 -0
- package/dist/models/social/Group.d.ts +30 -0
- package/dist/models/social/Group.d.ts.map +1 -0
- package/dist/models/social/Group.js +66 -0
- package/dist/models/social/Group.js.map +1 -0
- package/dist/models/social/Leaderboard.d.ts +24 -0
- package/dist/models/social/Leaderboard.d.ts.map +1 -0
- package/dist/models/social/Leaderboard.js +56 -0
- package/dist/models/social/Leaderboard.js.map +1 -0
- package/dist/models/social/Note.d.ts +15 -0
- package/dist/models/social/Note.d.ts.map +1 -0
- package/dist/models/social/Note.js +29 -0
- package/dist/models/social/Note.js.map +1 -0
- package/dist/models/social/Notification.d.ts +30 -0
- package/dist/models/social/Notification.d.ts.map +1 -0
- package/dist/models/social/Notification.js +88 -0
- package/dist/models/social/Notification.js.map +1 -0
- package/dist/models/social/NotificationSender.d.ts +18 -0
- package/dist/models/social/NotificationSender.d.ts.map +1 -0
- package/dist/models/social/NotificationSender.js +27 -0
- package/dist/models/social/NotificationSender.js.map +1 -0
- package/dist/models/social/Post.d.ts +41 -0
- package/dist/models/social/Post.d.ts.map +1 -0
- package/dist/models/social/Post.js +53 -0
- package/dist/models/social/Post.js.map +1 -0
- package/dist/models/social/Story.d.ts +16 -0
- package/dist/models/social/Story.d.ts.map +1 -0
- package/dist/models/social/Story.js +31 -0
- package/dist/models/social/Story.js.map +1 -0
- package/dist/models/social/SupportTicket.d.ts +20 -0
- package/dist/models/social/SupportTicket.d.ts.map +1 -0
- package/dist/models/social/SupportTicket.js +38 -0
- package/dist/models/social/SupportTicket.js.map +1 -0
- package/dist/models/store/StoreItem.d.ts +17 -0
- package/dist/models/store/StoreItem.d.ts.map +1 -0
- package/dist/models/store/StoreItem.js +34 -0
- package/dist/models/store/StoreItem.js.map +1 -0
- package/dist/services/AuthService.d.ts +30 -0
- package/dist/services/AuthService.d.ts.map +1 -0
- package/dist/services/AuthService.js +88 -0
- package/dist/services/AuthService.js.map +1 -0
- package/dist/services/SocialService.d.ts +28 -0
- package/dist/services/SocialService.d.ts.map +1 -0
- package/dist/services/SocialService.js +91 -0
- package/dist/services/SocialService.js.map +1 -0
- package/dist/services/SocketService.d.ts +20 -0
- package/dist/services/SocketService.d.ts.map +1 -0
- package/dist/services/SocketService.js +122 -0
- package/dist/services/SocketService.js.map +1 -0
- package/dist/services/UserService.d.ts +23 -0
- package/dist/services/UserService.d.ts.map +1 -0
- package/dist/services/UserService.js +73 -0
- package/dist/services/UserService.js.map +1 -0
- package/dist/types/stats.d.ts +17 -0
- package/dist/types/stats.d.ts.map +1 -0
- package/dist/types/stats.js +2 -0
- package/dist/types/stats.js.map +1 -0
- package/package.json +21 -0
- package/src/api/ApiClient.ts +57 -0
- package/src/index.ts +24 -0
- package/src/models/auth/Role.ts +26 -0
- package/src/models/auth/Session.ts +50 -0
- package/src/models/auth/User.ts +111 -0
- package/src/models/community/Classroom.ts +34 -0
- package/src/models/community/Event.ts +32 -0
- package/src/models/community/Faculty.ts +30 -0
- package/src/models/community/Forum.ts +42 -0
- package/src/models/community/Giveaway.ts +39 -0
- package/src/models/community/Group.ts +78 -0
- package/src/models/community/School.ts +51 -0
- package/src/models/community/SchoolTeam.ts +49 -0
- package/src/models/community/Station.ts +145 -0
- package/src/models/community/Survey.ts +53 -0
- package/src/models/community/SurveyAnswer.ts +26 -0
- package/src/models/community/Team.ts +24 -0
- package/src/models/community/Workplace.ts +32 -0
- package/src/models/content/Game.ts +39 -0
- package/src/models/content/Media.ts +30 -0
- package/src/models/content/Mod.ts +38 -0
- package/src/models/content/News.ts +43 -0
- package/src/models/content/Project.ts +49 -0
- package/src/models/core/PlatformStats.ts +74 -0
- package/src/models/core/SystemSettings.ts +59 -0
- package/src/models/index.ts +37 -0
- package/src/models/shop/CartItem.ts +31 -0
- package/src/models/shop/Order.ts +48 -0
- package/src/models/shop/Product.ts +61 -0
- package/src/models/social/Chat.ts +47 -0
- package/src/models/social/ChatMessage.ts +30 -0
- package/src/models/social/Comment.ts +38 -0
- package/src/models/social/Group.ts +63 -0
- package/src/models/social/Leaderboard.ts +57 -0
- package/src/models/social/Note.ts +28 -0
- package/src/models/social/Notification.ts +99 -0
- package/src/models/social/NotificationSender.ts +36 -0
- package/src/models/social/Post.ts +75 -0
- package/src/models/social/Story.ts +30 -0
- package/src/models/social/SupportTicket.ts +38 -0
- package/src/models/store/StoreItem.ts +32 -0
- package/src/services/AuthService.ts +91 -0
- package/src/services/SocialService.ts +92 -0
- package/src/services/SocketService.ts +112 -0
- package/src/services/UserService.ts +69 -0
- package/src/types/stats.ts +17 -0
- package/tsconfig.json +16 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export * from './auth/User';
|
|
2
|
+
export * from './auth/Role';
|
|
3
|
+
export * from './auth/Session';
|
|
4
|
+
export * from './social/Post';
|
|
5
|
+
export * from './social/Comment';
|
|
6
|
+
export * from './social/Story';
|
|
7
|
+
export * from './social/Chat';
|
|
8
|
+
export * from './social/ChatMessage';
|
|
9
|
+
export * from './social/Notification';
|
|
10
|
+
export * from './social/NotificationSender';
|
|
11
|
+
export * from './social/Note';
|
|
12
|
+
export * from './social/Leaderboard';
|
|
13
|
+
export * from './community/Group';
|
|
14
|
+
export * from './community/Giveaway';
|
|
15
|
+
export * from './community/Forum';
|
|
16
|
+
export * from './community/Workplace';
|
|
17
|
+
export * from './community/Event';
|
|
18
|
+
export * from './community/Station';
|
|
19
|
+
export * from './community/Survey';
|
|
20
|
+
export * from './community/SurveyAnswer';
|
|
21
|
+
export * from './community/School';
|
|
22
|
+
export * from './community/Faculty';
|
|
23
|
+
export * from './community/Classroom';
|
|
24
|
+
export * from './community/SchoolTeam';
|
|
25
|
+
export * from './community/Team';
|
|
26
|
+
export * from './store/StoreItem';
|
|
27
|
+
export * from './shop/Product';
|
|
28
|
+
export * from './shop/Order';
|
|
29
|
+
export * from './shop/CartItem';
|
|
30
|
+
export * from './core/PlatformStats';
|
|
31
|
+
export * from './core/SystemSettings';
|
|
32
|
+
export * from './social/SupportTicket';
|
|
33
|
+
export * from './content/Game';
|
|
34
|
+
export * from './content/Media';
|
|
35
|
+
export * from './content/Mod';
|
|
36
|
+
export * from './content/News';
|
|
37
|
+
export * from './content/Project';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Product } from './Product';
|
|
2
|
+
|
|
3
|
+
export class CartItem {
|
|
4
|
+
id: string; // Internal unique ID for the cart item
|
|
5
|
+
product: Product;
|
|
6
|
+
quantity: number;
|
|
7
|
+
addedAt: number;
|
|
8
|
+
|
|
9
|
+
constructor(data: Partial<CartItem>) {
|
|
10
|
+
this.product = data.product || new Product({});
|
|
11
|
+
this.id = data.id || `cart_${this.product.id}_${Date.now()}`;
|
|
12
|
+
this.quantity = data.quantity || 1;
|
|
13
|
+
this.addedAt = data.addedAt || Date.now();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Calculate total price for this item based on quantity and display price.
|
|
18
|
+
*/
|
|
19
|
+
getTotalPrice(): number {
|
|
20
|
+
return this.product.getDisplayPrice() * this.quantity;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
static fromJSON(json: any): CartItem {
|
|
24
|
+
return new CartItem({
|
|
25
|
+
id: json.id || '',
|
|
26
|
+
product: json.product ? Product.fromJSON(json.product) : undefined,
|
|
27
|
+
quantity: json.quantity || 1,
|
|
28
|
+
addedAt: json.addedAt || Date.now()
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { CartItem } from './CartItem';
|
|
2
|
+
|
|
3
|
+
export type OrderStatus = 'pending' | 'completed' | 'canceled' | 'shipped';
|
|
4
|
+
|
|
5
|
+
export class Order {
|
|
6
|
+
id: string;
|
|
7
|
+
items: CartItem[];
|
|
8
|
+
total: number;
|
|
9
|
+
status: OrderStatus;
|
|
10
|
+
createdAt: number;
|
|
11
|
+
paymentMethod: 'credit_card' | 'armoyu_coin' | 'paypal';
|
|
12
|
+
|
|
13
|
+
constructor(data: Partial<Order>) {
|
|
14
|
+
this.id = data.id || '';
|
|
15
|
+
this.items = data.items || [];
|
|
16
|
+
this.total = data.total || 0;
|
|
17
|
+
this.status = data.status || 'pending';
|
|
18
|
+
this.createdAt = data.createdAt || Date.now();
|
|
19
|
+
this.paymentMethod = data.paymentMethod || 'credit_card';
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Static factory to create an Order instance from JSON.
|
|
24
|
+
*/
|
|
25
|
+
static fromJSON(json: any): Order {
|
|
26
|
+
return new Order({
|
|
27
|
+
id: json.id || '',
|
|
28
|
+
items: Array.isArray(json.items) ? json.items.map((i: any) => CartItem.fromJSON(i)) : [],
|
|
29
|
+
total: json.total || json.total_amount || 0,
|
|
30
|
+
status: (json.status || 'pending') as OrderStatus,
|
|
31
|
+
createdAt: json.createdAt || json.created_at || Date.now(),
|
|
32
|
+
paymentMethod: (json.paymentMethod || json.payment_method || 'credit_card') as 'credit_card' | 'armoyu_coin' | 'paypal'
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Returns a user-friendly status name in Turkish.
|
|
38
|
+
*/
|
|
39
|
+
getStatusLabel(): string {
|
|
40
|
+
switch (this.status) {
|
|
41
|
+
case 'pending': return 'Hazırlanıyor';
|
|
42
|
+
case 'completed': return 'Tamamlandı';
|
|
43
|
+
case 'shipped': return 'Kargoya Verildi';
|
|
44
|
+
case 'canceled': return 'İptal Edildi';
|
|
45
|
+
default: return this.status;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
export class Product {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
price: number;
|
|
6
|
+
discountPrice?: number;
|
|
7
|
+
image: string;
|
|
8
|
+
category: string;
|
|
9
|
+
stock: number;
|
|
10
|
+
tags?: string[];
|
|
11
|
+
isFeatured: boolean = false;
|
|
12
|
+
badge?: string;
|
|
13
|
+
|
|
14
|
+
constructor(data: Partial<Product>) {
|
|
15
|
+
this.id = data.id || '';
|
|
16
|
+
this.name = data.name || '';
|
|
17
|
+
this.description = data.description || '';
|
|
18
|
+
this.price = data.price || 0;
|
|
19
|
+
this.discountPrice = data.discountPrice;
|
|
20
|
+
this.image = data.image || '';
|
|
21
|
+
this.category = data.category || '';
|
|
22
|
+
this.stock = data.stock || 0;
|
|
23
|
+
this.tags = data.tags || [];
|
|
24
|
+
this.isFeatured = data.isFeatured || false;
|
|
25
|
+
this.badge = data.badge;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Helper to get the display price (discounted if available)
|
|
30
|
+
*/
|
|
31
|
+
getDisplayPrice(): number {
|
|
32
|
+
return this.discountPrice && this.discountPrice < this.price
|
|
33
|
+
? this.discountPrice
|
|
34
|
+
: this.price;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
static fromJSON(json: any): Product {
|
|
38
|
+
const parsePrice = (p: any): number => {
|
|
39
|
+
if (typeof p === 'number') return p;
|
|
40
|
+
if (typeof p === 'string') {
|
|
41
|
+
const cleaned = p.replace(/[₺,]/g, '').replace(' ', '');
|
|
42
|
+
return parseFloat(cleaned) || 0;
|
|
43
|
+
}
|
|
44
|
+
return 0;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
return new Product({
|
|
48
|
+
id: json.id || '',
|
|
49
|
+
name: json.name || json.product_name || '',
|
|
50
|
+
description: json.description || json.desc || '',
|
|
51
|
+
price: parsePrice(json.price),
|
|
52
|
+
discountPrice: json.discountPrice !== undefined ? parsePrice(json.discountPrice) : undefined,
|
|
53
|
+
image: json.image || json.img_url || '',
|
|
54
|
+
category: json.category || 'Genel',
|
|
55
|
+
stock: json.stock || 0,
|
|
56
|
+
tags: json.tags || [],
|
|
57
|
+
isFeatured: json.isFeatured || json.is_featured || false,
|
|
58
|
+
badge: json.badge
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { User } from '../auth/User';
|
|
2
|
+
import { ChatMessage } from './ChatMessage';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Represents a Chat conversation or summary.
|
|
6
|
+
*/
|
|
7
|
+
export class Chat {
|
|
8
|
+
id: string = '';
|
|
9
|
+
participants: User[] = [];
|
|
10
|
+
name: string = '';
|
|
11
|
+
avatar: string = '';
|
|
12
|
+
lastMessage: ChatMessage | null = null;
|
|
13
|
+
time: string = '';
|
|
14
|
+
unreadCount: number = 0;
|
|
15
|
+
isOnline: boolean = false;
|
|
16
|
+
lastSeen: string = '';
|
|
17
|
+
updatedAt: number = 0;
|
|
18
|
+
isGroup: boolean = false;
|
|
19
|
+
isFavorite: boolean = false;
|
|
20
|
+
messages: ChatMessage[] = [];
|
|
21
|
+
|
|
22
|
+
constructor(data: Partial<Chat>) {
|
|
23
|
+
Object.assign(this, data);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Instantiates a Chat object from a JSON object.
|
|
28
|
+
*/
|
|
29
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
30
|
+
static fromJSON(json: Record<string, any>): Chat {
|
|
31
|
+
return new Chat({
|
|
32
|
+
id: json.id || '',
|
|
33
|
+
participants: Array.isArray(json.participants) ? json.participants.map((p: Record<string, any>) => User.fromJSON(p)) : [],
|
|
34
|
+
name: json.name || '',
|
|
35
|
+
avatar: json.avatar || '',
|
|
36
|
+
lastMessage: json.lastMessage ? ChatMessage.fromJSON(json.lastMessage) : (json.last_message ? ChatMessage.fromJSON(json.last_message) : null),
|
|
37
|
+
time: json.time || '',
|
|
38
|
+
unreadCount: json.unreadCount || json.unread_count || 0,
|
|
39
|
+
isOnline: json.isOnline || json.is_online || false,
|
|
40
|
+
lastSeen: json.lastSeen || json.last_seen || '',
|
|
41
|
+
updatedAt: json.updatedAt || json.updated_at || 0,
|
|
42
|
+
isGroup: json.isGroup || json.is_group || false,
|
|
43
|
+
isFavorite: json.isFavorite || json.is_favorite || false,
|
|
44
|
+
messages: Array.isArray(json.messages) ? json.messages.map((m: any) => ChatMessage.fromJSON(m)) : [],
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { User } from '../auth/User';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Represents a single message in a Chat.
|
|
5
|
+
*/
|
|
6
|
+
export class ChatMessage {
|
|
7
|
+
id: string = '';
|
|
8
|
+
sender: User | null = null;
|
|
9
|
+
content: string = '';
|
|
10
|
+
timestamp: string = '';
|
|
11
|
+
isSystem: boolean = false;
|
|
12
|
+
|
|
13
|
+
constructor(data: Partial<ChatMessage>) {
|
|
14
|
+
Object.assign(this, data);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Instantiates a ChatMessage object from a JSON object.
|
|
19
|
+
*/
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
21
|
+
static fromJSON(json: Record<string, any>): ChatMessage {
|
|
22
|
+
return new ChatMessage({
|
|
23
|
+
id: json.id || '',
|
|
24
|
+
sender: json.sender ? User.fromJSON(json.sender) : (json.sender_name ? new User({ displayName: json.sender_name }) : null),
|
|
25
|
+
content: json.content || json.text || '',
|
|
26
|
+
timestamp: json.timestamp || json.time || '',
|
|
27
|
+
isSystem: json.isSystem || json.is_system || false,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { User } from '../auth/User';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Represents a Comment (Yorum) in the aramizdakioyuncu.com platform.
|
|
5
|
+
*/
|
|
6
|
+
export class Comment {
|
|
7
|
+
id: string = '';
|
|
8
|
+
author: User | null = null;
|
|
9
|
+
text: string = '';
|
|
10
|
+
date: string = '';
|
|
11
|
+
replies: Comment[] = [];
|
|
12
|
+
|
|
13
|
+
constructor(data: Partial<Comment>) {
|
|
14
|
+
Object.assign(this, data);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Adds a reply to the comment.
|
|
19
|
+
*/
|
|
20
|
+
addReply(reply: Comment): void {
|
|
21
|
+
this.replies.push(reply);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Instantiates a Comment object from a JSON object.
|
|
26
|
+
*/
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
28
|
+
static fromJSON(json: Record<string, any>): Comment {
|
|
29
|
+
return new Comment({
|
|
30
|
+
id: json.id || '',
|
|
31
|
+
author: json.user ? User.fromJSON(json.user) : (json.author_name ? new User({ displayName: json.author_name }) : null),
|
|
32
|
+
text: json.text || json.comment || '',
|
|
33
|
+
date: json.date || json.created_at || '',
|
|
34
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
35
|
+
replies: Array.isArray(json.replies) ? json.replies.map((r: any) => Comment.fromJSON(r)) : [],
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { User } from '../auth/User';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Represents a Group/Community/Guild in the aramizdakioyuncu.com platform.
|
|
5
|
+
*/
|
|
6
|
+
export class Group {
|
|
7
|
+
id: string = '';
|
|
8
|
+
name: string = '';
|
|
9
|
+
shortName: string = '';
|
|
10
|
+
slug: string = '';
|
|
11
|
+
description: string = '';
|
|
12
|
+
avatar: string = ''; // Keep for backward compatibility
|
|
13
|
+
logo: string = '';
|
|
14
|
+
banner: string = '';
|
|
15
|
+
coverImage: string = ''; // Keep for backward compatibility
|
|
16
|
+
memberCount: number = 0;
|
|
17
|
+
isPrivate: boolean = false;
|
|
18
|
+
category: string = '';
|
|
19
|
+
tag: string = '';
|
|
20
|
+
recruitment: string = 'Açık';
|
|
21
|
+
date: string = '';
|
|
22
|
+
owner: User | null = null;
|
|
23
|
+
moderators: User[] = [];
|
|
24
|
+
members: User[] = [];
|
|
25
|
+
permissions: string[] = [];
|
|
26
|
+
|
|
27
|
+
constructor(data: Partial<Group>) {
|
|
28
|
+
Object.assign(this, data);
|
|
29
|
+
if (!this.slug && this.name) {
|
|
30
|
+
this.slug = this.name.toLowerCase().replace(/\s+/g, '-').replace(/[^a-z0-9-]/g, '');
|
|
31
|
+
}
|
|
32
|
+
if (!this.logo && this.avatar) this.logo = this.avatar;
|
|
33
|
+
if (!this.banner && this.coverImage) this.banner = this.coverImage;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Instantiates a Group object from a JSON object.
|
|
38
|
+
*/
|
|
39
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
40
|
+
static fromJSON(json: Record<string, any>): Group {
|
|
41
|
+
return new Group({
|
|
42
|
+
id: json.id || '',
|
|
43
|
+
name: json.name || '',
|
|
44
|
+
shortName: json.shortName || json.tag || '',
|
|
45
|
+
slug: json.slug || '',
|
|
46
|
+
description: json.description || '',
|
|
47
|
+
avatar: json.avatar || '',
|
|
48
|
+
logo: json.logo || json.avatar || '',
|
|
49
|
+
banner: json.banner || json.coverImage || json.cover_image || '',
|
|
50
|
+
coverImage: json.coverImage || json.cover_image || '',
|
|
51
|
+
memberCount: json.memberCount || json.member_count || 0,
|
|
52
|
+
isPrivate: json.isPrivate || json.is_private || false,
|
|
53
|
+
category: json.category || '',
|
|
54
|
+
tag: json.tag || '',
|
|
55
|
+
recruitment: json.recruitment || 'Açık',
|
|
56
|
+
date: json.date || '',
|
|
57
|
+
owner: json.owner ? User.fromJSON(json.owner) : null,
|
|
58
|
+
moderators: Array.isArray(json.moderators) ? json.moderators.map((m: any) => User.fromJSON(m)) : [],
|
|
59
|
+
members: Array.isArray(json.members) ? json.members.map((m: any) => User.fromJSON(m)) : [],
|
|
60
|
+
permissions: Array.isArray(json.permissions) ? json.permissions : [],
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { User } from '../auth/User';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Represents an entry in a leaderboard/ranking list.
|
|
5
|
+
*/
|
|
6
|
+
export class LeaderboardEntry {
|
|
7
|
+
displayName: string = '';
|
|
8
|
+
username: string = '';
|
|
9
|
+
score: string = '';
|
|
10
|
+
avatar: string = '';
|
|
11
|
+
|
|
12
|
+
constructor(data: Partial<LeaderboardEntry>) {
|
|
13
|
+
Object.assign(this, data);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Utility class to manage and generate various leaderboards across the platform.
|
|
19
|
+
*/
|
|
20
|
+
export class Leaderboard {
|
|
21
|
+
/**
|
|
22
|
+
* Generates a level-based ranking from a list of users.
|
|
23
|
+
*/
|
|
24
|
+
static getLevelRankings(users: User[], limit: number = 5): LeaderboardEntry[] {
|
|
25
|
+
return [...users]
|
|
26
|
+
.sort((a, b) => (b.level || 0) - (a.level || 0) || (b.xp || 0) - (a.xp || 0))
|
|
27
|
+
.slice(0, limit)
|
|
28
|
+
.map(user => new LeaderboardEntry({
|
|
29
|
+
displayName: user.displayName || user.username,
|
|
30
|
+
username: user.username,
|
|
31
|
+
score: `LVL ${user.level || 1}`,
|
|
32
|
+
avatar: user.avatar
|
|
33
|
+
}));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Generates a popularity-based ranking from a list of users.
|
|
38
|
+
*/
|
|
39
|
+
static getPopularityRankings(users: User[], limit: number = 5): LeaderboardEntry[] {
|
|
40
|
+
return [...users]
|
|
41
|
+
.sort((a, b) => (b.popScore || 0) - (a.popScore || 0))
|
|
42
|
+
.slice(0, limit)
|
|
43
|
+
.map(user => {
|
|
44
|
+
const score = user.popScore || 0;
|
|
45
|
+
const formattedScore = score >= 1000
|
|
46
|
+
? (score / 1000).toFixed(1) + 'k'
|
|
47
|
+
: score.toString();
|
|
48
|
+
|
|
49
|
+
return new LeaderboardEntry({
|
|
50
|
+
displayName: user.displayName || user.username,
|
|
51
|
+
username: user.username,
|
|
52
|
+
score: formattedScore,
|
|
53
|
+
avatar: user.avatar
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { User } from '../auth/User';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Represents a "Note" (Instagram-style status bubble) in the aramizdakioyuncu.com platform.
|
|
5
|
+
*/
|
|
6
|
+
export class Note {
|
|
7
|
+
id: string = '';
|
|
8
|
+
user: User | null = null;
|
|
9
|
+
note: string = '';
|
|
10
|
+
isMe: boolean = false;
|
|
11
|
+
|
|
12
|
+
constructor(data: Partial<Note>) {
|
|
13
|
+
Object.assign(this, data);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Instantiates a Note object from a JSON object.
|
|
18
|
+
*/
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
20
|
+
static fromJSON(json: Record<string, any>): Note {
|
|
21
|
+
return new Note({
|
|
22
|
+
id: json.id || '',
|
|
23
|
+
user: json.user ? User.fromJSON(json.user) : null,
|
|
24
|
+
note: json.note || '',
|
|
25
|
+
isMe: json.isMe || false,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { User } from '../auth/User';
|
|
2
|
+
import { Group } from '../community/Group';
|
|
3
|
+
import { Post } from './Post';
|
|
4
|
+
import { NotificationSender, NotificationType, NotificationCategory } from './NotificationSender';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Represents a Notification in the aramizdakioyuncu.com platform.
|
|
8
|
+
*/
|
|
9
|
+
export class Notification {
|
|
10
|
+
id: string = '';
|
|
11
|
+
type: NotificationType = 'SYSTEM_ALERT';
|
|
12
|
+
category: NotificationCategory = 'SYSTEM';
|
|
13
|
+
title: string = '';
|
|
14
|
+
message: string = '';
|
|
15
|
+
context: string = ''; // Detailed context (snippet of comment, etc)
|
|
16
|
+
sender?: NotificationSender;
|
|
17
|
+
link: string = '';
|
|
18
|
+
isRead: boolean = false;
|
|
19
|
+
isClickable: boolean = true; // New property
|
|
20
|
+
createdAt: string = '';
|
|
21
|
+
|
|
22
|
+
// Direct Associated IDs (Legacy supporting)
|
|
23
|
+
postId?: string;
|
|
24
|
+
commentId?: string;
|
|
25
|
+
eventId?: string;
|
|
26
|
+
groupId?: string;
|
|
27
|
+
|
|
28
|
+
// Rich Objects (OO approach)
|
|
29
|
+
group?: Group;
|
|
30
|
+
post?: Post;
|
|
31
|
+
// event?: Event; // Add when Event is ready
|
|
32
|
+
|
|
33
|
+
constructor(data: Partial<Notification>) {
|
|
34
|
+
Object.assign(this, data);
|
|
35
|
+
|
|
36
|
+
// 1. Sync from Post object if exists
|
|
37
|
+
if (this.post) {
|
|
38
|
+
this.postId = this.post.id;
|
|
39
|
+
if (!this.context) {
|
|
40
|
+
// Create context snippet from post content
|
|
41
|
+
this.context = this.post.content.length > 50
|
|
42
|
+
? this.post.content.substring(0, 47) + '...'
|
|
43
|
+
: this.post.content;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// 2. Auto-generate link from objects (OO)
|
|
48
|
+
if (!this.link) {
|
|
49
|
+
if (this.group) {
|
|
50
|
+
this.link = this.group.getGroupUrl();
|
|
51
|
+
} else if (this.groupId) {
|
|
52
|
+
// Fallback for ID strings
|
|
53
|
+
const targetSlug = this.groupId.toLowerCase().replace(/\s+/g, '-');
|
|
54
|
+
this.link = `/gruplar/${targetSlug}`;
|
|
55
|
+
} else if (this.postId) {
|
|
56
|
+
this.link = `/?post=${this.postId}`;
|
|
57
|
+
} else if (this.sender?.url) {
|
|
58
|
+
this.link = this.sender.url;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// 3. Sync title/metadata if missing but object exists
|
|
63
|
+
if (!this.title && this.group && this.type === 'GROUP_INVITE') {
|
|
64
|
+
this.title = 'Grup Daveti';
|
|
65
|
+
this.message = `${this.group.name} grubuna davet edildin.`;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Default to system sender if not provided for system notifications
|
|
69
|
+
if (this.category === 'SYSTEM') {
|
|
70
|
+
if (!this.sender) this.sender = NotificationSender.system();
|
|
71
|
+
this.isClickable = false;
|
|
72
|
+
this.link = ''; // System messages shouldn't have links usually
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Instantiates a Notification object from a JSON object.
|
|
78
|
+
*/
|
|
79
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
80
|
+
static fromJSON(json: Record<string, any>): Notification {
|
|
81
|
+
return new Notification({
|
|
82
|
+
id: json.id || '',
|
|
83
|
+
type: json.type || 'SYSTEM_ALERT',
|
|
84
|
+
category: json.category || 'SYSTEM',
|
|
85
|
+
title: json.title || '',
|
|
86
|
+
message: json.message || '',
|
|
87
|
+
context: json.context || '',
|
|
88
|
+
sender: json.sender ? new NotificationSender(json.sender) : undefined,
|
|
89
|
+
link: json.link || '',
|
|
90
|
+
isRead: json.isRead || false,
|
|
91
|
+
createdAt: json.createdAt || json.created_at || '',
|
|
92
|
+
postId: json.postId || json.post_id,
|
|
93
|
+
commentId: json.commentId || json.comment_id,
|
|
94
|
+
eventId: json.eventId || json.event_id,
|
|
95
|
+
groupId: json.groupId || json.group_id,
|
|
96
|
+
group: json.group ? Group.fromJSON(json.group) : undefined,
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export type NotificationType =
|
|
2
|
+
| 'POST_LIKE' | 'POST_COMMENT' | 'POST_MENTION'
|
|
3
|
+
| 'GROUP_INVITE' | 'GROUP_JOIN_REQUEST' | 'GROUP_ANNOUNCEMENT'
|
|
4
|
+
| 'EVENT_INVITE' | 'EVENT_REMINDER'
|
|
5
|
+
| 'FRIEND_REQUEST' | 'FRIEND_ACCEPT'
|
|
6
|
+
| 'SYSTEM_ALERT' | 'SYSTEM_UPDATE';
|
|
7
|
+
|
|
8
|
+
export type NotificationCategory = 'SOCIAL' | 'GROUP' | 'EVENT' | 'SYSTEM';
|
|
9
|
+
export type SenderType = 'USER' | 'GROUP' | 'SYSTEM';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Interface representing a standardized sender for notifications.
|
|
13
|
+
*/
|
|
14
|
+
export class NotificationSender {
|
|
15
|
+
id: string = '';
|
|
16
|
+
name: string = '';
|
|
17
|
+
avatar: string = '';
|
|
18
|
+
type: SenderType = 'SYSTEM';
|
|
19
|
+
url?: string;
|
|
20
|
+
|
|
21
|
+
constructor(data: Partial<NotificationSender>) {
|
|
22
|
+
Object.assign(this, data);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Helper to create a system sender.
|
|
27
|
+
*/
|
|
28
|
+
static system(): NotificationSender {
|
|
29
|
+
return new NotificationSender({
|
|
30
|
+
id: 'system',
|
|
31
|
+
name: 'ARMOYU',
|
|
32
|
+
avatar: 'https://armoyu.com/assets/img/armoyu_logo.png',
|
|
33
|
+
type: 'SYSTEM'
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { User } from '../auth/User';
|
|
2
|
+
|
|
3
|
+
export interface PostMedia {
|
|
4
|
+
type: 'image' | 'video';
|
|
5
|
+
url: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface PostStats {
|
|
9
|
+
likes: number;
|
|
10
|
+
comments: number;
|
|
11
|
+
reposts: number;
|
|
12
|
+
shares: number;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface PostComment {
|
|
16
|
+
id: string;
|
|
17
|
+
author: User;
|
|
18
|
+
content: string;
|
|
19
|
+
createdAt: string;
|
|
20
|
+
likes?: number;
|
|
21
|
+
replies?: PostComment[];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Represents a Post (Gönderi/Paylaşım) in the aramizdakioyuncu.com platform.
|
|
26
|
+
*/
|
|
27
|
+
export class Post {
|
|
28
|
+
id: string = '';
|
|
29
|
+
author: User | null = null;
|
|
30
|
+
content: string = '';
|
|
31
|
+
media: PostMedia[] = [];
|
|
32
|
+
createdAt: string = '';
|
|
33
|
+
stats: PostStats = { likes: 0, comments: 0, reposts: 0, shares: 0 };
|
|
34
|
+
hashtags: string[] = [];
|
|
35
|
+
isPending: boolean = false;
|
|
36
|
+
repostOf?: Post; // Original post if this is a repost
|
|
37
|
+
|
|
38
|
+
// Real-time Lists
|
|
39
|
+
likeList: User[] = [];
|
|
40
|
+
repostList: User[] = [];
|
|
41
|
+
commentList: PostComment[] = [];
|
|
42
|
+
|
|
43
|
+
constructor(data: Partial<Post>) {
|
|
44
|
+
Object.assign(this, data);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Instantiates a Post object from a JSON object.
|
|
49
|
+
*/
|
|
50
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
51
|
+
static fromJSON(json: Record<string, any>): Post {
|
|
52
|
+
return new Post({
|
|
53
|
+
id: json.id || '',
|
|
54
|
+
author: json.author ? User.fromJSON(json.author) : null,
|
|
55
|
+
content: json.content || '',
|
|
56
|
+
media: Array.isArray(json.media) ? json.media : (json.imageUrl ? [{ type: 'image', url: json.imageUrl }] : []),
|
|
57
|
+
createdAt: json.createdAt || json.created_at || '',
|
|
58
|
+
stats: json.stats || {
|
|
59
|
+
likes: json.likeCount || 0,
|
|
60
|
+
comments: json.commentCount || 0,
|
|
61
|
+
reposts: json.repostCount || 0,
|
|
62
|
+
shares: json.shareCount || 0,
|
|
63
|
+
},
|
|
64
|
+
hashtags: json.hashtags || [],
|
|
65
|
+
likeList: Array.isArray(json.likeList) ? json.likeList.map(User.fromJSON) : [],
|
|
66
|
+
repostList: Array.isArray(json.repostList) ? json.repostList.map(User.fromJSON) : [],
|
|
67
|
+
commentList: Array.isArray(json.commentList) ? json.commentList.map((c: any) => ({
|
|
68
|
+
...c,
|
|
69
|
+
author: User.fromJSON(c.author),
|
|
70
|
+
replies: Array.isArray(c.replies) ? c.replies.map((r: any) => ({ ...r, author: User.fromJSON(r.author) })) : []
|
|
71
|
+
})) : [],
|
|
72
|
+
repostOf: json.repostOf ? Post.fromJSON(json.repostOf) : undefined
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|