@oxyhq/services 5.9.2 → 5.9.4

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 (202) hide show
  1. package/README.md +1 -33
  2. package/lib/commonjs/core/OxyServices.js +322 -0
  3. package/lib/commonjs/core/OxyServices.js.map +1 -0
  4. package/lib/commonjs/core/OxyServicesMain.js +51 -0
  5. package/lib/commonjs/core/OxyServicesMain.js.map +1 -0
  6. package/lib/commonjs/core/analytics/AnalyticsService.js +67 -0
  7. package/lib/commonjs/core/analytics/AnalyticsService.js.map +1 -0
  8. package/lib/commonjs/core/auth/AuthService.js +526 -0
  9. package/lib/commonjs/core/auth/AuthService.js.map +1 -0
  10. package/lib/commonjs/core/devices/DeviceService.js +61 -0
  11. package/lib/commonjs/core/devices/DeviceService.js.map +1 -0
  12. package/lib/commonjs/core/files/FileService.js +176 -0
  13. package/lib/commonjs/core/files/FileService.js.map +1 -0
  14. package/lib/commonjs/core/index.js +103 -1701
  15. package/lib/commonjs/core/index.js.map +1 -1
  16. package/lib/commonjs/core/karma/KarmaService.js +100 -0
  17. package/lib/commonjs/core/karma/KarmaService.js.map +1 -0
  18. package/lib/commonjs/core/locations/LocationService.js +131 -0
  19. package/lib/commonjs/core/locations/LocationService.js.map +1 -0
  20. package/lib/commonjs/core/payments/PaymentService.js +124 -0
  21. package/lib/commonjs/core/payments/PaymentService.js.map +1 -0
  22. package/lib/commonjs/core/users/UserService.js +234 -0
  23. package/lib/commonjs/core/users/UserService.js.map +1 -0
  24. package/lib/commonjs/index.js +164 -3
  25. package/lib/commonjs/index.js.map +1 -1
  26. package/lib/commonjs/models/session.js +2 -0
  27. package/lib/commonjs/{types/middleware.js.map → models/session.js.map} +1 -1
  28. package/lib/commonjs/ui/context/OxyContext.js +28 -24
  29. package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
  30. package/lib/commonjs/ui/screens/AccountSwitcherScreen.js +2 -2
  31. package/lib/commonjs/ui/screens/AccountSwitcherScreen.js.map +1 -1
  32. package/lib/commonjs/ui/screens/FileManagementScreen.js +12 -12
  33. package/lib/commonjs/ui/screens/FileManagementScreen.js.map +1 -1
  34. package/lib/commonjs/ui/screens/ProfileScreen.js +2 -2
  35. package/lib/commonjs/ui/screens/ProfileScreen.js.map +1 -1
  36. package/lib/commonjs/ui/screens/SessionManagementScreen.js.map +1 -1
  37. package/lib/commonjs/ui/screens/SignInScreen.js +1 -1
  38. package/lib/commonjs/ui/screens/SignInScreen.js.map +1 -1
  39. package/lib/commonjs/ui/screens/karma/KarmaCenterScreen.js +1 -1
  40. package/lib/commonjs/ui/screens/karma/KarmaCenterScreen.js.map +1 -1
  41. package/lib/commonjs/ui/screens/karma/KarmaLeaderboardScreen.js +1 -1
  42. package/lib/commonjs/ui/screens/karma/KarmaLeaderboardScreen.js.map +1 -1
  43. package/lib/commonjs/ui/screens/karma/KarmaRulesScreen.js +1 -1
  44. package/lib/commonjs/ui/screens/karma/KarmaRulesScreen.js.map +1 -1
  45. package/lib/commonjs/ui/stores/followStore.js +4 -4
  46. package/lib/commonjs/ui/stores/followStore.js.map +1 -1
  47. package/lib/commonjs/utils/apiUtils.js +93 -0
  48. package/lib/commonjs/utils/apiUtils.js.map +1 -0
  49. package/lib/commonjs/utils/asyncUtils.js +219 -0
  50. package/lib/commonjs/utils/asyncUtils.js.map +1 -0
  51. package/lib/commonjs/utils/errorUtils.js +148 -0
  52. package/lib/commonjs/utils/errorUtils.js.map +1 -0
  53. package/lib/commonjs/utils/hookUtils.js +399 -0
  54. package/lib/commonjs/utils/hookUtils.js.map +1 -0
  55. package/lib/commonjs/utils/loggerUtils.js +160 -0
  56. package/lib/commonjs/utils/loggerUtils.js.map +1 -0
  57. package/lib/commonjs/utils/validationUtils.js +174 -0
  58. package/lib/commonjs/utils/validationUtils.js.map +1 -0
  59. package/lib/module/core/OxyServices.js +316 -0
  60. package/lib/module/core/OxyServices.js.map +1 -0
  61. package/lib/module/core/OxyServicesMain.js +47 -0
  62. package/lib/module/core/OxyServicesMain.js.map +1 -0
  63. package/lib/module/core/analytics/AnalyticsService.js +62 -0
  64. package/lib/module/core/analytics/AnalyticsService.js.map +1 -0
  65. package/lib/module/core/auth/AuthService.js +521 -0
  66. package/lib/module/core/auth/AuthService.js.map +1 -0
  67. package/lib/module/core/devices/DeviceService.js +57 -0
  68. package/lib/module/core/devices/DeviceService.js.map +1 -0
  69. package/lib/module/core/files/FileService.js +171 -0
  70. package/lib/module/core/files/FileService.js.map +1 -0
  71. package/lib/module/core/index.js +25 -1690
  72. package/lib/module/core/index.js.map +1 -1
  73. package/lib/module/core/karma/KarmaService.js +95 -0
  74. package/lib/module/core/karma/KarmaService.js.map +1 -0
  75. package/lib/module/core/locations/LocationService.js +127 -0
  76. package/lib/module/core/locations/LocationService.js.map +1 -0
  77. package/lib/module/core/payments/PaymentService.js +119 -0
  78. package/lib/module/core/payments/PaymentService.js.map +1 -0
  79. package/lib/module/core/users/UserService.js +230 -0
  80. package/lib/module/core/users/UserService.js.map +1 -0
  81. package/lib/module/index.js +8 -4
  82. package/lib/module/index.js.map +1 -1
  83. package/lib/module/models/session.js +2 -0
  84. package/lib/module/{types/middleware.js.map → models/session.js.map} +1 -1
  85. package/lib/module/ui/context/OxyContext.js +28 -24
  86. package/lib/module/ui/context/OxyContext.js.map +1 -1
  87. package/lib/module/ui/screens/AccountSwitcherScreen.js +2 -2
  88. package/lib/module/ui/screens/AccountSwitcherScreen.js.map +1 -1
  89. package/lib/module/ui/screens/FileManagementScreen.js +12 -12
  90. package/lib/module/ui/screens/FileManagementScreen.js.map +1 -1
  91. package/lib/module/ui/screens/ProfileScreen.js +2 -2
  92. package/lib/module/ui/screens/ProfileScreen.js.map +1 -1
  93. package/lib/module/ui/screens/SessionManagementScreen.js.map +1 -1
  94. package/lib/module/ui/screens/SignInScreen.js +1 -1
  95. package/lib/module/ui/screens/SignInScreen.js.map +1 -1
  96. package/lib/module/ui/screens/karma/KarmaCenterScreen.js +1 -1
  97. package/lib/module/ui/screens/karma/KarmaCenterScreen.js.map +1 -1
  98. package/lib/module/ui/screens/karma/KarmaLeaderboardScreen.js +1 -1
  99. package/lib/module/ui/screens/karma/KarmaLeaderboardScreen.js.map +1 -1
  100. package/lib/module/ui/screens/karma/KarmaRulesScreen.js +1 -1
  101. package/lib/module/ui/screens/karma/KarmaRulesScreen.js.map +1 -1
  102. package/lib/module/ui/stores/followStore.js +4 -4
  103. package/lib/module/ui/stores/followStore.js.map +1 -1
  104. package/lib/module/utils/apiUtils.js +85 -0
  105. package/lib/module/utils/apiUtils.js.map +1 -0
  106. package/lib/module/utils/asyncUtils.js +202 -0
  107. package/lib/module/utils/asyncUtils.js.map +1 -0
  108. package/lib/module/utils/errorUtils.js +139 -0
  109. package/lib/module/utils/errorUtils.js.map +1 -0
  110. package/lib/module/utils/hookUtils.js +381 -0
  111. package/lib/module/utils/hookUtils.js.map +1 -0
  112. package/lib/module/utils/loggerUtils.js +149 -0
  113. package/lib/module/utils/loggerUtils.js.map +1 -0
  114. package/lib/module/utils/validationUtils.js +154 -0
  115. package/lib/module/utils/validationUtils.js.map +1 -0
  116. package/lib/typescript/core/OxyServices.d.ts +99 -0
  117. package/lib/typescript/core/OxyServices.d.ts.map +1 -0
  118. package/lib/typescript/core/OxyServicesMain.d.ts +33 -0
  119. package/lib/typescript/core/OxyServicesMain.d.ts.map +1 -0
  120. package/lib/typescript/core/analytics/AnalyticsService.d.ts +26 -0
  121. package/lib/typescript/core/analytics/AnalyticsService.d.ts.map +1 -0
  122. package/lib/typescript/core/auth/AuthService.d.ts +165 -0
  123. package/lib/typescript/core/auth/AuthService.d.ts.map +1 -0
  124. package/lib/typescript/core/devices/DeviceService.d.ts +20 -0
  125. package/lib/typescript/core/devices/DeviceService.d.ts.map +1 -0
  126. package/lib/typescript/core/files/FileService.d.ts +59 -0
  127. package/lib/typescript/core/files/FileService.d.ts.map +1 -0
  128. package/lib/typescript/core/index.d.ts +19 -656
  129. package/lib/typescript/core/index.d.ts.map +1 -1
  130. package/lib/typescript/core/karma/KarmaService.d.ts +50 -0
  131. package/lib/typescript/core/karma/KarmaService.d.ts.map +1 -0
  132. package/lib/typescript/core/locations/LocationService.d.ts +39 -0
  133. package/lib/typescript/core/locations/LocationService.d.ts.map +1 -0
  134. package/lib/typescript/core/payments/PaymentService.d.ts +50 -0
  135. package/lib/typescript/core/payments/PaymentService.d.ts.map +1 -0
  136. package/lib/typescript/core/users/UserService.d.ts +111 -0
  137. package/lib/typescript/core/users/UserService.d.ts.map +1 -0
  138. package/lib/typescript/index.d.ts +7 -3
  139. package/lib/typescript/index.d.ts.map +1 -1
  140. package/lib/typescript/models/{secureSession.d.ts → session.d.ts} +4 -4
  141. package/lib/typescript/models/session.d.ts.map +1 -0
  142. package/lib/typescript/ui/context/OxyContext.d.ts +2 -2
  143. package/lib/typescript/ui/context/OxyContext.d.ts.map +1 -1
  144. package/lib/typescript/utils/apiUtils.d.ts +61 -0
  145. package/lib/typescript/utils/apiUtils.d.ts.map +1 -0
  146. package/lib/typescript/utils/asyncUtils.d.ts +64 -0
  147. package/lib/typescript/utils/asyncUtils.d.ts.map +1 -0
  148. package/lib/typescript/utils/errorUtils.d.ts +45 -0
  149. package/lib/typescript/utils/errorUtils.d.ts.map +1 -0
  150. package/lib/typescript/utils/hookUtils.d.ts +102 -0
  151. package/lib/typescript/utils/hookUtils.d.ts.map +1 -0
  152. package/lib/typescript/utils/loggerUtils.d.ts +49 -0
  153. package/lib/typescript/utils/loggerUtils.d.ts.map +1 -0
  154. package/lib/typescript/utils/validationUtils.d.ts +80 -0
  155. package/lib/typescript/utils/validationUtils.d.ts.map +1 -0
  156. package/package.json +2 -8
  157. package/src/core/OxyServices.ts +351 -0
  158. package/src/core/OxyServicesMain.ts +57 -0
  159. package/src/core/analytics/AnalyticsService.ts +64 -0
  160. package/src/core/auth/AuthService.ts +544 -0
  161. package/src/core/devices/DeviceService.ts +55 -0
  162. package/src/core/files/FileService.ts +194 -0
  163. package/src/core/index.ts +27 -1765
  164. package/src/core/karma/KarmaService.ts +104 -0
  165. package/src/core/locations/LocationService.ts +141 -0
  166. package/src/core/payments/PaymentService.ts +133 -0
  167. package/src/core/users/UserService.ts +241 -0
  168. package/src/index.ts +29 -8
  169. package/src/models/{secureSession.ts → session.ts} +5 -5
  170. package/src/ui/context/OxyContext.tsx +34 -30
  171. package/src/ui/screens/AccountSwitcherScreen.tsx +4 -4
  172. package/src/ui/screens/FileManagementScreen.tsx +12 -12
  173. package/src/ui/screens/ProfileScreen.tsx +3 -3
  174. package/src/ui/screens/SessionManagementScreen.tsx +2 -2
  175. package/src/ui/screens/SignInScreen.tsx +1 -1
  176. package/src/ui/screens/karma/KarmaCenterScreen.tsx +2 -2
  177. package/src/ui/screens/karma/KarmaLeaderboardScreen.tsx +3 -3
  178. package/src/ui/screens/karma/KarmaRulesScreen.tsx +3 -3
  179. package/src/ui/stores/followStore.ts +4 -4
  180. package/src/utils/apiUtils.ts +102 -0
  181. package/src/utils/asyncUtils.ts +265 -0
  182. package/src/utils/errorUtils.ts +172 -0
  183. package/src/utils/hookUtils.ts +397 -0
  184. package/src/utils/loggerUtils.ts +153 -0
  185. package/src/utils/validationUtils.ts +158 -0
  186. package/lib/commonjs/middleware.js +0 -17
  187. package/lib/commonjs/middleware.js.map +0 -1
  188. package/lib/commonjs/models/secureSession.js +0 -2
  189. package/lib/commonjs/models/secureSession.js.map +0 -1
  190. package/lib/commonjs/types/middleware.js +0 -6
  191. package/lib/module/middleware.js +0 -12
  192. package/lib/module/middleware.js.map +0 -1
  193. package/lib/module/models/secureSession.js +0 -2
  194. package/lib/module/models/secureSession.js.map +0 -1
  195. package/lib/module/types/middleware.js +0 -4
  196. package/lib/typescript/middleware.d.ts +0 -9
  197. package/lib/typescript/middleware.d.ts.map +0 -1
  198. package/lib/typescript/models/secureSession.d.ts.map +0 -1
  199. package/lib/typescript/types/middleware.d.ts +0 -19
  200. package/lib/typescript/types/middleware.d.ts.map +0 -1
  201. package/src/middleware.ts +0 -11
  202. package/src/types/middleware.ts +0 -20
@@ -0,0 +1,104 @@
1
+ import { OxyServices } from '../OxyServices';
2
+ import {
3
+ KarmaRule,
4
+ KarmaHistory,
5
+ KarmaLeaderboardEntry,
6
+ KarmaAwardRequest
7
+ } from '../../models/interfaces';
8
+
9
+ /**
10
+ * Karma service for handling karma system operations
11
+ */
12
+ export class KarmaService extends OxyServices {
13
+ /**
14
+ * Get karma leaderboard
15
+ */
16
+ async getKarmaLeaderboard(): Promise<KarmaLeaderboardEntry[]> {
17
+ try {
18
+ const res = await this.getClient().get('/karma/leaderboard');
19
+ return res.data;
20
+ } catch (error) {
21
+ throw this.handleError(error);
22
+ }
23
+ }
24
+
25
+ /**
26
+ * Get karma rules
27
+ */
28
+ async getKarmaRules(): Promise<KarmaRule[]> {
29
+ try {
30
+ const res = await this.getClient().get('/karma/rules');
31
+ return res.data;
32
+ } catch (error) {
33
+ throw this.handleError(error);
34
+ }
35
+ }
36
+
37
+ /**
38
+ * Get user karma total
39
+ */
40
+ async getUserKarmaTotal(userId: string): Promise<{ total: number }> {
41
+ try {
42
+ const res = await this.getClient().get(`/karma/users/${userId}/total`);
43
+ return res.data;
44
+ } catch (error) {
45
+ throw this.handleError(error);
46
+ }
47
+ }
48
+
49
+ /**
50
+ * Get user karma history
51
+ */
52
+ async getUserKarmaHistory(
53
+ userId: string,
54
+ limit?: number,
55
+ offset?: number
56
+ ): Promise<{ history: KarmaHistory[]; total: number; hasMore: boolean }> {
57
+ try {
58
+ const params = new URLSearchParams();
59
+ if (limit) params.append('limit', limit.toString());
60
+ if (offset) params.append('offset', offset.toString());
61
+
62
+ const res = await this.getClient().get(`/karma/users/${userId}/history?${params.toString()}`);
63
+ return res.data;
64
+ } catch (error) {
65
+ throw this.handleError(error);
66
+ }
67
+ }
68
+
69
+ /**
70
+ * Award karma to user
71
+ */
72
+ async awardKarma(data: KarmaAwardRequest): Promise<{ success: boolean; message: string; history: KarmaHistory }> {
73
+ try {
74
+ const res = await this.getClient().post('/karma/award', data);
75
+ return res.data;
76
+ } catch (error) {
77
+ throw this.handleError(error);
78
+ }
79
+ }
80
+
81
+ /**
82
+ * Deduct karma from user
83
+ */
84
+ async deductKarma(data: KarmaAwardRequest): Promise<{ success: boolean; message: string; history: KarmaHistory }> {
85
+ try {
86
+ const res = await this.getClient().post('/karma/deduct', data);
87
+ return res.data;
88
+ } catch (error) {
89
+ throw this.handleError(error);
90
+ }
91
+ }
92
+
93
+ /**
94
+ * Create or update karma rule
95
+ */
96
+ async createOrUpdateKarmaRule(data: Partial<KarmaRule>): Promise<KarmaRule> {
97
+ try {
98
+ const res = await this.getClient().post('/karma/rules', data);
99
+ return res.data;
100
+ } catch (error) {
101
+ throw this.handleError(error);
102
+ }
103
+ }
104
+ }
@@ -0,0 +1,141 @@
1
+ import { OxyServices } from '../OxyServices';
2
+
3
+ /**
4
+ * Location service for handling location search and geolocation features
5
+ */
6
+ export class LocationService extends OxyServices {
7
+ /**
8
+ * Search locations
9
+ */
10
+ async searchLocations(query: string, limit: number = 5, countrycodes?: string): Promise<any[]> {
11
+ try {
12
+ const params = new URLSearchParams({
13
+ query,
14
+ limit: limit.toString()
15
+ });
16
+
17
+ if (countrycodes) {
18
+ params.append('countrycodes', countrycodes);
19
+ }
20
+
21
+ const res = await this.getClient().get(`/location-search/search?${params.toString()}`);
22
+ return res.data;
23
+ } catch (error) {
24
+ throw this.handleError(error);
25
+ }
26
+ }
27
+
28
+ /**
29
+ * Get location details by coordinates
30
+ */
31
+ async getLocationDetails(lat: number, lon: number): Promise<any> {
32
+ try {
33
+ const res = await this.getClient().get(`/location-search/reverse?lat=${lat}&lon=${lon}`);
34
+ return res.data;
35
+ } catch (error) {
36
+ throw this.handleError(error);
37
+ }
38
+ }
39
+
40
+ /**
41
+ * Find locations near coordinates
42
+ */
43
+ async findLocationsNear(
44
+ lat: number,
45
+ lon: number,
46
+ maxDistance: number = 10000,
47
+ limit: number = 10,
48
+ skip: number = 0
49
+ ): Promise<any> {
50
+ try {
51
+ const params = new URLSearchParams({
52
+ lat: lat.toString(),
53
+ lon: lon.toString(),
54
+ maxDistance: maxDistance.toString(),
55
+ limit: limit.toString(),
56
+ skip: skip.toString()
57
+ });
58
+
59
+ const res = await this.getClient().get(`/location-search/near?${params.toString()}`);
60
+ return res.data;
61
+ } catch (error) {
62
+ throw this.handleError(error);
63
+ }
64
+ }
65
+
66
+ /**
67
+ * Search locations in database
68
+ */
69
+ async searchLocationsInDB(
70
+ query: string,
71
+ limit: number = 10,
72
+ skip: number = 0,
73
+ type?: string,
74
+ country?: string,
75
+ city?: string
76
+ ): Promise<any> {
77
+ try {
78
+ const params = new URLSearchParams({
79
+ query,
80
+ limit: limit.toString(),
81
+ skip: skip.toString()
82
+ });
83
+ if (type) params.append('type', type);
84
+ if (country) params.append('country', country);
85
+ if (city) params.append('city', city);
86
+
87
+ const res = await this.getClient().get(`/location-search/db-search?${params.toString()}`);
88
+ return res.data;
89
+ } catch (error) {
90
+ throw this.handleError(error);
91
+ }
92
+ }
93
+
94
+ /**
95
+ * Get location statistics
96
+ */
97
+ async getLocationStats(): Promise<any> {
98
+ try {
99
+ const res = await this.getClient().get('/location-search/stats');
100
+ return res.data.stats;
101
+ } catch (error) {
102
+ throw this.handleError(error);
103
+ }
104
+ }
105
+
106
+ /**
107
+ * Get cache statistics
108
+ */
109
+ async getLocationCacheStats(): Promise<any> {
110
+ try {
111
+ const res = await this.getClient().get('/location-search/cache/stats');
112
+ return res.data.stats;
113
+ } catch (error) {
114
+ throw this.handleError(error);
115
+ }
116
+ }
117
+
118
+ /**
119
+ * Clear location cache
120
+ */
121
+ async clearLocationCache(): Promise<any> {
122
+ try {
123
+ const res = await this.getClient().delete('/location-search/cache');
124
+ return res.data;
125
+ } catch (error) {
126
+ throw this.handleError(error);
127
+ }
128
+ }
129
+
130
+ /**
131
+ * Get performance statistics
132
+ */
133
+ async getLocationPerformanceStats(): Promise<any> {
134
+ try {
135
+ const res = await this.getClient().get('/location-search/performance');
136
+ return res.data;
137
+ } catch (error) {
138
+ throw this.handleError(error);
139
+ }
140
+ }
141
+ }
@@ -0,0 +1,133 @@
1
+ import { OxyServices } from '../OxyServices';
2
+ import {
3
+ Wallet,
4
+ Transaction,
5
+ TransferFundsRequest,
6
+ PurchaseRequest,
7
+ WithdrawalRequest,
8
+ TransactionResponse,
9
+ PaymentMethod,
10
+ PaymentRequest,
11
+ PaymentResponse
12
+ } from '../../models/interfaces';
13
+
14
+ /**
15
+ * Payment service for handling payments, wallet operations, and transactions
16
+ */
17
+ export class PaymentService extends OxyServices {
18
+ /**
19
+ * Process payment
20
+ */
21
+ async processPayment(data: PaymentRequest): Promise<PaymentResponse> {
22
+ try {
23
+ const res = await this.getClient().post('/payments/process', data);
24
+ return res.data;
25
+ } catch (error) {
26
+ throw this.handleError(error);
27
+ }
28
+ }
29
+
30
+ /**
31
+ * Validate payment method
32
+ */
33
+ async validatePaymentMethod(paymentMethod: any): Promise<{ valid: boolean }> {
34
+ try {
35
+ const res = await this.getClient().post('/payments/validate-method', paymentMethod);
36
+ return res.data;
37
+ } catch (error) {
38
+ throw this.handleError(error);
39
+ }
40
+ }
41
+
42
+ /**
43
+ * Get payment methods for user
44
+ */
45
+ async getPaymentMethods(userId: string): Promise<PaymentMethod[]> {
46
+ try {
47
+ const res = await this.getClient().get(`/payments/methods/${userId}`);
48
+ return res.data;
49
+ } catch (error) {
50
+ throw this.handleError(error);
51
+ }
52
+ }
53
+
54
+ /**
55
+ * Get user wallet
56
+ */
57
+ async getWallet(userId: string): Promise<Wallet> {
58
+ try {
59
+ const res = await this.getClient().get(`/wallet/${userId}`);
60
+ return res.data;
61
+ } catch (error) {
62
+ throw this.handleError(error);
63
+ }
64
+ }
65
+
66
+ /**
67
+ * Get transaction history
68
+ */
69
+ async getTransactionHistory(
70
+ userId: string,
71
+ limit?: number,
72
+ offset?: number
73
+ ): Promise<{ transactions: Transaction[]; total: number; hasMore: boolean }> {
74
+ try {
75
+ const params = new URLSearchParams();
76
+ if (limit) params.append('limit', limit.toString());
77
+ if (offset) params.append('offset', offset.toString());
78
+
79
+ const res = await this.getClient().get(`/wallet/${userId}/transactions?${params.toString()}`);
80
+ return res.data;
81
+ } catch (error) {
82
+ throw this.handleError(error);
83
+ }
84
+ }
85
+
86
+ /**
87
+ * Get specific transaction
88
+ */
89
+ async getTransaction(transactionId: string): Promise<Transaction> {
90
+ try {
91
+ const res = await this.getClient().get(`/transactions/${transactionId}`);
92
+ return res.data;
93
+ } catch (error) {
94
+ throw this.handleError(error);
95
+ }
96
+ }
97
+
98
+ /**
99
+ * Transfer funds between users
100
+ */
101
+ async transferFunds(data: TransferFundsRequest): Promise<TransactionResponse> {
102
+ try {
103
+ const res = await this.getClient().post('/wallet/transfer', data);
104
+ return res.data;
105
+ } catch (error) {
106
+ throw this.handleError(error);
107
+ }
108
+ }
109
+
110
+ /**
111
+ * Process purchase
112
+ */
113
+ async processPurchase(data: PurchaseRequest): Promise<TransactionResponse> {
114
+ try {
115
+ const res = await this.getClient().post('/wallet/purchase', data);
116
+ return res.data;
117
+ } catch (error) {
118
+ throw this.handleError(error);
119
+ }
120
+ }
121
+
122
+ /**
123
+ * Request withdrawal
124
+ */
125
+ async requestWithdrawal(data: WithdrawalRequest): Promise<TransactionResponse> {
126
+ try {
127
+ const res = await this.getClient().post('/wallet/withdraw', data);
128
+ return res.data;
129
+ } catch (error) {
130
+ throw this.handleError(error);
131
+ }
132
+ }
133
+ }
@@ -0,0 +1,241 @@
1
+ import { OxyServices } from '../OxyServices';
2
+ import { User, Notification } from '../../models/interfaces';
3
+ import { buildSearchParams, buildPaginationParams, PaginationParams } from '../../utils/apiUtils';
4
+
5
+ /**
6
+ * User service for handling user operations, profiles, and social features
7
+ */
8
+ export class UserService extends OxyServices {
9
+ /**
10
+ * Get profile by username
11
+ */
12
+ async getProfileByUsername(username: string): Promise<User> {
13
+ try {
14
+ const res = await this.getClient().get(`/users/profile/${username}`);
15
+ return res.data;
16
+ } catch (error) {
17
+ throw this.handleError(error);
18
+ }
19
+ }
20
+
21
+ /**
22
+ * Search user profiles
23
+ */
24
+ async searchProfiles(query: string, pagination?: PaginationParams): Promise<User[]> {
25
+ try {
26
+ const params = { query, ...pagination };
27
+ const searchParams = buildSearchParams(params);
28
+
29
+ const res = await this.getClient().get(`/users/search?${searchParams.toString()}`);
30
+ return res.data;
31
+ } catch (error) {
32
+ throw this.handleError(error);
33
+ }
34
+ }
35
+
36
+ /**
37
+ * Get profile recommendations
38
+ */
39
+ async getProfileRecommendations(): Promise<Array<{
40
+ id: string;
41
+ username: string;
42
+ name?: { first?: string; last?: string; full?: string };
43
+ description?: string;
44
+ _count?: { followers: number; following: number };
45
+ [key: string]: any;
46
+ }>> {
47
+ try {
48
+ const res = await this.getClient().get('/users/recommendations');
49
+ return res.data;
50
+ } catch (error) {
51
+ throw this.handleError(error);
52
+ }
53
+ }
54
+
55
+ /**
56
+ * Get user by ID
57
+ */
58
+ async getUserById(userId: string): Promise<User> {
59
+ try {
60
+ const res = await this.getClient().get(`/users/${userId}`);
61
+ return res.data;
62
+ } catch (error) {
63
+ throw this.handleError(error);
64
+ }
65
+ }
66
+
67
+ /**
68
+ * Get current user
69
+ */
70
+ async getCurrentUser(): Promise<User> {
71
+ try {
72
+ const res = await this.getClient().get('/users/me');
73
+ return res.data;
74
+ } catch (error) {
75
+ throw this.handleError(error);
76
+ }
77
+ }
78
+
79
+ /**
80
+ * Update user profile
81
+ */
82
+ async updateProfile(updates: Record<string, any>): Promise<User> {
83
+ try {
84
+ const res = await this.getClient().put('/users/profile', updates);
85
+ return res.data;
86
+ } catch (error) {
87
+ throw this.handleError(error);
88
+ }
89
+ }
90
+
91
+ /**
92
+ * Update user by ID (admin function)
93
+ */
94
+ async updateUser(userId: string, updates: Record<string, any>): Promise<User> {
95
+ try {
96
+ const res = await this.getClient().put(`/users/${userId}`, updates);
97
+ return res.data;
98
+ } catch (error) {
99
+ throw this.handleError(error);
100
+ }
101
+ }
102
+
103
+ /**
104
+ * Follow a user
105
+ */
106
+ async followUser(userId: string): Promise<{ success: boolean; message: string }> {
107
+ try {
108
+ const res = await this.getClient().post(`/users/${userId}/follow`);
109
+ return res.data;
110
+ } catch (error) {
111
+ throw this.handleError(error);
112
+ }
113
+ }
114
+
115
+ /**
116
+ * Unfollow a user
117
+ */
118
+ async unfollowUser(userId: string): Promise<{ success: boolean; message: string }> {
119
+ try {
120
+ const res = await this.getClient().delete(`/users/${userId}/follow`);
121
+ return res.data;
122
+ } catch (error) {
123
+ throw this.handleError(error);
124
+ }
125
+ }
126
+
127
+ /**
128
+ * Get follow status
129
+ */
130
+ async getFollowStatus(userId: string): Promise<{ isFollowing: boolean }> {
131
+ try {
132
+ const res = await this.getClient().get(`/users/${userId}/follow-status`);
133
+ return res.data;
134
+ } catch (error) {
135
+ throw this.handleError(error);
136
+ }
137
+ }
138
+
139
+ /**
140
+ * Get user followers
141
+ */
142
+ async getUserFollowers(
143
+ userId: string,
144
+ pagination?: PaginationParams
145
+ ): Promise<{ followers: User[]; total: number; hasMore: boolean }> {
146
+ try {
147
+ const searchParams = buildPaginationParams(pagination || {});
148
+
149
+ const res = await this.getClient().get(`/users/${userId}/followers?${searchParams.toString()}`);
150
+ return res.data;
151
+ } catch (error) {
152
+ throw this.handleError(error);
153
+ }
154
+ }
155
+
156
+ /**
157
+ * Get user following
158
+ */
159
+ async getUserFollowing(
160
+ userId: string,
161
+ pagination?: PaginationParams
162
+ ): Promise<{ following: User[]; total: number; hasMore: boolean }> {
163
+ try {
164
+ const searchParams = buildPaginationParams(pagination || {});
165
+
166
+ const res = await this.getClient().get(`/users/${userId}/following?${searchParams.toString()}`);
167
+ return res.data;
168
+ } catch (error) {
169
+ throw this.handleError(error);
170
+ }
171
+ }
172
+
173
+ /**
174
+ * Get notifications
175
+ */
176
+ async getNotifications(): Promise<Notification[]> {
177
+ try {
178
+ const res = await this.getClient().get('/notifications');
179
+ return res.data;
180
+ } catch (error) {
181
+ throw this.handleError(error);
182
+ }
183
+ }
184
+
185
+ /**
186
+ * Get unread notification count
187
+ */
188
+ async getUnreadCount(): Promise<number> {
189
+ try {
190
+ const res = await this.getClient().get('/notifications/unread-count');
191
+ return res.data.count;
192
+ } catch (error) {
193
+ throw this.handleError(error);
194
+ }
195
+ }
196
+
197
+ /**
198
+ * Create notification
199
+ */
200
+ async createNotification(data: Partial<Notification>): Promise<Notification> {
201
+ try {
202
+ const res = await this.getClient().post('/notifications', data);
203
+ return res.data;
204
+ } catch (error) {
205
+ throw this.handleError(error);
206
+ }
207
+ }
208
+
209
+ /**
210
+ * Mark notification as read
211
+ */
212
+ async markNotificationAsRead(notificationId: string): Promise<void> {
213
+ try {
214
+ await this.getClient().put(`/notifications/${notificationId}/read`);
215
+ } catch (error) {
216
+ throw this.handleError(error);
217
+ }
218
+ }
219
+
220
+ /**
221
+ * Mark all notifications as read
222
+ */
223
+ async markAllNotificationsAsRead(): Promise<void> {
224
+ try {
225
+ await this.getClient().put('/notifications/read-all');
226
+ } catch (error) {
227
+ throw this.handleError(error);
228
+ }
229
+ }
230
+
231
+ /**
232
+ * Delete notification
233
+ */
234
+ async deleteNotification(notificationId: string): Promise<void> {
235
+ try {
236
+ await this.getClient().delete(`/notifications/${notificationId}`);
237
+ } catch (error) {
238
+ throw this.handleError(error);
239
+ }
240
+ }
241
+ }
package/src/index.ts CHANGED
@@ -10,10 +10,6 @@
10
10
  export { OxyServices } from './core';
11
11
  export { OXY_CLOUD_URL } from './core';
12
12
 
13
- // Middleware exports (for server-side use)
14
- export type { AuthRequest, SimpleAuthRequest } from './types/middleware';
15
- export { createAuthMiddleware } from './middleware';
16
-
17
13
  // React context
18
14
  export {
19
15
  OxyContextProvider, // Backward compatibility
@@ -62,10 +58,10 @@ export type {
62
58
  } from './models/interfaces';
63
59
 
64
60
  export type {
65
- SecureLoginResponse,
66
- SecureClientSession,
61
+ SessionLoginResponse,
62
+ ClientSession,
67
63
  MinimalUserData
68
- } from './models/secureSession';
64
+ } from './models/session';
69
65
 
70
66
  // UI components and hooks
71
67
  export { useAuthStore } from './ui/stores/authStore';
@@ -73,4 +69,29 @@ export { useSessionSocket } from './ui/hooks/useSessionSocket';
73
69
 
74
70
  // UI components
75
71
  export { OxySignInButton } from './ui/components/OxySignInButton';
76
- export { OxyLogo, FollowButton } from './ui';
72
+ export { OxyLogo, FollowButton } from './ui';
73
+
74
+ // New consolidated utilities
75
+ export * from './utils/apiUtils';
76
+ export {
77
+ ErrorCodes,
78
+ createApiError,
79
+ handleHttpError,
80
+ validateRequiredFields,
81
+ retryWithBackoff
82
+ } from './utils/errorUtils';
83
+ export * from './utils/validationUtils';
84
+ export {
85
+ logger,
86
+ LogLevel,
87
+ LogContext,
88
+ logAuth,
89
+ logApi,
90
+ logSession,
91
+ logUser,
92
+ logDevice,
93
+ logPayment,
94
+ logPerformance
95
+ } from './utils/loggerUtils';
96
+ export * from './utils/asyncUtils';
97
+ export * from './utils/hookUtils';
@@ -1,4 +1,4 @@
1
- export interface SecureClientSession {
1
+ export interface ClientSession {
2
2
  sessionId: string;
3
3
  deviceId: string;
4
4
  expiresAt: string;
@@ -7,8 +7,8 @@ export interface SecureClientSession {
7
7
  userId?: string;
8
8
  }
9
9
 
10
- export interface SecureStorageKeys {
11
- sessions: string; // Array of SecureClientSession objects
10
+ export interface StorageKeys {
11
+ sessions: string; // Array of ClientSession objects
12
12
  activeSessionId: string; // ID of currently active session
13
13
  }
14
14
 
@@ -21,9 +21,9 @@ export interface MinimalUserData {
21
21
  };
22
22
  }
23
23
 
24
- export interface SecureLoginResponse {
24
+ export interface SessionLoginResponse {
25
25
  sessionId: string;
26
26
  deviceId: string;
27
27
  expiresAt: string;
28
28
  user: MinimalUserData;
29
- }
29
+ }