@unvired/react-native-unvired-sdk 0.0.12 → 0.0.14

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 (58) hide show
  1. package/BuildNo.txt +1 -1
  2. package/README.md +884 -255
  3. package/dist/database/Database.d.ts +71 -0
  4. package/dist/database/Database.js +156 -0
  5. package/dist/database/DatabaseManager.d.ts +12 -0
  6. package/dist/database/DatabaseManager.js +18 -0
  7. package/dist/database/index.d.ts +6 -0
  8. package/dist/database/index.js +5 -0
  9. package/dist/database/services/DatabaseNative.d.ts +8 -0
  10. package/dist/database/services/DatabaseNative.js +149 -0
  11. package/dist/database/services/DatabaseWeb.d.ts +13 -0
  12. package/dist/database/services/DatabaseWeb.js +138 -0
  13. package/dist/database/types.d.ts +94 -0
  14. package/dist/database/types.js +4 -0
  15. package/dist/device-info/BaseDeviceInfo.d.ts +39 -0
  16. package/dist/device-info/BaseDeviceInfo.js +116 -0
  17. package/dist/device-info/DeviceInfo.d.ts +9 -0
  18. package/dist/device-info/DeviceInfo.js +11 -0
  19. package/dist/device-info/DeviceInfo.types.d.ts +11 -0
  20. package/dist/device-info/DeviceInfo.types.js +3 -0
  21. package/dist/device-info/index.d.ts +3 -0
  22. package/dist/device-info/index.js +3 -0
  23. package/dist/file-system/BaseFileSystem.d.ts +61 -0
  24. package/dist/file-system/BaseFileSystem.js +164 -0
  25. package/dist/file-system/FileSystem.d.ts +9 -0
  26. package/dist/file-system/FileSystem.js +11 -0
  27. package/dist/file-system/FileSystem.types.d.ts +11 -0
  28. package/dist/file-system/FileSystem.types.js +3 -0
  29. package/dist/file-system/index.d.ts +3 -0
  30. package/dist/file-system/index.js +3 -0
  31. package/dist/file-system/services/FileSystemNative.d.ts +17 -0
  32. package/dist/file-system/services/FileSystemNative.js +73 -0
  33. package/dist/file-system/services/FileSystemWeb.d.ts +16 -0
  34. package/dist/file-system/services/FileSystemWeb.js +41 -0
  35. package/dist/local-storage/index.d.ts +1 -0
  36. package/dist/local-storage/index.js +2 -0
  37. package/dist/local-storage/localStorage.d.ts +49 -0
  38. package/dist/local-storage/localStorage.js +128 -0
  39. package/dist/local-storage/services/StorageNative.d.ts +10 -0
  40. package/dist/local-storage/services/StorageNative.js +27 -0
  41. package/dist/local-storage/services/StorageWeb.d.ts +10 -0
  42. package/dist/local-storage/services/StorageWeb.js +26 -0
  43. package/dist/logger/{Logger.js → index.js} +1 -4
  44. package/dist/main.d.ts +11 -0
  45. package/dist/main.js +24 -0
  46. package/dist/push-notification/BasePushNotification.d.ts +52 -0
  47. package/dist/push-notification/BasePushNotification.js +180 -0
  48. package/dist/push-notification/PushNotification.d.ts +9 -0
  49. package/dist/push-notification/PushNotification.js +11 -0
  50. package/dist/push-notification/PushNotification.types.d.ts +12 -0
  51. package/dist/push-notification/PushNotification.types.js +3 -0
  52. package/dist/push-notification/index.d.ts +3 -0
  53. package/dist/push-notification/index.js +3 -0
  54. package/example/USAGE_EXAMPLE.ts +167 -0
  55. package/package.json +17 -6
  56. package/dist/index.d.ts +0 -3
  57. package/dist/index.js +0 -4
  58. /package/dist/logger/{Logger.d.ts → index.d.ts} +0 -0
package/README.md CHANGED
@@ -1,348 +1,977 @@
1
- # React Native Unvired SDK
1
+ # Unvired React Native SDK
2
2
 
3
- A comprehensive SDK for React Native applications with support for logging, database operations, notifications, and file system management.
3
+ A comprehensive, production-ready SDK for React Native applications providing logging, database, storage, file system, device info, and push notification capabilities.
4
4
 
5
- ## Installation
5
+ [![npm version](https://img.shields.io/npm/v/@unvired/react-native-unvired-sdk.svg)](https://www.npmjs.com/package/@unvired/react-native-unvired-sdk)
6
+ [![License](https://img.shields.io/badge/license-UNLICENSED-blue.svg)](LICENSE)
6
7
 
7
- ```bash
8
- npm install react-native-unvired-sdk
9
- # or
10
- yarn add react-native-unvired-sdk
8
+ ---
9
+
10
+ ## 📋 Table of Contents
11
+
12
+ - [Features](#features)
13
+ - [Architecture](#architecture)
14
+ - [Installation](#installation)
15
+ - [Quick Start](#quick-start)
16
+ - [Modules](#modules)
17
+ - [Documentation](#documentation)
18
+ - [Requirements](#requirements)
19
+ - [License](#license)
20
+
21
+ ---
22
+
23
+ ## ✨ Features
24
+
25
+ - 📝 **Advanced Logging** - File persistence, compression, rotation, and multiple log levels
26
+ - 💾 **SQLite Database** - Both low-level and high-level ORM-like APIs
27
+ - 🗄️ **Local Storage** - AsyncStorage wrapper with automatic JSON serialization
28
+ - 📁 **File System** - Comprehensive file and directory operations
29
+ - 📱 **Device Info** - Platform detection and device information
30
+ - 🔔 **Push Notifications** - Firebase Cloud Messaging integration
31
+ - 🔌 **Platform Adapter** - Unified interface for all platform-specific functionality
32
+ - 🎯 **TypeScript First** - Full type safety and IntelliSense support
33
+ - 🏗️ **Modular Architecture** - Use individual modules or the complete platform adapter
34
+ - 🚀 **Production Ready** - Battle-tested and optimized for performance
35
+
36
+ ---
37
+
38
+ ## 🏗️ Architecture
39
+
40
+ ### Module Structure
41
+
42
+ The SDK follows a clean, modular architecture where each module is independent and can be used separately or through the unified platform adapter.
43
+
44
+ ```
45
+ src/
46
+ ├── main.ts # SDK Entry Point
47
+ │
48
+ ├── logger/ # Logger Module
49
+ │ ├── index.ts # Module exports
50
+ │ ├── BaseLogger.ts # Core logging logic
51
+ │ ├── Logger.types.ts # Type definitions
52
+ │ └── services/ # Platform-specific implementations
53
+ │ ├── LoggerNative.ts
54
+ │ ├── LoggerWeb.ts
55
+ │ └── LoggerWindows.ts
56
+ │
57
+ ├── database/ # Database Module
58
+ │ ├── index.ts # Module exports
59
+ │ ├── DatabaseManager.ts # Low-level adapter
60
+ │ ├── Database.ts # High-level ORM
61
+ │ └── types.ts # Type definitions
62
+ │
63
+ ├── local-storage/ # Local Storage Module
64
+ │ ├── index.ts # Module exports
65
+ │ └── localStorage.ts # AsyncStorage wrapper
66
+ │
67
+ ├── device-info/ # Device Info Module
68
+ │ ├── index.ts # Module exports
69
+ │ ├── DeviceInfo.ts # Main class
70
+ │ ├── BaseDeviceInfo.ts # Core implementation
71
+ │ └── DeviceInfo.types.ts # Type definitions
72
+ │
73
+ ├── file-system/ # File System Module
74
+ │ ├── index.ts # Module exports
75
+ │ ├── FileSystem.ts # Main class
76
+ │ ├── BaseFileSystem.ts # Core implementation
77
+ │ └── FileSystem.types.ts # Type definitions
78
+ │
79
+ ├── push-notification/ # Push Notification Module
80
+ │ ├── index.ts # Module exports
81
+ │ ├── PushNotification.ts # Main class
82
+ │ ├── BasePushNotification.ts # Core implementation
83
+ │ └── PushNotification.types.ts # Type definitions
84
+ │
85
+ └── platform/ # Platform Adapter Module
86
+ ├── index.ts # Module exports
87
+ ├── Platform.ts # Main adapter
88
+ ├── BasePlatform.ts # Core implementation
89
+ └── Platform.types.ts # Type definitions
11
90
  ```
12
91
 
13
- ### Optional Dependencies
92
+ ### Connection Flow
93
+
94
+ ```
95
+ @unvired/react-native-unvired-sdk
96
+ ↓
97
+ src/main.ts (Entry Point)
98
+ ↓
99
+ ┌───────┴───────┬───────────┬──────────┬────────────┬─────────────┬──────────┐
100
+ ↓ ↓ ↓ ↓ ↓ ↓ ↓
101
+ logger/ database/ local- device- file- push- platform/
102
+ index.ts index.ts storage/ info/ system/ notification/ index.ts
103
+ index.ts index.ts index.ts index.ts
104
+ ```
14
105
 
15
- The **logger works out of the box** with zero dependencies. For additional features, install the packages you need:
106
+ ---
107
+
108
+ ## 📦 Installation
109
+
110
+ ### Install the SDK
16
111
 
17
112
  ```bash
18
- # For file operations
19
- npm install @dr.pogodin/react-native-fs
113
+ npm install @unvired/react-native-unvired-sdk
114
+ ```
20
115
 
21
- # For database (choose one)
22
- npm install react-native-sqlite-storage # SQL database
23
- npm install @react-native-async-storage/async-storage # Simple key-value
116
+ ### Install Peer Dependencies
24
117
 
25
- # For notifications
26
- npm install @notifee/react-native
118
+ ```bash
119
+ npm install react-native-device-info @dr.pogodin/react-native-fs react-native-sqlite-storage @react-native-async-storage/async-storage
27
120
  ```
28
121
 
29
- > **See [NPM_PACKAGES.md](./NPM_PACKAGES.md) for detailed package information and implementation guide.**
122
+ ### Optional: Push Notifications
30
123
 
31
- ### Troubleshooting
124
+ ```bash
125
+ npm install @react-native-firebase/app @react-native-firebase/messaging
126
+ ```
32
127
 
33
- If you encounter errors like:
34
- - `Cannot read property 'RNFSFileTypeRegular' of null`
35
- - `Cannot read property 'PlatformManager' of undefined`
36
- - Native module linking issues
128
+ ### Platform Setup
37
129
 
38
- **See [TROUBLESHOOTING.md](./TROUBLESHOOTING.md) for detailed solutions.**
130
+ #### iOS
131
+ ```bash
132
+ cd ios && pod install
133
+ ```
39
134
 
40
- The SDK now includes defensive checks and will gracefully handle missing native modules with helpful error messages in the console.
135
+ #### Android
136
+ Ensure your `android/build.gradle` has the required repositories.
41
137
 
42
- ### Migration from react-native-fs
138
+ ---
43
139
 
44
- > **Note:** We now use `@dr.pogodin/react-native-fs` (actively maintained fork) instead of the deprecated `react-native-fs`.
45
- >
46
- > If you're upgrading from an older version, see [MIGRATION_GUIDE.md](./MIGRATION_GUIDE.md) for step-by-step instructions.
140
+ ## 🚀 Quick Start
47
141
 
48
- ## Features
142
+ ### Option 1: Use Individual Modules (Recommended)
49
143
 
50
- - 📝 **Logger** - Comprehensive logging with multiple log levels ✅ **No dependencies**
51
- - 💾 **Database** - Database operations and data persistence ⚠️ *Requires optional package*
52
- - 🔔 **Notifications** - Push and local notification management ⚠️ *Requires optional package*
53
- - 📁 **File System** - File read/write and management operations ⚠️ *Requires optional package*
54
- - 🔌 **PlatformInterface** - Compatible with PlatformInterface pattern for cross-platform logging
55
-
56
- ## Usage
57
-
58
- ### Basic Initialization
59
-
60
- ```javascript
61
- import UnviredSDK, { LogLevel } from 'react-native-unvired-sdk';
62
-
63
- // Initialize the SDK with all modules
64
- await UnviredSDK.initialize({
65
- logLevel: LogLevel.DEBUG,
66
- tag: 'MyApp',
67
- database: {
68
- // Database configuration
69
- },
70
- notifications: {
71
- // Notification configuration
72
- },
73
- fileSystem: {
74
- basePath: '/path/to/files'
75
- }
144
+ ```typescript
145
+ import {
146
+ logger,
147
+ LocalStorage,
148
+ createDatabase,
149
+ DeviceInfo,
150
+ FileSystem,
151
+ PushNotification
152
+ } from '@unvired/react-native-unvired-sdk';
153
+
154
+ // Logger
155
+ logger.setLogLevel('DEBUG');
156
+ logger.logInfo('App', 'init', 'Application started');
157
+
158
+ // Local Storage
159
+ await LocalStorage.setItem('user', { name: 'John', age: 30 });
160
+ const user = await LocalStorage.getItem('user');
161
+
162
+ // Database
163
+ const db = createDatabase('myapp');
164
+ await db.createTable('users', {
165
+ id: 'INTEGER PRIMARY KEY AUTOINCREMENT',
166
+ name: 'TEXT NOT NULL',
167
+ email: 'TEXT UNIQUE'
76
168
  });
77
- ```
169
+ await db.insert('users', { name: 'John', email: 'john@example.com' });
78
170
 
79
- ### Using the Logger
171
+ // Device Info
172
+ const platform = DeviceInfo.getPlatform(); // 'ios' or 'android'
173
+ const deviceInfo = DeviceInfo.getDeviceInfoSync();
80
174
 
81
- ```javascript
82
- import { logger, LogLevel } from 'react-native-unvired-sdk';
175
+ // File System
176
+ const docDir = FileSystem.getDocumentDirectory();
177
+ await FileSystem.writeFile(`${docDir}/test.txt`, 'Hello World');
83
178
 
84
- // Set log level
85
- logger.setLogLevel(LogLevel.DEBUG);
179
+ // Push Notifications
180
+ const push = new PushNotification();
181
+ await push.requestPermission();
182
+ const token = await push.getToken();
183
+ ```
86
184
 
87
- // Log messages
88
- logger.debug('Debug message');
89
- logger.info('Info message');
90
- logger.warn('Warning message');
91
- logger.error('Error message');
185
+ ### Option 2: Use Platform Adapter
92
186
 
93
- // Create child logger for specific modules
94
- const childLogger = logger.createChild('FeatureModule');
95
- childLogger.info('This is from a child logger');
187
+ ```typescript
188
+ import { getPlatformAdapter } from '@unvired/react-native-unvired-sdk';
189
+
190
+ const platform = getPlatformAdapter();
191
+
192
+ // All modules accessible through platform adapter
193
+ const logger = platform.getLoggerAdapter();
194
+ const storage = platform.getStorageAdapter();
195
+ const dbAdapter = platform.getDatabaseAdapter();
196
+ const deviceInfo = platform.getDeviceInfo();
96
197
  ```
97
198
 
98
- ### Using PlatformInterface Pattern
199
+ ---
200
+
201
+ ## 📚 Modules
99
202
 
100
- ```javascript
101
- import { logger } from 'react-native-unvired-sdk';
203
+ ### 1. Logger Module
102
204
 
103
- // Use with className and methodName (PlatformInterface compatible)
104
- logger.logInfo('UserService', 'login', 'User login attempt');
105
- logger.logError('UserService', 'login', 'Login failed');
106
- logger.logDebug('UserService', 'fetchProfile', 'Fetching user profile');
205
+ Advanced logging with file persistence, compression, and rotation.
206
+
207
+ ```typescript
208
+ import { logger } from '@unvired/react-native-unvired-sdk';
107
209
 
108
- // Set log level (accepts string)
109
210
  logger.setLogLevel('DEBUG');
211
+ logger.logDebug('MyClass', 'myMethod', 'Debug message');
212
+ logger.logInfo('MyClass', 'myMethod', 'Info message');
213
+ logger.logError('MyClass', 'myMethod', 'Error message');
110
214
 
111
- // File-based logging
215
+ // Get log file content
112
216
  const logs = await logger.getLogFileContent();
113
- const backupLogs = await logger.getBackupLogFileContent();
114
- await logger.clearLogFile();
115
217
  ```
116
218
 
117
- ### Database Operations
219
+ **Features:**
220
+ - Multiple log levels (DEBUG, INFO, ERROR)
221
+ - File persistence with automatic rotation
222
+ - Compression (gzip)
223
+ - Async operations
224
+ - Platform-specific implementations
118
225
 
119
- ```javascript
120
- import { database } from 'react-native-unvired-sdk';
226
+ ---
121
227
 
122
- // Initialize database (if not done in SDK initialization)
123
- await database.initialize({ /* config */ });
228
+ ### 2. Database Module
124
229
 
125
- // Insert or update data
126
- await database.upsert('users', {
127
- id: 1,
128
- name: 'John Doe',
129
- email: 'john@example.com'
130
- });
230
+ SQLite database with both low-level and high-level APIs.
231
+
232
+ ```typescript
233
+ import { createDatabase, DatabaseManager } from '@unvired/react-native-unvired-sdk';
131
234
 
132
- // Query data
133
- const users = await database.query('users', {
134
- where: { active: true }
235
+ // High-level API (recommended)
236
+ const db = createDatabase('myapp');
237
+ await db.createTable('users', {
238
+ id: 'INTEGER PRIMARY KEY AUTOINCREMENT',
239
+ name: 'TEXT NOT NULL',
240
+ email: 'TEXT UNIQUE'
135
241
  });
242
+ await db.insert('users', { name: 'John', email: 'john@example.com' });
243
+ const users = await db.select('users');
244
+
245
+ // Low-level API
246
+ const adapter = DatabaseManager.getDatabaseAdapter();
247
+ adapter.execute({
248
+ dbName: 'myapp',
249
+ query: 'SELECT * FROM users'
250
+ }, successCallback, errorCallback);
251
+ ```
136
252
 
137
- // Delete data
138
- await database.delete('users', { id: 1 });
253
+ **Features:**
254
+ - SQLite integration
255
+ - ORM-like interface
256
+ - Transaction support
257
+ - Connection pooling
258
+ - Batch operations
259
+ - Both callback and promise-based APIs
139
260
 
140
- // Execute transaction
141
- await database.transaction(async (db) => {
142
- await db.upsert('users', userData);
143
- await db.upsert('profiles', profileData);
144
- });
261
+ 📚 **[Database Documentation](./DATABASE_USAGE.md)** | **[Quick Reference](./DATABASE_QUICK_REF.md)**
262
+
263
+ ---
264
+
265
+ ### 3. Local Storage Module
266
+
267
+ AsyncStorage wrapper with automatic JSON serialization.
268
+
269
+ ```typescript
270
+ import { LocalStorage } from '@unvired/react-native-unvired-sdk';
271
+
272
+ // Store data
273
+ await LocalStorage.setItem('user', { name: 'John', age: 30 });
274
+
275
+ // Retrieve data
276
+ const user = await LocalStorage.getItem<{ name: string; age: number }>('user');
277
+
278
+ // Remove item
279
+ await LocalStorage.removeItem('user');
280
+
281
+ // Clear all
282
+ await LocalStorage.clear();
283
+
284
+ // Batch operations
285
+ await LocalStorage.multiSet([
286
+ ['key1', 'value1'],
287
+ ['key2', 'value2']
288
+ ]);
289
+ ```
290
+
291
+ **Features:**
292
+ - Automatic JSON serialization/deserialization
293
+ - TypeScript generics support
294
+ - Batch operations
295
+ - Error handling
296
+
297
+ 📚 **[LocalStorage Documentation](./LOCALSTORAGE_USAGE.md)**
298
+
299
+ ---
300
+
301
+ ### 4. Device Info Module
145
302
 
146
- // Clear all data
147
- await database.clear();
303
+ Device information and platform detection.
148
304
 
149
- // Close database
150
- await database.close();
305
+ ```typescript
306
+ import { DeviceInfo } from '@unvired/react-native-unvired-sdk';
307
+
308
+ // Synchronous (returns cached data)
309
+ const deviceInfo = DeviceInfo.getDeviceInfoSync();
310
+ console.log(deviceInfo.platform); // 'ios' or 'android'
311
+ console.log(deviceInfo.model); // 'iPhone 14 Pro'
312
+ console.log(deviceInfo.manufacturer); // 'Apple'
313
+
314
+ // Get platform
315
+ const platform = DeviceInfo.getPlatform(); // 'ios' or 'android'
316
+
317
+ // Get frontend type
318
+ const frontendType = DeviceInfo.getFrontendType(); // 'APPLE_PHONE' or 'ANDROID_PHONE'
319
+
320
+ // Async (populates cache)
321
+ await DeviceInfo.getDeviceInfo();
151
322
  ```
152
323
 
153
- ### Notifications
324
+ **Features:**
325
+ - Platform detection
326
+ - Device model and manufacturer
327
+ - Unique device ID
328
+ - App version information
329
+ - Tablet detection
330
+
331
+ ---
332
+
333
+ ### 5. File System Module
334
+
335
+ Comprehensive file system operations.
154
336
 
155
- ```javascript
156
- import { notificationManager } from 'react-native-unvired-sdk';
337
+ ```typescript
338
+ import { FileSystem } from '@unvired/react-native-unvired-sdk';
339
+
340
+ // Get document directory
341
+ const docDir = FileSystem.getDocumentDirectory();
342
+
343
+ // Read/Write files
344
+ const content = await FileSystem.readFile('/path/to/file.txt');
345
+ await FileSystem.writeFile('/path/to/file.txt', 'content');
346
+
347
+ // File operations
348
+ await FileSystem.copyFile(source, destination);
349
+ await FileSystem.moveFile(source, destination);
350
+ await FileSystem.deleteFile('/path/to/file.txt');
351
+
352
+ // Directory operations
353
+ await FileSystem.createDirectory('/path/to/dir');
354
+ const files = await FileSystem.readDir('/path/to/dir');
355
+
356
+ // Check existence
357
+ const exists = await FileSystem.exists('/path/to/file');
358
+
359
+ // User-specific folders
360
+ const userFolder = await FileSystem.getFolderBasedOnUserId('user123');
361
+ await FileSystem.deleteUserFolder('user123');
362
+ ```
157
363
 
158
- // Initialize notifications (if not done in SDK initialization)
159
- await notificationManager.initialize({ /* config */ });
364
+ **Features:**
365
+ - File read/write operations
366
+ - Directory management
367
+ - File copy/move operations
368
+ - User-specific folder management
369
+ - File existence checks
370
+ - File stats and metadata
160
371
 
161
- // Request permissions
162
- const granted = await notificationManager.requestPermissions();
372
+ ---
163
373
 
164
- // Show a notification
165
- await notificationManager.showNotification({
166
- title: 'Hello',
167
- body: 'This is a notification',
168
- data: { customData: 'value' }
374
+ ### 6. Push Notification Module
375
+
376
+ Firebase Cloud Messaging integration.
377
+
378
+ ```typescript
379
+ import { PushNotification } from '@unvired/react-native-unvired-sdk';
380
+
381
+ const push = new PushNotification();
382
+
383
+ // Request permission
384
+ await push.requestPermission();
385
+
386
+ // Get token
387
+ const token = await push.getToken();
388
+
389
+ // Listen for token refresh
390
+ push.onTokenRefresh((newToken) => {
391
+ console.log('Token refreshed:', newToken);
169
392
  });
170
393
 
171
- // Schedule a notification
172
- const notificationId = await notificationManager.scheduleNotification(
173
- {
174
- title: 'Reminder',
175
- body: 'Don\'t forget!'
176
- },
177
- new Date(Date.now() + 3600000) // 1 hour from now
178
- );
179
-
180
- // Cancel a notification
181
- await notificationManager.cancelNotification(notificationId);
182
-
183
- // Listen for notification events
184
- const unsubscribe = notificationManager.on('onNotificationReceived', (notification) => {
185
- console.log('Notification received:', notification);
394
+ // Listen for messages
395
+ push.onMessage((message) => {
396
+ console.log('Foreground message:', message);
186
397
  });
187
398
 
188
- // Set badge count
189
- await notificationManager.setBadgeCount(5);
399
+ // Listen for background messages
400
+ push.onBackgroundMessage((message) => {
401
+ console.log('Background message:', message);
402
+ });
190
403
 
191
- // Get badge count
192
- const count = await notificationManager.getBadgeCount();
404
+ // Subscribe to topics
405
+ await push.subscribeToTopic('news');
406
+ await push.unsubscribeFromTopic('news');
193
407
  ```
194
408
 
195
- ### File System Operations
409
+ **Features:**
410
+ - FCM integration
411
+ - Permission handling
412
+ - Token management
413
+ - Foreground/background message handling
414
+ - Topic subscription
415
+ - Initial notification handling
196
416
 
197
- ```javascript
198
- import { fileManager } from 'react-native-unvired-sdk';
417
+ ---
199
418
 
200
- // Initialize file manager (if not done in SDK initialization)
201
- await fileManager.initialize({ basePath: '/path/to/files' });
419
+ ### 7. Platform Adapter Module
202
420
 
203
- // Read a file
204
- const content = await fileManager.readFile('data.txt');
421
+ Unified interface for all platform-specific functionality.
205
422
 
206
- // Write to a file
207
- await fileManager.writeFile('data.txt', 'Hello World');
423
+ ```typescript
424
+ import { getPlatformAdapter } from '@unvired/react-native-unvired-sdk';
208
425
 
209
- // Append to a file
210
- await fileManager.appendFile('log.txt', 'New log entry\n');
426
+ const platform = getPlatformAdapter();
211
427
 
212
- // Check if file exists
213
- const exists = await fileManager.exists('data.txt');
428
+ // Device info
429
+ const deviceInfo = platform.getDeviceInfo();
430
+ const platformName = platform.getPlatform();
214
431
 
215
- // Delete a file
216
- await fileManager.deleteFile('old-file.txt');
432
+ // File system
433
+ const docDir = platform.getDocumentDirectory();
434
+ const userFolder = await platform.getFolderBasedOnUserId('user123');
217
435
 
218
- // Create directory
219
- await fileManager.createDirectory('my-folder');
436
+ // Database
437
+ const dbAdapter = platform.getDatabaseAdapter();
438
+
439
+ // Storage
440
+ const storage = platform.getStorageAdapter();
441
+ await storage.setItem('key', 'value');
442
+
443
+ // Logger
444
+ const logger = platform.getLoggerAdapter();
445
+ logger.logInfo('Class', 'method', 'message');
220
446
 
221
- // List files in directory
222
- const files = await fileManager.listFiles('my-folder');
447
+ // Push notifications
448
+ const pushAdapter = platform.getPushNotificationAdapter();
449
+ ```
450
+
451
+ **Features:**
452
+ - Unified interface for all modules
453
+ - Consistent API across platforms
454
+ - Easy integration with ts-core-sdk
455
+ - Singleton pattern
456
+
457
+ 📚 **[Platform Adapter Documentation](./PLATFORM_USAGE.md)**
458
+
459
+ ---
460
+
461
+ ## 📖 Documentation
462
+
463
+ - **[Platform Adapter Guide](./PLATFORM_USAGE.md)** - Complete platform adapter documentation
464
+ - **[Database Guide](./DATABASE_USAGE.md)** - Database operations and examples
465
+ - **[Database Quick Reference](./DATABASE_QUICK_REF.md)** - Quick reference for database
466
+ - **[LocalStorage Guide](./LOCALSTORAGE_USAGE.md)** - Local storage operations
467
+ - **[Module Connection Map](./MODULE_CONNECTION_MAP.md)** - Architecture and module connections
468
+ - **[How to Use in ts-core-sdk](./HOW_TO_USE_IN_TS_CORE_SDK.md)** - Integration guide
469
+
470
+ ---
471
+
472
+ ## 🎯 TypeScript Support
473
+
474
+ The SDK is fully typed with TypeScript:
475
+
476
+ ```typescript
477
+ import type {
478
+ // Platform types
479
+ IPlatformAdapter,
480
+ IDeviceInfo,
481
+ IFileEntry,
482
+
483
+ // Database types
484
+ IDatabaseAdapter,
485
+ DatabaseOptions,
486
+
487
+ // Logger types
488
+ ILoggerAdapter,
489
+ LogLevel,
490
+
491
+ // Storage types
492
+ IStorageAdapter,
493
+
494
+ // Push notification types
495
+ IPushNotificationAdapter
496
+ } from '@unvired/react-native-unvired-sdk';
497
+ ```
223
498
 
224
- // Copy file
225
- await fileManager.copyFile('source.txt', 'destination.txt');
499
+ ---
226
500
 
227
- // Move file
228
- await fileManager.moveFile('old-location.txt', 'new-location.txt');
501
+ ## 📋 Requirements
229
502
 
230
- // Download file
231
- await fileManager.downloadFile(
232
- 'https://example.com/file.pdf',
233
- 'downloads/file.pdf',
234
- (progress) => console.log(`Downloaded: ${progress}%`)
235
- );
503
+ - **React Native** >= 0.60.0
504
+ - **React** >= 16.8.0
505
+ - **iOS** >= 11.0
506
+ - **Android** >= API 21
507
+ - **Node.js** >= 14.0.0
236
508
 
237
- // Upload file
238
- await fileManager.uploadFile(
239
- 'local-file.jpg',
240
- 'https://example.com/upload',
241
- { headers: { 'Authorization': 'Bearer token' } },
242
- (progress) => console.log(`Uploaded: ${progress}%`)
243
- );
509
+ ---
244
510
 
245
- // Get file info
246
- const info = await fileManager.getFileInfo('data.txt');
247
- console.log(info.size, info.modifiedTime);
511
+ ## 🤝 Contributing
512
+
513
+ This is a private SDK. For issues and questions, please contact Unvired support.
514
+
515
+ ---
516
+
517
+ ## 📄 License
518
+
519
+ UNLICENSED - Private SDK for Unvired applications
520
+
521
+ ---
522
+
523
+ ## 🆘 Support
524
+
525
+ For support and questions:
526
+ - Check the documentation files in this repository
527
+ - Contact Unvired support team
528
+
529
+ ---
530
+
531
+ ## 🎉 Summary
532
+
533
+ The Unvired React Native SDK provides:
534
+
535
+ - ✅ **7 Major Modules** - Logger, Database, LocalStorage, DeviceInfo, FileSystem, PushNotification, Platform
536
+ - ✅ **Clean Architecture** - Modular design with consistent patterns
537
+ - ✅ **Full TypeScript** - Complete type safety throughout
538
+ - ✅ **Production Ready** - Battle-tested and optimized
539
+ - ✅ **Comprehensive Docs** - Detailed guides and examples
540
+ - ✅ **Easy Integration** - Works seamlessly with ts-core-sdk
541
+
542
+ **Build powerful React Native applications with confidence!** 🚀
543
+
544
+ Comprehensive SDK for React Native applications providing logging, database, storage, file system, device info, and push notification capabilities.
545
+
546
+ ## Features
547
+
548
+ - 📝 **Logger** - Advanced logging with file persistence and compression
549
+ - 💾 **Database** - SQLite database with ORM-like interface
550
+ - 🗄️ **Local Storage** - AsyncStorage wrapper with JSON serialization
551
+ - 📁 **File System** - Comprehensive file system operations
552
+ - 📱 **Device Info** - Device information and platform detection
553
+ - 🔔 **Push Notifications** - Firebase Cloud Messaging integration
554
+ - 🔌 **Platform Adapter** - Unified interface for all platform-specific functionality
555
+
556
+ ## Installation
557
+
558
+ ```bash
559
+ npm install @unvired/react-native-unvired-sdk
248
560
  ```
249
561
 
250
- ### SDK Shutdown
562
+ ### Peer Dependencies
251
563
 
252
- ```javascript
253
- // Properly shutdown SDK and cleanup resources
254
- await UnviredSDK.shutdown();
564
+ Install required peer dependencies:
565
+
566
+ ```bash
567
+ npm install react-native-device-info @dr.pogodin/react-native-fs react-native-sqlite-storage @react-native-async-storage/async-storage
255
568
  ```
256
569
 
257
- ## API Reference
570
+ ### Optional Dependencies
258
571
 
259
- ### Log Levels
260
-
261
- - `LogLevel.DEBUG` - Detailed debugging information
262
- - `LogLevel.INFO` - General informational messages
263
- - `LogLevel.WARN` - Warning messages
264
- - `LogLevel.ERROR` - Error messages
265
- - `LogLevel.NONE` - Disable all logging
266
-
267
- ### Logger Methods
268
-
269
- - `logger.debug(message, ...args)` - Log debug message
270
- - `logger.info(message, ...args)` - Log info message
271
- - `logger.warn(message, ...args)` - Log warning message
272
- - `logger.error(message, ...args)` - Log error message
273
- - `logger.setLogLevel(level)` - Set minimum log level
274
- - `logger.setTag(tag)` - Set custom tag
275
- - `logger.createChild(childTag)` - Create child logger with custom tag
276
-
277
- ### Database Methods
278
-
279
- - `database.initialize(config)` - Initialize database
280
- - `database.upsert(table, data)` - Insert or update data
281
- - `database.query(table, query)` - Query data
282
- - `database.delete(table, query)` - Delete data
283
- - `database.transaction(callback)` - Execute transaction
284
- - `database.clear()` - Clear all data
285
- - `database.close()` - Close database connection
286
-
287
- ### Notification Methods
288
-
289
- - `notificationManager.initialize(config)` - Initialize notifications
290
- - `notificationManager.requestPermissions()` - Request notification permissions
291
- - `notificationManager.showNotification(notification)` - Show notification
292
- - `notificationManager.scheduleNotification(notification, time)` - Schedule notification
293
- - `notificationManager.cancelNotification(id)` - Cancel notification
294
- - `notificationManager.cancelAllNotifications()` - Cancel all notifications
295
- - `notificationManager.on(event, handler)` - Register event handler
296
- - `notificationManager.setBadgeCount(count)` - Set badge count
297
- - `notificationManager.getBadgeCount()` - Get badge count
298
-
299
- ### File System Methods
300
-
301
- - `fileManager.initialize(config)` - Initialize file manager
302
- - `fileManager.readFile(path, encoding)` - Read file
303
- - `fileManager.writeFile(path, content, encoding)` - Write file
304
- - `fileManager.appendFile(path, content, encoding)` - Append to file
305
- - `fileManager.deleteFile(path)` - Delete file
306
- - `fileManager.exists(path)` - Check if file exists
307
- - `fileManager.createDirectory(path)` - Create directory
308
- - `fileManager.listFiles(path)` - List files in directory
309
- - `fileManager.copyFile(source, dest)` - Copy file
310
- - `fileManager.moveFile(source, dest)` - Move file
311
- - `fileManager.downloadFile(url, path, onProgress)` - Download file
312
- - `fileManager.uploadFile(path, url, options, onProgress)` - Upload file
313
- - `fileManager.getFileInfo(path)` - Get file information
314
-
315
- ## Development
572
+ For push notifications:
316
573
 
317
574
  ```bash
318
- # Install dependencies
319
- npm install
575
+ npm install @react-native-firebase/app @react-native-firebase/messaging
576
+ ```
320
577
 
321
- # Run tests
322
- npm test
578
+ ### Platform Setup
323
579
 
324
- # Lint code
325
- npm run lint
580
+ #### iOS
326
581
 
327
- # Format code
328
- npm run format
582
+ ```bash
583
+ cd ios && pod install
329
584
  ```
330
585
 
331
- ## Architecture
586
+ #### Android
332
587
 
333
- The SDK is organized into modular components:
588
+ Ensure your `android/build.gradle` has the required repositories.
334
589
 
590
+ ## Quick Start
591
+
592
+ ```typescript
593
+ import {
594
+ getPlatformAdapter,
595
+ logger,
596
+ LocalStorage,
597
+ createDatabase
598
+ } from '@unvired/react-native-unvired-sdk';
599
+
600
+ // Get platform adapter (recommended)
601
+ const platform = getPlatformAdapter();
602
+
603
+ // Or use individual modules
604
+ logger.logInfo('App', 'init', 'Application started');
605
+ await LocalStorage.setItem('user', { name: 'John' });
606
+ const db = createDatabase('myapp');
335
607
  ```
336
- src/
337
- ├── logger/ # Logging utilities
338
- ├── database/ # Database operations
339
- ├── notifications/ # Notification management
340
- ├── fileSystem/ # File system operations
341
- └── index.js # Main SDK entry point
608
+
609
+ ## Modules
610
+
611
+ ### 1. Platform Adapter (Recommended)
612
+
613
+ Unified interface for all SDK functionality.
614
+
615
+ ```typescript
616
+ import { getPlatformAdapter } from '@unvired/react-native-unvired-sdk';
617
+
618
+ const platform = getPlatformAdapter();
619
+
620
+ // Device info
621
+ const deviceInfo = platform.getDeviceInfo();
622
+
623
+ // Logger
624
+ const logger = platform.getLoggerAdapter();
625
+ logger.logInfo('MyClass', 'myMethod', 'Message');
626
+
627
+ // Database
628
+ const dbAdapter = platform.getDatabaseAdapter();
629
+
630
+ // Storage
631
+ const storage = platform.getStorageAdapter();
632
+ await storage.setItem('key', 'value');
633
+
634
+ // File system
635
+ const userFolder = await platform.getFolderBasedOnUserId('user123');
636
+
637
+ // Push notifications
638
+ const pushAdapter = platform.getPushNotificationAdapter();
342
639
  ```
343
640
 
344
- Each module can be initialized independently or as part of the main SDK initialization.
641
+ 📚 **[Platform Adapter Documentation](./PLATFORM_USAGE.md)**
642
+
643
+ ---
644
+
645
+ ### 2. Logger
646
+
647
+ Advanced logging with file persistence, compression, and rotation.
648
+
649
+ ```typescript
650
+ import { logger } from '@unvired/react-native-unvired-sdk';
651
+
652
+ logger.setLogLevel('DEBUG');
653
+ logger.logDebug('MyClass', 'myMethod', 'Debug message');
654
+ logger.logInfo('MyClass', 'myMethod', 'Info message');
655
+ logger.logError('MyClass', 'myMethod', 'Error message');
656
+
657
+ // Get log file content
658
+ const logs = await logger.getLogFileContent();
659
+ ```
660
+
661
+ **Features:**
662
+ - Multiple log levels (DEBUG, INFO, ERROR)
663
+ - File persistence with rotation
664
+ - Compression (gzip)
665
+ - Async operations
666
+
667
+ ---
668
+
669
+ ### 3. Database
670
+
671
+ SQLite database with both low-level and high-level APIs.
672
+
673
+ ```typescript
674
+ import { createDatabase, DatabaseManager } from '@unvired/react-native-unvired-sdk';
675
+
676
+ // High-level API (recommended)
677
+ const db = createDatabase('myapp');
678
+
679
+ await db.createTable('users', {
680
+ id: 'INTEGER PRIMARY KEY AUTOINCREMENT',
681
+ name: 'TEXT NOT NULL',
682
+ email: 'TEXT UNIQUE'
683
+ });
684
+
685
+ await db.insert('users', { name: 'John', email: 'john@example.com' });
686
+ const users = await db.select('users');
687
+
688
+ // Low-level API
689
+ const adapter = DatabaseManager.getDatabaseAdapter();
690
+ adapter.execute({
691
+ dbName: 'myapp',
692
+ query: 'SELECT * FROM users'
693
+ }, successCallback, errorCallback);
694
+ ```
695
+
696
+ **Features:**
697
+ - SQLite integration
698
+ - ORM-like interface
699
+ - Transaction support
700
+ - Connection pooling
701
+ - Batch operations
702
+
703
+ 📚 **[Database Documentation](./DATABASE_USAGE.md)** | **[Quick Reference](./DATABASE_QUICK_REF.md)**
704
+
705
+ ---
706
+
707
+ ### 4. Local Storage
708
+
709
+ AsyncStorage wrapper with automatic JSON serialization.
710
+
711
+ ```typescript
712
+ import { LocalStorage } from '@unvired/react-native-unvired-sdk';
713
+
714
+ // Store data
715
+ await LocalStorage.setItem('user', { name: 'John', age: 30 });
716
+
717
+ // Retrieve data
718
+ const user = await LocalStorage.getItem<{ name: string; age: number }>('user');
719
+
720
+ // Remove item
721
+ await LocalStorage.removeItem('user');
722
+
723
+ // Clear all
724
+ await LocalStorage.clear();
725
+
726
+ // Batch operations
727
+ await LocalStorage.multiSet([
728
+ ['key1', 'value1'],
729
+ ['key2', 'value2']
730
+ ]);
731
+ ```
732
+
733
+ **Features:**
734
+ - Automatic JSON serialization/deserialization
735
+ - TypeScript generics support
736
+ - Batch operations
737
+ - Error handling
738
+
739
+ 📚 **[LocalStorage Documentation](./LOCALSTORAGE_USAGE.md)**
740
+
741
+ ---
742
+
743
+ ### 5. File System
744
+
745
+ Comprehensive file system operations.
746
+
747
+ ```typescript
748
+ import { FileSystemManager } from '@unvired/react-native-unvired-sdk';
749
+
750
+ // Create directory
751
+ await FileSystemManager.createDirectory('/path/to/dir');
752
+
753
+ // Read/Write files
754
+ const content = await FileSystemManager.readFile('/path/to/file.txt');
755
+ await FileSystemManager.writeFile('/path/to/file.txt', 'content');
756
+
757
+ // File operations
758
+ await FileSystemManager.copyFile(source, destination);
759
+ await FileSystemManager.moveFile(source, destination);
760
+ await FileSystemManager.deleteFile('/path/to/file.txt');
761
+
762
+ // Check existence
763
+ const exists = await FileSystemManager.exists('/path/to/file.txt');
764
+
765
+ // List directory
766
+ const files = await FileSystemManager.readDir('/path/to/dir');
767
+ ```
768
+
769
+ ---
770
+
771
+ ### 6. Device Info
772
+
773
+ Device information and platform detection.
774
+
775
+ ```typescript
776
+ import { DeviceInfoManager } from '@unvired/react-native-unvired-sdk';
777
+
778
+ const deviceInfo = await DeviceInfoManager.getDeviceInfo();
779
+ console.log(deviceInfo.platform); // 'ios' or 'android'
780
+ console.log(deviceInfo.model); // 'iPhone 14 Pro'
781
+ console.log(deviceInfo.manufacturer); // 'Apple'
782
+ console.log(deviceInfo.uuid); // Unique device ID
783
+
784
+ const isTablet = await DeviceInfoManager.isTablet();
785
+ const appVersion = await DeviceInfoManager.getAppVersion();
786
+ ```
787
+
788
+ ---
789
+
790
+ ### 7. Push Notifications
791
+
792
+ Firebase Cloud Messaging integration.
793
+
794
+ ```typescript
795
+ import { PushNotificationManager } from '@unvired/react-native-unvired-sdk';
796
+
797
+ const pushManager = new PushNotificationManager();
798
+
799
+ // Request permission
800
+ await pushManager.requestPermission();
801
+
802
+ // Get token
803
+ const token = await pushManager.getToken();
804
+
805
+ // Listen for messages
806
+ pushManager.onMessage((message) => {
807
+ console.log('Foreground message:', message);
808
+ });
809
+
810
+ pushManager.onBackgroundMessage((message) => {
811
+ console.log('Background message:', message);
812
+ });
813
+
814
+ // Subscribe to topics
815
+ await pushManager.subscribeToTopic('news');
816
+ ```
817
+
818
+ ---
819
+
820
+ ## TypeScript Support
821
+
822
+ The SDK is fully typed with TypeScript:
823
+
824
+ ```typescript
825
+ import type {
826
+ PlatformInterface,
827
+ IDeviceInfo,
828
+ IFileEntry,
829
+ IDatabaseAdapter,
830
+ IPushNotificationAdapter,
831
+ ILoggerAdapter,
832
+ IStorageAdapter,
833
+ LogLevel
834
+ } from '@unvired/react-native-unvired-sdk';
835
+ ```
836
+
837
+ ---
838
+
839
+ ## Complete Example
840
+
841
+ ```typescript
842
+ import React, { useEffect } from 'react';
843
+ import { View, Text } from 'react-native';
844
+ import {
845
+ getPlatformAdapter,
846
+ createDatabase,
847
+ LocalStorage,
848
+ logger
849
+ } from '@unvired/react-native-unvired-sdk';
850
+
851
+ const App = () => {
852
+ useEffect(() => {
853
+ initializeSDK();
854
+ }, []);
855
+
856
+ const initializeSDK = async () => {
857
+ // Initialize logger
858
+ logger.setLogLevel('DEBUG');
859
+ logger.logInfo('App', 'init', 'Initializing SDK');
860
+
861
+ // Get platform adapter
862
+ const platform = getPlatformAdapter();
863
+ const deviceInfo = platform.getDeviceInfo();
864
+ logger.logInfo('App', 'init', `Platform: ${deviceInfo.platform}`);
865
+
866
+ // Initialize database
867
+ const db = createDatabase('myapp');
868
+ await db.createTable('users', {
869
+ id: 'INTEGER PRIMARY KEY AUTOINCREMENT',
870
+ name: 'TEXT NOT NULL',
871
+ email: 'TEXT UNIQUE'
872
+ });
873
+
874
+ // Store user preferences
875
+ await LocalStorage.setItem('preferences', {
876
+ theme: 'dark',
877
+ notifications: true
878
+ });
879
+
880
+ // Get user folder
881
+ const userFolder = await platform.getFolderBasedOnUserId('user123');
882
+ logger.logInfo('App', 'init', `User folder: ${userFolder}`);
883
+
884
+ // Initialize push notifications
885
+ const pushAdapter = platform.getPushNotificationAdapter();
886
+ if (pushAdapter) {
887
+ await pushAdapter.requestPermission();
888
+ const token = await pushAdapter.getToken();
889
+ logger.logInfo('App', 'init', `FCM Token: ${token}`);
890
+ }
891
+ };
892
+
893
+ return (
894
+ <View>
895
+ <Text>Unvired SDK Initialized</Text>
896
+ </View>
897
+ );
898
+ };
899
+
900
+ export default App;
901
+ ```
902
+
903
+ ---
904
+
905
+ ## Documentation
906
+
907
+ - **[Platform Adapter Guide](./PLATFORM_USAGE.md)** - Complete platform adapter documentation
908
+ - **[Database Guide](./DATABASE_USAGE.md)** - Database operations and examples
909
+ - **[Database Quick Reference](./DATABASE_QUICK_REF.md)** - Quick reference for database
910
+ - **[LocalStorage Guide](./LOCALSTORAGE_USAGE.md)** - Local storage operations
911
+
912
+ ---
913
+
914
+ ## API Reference
915
+
916
+ ### Exports
917
+
918
+ ```typescript
919
+ // Platform
920
+ export { ReactNativePlatformAdapter, getPlatformAdapter, resetPlatformAdapter }
921
+ export { DeviceInfoManager, FileSystemManager, PushNotificationManager }
922
+
923
+ // Logger
924
+ export { Logger, logger }
925
+
926
+ // Database
927
+ export { DatabaseManager, Database, createDatabase }
928
+
929
+ // Storage
930
+ export { LocalStorage }
931
+
932
+ // Types
933
+ export type {
934
+ PlatformInterface,
935
+ IDeviceInfo,
936
+ IFileEntry,
937
+ IDatabaseAdapter,
938
+ IPushNotificationAdapter,
939
+ ILoggerAdapter,
940
+ IStorageAdapter,
941
+ LogLevel,
942
+ DatabaseOptions,
943
+ // ... and more
944
+ }
945
+ ```
946
+
947
+ ---
948
+
949
+ ## Best Practices
950
+
951
+ 1. **Use Platform Adapter** - Recommended for accessing all SDK functionality
952
+ 2. **Initialize Early** - Initialize SDK in your app's entry point
953
+ 3. **Handle Errors** - Always use try-catch for async operations
954
+ 4. **TypeScript** - Leverage TypeScript for type safety
955
+ 5. **Logging** - Use the logger for consistent logging across your app
956
+ 6. **Clean Up** - Properly close database connections and clean up resources
957
+
958
+ ---
959
+
960
+ ## Requirements
961
+
962
+ - React Native >= 0.60.0
963
+ - React >= 16.8.0
964
+ - iOS >= 11.0
965
+ - Android >= API 21
966
+
967
+ ---
345
968
 
346
969
  ## License
347
970
 
348
- MIT
971
+ UNLICENSED
972
+
973
+ ---
974
+
975
+ ## Support
976
+
977
+ For issues and questions, please refer to the documentation files or contact Unvired support.