@oxyhq/services 0.1.0 → 0.1.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 (98) hide show
  1. package/README.md +144 -250
  2. package/dist/backend/auth.d.ts +37 -0
  3. package/dist/backend/auth.js +81 -0
  4. package/dist/backend/index.d.ts +12 -0
  5. package/dist/backend/index.js +20 -0
  6. package/dist/backend/karma.d.ts +45 -0
  7. package/dist/backend/karma.js +83 -0
  8. package/dist/backend/users.d.ts +39 -0
  9. package/dist/backend/users.js +87 -0
  10. package/dist/backend/wallet.d.ts +29 -0
  11. package/dist/backend/wallet.js +68 -0
  12. package/dist/bundle.js +2 -0
  13. package/dist/bundle.js.LICENSE.txt +1 -0
  14. package/dist/frontend/context/OxyContext.d.ts +20 -0
  15. package/dist/frontend/context/OxyContext.js +97 -0
  16. package/dist/frontend/hooks/useAuth.d.ts +19 -0
  17. package/dist/frontend/hooks/useAuth.js +234 -0
  18. package/dist/frontend/hooks/useKarma.d.ts +27 -0
  19. package/dist/frontend/hooks/useKarma.js +187 -0
  20. package/dist/frontend/hooks/useUser.d.ts +13 -0
  21. package/dist/frontend/hooks/useUser.js +136 -0
  22. package/dist/frontend/hooks/useWallet.d.ts +14 -0
  23. package/dist/frontend/hooks/useWallet.js +174 -0
  24. package/dist/frontend/index.d.ts +6 -0
  25. package/dist/frontend/index.js +14 -0
  26. package/dist/index.d.ts +3 -28
  27. package/dist/index.js +17 -66
  28. package/dist/shared/api-client.d.ts +15 -0
  29. package/dist/shared/api-client.js +197 -0
  30. package/dist/shared/types.d.ts +135 -0
  31. package/package.json +45 -71
  32. package/dist/components/AuthBottomSheet/types.d.ts +0 -24
  33. package/dist/components/FileSelectorModal/types.d.ts +0 -35
  34. package/dist/components/FileSelectorModal/types.js +0 -2
  35. package/dist/components/SessionProvider.d.ts +0 -26
  36. package/dist/components/SessionProvider.js +0 -367
  37. package/dist/config.d.ts +0 -169
  38. package/dist/config.js +0 -115
  39. package/dist/constants.d.ts +0 -54
  40. package/dist/constants.js +0 -61
  41. package/dist/hooks/index.d.ts +0 -11
  42. package/dist/hooks/index.js +0 -23
  43. package/dist/hooks/useAuth.d.ts +0 -6
  44. package/dist/hooks/useAuth.js +0 -17
  45. package/dist/hooks/useFiles.d.ts +0 -10
  46. package/dist/hooks/useFiles.js +0 -329
  47. package/dist/hooks/useProfile.d.ts +0 -13
  48. package/dist/hooks/useProfile.js +0 -154
  49. package/dist/hooks/useSession.d.ts +0 -2
  50. package/dist/hooks/useSession.js +0 -12
  51. package/dist/hooks/useSubscription.d.ts +0 -15
  52. package/dist/hooks/useSubscription.js +0 -85
  53. package/dist/package.json +0 -71
  54. package/dist/reducers/index.d.ts +0 -8
  55. package/dist/reducers/index.js +0 -29
  56. package/dist/reducers/profileReducer.d.ts +0 -55
  57. package/dist/reducers/profileReducer.js +0 -136
  58. package/dist/services/OxyClient.d.ts +0 -84
  59. package/dist/services/OxyClient.js +0 -309
  60. package/dist/services/api.service.d.ts +0 -61
  61. package/dist/services/api.service.js +0 -289
  62. package/dist/services/auth.service.d.ts +0 -87
  63. package/dist/services/auth.service.js +0 -266
  64. package/dist/services/index.d.ts +0 -30
  65. package/dist/services/index.js +0 -88
  66. package/dist/services/payment.service.d.ts +0 -20
  67. package/dist/services/payment.service.js +0 -56
  68. package/dist/services/privacy.service.d.ts +0 -16
  69. package/dist/services/privacy.service.js +0 -69
  70. package/dist/services/profile.service.d.ts +0 -20
  71. package/dist/services/profile.service.js +0 -158
  72. package/dist/services/subscription.service.d.ts +0 -7
  73. package/dist/services/subscription.service.js +0 -46
  74. package/dist/services/user.service.d.ts +0 -25
  75. package/dist/services/user.service.js +0 -109
  76. package/dist/styles/colors.d.ts +0 -24
  77. package/dist/styles/colors.js +0 -31
  78. package/dist/styles/shared.d.ts +0 -168
  79. package/dist/styles/shared.js +0 -177
  80. package/dist/types/index.d.ts +0 -136
  81. package/dist/types/index.js +0 -7
  82. package/dist/utils/api.d.ts +0 -20
  83. package/dist/utils/api.js +0 -546
  84. package/dist/utils/authEvents.d.ts +0 -44
  85. package/dist/utils/authEvents.js +0 -73
  86. package/dist/utils/errorHandler.d.ts +0 -68
  87. package/dist/utils/errorHandler.js +0 -166
  88. package/dist/utils/index.d.ts +0 -12
  89. package/dist/utils/index.js +0 -41
  90. package/dist/utils/logger.d.ts +0 -100
  91. package/dist/utils/logger.js +0 -298
  92. package/dist/utils/socket.d.ts +0 -6
  93. package/dist/utils/socket.js +0 -179
  94. package/dist/utils/socketConfig.d.ts +0 -32
  95. package/dist/utils/socketConfig.js +0 -67
  96. package/dist/utils/storage.d.ts +0 -54
  97. package/dist/utils/storage.js +0 -253
  98. /package/dist/{components/AuthBottomSheet → shared}/types.js +0 -0
package/README.md CHANGED
@@ -1,17 +1,13 @@
1
- # OxyHQ Services Module
1
+ # Oxy Services Module
2
2
 
3
- A comprehensive module for interacting with the OxyHQ platform APIs. This module provides authentication, profile management, file handling, and other services.
3
+ A comprehensive authentication, user management, and karma system module for Oxy applications.
4
4
 
5
5
  ## Features
6
6
 
7
- - 🔐 **Authentication**: Complete authentication flow with token management
8
- - 👤 **Profile Management**: User profile creation, retrieval, and updates
9
- - 📁 **File Handling**: Upload, download, and manage files
10
- - 💳 **Payments**: Process payments and manage subscriptions
11
- - 🔄 **Caching**: Efficient data caching for improved performance
12
- - 🔌 **Offline Support**: Graceful handling of offline scenarios
13
- - 📊 **Analytics**: User activity tracking and reporting
14
- - 🚀 **Performance Optimized**: Lazy loading, request deduplication, and more
7
+ - Authentication system with JWT support
8
+ - User profile management
9
+ - Karma/reputation system
10
+ - Wallet and transaction management
15
11
 
16
12
  ## Installation
17
13
 
@@ -19,286 +15,184 @@ A comprehensive module for interacting with the OxyHQ platform APIs. This module
19
15
  npm install @oxyhq/services
20
16
  ```
21
17
 
22
- ## Quick Start
18
+ ## Usage
19
+
20
+ ### Backend Usage
23
21
 
24
22
  ```typescript
25
- import { initialize, authService, oxyClient } from '@oxyhq/services';
26
-
27
- // Initialize the module with custom configuration
28
- initialize({
29
- apiUrl: 'https://api.your-instance.oxy.so',
30
- enableLogging: true,
31
- logLevel: 'debug'
32
- });
33
-
34
- // Use the authentication service
35
- const login = async () => {
36
- try {
37
- const result = await authService.login({
38
- email: 'user@example.com',
39
- password: 'password123'
40
- });
41
- console.log('Logged in successfully', result.user);
42
- } catch (error) {
43
- console.error('Login failed', error);
23
+ import { OxyBackend } from '@oxyhq/services';
24
+
25
+ // Initialize the backend services
26
+ const oxyBackend = new OxyBackend('https://api.oxy.example.com');
27
+
28
+ // Use authentication service
29
+ const login = async (username, password) => {
30
+ const response = await oxyBackend.auth.login({ username, password });
31
+ if (response.success) {
32
+ // Handle successful login
33
+ console.log('Tokens:', response.data);
34
+ } else {
35
+ // Handle login failure
36
+ console.error('Login failed:', response.error);
44
37
  }
45
38
  };
46
39
 
47
- // Get a user profile
48
- const getProfile = async (userId) => {
49
- try {
50
- const profile = await oxyClient.getProfile(userId);
51
- console.log('Profile retrieved', profile);
52
- } catch (error) {
53
- console.error('Failed to get profile', error);
40
+ // Use user service
41
+ const getUserProfile = async (userId) => {
42
+ const response = await oxyBackend.users.getUserById(userId);
43
+ if (response.success) {
44
+ console.log('User profile:', response.data);
54
45
  }
55
46
  };
56
- ```
57
-
58
- ## Architecture
59
-
60
- The OxyHQ Services module is built with a focus on performance, maintainability, and developer experience. Key architectural features include:
61
-
62
- ### Service Layer
63
-
64
- The module is organized into specialized services, each responsible for a specific domain:
65
-
66
- - **ApiService**: Core HTTP client with caching, retry logic, and token management
67
- - **AuthService**: Authentication and session management
68
- - **OxyClient**: High-level client for OxyHQ platform features
69
- - **ProfileService**: User profile management
70
- - **PaymentService**: Payment processing
71
- - **SubscriptionService**: Subscription management
72
- - **PrivacyService**: Privacy settings management
73
-
74
- ### Lazy Loading
75
-
76
- Services are lazy-loaded to minimize initial bundle size and improve startup performance. The module exports getter functions that instantiate services only when needed:
77
-
78
- ```typescript
79
- import { getAuthService, getOxyClient } from '@oxyhq/services';
80
-
81
- // Service is instantiated only when called
82
- const auth = getAuthService();
83
- ```
84
-
85
- ### Caching System
86
-
87
- The module includes a sophisticated caching system to minimize network requests:
88
-
89
- - **In-memory Cache**: Fast access to recently used data
90
- - **Persistent Cache**: Data is stored for offline access
91
- - **Cache Invalidation**: Automatic and manual cache invalidation strategies
92
- - **TTL Support**: Time-based expiration for cached items
93
-
94
- ### Error Handling
95
-
96
- Comprehensive error handling with:
97
-
98
- - **Error Normalization**: Consistent error format across services
99
- - **Retry Logic**: Automatic retry for transient failures
100
- - **Offline Detection**: Graceful handling of network unavailability
101
- - **Detailed Logging**: Contextual error information for debugging
102
-
103
- ### Logging
104
47
 
105
- A centralized logging system with:
106
-
107
- - **Log Levels**: DEBUG, INFO, WARN, ERROR, FATAL
108
- - **Context Support**: Logs include contextual information
109
- - **Remote Logging**: Optional sending of logs to a remote server
110
- - **Performance Metrics**: Timing of operations for performance analysis
111
- - **Sensitive Data Redaction**: Automatic redaction of sensitive information
112
-
113
- ## API Reference
114
-
115
- ### Core Services
116
-
117
- #### ApiService
118
-
119
- Low-level HTTP client with caching, retry logic, and token management.
120
-
121
- ```typescript
122
- import { apiService } from '@oxyhq/services';
123
-
124
- // GET request with caching
125
- const data = await apiService.get('/endpoint', {
126
- useCache: true,
127
- cacheTTL: 5 * 60 * 1000 // 5 minutes
128
- });
129
-
130
- // POST request
131
- const result = await apiService.post('/endpoint', { data: 'value' });
132
-
133
- // Cancel requests
134
- apiService.cancelAllRequests();
135
- ```
136
-
137
- #### OxyClient
138
-
139
- High-level client for OxyHQ platform features.
140
-
141
- ```typescript
142
- import { oxyClient } from '@oxyhq/services';
143
-
144
- // Get user profile
145
- const profile = await oxyClient.getProfile('user-id');
146
-
147
- // Get file data
148
- const files = await oxyClient.getFilesData(['file-id-1', 'file-id-2']);
48
+ // Use karma service
49
+ const getUserKarma = async (userId) => {
50
+ const response = await oxyBackend.karma.getUserKarma(userId);
51
+ if (response.success) {
52
+ console.log('User karma:', response.data.karma);
53
+ }
54
+ };
149
55
 
150
- // Get recommendations
151
- const recommendations = await oxyClient.getRecommendations(10);
56
+ // Use wallet service
57
+ const getWallet = async (userId) => {
58
+ const response = await oxyBackend.wallet.getWallet(userId);
59
+ if (response.success) {
60
+ console.log('Wallet balance:', response.data.balance);
61
+ }
62
+ };
152
63
  ```
153
64
 
154
- ### Authentication
155
-
156
- ```typescript
157
- import { authService } from '@oxyhq/services';
158
-
159
- // Login
160
- const loginResult = await authService.login({
161
- email: 'user@example.com',
162
- password: 'password123'
163
- });
164
-
165
- // Register
166
- const registerResult = await authService.register({
167
- username: 'newuser',
168
- email: 'newuser@example.com',
169
- password: 'password123'
170
- });
171
-
172
- // Logout
173
- await authService.logout();
174
-
175
- // Check if user is authenticated
176
- const isAuthenticated = await authService.isAuthenticated();
177
- ```
65
+ ### Frontend Usage (React)
178
66
 
179
- ### User Management
67
+ #### Using OxyProvider (Recommended)
180
68
 
181
69
  ```typescript
182
- import { userService } from '@oxyhq/services';
183
-
184
- // Get current user
185
- const currentUser = await userService.getCurrentUser();
186
-
187
- // Update user profile
188
- await userService.updateProfile({
189
- name: {
190
- first: 'John',
191
- last: 'Doe'
192
- },
193
- avatar: 'avatar-url'
194
- });
70
+ import React from 'react';
71
+ import { OxyProvider, useAuth, useUser, useKarma, useWallet } from '@oxyhq/services';
195
72
 
196
- // Follow a user
197
- await userService.followUser('user-id-to-follow');
198
-
199
- // Unfollow a user
200
- await userService.unfollowUser('user-id-to-unfollow');
201
- ```
202
-
203
- ### File Management
73
+ // Wrap your app with OxyProvider
74
+ function App() {
75
+ return (
76
+ <OxyProvider apiUrl="https://api.oxy.example.com" storage="local">
77
+ <AuthenticatedApp />
78
+ </OxyProvider>
79
+ );
80
+ }
204
81
 
205
- ```typescript
206
- import { useFiles } from '@oxyhq/services';
207
-
208
- // In a React component
209
- function MyComponent() {
210
- const {
211
- uploadFile,
212
- deleteFile,
213
- getFileUrl,
214
- isUploading
215
- } = useFiles();
216
-
217
- const handleUpload = async (file) => {
218
- const fileId = await uploadFile(file);
219
- console.log('File uploaded with ID:', fileId);
82
+ // Then in your components, you don't need to specify apiUrl
83
+ function AuthenticatedApp() {
84
+ // Use hooks without needing to specify apiUrl each time
85
+ const auth = useAuth();
86
+ const user = useUser();
87
+ const karma = useKarma();
88
+ const wallet = useWallet();
89
+
90
+ const handleLogin = async () => {
91
+ const result = await auth.login({
92
+ username: 'user123',
93
+ password: 'secure-password'
94
+ });
95
+
96
+ if (result.success) {
97
+ console.log('Logged in successfully');
98
+ }
220
99
  };
221
100
 
222
101
  return (
223
102
  <div>
224
- <input type="file" onChange={(e) => handleUpload(e.target.files[0])} />
225
- {isUploading && <p>Uploading...</p>}
103
+ {auth.isAuthenticated ? (
104
+ <div>
105
+ <h2>Welcome, {auth.user?.username}</h2>
106
+ <button onClick={auth.logout}>Logout</button>
107
+ </div>
108
+ ) : (
109
+ <button onClick={handleLogin}>Login</button>
110
+ )}
226
111
  </div>
227
112
  );
228
113
  }
229
- ```
230
114
 
231
- ### Configuration
115
+ export default App;
116
+ ```
232
117
 
233
- The module can be configured using the `initialize` function:
118
+ #### Direct Usage (Without Provider)
234
119
 
235
120
  ```typescript
236
- import { initialize } from '@oxyhq/services';
237
-
238
- initialize({
239
- apiUrl: 'https://api.custom-instance.oxy.so',
240
- cloudUrl: 'https://files.custom-instance.oxy.so',
241
- enableLogging: true,
242
- logLevel: 'debug',
243
- enableOfflineMode: true
244
- });
245
- ```
121
+ import React from 'react';
122
+ import { useAuth, useUser, useKarma, useWallet } from '@oxyhq/services';
123
+
124
+ function App() {
125
+ // Use authentication hook
126
+ const auth = useAuth({
127
+ apiUrl: 'https://api.oxy.example.com',
128
+ storage: 'local',
129
+ tokenRefreshInterval: 1000 * 60 * 15 // 15 minutes
130
+ });
246
131
 
247
- ## Advanced Usage
132
+ // Use user management hook
133
+ const user = useUser({
134
+ apiUrl: 'https://api.oxy.example.com',
135
+ getToken: auth.getToken
136
+ });
248
137
 
249
- ### Custom Error Handling
138
+ // Use karma hook
139
+ const karma = useKarma({
140
+ apiUrl: 'https://api.oxy.example.com',
141
+ getToken: auth.getToken
142
+ });
250
143
 
251
- ```typescript
252
- import { errorHandler } from '@oxyhq/services';
253
-
254
- try {
255
- // Your code
256
- } catch (error) {
257
- errorHandler.handleError(error, {
258
- context: 'Custom operation',
259
- fallbackMessage: 'Operation failed',
260
- showToast: true,
261
- onAuthError: () => {
262
- // Handle authentication errors
263
- }
144
+ // Use wallet hook
145
+ const wallet = useWallet({
146
+ apiUrl: 'https://api.oxy.example.com',
147
+ getToken: auth.getToken
264
148
  });
265
- }
266
- ```
267
149
 
268
- ### Performance Logging
150
+ const handleLogin = async () => {
151
+ const result = await auth.login({
152
+ username: 'user123',
153
+ password: 'secure-password'
154
+ });
155
+
156
+ if (result.success) {
157
+ console.log('Logged in successfully');
158
+ }
159
+ };
269
160
 
270
- ```typescript
271
- import { logger } from '@oxyhq/services';
161
+ return (
162
+ <div>
163
+ {auth.isAuthenticated ? (
164
+ <div>
165
+ <h2>Welcome, {auth.user?.username}</h2>
166
+ <button onClick={auth.logout}>Logout</button>
167
+ </div>
168
+ ) : (
169
+ <button onClick={handleLogin}>Login</button>
170
+ )}
171
+ </div>
172
+ );
173
+ }
272
174
 
273
- const performOperation = async () => {
274
- const startTime = Date.now();
275
-
276
- try {
277
- // Perform operation
278
- await someExpensiveOperation();
279
- } finally {
280
- // Log performance metrics
281
- logger.logPerformance('someExpensiveOperation', startTime, 'MyComponent');
282
- }
283
- };
175
+ export default App;
284
176
  ```
285
177
 
286
- ### Scoped Logging
287
-
288
- ```typescript
289
- import { logger } from '@oxyhq/services';
178
+ ## API Reference
290
179
 
291
- // Create a logger scoped to a specific context
292
- const componentLogger = logger.createScopedLogger('MyComponent');
180
+ ### Backend Services
293
181
 
294
- componentLogger.info('Component initialized');
295
- componentLogger.error('Error in component', { details: 'error details' });
296
- ```
182
+ - `OxyAuthBackend` - Authentication services
183
+ - `OxyUsersBackend` - User management services
184
+ - `OxyKarmaBackend` - Karma/reputation services
185
+ - `OxyWalletBackend` - Wallet and transaction services
297
186
 
298
- ## Contributing
187
+ ### Frontend Hooks & Context
299
188
 
300
- We welcome contributions to the OxyHQ Services module! Please see our [Contributing Guide](CONTRIBUTING.md) for more information.
189
+ - `OxyProvider` - Context provider for API URL and authentication
190
+ - `useOxyContext` - Hook to access the Oxy context
191
+ - `useAuth()` - Authentication hooks
192
+ - `useUser()` - User management hooks
193
+ - `useKarma()` - Karma/reputation hooks
194
+ - `useWallet()` - Wallet and transaction hooks
301
195
 
302
196
  ## License
303
197
 
304
- This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
198
+ MIT
@@ -0,0 +1,37 @@
1
+ import { ApiResponse, AuthTokens, UserCredentials, UserProfile, UserRegistration } from '../shared/types';
2
+ export declare class OxyAuthBackend {
3
+ private apiClient;
4
+ constructor(apiUrl: string);
5
+ /**
6
+ * Authenticate a user with username/email and password
7
+ */
8
+ login(credentials: UserCredentials): Promise<ApiResponse<AuthTokens>>;
9
+ /**
10
+ * Register a new user
11
+ */
12
+ register(userData: UserRegistration): Promise<ApiResponse<AuthTokens>>;
13
+ /**
14
+ * Refresh the authentication token
15
+ */
16
+ refreshToken(refreshToken: string): Promise<ApiResponse<AuthTokens>>;
17
+ /**
18
+ * Logout the current user
19
+ */
20
+ logout(refreshToken: string): Promise<ApiResponse<void>>;
21
+ /**
22
+ * Validate if a token is valid
23
+ */
24
+ validateToken(token: string): Promise<ApiResponse<{
25
+ valid: boolean;
26
+ }>>;
27
+ /**
28
+ * Get the current user's profile
29
+ */
30
+ getCurrentUser(token: string): Promise<ApiResponse<UserProfile>>;
31
+ /**
32
+ * Check if a username is available
33
+ */
34
+ checkUsernameAvailability(username: string): Promise<ApiResponse<{
35
+ available: boolean;
36
+ }>>;
37
+ }
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OxyAuthBackend = void 0;
4
+ const api_client_1 = require("../shared/api-client");
5
+ class OxyAuthBackend {
6
+ constructor(apiUrl) {
7
+ this.apiClient = new api_client_1.ApiClient({ apiUrl });
8
+ }
9
+ /**
10
+ * Authenticate a user with username/email and password
11
+ */
12
+ async login(credentials) {
13
+ return this.apiClient.request({
14
+ method: 'POST',
15
+ url: '/auth/login',
16
+ data: credentials
17
+ });
18
+ }
19
+ /**
20
+ * Register a new user
21
+ */
22
+ async register(userData) {
23
+ return this.apiClient.request({
24
+ method: 'POST',
25
+ url: '/auth/signup',
26
+ data: userData
27
+ });
28
+ }
29
+ /**
30
+ * Refresh the authentication token
31
+ */
32
+ async refreshToken(refreshToken) {
33
+ return this.apiClient.request({
34
+ method: 'POST',
35
+ url: '/auth/refresh-token',
36
+ data: { refreshToken }
37
+ });
38
+ }
39
+ /**
40
+ * Logout the current user
41
+ */
42
+ async logout(refreshToken) {
43
+ return this.apiClient.request({
44
+ method: 'POST',
45
+ url: '/auth/logout',
46
+ data: { refreshToken }
47
+ });
48
+ }
49
+ /**
50
+ * Validate if a token is valid
51
+ */
52
+ async validateToken(token) {
53
+ return this.apiClient.request({
54
+ method: 'POST',
55
+ url: '/auth/validate-token',
56
+ data: { token }
57
+ });
58
+ }
59
+ /**
60
+ * Get the current user's profile
61
+ */
62
+ async getCurrentUser(token) {
63
+ return this.apiClient.request({
64
+ method: 'GET',
65
+ url: '/auth/me',
66
+ headers: {
67
+ Authorization: `Bearer ${token}`
68
+ }
69
+ });
70
+ }
71
+ /**
72
+ * Check if a username is available
73
+ */
74
+ async checkUsernameAvailability(username) {
75
+ return this.apiClient.request({
76
+ method: 'GET',
77
+ url: `/auth/check-username/${username}`
78
+ });
79
+ }
80
+ }
81
+ exports.OxyAuthBackend = OxyAuthBackend;
@@ -0,0 +1,12 @@
1
+ import { OxyAuthBackend } from './auth';
2
+ import { OxyUsersBackend } from './users';
3
+ import { OxyKarmaBackend } from './karma';
4
+ import { OxyWalletBackend } from './wallet';
5
+ export { OxyAuthBackend, OxyUsersBackend, OxyKarmaBackend, OxyWalletBackend };
6
+ export declare class OxyBackend {
7
+ auth: OxyAuthBackend;
8
+ users: OxyUsersBackend;
9
+ karma: OxyKarmaBackend;
10
+ wallet: OxyWalletBackend;
11
+ constructor(apiUrl: string);
12
+ }
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OxyBackend = exports.OxyWalletBackend = exports.OxyKarmaBackend = exports.OxyUsersBackend = exports.OxyAuthBackend = void 0;
4
+ const auth_1 = require("./auth");
5
+ Object.defineProperty(exports, "OxyAuthBackend", { enumerable: true, get: function () { return auth_1.OxyAuthBackend; } });
6
+ const users_1 = require("./users");
7
+ Object.defineProperty(exports, "OxyUsersBackend", { enumerable: true, get: function () { return users_1.OxyUsersBackend; } });
8
+ const karma_1 = require("./karma");
9
+ Object.defineProperty(exports, "OxyKarmaBackend", { enumerable: true, get: function () { return karma_1.OxyKarmaBackend; } });
10
+ const wallet_1 = require("./wallet");
11
+ Object.defineProperty(exports, "OxyWalletBackend", { enumerable: true, get: function () { return wallet_1.OxyWalletBackend; } });
12
+ class OxyBackend {
13
+ constructor(apiUrl) {
14
+ this.auth = new auth_1.OxyAuthBackend(apiUrl);
15
+ this.users = new users_1.OxyUsersBackend(apiUrl);
16
+ this.karma = new karma_1.OxyKarmaBackend(apiUrl);
17
+ this.wallet = new wallet_1.OxyWalletBackend(apiUrl);
18
+ }
19
+ }
20
+ exports.OxyBackend = OxyBackend;
@@ -0,0 +1,45 @@
1
+ import { ApiResponse, KarmaAction, KarmaHistory, KarmaRule } from '../shared/types';
2
+ export declare class OxyKarmaBackend {
3
+ private apiClient;
4
+ constructor(apiUrl: string);
5
+ /**
6
+ * Get a user's karma total
7
+ */
8
+ getUserKarma(userId: string): Promise<ApiResponse<{
9
+ karma: number;
10
+ }>>;
11
+ /**
12
+ * Get a user's karma history (actions that affected karma)
13
+ */
14
+ getUserKarmaHistory(userId: string, limit?: number, offset?: number): Promise<ApiResponse<KarmaHistory>>;
15
+ /**
16
+ * Award karma points to a user for a specific action
17
+ */
18
+ awardKarma(karmaAction: KarmaAction): Promise<ApiResponse<{
19
+ success: boolean;
20
+ newTotal: number;
21
+ }>>;
22
+ /**
23
+ * Deduct karma points from a user for a specific action
24
+ */
25
+ deductKarma(karmaAction: KarmaAction): Promise<ApiResponse<{
26
+ success: boolean;
27
+ newTotal: number;
28
+ }>>;
29
+ /**
30
+ * Get the karma leaderboard (top users by karma)
31
+ */
32
+ getKarmaLeaderboard(limit?: number, offset?: number): Promise<ApiResponse<Array<{
33
+ userId: string;
34
+ username: string;
35
+ karma: number;
36
+ }>>>;
37
+ /**
38
+ * Get karma rules configuration
39
+ */
40
+ getKarmaRules(): Promise<ApiResponse<KarmaRule[]>>;
41
+ /**
42
+ * Admin only: Create or update a karma rule
43
+ */
44
+ createOrUpdateKarmaRule(rule: KarmaRule): Promise<ApiResponse<KarmaRule>>;
45
+ }