@oxyhq/services 0.1.0 → 0.1.2
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/README.md +144 -250
- package/dist/backend/auth.d.ts +37 -0
- package/dist/backend/index.d.ts +12 -0
- package/dist/backend/karma.d.ts +45 -0
- package/dist/backend/users.d.ts +39 -0
- package/dist/backend/wallet.d.ts +29 -0
- package/dist/bundle.js +2 -0
- package/dist/bundle.js.LICENSE.txt +9 -0
- package/dist/frontend/context/OxyContext.d.ts +20 -0
- package/dist/frontend/hooks/useAuth.d.ts +19 -0
- package/dist/frontend/hooks/useKarma.d.ts +27 -0
- package/dist/frontend/hooks/useUser.d.ts +13 -0
- package/dist/frontend/hooks/useWallet.d.ts +14 -0
- package/dist/frontend/index.d.ts +6 -0
- package/dist/index.d.ts +3 -28
- package/dist/shared/api-client.d.ts +15 -0
- package/dist/shared/types.d.ts +135 -0
- package/package.json +45 -71
- package/dist/components/AuthBottomSheet/types.d.ts +0 -24
- package/dist/components/AuthBottomSheet/types.js +0 -2
- package/dist/components/FileSelectorModal/types.d.ts +0 -35
- package/dist/components/FileSelectorModal/types.js +0 -2
- package/dist/components/SessionProvider.d.ts +0 -26
- package/dist/components/SessionProvider.js +0 -367
- package/dist/config.d.ts +0 -169
- package/dist/config.js +0 -115
- package/dist/constants.d.ts +0 -54
- package/dist/constants.js +0 -61
- package/dist/hooks/index.d.ts +0 -11
- package/dist/hooks/index.js +0 -23
- package/dist/hooks/useAuth.d.ts +0 -6
- package/dist/hooks/useAuth.js +0 -17
- package/dist/hooks/useFiles.d.ts +0 -10
- package/dist/hooks/useFiles.js +0 -329
- package/dist/hooks/useProfile.d.ts +0 -13
- package/dist/hooks/useProfile.js +0 -154
- package/dist/hooks/useSession.d.ts +0 -2
- package/dist/hooks/useSession.js +0 -12
- package/dist/hooks/useSubscription.d.ts +0 -15
- package/dist/hooks/useSubscription.js +0 -85
- package/dist/index.js +0 -82
- package/dist/package.json +0 -71
- package/dist/reducers/index.d.ts +0 -8
- package/dist/reducers/index.js +0 -29
- package/dist/reducers/profileReducer.d.ts +0 -55
- package/dist/reducers/profileReducer.js +0 -136
- package/dist/services/OxyClient.d.ts +0 -84
- package/dist/services/OxyClient.js +0 -309
- package/dist/services/api.service.d.ts +0 -61
- package/dist/services/api.service.js +0 -289
- package/dist/services/auth.service.d.ts +0 -87
- package/dist/services/auth.service.js +0 -266
- package/dist/services/index.d.ts +0 -30
- package/dist/services/index.js +0 -88
- package/dist/services/payment.service.d.ts +0 -20
- package/dist/services/payment.service.js +0 -56
- package/dist/services/privacy.service.d.ts +0 -16
- package/dist/services/privacy.service.js +0 -69
- package/dist/services/profile.service.d.ts +0 -20
- package/dist/services/profile.service.js +0 -158
- package/dist/services/subscription.service.d.ts +0 -7
- package/dist/services/subscription.service.js +0 -46
- package/dist/services/user.service.d.ts +0 -25
- package/dist/services/user.service.js +0 -109
- package/dist/styles/colors.d.ts +0 -24
- package/dist/styles/colors.js +0 -31
- package/dist/styles/shared.d.ts +0 -168
- package/dist/styles/shared.js +0 -177
- package/dist/types/index.d.ts +0 -136
- package/dist/types/index.js +0 -7
- package/dist/utils/api.d.ts +0 -20
- package/dist/utils/api.js +0 -546
- package/dist/utils/authEvents.d.ts +0 -44
- package/dist/utils/authEvents.js +0 -73
- package/dist/utils/errorHandler.d.ts +0 -68
- package/dist/utils/errorHandler.js +0 -166
- package/dist/utils/index.d.ts +0 -12
- package/dist/utils/index.js +0 -41
- package/dist/utils/logger.d.ts +0 -100
- package/dist/utils/logger.js +0 -298
- package/dist/utils/socket.d.ts +0 -6
- package/dist/utils/socket.js +0 -179
- package/dist/utils/socketConfig.d.ts +0 -32
- package/dist/utils/socketConfig.js +0 -67
- package/dist/utils/storage.d.ts +0 -54
- package/dist/utils/storage.js +0 -253
package/README.md
CHANGED
|
@@ -1,17 +1,13 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Oxy Services Module
|
|
2
2
|
|
|
3
|
-
A comprehensive
|
|
3
|
+
A comprehensive authentication, user management, and karma system module for Oxy applications.
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
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
|
-
##
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
### Backend Usage
|
|
23
21
|
|
|
24
22
|
```typescript
|
|
25
|
-
import {
|
|
26
|
-
|
|
27
|
-
// Initialize the
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
//
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
-
//
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
console.log('
|
|
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
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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
|
-
//
|
|
151
|
-
const
|
|
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
|
-
###
|
|
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
|
-
|
|
67
|
+
#### Using OxyProvider (Recommended)
|
|
180
68
|
|
|
181
69
|
```typescript
|
|
182
|
-
import
|
|
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
|
-
//
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
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
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
const
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
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
|
-
|
|
225
|
-
|
|
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
|
-
|
|
115
|
+
export default App;
|
|
116
|
+
```
|
|
232
117
|
|
|
233
|
-
|
|
118
|
+
#### Direct Usage (Without Provider)
|
|
234
119
|
|
|
235
120
|
```typescript
|
|
236
|
-
import
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
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
|
-
|
|
132
|
+
// Use user management hook
|
|
133
|
+
const user = useUser({
|
|
134
|
+
apiUrl: 'https://api.oxy.example.com',
|
|
135
|
+
getToken: auth.getToken
|
|
136
|
+
});
|
|
248
137
|
|
|
249
|
-
|
|
138
|
+
// Use karma hook
|
|
139
|
+
const karma = useKarma({
|
|
140
|
+
apiUrl: 'https://api.oxy.example.com',
|
|
141
|
+
getToken: auth.getToken
|
|
142
|
+
});
|
|
250
143
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
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
|
-
|
|
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
|
-
|
|
271
|
-
|
|
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
|
-
|
|
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
|
-
|
|
287
|
-
|
|
288
|
-
```typescript
|
|
289
|
-
import { logger } from '@oxyhq/services';
|
|
178
|
+
## API Reference
|
|
290
179
|
|
|
291
|
-
|
|
292
|
-
const componentLogger = logger.createScopedLogger('MyComponent');
|
|
180
|
+
### Backend Services
|
|
293
181
|
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
182
|
+
- `OxyAuthBackend` - Authentication services
|
|
183
|
+
- `OxyUsersBackend` - User management services
|
|
184
|
+
- `OxyKarmaBackend` - Karma/reputation services
|
|
185
|
+
- `OxyWalletBackend` - Wallet and transaction services
|
|
297
186
|
|
|
298
|
-
|
|
187
|
+
### Frontend Hooks & Context
|
|
299
188
|
|
|
300
|
-
|
|
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
|
-
|
|
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,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,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
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ApiResponse, UserProfile, PrivacySettings } from '../shared/types';
|
|
2
|
+
export declare class OxyUsersBackend {
|
|
3
|
+
private apiClient;
|
|
4
|
+
constructor(apiUrl: string);
|
|
5
|
+
/**
|
|
6
|
+
* Get a user by ID
|
|
7
|
+
*/
|
|
8
|
+
getUserById(userId: string): Promise<ApiResponse<UserProfile>>;
|
|
9
|
+
/**
|
|
10
|
+
* Get a user by username
|
|
11
|
+
*/
|
|
12
|
+
getUserByUsername(username: string): Promise<ApiResponse<UserProfile>>;
|
|
13
|
+
/**
|
|
14
|
+
* Update a user's profile
|
|
15
|
+
*/
|
|
16
|
+
updateUserProfile(userId: string, profileData: Partial<UserProfile>): Promise<ApiResponse<UserProfile>>;
|
|
17
|
+
/**
|
|
18
|
+
* Update a user's privacy settings
|
|
19
|
+
*/
|
|
20
|
+
updatePrivacySettings(userId: string, settings: Partial<PrivacySettings>): Promise<ApiResponse<PrivacySettings>>;
|
|
21
|
+
/**
|
|
22
|
+
* Get a user's privacy settings
|
|
23
|
+
*/
|
|
24
|
+
getPrivacySettings(userId: string): Promise<ApiResponse<PrivacySettings>>;
|
|
25
|
+
/**
|
|
26
|
+
* Convert username to user ID
|
|
27
|
+
*/
|
|
28
|
+
getUserIdFromUsername(username: string): Promise<ApiResponse<{
|
|
29
|
+
userId: string;
|
|
30
|
+
}>>;
|
|
31
|
+
/**
|
|
32
|
+
* Follow a user
|
|
33
|
+
*/
|
|
34
|
+
followUser(userId: string, targetUserId: string): Promise<ApiResponse<void>>;
|
|
35
|
+
/**
|
|
36
|
+
* Unfollow a user
|
|
37
|
+
*/
|
|
38
|
+
unfollowUser(userId: string, targetUserId: string): Promise<ApiResponse<void>>;
|
|
39
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ApiResponse, WalletInfo, TransactionInfo, TransferRequest, PurchaseRequest, WithdrawalRequest } from '../shared/types';
|
|
2
|
+
export declare class OxyWalletBackend {
|
|
3
|
+
private apiClient;
|
|
4
|
+
constructor(apiUrl: string);
|
|
5
|
+
/**
|
|
6
|
+
* Get wallet information for a user
|
|
7
|
+
*/
|
|
8
|
+
getWallet(userId: string): Promise<ApiResponse<WalletInfo>>;
|
|
9
|
+
/**
|
|
10
|
+
* Get transaction history for a user
|
|
11
|
+
*/
|
|
12
|
+
getTransactionHistory(userId: string, limit?: number, offset?: number): Promise<ApiResponse<TransactionInfo[]>>;
|
|
13
|
+
/**
|
|
14
|
+
* Transfer funds to another user
|
|
15
|
+
*/
|
|
16
|
+
transferFunds(transferRequest: TransferRequest): Promise<ApiResponse<TransactionInfo>>;
|
|
17
|
+
/**
|
|
18
|
+
* Process a purchase
|
|
19
|
+
*/
|
|
20
|
+
processPurchase(purchaseRequest: PurchaseRequest): Promise<ApiResponse<TransactionInfo>>;
|
|
21
|
+
/**
|
|
22
|
+
* Request a withdrawal
|
|
23
|
+
*/
|
|
24
|
+
requestWithdrawal(withdrawalRequest: WithdrawalRequest): Promise<ApiResponse<TransactionInfo>>;
|
|
25
|
+
/**
|
|
26
|
+
* Get a specific transaction
|
|
27
|
+
*/
|
|
28
|
+
getTransaction(transactionId: string): Promise<ApiResponse<TransactionInfo>>;
|
|
29
|
+
}
|