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