@explorins/pers-sdk-react-native 2.3.2 → 2.3.3
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/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +153 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +5 -0
package/dist/index.d.ts
CHANGED
|
@@ -137,6 +137,7 @@ export { PersSDKProvider, usePersSDK, type PersConfig, type PersSDKContext } fro
|
|
|
137
137
|
*
|
|
138
138
|
* **Business & Campaign Management:**
|
|
139
139
|
* - `useBusiness` - Business profile and operations
|
|
140
|
+
* - `useBookings` - Booking management with status validation
|
|
140
141
|
* - `useCampaigns` - Marketing campaigns and promotions
|
|
141
142
|
* - `useRedemptions` - Reward redemption and fulfillment
|
|
142
143
|
*
|
|
@@ -207,7 +208,7 @@ export { PersSDKProvider, usePersSDK, type PersConfig, type PersSDKContext } fro
|
|
|
207
208
|
* }
|
|
208
209
|
* ```
|
|
209
210
|
*/
|
|
210
|
-
export { useAuth, useTokens, useTokenBalances, useTransactions, useTransactionSigner, SigningStatus, useBusiness, useCampaigns, useRedemptions, useWeb3, usePurchases, useTenants, useUsers, useUserStatus, useFiles, useAnalytics, useDonations, useEvents, useTriggerSources, useResolvedUrl, useMetadata, useIPFSUrl, // alias for useResolvedUrl
|
|
211
|
+
export { useAuth, useTokens, useTokenBalances, useTransactions, useTransactionSigner, SigningStatus, useBusiness, useBookings, useCampaigns, useRedemptions, useWeb3, usePurchases, useTenants, useUsers, useUserStatus, useFiles, useAnalytics, useDonations, useEvents, useTriggerSources, useResolvedUrl, useMetadata, useIPFSUrl, // alias for useResolvedUrl
|
|
211
212
|
useTransactionMetadata } from './hooks';
|
|
212
213
|
export type { TransactionSignerHook, OnStatusUpdateFn, StatusUpdateData, SigningStatusType, TransactionSigningResult, SubmissionResult, AuthenticatedUser } from './hooks';
|
|
213
214
|
export type { EventsHook, PersEvent, EventHandler, EventFilter, Unsubscribe } from './hooks';
|
|
@@ -218,6 +219,7 @@ export type { BusinessFilterOptions, BusinessHook } from './hooks';
|
|
|
218
219
|
export type { TransactionQueryOptions, TransactionHook } from './hooks';
|
|
219
220
|
export type { TriggerSourceQueryOptions, TriggerSourceHook } from './hooks';
|
|
220
221
|
export type { AnalyticsHook } from './hooks';
|
|
222
|
+
export type { BookingHook, BookingQueryOptions, BookingValidationOptions } from './hooks';
|
|
221
223
|
/**
|
|
222
224
|
* React Native-optimized HTTP client with automatic request/response handling
|
|
223
225
|
*
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,gCAAgC,CAAC;AAExC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAGH,OAAO,aAAa,CAAC;AAMrB;;;;;;;;GAQG;AACH,OAAO,EACL,6BAA6B,EAC7B,KAAK,qBAAqB,EAC3B,MAAM,wCAAwC,CAAC;AAMhD;;;;;;;;;;GAUG;AACH,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AAEvE;;;;;;;;GAQG;AACH,OAAO,EACL,wBAAwB,GACzB,MAAM,uCAAuC,CAAC;AAM/C;;;GAGG;AACH,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAMvE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,OAAO,EACL,eAAe,EACf,UAAU,EACV,KAAK,UAAU,EACf,KAAK,cAAc,EACpB,MAAM,6BAA6B,CAAC;AAMrC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,gCAAgC,CAAC;AAExC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAGH,OAAO,aAAa,CAAC;AAM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
50325
|
+
/**
|
|
50326
|
+
* React hook for booking management operations
|
|
50327
|
+
*
|
|
50328
|
+
* Provides methods to create, read, update, and delete bookings,
|
|
50329
|
+
* as well as checking if a user has a valid booking for redemption eligibility.
|
|
50330
|
+
*
|
|
50331
|
+
* @example
|
|
50332
|
+
* ```typescript
|
|
50333
|
+
* import { useBookings } from '@explorins/pers-sdk-react-native';
|
|
50334
|
+
*
|
|
50335
|
+
* function BookingScreen() {
|
|
50336
|
+
* const { getBookings, createBooking, hasValidBooking } = useBookings();
|
|
50337
|
+
*
|
|
50338
|
+
* // List all bookings for a user
|
|
50339
|
+
* const userBookings = await getBookings({ userId: 'user-123' });
|
|
50340
|
+
*
|
|
50341
|
+
* // Create a booking
|
|
50342
|
+
* const newBooking = await createBooking({
|
|
50343
|
+
* userId: 'user-123',
|
|
50344
|
+
* locationName: 'Resort Hotel',
|
|
50345
|
+
* checkInDate: '2026-06-01',
|
|
50346
|
+
* checkOutDate: '2026-06-05'
|
|
50347
|
+
* });
|
|
50348
|
+
*
|
|
50349
|
+
* // Check if user has valid booking for redemption
|
|
50350
|
+
* const isEligible = await hasValidBooking('user-123', { status: 'active' });
|
|
50351
|
+
* }
|
|
50352
|
+
* ```
|
|
50353
|
+
*/
|
|
50354
|
+
const useBookings = () => {
|
|
50355
|
+
const { sdk, isInitialized, isAuthenticated } = usePersSDK();
|
|
50356
|
+
/**
|
|
50357
|
+
* Get all bookings with optional filters
|
|
50358
|
+
*
|
|
50359
|
+
* @param options - Query options including userId, businessId, status filters
|
|
50360
|
+
* @returns Array of booking DTOs
|
|
50361
|
+
*/
|
|
50362
|
+
const getBookings = react.useCallback(async (options) => {
|
|
50363
|
+
if (!isInitialized || !sdk) {
|
|
50364
|
+
throw new Error('SDK not initialized. Call initialize() first.');
|
|
50365
|
+
}
|
|
50366
|
+
try {
|
|
50367
|
+
return await sdk.bookings.getAll(options);
|
|
50368
|
+
}
|
|
50369
|
+
catch (error) {
|
|
50370
|
+
console.error('Failed to fetch bookings:', error);
|
|
50371
|
+
throw error;
|
|
50372
|
+
}
|
|
50373
|
+
}, [sdk, isInitialized]);
|
|
50374
|
+
/**
|
|
50375
|
+
* Get a single booking by ID
|
|
50376
|
+
*
|
|
50377
|
+
* @param id - Booking UUID
|
|
50378
|
+
* @returns Booking DTO
|
|
50379
|
+
*/
|
|
50380
|
+
const getBookingById = react.useCallback(async (id) => {
|
|
50381
|
+
if (!isInitialized || !sdk) {
|
|
50382
|
+
throw new Error('SDK not initialized. Call initialize() first.');
|
|
50383
|
+
}
|
|
50384
|
+
try {
|
|
50385
|
+
return await sdk.bookings.getById(id);
|
|
50386
|
+
}
|
|
50387
|
+
catch (error) {
|
|
50388
|
+
console.error('Failed to fetch booking:', error);
|
|
50389
|
+
throw error;
|
|
50390
|
+
}
|
|
50391
|
+
}, [sdk, isInitialized]);
|
|
50392
|
+
/**
|
|
50393
|
+
* Create a new booking
|
|
50394
|
+
*
|
|
50395
|
+
* @param data - Booking data including userId, locationName, dates
|
|
50396
|
+
* @returns Created booking DTO
|
|
50397
|
+
*/
|
|
50398
|
+
const createBooking = react.useCallback(async (data) => {
|
|
50399
|
+
if (!isInitialized || !sdk) {
|
|
50400
|
+
throw new Error('SDK not initialized. Call initialize() first.');
|
|
50401
|
+
}
|
|
50402
|
+
try {
|
|
50403
|
+
return await sdk.bookings.create(data);
|
|
50404
|
+
}
|
|
50405
|
+
catch (error) {
|
|
50406
|
+
console.error('Failed to create booking:', error);
|
|
50407
|
+
throw error;
|
|
50408
|
+
}
|
|
50409
|
+
}, [sdk, isInitialized]);
|
|
50410
|
+
/**
|
|
50411
|
+
* Update an existing booking
|
|
50412
|
+
*
|
|
50413
|
+
* @param id - Booking UUID
|
|
50414
|
+
* @param data - Partial booking data to update
|
|
50415
|
+
* @returns Updated booking DTO
|
|
50416
|
+
*/
|
|
50417
|
+
const updateBooking = react.useCallback(async (id, data) => {
|
|
50418
|
+
if (!isInitialized || !sdk) {
|
|
50419
|
+
throw new Error('SDK not initialized. Call initialize() first.');
|
|
50420
|
+
}
|
|
50421
|
+
try {
|
|
50422
|
+
return await sdk.bookings.update(id, data);
|
|
50423
|
+
}
|
|
50424
|
+
catch (error) {
|
|
50425
|
+
console.error('Failed to update booking:', error);
|
|
50426
|
+
throw error;
|
|
50427
|
+
}
|
|
50428
|
+
}, [sdk, isInitialized]);
|
|
50429
|
+
/**
|
|
50430
|
+
* Delete a booking
|
|
50431
|
+
*
|
|
50432
|
+
* @param id - Booking UUID
|
|
50433
|
+
*/
|
|
50434
|
+
const deleteBooking = react.useCallback(async (id) => {
|
|
50435
|
+
if (!isInitialized || !sdk) {
|
|
50436
|
+
throw new Error('SDK not initialized. Call initialize() first.');
|
|
50437
|
+
}
|
|
50438
|
+
try {
|
|
50439
|
+
await sdk.bookings.delete(id);
|
|
50440
|
+
}
|
|
50441
|
+
catch (error) {
|
|
50442
|
+
console.error('Failed to delete booking:', error);
|
|
50443
|
+
throw error;
|
|
50444
|
+
}
|
|
50445
|
+
}, [sdk, isInitialized]);
|
|
50446
|
+
/**
|
|
50447
|
+
* Check if a user has a valid booking
|
|
50448
|
+
*
|
|
50449
|
+
* @param userId - User ID to check
|
|
50450
|
+
* @param options - Validation options including status filter
|
|
50451
|
+
* @returns true if user has valid booking matching criteria
|
|
50452
|
+
*/
|
|
50453
|
+
const hasValidBooking = react.useCallback(async (userId, options) => {
|
|
50454
|
+
if (!isInitialized || !sdk) {
|
|
50455
|
+
throw new Error('SDK not initialized. Call initialize() first.');
|
|
50456
|
+
}
|
|
50457
|
+
try {
|
|
50458
|
+
return await sdk.bookings.hasValidBooking(userId, options);
|
|
50459
|
+
}
|
|
50460
|
+
catch (error) {
|
|
50461
|
+
console.error('Failed to check booking validity:', error);
|
|
50462
|
+
throw error;
|
|
50463
|
+
}
|
|
50464
|
+
}, [sdk, isInitialized]);
|
|
50465
|
+
return {
|
|
50466
|
+
getBookings,
|
|
50467
|
+
getBookingById,
|
|
50468
|
+
createBooking,
|
|
50469
|
+
updateBooking,
|
|
50470
|
+
deleteBooking,
|
|
50471
|
+
hasValidBooking,
|
|
50472
|
+
isInitialized,
|
|
50473
|
+
isAuthenticated,
|
|
50474
|
+
};
|
|
50475
|
+
};
|
|
50476
|
+
|
|
50325
50477
|
exports.ACTIVE_USER_DEFINITION = ACTIVE_USER_DEFINITION;
|
|
50326
50478
|
exports.ANALYTICS_GROUP_BY_TYPES = ANALYTICS_GROUP_BY_TYPES;
|
|
50327
50479
|
exports.ANALYTICS_METRIC_TYPES = ANALYTICS_METRIC_TYPES;
|
|
@@ -50558,6 +50710,7 @@ exports.testnetShortPrefix = testnetShortPrefix;
|
|
|
50558
50710
|
exports.uniqueUserIdentifierKeys = uniqueUserIdentifierKeys;
|
|
50559
50711
|
exports.useAnalytics = useAnalytics;
|
|
50560
50712
|
exports.useAuth = useAuth;
|
|
50713
|
+
exports.useBookings = useBookings;
|
|
50561
50714
|
exports.useBusiness = useBusiness;
|
|
50562
50715
|
exports.useCampaigns = useCampaigns;
|
|
50563
50716
|
exports.useDonations = useDonations;
|