@oxyhq/services 5.9.1 → 5.9.3
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 +1 -33
- package/lib/commonjs/core/OxyServices.js +159 -0
- package/lib/commonjs/core/OxyServices.js.map +1 -0
- package/lib/commonjs/core/OxyServicesMain.js +51 -0
- package/lib/commonjs/core/OxyServicesMain.js.map +1 -0
- package/lib/commonjs/core/analytics/AnalyticsService.js +67 -0
- package/lib/commonjs/core/analytics/AnalyticsService.js.map +1 -0
- package/lib/commonjs/core/auth/AuthService.js +526 -0
- package/lib/commonjs/core/auth/AuthService.js.map +1 -0
- package/lib/commonjs/core/devices/DeviceService.js +61 -0
- package/lib/commonjs/core/devices/DeviceService.js.map +1 -0
- package/lib/commonjs/core/files/FileService.js +176 -0
- package/lib/commonjs/core/files/FileService.js.map +1 -0
- package/lib/commonjs/core/index.js +103 -1707
- package/lib/commonjs/core/index.js.map +1 -1
- package/lib/commonjs/core/karma/KarmaService.js +100 -0
- package/lib/commonjs/core/karma/KarmaService.js.map +1 -0
- package/lib/commonjs/core/locations/LocationService.js +131 -0
- package/lib/commonjs/core/locations/LocationService.js.map +1 -0
- package/lib/commonjs/core/payments/PaymentService.js +124 -0
- package/lib/commonjs/core/payments/PaymentService.js.map +1 -0
- package/lib/commonjs/core/users/UserService.js +234 -0
- package/lib/commonjs/core/users/UserService.js.map +1 -0
- package/lib/commonjs/index.js +164 -2
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/models/session.js +2 -0
- package/lib/{module/types/middleware.js.map → commonjs/models/session.js.map} +1 -1
- package/lib/commonjs/ui/context/OxyContext.js +28 -24
- package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
- package/lib/commonjs/ui/screens/AccountSwitcherScreen.js +2 -2
- package/lib/commonjs/ui/screens/AccountSwitcherScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/FileManagementScreen.js +12 -12
- package/lib/commonjs/ui/screens/FileManagementScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/ProfileScreen.js +2 -2
- package/lib/commonjs/ui/screens/ProfileScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/SessionManagementScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/SignInScreen.js +1 -1
- package/lib/commonjs/ui/screens/SignInScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/karma/KarmaCenterScreen.js +1 -1
- package/lib/commonjs/ui/screens/karma/KarmaCenterScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/karma/KarmaLeaderboardScreen.js +1 -1
- package/lib/commonjs/ui/screens/karma/KarmaLeaderboardScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/karma/KarmaRulesScreen.js +1 -1
- package/lib/commonjs/ui/screens/karma/KarmaRulesScreen.js.map +1 -1
- package/lib/commonjs/ui/stores/followStore.js +4 -4
- package/lib/commonjs/ui/stores/followStore.js.map +1 -1
- package/lib/commonjs/utils/apiUtils.js +93 -0
- package/lib/commonjs/utils/apiUtils.js.map +1 -0
- package/lib/commonjs/utils/asyncUtils.js +219 -0
- package/lib/commonjs/utils/asyncUtils.js.map +1 -0
- package/lib/commonjs/utils/errorUtils.js +148 -0
- package/lib/commonjs/utils/errorUtils.js.map +1 -0
- package/lib/commonjs/utils/hookUtils.js +399 -0
- package/lib/commonjs/utils/hookUtils.js.map +1 -0
- package/lib/commonjs/utils/loggerUtils.js +160 -0
- package/lib/commonjs/utils/loggerUtils.js.map +1 -0
- package/lib/commonjs/utils/validationUtils.js +174 -0
- package/lib/commonjs/utils/validationUtils.js.map +1 -0
- package/lib/module/core/OxyServices.js +153 -0
- package/lib/module/core/OxyServices.js.map +1 -0
- package/lib/module/core/OxyServicesMain.js +47 -0
- package/lib/module/core/OxyServicesMain.js.map +1 -0
- package/lib/module/core/analytics/AnalyticsService.js +62 -0
- package/lib/module/core/analytics/AnalyticsService.js.map +1 -0
- package/lib/module/core/auth/AuthService.js +521 -0
- package/lib/module/core/auth/AuthService.js.map +1 -0
- package/lib/module/core/devices/DeviceService.js +57 -0
- package/lib/module/core/devices/DeviceService.js.map +1 -0
- package/lib/module/core/files/FileService.js +171 -0
- package/lib/module/core/files/FileService.js.map +1 -0
- package/lib/module/core/index.js +25 -1694
- package/lib/module/core/index.js.map +1 -1
- package/lib/module/core/karma/KarmaService.js +95 -0
- package/lib/module/core/karma/KarmaService.js.map +1 -0
- package/lib/module/core/locations/LocationService.js +127 -0
- package/lib/module/core/locations/LocationService.js.map +1 -0
- package/lib/module/core/payments/PaymentService.js +119 -0
- package/lib/module/core/payments/PaymentService.js.map +1 -0
- package/lib/module/core/users/UserService.js +230 -0
- package/lib/module/core/users/UserService.js.map +1 -0
- package/lib/module/index.js +8 -4
- package/lib/module/index.js.map +1 -1
- package/lib/module/models/session.js +2 -0
- package/lib/{commonjs/types/middleware.js.map → module/models/session.js.map} +1 -1
- package/lib/module/ui/context/OxyContext.js +28 -24
- package/lib/module/ui/context/OxyContext.js.map +1 -1
- package/lib/module/ui/screens/AccountSwitcherScreen.js +2 -2
- package/lib/module/ui/screens/AccountSwitcherScreen.js.map +1 -1
- package/lib/module/ui/screens/FileManagementScreen.js +12 -12
- package/lib/module/ui/screens/FileManagementScreen.js.map +1 -1
- package/lib/module/ui/screens/ProfileScreen.js +2 -2
- package/lib/module/ui/screens/ProfileScreen.js.map +1 -1
- package/lib/module/ui/screens/SessionManagementScreen.js.map +1 -1
- package/lib/module/ui/screens/SignInScreen.js +1 -1
- package/lib/module/ui/screens/SignInScreen.js.map +1 -1
- package/lib/module/ui/screens/karma/KarmaCenterScreen.js +1 -1
- package/lib/module/ui/screens/karma/KarmaCenterScreen.js.map +1 -1
- package/lib/module/ui/screens/karma/KarmaLeaderboardScreen.js +1 -1
- package/lib/module/ui/screens/karma/KarmaLeaderboardScreen.js.map +1 -1
- package/lib/module/ui/screens/karma/KarmaRulesScreen.js +1 -1
- package/lib/module/ui/screens/karma/KarmaRulesScreen.js.map +1 -1
- package/lib/module/ui/stores/followStore.js +4 -4
- package/lib/module/ui/stores/followStore.js.map +1 -1
- package/lib/module/utils/apiUtils.js +85 -0
- package/lib/module/utils/apiUtils.js.map +1 -0
- package/lib/module/utils/asyncUtils.js +202 -0
- package/lib/module/utils/asyncUtils.js.map +1 -0
- package/lib/module/utils/errorUtils.js +139 -0
- package/lib/module/utils/errorUtils.js.map +1 -0
- package/lib/module/utils/hookUtils.js +381 -0
- package/lib/module/utils/hookUtils.js.map +1 -0
- package/lib/module/utils/loggerUtils.js +149 -0
- package/lib/module/utils/loggerUtils.js.map +1 -0
- package/lib/module/utils/validationUtils.js +154 -0
- package/lib/module/utils/validationUtils.js.map +1 -0
- package/lib/typescript/core/OxyServices.d.ts +64 -0
- package/lib/typescript/core/OxyServices.d.ts.map +1 -0
- package/lib/typescript/core/OxyServicesMain.d.ts +33 -0
- package/lib/typescript/core/OxyServicesMain.d.ts.map +1 -0
- package/lib/typescript/core/analytics/AnalyticsService.d.ts +26 -0
- package/lib/typescript/core/analytics/AnalyticsService.d.ts.map +1 -0
- package/lib/typescript/core/auth/AuthService.d.ts +165 -0
- package/lib/typescript/core/auth/AuthService.d.ts.map +1 -0
- package/lib/typescript/core/devices/DeviceService.d.ts +20 -0
- package/lib/typescript/core/devices/DeviceService.d.ts.map +1 -0
- package/lib/typescript/core/files/FileService.d.ts +59 -0
- package/lib/typescript/core/files/FileService.d.ts.map +1 -0
- package/lib/typescript/core/index.d.ts +19 -657
- package/lib/typescript/core/index.d.ts.map +1 -1
- package/lib/typescript/core/karma/KarmaService.d.ts +50 -0
- package/lib/typescript/core/karma/KarmaService.d.ts.map +1 -0
- package/lib/typescript/core/locations/LocationService.d.ts +39 -0
- package/lib/typescript/core/locations/LocationService.d.ts.map +1 -0
- package/lib/typescript/core/payments/PaymentService.d.ts +50 -0
- package/lib/typescript/core/payments/PaymentService.d.ts.map +1 -0
- package/lib/typescript/core/users/UserService.d.ts +111 -0
- package/lib/typescript/core/users/UserService.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +7 -3
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/models/{secureSession.d.ts → session.d.ts} +4 -4
- package/lib/typescript/models/session.d.ts.map +1 -0
- package/lib/typescript/ui/context/OxyContext.d.ts +2 -2
- package/lib/typescript/ui/context/OxyContext.d.ts.map +1 -1
- package/lib/typescript/utils/apiUtils.d.ts +61 -0
- package/lib/typescript/utils/apiUtils.d.ts.map +1 -0
- package/lib/typescript/utils/asyncUtils.d.ts +64 -0
- package/lib/typescript/utils/asyncUtils.d.ts.map +1 -0
- package/lib/typescript/utils/errorUtils.d.ts +45 -0
- package/lib/typescript/utils/errorUtils.d.ts.map +1 -0
- package/lib/typescript/utils/hookUtils.d.ts +102 -0
- package/lib/typescript/utils/hookUtils.d.ts.map +1 -0
- package/lib/typescript/utils/loggerUtils.d.ts +49 -0
- package/lib/typescript/utils/loggerUtils.d.ts.map +1 -0
- package/lib/typescript/utils/validationUtils.d.ts +80 -0
- package/lib/typescript/utils/validationUtils.d.ts.map +1 -0
- package/package.json +2 -8
- package/src/core/OxyServices.ts +168 -0
- package/src/core/OxyServicesMain.ts +57 -0
- package/src/core/analytics/AnalyticsService.ts +64 -0
- package/src/core/auth/AuthService.ts +544 -0
- package/src/core/devices/DeviceService.ts +55 -0
- package/src/core/files/FileService.ts +194 -0
- package/src/core/index.ts +26 -1769
- package/src/core/karma/KarmaService.ts +104 -0
- package/src/core/locations/LocationService.ts +141 -0
- package/src/core/payments/PaymentService.ts +133 -0
- package/src/core/users/UserService.ts +241 -0
- package/src/index.ts +29 -8
- package/src/models/{secureSession.ts → session.ts} +5 -5
- package/src/ui/context/OxyContext.tsx +34 -30
- package/src/ui/screens/AccountSwitcherScreen.tsx +4 -4
- package/src/ui/screens/FileManagementScreen.tsx +12 -12
- package/src/ui/screens/ProfileScreen.tsx +3 -3
- package/src/ui/screens/SessionManagementScreen.tsx +2 -2
- package/src/ui/screens/SignInScreen.tsx +1 -1
- package/src/ui/screens/karma/KarmaCenterScreen.tsx +2 -2
- package/src/ui/screens/karma/KarmaLeaderboardScreen.tsx +3 -3
- package/src/ui/screens/karma/KarmaRulesScreen.tsx +3 -3
- package/src/ui/stores/followStore.ts +4 -4
- package/src/utils/apiUtils.ts +102 -0
- package/src/utils/asyncUtils.ts +265 -0
- package/src/utils/errorUtils.ts +172 -0
- package/src/utils/hookUtils.ts +397 -0
- package/src/utils/loggerUtils.ts +153 -0
- package/src/utils/validationUtils.ts +158 -0
- package/lib/commonjs/models/secureSession.js +0 -2
- package/lib/commonjs/models/secureSession.js.map +0 -1
- package/lib/commonjs/types/middleware.js +0 -6
- package/lib/module/models/secureSession.js +0 -2
- package/lib/module/models/secureSession.js.map +0 -1
- package/lib/module/types/middleware.js +0 -4
- package/lib/typescript/models/secureSession.d.ts.map +0 -1
- package/lib/typescript/types/middleware.d.ts +0 -19
- package/lib/typescript/types/middleware.d.ts.map +0 -1
- package/src/types/middleware.ts +0 -20
package/README.md
CHANGED
|
@@ -110,13 +110,7 @@ const user = await oxy.users.getCurrentUser();
|
|
|
110
110
|
|
|
111
111
|
## Documentation
|
|
112
112
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
- [📚 Full Documentation](./docs/README.md)
|
|
116
|
-
- [🚀 Quick Start Guide](./docs/quick-start.md)
|
|
117
|
-
- [🔐 Core API Reference](./docs/core-api.md)
|
|
118
|
-
- [⚡ Streamlined Authentication](./docs/core-api.md#streamlined-authentication) - **NEW!**
|
|
119
|
-
- [💼 Integration Examples](./docs/examples/)
|
|
113
|
+
This package provides a TypeScript client library for the Oxy API with authentication, user management, and UI components.
|
|
120
114
|
|
|
121
115
|
## UI Components
|
|
122
116
|
|
|
@@ -141,19 +135,7 @@ import { OxyProvider, Avatar } from '@oxyhq/services/ui';
|
|
|
141
135
|
import { OxyServices, OxyProvider } from '@oxyhq/services/full';
|
|
142
136
|
```
|
|
143
137
|
|
|
144
|
-
## Zero-Config Express Router
|
|
145
|
-
|
|
146
|
-
Quickly mount authentication routes in any Express app:
|
|
147
|
-
|
|
148
|
-
```typescript
|
|
149
|
-
import express from 'express';
|
|
150
|
-
import { createAuth } from '@oxyhq/services/core';
|
|
151
|
-
|
|
152
|
-
const app = express();
|
|
153
|
-
app.use('/auth', createAuth({ baseURL: 'http://localhost:3000' }).middleware());
|
|
154
|
-
```
|
|
155
138
|
|
|
156
|
-
This automatically provides sign-up, login, logout, refresh, and session management endpoints.
|
|
157
139
|
|
|
158
140
|
## Requirements
|
|
159
141
|
|
|
@@ -205,22 +187,8 @@ npm install
|
|
|
205
187
|
|
|
206
188
|
# Build the library
|
|
207
189
|
npm run build
|
|
208
|
-
|
|
209
|
-
# Run tests
|
|
210
|
-
npm test
|
|
211
|
-
|
|
212
|
-
# Development mode
|
|
213
|
-
npm run dev
|
|
214
190
|
```
|
|
215
191
|
|
|
216
|
-
## Integration
|
|
217
|
-
|
|
218
|
-
This library works with:
|
|
219
|
-
- **[Oxy API](../oxy-api/)** - The companion authentication server
|
|
220
|
-
- **Express.js** - Built-in middleware support
|
|
221
|
-
- **React/React Native** - UI components and hooks
|
|
222
|
-
- **Next.js** - SSR/SSG authentication
|
|
223
|
-
|
|
224
192
|
## License
|
|
225
193
|
|
|
226
194
|
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.OxyServices = void 0;
|
|
7
|
+
var _axios = _interopRequireDefault(require("axios"));
|
|
8
|
+
var _jwtDecode = require("jwt-decode");
|
|
9
|
+
var _errorUtils = require("../utils/errorUtils");
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
/**
|
|
12
|
+
* OxyServices - Base client library for interacting with the Oxy API
|
|
13
|
+
*
|
|
14
|
+
* This class provides the core HTTP client setup, token management, and error handling.
|
|
15
|
+
* Specific functionality is delegated to focused service modules.
|
|
16
|
+
*/
|
|
17
|
+
class OxyServices {
|
|
18
|
+
accessToken = null;
|
|
19
|
+
refreshToken = null;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Creates a new instance of the OxyServices client
|
|
23
|
+
* @param config - Configuration for the client
|
|
24
|
+
*/
|
|
25
|
+
constructor(config) {
|
|
26
|
+
this.client = _axios.default.create({
|
|
27
|
+
baseURL: config.baseURL,
|
|
28
|
+
timeout: 10000 // 10 second timeout
|
|
29
|
+
});
|
|
30
|
+
this.setupInterceptors();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Setup axios interceptors for authentication and error handling
|
|
35
|
+
*/
|
|
36
|
+
setupInterceptors() {
|
|
37
|
+
// Request interceptor for adding auth header and handling token refresh
|
|
38
|
+
this.client.interceptors.request.use(async req => {
|
|
39
|
+
if (!this.accessToken) {
|
|
40
|
+
return req;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Check if token is expired and refresh if needed
|
|
44
|
+
try {
|
|
45
|
+
const decoded = (0, _jwtDecode.jwtDecode)(this.accessToken);
|
|
46
|
+
const currentTime = Math.floor(Date.now() / 1000);
|
|
47
|
+
|
|
48
|
+
// If token expires in less than 60 seconds, refresh it
|
|
49
|
+
if (decoded.exp - currentTime < 60) {
|
|
50
|
+
// For session-based tokens, get a new token from the session
|
|
51
|
+
if (decoded.sessionId) {
|
|
52
|
+
try {
|
|
53
|
+
const res = await this.client.get(`/session/token/${decoded.sessionId}`);
|
|
54
|
+
this.accessToken = res.data.accessToken;
|
|
55
|
+
} catch (refreshError) {
|
|
56
|
+
// If refresh fails, clear tokens
|
|
57
|
+
this.clearTokens();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Add authorization header
|
|
63
|
+
req.headers.Authorization = `Bearer ${this.accessToken}`;
|
|
64
|
+
} catch (error) {
|
|
65
|
+
// If token is invalid, clear it
|
|
66
|
+
this.clearTokens();
|
|
67
|
+
}
|
|
68
|
+
return req;
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Get the configured base URL
|
|
74
|
+
*/
|
|
75
|
+
getBaseURL() {
|
|
76
|
+
return this.client.defaults.baseURL || '';
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Set authentication tokens
|
|
81
|
+
*/
|
|
82
|
+
setTokens(accessToken, refreshToken = '') {
|
|
83
|
+
this.accessToken = accessToken;
|
|
84
|
+
this.refreshToken = refreshToken;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Clear stored authentication tokens
|
|
89
|
+
*/
|
|
90
|
+
clearTokens() {
|
|
91
|
+
this.accessToken = null;
|
|
92
|
+
this.refreshToken = null;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Get the current user ID from the access token
|
|
97
|
+
*/
|
|
98
|
+
getCurrentUserId() {
|
|
99
|
+
if (!this.accessToken) {
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
try {
|
|
103
|
+
const decoded = (0, _jwtDecode.jwtDecode)(this.accessToken);
|
|
104
|
+
return decoded.userId || decoded.id || null;
|
|
105
|
+
} catch (error) {
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Check if the client has a valid access token
|
|
112
|
+
*/
|
|
113
|
+
hasAccessToken() {
|
|
114
|
+
return !!this.accessToken;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Validate the current access token with the server
|
|
119
|
+
*/
|
|
120
|
+
async validate() {
|
|
121
|
+
if (!this.hasAccessToken()) {
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
try {
|
|
125
|
+
const res = await this.client.get('/auth/validate');
|
|
126
|
+
return res.data.valid === true;
|
|
127
|
+
} catch (error) {
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Get the HTTP client instance (protected for use by service modules)
|
|
134
|
+
*/
|
|
135
|
+
getClient() {
|
|
136
|
+
return this.client;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Centralized error handling
|
|
141
|
+
*/
|
|
142
|
+
handleError(error) {
|
|
143
|
+
return (0, _errorUtils.handleHttpError)(error);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Health check endpoint
|
|
148
|
+
*/
|
|
149
|
+
async healthCheck() {
|
|
150
|
+
try {
|
|
151
|
+
const res = await this.client.get('/health');
|
|
152
|
+
return res.data;
|
|
153
|
+
} catch (error) {
|
|
154
|
+
throw this.handleError(error);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
exports.OxyServices = OxyServices;
|
|
159
|
+
//# sourceMappingURL=OxyServices.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_axios","_interopRequireDefault","require","_jwtDecode","_errorUtils","e","__esModule","default","OxyServices","accessToken","refreshToken","constructor","config","client","axios","create","baseURL","timeout","setupInterceptors","interceptors","request","use","req","decoded","jwtDecode","currentTime","Math","floor","Date","now","exp","sessionId","res","get","data","refreshError","clearTokens","headers","Authorization","error","getBaseURL","defaults","setTokens","getCurrentUserId","userId","id","hasAccessToken","validate","valid","getClient","handleError","handleHttpError","healthCheck","exports"],"sourceRoot":"../../../src","sources":["core/OxyServices.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAEA,IAAAE,WAAA,GAAAF,OAAA;AAAsD,SAAAD,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAA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c,KAAK,KAAK,IAAI;IAChC,CAAC,CAAC,OAAOT,KAAK,EAAE;MACd,OAAO,KAAK;IACd;EACF;;EAEA;AACF;AACA;EACYU,SAASA,CAAA,EAAkB;IACnC,OAAO,IAAI,CAACpC,MAAM;EACpB;;EAEA;AACF;AACA;EACYqC,WAAWA,CAACX,KAAU,EAAY;IAC1C,OAAO,IAAAY,2BAAe,EAACZ,KAAK,CAAC;EAC/B;;EAEA;AACF;AACA;EACE,MAAMa,WAAWA,CAAA,EAKd;IACD,IAAI;MACF,MAAMpB,GAAG,GAAG,MAAM,IAAI,CAACnB,MAAM,CAACoB,GAAG,CAAC,SAAS,CAAC;MAC5C,OAAOD,GAAG,CAACE,IAAI;IACjB,CAAC,CAAC,OAAOK,KAAK,EAAE;MACd,MAAM,IAAI,CAACW,WAAW,CAACX,KAAK,CAAC;IAC/B;EACF;AACF;AAACc,OAAA,CAAA7C,WAAA,GAAAA,WAAA","ignoreList":[]}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.OxyServicesMain = void 0;
|
|
7
|
+
var _AuthService = require("./auth/AuthService");
|
|
8
|
+
var _UserService = require("./users/UserService");
|
|
9
|
+
var _PaymentService = require("./payments/PaymentService");
|
|
10
|
+
var _KarmaService = require("./karma/KarmaService");
|
|
11
|
+
var _FileService = require("./files/FileService");
|
|
12
|
+
var _LocationService = require("./locations/LocationService");
|
|
13
|
+
var _AnalyticsService = require("./analytics/AnalyticsService");
|
|
14
|
+
var _DeviceService = require("./devices/DeviceService");
|
|
15
|
+
/**
|
|
16
|
+
* Main OxyServices class that combines all individual services
|
|
17
|
+
*
|
|
18
|
+
* This class provides a unified interface to all Oxy API services while maintaining
|
|
19
|
+
* backward compatibility with the original monolithic structure.
|
|
20
|
+
*/
|
|
21
|
+
class OxyServicesMain extends _AuthService.AuthService {
|
|
22
|
+
// Service instances
|
|
23
|
+
|
|
24
|
+
constructor(config) {
|
|
25
|
+
super(config);
|
|
26
|
+
|
|
27
|
+
// Initialize all service instances
|
|
28
|
+
this.users = new _UserService.UserService(config);
|
|
29
|
+
this.payments = new _PaymentService.PaymentService(config);
|
|
30
|
+
this.karma = new _KarmaService.KarmaService(config);
|
|
31
|
+
this.files = new _FileService.FileService(config);
|
|
32
|
+
this.locations = new _LocationService.LocationService(config);
|
|
33
|
+
this.analytics = new _AnalyticsService.AnalyticsService(config);
|
|
34
|
+
this.devices = new _DeviceService.DeviceService(config);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Re-export OXY_CLOUD_URL for convenience
|
|
38
|
+
static OXY_CLOUD_URL = _FileService.OXY_CLOUD_URL;
|
|
39
|
+
|
|
40
|
+
// Additional utility methods that span multiple services
|
|
41
|
+
async fetchLinkMetadata(url) {
|
|
42
|
+
try {
|
|
43
|
+
const res = await this.getClient().get(`/link-metadata?url=${encodeURIComponent(url)}`);
|
|
44
|
+
return res.data;
|
|
45
|
+
} catch (error) {
|
|
46
|
+
throw this.handleError(error);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.OxyServicesMain = OxyServicesMain;
|
|
51
|
+
//# sourceMappingURL=OxyServicesMain.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_AuthService","require","_UserService","_PaymentService","_KarmaService","_FileService","_LocationService","_AnalyticsService","_DeviceService","OxyServicesMain","AuthService","constructor","config","users","UserService","payments","PaymentService","karma","KarmaService","files","FileService","locations","LocationService","analytics","AnalyticsService","devices","DeviceService","OXY_CLOUD_URL","fetchLinkMetadata","url","res","getClient","get","encodeURIComponent","data","error","handleError","exports"],"sourceRoot":"../../../src","sources":["core/OxyServicesMain.ts"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAA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2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.AnalyticsService = void 0;
|
|
7
|
+
var _OxyServices = require("../OxyServices");
|
|
8
|
+
/**
|
|
9
|
+
* Analytics service for handling analytics and content viewer operations
|
|
10
|
+
*/
|
|
11
|
+
class AnalyticsService extends _OxyServices.OxyServices {
|
|
12
|
+
/**
|
|
13
|
+
* Get analytics data for user
|
|
14
|
+
*/
|
|
15
|
+
async getAnalytics(userId, period) {
|
|
16
|
+
try {
|
|
17
|
+
const params = new URLSearchParams();
|
|
18
|
+
if (period) params.append('period', period);
|
|
19
|
+
const res = await this.getClient().get(`/analytics/users/${userId}?${params.toString()}`);
|
|
20
|
+
return res.data;
|
|
21
|
+
} catch (error) {
|
|
22
|
+
throw this.handleError(error);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Update analytics data
|
|
28
|
+
*/
|
|
29
|
+
async updateAnalytics(userId, type, data) {
|
|
30
|
+
try {
|
|
31
|
+
const res = await this.getClient().put(`/analytics/users/${userId}/${type}`, data);
|
|
32
|
+
return res.data;
|
|
33
|
+
} catch (error) {
|
|
34
|
+
throw this.handleError(error);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Get content viewers for user
|
|
40
|
+
*/
|
|
41
|
+
async getContentViewers(userId, period) {
|
|
42
|
+
try {
|
|
43
|
+
const params = new URLSearchParams();
|
|
44
|
+
if (period) params.append('period', period);
|
|
45
|
+
const res = await this.getClient().get(`/analytics/users/${userId}/viewers?${params.toString()}`);
|
|
46
|
+
return res.data;
|
|
47
|
+
} catch (error) {
|
|
48
|
+
throw this.handleError(error);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Get follower details for user
|
|
54
|
+
*/
|
|
55
|
+
async getFollowerDetails(userId, period) {
|
|
56
|
+
try {
|
|
57
|
+
const params = new URLSearchParams();
|
|
58
|
+
if (period) params.append('period', period);
|
|
59
|
+
const res = await this.getClient().get(`/analytics/users/${userId}/followers?${params.toString()}`);
|
|
60
|
+
return res.data;
|
|
61
|
+
} catch (error) {
|
|
62
|
+
throw this.handleError(error);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.AnalyticsService = AnalyticsService;
|
|
67
|
+
//# sourceMappingURL=AnalyticsService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_OxyServices","require","AnalyticsService","OxyServices","getAnalytics","userId","period","params","URLSearchParams","append","res","getClient","get","toString","data","error","handleError","updateAnalytics","type","put","getContentViewers","getFollowerDetails","exports"],"sourceRoot":"../../../../src","sources":["core/analytics/AnalyticsService.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAGA;AACA;AACA;AACO,MAAMC,gBAAgB,SAASC,wBAAW,CAAC;EAChD;AACF;AACA;EACE,MAAMC,YAAYA,CAACC,MAAc,EAAEC,MAAe,EAA0B;IAC1E,IAAI;MACF,MAAMC,MAAM,GAAG,IAAIC,eAAe,CAAC,CAAC;MACpC,IAAIF,MAAM,EAAEC,MAAM,CAACE,MAAM,CAAC,QAAQ,EAAEH,MAAM,CAAC;MAE3C,MAAMI,GAAG,GAAG,MAAM,IAAI,CAACC,SAAS,CAAC,CAAC,CAACC,GAAG,CAAC,oBAAoBP,MAAM,IAAIE,MAAM,CAACM,QAAQ,CAAC,CAAC,EAAE,CAAC;MACzF,OAAOH,GAAG,CAACI,IAAI;IACjB,CAAC,CAAC,OAAOC,KAAK,EAAE;MACd,MAAM,IAAI,CAACC,WAAW,CAACD,KAAK,CAAC;IAC/B;EACF;;EAEA;AACF;AACA;EACE,MAAME,eAAeA,CAACZ,MAAc,EAAEa,IAAY,EAAEJ,IAAyB,EAAgC;IAC3G,IAAI;MACF,MAAMJ,GAAG,GAAG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