riuve-rn 1.0.0

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 (99) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +848 -0
  3. package/dist/Riuve.d.ts +91 -0
  4. package/dist/Riuve.d.ts.map +1 -0
  5. package/dist/Riuve.js +402 -0
  6. package/dist/Rive.d.ts +91 -0
  7. package/dist/Rive.d.ts.map +1 -0
  8. package/dist/Rive.js +402 -0
  9. package/dist/adapters/deviceInfo/ExpoDeviceInfo.d.ts +13 -0
  10. package/dist/adapters/deviceInfo/ExpoDeviceInfo.d.ts.map +1 -0
  11. package/dist/adapters/deviceInfo/ExpoDeviceInfo.js +91 -0
  12. package/dist/adapters/deviceInfo/FallbackDeviceInfo.d.ts +13 -0
  13. package/dist/adapters/deviceInfo/FallbackDeviceInfo.d.ts.map +1 -0
  14. package/dist/adapters/deviceInfo/FallbackDeviceInfo.js +36 -0
  15. package/dist/adapters/deviceInfo/NativeDeviceInfo.d.ts +17 -0
  16. package/dist/adapters/deviceInfo/NativeDeviceInfo.d.ts.map +1 -0
  17. package/dist/adapters/deviceInfo/NativeDeviceInfo.js +83 -0
  18. package/dist/adapters/deviceInfo/index.d.ts +14 -0
  19. package/dist/adapters/deviceInfo/index.d.ts.map +1 -0
  20. package/dist/adapters/deviceInfo/index.js +38 -0
  21. package/dist/adapters/deviceInfo/types.d.ts +25 -0
  22. package/dist/adapters/deviceInfo/types.d.ts.map +1 -0
  23. package/dist/adapters/deviceInfo/types.js +7 -0
  24. package/dist/adapters/network/ExpoNetworkManager.d.ts +20 -0
  25. package/dist/adapters/network/ExpoNetworkManager.d.ts.map +1 -0
  26. package/dist/adapters/network/ExpoNetworkManager.js +114 -0
  27. package/dist/adapters/network/FallbackNetworkManager.d.ts +15 -0
  28. package/dist/adapters/network/FallbackNetworkManager.d.ts.map +1 -0
  29. package/dist/adapters/network/FallbackNetworkManager.js +27 -0
  30. package/dist/adapters/network/NativeNetworkManager.d.ts +20 -0
  31. package/dist/adapters/network/NativeNetworkManager.d.ts.map +1 -0
  32. package/dist/adapters/network/NativeNetworkManager.js +68 -0
  33. package/dist/adapters/network/index.d.ts +14 -0
  34. package/dist/adapters/network/index.d.ts.map +1 -0
  35. package/dist/adapters/network/index.js +38 -0
  36. package/dist/adapters/network/types.d.ts +28 -0
  37. package/dist/adapters/network/types.d.ts.map +1 -0
  38. package/dist/adapters/network/types.js +7 -0
  39. package/dist/adapters/utils/moduleDetector.d.ts +17 -0
  40. package/dist/adapters/utils/moduleDetector.d.ts.map +1 -0
  41. package/dist/adapters/utils/moduleDetector.js +32 -0
  42. package/dist/constants.d.ts +41 -0
  43. package/dist/constants.d.ts.map +1 -0
  44. package/dist/constants.js +43 -0
  45. package/dist/core/ApiClient.d.ts +49 -0
  46. package/dist/core/ApiClient.d.ts.map +1 -0
  47. package/dist/core/ApiClient.js +184 -0
  48. package/dist/core/DeviceInfo.d.ts +27 -0
  49. package/dist/core/DeviceInfo.d.ts.map +1 -0
  50. package/dist/core/DeviceInfo.js +69 -0
  51. package/dist/core/EventQueue.d.ts +71 -0
  52. package/dist/core/EventQueue.d.ts.map +1 -0
  53. package/dist/core/EventQueue.js +216 -0
  54. package/dist/core/Storage.d.ts +29 -0
  55. package/dist/core/Storage.d.ts.map +1 -0
  56. package/dist/core/Storage.js +88 -0
  57. package/dist/index.d.ts +9 -0
  58. package/dist/index.d.ts.map +1 -0
  59. package/dist/index.js +17 -0
  60. package/dist/managers/BatchManager.d.ts +50 -0
  61. package/dist/managers/BatchManager.d.ts.map +1 -0
  62. package/dist/managers/BatchManager.js +277 -0
  63. package/dist/managers/IdentityManager.d.ts +47 -0
  64. package/dist/managers/IdentityManager.d.ts.map +1 -0
  65. package/dist/managers/IdentityManager.js +135 -0
  66. package/dist/managers/NetworkManager.d.ts +32 -0
  67. package/dist/managers/NetworkManager.d.ts.map +1 -0
  68. package/dist/managers/NetworkManager.js +67 -0
  69. package/dist/types/api.d.ts +65 -0
  70. package/dist/types/api.d.ts.map +1 -0
  71. package/dist/types/api.js +15 -0
  72. package/dist/types/config.d.ts +32 -0
  73. package/dist/types/config.d.ts.map +1 -0
  74. package/dist/types/config.js +5 -0
  75. package/dist/types/events.d.ts +63 -0
  76. package/dist/types/events.d.ts.map +1 -0
  77. package/dist/types/events.js +5 -0
  78. package/dist/types/index.d.ts +8 -0
  79. package/dist/types/index.d.ts.map +1 -0
  80. package/dist/types/index.js +23 -0
  81. package/dist/types/storage.d.ts +26 -0
  82. package/dist/types/storage.d.ts.map +1 -0
  83. package/dist/types/storage.js +5 -0
  84. package/dist/utils/fetchWithTimeout.d.ts +6 -0
  85. package/dist/utils/fetchWithTimeout.d.ts.map +1 -0
  86. package/dist/utils/fetchWithTimeout.js +28 -0
  87. package/dist/utils/logger.d.ts +21 -0
  88. package/dist/utils/logger.d.ts.map +1 -0
  89. package/dist/utils/logger.js +39 -0
  90. package/dist/utils/retry.d.ts +29 -0
  91. package/dist/utils/retry.d.ts.map +1 -0
  92. package/dist/utils/retry.js +78 -0
  93. package/dist/utils/uuid.d.ts +12 -0
  94. package/dist/utils/uuid.d.ts.map +1 -0
  95. package/dist/utils/uuid.js +27 -0
  96. package/dist/utils/validators.d.ts +32 -0
  97. package/dist/utils/validators.d.ts.map +1 -0
  98. package/dist/utils/validators.js +68 -0
  99. package/package.json +65 -0
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ /**
3
+ * Network Manager - Monitors network connectivity
4
+ *
5
+ * Uses the adapter pattern to automatically select the best network implementation
6
+ * based on available modules (Native > Expo > Fallback)
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.NetworkManager = void 0;
10
+ const network_1 = require("../adapters/network");
11
+ const logger_1 = require("../utils/logger");
12
+ class NetworkManager {
13
+ constructor() {
14
+ this.adapter = (0, network_1.getNetworkAdapter)();
15
+ }
16
+ /**
17
+ * Initializes the network manager and starts monitoring
18
+ */
19
+ async initialize() {
20
+ await this.adapter.initialize();
21
+ logger_1.logger.info(`Network initialized. Online: ${this.adapter.isConnected()}`);
22
+ }
23
+ /**
24
+ * Adds a listener for network status changes
25
+ */
26
+ onStatusChange(callback) {
27
+ // Wrap the callback to add logging
28
+ const wrappedCallback = (isOnline) => {
29
+ logger_1.logger.info(`Network status changed: ${isOnline ? 'online' : 'offline'}`);
30
+ try {
31
+ callback(isOnline);
32
+ }
33
+ catch (error) {
34
+ logger_1.logger.error('Error in network status listener:', error);
35
+ }
36
+ };
37
+ this.adapter.onStatusChange(wrappedCallback);
38
+ // Return unsubscribe function (though not fully implemented in adapter)
39
+ return () => {
40
+ // Note: Individual listener removal not implemented in adapters
41
+ // This would require refactoring adapter interface
42
+ };
43
+ }
44
+ /**
45
+ * Checks if currently online
46
+ */
47
+ isConnected() {
48
+ return this.adapter.isConnected();
49
+ }
50
+ /**
51
+ * Manually refreshes network status
52
+ */
53
+ async refresh() {
54
+ await this.adapter.refresh();
55
+ const isOnline = this.adapter.isConnected();
56
+ logger_1.logger.info(`Network status refreshed: ${isOnline ? 'online' : 'offline'}`);
57
+ return isOnline;
58
+ }
59
+ /**
60
+ * Cleans up the network manager
61
+ */
62
+ cleanup() {
63
+ this.adapter.cleanup();
64
+ logger_1.logger.info('NetworkManager cleaned up');
65
+ }
66
+ }
67
+ exports.NetworkManager = NetworkManager;
@@ -0,0 +1,65 @@
1
+ /**
2
+ * API Request and Response Types
3
+ */
4
+ import type { DeviceInfo, Event } from './events';
5
+ /** Initialize request payload */
6
+ export interface InitializeRequest {
7
+ api_key: string;
8
+ anonymous_id: string;
9
+ device_info: DeviceInfo;
10
+ }
11
+ /** Initialize response payload */
12
+ export interface InitializeResponse {
13
+ success: boolean;
14
+ anonymous_id: string;
15
+ }
16
+ /** Identify request payload */
17
+ export interface IdentifyRequest {
18
+ api_key: string;
19
+ anonymous_id: string;
20
+ external_user_id: string;
21
+ user_properties?: Record<string, any>;
22
+ }
23
+ /** Identify response payload */
24
+ export interface IdentifyResponse {
25
+ success: boolean;
26
+ }
27
+ /** Track request payload */
28
+ export interface TrackRequest {
29
+ api_key: string;
30
+ anonymous_id: string;
31
+ external_user_id?: string;
32
+ events: Event[];
33
+ }
34
+ /** Track response payload */
35
+ export interface TrackResponse {
36
+ success: boolean;
37
+ processed: number;
38
+ }
39
+ /** Set FCM token request payload */
40
+ export interface SetFcmTokenRequest {
41
+ api_key: string;
42
+ anonymous_id: string;
43
+ external_user_id?: string;
44
+ fcm_token: string;
45
+ }
46
+ /** Set FCM token response payload */
47
+ export interface SetFcmTokenResponse {
48
+ success: boolean;
49
+ }
50
+ /** API error response */
51
+ export interface ApiError {
52
+ error: string;
53
+ message?: string;
54
+ code?: string;
55
+ status?: number;
56
+ }
57
+ /** Error types for categorization */
58
+ export declare enum ErrorType {
59
+ NETWORK_ERROR = "NETWORK_ERROR",
60
+ SERVER_ERROR = "SERVER_ERROR",
61
+ CLIENT_ERROR = "CLIENT_ERROR",
62
+ TIMEOUT_ERROR = "TIMEOUT_ERROR",
63
+ UNKNOWN_ERROR = "UNKNOWN_ERROR"
64
+ }
65
+ //# sourceMappingURL=api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/types/api.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAElD,iCAAiC;AACjC,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,UAAU,CAAC;CACzB;AAED,kCAAkC;AAClC,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,+BAA+B;AAC/B,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;IACzB,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACvC;AAED,gCAAgC;AAChC,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,4BAA4B;AAC5B,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,MAAM,EAAE,KAAK,EAAE,CAAC;CACjB;AAED,6BAA6B;AAC7B,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,oCAAoC;AACpC,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,qCAAqC;AACrC,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,yBAAyB;AACzB,MAAM,WAAW,QAAQ;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,qCAAqC;AACrC,oBAAY,SAAS;IACnB,aAAa,kBAAkB;IAC/B,YAAY,iBAAiB;IAC7B,YAAY,iBAAiB;IAC7B,aAAa,kBAAkB;IAC/B,aAAa,kBAAkB;CAChC"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ /**
3
+ * API Request and Response Types
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ErrorType = void 0;
7
+ /** Error types for categorization */
8
+ var ErrorType;
9
+ (function (ErrorType) {
10
+ ErrorType["NETWORK_ERROR"] = "NETWORK_ERROR";
11
+ ErrorType["SERVER_ERROR"] = "SERVER_ERROR";
12
+ ErrorType["CLIENT_ERROR"] = "CLIENT_ERROR";
13
+ ErrorType["TIMEOUT_ERROR"] = "TIMEOUT_ERROR";
14
+ ErrorType["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
15
+ })(ErrorType || (exports.ErrorType = ErrorType = {}));
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Configuration Types
3
+ */
4
+ export interface RiuveConfig {
5
+ /** API key for authenticating with the backend */
6
+ apiKey: string;
7
+ /** Number of events to batch before sending (default: 10) */
8
+ batchSize: number;
9
+ /** Maximum time in milliseconds to wait before sending a batch (default: 30000) */
10
+ batchTimeout: number;
11
+ /** Maximum number of retry attempts for failed requests (default: 3) */
12
+ maxRetries: number;
13
+ /** Initial delay in milliseconds before retrying (default: 1000) */
14
+ retryDelay: number;
15
+ /** Persist events to storage for offline support (default: true) */
16
+ persistEvents: boolean;
17
+ /** Automatically flush events when app goes to background (default: true) */
18
+ autoFlushOnBackground: boolean;
19
+ /** Maximum number of events to keep in memory (default: 1000) */
20
+ maxQueueSize: number;
21
+ /** Number of days to retain failed events (default: 7) */
22
+ eventRetentionDays: number;
23
+ /** Request timeout in milliseconds (default: 10000) */
24
+ requestTimeout: number;
25
+ /** Enable debug mode with detailed logging (default: false) */
26
+ debugMode: boolean;
27
+ }
28
+ /** Partial configuration that can be passed during initialization */
29
+ export type RiuveConfigInput = Partial<Omit<RiuveConfig, 'apiKey'>> & {
30
+ apiKey: string;
31
+ };
32
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,WAAW;IAC1B,kDAAkD;IAClD,MAAM,EAAE,MAAM,CAAC;IAEf,6DAA6D;IAC7D,SAAS,EAAE,MAAM,CAAC;IAElB,mFAAmF;IACnF,YAAY,EAAE,MAAM,CAAC;IAErB,wEAAwE;IACxE,UAAU,EAAE,MAAM,CAAC;IAEnB,oEAAoE;IACpE,UAAU,EAAE,MAAM,CAAC;IAEnB,oEAAoE;IACpE,aAAa,EAAE,OAAO,CAAC;IAEvB,6EAA6E;IAC7E,qBAAqB,EAAE,OAAO,CAAC;IAE/B,iEAAiE;IACjE,YAAY,EAAE,MAAM,CAAC;IAErB,0DAA0D;IAC1D,kBAAkB,EAAE,MAAM,CAAC;IAE3B,uDAAuD;IACvD,cAAc,EAAE,MAAM,CAAC;IAEvB,+DAA+D;IAC/D,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,qEAAqE;AACrE,MAAM,MAAM,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC,GAAG;IACpE,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * Configuration Types
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Event Types
3
+ */
4
+ /** Single event structure */
5
+ export interface Event {
6
+ /** Unique identifier for the event (UUID) */
7
+ id: string;
8
+ /** Name of the event */
9
+ name: string;
10
+ /** Optional event properties */
11
+ properties?: Record<string, any>;
12
+ /** Unix timestamp when the event was created */
13
+ timestamp: number;
14
+ /** Anonymous user ID */
15
+ anonymousId: string;
16
+ /** External user ID (if user is identified) */
17
+ externalUserId?: string;
18
+ }
19
+ /** Batch of events with metadata */
20
+ export interface EventBatch {
21
+ /** Array of events in this batch */
22
+ events: Event[];
23
+ /** Metadata about the batch */
24
+ metadata: {
25
+ /** Anonymous user ID */
26
+ anonymousId: string;
27
+ /** External user ID (if user is identified) */
28
+ externalUserId?: string;
29
+ /** Device information */
30
+ deviceInfo: DeviceInfo;
31
+ };
32
+ }
33
+ /** Device information structure */
34
+ export interface DeviceInfo {
35
+ /** Operating system version (e.g., "iOS 17.2", "Android 14") */
36
+ os_version: string;
37
+ /** Device model (e.g., "iPhone 15 Pro", "Samsung Galaxy S23") */
38
+ device_model: string;
39
+ /** App version (e.g., "1.0.0") */
40
+ app_version: string;
41
+ /** Locale (e.g., "en-US", "tr-TR") */
42
+ locale: string;
43
+ /** Platform (ios or android) */
44
+ platform: 'ios' | 'android';
45
+ /** Device manufacturer (optional) */
46
+ manufacturer?: string;
47
+ /** Device brand (optional) */
48
+ brand?: string;
49
+ }
50
+ /** Failed batch that needs to be retried */
51
+ export interface FailedBatch {
52
+ /** Unique identifier for the failed batch */
53
+ id: string;
54
+ /** Array of events in this failed batch */
55
+ events: Event[];
56
+ /** Timestamp when the batch failed */
57
+ failedAt: number;
58
+ /** Number of retry attempts made */
59
+ retryCount: number;
60
+ /** Last error message */
61
+ lastError: string;
62
+ }
63
+ //# sourceMappingURL=events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/types/events.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,6BAA6B;AAC7B,MAAM,WAAW,KAAK;IACpB,6CAA6C;IAC7C,EAAE,EAAE,MAAM,CAAC;IAEX,wBAAwB;IACxB,IAAI,EAAE,MAAM,CAAC;IAEb,gCAAgC;IAChC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAEjC,gDAAgD;IAChD,SAAS,EAAE,MAAM,CAAC;IAElB,wBAAwB;IACxB,WAAW,EAAE,MAAM,CAAC;IAEpB,+CAA+C;IAC/C,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,oCAAoC;AACpC,MAAM,WAAW,UAAU;IACzB,oCAAoC;IACpC,MAAM,EAAE,KAAK,EAAE,CAAC;IAEhB,+BAA+B;IAC/B,QAAQ,EAAE;QACR,wBAAwB;QACxB,WAAW,EAAE,MAAM,CAAC;QAEpB,+CAA+C;QAC/C,cAAc,CAAC,EAAE,MAAM,CAAC;QAExB,yBAAyB;QACzB,UAAU,EAAE,UAAU,CAAC;KACxB,CAAC;CACH;AAED,mCAAmC;AACnC,MAAM,WAAW,UAAU;IACzB,gEAAgE;IAChE,UAAU,EAAE,MAAM,CAAC;IAEnB,iEAAiE;IACjE,YAAY,EAAE,MAAM,CAAC;IAErB,kCAAkC;IAClC,WAAW,EAAE,MAAM,CAAC;IAEpB,sCAAsC;IACtC,MAAM,EAAE,MAAM,CAAC;IAEf,gCAAgC;IAChC,QAAQ,EAAE,KAAK,GAAG,SAAS,CAAC;IAE5B,qCAAqC;IACrC,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,8BAA8B;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,4CAA4C;AAC5C,MAAM,WAAW,WAAW;IAC1B,6CAA6C;IAC7C,EAAE,EAAE,MAAM,CAAC;IAEX,2CAA2C;IAC3C,MAAM,EAAE,KAAK,EAAE,CAAC;IAEhB,sCAAsC;IACtC,QAAQ,EAAE,MAAM,CAAC;IAEjB,oCAAoC;IACpC,UAAU,EAAE,MAAM,CAAC;IAEnB,yBAAyB;IACzB,SAAS,EAAE,MAAM,CAAC;CACnB"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * Event Types
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Main type exports
3
+ */
4
+ export * from './config';
5
+ export * from './events';
6
+ export * from './api';
7
+ export * from './storage';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,OAAO,CAAC;AACtB,cAAc,WAAW,CAAC"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ /**
3
+ * Main type exports
4
+ */
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = { enumerable: true, get: function() { return m[k]; } };
10
+ }
11
+ Object.defineProperty(o, k2, desc);
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
17
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ __exportStar(require("./config"), exports);
21
+ __exportStar(require("./events"), exports);
22
+ __exportStar(require("./api"), exports);
23
+ __exportStar(require("./storage"), exports);
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Storage Schema Types
3
+ */
4
+ import type { DeviceInfo, Event, FailedBatch } from './events';
5
+ /** Storage schema defining all keys and their value types */
6
+ export interface StorageSchema {
7
+ /** Anonymous user ID (UUID v4) */
8
+ ANONYMOUS_ID: string;
9
+ /** External user ID (after identification) */
10
+ EXTERNAL_USER_ID: string | null;
11
+ /** User properties object */
12
+ USER_PROPERTIES: Record<string, any> | null;
13
+ /** Cached device information */
14
+ DEVICE_INFO: DeviceInfo | null;
15
+ /** FCM push notification token */
16
+ FCM_TOKEN: string | null;
17
+ /** Queue of events waiting to be sent */
18
+ EVENT_QUEUE: Event[];
19
+ /** Failed batches that need to be retried */
20
+ FAILED_BATCHES: FailedBatch[];
21
+ }
22
+ /** Storage keys type */
23
+ export type StorageKey = keyof StorageSchema;
24
+ /** Storage value type based on key */
25
+ export type StorageValue<K extends StorageKey> = StorageSchema[K];
26
+ //# sourceMappingURL=storage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/types/storage.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE/D,6DAA6D;AAC7D,MAAM,WAAW,aAAa;IAC5B,kCAAkC;IAClC,YAAY,EAAE,MAAM,CAAC;IAErB,8CAA8C;IAC9C,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAEhC,6BAA6B;IAC7B,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC;IAE5C,gCAAgC;IAChC,WAAW,EAAE,UAAU,GAAG,IAAI,CAAC;IAE/B,kCAAkC;IAClC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAEzB,yCAAyC;IACzC,WAAW,EAAE,KAAK,EAAE,CAAC;IAErB,6CAA6C;IAC7C,cAAc,EAAE,WAAW,EAAE,CAAC;CAC/B;AAED,wBAAwB;AACxB,MAAM,MAAM,UAAU,GAAG,MAAM,aAAa,CAAC;AAE7C,sCAAsC;AACtC,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,UAAU,IAAI,aAAa,CAAC,CAAC,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * Storage Schema Types
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Fetch wrapper with timeout support
3
+ * React Native fetch doesn't support timeout natively
4
+ */
5
+ export declare function fetchWithTimeout(url: string, options?: RequestInit, timeout?: number): Promise<Response>;
6
+ //# sourceMappingURL=fetchWithTimeout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetchWithTimeout.d.ts","sourceRoot":"","sources":["../../src/utils/fetchWithTimeout.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,WAAgB,EACzB,OAAO,GAAE,MAAc,GACtB,OAAO,CAAC,QAAQ,CAAC,CAoBnB"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fetchWithTimeout = fetchWithTimeout;
4
+ /**
5
+ * Fetch wrapper with timeout support
6
+ * React Native fetch doesn't support timeout natively
7
+ */
8
+ async function fetchWithTimeout(url, options = {}, timeout = 10000 // 10 seconds default
9
+ ) {
10
+ const controller = new AbortController();
11
+ const timeoutId = setTimeout(() => controller.abort(), timeout);
12
+ try {
13
+ const response = await fetch(url, {
14
+ ...options,
15
+ signal: controller.signal,
16
+ });
17
+ clearTimeout(timeoutId);
18
+ return response;
19
+ }
20
+ catch (error) {
21
+ clearTimeout(timeoutId);
22
+ // Transform abort error to timeout error
23
+ if (error instanceof Error && error.name === 'AbortError') {
24
+ throw new Error('Request timeout');
25
+ }
26
+ throw error;
27
+ }
28
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Internal Logger Utility
3
+ */
4
+ export declare enum LogLevel {
5
+ DEBUG = "debug",
6
+ INFO = "info",
7
+ WARN = "warn",
8
+ ERROR = "error"
9
+ }
10
+ declare class Logger {
11
+ private debugMode;
12
+ private prefix;
13
+ setDebugMode(enabled: boolean): void;
14
+ debug(message: string, ...args: any[]): void;
15
+ info(message: string, ...args: any[]): void;
16
+ warn(message: string, ...args: any[]): void;
17
+ error(message: string, ...args: any[]): void;
18
+ }
19
+ export declare const logger: Logger;
20
+ export {};
21
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,oBAAY,QAAQ;IAClB,KAAK,UAAU;IACf,IAAI,SAAS;IACb,IAAI,SAAS;IACb,KAAK,UAAU;CAChB;AAED,cAAM,MAAM;IACV,OAAO,CAAC,SAAS,CAAkB;IACnC,OAAO,CAAC,MAAM,CAAyB;IAEvC,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAIpC,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAM5C,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAM3C,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAI3C,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;CAG7C;AAED,eAAO,MAAM,MAAM,QAAe,CAAC"}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ /**
3
+ * Internal Logger Utility
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.logger = exports.LogLevel = void 0;
7
+ var LogLevel;
8
+ (function (LogLevel) {
9
+ LogLevel["DEBUG"] = "debug";
10
+ LogLevel["INFO"] = "info";
11
+ LogLevel["WARN"] = "warn";
12
+ LogLevel["ERROR"] = "error";
13
+ })(LogLevel || (exports.LogLevel = LogLevel = {}));
14
+ class Logger {
15
+ constructor() {
16
+ this.debugMode = false;
17
+ this.prefix = '[Riuve SDK]';
18
+ }
19
+ setDebugMode(enabled) {
20
+ this.debugMode = enabled;
21
+ }
22
+ debug(message, ...args) {
23
+ if (this.debugMode) {
24
+ console.log(`${this.prefix} [DEBUG]`, message, ...args);
25
+ }
26
+ }
27
+ info(message, ...args) {
28
+ if (this.debugMode) {
29
+ console.log(`${this.prefix} [INFO]`, message, ...args);
30
+ }
31
+ }
32
+ warn(message, ...args) {
33
+ console.warn(`${this.prefix} [WARN]`, message, ...args);
34
+ }
35
+ error(message, ...args) {
36
+ console.error(`${this.prefix} [ERROR]`, message, ...args);
37
+ }
38
+ }
39
+ exports.logger = new Logger();
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Retry Logic Helpers
3
+ */
4
+ import { ErrorType } from '../types';
5
+ /**
6
+ * Determines if an error type should be retried
7
+ */
8
+ export declare function shouldRetry(errorType: ErrorType): boolean;
9
+ /**
10
+ * Calculates exponential backoff delay with jitter
11
+ * @param attempt - Current attempt number (1-indexed)
12
+ * @param baseDelay - Base delay in milliseconds
13
+ * @returns Delay in milliseconds
14
+ */
15
+ export declare function calculateBackoff(attempt: number, baseDelay: number): number;
16
+ /**
17
+ * Sleeps for a specified duration
18
+ * @param ms - Duration in milliseconds
19
+ */
20
+ export declare function sleep(ms: number): Promise<void>;
21
+ /**
22
+ * Retry wrapper for async functions
23
+ * @param fn - Async function to retry
24
+ * @param maxRetries - Maximum number of retry attempts
25
+ * @param baseDelay - Base delay for exponential backoff
26
+ * @param shouldRetryFn - Function to determine if error should be retried
27
+ */
28
+ export declare function retryWithBackoff<T>(fn: () => Promise<T>, maxRetries: number, baseDelay: number, shouldRetryFn: (error: any) => boolean): Promise<T>;
29
+ //# sourceMappingURL=retry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../../src/utils/retry.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAGrC;;GAEG;AACH,wBAAgB,WAAW,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAWzD;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAiB3E;AAED;;;GAGG;AACH,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE/C;AAED;;;;;;GAMG;AACH,wBAAsB,gBAAgB,CAAC,CAAC,EACtC,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACpB,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,EACjB,aAAa,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,OAAO,GACrC,OAAO,CAAC,CAAC,CAAC,CAqBZ"}
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ /**
3
+ * Retry Logic Helpers
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.shouldRetry = shouldRetry;
7
+ exports.calculateBackoff = calculateBackoff;
8
+ exports.sleep = sleep;
9
+ exports.retryWithBackoff = retryWithBackoff;
10
+ const types_1 = require("../types");
11
+ const logger_1 = require("./logger");
12
+ /**
13
+ * Determines if an error type should be retried
14
+ */
15
+ function shouldRetry(errorType) {
16
+ switch (errorType) {
17
+ case types_1.ErrorType.NETWORK_ERROR:
18
+ case types_1.ErrorType.SERVER_ERROR:
19
+ case types_1.ErrorType.TIMEOUT_ERROR:
20
+ return true;
21
+ case types_1.ErrorType.CLIENT_ERROR:
22
+ case types_1.ErrorType.UNKNOWN_ERROR:
23
+ default:
24
+ return false;
25
+ }
26
+ }
27
+ /**
28
+ * Calculates exponential backoff delay with jitter
29
+ * @param attempt - Current attempt number (1-indexed)
30
+ * @param baseDelay - Base delay in milliseconds
31
+ * @returns Delay in milliseconds
32
+ */
33
+ function calculateBackoff(attempt, baseDelay) {
34
+ if (attempt <= 1) {
35
+ return 0; // First attempt is immediate
36
+ }
37
+ // Exponential backoff: baseDelay * 2^(attempt - 2)
38
+ const exponentialDelay = baseDelay * Math.pow(2, attempt - 2);
39
+ // Add jitter (±30%)
40
+ const jitter = Math.random() * 0.6 - 0.3; // Random between -0.3 and 0.3
41
+ const jitterAmount = exponentialDelay * jitter;
42
+ const finalDelay = exponentialDelay + jitterAmount;
43
+ logger_1.logger.debug(`Backoff delay for attempt ${attempt}: ${Math.round(finalDelay)}ms`);
44
+ return Math.max(0, finalDelay);
45
+ }
46
+ /**
47
+ * Sleeps for a specified duration
48
+ * @param ms - Duration in milliseconds
49
+ */
50
+ function sleep(ms) {
51
+ return new Promise((resolve) => setTimeout(resolve, ms));
52
+ }
53
+ /**
54
+ * Retry wrapper for async functions
55
+ * @param fn - Async function to retry
56
+ * @param maxRetries - Maximum number of retry attempts
57
+ * @param baseDelay - Base delay for exponential backoff
58
+ * @param shouldRetryFn - Function to determine if error should be retried
59
+ */
60
+ async function retryWithBackoff(fn, maxRetries, baseDelay, shouldRetryFn) {
61
+ let lastError;
62
+ for (let attempt = 1; attempt <= maxRetries + 1; attempt++) {
63
+ try {
64
+ return await fn();
65
+ }
66
+ catch (error) {
67
+ lastError = error;
68
+ if (attempt >= maxRetries + 1 || !shouldRetryFn(error)) {
69
+ logger_1.logger.error(`Failed after ${attempt} attempts:`, error);
70
+ throw error;
71
+ }
72
+ const delay = calculateBackoff(attempt + 1, baseDelay);
73
+ logger_1.logger.warn(`Attempt ${attempt} failed, retrying in ${Math.round(delay)}ms...`);
74
+ await sleep(delay);
75
+ }
76
+ }
77
+ throw lastError;
78
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * React Native compatible UUID generator
3
+ *
4
+ * This implementation doesn't rely on crypto.getRandomValues() which is not
5
+ * available in React Native without polyfills.
6
+ */
7
+ /**
8
+ * Generates a UUID v4 compatible string using timestamp and random values
9
+ * This is a proper UUID v4 format that works in React Native without polyfills
10
+ */
11
+ export declare function generateUUID(): string;
12
+ //# sourceMappingURL=uuid.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uuid.d.ts","sourceRoot":"","sources":["../../src/utils/uuid.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;GAGG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAcrC"}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ /**
3
+ * React Native compatible UUID generator
4
+ *
5
+ * This implementation doesn't rely on crypto.getRandomValues() which is not
6
+ * available in React Native without polyfills.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.generateUUID = generateUUID;
10
+ /**
11
+ * Generates a UUID v4 compatible string using timestamp and random values
12
+ * This is a proper UUID v4 format that works in React Native without polyfills
13
+ */
14
+ function generateUUID() {
15
+ // Generate random hex strings with proper length
16
+ // s4() generates exactly 4 hex characters (0000-ffff)
17
+ const s4 = () => {
18
+ return Math.floor(Math.random() * 0x10000)
19
+ .toString(16)
20
+ .padStart(4, '0'); // Always 4 characters
21
+ };
22
+ // UUID v4 format: xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx
23
+ // The 4 indicates version 4
24
+ // The y is one of 8, 9, A, or B (indicates variant)
25
+ // Last segment must be exactly 12 characters (3x s4() = 12)
26
+ return `${s4()}${s4()}-${s4()}-4${s4().substring(0, 3)}-${(['8', '9', 'a', 'b'][Math.floor(Math.random() * 4)])}${s4().substring(0, 3)}-${s4()}${s4()}${s4()}`;
27
+ }
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Input Validation Utilities
3
+ */
4
+ /**
5
+ * Validates that a value is a non-empty string
6
+ */
7
+ export declare function isNonEmptyString(value: any): value is string;
8
+ /**
9
+ * Validates API key
10
+ */
11
+ export declare function validateApiKey(apiKey: any): void;
12
+ /**
13
+ * Validates event name
14
+ */
15
+ export declare function validateEventName(eventName: any): void;
16
+ /**
17
+ * Validates user ID
18
+ */
19
+ export declare function validateUserId(userId: any): void;
20
+ /**
21
+ * Validates that a value is a plain object
22
+ */
23
+ export declare function isPlainObject(value: any): value is Record<string, any>;
24
+ /**
25
+ * Validates event properties (optional, must be object if provided)
26
+ */
27
+ export declare function validateEventProperties(properties: any): void;
28
+ /**
29
+ * Validates user properties (optional, must be object if provided)
30
+ */
31
+ export declare function validateUserProperties(properties: any): void;
32
+ //# sourceMappingURL=validators.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../../src/utils/validators.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,MAAM,CAE5D;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,GAAG,GAAG,IAAI,CAIhD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,GAAG,GAAG,IAAI,CAItD;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,GAAG,GAAG,IAAI,CAIhD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAOtE;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,GAAG,GAAG,IAAI,CAI7D;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,GAAG,GAAG,IAAI,CAI5D"}