@explorins/pers-sdk 1.3.4 → 1.3.6
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 +107 -339
- package/dist/business/index.d.ts +9 -9
- package/dist/campaign/index.d.ts +19 -19
- package/dist/chunks/{pers-sdk-Ct_uUMJl.cjs → pers-sdk-DiwCwBiC.cjs} +279 -4
- package/dist/chunks/pers-sdk-DiwCwBiC.cjs.map +1 -0
- package/dist/chunks/{pers-sdk-tKHGQr5x.js → pers-sdk-Rc8YKyNc.js} +279 -5
- package/dist/chunks/pers-sdk-Rc8YKyNc.js.map +1 -0
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core.cjs +2 -1
- package/dist/core.cjs.map +1 -1
- package/dist/core.js +1 -1
- package/dist/donation/index.d.ts +1 -1
- package/dist/index.cjs +3 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3 -6
- package/dist/index.js.map +1 -1
- package/dist/package.json +148 -147
- package/dist/payment/index.d.ts +6 -6
- package/dist/redemption/index.d.ts +10 -10
- package/dist/tenant/index.d.ts +4 -4
- package/dist/transaction/index.d.ts +4 -4
- package/dist/web3/application/web3-application.service.d.ts +3 -3
- package/dist/web3/application/web3-application.service.d.ts.map +1 -1
- package/dist/web3/domain/models/index.d.ts.map +1 -1
- package/dist/web3/domain/services/contract-domain.service.d.ts +2 -4
- package/dist/web3/domain/services/contract-domain.service.d.ts.map +1 -1
- package/dist/web3/domain/services/token-domain.service.d.ts +5 -5
- package/dist/web3/domain/services/token-domain.service.d.ts.map +1 -1
- package/dist/web3/index.d.ts +5 -5
- package/dist/web3/index.d.ts.map +1 -1
- package/dist/web3/infrastructure/api/web3-api.d.ts +4 -4
- package/dist/web3/infrastructure/api/web3-api.d.ts.map +1 -1
- package/dist/web3-chain/index.d.ts +3 -5
- package/dist/web3-chain/index.d.ts.map +1 -1
- package/dist/web3-chain/services/ethers-provider.service.d.ts +11 -0
- package/dist/web3-chain/services/ethers-provider.service.d.ts.map +1 -0
- package/dist/web3-chain/services/getWeb3FCD.service.d.ts +1 -1
- package/dist/web3-chain/services/getWeb3FCD.service.d.ts.map +1 -1
- package/dist/web3-chain/services/web3-chain-service.d.ts +7 -7
- package/dist/web3-chain/services/web3-chain-service.d.ts.map +1 -1
- package/dist/web3-chain/services/web3-provider.service.d.ts +1 -0
- package/dist/web3-chain/services/web3-provider.service.d.ts.map +1 -0
- package/dist/web3-chain.cjs +108 -231
- package/dist/web3-chain.cjs.map +1 -1
- package/dist/web3-chain.js +106 -228
- package/dist/web3-chain.js.map +1 -1
- package/dist/web3.cjs +19 -27
- package/dist/web3.cjs.map +1 -1
- package/dist/web3.js +17 -25
- package/dist/web3.js.map +1 -1
- package/package.json +148 -147
- package/dist/chunks/pers-sdk-Ct_uUMJl.cjs.map +0 -1
- package/dist/chunks/pers-sdk-tKHGQr5x.js.map +0 -1
- package/dist/web3-chain/services/provider.service.d.ts +0 -13
- package/dist/web3-chain/services/provider.service.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @explorins/pers-sdk
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://badge.fury.io/js/%40explorins%2Fpers-sdk)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
**Platform-agnostic TypeScript SDK for PERS (Phygital Experience Rewards System)** - Core SDK providing domain-driven business logic and API integration for tourism loyalty applications.
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
- **TypeScript Support**: Full type safety with comprehensive interfaces
|
|
11
|
-
- **Error Handling**: Robust error handling with retry mechanisms
|
|
12
|
-
- **Production Ready**: Optimized defaults for production environments
|
|
8
|
+
## PERS Ecosystem
|
|
9
|
+
|
|
10
|
+
PERS is a comprehensive tourism loyalty platform bridging physical and digital experiences through loyalty programs, campaign management, payments, blockchain integration, business management, and analytics.
|
|
13
11
|
|
|
14
12
|
## Installation
|
|
15
13
|
|
|
@@ -17,399 +15,169 @@ Platform-agnostic TypeScript SDK for the PERS (Phygital Experience Rewards Syste
|
|
|
17
15
|
npm install @explorins/pers-sdk
|
|
18
16
|
```
|
|
19
17
|
|
|
18
|
+
## Platform Integration
|
|
19
|
+
|
|
20
|
+
- **[@explorins/pers-sdk-angular](https://www.npmjs.com/package/@explorins/pers-sdk-angular)** - Angular dependency injection wrapper
|
|
21
|
+
- **[@explorins/pers-sdk-react-native](https://www.npmjs.com/package/@explorins/pers-sdk-react-native)** - React Native providers and hooks
|
|
22
|
+
- **Direct Integration** - Node.js, Vanilla JS, or custom frameworks
|
|
23
|
+
|
|
20
24
|
## Quick Start
|
|
21
25
|
|
|
22
26
|
### Basic Setup
|
|
23
27
|
|
|
24
28
|
```typescript
|
|
25
|
-
import {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
})
|
|
29
|
+
import { PersApiClient } from '@explorins/pers-sdk/core';
|
|
30
|
+
|
|
31
|
+
// Custom HTTP client (platform-specific)
|
|
32
|
+
const httpClient = {
|
|
33
|
+
get: async (url: string) => fetch(url).then(r => r.json()),
|
|
34
|
+
post: async (url: string, data: any) =>
|
|
35
|
+
fetch(url, { method: 'POST', body: JSON.stringify(data) }).then(r => r.json()),
|
|
36
|
+
put: async (url: string, data: any) =>
|
|
37
|
+
fetch(url, { method: 'PUT', body: JSON.stringify(data) }).then(r => r.json()),
|
|
38
|
+
delete: async (url: string) =>
|
|
39
|
+
fetch(url, { method: 'DELETE' }).then(r => r.json())
|
|
40
|
+
};
|
|
34
41
|
|
|
35
|
-
// Create
|
|
36
|
-
const
|
|
42
|
+
// Create API client
|
|
43
|
+
const apiClient = new PersApiClient(httpClient, {
|
|
37
44
|
environment: 'production',
|
|
38
|
-
|
|
39
|
-
|
|
45
|
+
apiVersion: 'v2',
|
|
46
|
+
apiProjectKey: 'your-project-key'
|
|
40
47
|
});
|
|
41
48
|
|
|
42
|
-
//
|
|
43
|
-
const
|
|
49
|
+
// Login with external JWT (Firebase, Auth0, etc.)
|
|
50
|
+
const result = await apiClient.loginUser(firebaseJWT);
|
|
44
51
|
```
|
|
45
52
|
|
|
46
|
-
###
|
|
47
|
-
|
|
48
|
-
#### User Authentication
|
|
53
|
+
### Platform Examples
|
|
49
54
|
|
|
50
|
-
|
|
51
|
-
// Login user with external JWT (Firebase, Auth0, etc.)
|
|
52
|
-
const firebaseToken = await getIdToken();
|
|
53
|
-
const session = await apiClient.loginUser(firebaseToken);
|
|
54
|
-
|
|
55
|
-
console.log('User authenticated:', session.user.email);
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
#### Admin Authentication
|
|
55
|
+
#### Angular
|
|
59
56
|
|
|
60
57
|
```typescript
|
|
61
|
-
|
|
62
|
-
const adminToken = await getAdminToken();
|
|
63
|
-
const session = await apiClient.loginAdmin(adminToken);
|
|
58
|
+
import { PERS_ANGULAR_SDK_SERVICE } from '@explorins/pers-sdk-angular';
|
|
64
59
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
### Making API Calls
|
|
60
|
+
@Injectable()
|
|
61
|
+
export class AuthService {
|
|
62
|
+
private persSDK = inject(PERS_ANGULAR_SDK_SERVICE);
|
|
69
63
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
const user = await apiClient.get<User>('/users/me');
|
|
75
|
-
|
|
76
|
-
// Download file
|
|
77
|
-
const csvData = await apiClient.get('/export/data.csv', 'blob');
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
#### POST Requests
|
|
81
|
-
|
|
82
|
-
```typescript
|
|
83
|
-
// Create resource
|
|
84
|
-
const newUser = await apiClient.post<User>('/users', {
|
|
85
|
-
name: 'John Doe',
|
|
86
|
-
email: 'john@example.com'
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
// Public endpoint (bypass auth)
|
|
90
|
-
const contact = await apiClient.post('/public/contact', formData, {
|
|
91
|
-
bypassAuth: true
|
|
92
|
-
});
|
|
64
|
+
async login(firebaseToken: string) {
|
|
65
|
+
return this.persSDK.api().loginUser(firebaseToken);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
93
68
|
```
|
|
94
69
|
|
|
95
|
-
####
|
|
96
|
-
|
|
97
|
-
```typescript
|
|
98
|
-
// Update resource
|
|
99
|
-
const updatedUser = await apiClient.put<User>('/users/123', userData);
|
|
70
|
+
#### React Native
|
|
100
71
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
## Configuration
|
|
72
|
+
```tsx
|
|
73
|
+
import { usePersSDK } from '@explorins/pers-sdk-react-native';
|
|
106
74
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
```typescript
|
|
110
|
-
const config = {
|
|
111
|
-
environment: 'production', // 'development' | 'staging' | 'production'
|
|
112
|
-
apiProjectKey: 'your-project-key', // Required for API access
|
|
113
|
-
apiVersion: 'v2', // 'v1' | 'v1.8' | 'v1.9' | 'v2'
|
|
114
|
-
timeout: 30000, // Request timeout (ms)
|
|
115
|
-
retries: 3, // Retry attempts
|
|
116
|
-
authProvider // Authentication provider
|
|
117
|
-
};
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
### Advanced Configuration
|
|
121
|
-
|
|
122
|
-
```typescript
|
|
123
|
-
const config = {
|
|
124
|
-
// ... basic config
|
|
75
|
+
function LoginScreen() {
|
|
76
|
+
const { login } = usePersSDK();
|
|
125
77
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
## Authentication Providers
|
|
133
|
-
|
|
134
|
-
### Simple Token Provider
|
|
135
|
-
|
|
136
|
-
```typescript
|
|
137
|
-
const authProvider = createAuthProvider({
|
|
138
|
-
authType: 'user',
|
|
139
|
-
token: 'static-token', // Static token
|
|
140
|
-
projectKey: 'your-project-key'
|
|
141
|
-
});
|
|
78
|
+
const handleLogin = async () => {
|
|
79
|
+
await login(firebaseToken);
|
|
80
|
+
};
|
|
81
|
+
}
|
|
142
82
|
```
|
|
143
83
|
|
|
144
|
-
|
|
84
|
+
## Domain Architecture
|
|
145
85
|
|
|
146
86
|
```typescript
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
},
|
|
153
|
-
projectKey: 'your-project-key',
|
|
154
|
-
|
|
155
|
-
// Optional: Handle token refresh
|
|
156
|
-
onTokenExpired: async () => {
|
|
157
|
-
console.log('Token expired - refreshing...');
|
|
158
|
-
},
|
|
159
|
-
|
|
160
|
-
// Optional: React to token refresh
|
|
161
|
-
onTokenRefreshed: (newToken) => {
|
|
162
|
-
console.log('New token received');
|
|
163
|
-
}
|
|
164
|
-
});
|
|
87
|
+
// Domain-specific imports (recommended)
|
|
88
|
+
import { PersApiClient } from '@explorins/pers-sdk/core';
|
|
89
|
+
import { TokenSDK } from '@explorins/pers-sdk/token';
|
|
90
|
+
import { createBusinessSDK } from '@explorins/pers-sdk/business';
|
|
91
|
+
import { createCampaignSDK } from '@explorins/pers-sdk/campaign';
|
|
165
92
|
```
|
|
166
93
|
|
|
167
|
-
|
|
94
|
+
## Core Authentication
|
|
168
95
|
|
|
169
96
|
```typescript
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
tokenProvider: () => getToken(),
|
|
173
|
-
projectKey: 'your-project-key',
|
|
174
|
-
tokenStorage: 'localStorage', // 'localStorage' | 'memory' | 'sessionStorage'
|
|
175
|
-
|
|
176
|
-
// Or custom storage
|
|
177
|
-
customTokenStorage: {
|
|
178
|
-
setItem: async (key, value) => await customStorage.set(key, value),
|
|
179
|
-
getItem: async (key) => await customStorage.get(key),
|
|
180
|
-
removeItem: async (key) => await customStorage.remove(key)
|
|
181
|
-
}
|
|
182
|
-
});
|
|
183
|
-
```
|
|
184
|
-
|
|
185
|
-
## Token Management
|
|
186
|
-
|
|
187
|
-
### Token Lifecycle
|
|
188
|
-
|
|
189
|
-
The SDK automatically handles token lifecycle:
|
|
190
|
-
|
|
191
|
-
1. **Proactive Refresh**: Tokens are refreshed before expiry
|
|
192
|
-
2. **Background Refresh**: Non-blocking refresh for optimal performance
|
|
193
|
-
3. **Fallback Refresh**: Reactive refresh if proactive refresh fails
|
|
194
|
-
4. **Provider Token**: Automatic fallback to provider token if refresh tokens expire
|
|
195
|
-
|
|
196
|
-
### Manual Token Checks
|
|
97
|
+
// Login with external JWT
|
|
98
|
+
const authResult = await apiClient.loginUser(externalJWT);
|
|
197
99
|
|
|
198
|
-
|
|
199
|
-
// Check if user is authenticated
|
|
100
|
+
// Check authentication status
|
|
200
101
|
if (apiClient.hasValidAuth()) {
|
|
201
102
|
console.log('User is authenticated');
|
|
202
103
|
}
|
|
203
104
|
|
|
204
|
-
//
|
|
205
|
-
|
|
206
|
-
console.log('Token expires within 2 minutes');
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
// Check if full re-authentication is needed
|
|
210
|
-
if (await apiClient.areAllTokensExpired()) {
|
|
211
|
-
console.log('Full re-authentication required');
|
|
212
|
-
redirectToLogin();
|
|
213
|
-
}
|
|
214
|
-
```
|
|
215
|
-
|
|
216
|
-
## Error Handling
|
|
217
|
-
|
|
218
|
-
### API Errors
|
|
219
|
-
|
|
220
|
-
```typescript
|
|
221
|
-
import { PersApiError } from '@explorins/pers-sdk/core';
|
|
222
|
-
|
|
223
|
-
try {
|
|
224
|
-
const data = await apiClient.get('/protected-endpoint');
|
|
225
|
-
} catch (error) {
|
|
226
|
-
if (error instanceof PersApiError) {
|
|
227
|
-
console.error('API Error:', error.message);
|
|
228
|
-
console.error('Status:', error.status);
|
|
229
|
-
console.error('Endpoint:', error.endpoint);
|
|
230
|
-
console.error('Retryable:', error.retryable);
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
```
|
|
234
|
-
|
|
235
|
-
### Authentication Errors
|
|
236
|
-
|
|
237
|
-
Authentication failures are handled automatically, but you can listen for events:
|
|
238
|
-
|
|
239
|
-
```typescript
|
|
240
|
-
// The SDK will automatically attempt refresh and fallback strategies
|
|
241
|
-
// If all authentication methods fail, API calls will throw appropriate errors
|
|
242
|
-
```
|
|
243
|
-
|
|
244
|
-
## TypeScript Support
|
|
245
|
-
|
|
246
|
-
### Type Definitions
|
|
105
|
+
// Automatic token refresh handled internally
|
|
106
|
+
await apiClient.refreshToken();
|
|
247
107
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
PersApiClient,
|
|
251
|
-
PersConfig,
|
|
252
|
-
PersAuthProvider,
|
|
253
|
-
PersEnvironment,
|
|
254
|
-
PersApiVersion
|
|
255
|
-
} from '@explorins/pers-sdk/core';
|
|
256
|
-
|
|
257
|
-
// Custom interfaces
|
|
258
|
-
interface User {
|
|
259
|
-
id: string;
|
|
260
|
-
email: string;
|
|
261
|
-
name: string;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
// Typed API calls
|
|
265
|
-
const user = await apiClient.get<User>('/users/me');
|
|
266
|
-
const users = await apiClient.get<User[]>('/users');
|
|
108
|
+
// Clear authentication
|
|
109
|
+
await apiClient.clearAuth();
|
|
267
110
|
```
|
|
268
111
|
|
|
269
|
-
|
|
112
|
+
## Business Domain Examples
|
|
270
113
|
|
|
114
|
+
### Token Management
|
|
271
115
|
```typescript
|
|
272
|
-
import {
|
|
116
|
+
import { TokenSDK } from '@explorins/pers-sdk/token';
|
|
273
117
|
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
async getToken(): Promise<string | null> {
|
|
278
|
-
// Your implementation
|
|
279
|
-
return await this.tokenManager.getAccessToken();
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
async getProjectKey(): Promise<string | null> {
|
|
283
|
-
return 'your-project-key';
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
// Implement other required methods...
|
|
287
|
-
}
|
|
118
|
+
const tokenSDK = new TokenSDK(apiClient);
|
|
119
|
+
const balances = await tokenSDK.getBalances(userId);
|
|
288
120
|
```
|
|
289
121
|
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
### Browser (React, Vue, etc.)
|
|
293
|
-
|
|
122
|
+
### Business Operations
|
|
294
123
|
```typescript
|
|
295
|
-
import {
|
|
124
|
+
import { createBusinessSDK } from '@explorins/pers-sdk/business';
|
|
296
125
|
|
|
297
|
-
const
|
|
126
|
+
const businessSDK = createBusinessSDK(apiClient);
|
|
127
|
+
const businesses = await businessSDK.listBusinesses();
|
|
298
128
|
```
|
|
299
129
|
|
|
300
|
-
###
|
|
301
|
-
|
|
130
|
+
### Campaign Management
|
|
302
131
|
```typescript
|
|
303
|
-
import {
|
|
132
|
+
import { createCampaignSDK } from '@explorins/pers-sdk/campaign';
|
|
304
133
|
|
|
305
|
-
const
|
|
134
|
+
const campaignSDK = createCampaignSDK(apiClient);
|
|
135
|
+
const campaigns = await campaignSDK.getActiveCampaigns();
|
|
306
136
|
```
|
|
307
137
|
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
```typescript
|
|
311
|
-
import { ReactNativeHttpClient } from '@explorins/pers-sdk/react-native';
|
|
312
|
-
|
|
313
|
-
const sdk = createPersSDK(new ReactNativeHttpClient(), config);
|
|
314
|
-
```
|
|
138
|
+
## Available Domains
|
|
315
139
|
|
|
316
|
-
|
|
140
|
+
- `/core` - Core API client and authentication
|
|
141
|
+
- `/token` - Token balances and transfers
|
|
142
|
+
- `/business` - Business operations and management
|
|
143
|
+
- `/campaign` - Marketing campaigns and challenges
|
|
144
|
+
- `/transaction` - Payment and transaction history
|
|
145
|
+
- `/redemption` - Reward redemption system
|
|
146
|
+
- `/payment` - Payment processing
|
|
147
|
+
- `/user` - User profile management
|
|
148
|
+
- `/web3` - Blockchain and wallet integration
|
|
149
|
+
- `/analytics` - Reporting and analytics
|
|
150
|
+
- `/tenant` - Multi-tenant management
|
|
317
151
|
|
|
318
|
-
|
|
152
|
+
## Configuration
|
|
319
153
|
|
|
320
154
|
```typescript
|
|
321
|
-
// Use environment variables
|
|
322
155
|
const config = {
|
|
323
|
-
environment:
|
|
324
|
-
|
|
156
|
+
environment: 'production', // 'development' | 'staging' | 'production'
|
|
157
|
+
apiVersion: 'v2', // 'v1' | 'v1.8' | 'v1.9' | 'v2'
|
|
158
|
+
apiProjectKey: 'your-key', // Required: Your PERS project key
|
|
159
|
+
timeout: 30000, // Request timeout (default: 30s)
|
|
160
|
+
retries: 3 // Retry attempts (default: 3)
|
|
325
161
|
};
|
|
326
162
|
```
|
|
327
163
|
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
```typescript
|
|
331
|
-
// Wrap API calls in try-catch blocks
|
|
332
|
-
const fetchUserData = async () => {
|
|
333
|
-
try {
|
|
334
|
-
return await apiClient.get<User>('/users/me');
|
|
335
|
-
} catch (error) {
|
|
336
|
-
// Handle error appropriately
|
|
337
|
-
logError(error);
|
|
338
|
-
showErrorToast('Failed to load user data');
|
|
339
|
-
return null;
|
|
340
|
-
}
|
|
341
|
-
};
|
|
342
|
-
```
|
|
343
|
-
|
|
344
|
-
### 3. Token Provider Caching
|
|
345
|
-
|
|
346
|
-
```typescript
|
|
347
|
-
let cachedToken: string | null = null;
|
|
348
|
-
|
|
349
|
-
const authProvider = createAuthProvider({
|
|
350
|
-
tokenProvider: async () => {
|
|
351
|
-
if (!cachedToken) {
|
|
352
|
-
cachedToken = await getFirebaseToken();
|
|
353
|
-
}
|
|
354
|
-
return cachedToken;
|
|
355
|
-
},
|
|
356
|
-
onTokenRefreshed: (newToken) => {
|
|
357
|
-
cachedToken = newToken; // Update cache
|
|
358
|
-
}
|
|
359
|
-
});
|
|
360
|
-
```
|
|
361
|
-
|
|
362
|
-
## Migration Guide
|
|
363
|
-
|
|
364
|
-
### From v1.x to v2.x
|
|
365
|
-
|
|
366
|
-
The v2 SDK introduces a cleaner, more maintainable architecture:
|
|
367
|
-
|
|
368
|
-
```typescript
|
|
369
|
-
// v1.x (Legacy)
|
|
370
|
-
import { PersSDK } from '@explorins/pers-sdk';
|
|
371
|
-
const sdk = new PersSDK(config);
|
|
372
|
-
|
|
373
|
-
// v2.x (Current)
|
|
374
|
-
import { createPersSDK, createAuthProvider } from '@explorins/pers-sdk/core';
|
|
375
|
-
import { BrowserHttpClient } from '@explorins/pers-sdk/browser';
|
|
376
|
-
|
|
377
|
-
const authProvider = createAuthProvider(authConfig);
|
|
378
|
-
const sdk = createPersSDK(new BrowserHttpClient(), {
|
|
379
|
-
...config,
|
|
380
|
-
authProvider
|
|
381
|
-
});
|
|
382
|
-
```
|
|
383
|
-
|
|
384
|
-
## API Reference
|
|
385
|
-
|
|
386
|
-
### Core Classes
|
|
387
|
-
|
|
388
|
-
- **`PersApiClient`** - Main API client for authenticated requests
|
|
389
|
-
- **`PersSDK`** - SDK wrapper providing access to API client
|
|
390
|
-
- **`createAuthProvider()`** - Factory for creating authentication providers
|
|
391
|
-
- **`createPersSDK()`** - Factory for creating SDK instances
|
|
392
|
-
|
|
393
|
-
### Interfaces
|
|
394
|
-
|
|
395
|
-
- **`PersConfig`** - SDK configuration options
|
|
396
|
-
- **`PersAuthProvider`** - Authentication provider interface
|
|
397
|
-
- **`AuthTokens`** - Token structure definition
|
|
398
|
-
- **`SimpleAuthConfig`** - Simple auth provider configuration
|
|
164
|
+
## Dependencies
|
|
399
165
|
|
|
400
|
-
|
|
166
|
+
- **`@explorins/web3-ts`** (^0.3.75) - Web3 blockchain integration
|
|
167
|
+
- **`jwt-decode`** (^4.0.0) - JWT token parsing
|
|
168
|
+
- **`@explorins/pers-shared`** (*) - Shared types (peer dependency)
|
|
169
|
+
- **`ethers`** (^6.15.0) - Ethereum integration (peer dependency)
|
|
401
170
|
|
|
402
|
-
|
|
403
|
-
- **`PersApiVersion`** - Supported API versions
|
|
404
|
-
- **`AuthType`** - Authentication types ('user' | 'admin')
|
|
171
|
+
## Related Packages
|
|
405
172
|
|
|
406
|
-
|
|
173
|
+
- [@explorins/pers-sdk-angular](https://www.npmjs.com/package/@explorins/pers-sdk-angular) - Angular integration
|
|
174
|
+
- [@explorins/pers-sdk-react-native](https://www.npmjs.com/package/@explorins/pers-sdk-react-native) - React Native integration
|
|
175
|
+
- [@explorins/pers-shared](https://www.npmjs.com/package/@explorins/pers-shared) - Shared types and DTOs
|
|
176
|
+
- [@explorins/web3-ts](https://www.npmjs.com/package/@explorins/web3-ts) - Web3 utilities
|
|
407
177
|
|
|
408
|
-
|
|
178
|
+
## Documentation
|
|
409
179
|
|
|
410
|
-
|
|
411
|
-
2. Search [existing issues](https://github.com/explorins/pers-sdk/issues)
|
|
412
|
-
3. Create a [new issue](https://github.com/explorins/pers-sdk/issues/new)
|
|
180
|
+
For comprehensive API documentation, usage guides, and examples, visit the [PERS SDK Documentation](https://docs.pers.ninja).
|
|
413
181
|
|
|
414
182
|
## License
|
|
415
183
|
|
package/dist/business/index.d.ts
CHANGED
|
@@ -18,15 +18,15 @@ import { BusinessService } from './services/business-service';
|
|
|
18
18
|
* @returns Business SDK with flattened structure for better DX
|
|
19
19
|
*/
|
|
20
20
|
export declare function createBusinessSDK(apiClient: PersApiClient): {
|
|
21
|
-
getActiveBusinesses: () => Promise<import("@explorins/pers-shared
|
|
22
|
-
getAllBusinessTypes: () => Promise<import("@explorins/pers-shared
|
|
23
|
-
getBusinessById: (businessId: string) => Promise<import("@explorins/pers-shared
|
|
24
|
-
getBusinessByAccount: (accountAddress: string) => Promise<import("@explorins/pers-shared
|
|
25
|
-
getBusinessesByType: (typeId: string) => Promise<import("@explorins/pers-shared
|
|
26
|
-
getAllBusinesses: () => Promise<import("@explorins/pers-shared
|
|
27
|
-
createBusinessByDisplayName: (displayName: string) => Promise<import("@explorins/pers-shared
|
|
28
|
-
updateBusiness: (id: string, businessData: BusinessUpdateRequestDTO) => Promise<import("@explorins/pers-shared
|
|
29
|
-
toggleBusinessActive: (id: string, isActive: boolean) => Promise<import("@explorins/pers-shared
|
|
21
|
+
getActiveBusinesses: () => Promise<import("@explorins/pers-shared").BusinessDTO[]>;
|
|
22
|
+
getAllBusinessTypes: () => Promise<import("@explorins/pers-shared").BusinessTypeDTO[]>;
|
|
23
|
+
getBusinessById: (businessId: string) => Promise<import("@explorins/pers-shared").BusinessDTO>;
|
|
24
|
+
getBusinessByAccount: (accountAddress: string) => Promise<import("@explorins/pers-shared").BusinessDTO>;
|
|
25
|
+
getBusinessesByType: (typeId: string) => Promise<import("@explorins/pers-shared").BusinessDTO[]>;
|
|
26
|
+
getAllBusinesses: () => Promise<import("@explorins/pers-shared").BusinessDTO[]>;
|
|
27
|
+
createBusinessByDisplayName: (displayName: string) => Promise<import("@explorins/pers-shared").BusinessDTO>;
|
|
28
|
+
updateBusiness: (id: string, businessData: BusinessUpdateRequestDTO) => Promise<import("@explorins/pers-shared").BusinessDTO>;
|
|
29
|
+
toggleBusinessActive: (id: string, isActive: boolean) => Promise<import("@explorins/pers-shared").BusinessDTO>;
|
|
30
30
|
api: BusinessApi;
|
|
31
31
|
service: BusinessService;
|
|
32
32
|
};
|
package/dist/campaign/index.d.ts
CHANGED
|
@@ -18,25 +18,25 @@ import { CampaignClaimRequestDTO, CampaignCreateRequestDTO, TokenUnitCreateReque
|
|
|
18
18
|
* @returns Campaign SDK with flattened structure for better DX
|
|
19
19
|
*/
|
|
20
20
|
export declare function createCampaignSDK(apiClient: PersApiClient): {
|
|
21
|
-
getActiveCampaigns: () => Promise<import("@explorins/pers-shared
|
|
22
|
-
getCampaignById: (id: string) => Promise<import("@explorins/pers-shared
|
|
23
|
-
claimCampaign: (request: CampaignClaimRequestDTO) => Promise<import("@explorins/pers-shared
|
|
24
|
-
getClaimsForLoggedUser: () => Promise<import("@explorins/pers-shared
|
|
25
|
-
getCampaigns: (active?: boolean) => Promise<import("@explorins/pers-shared
|
|
26
|
-
getCampaignTriggers: () => Promise<import("@explorins/pers-shared
|
|
27
|
-
toggleCampaignActive: (campaignId: string) => Promise<import("@explorins/pers-shared
|
|
28
|
-
toggleCampaignTestnet: (campaignId: string) => Promise<import("@explorins/pers-shared
|
|
29
|
-
createCampaign: (campaign: CampaignCreateRequestDTO) => Promise<import("@explorins/pers-shared
|
|
30
|
-
setCampaignTrigger: (campaignId: string, triggerId: string) => Promise<import("@explorins/pers-shared
|
|
31
|
-
updateCampaign: (campaignId: string, campaign: CampaignCreateRequestDTO) => Promise<import("@explorins/pers-shared
|
|
32
|
-
createCampaignTokenUnit: (campaignId: string, campaignTokenUnit: TokenUnitCreateRequestDTO) => Promise<import("@explorins/pers-shared
|
|
33
|
-
deleteCampaignTokenUnit: (campaignId: string, campaignTokenUnitId: string) => Promise<import("@explorins/pers-shared
|
|
34
|
-
addBusinessEngagementToCampaign: (campaignId: string, campaignBusinessEngagement: CampaignBusinessEngagementCreateRequestDTO) => Promise<import("@explorins/pers-shared
|
|
35
|
-
updateCampaignBusinessEngagement: (campaignId: string, businessEngagementId: string, campaignBusinessEngagement: CampaignBusinessEngagementCreateRequestDTO) => Promise<import("@explorins/pers-shared
|
|
36
|
-
deleteCampaignBusinessEngagement: (campaignId: string, businessEngagementId: string) => Promise<import("@explorins/pers-shared
|
|
37
|
-
getCampaignClaims: () => Promise<import("@explorins/pers-shared
|
|
38
|
-
getCampaignClaimsByUserId: (userId: string) => Promise<import("@explorins/pers-shared
|
|
39
|
-
getCampaignClaimsByBusinessId: (businessId: string) => Promise<import("@explorins/pers-shared
|
|
21
|
+
getActiveCampaigns: () => Promise<import("@explorins/pers-shared").CampaignDTO[]>;
|
|
22
|
+
getCampaignById: (id: string) => Promise<import("@explorins/pers-shared").CampaignDTO>;
|
|
23
|
+
claimCampaign: (request: CampaignClaimRequestDTO) => Promise<import("@explorins/pers-shared").CampaignClaimDTO>;
|
|
24
|
+
getClaimsForLoggedUser: () => Promise<import("@explorins/pers-shared").CampaignClaimDTO[]>;
|
|
25
|
+
getCampaigns: (active?: boolean) => Promise<import("@explorins/pers-shared").CampaignDTO[]>;
|
|
26
|
+
getCampaignTriggers: () => Promise<import("@explorins/pers-shared").CampaignTriggerDTO[]>;
|
|
27
|
+
toggleCampaignActive: (campaignId: string) => Promise<import("@explorins/pers-shared").CampaignDTO>;
|
|
28
|
+
toggleCampaignTestnet: (campaignId: string) => Promise<import("@explorins/pers-shared").CampaignDTO>;
|
|
29
|
+
createCampaign: (campaign: CampaignCreateRequestDTO) => Promise<import("@explorins/pers-shared").CampaignDTO>;
|
|
30
|
+
setCampaignTrigger: (campaignId: string, triggerId: string) => Promise<import("@explorins/pers-shared").CampaignDTO>;
|
|
31
|
+
updateCampaign: (campaignId: string, campaign: CampaignCreateRequestDTO) => Promise<import("@explorins/pers-shared").CampaignDTO>;
|
|
32
|
+
createCampaignTokenUnit: (campaignId: string, campaignTokenUnit: TokenUnitCreateRequestDTO) => Promise<import("@explorins/pers-shared").CampaignDTO>;
|
|
33
|
+
deleteCampaignTokenUnit: (campaignId: string, campaignTokenUnitId: string) => Promise<import("@explorins/pers-shared").CampaignDTO>;
|
|
34
|
+
addBusinessEngagementToCampaign: (campaignId: string, campaignBusinessEngagement: CampaignBusinessEngagementCreateRequestDTO) => Promise<import("@explorins/pers-shared").CampaignDTO>;
|
|
35
|
+
updateCampaignBusinessEngagement: (campaignId: string, businessEngagementId: string, campaignBusinessEngagement: CampaignBusinessEngagementCreateRequestDTO) => Promise<import("@explorins/pers-shared").CampaignDTO>;
|
|
36
|
+
deleteCampaignBusinessEngagement: (campaignId: string, businessEngagementId: string) => Promise<import("@explorins/pers-shared").CampaignDTO>;
|
|
37
|
+
getCampaignClaims: () => Promise<import("@explorins/pers-shared").CampaignClaimDTO[]>;
|
|
38
|
+
getCampaignClaimsByUserId: (userId: string) => Promise<import("@explorins/pers-shared").CampaignClaimDTO[]>;
|
|
39
|
+
getCampaignClaimsByBusinessId: (businessId: string) => Promise<import("@explorins/pers-shared").CampaignClaimDTO[]>;
|
|
40
40
|
api: CampaignApi;
|
|
41
41
|
service: CampaignService;
|
|
42
42
|
};
|