@explorins/pers-sdk-react-native 2.1.3 → 2.1.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.
Files changed (51) hide show
  1. package/README.md +7 -7
  2. package/dist/hooks/index.d.ts +6 -0
  3. package/dist/hooks/index.d.ts.map +1 -1
  4. package/dist/hooks/index.js +1 -0
  5. package/dist/hooks/useAnalytics.d.ts +37 -14
  6. package/dist/hooks/useAnalytics.d.ts.map +1 -1
  7. package/dist/hooks/useAnalytics.js +239 -19
  8. package/dist/hooks/useCampaigns.d.ts +14 -6
  9. package/dist/hooks/useCampaigns.d.ts.map +1 -1
  10. package/dist/hooks/useCampaigns.js +144 -10
  11. package/dist/hooks/useEvents.d.ts +17 -5
  12. package/dist/hooks/useEvents.d.ts.map +1 -1
  13. package/dist/hooks/useEvents.js +17 -5
  14. package/dist/hooks/useRedemptions.d.ts +5 -2
  15. package/dist/hooks/useRedemptions.d.ts.map +1 -1
  16. package/dist/hooks/useRedemptions.js +53 -2
  17. package/dist/hooks/useTokenBalances.d.ts +24 -0
  18. package/dist/hooks/useTokenBalances.d.ts.map +1 -1
  19. package/dist/hooks/useTokenBalances.js +42 -2
  20. package/dist/hooks/useTransactions.d.ts +8 -5
  21. package/dist/hooks/useTransactions.d.ts.map +1 -1
  22. package/dist/hooks/useTransactions.js +70 -27
  23. package/dist/hooks/useTriggerSources.d.ts +76 -0
  24. package/dist/hooks/useTriggerSources.d.ts.map +1 -0
  25. package/dist/hooks/useTriggerSources.js +272 -0
  26. package/dist/hooks/useUsers.d.ts +5 -4
  27. package/dist/hooks/useUsers.d.ts.map +1 -1
  28. package/dist/hooks/useUsers.js +47 -8
  29. package/dist/hooks/useWeb3.d.ts +6 -5
  30. package/dist/hooks/useWeb3.d.ts.map +1 -1
  31. package/dist/hooks/useWeb3.js +23 -10
  32. package/dist/index.d.ts +12 -3
  33. package/dist/index.d.ts.map +1 -1
  34. package/dist/index.js +5500 -893
  35. package/dist/index.js.map +1 -1
  36. package/dist/providers/PersSDKProvider.d.ts +38 -0
  37. package/dist/providers/PersSDKProvider.d.ts.map +1 -1
  38. package/dist/providers/PersSDKProvider.js +29 -1
  39. package/package.json +3 -2
  40. package/src/hooks/index.ts +17 -1
  41. package/src/hooks/useAnalytics.ts +268 -21
  42. package/src/hooks/useCampaigns.ts +176 -14
  43. package/src/hooks/useEvents.ts +17 -5
  44. package/src/hooks/useRedemptions.ts +66 -3
  45. package/src/hooks/useTokenBalances.ts +60 -2
  46. package/src/hooks/useTransactions.ts +84 -29
  47. package/src/hooks/useTriggerSources.ts +301 -0
  48. package/src/hooks/useUsers.ts +51 -9
  49. package/src/hooks/useWeb3.ts +28 -13
  50. package/src/index.ts +33 -3
  51. package/src/providers/PersSDKProvider.tsx +38 -1
@@ -5,10 +5,14 @@ import type {
5
5
  TransactionRequestDTO,
6
6
  TransactionRequestResponseDTO,
7
7
  TransactionDTO,
8
- TransactionRole,
9
8
  TransactionPaginationRequestDTO,
10
- PaginatedResponseDTO
9
+ PaginatedResponseDTO,
10
+ TransactionIncludeRelation
11
11
  } from '@explorins/pers-shared';
12
+ import type { TransactionQueryOptions } from '@explorins/pers-sdk/transaction';
13
+
14
+ // Re-export for consumers
15
+ export type { TransactionQueryOptions } from '@explorins/pers-sdk/transaction';
12
16
 
13
17
  /**
14
18
  * React hook for transaction operations in the PERS SDK
@@ -124,26 +128,36 @@ export const useTransactions = () => {
124
128
  }, [sdk, isInitialized, signAndSubmitTransactionWithJWT, isSignerAvailable]);
125
129
 
126
130
  /**
127
- * Retrieves a specific transaction by its ID
131
+ * Retrieves a specific transaction by its ID with optional include relations
128
132
  *
129
133
  * @param transactionId - Unique identifier of the transaction
134
+ * @param include - Optional relations to include (sender, recipient, business) for enriched entity data
130
135
  * @returns Promise resolving to transaction data or null if not found
131
136
  * @throws Error if SDK is not initialized
132
137
  *
133
138
  * @example
134
139
  * ```typescript
135
140
  * const { getTransactionById } = useTransactions();
141
+ *
142
+ * // Basic retrieval
136
143
  * const transaction = await getTransactionById('txn-123');
137
- * console.log('Transaction details:', transaction);
144
+ *
145
+ * // With enriched sender/recipient data
146
+ * const enrichedTx = await getTransactionById('txn-123', ['sender', 'recipient', 'business']);
147
+ * console.log('Sender:', enrichedTx?.included?.sender);
148
+ * console.log('Business:', enrichedTx?.included?.engagedBusiness?.displayName);
138
149
  * ```
139
150
  */
140
- const getTransactionById = useCallback(async (transactionId: string): Promise<TransactionDTO | null> => {
151
+ const getTransactionById = useCallback(async (
152
+ transactionId: string,
153
+ include?: TransactionIncludeRelation[]
154
+ ): Promise<TransactionDTO | null> => {
141
155
  if (!isInitialized || !sdk) {
142
156
  throw new Error('SDK not initialized. Call initialize() first.');
143
157
  }
144
158
 
145
159
  try {
146
- const result = await sdk.transactions.getTransactionById(transactionId);
160
+ const result = await sdk.transactions.getTransactionById(transactionId, include);
147
161
  return result;
148
162
  } catch (error) {
149
163
  console.error('Failed to fetch transaction:', error);
@@ -152,27 +166,52 @@ export const useTransactions = () => {
152
166
  }, [sdk, isInitialized]);
153
167
 
154
168
  /**
155
- * Retrieves transaction history for the authenticated user, filtered by role
169
+ * Retrieves transaction history for the authenticated user with comprehensive filtering
156
170
  *
157
- * @param role - Optional transaction role filter (TransactionRole.SENDER, TransactionRole.RECIPIENT)
158
- * @returns Promise resolving to array of user's transactions
171
+ * Supports filtering by role, status, type, business, token, and more.
172
+ * Optionally enrich with related entities (sender, recipient, business).
173
+ *
174
+ * @param options - Query options including filters, pagination, and include relations
175
+ * @returns Promise resolving to paginated array of user's transactions
159
176
  * @throws Error if SDK is not initialized
160
177
  *
161
178
  * @example
162
179
  * ```typescript
163
180
  * const { getUserTransactionHistory } = useTransactions();
164
- * const sentTransactions = await getUserTransactionHistory(TransactionRole.SENDER);
165
- * const allTransactions = await getUserTransactionHistory(); // No filter
181
+ *
182
+ * // Simple: Get all transactions
183
+ * const allTransactions = await getUserTransactionHistory();
184
+ *
185
+ * // Filter by role (legacy support)
186
+ * const sentTransactions = await getUserTransactionHistory({ role: 'SENDER' });
187
+ *
188
+ * // Advanced filtering with include relations
189
+ * const filtered = await getUserTransactionHistory({
190
+ * role: 'SENDER',
191
+ * status: 'COMPLETED',
192
+ * engagedBusinessId: 'business-123',
193
+ * include: ['recipient', 'business'],
194
+ * page: 1,
195
+ * limit: 20
196
+ * });
197
+ *
198
+ * // Access enriched data
199
+ * filtered.data.forEach(tx => {
200
+ * console.log('Recipient:', tx.included?.recipient);
201
+ * console.log('Business:', tx.included?.engagedBusiness?.displayName);
202
+ * });
166
203
  * ```
167
204
  */
168
- const getUserTransactionHistory = useCallback(async (role?: TransactionRole): Promise<PaginatedResponseDTO<TransactionDTO>> => {
205
+ const getUserTransactionHistory = useCallback(async (
206
+ options?: TransactionQueryOptions
207
+ ): Promise<PaginatedResponseDTO<TransactionDTO>> => {
169
208
 
170
209
  if (!isInitialized || !sdk) {
171
210
  throw new Error('SDK not initialized. Call initialize() first.');
172
211
  }
173
212
 
174
213
  try {
175
- const result = await sdk.transactions.getUserTransactionHistory(role);
214
+ const result = await sdk.transactions.getUserTransactionHistory(options);
176
215
  return result;
177
216
  } catch (error) {
178
217
  console.error('Failed to fetch transaction history:', error);
@@ -180,27 +219,44 @@ export const useTransactions = () => {
180
219
  }
181
220
  }, [sdk, isInitialized]);
182
221
 
183
- const getTenantTransactions = useCallback(async (): Promise<PaginatedResponseDTO<TransactionDTO>> => {
184
- if (!isInitialized || !sdk) {
185
- throw new Error('SDK not initialized. Call initialize() first.');
186
- }
187
-
188
- try {
189
- const result = await sdk.transactions.getTenantTransactions();
190
- return result;
191
- } catch (error) {
192
- console.error('Failed to fetch tenant transactions:', error);
193
- throw error;
222
+ /**
223
+ * Admin: Get paginated transactions with optional include relations
224
+ *
225
+ * @param params - Pagination and filtering parameters
226
+ * @param include - Optional relations to include for enriched entity data
227
+ * @returns Promise resolving to paginated transaction results
228
+ * @throws Error if SDK is not initialized
229
+ *
230
+ * @example
231
+ * ```typescript
232
+ * const { getPaginatedTransactions } = useTransactions();
233
+ *
234
+ * // Basic pagination
235
+ * const result = await getPaginatedTransactions({ page: 1, limit: 50 });
236
+ *
237
+ * // With include relations
238
+ * const enrichedResult = await getPaginatedTransactions(
239
+ * { page: 1, limit: 50, sortBy: 'createdAt', sortOrder: 'DESC' },
240
+ * include: ['sender', 'recipient', 'business']
241
+ * });
242
+ *
243
+ * enrichedResult.data.forEach(tx => {
244
+ * console.log('From:', tx.included?.sender);
245
+ * console.log('To:', tx.included?.recipient);
246
+ * });
247
+ * ```
248
+ */
249
+ const getPaginatedTransactions = useCallback(async (
250
+ options: TransactionPaginationRequestDTO & {
251
+ include?: TransactionIncludeRelation[];
194
252
  }
195
- }, [sdk, isInitialized]);
196
-
197
- const getPaginatedTransactions = useCallback(async (params: TransactionPaginationRequestDTO): Promise<any> => {
253
+ ): Promise<PaginatedResponseDTO<TransactionDTO>> => {
198
254
  if (!isInitialized || !sdk) {
199
255
  throw new Error('SDK not initialized. Call initialize() first.');
200
256
  }
201
257
 
202
258
  try {
203
- const result = await sdk.transactions.getPaginatedTransactions(params);
259
+ const result = await sdk.transactions.getPaginatedTransactions(options);
204
260
  return result;
205
261
  } catch (error) {
206
262
  console.error('Failed to fetch paginated transactions:', error);
@@ -226,7 +282,6 @@ export const useTransactions = () => {
226
282
  createTransaction,
227
283
  getTransactionById,
228
284
  getUserTransactionHistory,
229
- getTenantTransactions,
230
285
  getPaginatedTransactions,
231
286
  exportTransactionsCSV,
232
287
  isAvailable: isInitialized && !!sdk?.transactions,
@@ -0,0 +1,301 @@
1
+ import { useCallback } from 'react';
2
+ import { usePersSDK } from '../providers/PersSDKProvider';
3
+ import type {
4
+ TriggerSourceDTO,
5
+ TriggerSourceCreateRequestDTO,
6
+ PaginatedResponseDTO
7
+ } from '@explorins/pers-shared';
8
+ import type { TriggerSourceQueryOptions } from '@explorins/pers-sdk/trigger-source';
9
+
10
+ // Re-export for consumers
11
+ export type { TriggerSourceQueryOptions } from '@explorins/pers-sdk/trigger-source';
12
+
13
+ /**
14
+ * React hook for TriggerSource operations in the PERS SDK
15
+ *
16
+ * Manages trigger sources which are physical or digital activation points for campaigns:
17
+ * - **QR_CODE**: Scannable QR codes at physical locations
18
+ * - **NFC_TAG**: NFC tap points for contactless interactions
19
+ * - **GPS_GEOFENCE**: Location-based triggers with radius detection
20
+ * - **API_WEBHOOK**: External system integration triggers
21
+ * - **TRANSACTION**: Purchase/payment based triggers
22
+ *
23
+ * TriggerSources are standalone entities that can be created, managed, and then
24
+ * assigned to campaigns. This separation allows reuse across multiple campaigns.
25
+ *
26
+ * **Admin Only**: All create, update, and delete operations require admin authentication.
27
+ *
28
+ * @returns TriggerSource hook with CRUD operations
29
+ *
30
+ * @example Basic TriggerSource Operations
31
+ * ```typescript
32
+ * function TriggerSourceManager() {
33
+ * const {
34
+ * getAll,
35
+ * getById,
36
+ * create,
37
+ * update,
38
+ * remove
39
+ * } = useTriggerSources();
40
+ *
41
+ * // List all QR code trigger sources
42
+ * const loadQRSources = async () => {
43
+ * const { data: sources } = await getAll({ type: 'QR_CODE' });
44
+ * console.log('QR Sources:', sources);
45
+ * };
46
+ *
47
+ * // Create a new QR code for a store
48
+ * const createStoreQR = async () => {
49
+ * const source = await create({
50
+ * type: 'QR_CODE',
51
+ * name: 'Store Entrance QR',
52
+ * description: 'Scan at the entrance',
53
+ * businessId: 'business-123',
54
+ * coordsLatitude: 47.6062,
55
+ * coordsLongitude: -122.3321
56
+ * });
57
+ * console.log('Created:', source.id);
58
+ * };
59
+ * }
60
+ * ```
61
+ *
62
+ * @example GPS Geofence Trigger
63
+ * ```typescript
64
+ * const { create } = useTriggerSources();
65
+ *
66
+ * // Create a GPS geofence around a location
67
+ * const geofence = await create({
68
+ * type: 'GPS_GEOFENCE',
69
+ * name: 'Downtown Area',
70
+ * coordsLatitude: 47.6062,
71
+ * coordsLongitude: -122.3321,
72
+ * metadata: { radiusMeters: 100 }
73
+ * });
74
+ * ```
75
+ */
76
+ export const useTriggerSources = () => {
77
+ const { sdk, isInitialized, isAuthenticated } = usePersSDK();
78
+
79
+ /**
80
+ * Get trigger sources with optional filters and pagination
81
+ *
82
+ * Retrieves trigger sources (QR codes, NFC tags, GPS geofences, webhooks, etc.)
83
+ * that can be used to activate campaigns. Supports filtering by type, business,
84
+ * campaign association, and active status.
85
+ *
86
+ * @param options - Filter and pagination options
87
+ * @returns Promise resolving to paginated trigger sources
88
+ *
89
+ * @example
90
+ * ```typescript
91
+ * // Get all QR code trigger sources
92
+ * const { data: qrSources } = await getAll({ type: 'QR_CODE' });
93
+ *
94
+ * // Get trigger sources for a specific business
95
+ * const { data: businessSources, pagination } = await getAll({
96
+ * businessId: 'business-123',
97
+ * active: true,
98
+ * page: 1,
99
+ * limit: 20
100
+ * });
101
+ *
102
+ * // Get trigger sources assigned to a campaign
103
+ * const { data: campaignSources } = await getAll({
104
+ * campaignId: 'campaign-456'
105
+ * });
106
+ * ```
107
+ */
108
+ const getAll = useCallback(async (
109
+ options?: TriggerSourceQueryOptions
110
+ ): Promise<PaginatedResponseDTO<TriggerSourceDTO>> => {
111
+ if (!isInitialized || !sdk) {
112
+ throw new Error('SDK not initialized. Call initialize() first.');
113
+ }
114
+
115
+ try {
116
+ const result = await sdk.triggerSources.getAll(options);
117
+ return result;
118
+ } catch (error) {
119
+ console.error('Failed to fetch trigger sources:', error);
120
+ throw error;
121
+ }
122
+ }, [sdk, isInitialized]);
123
+
124
+ /**
125
+ * Get trigger source by ID
126
+ *
127
+ * Retrieves detailed information for a specific trigger source including
128
+ * its type, location, metadata, and configuration.
129
+ *
130
+ * @param triggerSourceId - UUID of the trigger source
131
+ * @returns Promise resolving to trigger source details
132
+ * @throws {PersApiError} When trigger source with specified ID is not found
133
+ *
134
+ * @example
135
+ * ```typescript
136
+ * const source = await getById('source-123');
137
+ *
138
+ * console.log('Trigger Source:', source.name);
139
+ * console.log('Type:', source.type);
140
+ * console.log('Active:', source.isActive);
141
+ *
142
+ * if (source.coordsLatitude && source.coordsLongitude) {
143
+ * console.log('Location:', source.coordsLatitude, source.coordsLongitude);
144
+ * }
145
+ * ```
146
+ */
147
+ const getById = useCallback(async (
148
+ triggerSourceId: string
149
+ ): Promise<TriggerSourceDTO> => {
150
+ if (!isInitialized || !sdk) {
151
+ throw new Error('SDK not initialized. Call initialize() first.');
152
+ }
153
+
154
+ try {
155
+ const result = await sdk.triggerSources.getById(triggerSourceId);
156
+ return result;
157
+ } catch (error) {
158
+ console.error('Failed to fetch trigger source:', error);
159
+ throw error;
160
+ }
161
+ }, [sdk, isInitialized]);
162
+
163
+ /**
164
+ * Admin: Create a new trigger source
165
+ *
166
+ * Creates a new trigger source (QR code, NFC tag, GPS geofence, webhook, or
167
+ * transaction-based trigger) that can be assigned to campaigns. Requires
168
+ * administrator privileges.
169
+ *
170
+ * @param triggerSource - Trigger source creation data
171
+ * @returns Promise resolving to created trigger source
172
+ * @throws {PersApiError} When not authenticated as admin or validation fails
173
+ *
174
+ * @example
175
+ * ```typescript
176
+ * // Create a QR code trigger source
177
+ * const qrSource = await create({
178
+ * type: 'QR_CODE',
179
+ * name: 'Store Entrance QR',
180
+ * description: 'QR code at main entrance',
181
+ * businessId: 'business-123',
182
+ * coordsLatitude: 47.6062,
183
+ * coordsLongitude: -122.3321
184
+ * });
185
+ *
186
+ * // Create an NFC tag trigger source
187
+ * const nfcSource = await create({
188
+ * type: 'NFC_TAG',
189
+ * name: 'Product Display NFC',
190
+ * metadata: { productId: 'SKU-12345' }
191
+ * });
192
+ * ```
193
+ */
194
+ const create = useCallback(async (
195
+ triggerSource: TriggerSourceCreateRequestDTO
196
+ ): Promise<TriggerSourceDTO> => {
197
+ if (!isInitialized || !sdk) {
198
+ throw new Error('SDK not initialized. Call initialize() first.');
199
+ }
200
+ if (!isAuthenticated) {
201
+ throw new Error('SDK not authenticated. create requires admin authentication.');
202
+ }
203
+
204
+ try {
205
+ const result = await sdk.triggerSources.create(triggerSource);
206
+ return result;
207
+ } catch (error) {
208
+ console.error('Failed to create trigger source:', error);
209
+ throw error;
210
+ }
211
+ }, [sdk, isInitialized, isAuthenticated]);
212
+
213
+ /**
214
+ * Admin: Update a trigger source
215
+ *
216
+ * Updates an existing trigger source's configuration. All fields are optional;
217
+ * only provided fields will be updated. Requires administrator privileges.
218
+ *
219
+ * @param triggerSourceId - UUID of the trigger source to update
220
+ * @param triggerSource - Updated trigger source data (partial)
221
+ * @returns Promise resolving to updated trigger source
222
+ * @throws {PersApiError} When not authenticated as admin or trigger source not found
223
+ *
224
+ * @example
225
+ * ```typescript
226
+ * // Update trigger source name and location
227
+ * const updated = await update('source-123', {
228
+ * name: 'Updated Store Entrance QR',
229
+ * description: 'New description',
230
+ * coordsLatitude: 47.6063,
231
+ * coordsLongitude: -122.3322
232
+ * });
233
+ * ```
234
+ */
235
+ const update = useCallback(async (
236
+ triggerSourceId: string,
237
+ triggerSource: Partial<TriggerSourceCreateRequestDTO>
238
+ ): Promise<TriggerSourceDTO> => {
239
+ if (!isInitialized || !sdk) {
240
+ throw new Error('SDK not initialized. Call initialize() first.');
241
+ }
242
+ if (!isAuthenticated) {
243
+ throw new Error('SDK not authenticated. update requires admin authentication.');
244
+ }
245
+
246
+ try {
247
+ const result = await sdk.triggerSources.update(triggerSourceId, triggerSource);
248
+ return result;
249
+ } catch (error) {
250
+ console.error('Failed to update trigger source:', error);
251
+ throw error;
252
+ }
253
+ }, [sdk, isInitialized, isAuthenticated]);
254
+
255
+ /**
256
+ * Admin: Delete a trigger source
257
+ *
258
+ * Soft deletes a trigger source, making it inactive. The trigger source will
259
+ * be removed from any campaigns it was assigned to. Requires administrator
260
+ * privileges.
261
+ *
262
+ * @param triggerSourceId - UUID of the trigger source to delete
263
+ * @returns Promise resolving to success status
264
+ * @throws {PersApiError} When not authenticated as admin or trigger source not found
265
+ *
266
+ * @example
267
+ * ```typescript
268
+ * const success = await remove('source-123');
269
+ * console.log('Trigger source deleted:', success);
270
+ * ```
271
+ */
272
+ const remove = useCallback(async (
273
+ triggerSourceId: string
274
+ ): Promise<boolean> => {
275
+ if (!isInitialized || !sdk) {
276
+ throw new Error('SDK not initialized. Call initialize() first.');
277
+ }
278
+ if (!isAuthenticated) {
279
+ throw new Error('SDK not authenticated. remove requires admin authentication.');
280
+ }
281
+
282
+ try {
283
+ const result = await sdk.triggerSources.delete(triggerSourceId);
284
+ return result;
285
+ } catch (error) {
286
+ console.error('Failed to delete trigger source:', error);
287
+ throw error;
288
+ }
289
+ }, [sdk, isInitialized, isAuthenticated]);
290
+
291
+ return {
292
+ getAll,
293
+ getById,
294
+ create,
295
+ update,
296
+ remove,
297
+ isAvailable: isInitialized && !!sdk?.triggerSources,
298
+ };
299
+ };
300
+
301
+ export type TriggerSourceHook = ReturnType<typeof useTriggerSources>;
@@ -1,12 +1,31 @@
1
1
  import { useCallback } from 'react';
2
2
  import { usePersSDK } from '../providers/PersSDKProvider';
3
3
  import type { UserDTO, UserCreateRequestDTO, PaginatedResponseDTO } from '@explorins/pers-shared';
4
- import type { UserPublicProfileDTO } from '@explorins/pers-sdk/user';
4
+ import type { UserPublicProfileDTO, UserQueryOptions } from '@explorins/pers-sdk/user';
5
+
6
+ // Re-export for consumers
7
+ export type { UserQueryOptions } from '@explorins/pers-sdk/user';
5
8
 
6
9
  export const useUsers = () => {
7
10
  const { sdk, isInitialized, isAuthenticated } = usePersSDK();
8
11
 
9
- const getCurrentUser = useCallback(async (): Promise<UserDTO> => {
12
+ /**
13
+ * Get the current authenticated user with optional include relations
14
+ *
15
+ * @param options - Query options including include relations
16
+ * @returns Current user data
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * // Basic
21
+ * const user = await getCurrentUser();
22
+ *
23
+ * // With wallets included
24
+ * const userWithWallets = await getCurrentUser({ include: ['wallets'] });
25
+ * console.log('Wallets:', userWithWallets.included?.wallets);
26
+ * ```
27
+ */
28
+ const getCurrentUser = useCallback(async (options?: UserQueryOptions): Promise<UserDTO> => {
10
29
  if (!isInitialized || !sdk) {
11
30
  throw new Error('SDK not initialized. Call initialize() first.');
12
31
  }
@@ -15,7 +34,7 @@ export const useUsers = () => {
15
34
  }
16
35
 
17
36
  try {
18
- const result = await sdk.users.getCurrentUser();
37
+ const result = await sdk.users.getCurrentUser(options);
19
38
  return result;
20
39
  } catch (error) {
21
40
  console.error('Failed to fetch current user:', error);
@@ -40,13 +59,29 @@ export const useUsers = () => {
40
59
  }
41
60
  }, [sdk, isInitialized, isAuthenticated]);
42
61
 
43
- const getUserById = useCallback(async (userId: string): Promise<UserDTO> => {
62
+ /**
63
+ * Get user by ID with optional include relations
64
+ *
65
+ * @param userId - User identifier (id, email, externalId, etc.)
66
+ * @param options - Query options including include relations
67
+ * @returns User data
68
+ *
69
+ * @example
70
+ * ```typescript
71
+ * // Basic
72
+ * const user = await getUserById('user-123');
73
+ *
74
+ * // With wallets included
75
+ * const userWithWallets = await getUserById('user-123', { include: ['wallets'] });
76
+ * ```
77
+ */
78
+ const getUserById = useCallback(async (userId: string, options?: UserQueryOptions): Promise<UserDTO> => {
44
79
  if (!isInitialized || !sdk) {
45
80
  throw new Error('SDK not initialized. Call initialize() first.');
46
81
  }
47
82
 
48
83
  try {
49
- const result = await sdk.users.getUserById(userId);
84
+ const result = await sdk.users.getUserById(userId, options);
50
85
  return result;
51
86
  } catch (error) {
52
87
  console.error('Failed to fetch user:', error);
@@ -97,16 +132,23 @@ export const useUsers = () => {
97
132
  }
98
133
  }, [sdk, isInitialized]);
99
134
 
100
- const toggleUserStatus = useCallback(async (user: UserDTO): Promise<UserDTO> => {
135
+ /**
136
+ * Toggle or set a user's active status (admin only)
137
+ *
138
+ * @param userId - User ID to update
139
+ * @param isActive - Optional explicit status. If omitted, toggles current status.
140
+ * @returns Updated user
141
+ */
142
+ const setUserActiveStatus = useCallback(async (userId: string, isActive?: boolean): Promise<UserDTO> => {
101
143
  if (!isInitialized || !sdk) {
102
144
  throw new Error('SDK not initialized. Call initialize() first.');
103
145
  }
104
146
 
105
147
  try {
106
- const result = await sdk.users.toggleUserStatus(user);
148
+ const result = await sdk.users.setUserActiveStatus(userId, isActive);
107
149
  return result;
108
150
  } catch (error) {
109
- console.error('Failed to toggle user status:', error);
151
+ console.error('Failed to set user active status:', error);
110
152
  throw error;
111
153
  }
112
154
  }, [sdk, isInitialized]);
@@ -118,7 +160,7 @@ export const useUsers = () => {
118
160
  getAllUsersPublic,
119
161
  getAllUsers,
120
162
  updateUser,
121
- toggleUserStatus,
163
+ setUserActiveStatus,
122
164
  isAvailable: isInitialized && !!sdk?.users,
123
165
  };
124
166
  };