@oxyhq/services 5.10.4 → 5.10.5

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 (114) hide show
  1. package/README.md +62 -14
  2. package/lib/commonjs/core/OxyServices.js +796 -4
  3. package/lib/commonjs/core/OxyServices.js.map +1 -1
  4. package/lib/commonjs/core/index.js +8 -83
  5. package/lib/commonjs/core/index.js.map +1 -1
  6. package/lib/commonjs/ui/screens/FileManagementScreen.js +12 -12
  7. package/lib/commonjs/ui/screens/FileManagementScreen.js.map +1 -1
  8. package/lib/commonjs/ui/screens/ProfileScreen.js +2 -2
  9. package/lib/commonjs/ui/screens/ProfileScreen.js.map +1 -1
  10. package/lib/commonjs/ui/screens/SignInScreen.js +1 -1
  11. package/lib/commonjs/ui/screens/SignInScreen.js.map +1 -1
  12. package/lib/commonjs/ui/screens/karma/KarmaCenterScreen.js +1 -1
  13. package/lib/commonjs/ui/screens/karma/KarmaCenterScreen.js.map +1 -1
  14. package/lib/commonjs/ui/screens/karma/KarmaLeaderboardScreen.js +1 -1
  15. package/lib/commonjs/ui/screens/karma/KarmaLeaderboardScreen.js.map +1 -1
  16. package/lib/commonjs/ui/screens/karma/KarmaRulesScreen.js +1 -1
  17. package/lib/commonjs/ui/screens/karma/KarmaRulesScreen.js.map +1 -1
  18. package/lib/commonjs/ui/stores/followStore.js +4 -4
  19. package/lib/commonjs/ui/stores/followStore.js.map +1 -1
  20. package/lib/module/core/OxyServices.js +795 -3
  21. package/lib/module/core/OxyServices.js.map +1 -1
  22. package/lib/module/core/index.js +9 -24
  23. package/lib/module/core/index.js.map +1 -1
  24. package/lib/module/ui/screens/FileManagementScreen.js +12 -12
  25. package/lib/module/ui/screens/FileManagementScreen.js.map +1 -1
  26. package/lib/module/ui/screens/ProfileScreen.js +2 -2
  27. package/lib/module/ui/screens/ProfileScreen.js.map +1 -1
  28. package/lib/module/ui/screens/SignInScreen.js +1 -1
  29. package/lib/module/ui/screens/SignInScreen.js.map +1 -1
  30. package/lib/module/ui/screens/karma/KarmaCenterScreen.js +1 -1
  31. package/lib/module/ui/screens/karma/KarmaCenterScreen.js.map +1 -1
  32. package/lib/module/ui/screens/karma/KarmaLeaderboardScreen.js +1 -1
  33. package/lib/module/ui/screens/karma/KarmaLeaderboardScreen.js.map +1 -1
  34. package/lib/module/ui/screens/karma/KarmaRulesScreen.js +1 -1
  35. package/lib/module/ui/screens/karma/KarmaRulesScreen.js.map +1 -1
  36. package/lib/module/ui/stores/followStore.js +4 -4
  37. package/lib/module/ui/stores/followStore.js.map +1 -1
  38. package/lib/typescript/core/OxyServices.d.ts +290 -1
  39. package/lib/typescript/core/OxyServices.d.ts.map +1 -1
  40. package/lib/typescript/core/index.d.ts +7 -16
  41. package/lib/typescript/core/index.d.ts.map +1 -1
  42. package/package.json +1 -1
  43. package/src/core/OxyServices.ts +881 -46
  44. package/src/core/index.ts +9 -24
  45. package/src/ui/screens/FileManagementScreen.tsx +12 -12
  46. package/src/ui/screens/ProfileScreen.tsx +3 -3
  47. package/src/ui/screens/SignInScreen.tsx +1 -1
  48. package/src/ui/screens/karma/KarmaCenterScreen.tsx +2 -2
  49. package/src/ui/screens/karma/KarmaLeaderboardScreen.tsx +1 -1
  50. package/src/ui/screens/karma/KarmaRulesScreen.tsx +1 -1
  51. package/src/ui/stores/followStore.ts +4 -4
  52. package/lib/commonjs/core/OxyServicesMain.js +0 -51
  53. package/lib/commonjs/core/OxyServicesMain.js.map +0 -1
  54. package/lib/commonjs/core/analytics/AnalyticsService.js +0 -67
  55. package/lib/commonjs/core/analytics/AnalyticsService.js.map +0 -1
  56. package/lib/commonjs/core/auth/AuthService.js +0 -538
  57. package/lib/commonjs/core/auth/AuthService.js.map +0 -1
  58. package/lib/commonjs/core/devices/DeviceService.js +0 -61
  59. package/lib/commonjs/core/devices/DeviceService.js.map +0 -1
  60. package/lib/commonjs/core/files/FileService.js +0 -180
  61. package/lib/commonjs/core/files/FileService.js.map +0 -1
  62. package/lib/commonjs/core/karma/KarmaService.js +0 -100
  63. package/lib/commonjs/core/karma/KarmaService.js.map +0 -1
  64. package/lib/commonjs/core/locations/LocationService.js +0 -131
  65. package/lib/commonjs/core/locations/LocationService.js.map +0 -1
  66. package/lib/commonjs/core/payments/PaymentService.js +0 -124
  67. package/lib/commonjs/core/payments/PaymentService.js.map +0 -1
  68. package/lib/commonjs/core/users/UserService.js +0 -234
  69. package/lib/commonjs/core/users/UserService.js.map +0 -1
  70. package/lib/module/core/OxyServicesMain.js +0 -47
  71. package/lib/module/core/OxyServicesMain.js.map +0 -1
  72. package/lib/module/core/analytics/AnalyticsService.js +0 -62
  73. package/lib/module/core/analytics/AnalyticsService.js.map +0 -1
  74. package/lib/module/core/auth/AuthService.js +0 -533
  75. package/lib/module/core/auth/AuthService.js.map +0 -1
  76. package/lib/module/core/devices/DeviceService.js +0 -57
  77. package/lib/module/core/devices/DeviceService.js.map +0 -1
  78. package/lib/module/core/files/FileService.js +0 -175
  79. package/lib/module/core/files/FileService.js.map +0 -1
  80. package/lib/module/core/karma/KarmaService.js +0 -95
  81. package/lib/module/core/karma/KarmaService.js.map +0 -1
  82. package/lib/module/core/locations/LocationService.js +0 -127
  83. package/lib/module/core/locations/LocationService.js.map +0 -1
  84. package/lib/module/core/payments/PaymentService.js +0 -119
  85. package/lib/module/core/payments/PaymentService.js.map +0 -1
  86. package/lib/module/core/users/UserService.js +0 -230
  87. package/lib/module/core/users/UserService.js.map +0 -1
  88. package/lib/typescript/core/OxyServicesMain.d.ts +0 -33
  89. package/lib/typescript/core/OxyServicesMain.d.ts.map +0 -1
  90. package/lib/typescript/core/analytics/AnalyticsService.d.ts +0 -26
  91. package/lib/typescript/core/analytics/AnalyticsService.d.ts.map +0 -1
  92. package/lib/typescript/core/auth/AuthService.d.ts +0 -165
  93. package/lib/typescript/core/auth/AuthService.d.ts.map +0 -1
  94. package/lib/typescript/core/devices/DeviceService.d.ts +0 -20
  95. package/lib/typescript/core/devices/DeviceService.d.ts.map +0 -1
  96. package/lib/typescript/core/files/FileService.d.ts +0 -59
  97. package/lib/typescript/core/files/FileService.d.ts.map +0 -1
  98. package/lib/typescript/core/karma/KarmaService.d.ts +0 -50
  99. package/lib/typescript/core/karma/KarmaService.d.ts.map +0 -1
  100. package/lib/typescript/core/locations/LocationService.d.ts +0 -39
  101. package/lib/typescript/core/locations/LocationService.d.ts.map +0 -1
  102. package/lib/typescript/core/payments/PaymentService.d.ts +0 -50
  103. package/lib/typescript/core/payments/PaymentService.d.ts.map +0 -1
  104. package/lib/typescript/core/users/UserService.d.ts +0 -111
  105. package/lib/typescript/core/users/UserService.d.ts.map +0 -1
  106. package/src/core/OxyServicesMain.ts +0 -57
  107. package/src/core/analytics/AnalyticsService.ts +0 -64
  108. package/src/core/auth/AuthService.ts +0 -560
  109. package/src/core/devices/DeviceService.ts +0 -55
  110. package/src/core/files/FileService.ts +0 -198
  111. package/src/core/karma/KarmaService.ts +0 -104
  112. package/src/core/locations/LocationService.ts +0 -141
  113. package/src/core/payments/PaymentService.ts +0 -133
  114. package/src/core/users/UserService.ts +0 -241
@@ -3,16 +3,17 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.OxyServices = void 0;
6
+ exports.OxyServices = exports.OXY_CLOUD_URL = void 0;
7
7
  var _axios = _interopRequireDefault(require("axios"));
8
8
  var _jwtDecode = require("jwt-decode");
9
9
  var _errorUtils = require("../utils/errorUtils");
10
+ var _apiUtils = require("../utils/apiUtils");
10
11
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
12
  /**
12
- * OxyServices - Base client library for interacting with the Oxy API
13
+ * OxyServices - Unified client library for interacting with the Oxy API
13
14
  *
14
- * This class provides the core HTTP client setup, token management, and error handling.
15
- * Specific functionality is delegated to focused service modules.
15
+ * This class provides all API functionality in one simple, easy-to-use interface.
16
+ * No need to manage multiple service instances - everything is available directly.
16
17
  */
17
18
  // Centralized token store
18
19
  class TokenStore {
@@ -110,6 +111,10 @@ class OxyServices {
110
111
  });
111
112
  }
112
113
 
114
+ // ============================================================================
115
+ // CORE METHODS (HTTP Client, Token Management, Error Handling)
116
+ // ============================================================================
117
+
113
118
  /**
114
119
  * Get the configured base URL
115
120
  */
@@ -195,6 +200,790 @@ class OxyServices {
195
200
  }
196
201
  }
197
202
 
203
+ // ============================================================================
204
+ // AUTHENTICATION METHODS
205
+ // ============================================================================
206
+
207
+ /**
208
+ * Sign up a new user
209
+ */
210
+ async signUp(username, email, password) {
211
+ try {
212
+ const res = await this.client.post('/api/auth/signup', {
213
+ username,
214
+ email,
215
+ password
216
+ });
217
+ return res.data;
218
+ } catch (error) {
219
+ throw this.handleError(error);
220
+ }
221
+ }
222
+
223
+ /**
224
+ * Sign in with device management
225
+ */
226
+ async signIn(username, password, deviceName, deviceFingerprint) {
227
+ try {
228
+ const res = await this.client.post('/api/auth/login', {
229
+ username,
230
+ password,
231
+ deviceName,
232
+ deviceFingerprint
233
+ });
234
+ return res.data;
235
+ } catch (error) {
236
+ throw this.handleError(error);
237
+ }
238
+ }
239
+
240
+ /**
241
+ * Get user by session ID
242
+ */
243
+ async getUserBySession(sessionId) {
244
+ try {
245
+ const res = await this.client.get(`/api/session/user/${sessionId}`);
246
+ return res.data;
247
+ } catch (error) {
248
+ throw this.handleError(error);
249
+ }
250
+ }
251
+
252
+ /**
253
+ * Get access token by session ID and set it in the token store
254
+ */
255
+ async getTokenBySession(sessionId) {
256
+ try {
257
+ console.log('🔑 getTokenBySession - Fetching token for session:', sessionId);
258
+ const res = await this.client.get(`/api/session/token/${sessionId}`);
259
+ const {
260
+ accessToken
261
+ } = res.data;
262
+ console.log('🔑 getTokenBySession - Token received:', !!accessToken);
263
+
264
+ // Set the token in the centralized token store
265
+ this.setTokens(accessToken);
266
+ console.log('🔑 getTokenBySession - Token set in store');
267
+ return res.data;
268
+ } catch (error) {
269
+ console.log('❌ getTokenBySession - Error:', error);
270
+ throw this.handleError(error);
271
+ }
272
+ }
273
+
274
+ /**
275
+ * Get sessions by session ID
276
+ */
277
+ async getSessionsBySessionId(sessionId) {
278
+ try {
279
+ const res = await this.client.get(`/api/session/sessions/${sessionId}`);
280
+ return res.data;
281
+ } catch (error) {
282
+ throw this.handleError(error);
283
+ }
284
+ }
285
+
286
+ /**
287
+ * Logout from a specific session
288
+ */
289
+ async logoutSession(sessionId, targetSessionId) {
290
+ try {
291
+ const url = targetSessionId ? `/api/session/logout/${sessionId}/${targetSessionId}` : `/api/session/logout/${sessionId}`;
292
+ await this.client.post(url);
293
+ } catch (error) {
294
+ throw this.handleError(error);
295
+ }
296
+ }
297
+
298
+ /**
299
+ * Logout from all sessions
300
+ */
301
+ async logoutAllSessions(sessionId) {
302
+ try {
303
+ await this.client.post(`/api/session/logout-all/${sessionId}`);
304
+ } catch (error) {
305
+ throw this.handleError(error);
306
+ }
307
+ }
308
+
309
+ /**
310
+ * Validate session
311
+ */
312
+ async validateSession(sessionId, options = {}) {
313
+ try {
314
+ const params = new URLSearchParams();
315
+ if (options.deviceFingerprint) {
316
+ params.append('deviceFingerprint', options.deviceFingerprint);
317
+ }
318
+ if (options.useHeaderValidation) {
319
+ params.append('useHeaderValidation', 'true');
320
+ }
321
+ const url = `/api/session/validate/${sessionId}?${params.toString()}`;
322
+ const res = await this.client.get(url);
323
+ return res.data;
324
+ } catch (error) {
325
+ throw this.handleError(error);
326
+ }
327
+ }
328
+
329
+ /**
330
+ * Check username availability
331
+ */
332
+ async checkUsernameAvailability(username) {
333
+ try {
334
+ const res = await this.client.get(`/api/auth/check-username/${username}`);
335
+ return res.data;
336
+ } catch (error) {
337
+ throw this.handleError(error);
338
+ }
339
+ }
340
+
341
+ /**
342
+ * Check email availability
343
+ */
344
+ async checkEmailAvailability(email) {
345
+ try {
346
+ const res = await this.client.get(`/api/auth/check-email/${email}`);
347
+ return res.data;
348
+ } catch (error) {
349
+ throw this.handleError(error);
350
+ }
351
+ }
352
+
353
+ // ============================================================================
354
+ // USER METHODS
355
+ // ============================================================================
356
+
357
+ /**
358
+ * Get profile by username
359
+ */
360
+ async getProfileByUsername(username) {
361
+ try {
362
+ const res = await this.client.get(`/api/profiles/username/${username}`);
363
+ return res.data;
364
+ } catch (error) {
365
+ throw this.handleError(error);
366
+ }
367
+ }
368
+
369
+ /**
370
+ * Search user profiles
371
+ */
372
+ async searchProfiles(query, pagination) {
373
+ try {
374
+ const params = {
375
+ query,
376
+ ...pagination
377
+ };
378
+ const searchParams = (0, _apiUtils.buildSearchParams)(params);
379
+ const res = await this.client.get(`/api/profiles/search?${searchParams.toString()}`);
380
+ return res.data;
381
+ } catch (error) {
382
+ throw this.handleError(error);
383
+ }
384
+ }
385
+
386
+ /**
387
+ * Get profile recommendations
388
+ */
389
+ async getProfileRecommendations() {
390
+ try {
391
+ const res = await this.client.get('/api/profiles/recommendations');
392
+ return res.data;
393
+ } catch (error) {
394
+ throw this.handleError(error);
395
+ }
396
+ }
397
+
398
+ /**
399
+ * Get user by ID
400
+ */
401
+ async getUserById(userId) {
402
+ try {
403
+ const res = await this.client.get(`/api/users/${userId}`);
404
+ return res.data;
405
+ } catch (error) {
406
+ throw this.handleError(error);
407
+ }
408
+ }
409
+
410
+ /**
411
+ * Get current user
412
+ */
413
+ async getCurrentUser() {
414
+ try {
415
+ const res = await this.client.get('/api/users/me');
416
+ return res.data;
417
+ } catch (error) {
418
+ throw this.handleError(error);
419
+ }
420
+ }
421
+
422
+ /**
423
+ * Update user profile
424
+ */
425
+ async updateProfile(updates) {
426
+ try {
427
+ const res = await this.client.put('/api/users/me', updates);
428
+ return res.data;
429
+ } catch (error) {
430
+ throw this.handleError(error);
431
+ }
432
+ }
433
+
434
+ /**
435
+ * Update user by ID (admin function)
436
+ */
437
+ async updateUser(userId, updates) {
438
+ try {
439
+ const res = await this.client.put(`/api/users/${userId}`, updates);
440
+ return res.data;
441
+ } catch (error) {
442
+ throw this.handleError(error);
443
+ }
444
+ }
445
+
446
+ /**
447
+ * Follow a user
448
+ */
449
+ async followUser(userId) {
450
+ try {
451
+ const res = await this.client.post(`/api/users/${userId}/follow`);
452
+ return res.data;
453
+ } catch (error) {
454
+ throw this.handleError(error);
455
+ }
456
+ }
457
+
458
+ /**
459
+ * Unfollow a user
460
+ */
461
+ async unfollowUser(userId) {
462
+ try {
463
+ const res = await this.client.delete(`/api/users/${userId}/follow`);
464
+ return res.data;
465
+ } catch (error) {
466
+ throw this.handleError(error);
467
+ }
468
+ }
469
+
470
+ /**
471
+ * Get follow status
472
+ */
473
+ async getFollowStatus(userId) {
474
+ try {
475
+ const res = await this.client.get(`/api/users/${userId}/follow-status`);
476
+ return res.data;
477
+ } catch (error) {
478
+ throw this.handleError(error);
479
+ }
480
+ }
481
+
482
+ /**
483
+ * Get user followers
484
+ */
485
+ async getUserFollowers(userId, pagination) {
486
+ try {
487
+ const params = (0, _apiUtils.buildPaginationParams)(pagination || {});
488
+ const res = await this.client.get(`/api/users/${userId}/followers?${params.toString()}`);
489
+ return res.data;
490
+ } catch (error) {
491
+ throw this.handleError(error);
492
+ }
493
+ }
494
+
495
+ /**
496
+ * Get user following
497
+ */
498
+ async getUserFollowing(userId, pagination) {
499
+ try {
500
+ const params = (0, _apiUtils.buildPaginationParams)(pagination || {});
501
+ const res = await this.client.get(`/api/users/${userId}/following?${params.toString()}`);
502
+ return res.data;
503
+ } catch (error) {
504
+ throw this.handleError(error);
505
+ }
506
+ }
507
+
508
+ /**
509
+ * Get notifications
510
+ */
511
+ async getNotifications() {
512
+ try {
513
+ const res = await this.client.get('/api/notifications');
514
+ return res.data;
515
+ } catch (error) {
516
+ throw this.handleError(error);
517
+ }
518
+ }
519
+
520
+ /**
521
+ * Get unread notification count
522
+ */
523
+ async getUnreadCount() {
524
+ try {
525
+ const res = await this.client.get('/api/notifications/unread-count');
526
+ return res.data.count;
527
+ } catch (error) {
528
+ throw this.handleError(error);
529
+ }
530
+ }
531
+
532
+ /**
533
+ * Create notification
534
+ */
535
+ async createNotification(data) {
536
+ try {
537
+ const res = await this.client.post('/api/notifications', data);
538
+ return res.data;
539
+ } catch (error) {
540
+ throw this.handleError(error);
541
+ }
542
+ }
543
+
544
+ /**
545
+ * Mark notification as read
546
+ */
547
+ async markNotificationAsRead(notificationId) {
548
+ try {
549
+ await this.client.put(`/api/notifications/${notificationId}/read`);
550
+ } catch (error) {
551
+ throw this.handleError(error);
552
+ }
553
+ }
554
+
555
+ /**
556
+ * Mark all notifications as read
557
+ */
558
+ async markAllNotificationsAsRead() {
559
+ try {
560
+ await this.client.put('/api/notifications/read-all');
561
+ } catch (error) {
562
+ throw this.handleError(error);
563
+ }
564
+ }
565
+
566
+ /**
567
+ * Delete notification
568
+ */
569
+ async deleteNotification(notificationId) {
570
+ try {
571
+ await this.client.delete(`/api/notifications/${notificationId}`);
572
+ } catch (error) {
573
+ throw this.handleError(error);
574
+ }
575
+ }
576
+
577
+ // ============================================================================
578
+ // PAYMENT METHODS
579
+ // ============================================================================
580
+
581
+ /**
582
+ * Create a payment
583
+ */
584
+ async createPayment(data) {
585
+ try {
586
+ const res = await this.client.post('/api/payments', data);
587
+ return res.data;
588
+ } catch (error) {
589
+ throw this.handleError(error);
590
+ }
591
+ }
592
+
593
+ /**
594
+ * Get payment by ID
595
+ */
596
+ async getPayment(paymentId) {
597
+ try {
598
+ const res = await this.client.get(`/api/payments/${paymentId}`);
599
+ return res.data;
600
+ } catch (error) {
601
+ throw this.handleError(error);
602
+ }
603
+ }
604
+
605
+ /**
606
+ * Get user payments
607
+ */
608
+ async getUserPayments() {
609
+ try {
610
+ const res = await this.client.get('/api/payments/user');
611
+ return res.data;
612
+ } catch (error) {
613
+ throw this.handleError(error);
614
+ }
615
+ }
616
+
617
+ // ============================================================================
618
+ // KARMA METHODS
619
+ // ============================================================================
620
+
621
+ /**
622
+ * Get user karma
623
+ */
624
+ async getUserKarma(userId) {
625
+ try {
626
+ const res = await this.client.get(`/api/karma/${userId}`);
627
+ return res.data;
628
+ } catch (error) {
629
+ throw this.handleError(error);
630
+ }
631
+ }
632
+
633
+ /**
634
+ * Give karma to user
635
+ */
636
+ async giveKarma(userId, amount, reason) {
637
+ try {
638
+ const res = await this.client.post(`/api/karma/${userId}/give`, {
639
+ amount,
640
+ reason
641
+ });
642
+ return res.data;
643
+ } catch (error) {
644
+ throw this.handleError(error);
645
+ }
646
+ }
647
+
648
+ /**
649
+ * Get user karma total
650
+ */
651
+ async getUserKarmaTotal(userId) {
652
+ try {
653
+ const res = await this.client.get(`/api/karma/${userId}/total`);
654
+ return res.data;
655
+ } catch (error) {
656
+ throw this.handleError(error);
657
+ }
658
+ }
659
+
660
+ /**
661
+ * Get user karma history
662
+ */
663
+ async getUserKarmaHistory(userId, limit, offset) {
664
+ try {
665
+ const params = new URLSearchParams();
666
+ if (limit) params.append('limit', limit.toString());
667
+ if (offset) params.append('offset', offset.toString());
668
+ const res = await this.client.get(`/api/karma/${userId}/history?${params.toString()}`);
669
+ return res.data;
670
+ } catch (error) {
671
+ throw this.handleError(error);
672
+ }
673
+ }
674
+
675
+ /**
676
+ * Get karma leaderboard
677
+ */
678
+ async getKarmaLeaderboard() {
679
+ try {
680
+ const res = await this.client.get('/api/karma/leaderboard');
681
+ return res.data;
682
+ } catch (error) {
683
+ throw this.handleError(error);
684
+ }
685
+ }
686
+
687
+ /**
688
+ * Get karma rules
689
+ */
690
+ async getKarmaRules() {
691
+ try {
692
+ const res = await this.client.get('/api/karma/rules');
693
+ return res.data;
694
+ } catch (error) {
695
+ throw this.handleError(error);
696
+ }
697
+ }
698
+
699
+ // ============================================================================
700
+ // FILE METHODS
701
+ // ============================================================================
702
+
703
+ /**
704
+ * Upload file
705
+ */
706
+ async uploadFile(file, options) {
707
+ try {
708
+ const formData = file instanceof FormData ? file : new FormData();
709
+ if (file instanceof File) {
710
+ formData.append('file', file);
711
+ }
712
+ const res = await this.client.post('/api/files/upload', formData, {
713
+ headers: {
714
+ 'Content-Type': 'multipart/form-data'
715
+ },
716
+ ...options
717
+ });
718
+ return res.data;
719
+ } catch (error) {
720
+ throw this.handleError(error);
721
+ }
722
+ }
723
+
724
+ /**
725
+ * Get file by ID
726
+ */
727
+ async getFile(fileId) {
728
+ try {
729
+ const res = await this.client.get(`/api/files/${fileId}`);
730
+ return res.data;
731
+ } catch (error) {
732
+ throw this.handleError(error);
733
+ }
734
+ }
735
+
736
+ /**
737
+ * Delete file
738
+ */
739
+ async deleteFile(fileId) {
740
+ try {
741
+ const res = await this.client.delete(`/api/files/${fileId}`);
742
+ return res.data;
743
+ } catch (error) {
744
+ throw this.handleError(error);
745
+ }
746
+ }
747
+
748
+ /**
749
+ * Get file download URL
750
+ */
751
+ getFileDownloadUrl(fileId) {
752
+ return `${OXY_CLOUD_URL}/files/${fileId}/download`;
753
+ }
754
+
755
+ /**
756
+ * Get file stream URL
757
+ */
758
+ getFileStreamUrl(fileId) {
759
+ return `${OXY_CLOUD_URL}/files/${fileId}/stream`;
760
+ }
761
+
762
+ /**
763
+ * List user files
764
+ */
765
+ async listUserFiles(userId, limit, offset, filters) {
766
+ try {
767
+ const params = new URLSearchParams();
768
+ if (limit) params.append('limit', limit.toString());
769
+ if (offset) params.append('offset', offset.toString());
770
+ if (filters) {
771
+ Object.entries(filters).forEach(([key, value]) => {
772
+ params.append(key, value.toString());
773
+ });
774
+ }
775
+ const res = await this.client.get(`/api/files/list/${userId}?${params.toString()}`);
776
+ return res.data;
777
+ } catch (error) {
778
+ throw this.handleError(error);
779
+ }
780
+ }
781
+
782
+ /**
783
+ * Download file content
784
+ */
785
+ async downloadFileContent(fileId) {
786
+ try {
787
+ const res = await this.client.get(`/api/files/${fileId}`, {
788
+ responseType: 'blob'
789
+ });
790
+ return res.data;
791
+ } catch (error) {
792
+ throw this.handleError(error);
793
+ }
794
+ }
795
+
796
+ /**
797
+ * Get file content as text
798
+ */
799
+ async getFileContentAsText(fileId) {
800
+ try {
801
+ const res = await this.client.get(`/api/files/${fileId}`, {
802
+ headers: {
803
+ 'Accept': 'text/plain'
804
+ }
805
+ });
806
+ return res.data;
807
+ } catch (error) {
808
+ throw this.handleError(error);
809
+ }
810
+ }
811
+
812
+ /**
813
+ * Get file content as blob
814
+ */
815
+ async getFileContentAsBlob(fileId) {
816
+ try {
817
+ const res = await this.client.get(`/api/files/${fileId}`, {
818
+ responseType: 'blob'
819
+ });
820
+ return res.data;
821
+ } catch (error) {
822
+ throw this.handleError(error);
823
+ }
824
+ }
825
+
826
+ // ============================================================================
827
+ // LOCATION METHODS
828
+ // ============================================================================
829
+
830
+ /**
831
+ * Update user location
832
+ */
833
+ async updateLocation(latitude, longitude) {
834
+ try {
835
+ const res = await this.client.post('/api/location', {
836
+ latitude,
837
+ longitude
838
+ });
839
+ return res.data;
840
+ } catch (error) {
841
+ throw this.handleError(error);
842
+ }
843
+ }
844
+
845
+ /**
846
+ * Get nearby users
847
+ */
848
+ async getNearbyUsers(radius) {
849
+ try {
850
+ const params = radius ? `?radius=${radius}` : '';
851
+ const res = await this.client.get(`/api/location/nearby${params}`);
852
+ return res.data;
853
+ } catch (error) {
854
+ throw this.handleError(error);
855
+ }
856
+ }
857
+
858
+ // ============================================================================
859
+ // ANALYTICS METHODS
860
+ // ============================================================================
861
+
862
+ /**
863
+ * Track event
864
+ */
865
+ async trackEvent(eventName, properties) {
866
+ try {
867
+ await this.client.post('/api/analytics/events', {
868
+ event: eventName,
869
+ properties
870
+ });
871
+ } catch (error) {
872
+ throw this.handleError(error);
873
+ }
874
+ }
875
+
876
+ /**
877
+ * Get analytics data
878
+ */
879
+ async getAnalytics(startDate, endDate) {
880
+ try {
881
+ const params = new URLSearchParams();
882
+ if (startDate) params.append('startDate', startDate);
883
+ if (endDate) params.append('endDate', endDate);
884
+ const res = await this.client.get(`/api/analytics?${params.toString()}`);
885
+ return res.data;
886
+ } catch (error) {
887
+ throw this.handleError(error);
888
+ }
889
+ }
890
+
891
+ // ============================================================================
892
+ // DEVICE METHODS
893
+ // ============================================================================
894
+
895
+ /**
896
+ * Register device
897
+ */
898
+ async registerDevice(deviceData) {
899
+ try {
900
+ const res = await this.client.post('/api/devices', deviceData);
901
+ return res.data;
902
+ } catch (error) {
903
+ throw this.handleError(error);
904
+ }
905
+ }
906
+
907
+ /**
908
+ * Get user devices
909
+ */
910
+ async getUserDevices() {
911
+ try {
912
+ const res = await this.client.get('/api/devices');
913
+ return res.data;
914
+ } catch (error) {
915
+ throw this.handleError(error);
916
+ }
917
+ }
918
+
919
+ /**
920
+ * Remove device
921
+ */
922
+ async removeDevice(deviceId) {
923
+ try {
924
+ await this.client.delete(`/api/devices/${deviceId}`);
925
+ } catch (error) {
926
+ throw this.handleError(error);
927
+ }
928
+ }
929
+
930
+ /**
931
+ * Get device sessions
932
+ */
933
+ async getDeviceSessions(sessionId) {
934
+ try {
935
+ const res = await this.client.get(`/api/devices/sessions/${sessionId}`);
936
+ return res.data;
937
+ } catch (error) {
938
+ throw this.handleError(error);
939
+ }
940
+ }
941
+
942
+ /**
943
+ * Logout all device sessions
944
+ */
945
+ async logoutAllDeviceSessions(sessionId, deviceId, excludeCurrent) {
946
+ try {
947
+ const params = new URLSearchParams();
948
+ if (deviceId) params.append('deviceId', deviceId);
949
+ if (excludeCurrent) params.append('excludeCurrent', 'true');
950
+ const res = await this.client.post(`/api/devices/logout-all/${sessionId}?${params.toString()}`);
951
+ return res.data;
952
+ } catch (error) {
953
+ throw this.handleError(error);
954
+ }
955
+ }
956
+
957
+ /**
958
+ * Update device name
959
+ */
960
+ async updateDeviceName(sessionId, deviceName) {
961
+ try {
962
+ const res = await this.client.put(`/api/devices/name/${sessionId}`, {
963
+ deviceName
964
+ });
965
+ return res.data;
966
+ } catch (error) {
967
+ throw this.handleError(error);
968
+ }
969
+ }
970
+
971
+ // ============================================================================
972
+ // UTILITY METHODS
973
+ // ============================================================================
974
+
975
+ /**
976
+ * Fetch link metadata
977
+ */
978
+ async fetchLinkMetadata(url) {
979
+ try {
980
+ const res = await this.client.get(`/api/link-metadata?url=${encodeURIComponent(url)}`);
981
+ return res.data;
982
+ } catch (error) {
983
+ throw this.handleError(error);
984
+ }
985
+ }
986
+
198
987
  /**
199
988
  * Simple Express.js authentication middleware
200
989
  *
@@ -318,5 +1107,8 @@ class OxyServices {
318
1107
  };
319
1108
  }
320
1109
  }
1110
+
1111
+ // Export the cloud URL constant
321
1112
  exports.OxyServices = OxyServices;
1113
+ const OXY_CLOUD_URL = exports.OXY_CLOUD_URL = 'https://cloud.oxyhq.com';
322
1114
  //# sourceMappingURL=OxyServices.js.map