@explorins/pers-sdk-react-native 2.3.0-alpha.2 → 2.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +84 -0
- package/dist/hooks/useRedemptions.d.ts +7 -3
- package/dist/hooks/useRedemptions.d.ts.map +1 -1
- package/dist/hooks/useRedemptions.js +7 -1
- package/dist/hooks/useTokens.d.ts +2 -2
- package/dist/hooks/useTokens.d.ts.map +1 -1
- package/dist/index.d.ts +155 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1025 -72
- package/dist/index.js.map +1 -1
- package/dist/providers/PersSDKProvider.d.ts.map +1 -1
- package/dist/providers/PersSDKProvider.js +17 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +4 -0
- package/dist/utils/platform-detection.d.ts +35 -0
- package/dist/utils/platform-detection.d.ts.map +1 -0
- package/dist/utils/platform-detection.js +79 -0
- package/package.json +7 -3
- package/src/hooks/useRedemptions.ts +16 -5
- package/src/index.ts +202 -1
- package/src/providers/PersSDKProvider.tsx +19 -0
- package/src/utils/index.ts +8 -0
- package/src/utils/platform-detection.ts +86 -0
package/README.md
CHANGED
|
@@ -871,6 +871,90 @@ if (transaction.txType === ClientTransactionType.PENDING_SUBMISSION) {
|
|
|
871
871
|
- **Expo**: Compatible with Expo managed workflow
|
|
872
872
|
- **Web**: React Native Web compatibility
|
|
873
873
|
|
|
874
|
+
---
|
|
875
|
+
|
|
876
|
+
## Analytics & Attribution Tracking
|
|
877
|
+
|
|
878
|
+
The SDK provides built-in analytics tracking for user acquisition and engagement. The `PersSDKProvider` **automatically detects the platform** (iOS/Android) and sends tracking headers with all API requests.
|
|
879
|
+
|
|
880
|
+
### Automatic Platform Detection
|
|
881
|
+
|
|
882
|
+
When you wrap your app with `PersSDKProvider`, platform info is auto-detected:
|
|
883
|
+
|
|
884
|
+
```typescript
|
|
885
|
+
// Platform is automatically detected and set:
|
|
886
|
+
// { os: 'iOS', osVersion: '17.4', deviceType: 'phone', app: 'MyApp' }
|
|
887
|
+
```
|
|
888
|
+
|
|
889
|
+
### Manual Data Source Tracking
|
|
890
|
+
|
|
891
|
+
For campaign attribution, use `usePersSDK()` to set custom tracking data:
|
|
892
|
+
|
|
893
|
+
```typescript
|
|
894
|
+
import { usePersSDK } from '@explorins/pers-sdk-react-native';
|
|
895
|
+
import { Linking } from 'react-native';
|
|
896
|
+
|
|
897
|
+
function DeepLinkHandler() {
|
|
898
|
+
const { sdk } = usePersSDK();
|
|
899
|
+
|
|
900
|
+
useEffect(() => {
|
|
901
|
+
// Handle deep links with UTM params
|
|
902
|
+
Linking.getInitialURL().then(url => {
|
|
903
|
+
if (url) {
|
|
904
|
+
const params = new URL(url).searchParams;
|
|
905
|
+
|
|
906
|
+
sdk.setDataSource({
|
|
907
|
+
channel: 'mobile',
|
|
908
|
+
medium: params.get('utm_medium') || undefined,
|
|
909
|
+
campaign: params.get('utm_campaign') || undefined,
|
|
910
|
+
source: params.get('utm_source') || undefined,
|
|
911
|
+
});
|
|
912
|
+
}
|
|
913
|
+
});
|
|
914
|
+
}, [sdk]);
|
|
915
|
+
}
|
|
916
|
+
```
|
|
917
|
+
|
|
918
|
+
### HTTP Headers Sent
|
|
919
|
+
|
|
920
|
+
The SDK automatically sends tracking data as HTTP headers:
|
|
921
|
+
|
|
922
|
+
| Header | Source | Description |
|
|
923
|
+
|--------|--------|-------------|
|
|
924
|
+
| `x-source-channel` | `dataSource.channel` | `'mobile'` for native apps |
|
|
925
|
+
| `x-source-medium` | `dataSource.medium` | Traffic medium (push, email, etc.) |
|
|
926
|
+
| `x-source-campaign` | `dataSource.campaign` | Campaign identifier |
|
|
927
|
+
| `x-source` | `dataSource.source` | Traffic source |
|
|
928
|
+
| `x-platform` | Auto-detected | JSON: `{ os, osVersion, deviceType, app }` |
|
|
929
|
+
|
|
930
|
+
### Push Notification Attribution
|
|
931
|
+
|
|
932
|
+
Track users coming from push notifications:
|
|
933
|
+
|
|
934
|
+
```typescript
|
|
935
|
+
import { usePersSDK } from '@explorins/pers-sdk-react-native';
|
|
936
|
+
|
|
937
|
+
function usePushNotificationTracking() {
|
|
938
|
+
const { sdk } = usePersSDK();
|
|
939
|
+
|
|
940
|
+
const handlePushNotification = (notification: any) => {
|
|
941
|
+
// Extract campaign from notification data
|
|
942
|
+
const campaignId = notification.data?.campaignId;
|
|
943
|
+
|
|
944
|
+
if (campaignId) {
|
|
945
|
+
sdk.updateDataSource({
|
|
946
|
+
medium: 'push',
|
|
947
|
+
campaign: campaignId,
|
|
948
|
+
});
|
|
949
|
+
}
|
|
950
|
+
};
|
|
951
|
+
|
|
952
|
+
return { handlePushNotification };
|
|
953
|
+
}
|
|
954
|
+
```
|
|
955
|
+
|
|
956
|
+
---
|
|
957
|
+
|
|
874
958
|
## Advanced Configuration
|
|
875
959
|
|
|
876
960
|
### SDK Initialization & DPoP
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { OnStatusUpdateFn } from './useTransactionSigner';
|
|
2
2
|
import type { RedemptionCreateRequestDTO, RedemptionDTO, RedemptionRedeemDTO, RedemptionRedeemRequestResponseDTO, RedemptionTypeDTO, PaginatedResponseDTO, RedemptionRedeemIncludeRelation, RedemptionIncludeRelation, ProcessRecordStatus, DynamicContext, SortOrder } from '@explorins/pers-sdk';
|
|
3
|
-
import type {
|
|
3
|
+
import type { RedemptionRedeemQueryParams, RedemptionQueryParams } from '@explorins/pers-sdk/redemption';
|
|
4
4
|
import type { PaginationOptions } from '@explorins/pers-sdk';
|
|
5
|
-
export type {
|
|
5
|
+
export type { RedemptionRedeemQueryParams, RedemptionQueryParams } from '@explorins/pers-sdk/redemption';
|
|
6
|
+
/** @deprecated Use RedemptionRedeemQueryParams instead */
|
|
7
|
+
export type RedemptionRedeemFilters = RedemptionRedeemQueryParams;
|
|
8
|
+
/** @deprecated Use RedemptionQueryParams instead */
|
|
9
|
+
export type RedemptionFilterOptions = RedemptionQueryParams;
|
|
6
10
|
/**
|
|
7
11
|
* Options for fetching redemptions with filtering and pagination
|
|
8
12
|
*/
|
|
@@ -40,7 +44,7 @@ export declare const useRedemptions: () => {
|
|
|
40
44
|
onStatusUpdate?: OnStatusUpdateFn;
|
|
41
45
|
}) => Promise<RedemptionRedeemRequestResponseDTO>;
|
|
42
46
|
getRedemptionTypes: () => Promise<PaginatedResponseDTO<RedemptionTypeDTO>>;
|
|
43
|
-
getRedemptionRedeems: (filters?:
|
|
47
|
+
getRedemptionRedeems: (filters?: RedemptionRedeemQueryParams, include?: RedemptionRedeemIncludeRelation[]) => Promise<PaginatedResponseDTO<RedemptionRedeemDTO>>;
|
|
44
48
|
createRedemption: (redemptionData: RedemptionCreateRequestDTO) => Promise<RedemptionDTO>;
|
|
45
49
|
updateRedemption: (redemptionId: string, redemptionData: RedemptionCreateRequestDTO) => Promise<RedemptionDTO>;
|
|
46
50
|
toggleRedemptionStatus: (redemptionId: string) => Promise<RedemptionDTO>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRedemptions.d.ts","sourceRoot":"","sources":["../../src/hooks/useRedemptions.ts"],"names":[],"mappings":"AAEA,OAAO,EAA0C,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAClG,OAAO,KAAK,EACV,0BAA0B,EAC1B,aAAa,EACb,mBAAmB,EACnB,kCAAkC,EAClC,iBAAiB,EACjB,oBAAoB,EACpB,+BAA+B,EAC/B,yBAAyB,EACzB,mBAAmB,EACnB,cAAc,EACd,SAAS,EACV,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"useRedemptions.d.ts","sourceRoot":"","sources":["../../src/hooks/useRedemptions.ts"],"names":[],"mappings":"AAEA,OAAO,EAA0C,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAClG,OAAO,KAAK,EACV,0BAA0B,EAC1B,aAAa,EACb,mBAAmB,EACnB,kCAAkC,EAClC,iBAAiB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EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,mBAAmB,CAAA;KAAE,YACvD,iBAAiB,YACjB,+BAA+B,EAAE,KAC1C,QAAQ,qBAAqB,mBAAmB,CAAC,CAAC;2BAiGrC,MAAM,YACV;QAAE,OAAO,CAAC,EAAE,cAAc,CAAC;QAAC,cAAc,CAAC,EAAE,gBAAgB,CAAA;KAAE,KACxE,QAAQ,kCAAkC,CAAC;8BAmHG,QAAQ,qBAAqB,iBAAiB,CAAC,CAAC;qCA9BrF,2BAA2B,YAC3B,+BAA+B,EAAE,KAC1C,QAAQ,qBAAqB,mBAAmB,CAAC,CAAC;uCAcO,0BAA0B,KAAG,QAAQ,aAAa,CAAC;qCA4BrD,MAAM,kBAAkB,0BAA0B,KAAG,QAAQ,aAAa,CAAC;2CAcrE,MAAM,KAAG,QAAQ,aAAa,CAAC;;;;CAmEhG,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC"}
|
|
@@ -58,7 +58,13 @@ export const useRedemptions = () => {
|
|
|
58
58
|
throw new Error('SDK not initialized. Call initialize() first.');
|
|
59
59
|
}
|
|
60
60
|
try {
|
|
61
|
-
|
|
61
|
+
// Convert Date to ISO string for API compatibility
|
|
62
|
+
const apiOptions = options ? {
|
|
63
|
+
...options,
|
|
64
|
+
startDate: options.startDate instanceof Date ? options.startDate.toISOString() : options.startDate,
|
|
65
|
+
endDate: options.endDate instanceof Date ? options.endDate.toISOString() : options.endDate,
|
|
66
|
+
} : undefined;
|
|
67
|
+
const result = await sdk.redemptions.getRedemptions(apiOptions);
|
|
62
68
|
return result;
|
|
63
69
|
}
|
|
64
70
|
catch (error) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { TokenDTO, TokenMetadataDTO, PaginatedResponseDTO } from '@explorins/pers-sdk';
|
|
1
|
+
import type { TokenDTO, TokenMetadataDTO, PaginatedResponseDTO, TokenMetadataFilterOptions } from '@explorins/pers-sdk';
|
|
2
2
|
/**
|
|
3
3
|
* React hook for token operations in the PERS SDK
|
|
4
4
|
*
|
|
@@ -34,7 +34,7 @@ export declare const useTokens: () => {
|
|
|
34
34
|
getTokenTypes: () => Promise<any>;
|
|
35
35
|
getStatusTokens: () => Promise<PaginatedResponseDTO<TokenDTO>>;
|
|
36
36
|
getTokenByContract: (contractAddress: string, contractTokenId?: string | null) => Promise<TokenDTO>;
|
|
37
|
-
getTokenMetadata: (options?:
|
|
37
|
+
getTokenMetadata: (options?: TokenMetadataFilterOptions) => Promise<PaginatedResponseDTO<TokenMetadataDTO>>;
|
|
38
38
|
getRewards: (options?: any) => Promise<PaginatedResponseDTO<TokenMetadataDTO>>;
|
|
39
39
|
getStamps: (options?: any) => Promise<PaginatedResponseDTO<TokenMetadataDTO>>;
|
|
40
40
|
isAvailable: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTokens.d.ts","sourceRoot":"","sources":["../../src/hooks/useTokens.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAE,oBAAoB,
|
|
1
|
+
{"version":3,"file":"useTokens.d.ts","sourceRoot":"","sources":["../../src/hooks/useTokens.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,0BAA0B,EAA6C,MAAM,qBAAqB,CAAC;AAEnK;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,SAAS;qBAoBoB,QAAQ,qBAAqB,QAAQ,CAAC,CAAC;gCA2B5B,QAAQ,QAAQ,CAAC;2BA2BtB,QAAQ,qBAAqB,QAAQ,CAAC,CAAC;yBA2BzC,QAAQ,GAAG,CAAC;2BA2BV,QAAQ,qBAAqB,QAAQ,CAAC,CAAC;0CA6BtB,MAAM,oBAAoB,MAAM,GAAG,IAAI,KAAG,QAAQ,QAAQ,CAAC;iCAkCpE,0BAA0B,KAAG,QAAQ,qBAAqB,gBAAgB,CAAC,CAAC;mCA+B3D,QAAQ,qBAAqB,gBAAgB,CAAC,CAAC;kCA+BjD,QAAQ,qBAAqB,gBAAgB,CAAC,CAAC;;CA0BrH,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import 'react-native-url-polyfill/auto';
|
|
1
2
|
/**
|
|
2
3
|
* @fileoverview PERS SDK for React Native - Tourism Loyalty System
|
|
3
4
|
*
|
|
@@ -413,4 +414,158 @@ export type { POSAuthorizationOptions, PendingTransactionParams } from '@explori
|
|
|
413
414
|
* ```
|
|
414
415
|
*/
|
|
415
416
|
export { PersApiError, AuthenticationError, ErrorUtils } from '@explorins/pers-sdk/core';
|
|
417
|
+
/**
|
|
418
|
+
* Data source tracking utilities for attribution analytics
|
|
419
|
+
*
|
|
420
|
+
* Native apps MUST configure data source and platform info for proper attribution.
|
|
421
|
+
* Web apps benefit from auto-detection, but can still set explicit values.
|
|
422
|
+
*
|
|
423
|
+
* @example
|
|
424
|
+
* **React Native Setup:**
|
|
425
|
+
* ```typescript
|
|
426
|
+
* import { usePersSDK, detectReactNativePlatform } from '@explorins/pers-sdk-react-native';
|
|
427
|
+
*
|
|
428
|
+
* const { sdk } = usePersSDK();
|
|
429
|
+
*
|
|
430
|
+
* // Set platform info (call once on app start)
|
|
431
|
+
* sdk.setPlatform(detectReactNativePlatform());
|
|
432
|
+
*
|
|
433
|
+
* // Set data source (call once, update on deep links/push)
|
|
434
|
+
* sdk.setDataSource({
|
|
435
|
+
* channel: 'mobile',
|
|
436
|
+
* source: 'app_store',
|
|
437
|
+
* });
|
|
438
|
+
* ```
|
|
439
|
+
*
|
|
440
|
+
* @example
|
|
441
|
+
* **Handle Deep Links:**
|
|
442
|
+
* ```typescript
|
|
443
|
+
* import { parseUtmParams } from '@explorins/pers-sdk-react-native';
|
|
444
|
+
*
|
|
445
|
+
* function handleDeepLink(url: string) {
|
|
446
|
+
* const utm = parseUtmParams(url);
|
|
447
|
+
* sdk.updateDataSource({
|
|
448
|
+
* medium: utm.medium,
|
|
449
|
+
* campaign: utm.campaign,
|
|
450
|
+
* source: utm.source || 'deep_link',
|
|
451
|
+
* });
|
|
452
|
+
* }
|
|
453
|
+
* ```
|
|
454
|
+
*
|
|
455
|
+
* @example
|
|
456
|
+
* **Handle Push Notifications:**
|
|
457
|
+
* ```typescript
|
|
458
|
+
* function handlePushNotification(notification: PushNotification) {
|
|
459
|
+
* sdk.updateDataSource({
|
|
460
|
+
* medium: 'push',
|
|
461
|
+
* source: 'push_notification',
|
|
462
|
+
* campaign: notification.campaignId,
|
|
463
|
+
* });
|
|
464
|
+
* }
|
|
465
|
+
* ```
|
|
466
|
+
*/
|
|
467
|
+
export { type Platform, type DataSource, type UtmParams, type WebDataSourceConfig, type NativeDataSourceConfig, parseUtmParams, detectSourceFromReferrer, detectWebPlatform, } from '@explorins/pers-sdk/core';
|
|
468
|
+
export { detectReactNativePlatform } from './utils/platform-detection';
|
|
469
|
+
/**
|
|
470
|
+
* Field validation utilities for custom fields and forms
|
|
471
|
+
*
|
|
472
|
+
* These functions are re-exported from @explorins/pers-shared for convenience.
|
|
473
|
+
* Use them for client-side validation before submitting data to the backend.
|
|
474
|
+
*
|
|
475
|
+
* @example
|
|
476
|
+
* **Single Field Validation:**
|
|
477
|
+
* ```typescript
|
|
478
|
+
* import { validateFieldValue, FieldType, FieldValidationRules } from '@explorins/pers-sdk-react-native';
|
|
479
|
+
*
|
|
480
|
+
* const rules: FieldValidationRules = { minLength: 3 };
|
|
481
|
+
* const error = validateFieldValue('ab', rules, 'text');
|
|
482
|
+
* // error: { message: 'Must be at least 3 characters' }
|
|
483
|
+
* ```
|
|
484
|
+
*
|
|
485
|
+
* @example
|
|
486
|
+
* **Form Validation:**
|
|
487
|
+
* ```typescript
|
|
488
|
+
* import { validateAllFields, FieldDefinition } from '@explorins/pers-sdk-react-native';
|
|
489
|
+
*
|
|
490
|
+
* const definitions: FieldDefinition[] = [
|
|
491
|
+
* { key: 'email', fieldType: 'email', label: 'Email', validation: { minLength: 1 } },
|
|
492
|
+
* { key: 'phone', fieldType: 'phone', label: 'Phone', validation: {} }
|
|
493
|
+
* ];
|
|
494
|
+
*
|
|
495
|
+
* const formData = { email: 'invalid', phone: '123' };
|
|
496
|
+
* const errors = validateAllFields(formData, definitions);
|
|
497
|
+
* // errors: [{ field: 'email', message: 'Invalid email format' }]
|
|
498
|
+
* ```
|
|
499
|
+
*
|
|
500
|
+
* @see {@link validateFieldValue} - Validate a single field value
|
|
501
|
+
* @see {@link validateAllFields} - Validate all fields against definitions
|
|
502
|
+
* @see {@link FieldDefinition} - Field definition structure
|
|
503
|
+
* @see {@link FieldValidationRules} - Available validation rules
|
|
504
|
+
*/
|
|
505
|
+
export { validateFieldValue, validateAllFields, validateFieldComparisons, compareValues, type FieldDefinition, type FieldValidationRules, type ValidationErrorDetail, type FieldType, type FieldComparison, type ComparisonOperator, } from '@explorins/pers-sdk';
|
|
506
|
+
/**
|
|
507
|
+
* Booking status types and validation utilities for eligibility checks
|
|
508
|
+
*
|
|
509
|
+
* Use these to validate if a user's booking status meets requirements
|
|
510
|
+
* for redemptions, campaigns, or other booking-dependent features.
|
|
511
|
+
*
|
|
512
|
+
* **BookingStatus:** 'past' | 'active' | 'future'
|
|
513
|
+
* - `past`: User's stay has ended (checkOut ≤ now)
|
|
514
|
+
* - `active`: User is currently staying (checkIn ≤ now < checkOut)
|
|
515
|
+
* - `future`: Upcoming booking (checkIn > now)
|
|
516
|
+
*
|
|
517
|
+
* **BookingRequirementType:** 'active' | 'future' | 'past' | 'active_future' | 'any'
|
|
518
|
+
* - `active`: Only active bookings allowed
|
|
519
|
+
* - `future`: Only future bookings allowed
|
|
520
|
+
* - `past`: Only past bookings allowed
|
|
521
|
+
* - `active_future`: Active OR future bookings allowed
|
|
522
|
+
* - `any`: Any booking status allowed
|
|
523
|
+
*
|
|
524
|
+
* @example
|
|
525
|
+
* **Basic Validation:**
|
|
526
|
+
* ```typescript
|
|
527
|
+
* import {
|
|
528
|
+
* isBookingStatusValid,
|
|
529
|
+
* BookingStatus,
|
|
530
|
+
* BookingRequirementType
|
|
531
|
+
* } from '@explorins/pers-sdk-react-native';
|
|
532
|
+
*
|
|
533
|
+
* const userBookingStatus: BookingStatus = booking.status;
|
|
534
|
+
* const requirement: BookingRequirementType = redemption.bookingRequirement;
|
|
535
|
+
* const canRedeem = isBookingStatusValid(userBookingStatus, requirement);
|
|
536
|
+
* ```
|
|
537
|
+
*
|
|
538
|
+
* @example
|
|
539
|
+
* **Redemption Screen:**
|
|
540
|
+
* ```typescript
|
|
541
|
+
* function RedemptionCard({ redemption, userBooking }) {
|
|
542
|
+
* const isEligible = redemption.bookingRequirement
|
|
543
|
+
* ? isBookingStatusValid(userBooking?.status ?? 'past', redemption.bookingRequirement)
|
|
544
|
+
* : true;
|
|
545
|
+
*
|
|
546
|
+
* return (
|
|
547
|
+
* <View style={[styles.card, !isEligible && styles.disabled]}>
|
|
548
|
+
* <Text>{redemption.name}</Text>
|
|
549
|
+
* {!isEligible && (
|
|
550
|
+
* <Text style={styles.warning}>
|
|
551
|
+
* Requires {redemption.bookingRequirement} booking
|
|
552
|
+
* </Text>
|
|
553
|
+
* )}
|
|
554
|
+
* </View>
|
|
555
|
+
* );
|
|
556
|
+
* }
|
|
557
|
+
* ```
|
|
558
|
+
*
|
|
559
|
+
* @example
|
|
560
|
+
* **Validation Results:**
|
|
561
|
+
* ```typescript
|
|
562
|
+
* isBookingStatusValid('active', 'active'); // true
|
|
563
|
+
* isBookingStatusValid('future', 'active'); // false
|
|
564
|
+
* isBookingStatusValid('active', 'active_future'); // true
|
|
565
|
+
* isBookingStatusValid('future', 'active_future'); // true
|
|
566
|
+
* isBookingStatusValid('past', 'active_future'); // false
|
|
567
|
+
* isBookingStatusValid('past', 'any'); // true
|
|
568
|
+
* ```
|
|
569
|
+
*/
|
|
570
|
+
export { isBookingStatusValid, type BookingStatus, type BookingRequirementType } from '@explorins/pers-sdk';
|
|
416
571
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0FG;AACH,OAAO,EACL,OAAO,EACP,SAAS,EACT,gBAAgB,EAChB,eAAe,EACf,oBAAoB,EACpB,aAAa,EACb,WAAW,EACX,YAAY,EACZ,cAAc,EACd,OAAO,EACP,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,aAAa,EACb,QAAQ,EACR,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,iBAAiB,EAEjB,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