@explorins/pers-sdk-react-native 1.3.2 → 1.5.2
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.
- package/README.md +276 -123
- package/dist/hooks/index.d.ts +10 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +8 -0
- package/dist/hooks/useAnalytics.d.ts +96 -0
- package/dist/hooks/useAnalytics.d.ts.map +1 -0
- package/dist/hooks/useAnalytics.js +73 -0
- package/dist/hooks/useAuth.d.ts +52 -7
- package/dist/hooks/useAuth.d.ts.map +1 -1
- package/dist/hooks/useAuth.js +250 -3
- package/dist/hooks/useBusiness.d.ts +45 -3
- package/dist/hooks/useBusiness.d.ts.map +1 -1
- package/dist/hooks/useBusiness.js +182 -28
- package/dist/hooks/useCampaigns.d.ts +11 -4
- package/dist/hooks/useCampaigns.d.ts.map +1 -1
- package/dist/hooks/useCampaigns.js +101 -39
- package/dist/hooks/useDonations.d.ts +33 -0
- package/dist/hooks/useDonations.d.ts.map +1 -0
- package/dist/hooks/useDonations.js +62 -0
- package/dist/hooks/useFiles.d.ts +50 -0
- package/dist/hooks/useFiles.d.ts.map +1 -0
- package/dist/hooks/useFiles.js +140 -0
- package/dist/hooks/usePurchases.d.ts +9 -0
- package/dist/hooks/usePurchases.d.ts.map +1 -0
- package/dist/hooks/usePurchases.js +56 -0
- package/dist/hooks/useRedemptions.d.ts +10 -5
- package/dist/hooks/useRedemptions.d.ts.map +1 -1
- package/dist/hooks/useRedemptions.js +118 -66
- package/dist/hooks/useTenants.d.ts +10 -0
- package/dist/hooks/useTenants.d.ts.map +1 -0
- package/dist/hooks/useTenants.js +68 -0
- package/dist/hooks/useTokens.d.ts +36 -2
- package/dist/hooks/useTokens.d.ts.map +1 -1
- package/dist/hooks/useTokens.js +180 -19
- package/dist/hooks/useTransactionSigner.d.ts +73 -0
- package/dist/hooks/useTransactionSigner.d.ts.map +1 -0
- package/dist/hooks/useTransactionSigner.js +216 -0
- package/dist/hooks/useTransactions.d.ts +45 -3
- package/dist/hooks/useTransactions.d.ts.map +1 -1
- package/dist/hooks/useTransactions.js +149 -39
- package/dist/hooks/useUserStatus.d.ts +9 -0
- package/dist/hooks/useUserStatus.d.ts.map +1 -0
- package/dist/hooks/useUserStatus.js +57 -0
- package/dist/hooks/useUsers.d.ts +17 -0
- package/dist/hooks/useUsers.d.ts.map +1 -0
- package/dist/hooks/useUsers.js +120 -0
- package/dist/hooks/useWeb3.d.ts +69 -6
- package/dist/hooks/useWeb3.d.ts.map +1 -1
- package/dist/hooks/useWeb3.js +177 -17
- package/dist/index.d.ts +6 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +31540 -794
- package/dist/index.js.map +1 -1
- package/dist/polyfills/index.d.ts +1 -1
- package/dist/polyfills/index.d.ts.map +1 -1
- package/dist/polyfills/index.js +155 -9
- package/dist/polyfills/web3-polyfills.d.ts +7 -0
- package/dist/polyfills/web3-polyfills.d.ts.map +1 -0
- package/dist/polyfills/web3-polyfills.js +85 -0
- package/dist/providers/PersSDKProvider.d.ts +28 -18
- package/dist/providers/PersSDKProvider.d.ts.map +1 -1
- package/dist/providers/PersSDKProvider.js +63 -129
- package/dist/providers/react-native-auth-provider.d.ts +19 -64
- package/dist/providers/react-native-auth-provider.d.ts.map +1 -1
- package/dist/providers/react-native-auth-provider.js +57 -175
- package/package.json +177 -157
- package/src/hooks/index.ts +13 -1
- package/src/hooks/useAnalytics.ts +150 -0
- package/src/hooks/useAuth.ts +286 -27
- package/src/hooks/useBusiness.ts +193 -30
- package/src/hooks/useCampaigns.ts +121 -43
- package/src/hooks/useDonations.ts +68 -0
- package/src/hooks/useFiles.ts +160 -0
- package/src/hooks/usePurchases.ts +69 -0
- package/src/hooks/useRedemptions.ts +135 -68
- package/src/hooks/useTenants.ts +77 -0
- package/src/hooks/useTokens.ts +189 -21
- package/src/hooks/useTransactionSigner.ts +287 -0
- package/src/hooks/useTransactions.ts +163 -41
- package/src/hooks/useUserStatus.ts +65 -0
- package/src/hooks/useUsers.ts +133 -0
- package/src/hooks/useWeb3.ts +201 -21
- package/src/index.ts +22 -17
- package/src/polyfills/index.ts +163 -10
- package/src/polyfills/web3-polyfills.ts +98 -0
- package/src/providers/PersSDKProvider.tsx +114 -178
- package/src/providers/react-native-auth-provider.ts +65 -208
- package/dist/index.esm.js +0 -1057
- package/dist/index.esm.js.map +0 -1
- package/dist/polyfills/index.simple.d.ts +0 -2
- package/dist/polyfills/index.simple.d.ts.map +0 -1
- package/dist/polyfills/index.simple.js +0 -17
- package/src/polyfills/index.simple.ts +0 -22
- package/src/types/external-modules.d.ts +0 -13
package/README.md
CHANGED
|
@@ -1,200 +1,353 @@
|
|
|
1
|
-
# PERS SDK
|
|
1
|
+
# PERS SDK React Native
|
|
2
2
|
|
|
3
|
-
React Native SDK for PERS
|
|
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
|
-
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
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
|
|
26
|
+
npm install @explorins/pers-sdk-react-native
|
|
18
27
|
```
|
|
19
28
|
|
|
20
|
-
###
|
|
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-
|
|
34
|
+
npm install @react-native-async-storage/async-storage
|
|
25
35
|
```
|
|
26
36
|
|
|
27
|
-
|
|
37
|
+
### Optional Dependencies
|
|
28
38
|
|
|
29
|
-
|
|
39
|
+
For additional functionality, install these optional packages:
|
|
30
40
|
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
|
|
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
|
-
|
|
39
|
-
|
|
45
|
+
# For crypto polyfills (recommended for Web3 features)
|
|
46
|
+
npm install react-native-get-random-values
|
|
40
47
|
|
|
41
|
-
|
|
42
|
-
|
|
48
|
+
# For URL polyfills (if needed)
|
|
49
|
+
npm install react-native-url-polyfill
|
|
43
50
|
|
|
44
|
-
|
|
45
|
-
|
|
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
|
-
|
|
53
|
-
|
|
54
|
-
console.log('Logged in:', result.user);
|
|
54
|
+
# For stream polyfills (if needed)
|
|
55
|
+
npm install web-streams-polyfill
|
|
55
56
|
```
|
|
56
57
|
|
|
57
|
-
|
|
58
|
+
## Quick Start
|
|
58
59
|
|
|
59
|
-
|
|
60
|
-
import {
|
|
61
|
-
SecureReactNativeAuthProvider,
|
|
62
|
-
StorageStrategy
|
|
63
|
-
} from '@explorins/pers-sdk-react-native';
|
|
60
|
+
### 1. Setup the Provider
|
|
64
61
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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
|
-
###
|
|
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
|
-
|
|
80
|
-
|
|
82
|
+
function InitializeSDK() {
|
|
83
|
+
const { initialize, isInitialized } = useAuth();
|
|
81
84
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
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
|
-
|
|
92
|
-
return
|
|
92
|
+
if (!isInitialized) {
|
|
93
|
+
return <Text>Initializing...</Text>;
|
|
93
94
|
}
|
|
94
95
|
|
|
95
|
-
|
|
96
|
-
// Implement token refresh logic
|
|
97
|
-
console.log('Token expired - implement refresh');
|
|
98
|
-
}
|
|
96
|
+
return <YourMainComponent />;
|
|
99
97
|
}
|
|
100
98
|
```
|
|
101
99
|
|
|
102
|
-
|
|
100
|
+
### 3. Authentication
|
|
103
101
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
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
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
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
|
-
###
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
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
|
-
###
|
|
156
|
+
### Available Hooks
|
|
157
|
+
|
|
158
|
+
The SDK provides comprehensive hooks for all PERS platform functionality through modern manager pattern:
|
|
122
159
|
|
|
123
|
-
|
|
124
|
-
-
|
|
125
|
-
-
|
|
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
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
183
|
+
const {
|
|
184
|
+
isInitialized,
|
|
185
|
+
isAuthenticated,
|
|
186
|
+
user,
|
|
187
|
+
accountAddress,
|
|
188
|
+
login,
|
|
189
|
+
loginWithRawData,
|
|
190
|
+
logout
|
|
191
|
+
} = useAuth();
|
|
132
192
|
```
|
|
133
193
|
|
|
134
|
-
###
|
|
194
|
+
### Storage Strategies
|
|
135
195
|
|
|
136
|
-
|
|
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
|
-
|
|
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
|
-
|
|
205
|
+
## Advanced Usage
|
|
145
206
|
|
|
146
|
-
|
|
207
|
+
### Custom HTTP Client
|
|
147
208
|
|
|
148
209
|
```typescript
|
|
149
|
-
|
|
150
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
}
|
|
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
|
-
|
|
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
|
-
##
|
|
277
|
+
## TypeScript Support
|
|
172
278
|
|
|
173
|
-
|
|
279
|
+
The SDK is fully typed and provides comprehensive TypeScript support. Import types as needed for your implementation.
|
|
174
280
|
|
|
175
|
-
|
|
176
|
-
- AsyncStorage → NSUserDefaults
|
|
177
|
-
- Keychain → iOS Keychain Services
|
|
178
|
-
- HTTP Client → NSURLSession
|
|
281
|
+
#### useTokens()
|
|
179
282
|
|
|
180
|
-
|
|
181
|
-
- AsyncStorage → SharedPreferences
|
|
182
|
-
- Keychain → Android Keystore
|
|
183
|
-
- HTTP Client → OkHttp/Retrofit
|
|
283
|
+
Manage token operations and balances.
|
|
184
284
|
|
|
185
|
-
|
|
285
|
+
```typescript
|
|
286
|
+
const { getTokens, getActiveCreditToken, getRewardTokens } = useTokens();
|
|
186
287
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
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
|
-
|
|
192
|
-
npm run build
|
|
300
|
+
Handle payment processing and purchase tokens.
|
|
193
301
|
|
|
194
|
-
|
|
195
|
-
|
|
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.
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
export { useAuth } from './useAuth';
|
|
2
2
|
export { useTokens } from './useTokens';
|
|
3
3
|
export { useTransactions } from './useTransactions';
|
|
4
|
+
export { useTransactionSigner } from './useTransactionSigner';
|
|
4
5
|
export { useBusiness } from './useBusiness';
|
|
5
6
|
export { useCampaigns } from './useCampaigns';
|
|
6
7
|
export { useRedemptions } from './useRedemptions';
|
|
7
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';
|
|
16
|
+
export type { RawUserData } from './useAuth';
|
|
17
|
+
export type { TransactionSignerHook, TransactionSigningResult } from './useTransactionSigner';
|
|
8
18
|
//# 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,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,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;AAC7C,YAAY,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC"}
|
package/dist/hooks/index.js
CHANGED
|
@@ -2,7 +2,15 @@
|
|
|
2
2
|
export { useAuth } from './useAuth';
|
|
3
3
|
export { useTokens } from './useTokens';
|
|
4
4
|
export { useTransactions } from './useTransactions';
|
|
5
|
+
export { useTransactionSigner } from './useTransactionSigner';
|
|
5
6
|
export { useBusiness } from './useBusiness';
|
|
6
7
|
export { useCampaigns } from './useCampaigns';
|
|
7
8
|
export { useRedemptions } from './useRedemptions';
|
|
8
9
|
export { useWeb3 } from './useWeb3';
|
|
10
|
+
export { usePurchases } from './usePurchases';
|
|
11
|
+
export { useTenants } from './useTenants';
|
|
12
|
+
export { useUsers } from './useUsers';
|
|
13
|
+
export { useUserStatus } from './useUserStatus';
|
|
14
|
+
export { useFiles } from './useFiles';
|
|
15
|
+
export { useAnalytics } from './useAnalytics';
|
|
16
|
+
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,GAAG,oBAAoB,GAAG,MAAM,GAClE,eAAe,GAAG,kBAAkB,GAAG,UAAU,GAAG,aAAa,GAAG,iBAAiB,GAAG,oBAAoB,GAAG,WAAW,CAAC;AAE/H,KAAK,0BAA0B,GAC3B,OAAO,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;AAE5C,UAAU,qCAAqC;IAC7C,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,UAAU,8BAA8B;IACtC,OAAO,CAAC,EAAE,2BAA2B,CAAC;IACtC,OAAO,CAAC,EAAE,2BAA2B,EAAE,CAAC;IACxC,kBAAkB,CAAC,EAAE,qCAAqC,EAAE,CAAC;IAC7D,OAAO,CAAC,EAAE,0BAA0B,EAAE,CAAC;IACvC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,UAAU,8BAA8B;IACtC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAClD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,UAAU,+BAA+B;IACvC,OAAO,EAAE,8BAA8B,EAAE,CAAC;IAC1C,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE;QACR,aAAa,EAAE,MAAM,CAAC;KACvB,CAAC;CACH;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,YAAY;uCAwBqC,8BAA8B,KAAG,QAAQ,+BAA+B,CAAC;;CAmBtI,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC"}
|