@explorins/pers-sdk-react-native 2.3.7 → 2.3.8

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 (58) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1266 -1244
  3. package/dist/__tests__/PersSDKProvider.test.js +33 -0
  4. package/dist/hooks/useBusiness.d.ts +2 -2
  5. package/dist/hooks/useBusiness.d.ts.map +1 -1
  6. package/dist/hooks/useBusiness.js +2 -2
  7. package/dist/hooks/useIPFSUrl.d.ts +3 -3
  8. package/dist/hooks/useIPFSUrl.d.ts.map +1 -1
  9. package/dist/hooks/useIPFSUrl.js +7 -7
  10. package/dist/hooks/useWeb3.js +4 -4
  11. package/dist/index.js +2400 -487
  12. package/dist/index.js.map +1 -1
  13. package/dist/providers/PersSDKProvider.d.ts +4 -0
  14. package/dist/providers/PersSDKProvider.d.ts.map +1 -1
  15. package/dist/providers/PersSDKProvider.js +14 -0
  16. package/dist/providers/react-native-http-client.d.ts +2 -0
  17. package/dist/providers/react-native-http-client.d.ts.map +1 -1
  18. package/dist/providers/react-native-http-client.js +5 -2
  19. package/dist/storage/rn-secure-storage.d.ts.map +1 -1
  20. package/dist/storage/rn-secure-storage.js +21 -8
  21. package/package.json +3 -3
  22. package/src/__tests__/PersSDKProvider.test.tsx +484 -420
  23. package/src/__tests__/setup.ts +40 -40
  24. package/src/hooks/index.ts +60 -60
  25. package/src/hooks/useAnalytics.ts +327 -327
  26. package/src/hooks/useAuth.ts +265 -265
  27. package/src/hooks/useBookings.ts +191 -191
  28. package/src/hooks/useBusiness.ts +251 -251
  29. package/src/hooks/useCampaigns.ts +500 -500
  30. package/src/hooks/useDonations.ts +66 -66
  31. package/src/hooks/useEvents.ts +372 -372
  32. package/src/hooks/useFiles.ts +155 -155
  33. package/src/hooks/useIPFSUrl.ts +192 -192
  34. package/src/hooks/usePurchases.ts +65 -65
  35. package/src/hooks/useRedemptions.ts +467 -467
  36. package/src/hooks/useTenants.ts +72 -72
  37. package/src/hooks/useTokenBalances.ts +385 -385
  38. package/src/hooks/useTokens.ts +313 -313
  39. package/src/hooks/useTransactionSigner.ts +611 -611
  40. package/src/hooks/useTransactions.ts +299 -299
  41. package/src/hooks/useTriggerSources.ts +301 -301
  42. package/src/hooks/useUserStatus.ts +61 -61
  43. package/src/hooks/useUsers.ts +167 -167
  44. package/src/hooks/useWeb3.ts +355 -355
  45. package/src/index.ts +777 -777
  46. package/src/polyfills/index.ts +160 -160
  47. package/src/polyfills/web3-polyfills.ts +97 -97
  48. package/src/providers/PersSDKProvider.tsx +393 -374
  49. package/src/providers/react-native-auth-provider.ts +110 -110
  50. package/src/providers/react-native-http-client.ts +150 -145
  51. package/src/providers/rn-dpop-provider.ts +190 -190
  52. package/src/storage/async-storage-token-storage.ts +185 -185
  53. package/src/storage/rn-secure-storage.ts +182 -170
  54. package/src/types/react-native-globals.d.ts +45 -45
  55. package/src/utils/index.ts +8 -8
  56. package/src/utils/platform-detection.ts +86 -86
  57. package/dist/index-CzLxqePZ.js +0 -7717
  58. package/dist/index-CzLxqePZ.js.map +0 -1
@@ -1,301 +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-sdk';
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
+ import { useCallback } from 'react';
2
+ import { usePersSDK } from '../providers/PersSDKProvider';
3
+ import type {
4
+ TriggerSourceDTO,
5
+ TriggerSourceCreateRequestDTO,
6
+ PaginatedResponseDTO
7
+ } from '@explorins/pers-sdk';
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>;