@explorins/pers-sdk-react-native 1.3.2 → 1.5.1

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 (90) hide show
  1. package/README.md +276 -123
  2. package/dist/hooks/index.d.ts +8 -0
  3. package/dist/hooks/index.d.ts.map +1 -1
  4. package/dist/hooks/index.js +7 -0
  5. package/dist/hooks/useAnalytics.d.ts +96 -0
  6. package/dist/hooks/useAnalytics.d.ts.map +1 -0
  7. package/dist/hooks/useAnalytics.js +73 -0
  8. package/dist/hooks/useAuth.d.ts +52 -7
  9. package/dist/hooks/useAuth.d.ts.map +1 -1
  10. package/dist/hooks/useAuth.js +250 -3
  11. package/dist/hooks/useBusiness.d.ts +45 -3
  12. package/dist/hooks/useBusiness.d.ts.map +1 -1
  13. package/dist/hooks/useBusiness.js +182 -28
  14. package/dist/hooks/useCampaigns.d.ts +11 -4
  15. package/dist/hooks/useCampaigns.d.ts.map +1 -1
  16. package/dist/hooks/useCampaigns.js +101 -39
  17. package/dist/hooks/useDonations.d.ts +33 -0
  18. package/dist/hooks/useDonations.d.ts.map +1 -0
  19. package/dist/hooks/useDonations.js +62 -0
  20. package/dist/hooks/useFiles.d.ts +50 -0
  21. package/dist/hooks/useFiles.d.ts.map +1 -0
  22. package/dist/hooks/useFiles.js +140 -0
  23. package/dist/hooks/usePurchases.d.ts +9 -0
  24. package/dist/hooks/usePurchases.d.ts.map +1 -0
  25. package/dist/hooks/usePurchases.js +56 -0
  26. package/dist/hooks/useRedemptions.d.ts +10 -5
  27. package/dist/hooks/useRedemptions.d.ts.map +1 -1
  28. package/dist/hooks/useRedemptions.js +94 -66
  29. package/dist/hooks/useTenants.d.ts +10 -0
  30. package/dist/hooks/useTenants.d.ts.map +1 -0
  31. package/dist/hooks/useTenants.js +68 -0
  32. package/dist/hooks/useTokens.d.ts +36 -2
  33. package/dist/hooks/useTokens.d.ts.map +1 -1
  34. package/dist/hooks/useTokens.js +180 -19
  35. package/dist/hooks/useTransactions.d.ts +45 -3
  36. package/dist/hooks/useTransactions.d.ts.map +1 -1
  37. package/dist/hooks/useTransactions.js +152 -31
  38. package/dist/hooks/useUserStatus.d.ts +9 -0
  39. package/dist/hooks/useUserStatus.d.ts.map +1 -0
  40. package/dist/hooks/useUserStatus.js +57 -0
  41. package/dist/hooks/useUsers.d.ts +17 -0
  42. package/dist/hooks/useUsers.d.ts.map +1 -0
  43. package/dist/hooks/useUsers.js +120 -0
  44. package/dist/hooks/useWeb3.d.ts +69 -6
  45. package/dist/hooks/useWeb3.d.ts.map +1 -1
  46. package/dist/hooks/useWeb3.js +177 -17
  47. package/dist/index.d.ts +6 -4
  48. package/dist/index.d.ts.map +1 -1
  49. package/dist/index.js +12199 -796
  50. package/dist/index.js.map +1 -1
  51. package/dist/polyfills/index.d.ts +1 -1
  52. package/dist/polyfills/index.d.ts.map +1 -1
  53. package/dist/polyfills/index.js +155 -9
  54. package/dist/polyfills/web3-polyfills.d.ts +7 -0
  55. package/dist/polyfills/web3-polyfills.d.ts.map +1 -0
  56. package/dist/polyfills/web3-polyfills.js +85 -0
  57. package/dist/providers/PersSDKProvider.d.ts +28 -18
  58. package/dist/providers/PersSDKProvider.d.ts.map +1 -1
  59. package/dist/providers/PersSDKProvider.js +63 -129
  60. package/dist/providers/react-native-auth-provider.d.ts +19 -64
  61. package/dist/providers/react-native-auth-provider.d.ts.map +1 -1
  62. package/dist/providers/react-native-auth-provider.js +57 -175
  63. package/package.json +171 -157
  64. package/src/hooks/index.ts +11 -1
  65. package/src/hooks/useAnalytics.ts +150 -0
  66. package/src/hooks/useAuth.ts +286 -27
  67. package/src/hooks/useBusiness.ts +193 -30
  68. package/src/hooks/useCampaigns.ts +121 -43
  69. package/src/hooks/useDonations.ts +68 -0
  70. package/src/hooks/useFiles.ts +160 -0
  71. package/src/hooks/usePurchases.ts +69 -0
  72. package/src/hooks/useRedemptions.ts +109 -68
  73. package/src/hooks/useTenants.ts +77 -0
  74. package/src/hooks/useTokens.ts +189 -21
  75. package/src/hooks/useTransactions.ts +170 -34
  76. package/src/hooks/useUserStatus.ts +65 -0
  77. package/src/hooks/useUsers.ts +133 -0
  78. package/src/hooks/useWeb3.ts +201 -21
  79. package/src/index.ts +21 -17
  80. package/src/polyfills/index.ts +163 -10
  81. package/src/polyfills/web3-polyfills.ts +98 -0
  82. package/src/providers/PersSDKProvider.tsx +114 -178
  83. package/src/providers/react-native-auth-provider.ts +65 -208
  84. package/dist/index.esm.js +0 -1057
  85. package/dist/index.esm.js.map +0 -1
  86. package/dist/polyfills/index.simple.d.ts +0 -2
  87. package/dist/polyfills/index.simple.d.ts.map +0 -1
  88. package/dist/polyfills/index.simple.js +0 -17
  89. package/src/polyfills/index.simple.ts +0 -22
  90. package/src/types/external-modules.d.ts +0 -13
package/README.md CHANGED
@@ -1,200 +1,353 @@
1
- # PERS SDK - React Native
1
+ # PERS SDK React Native
2
2
 
3
- React Native SDK for PERS Platform - Tourism Loyalty System. This package provides React Native-specific implementations of authentication providers and HTTP clients that integrate seamlessly with the PERS SDK.
3
+ A comprehensive React Native SDK for the PERS (Personal Engagement & Reward System) platform, designed specifically for tourism loyalty applications with modern manager pattern architecture.
4
4
 
5
5
  ## Features
6
6
 
7
- - 🔐 **Multiple Storage Strategies**: AsyncStorage, Keychain, or Memory
8
- - 🛡️ **Security-First**: Configurable security levels per token type
9
- - 📱 **Cross-Platform**: iOS, Android, and Web support
10
- - 🎯 **Blueprint Ready**: Serves as blueprint for native iOS/Android implementations
11
- - 🔧 **Flexible Configuration**: Customizable storage and security options
12
- - 📦 **TypeScript**: Full type safety and IntelliSense support
7
+ - **🏗️ Modern Manager Pattern**: Clean, intuitive high-level APIs through domain managers
8
+ - **🔐 Authentication Management**: Complete user authentication flow with secure providers
9
+ - **💰 Token Operations**: Balance checking, transfers, and comprehensive token management
10
+ - **📊 Transaction History**: Complete transaction tracking and analytics
11
+ - **🏢 Business Integration**: Business data, types, and operations management
12
+ - **🎯 Campaign Management**: Marketing campaigns, claims, and promotions
13
+ - **🎁 Redemption System**: Comprehensive reward redemption functionality
14
+ - **💳 Purchase Processing**: Payment intents, purchases, and transaction handling
15
+ - **🏢 Tenant Management**: Multi-tenant configuration and admin operations
16
+ - **📈 Analytics**: Transaction analytics and reporting capabilities
17
+ - **💝 Donations**: Donation type and management system
18
+ - **👥 User Management**: User profiles, public data, and admin operations
19
+ - **🌐 Web3 Integration**: Blockchain operations and wallet management
20
+ - **🔒 Secure Storage**: Multiple storage strategies for different security needs
21
+ - **📱 Cross-Platform**: Full React Native support with optimized performance
13
22
 
14
23
  ## Installation
15
24
 
16
25
  ```bash
17
- npm install @explorins/pers-sdk-react-native @explorins/pers-sdk @react-native-async-storage/async-storage
26
+ npm install @explorins/pers-sdk-react-native
18
27
  ```
19
28
 
20
- ### Optional Dependencies
29
+ ### Required Dependencies
30
+
31
+ The SDK requires AsyncStorage for persistence:
21
32
 
22
- For enhanced security (Keychain storage):
23
33
  ```bash
24
- npm install react-native-keychain
34
+ npm install @react-native-async-storage/async-storage
25
35
  ```
26
36
 
27
- ## Quick Start
37
+ ### Optional Dependencies
28
38
 
29
- ### Basic Usage
39
+ For additional functionality, install these optional packages:
30
40
 
31
- ```typescript
32
- import {
33
- PersApiClient,
34
- SimpleReactNativeAuthProvider,
35
- ReactNativeHttpClient
36
- } from '@explorins/pers-sdk-react-native';
41
+ ```bash
42
+ # For secure keychain storage (iOS/Android)
43
+ npm install react-native-keychain
37
44
 
38
- // Create HTTP client
39
- const httpClient = new ReactNativeHttpClient();
45
+ # For crypto polyfills (recommended for Web3 features)
46
+ npm install react-native-get-random-values
40
47
 
41
- // Create auth provider
42
- const authProvider = new SimpleReactNativeAuthProvider('your-project-key');
48
+ # For URL polyfills (if needed)
49
+ npm install react-native-url-polyfill
43
50
 
44
- // Create API client
45
- const apiClient = new PersApiClient(httpClient, {
46
- environment: 'staging',
47
- apiVersion: 'v2',
48
- apiProjectKey: 'your-project-key',
49
- authProvider: authProvider,
50
- });
51
+ # For global polyfills (if needed)
52
+ npm install react-native-polyfill-globals
51
53
 
52
- // Login and store tokens automatically
53
- const result = await apiClient.loginUser('your-jwt-token');
54
- console.log('Logged in:', result.user);
54
+ # For stream polyfills (if needed)
55
+ npm install web-streams-polyfill
55
56
  ```
56
57
 
57
- ### Secure Usage (with Keychain)
58
+ ## Quick Start
58
59
 
59
- ```typescript
60
- import {
61
- SecureReactNativeAuthProvider,
62
- StorageStrategy
63
- } from '@explorins/pers-sdk-react-native';
60
+ ### 1. Setup the Provider
64
61
 
65
- // Maximum security - all tokens in Keychain
66
- const authProvider = new SecureReactNativeAuthProvider('your-project-key', {
67
- debug: true // Enable debug logging
68
- });
62
+ Wrap your app with the `PersSDKProvider`:
63
+
64
+ ```typescript
65
+ import React from 'react';
66
+ import { PersSDKProvider } from '@explorins/pers-sdk-react-native';
67
+
68
+ export default function App() {
69
+ return (
70
+ <PersSDKProvider>
71
+ {/* Your app components */}
72
+ </PersSDKProvider>
73
+ );
74
+ }
69
75
  ```
70
76
 
71
- ### Custom Configuration
77
+ ### 2. Initialize the SDK
72
78
 
73
79
  ```typescript
74
- import {
75
- BaseReactNativeAuthProvider,
76
- StorageStrategy
77
- } from '@explorins/pers-sdk-react-native';
80
+ import { useAuth } from '@explorins/pers-sdk-react-native';
78
81
 
79
- class CustomAuthProvider extends BaseReactNativeAuthProvider {
80
- readonly authType = 'user' as const;
82
+ function InitializeSDK() {
83
+ const { initialize, isInitialized } = useAuth();
81
84
 
82
- constructor(projectKey: string) {
83
- super(projectKey, {
84
- accessTokenStrategy: StorageStrategy.ASYNC_STORAGE,
85
- refreshTokenStrategy: StorageStrategy.KEYCHAIN,
86
- keyPrefix: 'myapp',
87
- debug: __DEV__
85
+ useEffect(() => {
86
+ initialize({
87
+ apiProjectKey: 'your-project-key',
88
+ environment: 'production', // or 'development', 'staging'
88
89
  });
89
- }
90
+ }, []);
90
91
 
91
- async getProjectKey(): Promise<string | null> {
92
- return 'your-project-key';
92
+ if (!isInitialized) {
93
+ return <Text>Initializing...</Text>;
93
94
  }
94
95
 
95
- async onTokenExpired(): Promise<void> {
96
- // Implement token refresh logic
97
- console.log('Token expired - implement refresh');
98
- }
96
+ return <YourMainComponent />;
99
97
  }
100
98
  ```
101
99
 
102
- ## Storage Strategies
100
+ ### 3. Authentication
103
101
 
104
- ### AsyncStorage (Default)
105
- - **Use Case**: General app data, user preferences
106
- - **Security**: Basic - data is stored unencrypted locally
107
- - **Availability**: Always available on React Native
102
+ ```typescript
103
+ import { useAuth } from '@explorins/pers-sdk-react-native';
104
+
105
+ function LoginComponent() {
106
+ const { login, isAuthenticated, user } = useAuth();
107
+
108
+ const handleLogin = async () => {
109
+ try {
110
+ await login('your-jwt-token');
111
+ console.log('Login successful');
112
+ } catch (error) {
113
+ console.error('Login failed:', error);
114
+ }
115
+ };
116
+
117
+ return (
118
+ <View>
119
+ {isAuthenticated ? (
120
+ <Text>Welcome, {user?.name}</Text>
121
+ ) : (
122
+ <Button title="Login" onPress={handleLogin} />
123
+ )}
124
+ </View>
125
+ );
126
+ }
127
+ ```
128
+
129
+ ## Authentication Providers
108
130
 
109
- ### Keychain (Recommended for Tokens)
110
- - **Use Case**: Sensitive data like JWT tokens
111
- - **Security**: High - uses iOS Keychain / Android Keystore
112
- - **Availability**: Requires `react-native-keychain` package
131
+ The SDK provides multiple authentication providers for different security needs:
132
+
133
+ ### BaseReactNativeAuthProvider
134
+ Base class for all React Native authentication providers.
113
135
 
114
- ### Memory
115
- - **Use Case**: Temporary data, development, fallback
116
- - **Security**: High - data cleared on app termination
117
- - **Availability**: Always available
136
+ ### ReactNativeAuthProvider
137
+ Standard authentication with AsyncStorage for persistence.
138
+
139
+ ```typescript
140
+ import { ReactNativeAuthProvider } from '@explorins/pers-sdk-react-native';
141
+
142
+ const authProvider = new ReactNativeAuthProvider('your-project-key');
143
+ ```
144
+
145
+ ### SecureReactNativeAuthProvider
146
+ Secure keychain storage for sensitive data.
147
+
148
+ ```typescript
149
+ import { SecureReactNativeAuthProvider } from '@explorins/pers-sdk-react-native';
150
+
151
+ const authProvider = new SecureReactNativeAuthProvider('your-project-key');
152
+ ```
118
153
 
119
154
  ## API Reference
120
155
 
121
- ### SimpleReactNativeAuthProvider
156
+ ### Available Hooks
157
+
158
+ The SDK provides comprehensive hooks for all PERS platform functionality through modern manager pattern:
122
159
 
123
- Ready-to-use provider with sensible defaults:
124
- - Access tokens: AsyncStorage
125
- - Refresh tokens: Keychain (fallback to AsyncStorage)
160
+ #### Core Hooks
161
+ - **useAuth()** - Authentication state and operations (login, logout, user management)
162
+ - **useUsers()** - User profile management and public user data
163
+ - **useTokens()** - Token operations, balances, and credit/reward tokens
164
+
165
+ #### Business Logic Hooks
166
+ - **useBusiness()** - Business data, types, and operations management
167
+ - **useCampaigns()** - Marketing campaigns, claims, and promotions
168
+ - **useRedemptions()** - Reward redemption functionality and user redemptions
169
+ - **useTransactions()** - Transaction history, creation, and analytics
170
+
171
+ #### Platform Integration Hooks
172
+ - **usePurchases()** - Payment intents, purchase tokens, and purchase processing
173
+ - **useTenants()** - Multi-tenant configuration and admin operations
174
+ - **useWeb3()** - Web3 and blockchain functionality
175
+
176
+ ### Hook Examples
177
+
178
+ #### useAuth()
179
+
180
+ Handles authentication state and operations.
126
181
 
127
182
  ```typescript
128
- const authProvider = new SimpleReactNativeAuthProvider(projectKey, {
129
- debug: true,
130
- keyPrefix: 'custom_prefix'
131
- });
183
+ const {
184
+ isInitialized,
185
+ isAuthenticated,
186
+ user,
187
+ accountAddress,
188
+ login,
189
+ loginWithRawData,
190
+ logout
191
+ } = useAuth();
132
192
  ```
133
193
 
134
- ### SecureReactNativeAuthProvider
194
+ ### Storage Strategies
135
195
 
136
- Maximum security provider:
137
- - All tokens: Keychain storage
138
- - Automatic fallback to AsyncStorage if Keychain unavailable
196
+ Configure different storage strategies based on your security requirements:
139
197
 
140
198
  ```typescript
141
- const authProvider = new SecureReactNativeAuthProvider(projectKey);
199
+ // Available strategies from the auth providers:
200
+ // ASYNC_STORAGE - Default AsyncStorage
201
+ // KEYCHAIN - Secure keychain storage
202
+ // MEMORY - Memory-only (not persistent)
142
203
  ```
143
204
 
144
- ### BaseReactNativeAuthProvider
205
+ ## Advanced Usage
145
206
 
146
- Extendable base class for custom implementations:
207
+ ### Custom HTTP Client
147
208
 
148
209
  ```typescript
149
- class MyAuthProvider extends BaseReactNativeAuthProvider {
150
- // Implement required methods
210
+ import { ReactNativeHttpClient } from '@explorins/pers-sdk-react-native';
211
+
212
+ const httpClient = new ReactNativeHttpClient();
213
+ ```
214
+
215
+ ### Direct SDK Access
216
+
217
+ If you need direct access to individual SDKs:
218
+
219
+ ```typescript
220
+ import { usePersSDK } from '@explorins/pers-sdk-react-native';
221
+
222
+ function MyComponent() {
223
+ const { tokens, transactions, business, campaigns, redemptions, web3 } = usePersSDK();
224
+
225
+ // Direct SDK usage available through the provider
151
226
  }
152
227
  ```
153
228
 
154
- ## Integration with PERS SDK
229
+ ### Using Core SDK Components
230
+
231
+ For advanced usage, you can import components from the core SDK:
232
+
233
+ ```typescript
234
+ import { PersApiClient } from '@explorins/pers-sdk/core';
235
+ import { ReactNativeHttpClient } from '@explorins/pers-sdk-react-native';
236
+
237
+ const httpClient = new ReactNativeHttpClient();
238
+ const apiClient = new PersApiClient('your-project-key', httpClient);
239
+ ```
240
+
241
+ ## Error Handling
155
242
 
156
- This package works seamlessly with all PERS SDK features:
243
+ ```typescript
244
+ import { useAuth } from '@explorins/pers-sdk-react-native';
245
+
246
+ function MyComponent() {
247
+ const { login } = useAuth();
248
+
249
+ const handleLogin = async () => {
250
+ try {
251
+ await login('jwt-token');
252
+ } catch (error) {
253
+ if (error.code === 'INVALID_TOKEN') {
254
+ // Handle invalid token
255
+ } else if (error.code === 'NETWORK_ERROR') {
256
+ // Handle network issues
257
+ } else {
258
+ // Handle other errors
259
+ }
260
+ }
261
+ };
262
+ }
263
+ ```
264
+
265
+ ## Environment Configuration
157
266
 
158
267
  ```typescript
159
- import {
160
- createWeb3SDK,
161
- createBusinessSDK,
162
- TokenSDK
163
- } from '@explorins/pers-sdk-react-native';
268
+ const config = {
269
+ apiProjectKey: 'your-project-key',
270
+ environment: 'production', // 'development' | 'staging' | 'production'
271
+ timeout: 30000, // Request timeout in milliseconds
272
+ };
164
273
 
165
- // All SDK features are available
166
- const web3SDK = createWeb3SDK(apiClient);
167
- const tokenSDK = new TokenSDK(apiClient);
168
- const businessSDK = createBusinessSDK(apiClient);
274
+ await initialize(config);
169
275
  ```
170
276
 
171
- ## Native Implementation Blueprint
277
+ ## TypeScript Support
172
278
 
173
- This React Native SDK serves as a blueprint for native iOS and Android implementations:
279
+ The SDK is fully typed and provides comprehensive TypeScript support. Import types as needed for your implementation.
174
280
 
175
- ### iOS Blueprint
176
- - AsyncStorage → NSUserDefaults
177
- - Keychain → iOS Keychain Services
178
- - HTTP Client → NSURLSession
281
+ #### useTokens()
179
282
 
180
- ### Android Blueprint
181
- - AsyncStorage → SharedPreferences
182
- - Keychain → Android Keystore
183
- - HTTP Client → OkHttp/Retrofit
283
+ Manage token operations and balances.
184
284
 
185
- ## Development
285
+ ```typescript
286
+ const { getTokens, getActiveCreditToken, getRewardTokens } = useTokens();
186
287
 
187
- ```bash
188
- # Install dependencies
189
- npm install
288
+ // Get all tokens
289
+ const tokens = await getTokens();
290
+
291
+ // Get active credit token
292
+ const creditToken = await getActiveCreditToken();
293
+
294
+ // Get reward tokens
295
+ const rewardTokens = await getRewardTokens();
296
+ ```
297
+
298
+ #### usePayments()
190
299
 
191
- # Build the package
192
- npm run build
300
+ Handle payment processing and purchase tokens.
193
301
 
194
- # Watch mode for development
195
- npm run dev
302
+ ```typescript
303
+ const { createPaymentIntent, getActivePurchaseTokens, getAllUserPurchases } = usePayments();
304
+
305
+ // Create payment intent
306
+ const paymentIntent = await createPaymentIntent(100, 'usd', 'user@example.com', 'Token purchase');
307
+
308
+ // Get purchase tokens
309
+ const purchaseTokens = await getActivePurchaseTokens();
310
+
311
+ // Get user purchase history
312
+ const userPurchases = await getAllUserPurchases();
313
+ ```
314
+
315
+ #### useTenants()
316
+
317
+ Multi-tenant configuration and management.
318
+
319
+ ```typescript
320
+ const { getTenantInfo, getClientConfig, getAdmins } = useTenants();
321
+
322
+ // Get tenant configuration
323
+ const tenantInfo = await getTenantInfo();
324
+
325
+ // Get client configuration
326
+ const clientConfig = await getClientConfig();
327
+
328
+ // Get tenant admins (admin only)
329
+ const admins = await getAdmins();
196
330
  ```
197
331
 
332
+ ## Troubleshooting
333
+
334
+ ### Metro Configuration
335
+
336
+ If you encounter bundling issues, add polyfill configurations to your `metro.config.js` as needed.
337
+
338
+ ### Polyfill Setup
339
+
340
+ Add to your root index file:
341
+
342
+ ```typescript
343
+ import 'react-native-get-random-values';
344
+ import 'react-native-url-polyfill/auto';
345
+ ```
346
+
347
+ ## Contributing
348
+
349
+ Please read our contributing guidelines before submitting pull requests.
350
+
198
351
  ## License
199
352
 
200
353
  MIT License - see LICENSE file for details.
@@ -5,4 +5,12 @@ export { useBusiness } from './useBusiness';
5
5
  export { useCampaigns } from './useCampaigns';
6
6
  export { useRedemptions } from './useRedemptions';
7
7
  export { useWeb3 } from './useWeb3';
8
+ export { usePurchases } from './usePurchases';
9
+ export { useTenants } from './useTenants';
10
+ export { useUsers } from './useUsers';
11
+ export { useUserStatus } from './useUserStatus';
12
+ export { useFiles } from './useFiles';
13
+ export { useAnalytics } from './useAnalytics';
14
+ export { useDonations } from './useDonations';
15
+ export type { RawUserData } from './useAuth';
8
16
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC"}
@@ -6,3 +6,10 @@ export { useBusiness } from './useBusiness';
6
6
  export { useCampaigns } from './useCampaigns';
7
7
  export { useRedemptions } from './useRedemptions';
8
8
  export { useWeb3 } from './useWeb3';
9
+ export { usePurchases } from './usePurchases';
10
+ export { useTenants } from './useTenants';
11
+ export { useUsers } from './useUsers';
12
+ export { useUserStatus } from './useUserStatus';
13
+ export { useFiles } from './useFiles';
14
+ export { useAnalytics } from './useAnalytics';
15
+ export { useDonations } from './useDonations';
@@ -0,0 +1,96 @@
1
+ interface TransactionAnalyticsFilters {
2
+ status?: string;
3
+ tokenType?: string;
4
+ triggerProcessType?: string;
5
+ tenantId?: string;
6
+ chainId?: number;
7
+ type?: string;
8
+ [key: string]: any;
9
+ }
10
+ type TransactionAnalyticsGroupBy = 'month' | 'week' | 'day' | 'year' | 'quarter' | 'tokenType' | 'status' | 'chainId' | 'triggerProcessType' | 'type' | 'senderAddress' | 'recipientAddress' | 'senderId' | 'recipientId' | 'senderOwnerType' | 'recipientOwnerType' | 'createdAt';
11
+ type TransactionAnalyticsMetric = 'count' | 'sum' | 'avg' | 'min' | 'max';
12
+ interface TransactionAnalyticsGroupByExpression {
13
+ expression: string;
14
+ alias: string;
15
+ }
16
+ /**
17
+ * Request DTO for transaction analytics
18
+ */
19
+ interface TransactionAnalyticsRequestDTO {
20
+ filters?: TransactionAnalyticsFilters;
21
+ groupBy?: TransactionAnalyticsGroupBy[];
22
+ groupByExpressions?: TransactionAnalyticsGroupByExpression[];
23
+ metrics?: TransactionAnalyticsMetric[];
24
+ orderBy?: string;
25
+ orderDirection?: 'ASC' | 'DESC';
26
+ limit?: number;
27
+ startDate?: string;
28
+ endDate?: string;
29
+ }
30
+ interface TransactionAnalyticsResultItem {
31
+ [key: string]: string | number | Date | undefined;
32
+ count?: string;
33
+ sum?: number;
34
+ avg?: number;
35
+ min?: number;
36
+ max?: number;
37
+ tokentype?: string;
38
+ tokenType?: string;
39
+ year?: string;
40
+ month?: string;
41
+ type?: string;
42
+ senderaddress?: string;
43
+ senderAddress?: string;
44
+ recipientaddress?: string;
45
+ recipientAddress?: string;
46
+ triggerprocesstype?: string;
47
+ triggerProcessType?: string;
48
+ userid?: string;
49
+ userId?: string;
50
+ }
51
+ /**
52
+ * Response DTO for transaction analytics
53
+ */
54
+ interface TransactionAnalyticsResponseDTO {
55
+ results: TransactionAnalyticsResultItem[];
56
+ totalGroups: number;
57
+ metadata: {
58
+ executionTime: string;
59
+ };
60
+ }
61
+ /**
62
+ * React hook for analytics operations in the PERS SDK
63
+ *
64
+ * Provides methods for retrieving transaction analytics and insights.
65
+ * Supports various analytics queries for business intelligence and reporting.
66
+ *
67
+ * @returns Analytics hook with methods for data analysis
68
+ *
69
+ * @example
70
+ * ```typescript
71
+ * function AnalyticsComponent() {
72
+ * const { getTransactionAnalytics } = useAnalytics();
73
+ *
74
+ * const loadAnalytics = async () => {
75
+ * try {
76
+ * const analytics = await getTransactionAnalytics({
77
+ * timeRange: 'last_30_days',
78
+ * groupBy: 'day'
79
+ * });
80
+ * console.log('Transaction analytics:', analytics);
81
+ * } catch (error) {
82
+ * console.error('Failed to load analytics:', error);
83
+ * }
84
+ * };
85
+ *
86
+ * return <button onClick={loadAnalytics}>Load Analytics</button>;
87
+ * }
88
+ * ```
89
+ */
90
+ export declare const useAnalytics: () => {
91
+ getTransactionAnalytics: (request: TransactionAnalyticsRequestDTO) => Promise<TransactionAnalyticsResponseDTO>;
92
+ isAvailable: boolean;
93
+ };
94
+ export type AnalyticsHook = ReturnType<typeof useAnalytics>;
95
+ export {};
96
+ //# sourceMappingURL=useAnalytics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAnalytics.d.ts","sourceRoot":"","sources":["../../src/hooks/useAnalytics.ts"],"names":[],"mappings":"AAIA,UAAU,2BAA2B;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,KAAK,2BAA2B,GAC5B,OAAO,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,SAAS,GAC7C,WAAW,GAAG,QAAQ,GAAG,SAAS,GA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