@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
@@ -109,25 +109,32 @@ export const useTransactions = () => {
109
109
  }
110
110
  }, [sdk, isInitialized, signAndSubmitTransactionWithJWT, isSignerAvailable]);
111
111
  /**
112
- * Retrieves a specific transaction by its ID
112
+ * Retrieves a specific transaction by its ID with optional include relations
113
113
  *
114
114
  * @param transactionId - Unique identifier of the transaction
115
+ * @param include - Optional relations to include (sender, recipient, business) for enriched entity data
115
116
  * @returns Promise resolving to transaction data or null if not found
116
117
  * @throws Error if SDK is not initialized
117
118
  *
118
119
  * @example
119
120
  * ```typescript
120
121
  * const { getTransactionById } = useTransactions();
122
+ *
123
+ * // Basic retrieval
121
124
  * const transaction = await getTransactionById('txn-123');
122
- * console.log('Transaction details:', transaction);
125
+ *
126
+ * // With enriched sender/recipient data
127
+ * const enrichedTx = await getTransactionById('txn-123', ['sender', 'recipient', 'business']);
128
+ * console.log('Sender:', enrichedTx?.included?.sender);
129
+ * console.log('Business:', enrichedTx?.included?.engagedBusiness?.displayName);
123
130
  * ```
124
131
  */
125
- const getTransactionById = useCallback(async (transactionId) => {
132
+ const getTransactionById = useCallback(async (transactionId, include) => {
126
133
  if (!isInitialized || !sdk) {
127
134
  throw new Error('SDK not initialized. Call initialize() first.');
128
135
  }
129
136
  try {
130
- const result = await sdk.transactions.getTransactionById(transactionId);
137
+ const result = await sdk.transactions.getTransactionById(transactionId, include);
131
138
  return result;
132
139
  }
133
140
  catch (error) {
@@ -136,25 +143,48 @@ export const useTransactions = () => {
136
143
  }
137
144
  }, [sdk, isInitialized]);
138
145
  /**
139
- * Retrieves transaction history for the authenticated user, filtered by role
146
+ * Retrieves transaction history for the authenticated user with comprehensive filtering
140
147
  *
141
- * @param role - Optional transaction role filter (TransactionRole.SENDER, TransactionRole.RECIPIENT)
142
- * @returns Promise resolving to array of user's transactions
148
+ * Supports filtering by role, status, type, business, token, and more.
149
+ * Optionally enrich with related entities (sender, recipient, business).
150
+ *
151
+ * @param options - Query options including filters, pagination, and include relations
152
+ * @returns Promise resolving to paginated array of user's transactions
143
153
  * @throws Error if SDK is not initialized
144
154
  *
145
155
  * @example
146
156
  * ```typescript
147
157
  * const { getUserTransactionHistory } = useTransactions();
148
- * const sentTransactions = await getUserTransactionHistory(TransactionRole.SENDER);
149
- * const allTransactions = await getUserTransactionHistory(); // No filter
158
+ *
159
+ * // Simple: Get all transactions
160
+ * const allTransactions = await getUserTransactionHistory();
161
+ *
162
+ * // Filter by role (legacy support)
163
+ * const sentTransactions = await getUserTransactionHistory({ role: 'SENDER' });
164
+ *
165
+ * // Advanced filtering with include relations
166
+ * const filtered = await getUserTransactionHistory({
167
+ * role: 'SENDER',
168
+ * status: 'COMPLETED',
169
+ * engagedBusinessId: 'business-123',
170
+ * include: ['recipient', 'business'],
171
+ * page: 1,
172
+ * limit: 20
173
+ * });
174
+ *
175
+ * // Access enriched data
176
+ * filtered.data.forEach(tx => {
177
+ * console.log('Recipient:', tx.included?.recipient);
178
+ * console.log('Business:', tx.included?.engagedBusiness?.displayName);
179
+ * });
150
180
  * ```
151
181
  */
152
- const getUserTransactionHistory = useCallback(async (role) => {
182
+ const getUserTransactionHistory = useCallback(async (options) => {
153
183
  if (!isInitialized || !sdk) {
154
184
  throw new Error('SDK not initialized. Call initialize() first.');
155
185
  }
156
186
  try {
157
- const result = await sdk.transactions.getUserTransactionHistory(role);
187
+ const result = await sdk.transactions.getUserTransactionHistory(options);
158
188
  return result;
159
189
  }
160
190
  catch (error) {
@@ -162,25 +192,39 @@ export const useTransactions = () => {
162
192
  throw error;
163
193
  }
164
194
  }, [sdk, isInitialized]);
165
- const getTenantTransactions = useCallback(async () => {
166
- if (!isInitialized || !sdk) {
167
- throw new Error('SDK not initialized. Call initialize() first.');
168
- }
169
- try {
170
- const result = await sdk.transactions.getTenantTransactions();
171
- return result;
172
- }
173
- catch (error) {
174
- console.error('Failed to fetch tenant transactions:', error);
175
- throw error;
176
- }
177
- }, [sdk, isInitialized]);
178
- const getPaginatedTransactions = useCallback(async (params) => {
195
+ /**
196
+ * Admin: Get paginated transactions with optional include relations
197
+ *
198
+ * @param params - Pagination and filtering parameters
199
+ * @param include - Optional relations to include for enriched entity data
200
+ * @returns Promise resolving to paginated transaction results
201
+ * @throws Error if SDK is not initialized
202
+ *
203
+ * @example
204
+ * ```typescript
205
+ * const { getPaginatedTransactions } = useTransactions();
206
+ *
207
+ * // Basic pagination
208
+ * const result = await getPaginatedTransactions({ page: 1, limit: 50 });
209
+ *
210
+ * // With include relations
211
+ * const enrichedResult = await getPaginatedTransactions(
212
+ * { page: 1, limit: 50, sortBy: 'createdAt', sortOrder: 'DESC' },
213
+ * include: ['sender', 'recipient', 'business']
214
+ * });
215
+ *
216
+ * enrichedResult.data.forEach(tx => {
217
+ * console.log('From:', tx.included?.sender);
218
+ * console.log('To:', tx.included?.recipient);
219
+ * });
220
+ * ```
221
+ */
222
+ const getPaginatedTransactions = useCallback(async (options) => {
179
223
  if (!isInitialized || !sdk) {
180
224
  throw new Error('SDK not initialized. Call initialize() first.');
181
225
  }
182
226
  try {
183
- const result = await sdk.transactions.getPaginatedTransactions(params);
227
+ const result = await sdk.transactions.getPaginatedTransactions(options);
184
228
  return result;
185
229
  }
186
230
  catch (error) {
@@ -205,7 +249,6 @@ export const useTransactions = () => {
205
249
  createTransaction,
206
250
  getTransactionById,
207
251
  getUserTransactionHistory,
208
- getTenantTransactions,
209
252
  getPaginatedTransactions,
210
253
  exportTransactionsCSV,
211
254
  isAvailable: isInitialized && !!sdk?.transactions,
@@ -0,0 +1,76 @@
1
+ import type { TriggerSourceDTO, TriggerSourceCreateRequestDTO, PaginatedResponseDTO } from '@explorins/pers-shared';
2
+ import type { TriggerSourceQueryOptions } from '@explorins/pers-sdk/trigger-source';
3
+ export type { TriggerSourceQueryOptions } from '@explorins/pers-sdk/trigger-source';
4
+ /**
5
+ * React hook for TriggerSource operations in the PERS SDK
6
+ *
7
+ * Manages trigger sources which are physical or digital activation points for campaigns:
8
+ * - **QR_CODE**: Scannable QR codes at physical locations
9
+ * - **NFC_TAG**: NFC tap points for contactless interactions
10
+ * - **GPS_GEOFENCE**: Location-based triggers with radius detection
11
+ * - **API_WEBHOOK**: External system integration triggers
12
+ * - **TRANSACTION**: Purchase/payment based triggers
13
+ *
14
+ * TriggerSources are standalone entities that can be created, managed, and then
15
+ * assigned to campaigns. This separation allows reuse across multiple campaigns.
16
+ *
17
+ * **Admin Only**: All create, update, and delete operations require admin authentication.
18
+ *
19
+ * @returns TriggerSource hook with CRUD operations
20
+ *
21
+ * @example Basic TriggerSource Operations
22
+ * ```typescript
23
+ * function TriggerSourceManager() {
24
+ * const {
25
+ * getAll,
26
+ * getById,
27
+ * create,
28
+ * update,
29
+ * remove
30
+ * } = useTriggerSources();
31
+ *
32
+ * // List all QR code trigger sources
33
+ * const loadQRSources = async () => {
34
+ * const { data: sources } = await getAll({ type: 'QR_CODE' });
35
+ * console.log('QR Sources:', sources);
36
+ * };
37
+ *
38
+ * // Create a new QR code for a store
39
+ * const createStoreQR = async () => {
40
+ * const source = await create({
41
+ * type: 'QR_CODE',
42
+ * name: 'Store Entrance QR',
43
+ * description: 'Scan at the entrance',
44
+ * businessId: 'business-123',
45
+ * coordsLatitude: 47.6062,
46
+ * coordsLongitude: -122.3321
47
+ * });
48
+ * console.log('Created:', source.id);
49
+ * };
50
+ * }
51
+ * ```
52
+ *
53
+ * @example GPS Geofence Trigger
54
+ * ```typescript
55
+ * const { create } = useTriggerSources();
56
+ *
57
+ * // Create a GPS geofence around a location
58
+ * const geofence = await create({
59
+ * type: 'GPS_GEOFENCE',
60
+ * name: 'Downtown Area',
61
+ * coordsLatitude: 47.6062,
62
+ * coordsLongitude: -122.3321,
63
+ * metadata: { radiusMeters: 100 }
64
+ * });
65
+ * ```
66
+ */
67
+ export declare const useTriggerSources: () => {
68
+ getAll: (options?: TriggerSourceQueryOptions) => Promise<PaginatedResponseDTO<TriggerSourceDTO>>;
69
+ getById: (triggerSourceId: string) => Promise<TriggerSourceDTO>;
70
+ create: (triggerSource: TriggerSourceCreateRequestDTO) => Promise<TriggerSourceDTO>;
71
+ update: (triggerSourceId: string, triggerSource: Partial<TriggerSourceCreateRequestDTO>) => Promise<TriggerSourceDTO>;
72
+ remove: (triggerSourceId: string) => Promise<boolean>;
73
+ isAvailable: boolean;
74
+ };
75
+ export type TriggerSourceHook = ReturnType<typeof useTriggerSources>;
76
+ //# sourceMappingURL=useTriggerSources.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useTriggerSources.d.ts","sourceRoot":"","sources":["../../src/hooks/useTriggerSources.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,gBAAgB,EAChB,6BAA6B,EAC7B,oBAAoB,EACrB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAGpF,YAAY,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAEpF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8DG;AACH,eAAO,MAAM,iBAAiB;uBAiChB,yBAAyB,KAClC,QAAQ,qBAAqB,gBAAgB,CAAC,CAAC;+BAsC/B,MAAM,KACtB,QAAQ,gBAAgB,CAAC;4BA8CX,6BAA6B,KAC3C,QAAQ,gBAAgB,CAAC;8BAwCT,MAAM,iBACR,QAAQ,6BAA6B,CAAC,KACpD,QAAQ,gBAAgB,CAAC;8BAmCT,MAAM,KACtB,QAAQ,OAAO,CAAC;;CAyBpB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC"}
@@ -0,0 +1,272 @@
1
+ import { useCallback } from 'react';
2
+ import { usePersSDK } from '../providers/PersSDKProvider';
3
+ /**
4
+ * React hook for TriggerSource operations in the PERS SDK
5
+ *
6
+ * Manages trigger sources which are physical or digital activation points for campaigns:
7
+ * - **QR_CODE**: Scannable QR codes at physical locations
8
+ * - **NFC_TAG**: NFC tap points for contactless interactions
9
+ * - **GPS_GEOFENCE**: Location-based triggers with radius detection
10
+ * - **API_WEBHOOK**: External system integration triggers
11
+ * - **TRANSACTION**: Purchase/payment based triggers
12
+ *
13
+ * TriggerSources are standalone entities that can be created, managed, and then
14
+ * assigned to campaigns. This separation allows reuse across multiple campaigns.
15
+ *
16
+ * **Admin Only**: All create, update, and delete operations require admin authentication.
17
+ *
18
+ * @returns TriggerSource hook with CRUD operations
19
+ *
20
+ * @example Basic TriggerSource Operations
21
+ * ```typescript
22
+ * function TriggerSourceManager() {
23
+ * const {
24
+ * getAll,
25
+ * getById,
26
+ * create,
27
+ * update,
28
+ * remove
29
+ * } = useTriggerSources();
30
+ *
31
+ * // List all QR code trigger sources
32
+ * const loadQRSources = async () => {
33
+ * const { data: sources } = await getAll({ type: 'QR_CODE' });
34
+ * console.log('QR Sources:', sources);
35
+ * };
36
+ *
37
+ * // Create a new QR code for a store
38
+ * const createStoreQR = async () => {
39
+ * const source = await create({
40
+ * type: 'QR_CODE',
41
+ * name: 'Store Entrance QR',
42
+ * description: 'Scan at the entrance',
43
+ * businessId: 'business-123',
44
+ * coordsLatitude: 47.6062,
45
+ * coordsLongitude: -122.3321
46
+ * });
47
+ * console.log('Created:', source.id);
48
+ * };
49
+ * }
50
+ * ```
51
+ *
52
+ * @example GPS Geofence Trigger
53
+ * ```typescript
54
+ * const { create } = useTriggerSources();
55
+ *
56
+ * // Create a GPS geofence around a location
57
+ * const geofence = await create({
58
+ * type: 'GPS_GEOFENCE',
59
+ * name: 'Downtown Area',
60
+ * coordsLatitude: 47.6062,
61
+ * coordsLongitude: -122.3321,
62
+ * metadata: { radiusMeters: 100 }
63
+ * });
64
+ * ```
65
+ */
66
+ export const useTriggerSources = () => {
67
+ const { sdk, isInitialized, isAuthenticated } = usePersSDK();
68
+ /**
69
+ * Get trigger sources with optional filters and pagination
70
+ *
71
+ * Retrieves trigger sources (QR codes, NFC tags, GPS geofences, webhooks, etc.)
72
+ * that can be used to activate campaigns. Supports filtering by type, business,
73
+ * campaign association, and active status.
74
+ *
75
+ * @param options - Filter and pagination options
76
+ * @returns Promise resolving to paginated trigger sources
77
+ *
78
+ * @example
79
+ * ```typescript
80
+ * // Get all QR code trigger sources
81
+ * const { data: qrSources } = await getAll({ type: 'QR_CODE' });
82
+ *
83
+ * // Get trigger sources for a specific business
84
+ * const { data: businessSources, pagination } = await getAll({
85
+ * businessId: 'business-123',
86
+ * active: true,
87
+ * page: 1,
88
+ * limit: 20
89
+ * });
90
+ *
91
+ * // Get trigger sources assigned to a campaign
92
+ * const { data: campaignSources } = await getAll({
93
+ * campaignId: 'campaign-456'
94
+ * });
95
+ * ```
96
+ */
97
+ const getAll = useCallback(async (options) => {
98
+ if (!isInitialized || !sdk) {
99
+ throw new Error('SDK not initialized. Call initialize() first.');
100
+ }
101
+ try {
102
+ const result = await sdk.triggerSources.getAll(options);
103
+ return result;
104
+ }
105
+ catch (error) {
106
+ console.error('Failed to fetch trigger sources:', error);
107
+ throw error;
108
+ }
109
+ }, [sdk, isInitialized]);
110
+ /**
111
+ * Get trigger source by ID
112
+ *
113
+ * Retrieves detailed information for a specific trigger source including
114
+ * its type, location, metadata, and configuration.
115
+ *
116
+ * @param triggerSourceId - UUID of the trigger source
117
+ * @returns Promise resolving to trigger source details
118
+ * @throws {PersApiError} When trigger source with specified ID is not found
119
+ *
120
+ * @example
121
+ * ```typescript
122
+ * const source = await getById('source-123');
123
+ *
124
+ * console.log('Trigger Source:', source.name);
125
+ * console.log('Type:', source.type);
126
+ * console.log('Active:', source.isActive);
127
+ *
128
+ * if (source.coordsLatitude && source.coordsLongitude) {
129
+ * console.log('Location:', source.coordsLatitude, source.coordsLongitude);
130
+ * }
131
+ * ```
132
+ */
133
+ const getById = useCallback(async (triggerSourceId) => {
134
+ if (!isInitialized || !sdk) {
135
+ throw new Error('SDK not initialized. Call initialize() first.');
136
+ }
137
+ try {
138
+ const result = await sdk.triggerSources.getById(triggerSourceId);
139
+ return result;
140
+ }
141
+ catch (error) {
142
+ console.error('Failed to fetch trigger source:', error);
143
+ throw error;
144
+ }
145
+ }, [sdk, isInitialized]);
146
+ /**
147
+ * Admin: Create a new trigger source
148
+ *
149
+ * Creates a new trigger source (QR code, NFC tag, GPS geofence, webhook, or
150
+ * transaction-based trigger) that can be assigned to campaigns. Requires
151
+ * administrator privileges.
152
+ *
153
+ * @param triggerSource - Trigger source creation data
154
+ * @returns Promise resolving to created trigger source
155
+ * @throws {PersApiError} When not authenticated as admin or validation fails
156
+ *
157
+ * @example
158
+ * ```typescript
159
+ * // Create a QR code trigger source
160
+ * const qrSource = await create({
161
+ * type: 'QR_CODE',
162
+ * name: 'Store Entrance QR',
163
+ * description: 'QR code at main entrance',
164
+ * businessId: 'business-123',
165
+ * coordsLatitude: 47.6062,
166
+ * coordsLongitude: -122.3321
167
+ * });
168
+ *
169
+ * // Create an NFC tag trigger source
170
+ * const nfcSource = await create({
171
+ * type: 'NFC_TAG',
172
+ * name: 'Product Display NFC',
173
+ * metadata: { productId: 'SKU-12345' }
174
+ * });
175
+ * ```
176
+ */
177
+ const create = useCallback(async (triggerSource) => {
178
+ if (!isInitialized || !sdk) {
179
+ throw new Error('SDK not initialized. Call initialize() first.');
180
+ }
181
+ if (!isAuthenticated) {
182
+ throw new Error('SDK not authenticated. create requires admin authentication.');
183
+ }
184
+ try {
185
+ const result = await sdk.triggerSources.create(triggerSource);
186
+ return result;
187
+ }
188
+ catch (error) {
189
+ console.error('Failed to create trigger source:', error);
190
+ throw error;
191
+ }
192
+ }, [sdk, isInitialized, isAuthenticated]);
193
+ /**
194
+ * Admin: Update a trigger source
195
+ *
196
+ * Updates an existing trigger source's configuration. All fields are optional;
197
+ * only provided fields will be updated. Requires administrator privileges.
198
+ *
199
+ * @param triggerSourceId - UUID of the trigger source to update
200
+ * @param triggerSource - Updated trigger source data (partial)
201
+ * @returns Promise resolving to updated trigger source
202
+ * @throws {PersApiError} When not authenticated as admin or trigger source not found
203
+ *
204
+ * @example
205
+ * ```typescript
206
+ * // Update trigger source name and location
207
+ * const updated = await update('source-123', {
208
+ * name: 'Updated Store Entrance QR',
209
+ * description: 'New description',
210
+ * coordsLatitude: 47.6063,
211
+ * coordsLongitude: -122.3322
212
+ * });
213
+ * ```
214
+ */
215
+ const update = useCallback(async (triggerSourceId, triggerSource) => {
216
+ if (!isInitialized || !sdk) {
217
+ throw new Error('SDK not initialized. Call initialize() first.');
218
+ }
219
+ if (!isAuthenticated) {
220
+ throw new Error('SDK not authenticated. update requires admin authentication.');
221
+ }
222
+ try {
223
+ const result = await sdk.triggerSources.update(triggerSourceId, triggerSource);
224
+ return result;
225
+ }
226
+ catch (error) {
227
+ console.error('Failed to update trigger source:', error);
228
+ throw error;
229
+ }
230
+ }, [sdk, isInitialized, isAuthenticated]);
231
+ /**
232
+ * Admin: Delete a trigger source
233
+ *
234
+ * Soft deletes a trigger source, making it inactive. The trigger source will
235
+ * be removed from any campaigns it was assigned to. Requires administrator
236
+ * privileges.
237
+ *
238
+ * @param triggerSourceId - UUID of the trigger source to delete
239
+ * @returns Promise resolving to success status
240
+ * @throws {PersApiError} When not authenticated as admin or trigger source not found
241
+ *
242
+ * @example
243
+ * ```typescript
244
+ * const success = await remove('source-123');
245
+ * console.log('Trigger source deleted:', success);
246
+ * ```
247
+ */
248
+ const remove = useCallback(async (triggerSourceId) => {
249
+ if (!isInitialized || !sdk) {
250
+ throw new Error('SDK not initialized. Call initialize() first.');
251
+ }
252
+ if (!isAuthenticated) {
253
+ throw new Error('SDK not authenticated. remove requires admin authentication.');
254
+ }
255
+ try {
256
+ const result = await sdk.triggerSources.delete(triggerSourceId);
257
+ return result;
258
+ }
259
+ catch (error) {
260
+ console.error('Failed to delete trigger source:', error);
261
+ throw error;
262
+ }
263
+ }, [sdk, isInitialized, isAuthenticated]);
264
+ return {
265
+ getAll,
266
+ getById,
267
+ create,
268
+ update,
269
+ remove,
270
+ isAvailable: isInitialized && !!sdk?.triggerSources,
271
+ };
272
+ };
@@ -1,16 +1,17 @@
1
1
  import type { UserDTO, UserCreateRequestDTO, PaginatedResponseDTO } from '@explorins/pers-shared';
2
- import type { UserPublicProfileDTO } from '@explorins/pers-sdk/user';
2
+ import type { UserPublicProfileDTO, UserQueryOptions } from '@explorins/pers-sdk/user';
3
+ export type { UserQueryOptions } from '@explorins/pers-sdk/user';
3
4
  export declare const useUsers: () => {
4
- getCurrentUser: () => Promise<UserDTO>;
5
+ getCurrentUser: (options?: UserQueryOptions) => Promise<UserDTO>;
5
6
  updateCurrentUser: (userData: UserCreateRequestDTO) => Promise<UserDTO>;
6
- getUserById: (userId: string) => Promise<UserDTO>;
7
+ getUserById: (userId: string, options?: UserQueryOptions) => Promise<UserDTO>;
7
8
  getAllUsersPublic: (filter?: {
8
9
  key: string;
9
10
  value: string;
10
11
  }) => Promise<PaginatedResponseDTO<UserPublicProfileDTO>>;
11
12
  getAllUsers: () => Promise<PaginatedResponseDTO<UserDTO>>;
12
13
  updateUser: (userId: string, userData: UserCreateRequestDTO) => Promise<UserDTO>;
13
- toggleUserStatus: (user: UserDTO) => Promise<UserDTO>;
14
+ setUserActiveStatus: (userId: string, isActive?: boolean) => Promise<UserDTO>;
14
15
  isAvailable: boolean;
15
16
  };
16
17
  export type UserHook = ReturnType<typeof useUsers>;
@@ -1 +1 @@
1
- {"version":3,"file":"useUsers.d.ts","sourceRoot":"","sources":["../../src/hooks/useUsers.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAClG,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAErE,eAAO,MAAM,QAAQ;0BAG0B,QAAQ,OAAO,CAAC;kCAiBN,oBAAoB,KAAG,QAAQ,OAAO,CAAC;0BAiB/C,MAAM,KAAG,QAAQ,OAAO,CAAC;iCAclB;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,KAAG,QAAQ,qBAAqB,oBAAoB,CAAC,CAAC;uBAehG,QAAQ,qBAAqB,OAAO,CAAC,CAAC;yBAclC,MAAM,YAAY,oBAAoB,KAAG,QAAQ,OAAO,CAAC;6BAcrD,OAAO,KAAG,QAAQ,OAAO,CAAC;;CAwB7E,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC"}
1
+ {"version":3,"file":"useUsers.d.ts","sourceRoot":"","sources":["../../src/hooks/useUsers.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAClG,OAAO,KAAK,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAGvF,YAAY,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,eAAO,MAAM,QAAQ;+BAmBiC,gBAAgB,KAAG,QAAQ,OAAO,CAAC;kCAiBhC,oBAAoB,KAAG,QAAQ,OAAO,CAAC;0BAiC/C,MAAM,YAAY,gBAAgB,KAAG,QAAQ,OAAO,CAAC;iCAc9C;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,KAAG,QAAQ,qBAAqB,oBAAoB,CAAC,CAAC;uBAehG,QAAQ,qBAAqB,OAAO,CAAC,CAAC;yBAclC,MAAM,YAAY,oBAAoB,KAAG,QAAQ,OAAO,CAAC;kCAqBhD,MAAM,aAAa,OAAO,KAAG,QAAQ,OAAO,CAAC;;CAwBrG,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC"}
@@ -2,7 +2,23 @@ import { useCallback } from 'react';
2
2
  import { usePersSDK } from '../providers/PersSDKProvider';
3
3
  export const useUsers = () => {
4
4
  const { sdk, isInitialized, isAuthenticated } = usePersSDK();
5
- const getCurrentUser = useCallback(async () => {
5
+ /**
6
+ * Get the current authenticated user with optional include relations
7
+ *
8
+ * @param options - Query options including include relations
9
+ * @returns Current user data
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * // Basic
14
+ * const user = await getCurrentUser();
15
+ *
16
+ * // With wallets included
17
+ * const userWithWallets = await getCurrentUser({ include: ['wallets'] });
18
+ * console.log('Wallets:', userWithWallets.included?.wallets);
19
+ * ```
20
+ */
21
+ const getCurrentUser = useCallback(async (options) => {
6
22
  if (!isInitialized || !sdk) {
7
23
  throw new Error('SDK not initialized. Call initialize() first.');
8
24
  }
@@ -10,7 +26,7 @@ export const useUsers = () => {
10
26
  throw new Error('SDK not authenticated. getCurrentUser requires authentication.');
11
27
  }
12
28
  try {
13
- const result = await sdk.users.getCurrentUser();
29
+ const result = await sdk.users.getCurrentUser(options);
14
30
  return result;
15
31
  }
16
32
  catch (error) {
@@ -34,12 +50,28 @@ export const useUsers = () => {
34
50
  throw error;
35
51
  }
36
52
  }, [sdk, isInitialized, isAuthenticated]);
37
- const getUserById = useCallback(async (userId) => {
53
+ /**
54
+ * Get user by ID with optional include relations
55
+ *
56
+ * @param userId - User identifier (id, email, externalId, etc.)
57
+ * @param options - Query options including include relations
58
+ * @returns User data
59
+ *
60
+ * @example
61
+ * ```typescript
62
+ * // Basic
63
+ * const user = await getUserById('user-123');
64
+ *
65
+ * // With wallets included
66
+ * const userWithWallets = await getUserById('user-123', { include: ['wallets'] });
67
+ * ```
68
+ */
69
+ const getUserById = useCallback(async (userId, options) => {
38
70
  if (!isInitialized || !sdk) {
39
71
  throw new Error('SDK not initialized. Call initialize() first.');
40
72
  }
41
73
  try {
42
- const result = await sdk.users.getUserById(userId);
74
+ const result = await sdk.users.getUserById(userId, options);
43
75
  return result;
44
76
  }
45
77
  catch (error) {
@@ -87,16 +119,23 @@ export const useUsers = () => {
87
119
  throw error;
88
120
  }
89
121
  }, [sdk, isInitialized]);
90
- const toggleUserStatus = useCallback(async (user) => {
122
+ /**
123
+ * Toggle or set a user's active status (admin only)
124
+ *
125
+ * @param userId - User ID to update
126
+ * @param isActive - Optional explicit status. If omitted, toggles current status.
127
+ * @returns Updated user
128
+ */
129
+ const setUserActiveStatus = useCallback(async (userId, isActive) => {
91
130
  if (!isInitialized || !sdk) {
92
131
  throw new Error('SDK not initialized. Call initialize() first.');
93
132
  }
94
133
  try {
95
- const result = await sdk.users.toggleUserStatus(user);
134
+ const result = await sdk.users.setUserActiveStatus(userId, isActive);
96
135
  return result;
97
136
  }
98
137
  catch (error) {
99
- console.error('Failed to toggle user status:', error);
138
+ console.error('Failed to set user active status:', error);
100
139
  throw error;
101
140
  }
102
141
  }, [sdk, isInitialized]);
@@ -107,7 +146,7 @@ export const useUsers = () => {
107
146
  getAllUsersPublic,
108
147
  getAllUsers,
109
148
  updateUser,
110
- toggleUserStatus,
149
+ setUserActiveStatus,
111
150
  isAvailable: isInitialized && !!sdk?.users,
112
151
  };
113
152
  };
@@ -1,6 +1,7 @@
1
+ import { Web3Manager } from '@explorins/pers-sdk/web3';
1
2
  import type { TokenBalance, TokenBalanceRequest, TokenCollectionRequest, TokenCollection, TokenMetadata, AccountOwnedTokensResult } from '@explorins/pers-sdk/web3';
2
- import type { ChainData } from '@explorins/pers-sdk/web3-chain';
3
- import type { TokenDTO } from '@explorins/pers-shared';
3
+ import type { TokenDTO } from '@explorins/pers-sdk/token';
4
+ type ChainData = Awaited<ReturnType<Web3Manager['getChainDataById']>>;
4
5
  export type { AccountOwnedTokensResult } from '@explorins/pers-sdk/web3';
5
6
  /**
6
7
  * React hook for Web3 operations in the PERS SDK
@@ -56,9 +57,9 @@ export declare const useWeb3: () => {
56
57
  getTokenBalance: (request: TokenBalanceRequest) => Promise<TokenBalance>;
57
58
  getTokenMetadata: (request: TokenBalanceRequest) => Promise<TokenMetadata | null>;
58
59
  getTokenCollection: (request: TokenCollectionRequest) => Promise<TokenCollection>;
59
- resolveIPFSUrl: (url: string, chainId: number) => Promise<string>;
60
- fetchAndProcessMetadata: (tokenUri: string, chainId: number) => Promise<TokenMetadata | null>;
61
- getChainDataById: (chainId: number) => Promise<ChainData | null>;
60
+ resolveIPFSUrl: (url: string) => Promise<string>;
61
+ fetchAndProcessMetadata: (tokenUri: string) => Promise<TokenMetadata | null>;
62
+ getChainDataById: (chainId: number) => Promise<ChainData>;
62
63
  getExplorerUrl: (chainId: number, address: string, type: 'address' | 'tx') => Promise<string>;
63
64
  extractTokenIds: (token: TokenDTO) => string[] | undefined;
64
65
  getAccountOwnedTokensFromContract: (accountAddress: string, token: TokenDTO, maxTokens?: number) => Promise<AccountOwnedTokensResult>;
@@ -1 +1 @@
1
- {"version":3,"file":"useWeb3.d.ts","sourceRoot":"","sources":["../../src/hooks/useWeb3.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,YAAY,EACZ,mBAAmB,EACnB,sBAAsB,EACtB,eAAe,EACf,aAAa,EACb,wBAAwB,EACzB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAGvD,YAAY,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AAEzE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,eAAO,MAAM,OAAO;+BAmCkC,mBAAmB,KAAG,QAAQ,YAAY,CAAC;gCAiC1C,mBAAmB,KAAG,QAAQ,aAAa,GAAG,IAAI,CAAC;kCAcjD,sBAAsB,KAAG,QAAQ,eAAe,CAAC;0BAczD,MAAM,WAAW,MAAM,KAAG,QAAQ,MAAM,CAAC;wCAc3B,MAAM,WAAW,MAAM,KAAG,QAAQ,aAAa,GAAG,IAAI,CAAC;gCAc/D,MAAM,KAAG,QAAQ,SAAS,GAAG,IAAI,CAAC;8BAcpC,MAAM,WAAW,MAAM,QAAQ,SAAS,GAAG,IAAI,KAAG,QAAQ,MAAM,CAAC;6BAiCxE,QAAQ,KAAG,MAAM,EAAE,GAAG,SAAS;wDAuCzD,MAAM,SACf,QAAQ,cACJ,MAAM,KAChB,QAAQ,wBAAwB,CAAC;6CAqBlB,MAAM,SACf,QAAQ,cACJ,MAAM,KAChB,sBAAsB;;CAqB1B,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG,UAAU,CAAC,OAAO,OAAO,CAAC,CAAC"}
1
+ {"version":3,"file":"useWeb3.d.ts","sourceRoot":"","sources":["../../src/hooks/useWeb3.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,KAAK,EACV,YAAY,EACZ,mBAAmB,EACnB,sBAAsB,EACtB,eAAe,EACf,aAAa,EACb,wBAAwB,EACzB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAG1D,KAAK,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC;AAGtE,YAAY,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AAEzE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,eAAO,MAAM,OAAO;+BAmCkC,mBAAmB,KAAG,QAAQ,YAAY,CAAC;gCAiC1C,mBAAmB,KAAG,QAAQ,aAAa,GAAG,IAAI,CAAC;kCAcjD,sBAAsB,KAAG,QAAQ,eAAe,CAAC;0BAqBzD,MAAM,KAAG,QAAQ,MAAM,CAAC;wCAoBV,MAAM,KAAG,QAAQ,aAAa,GAAG,IAAI,CAAC;gCAc9C,MAAM,KAAG,QAAQ,SAAS,CAAC;8BAc7B,MAAM,WAAW,MAAM,QAAQ,SAAS,GAAG,IAAI,KAAG,QAAQ,MAAM,CAAC;6BAiCxE,QAAQ,KAAG,MAAM,EAAE,GAAG,SAAS;wDAuCzD,MAAM,SACf,QAAQ,cACJ,MAAM,KAChB,QAAQ,wBAAwB,CAAC;6CAqBlB,MAAM,SACf,QAAQ,cACJ,MAAM,KAChB,sBAAsB;;CAqB1B,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG,UAAU,CAAC,OAAO,OAAO,CAAC,CAAC"}