@explorins/pers-sdk 2.2.0-alpha.1 → 2.2.0-alpha.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.
@@ -0,0 +1,71 @@
1
+ import { PersApiClient } from '../../core/pers-api-client';
2
+ import type { BookingDTO, CreateBookingDTO, UpdateBookingDTO } from '@explorins/pers-shared';
3
+ /**
4
+ * Booking filter options for querying bookings
5
+ */
6
+ /**
7
+ * Options for booking validation checks
8
+ */
9
+ export interface BookingValidationOptions {
10
+ /** Status to check - defaults to checking active+future */
11
+ status?: 'active' | 'future' | 'past' | 'active_future' | 'any';
12
+ /** Business ID to filter by */
13
+ businessId?: string;
14
+ }
15
+ export interface BookingQueryOptions {
16
+ userId?: string;
17
+ businessId?: string;
18
+ status?: 'active' | 'future' | 'past' | 'any';
19
+ }
20
+ /**
21
+ * Low-level API for booking operations
22
+ *
23
+ * Provides direct HTTP calls to the booking endpoints.
24
+ * For most use cases, prefer using BookingManager or BookingService.
25
+ *
26
+ * @internal
27
+ */
28
+ export declare class BookingApi {
29
+ private readonly apiClient;
30
+ private readonly basePath;
31
+ constructor(apiClient: PersApiClient);
32
+ /**
33
+ * List all bookings with optional filters
34
+ *
35
+ * @param options - Filter options (userId, businessId, status)
36
+ * @returns Promise resolving to array of bookings
37
+ */
38
+ getAll(options?: BookingQueryOptions): Promise<BookingDTO[]>;
39
+ /**
40
+ * Get a single booking by ID
41
+ *
42
+ * @param id - Booking UUID
43
+ * @returns Promise resolving to booking data
44
+ */
45
+ getById(id: string): Promise<BookingDTO>;
46
+ /**
47
+ * Create a new booking
48
+ *
49
+ * @param data - Booking creation data
50
+ * @returns Promise resolving to created booking
51
+ */
52
+ create(data: CreateBookingDTO): Promise<BookingDTO>;
53
+ /**
54
+ * Update an existing booking
55
+ *
56
+ * @param id - Booking UUID
57
+ * @param data - Booking update data
58
+ * @returns Promise resolving to updated booking
59
+ */
60
+ update(id: string, data: UpdateBookingDTO): Promise<BookingDTO>;
61
+ /**
62
+ * Delete a booking
63
+ *
64
+ * @param id - Booking UUID
65
+ * @returns Promise resolving to success status
66
+ */
67
+ delete(id: string): Promise<{
68
+ success: boolean;
69
+ }>;
70
+ }
71
+ //# sourceMappingURL=booking-api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"booking-api.d.ts","sourceRoot":"","sources":["../../../src/booking/api/booking-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,KAAK,EACV,UAAU,EACV,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,wBAAwB,CAAC;AAEhC;;GAEG;AACH;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,2DAA2D;IAC3D,MAAM,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,eAAe,GAAG,KAAK,CAAC;IAChE,+BAA+B;IAC/B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,mBAAmB;IAClC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,KAAK,CAAC;CAC/C;AAED;;;;;;;GAOG;AACH,qBAAa,UAAU;IAGT,OAAO,CAAC,QAAQ,CAAC,SAAS;IAFtC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAe;gBAEX,SAAS,EAAE,aAAa;IAErD;;;;;OAKG;IACG,MAAM,CAAC,OAAO,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IAmBlE;;;;;OAKG;IACG,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAI9C;;;;;OAKG;IACG,MAAM,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,UAAU,CAAC;IAIzD;;;;;;OAMG;IACG,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,UAAU,CAAC;IAIrE;;;;;OAKG;IACG,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;CAGxD"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @explorins/pers-sdk-booking
3
+ *
4
+ * Platform-agnostic Booking Domain SDK for PERS ecosystem
5
+ * Handles booking management for eligibility checks and tracking
6
+ */
7
+ export { BookingApi, type BookingQueryOptions, type BookingValidationOptions } from './api/booking-api';
8
+ export { BookingService } from './services/booking-service';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/booking/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,UAAU,EAAE,KAAK,mBAAmB,EAAE,KAAK,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAGxG,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC"}
@@ -0,0 +1,79 @@
1
+ import { BookingApi, type BookingQueryOptions, type BookingValidationOptions } from '../api/booking-api';
2
+ import type { BookingDTO, CreateBookingDTO, UpdateBookingDTO } from '@explorins/pers-shared';
3
+ /**
4
+ * Booking Service - Business logic layer for booking operations
5
+ *
6
+ * Provides booking management functionality with validation and
7
+ * business rule enforcement.
8
+ *
9
+ * @internal
10
+ */
11
+ export declare class BookingService {
12
+ private readonly bookingApi;
13
+ constructor(bookingApi: BookingApi);
14
+ /**
15
+ * Get all bookings with optional filters
16
+ *
17
+ * @param options - Filter options
18
+ * @returns Promise resolving to array of bookings
19
+ */
20
+ getAll(options?: BookingQueryOptions): Promise<BookingDTO[]>;
21
+ /**
22
+ * Get bookings for a specific user
23
+ *
24
+ * @param userId - User ID to filter by
25
+ * @param status - Optional status filter
26
+ * @returns Promise resolving to user's bookings
27
+ */
28
+ getByUser(userId: string, status?: BookingQueryOptions['status']): Promise<BookingDTO[]>;
29
+ /**
30
+ * Get bookings for a specific business
31
+ *
32
+ * @param businessId - Business ID to filter by
33
+ * @param status - Optional status filter
34
+ * @returns Promise resolving to business's bookings
35
+ */
36
+ getByBusiness(businessId: string, status?: BookingQueryOptions['status']): Promise<BookingDTO[]>;
37
+ /**
38
+ * Get a single booking by ID
39
+ *
40
+ * @param id - Booking UUID
41
+ * @returns Promise resolving to booking data
42
+ */
43
+ getById(id: string): Promise<BookingDTO>;
44
+ /**
45
+ * Create a new booking
46
+ *
47
+ * @param data - Booking creation data
48
+ * @returns Promise resolving to created booking
49
+ */
50
+ create(data: CreateBookingDTO): Promise<BookingDTO>;
51
+ /**
52
+ * Update an existing booking
53
+ *
54
+ * @param id - Booking UUID
55
+ * @param data - Booking update data
56
+ * @returns Promise resolving to updated booking
57
+ */
58
+ update(id: string, data: UpdateBookingDTO): Promise<BookingDTO>;
59
+ /**
60
+ * Delete a booking
61
+ *
62
+ * @param id - Booking UUID
63
+ * @returns Promise resolving to success status
64
+ */
65
+ delete(id: string): Promise<{
66
+ success: boolean;
67
+ }>;
68
+ /**
69
+ * Check if a user has an active or future booking
70
+ *
71
+ * Useful for eligibility checks on redemptions.
72
+ *
73
+ * @param userId - User ID to check
74
+ * @param options - Validation options (status filter, business filter)
75
+ * @returns Promise resolving to true if user has valid booking
76
+ */
77
+ hasValidBooking(userId: string, options?: BookingValidationOptions): Promise<boolean>;
78
+ }
79
+ //# sourceMappingURL=booking-service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"booking-service.d.ts","sourceRoot":"","sources":["../../../src/booking/services/booking-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,mBAAmB,EAAE,KAAK,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AACzG,OAAO,KAAK,EACV,UAAU,EACV,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,wBAAwB,CAAC;AAEhC;;;;;;;GAOG;AACH,qBAAa,cAAc;IACb,OAAO,CAAC,QAAQ,CAAC,UAAU;gBAAV,UAAU,EAAE,UAAU;IAEnD;;;;;OAKG;IACG,MAAM,CAAC,OAAO,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IAIlE;;;;;;OAMG;IACG,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,mBAAmB,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IAI9F;;;;;;OAMG;IACG,aAAa,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,mBAAmB,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IAItG;;;;;OAKG;IACG,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAI9C;;;;;OAKG;IACG,MAAM,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,UAAU,CAAC;IAazD;;;;;;OAMG;IACG,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,UAAU,CAAC;IAarE;;;;;OAKG;IACG,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;IAIvD;;;;;;;;OAQG;IACG,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,wBAAwB,GAAG,OAAO,CAAC,OAAO,CAAC;CAoB5F"}
@@ -1585,7 +1585,7 @@ class DefaultAuthProvider {
1585
1585
  /** SDK package name */
1586
1586
  const SDK_NAME = "@explorins/pers-sdk";
1587
1587
  /** SDK version - injected from package.json at build time */
1588
- const SDK_VERSION = "2.2.0-alpha.1";
1588
+ const SDK_VERSION = "2.2.0-alpha.2";
1589
1589
  /** Full SDK identifier for headers */
1590
1590
  const SDK_USER_AGENT = `${SDK_NAME}/${SDK_VERSION}`;
1591
1591
 
@@ -1921,6 +1921,24 @@ class PersApiClient {
1921
1921
  else if (this.mergedConfig.apiProjectKey) {
1922
1922
  headers['x-project-key'] = this.mergedConfig.apiProjectKey;
1923
1923
  }
1924
+ // Add data source tracking headers
1925
+ const dataSource = this.mergedConfig.dataSource;
1926
+ if (dataSource) {
1927
+ headers['x-source-channel'] = dataSource.channel;
1928
+ if (dataSource.medium) {
1929
+ headers['x-source-medium'] = dataSource.medium;
1930
+ }
1931
+ if (dataSource.campaign) {
1932
+ headers['x-source-campaign'] = dataSource.campaign;
1933
+ }
1934
+ if (dataSource.source) {
1935
+ headers['x-source'] = dataSource.source;
1936
+ }
1937
+ // Note: referrer is typically set by browser, but can be overridden
1938
+ if (dataSource.referrer) {
1939
+ headers['Referer'] = dataSource.referrer;
1940
+ }
1941
+ }
1924
1942
  return headers;
1925
1943
  }
1926
1944
  // ==========================================
@@ -10529,6 +10547,412 @@ class CustomFieldDefinitionManager {
10529
10547
  }
10530
10548
  }
10531
10549
 
10550
+ /**
10551
+ * Low-level API for booking operations
10552
+ *
10553
+ * Provides direct HTTP calls to the booking endpoints.
10554
+ * For most use cases, prefer using BookingManager or BookingService.
10555
+ *
10556
+ * @internal
10557
+ */
10558
+ class BookingApi {
10559
+ constructor(apiClient) {
10560
+ this.apiClient = apiClient;
10561
+ this.basePath = '/bookings';
10562
+ }
10563
+ /**
10564
+ * List all bookings with optional filters
10565
+ *
10566
+ * @param options - Filter options (userId, businessId, status)
10567
+ * @returns Promise resolving to array of bookings
10568
+ */
10569
+ async getAll(options) {
10570
+ const params = new URLSearchParams();
10571
+ if (options?.userId) {
10572
+ params.append('userId', options.userId);
10573
+ }
10574
+ if (options?.businessId) {
10575
+ params.append('businessId', options.businessId);
10576
+ }
10577
+ if (options?.status) {
10578
+ params.append('status', options.status);
10579
+ }
10580
+ const queryString = params.toString();
10581
+ const url = queryString ? `${this.basePath}?${queryString}` : this.basePath;
10582
+ return this.apiClient.get(url);
10583
+ }
10584
+ /**
10585
+ * Get a single booking by ID
10586
+ *
10587
+ * @param id - Booking UUID
10588
+ * @returns Promise resolving to booking data
10589
+ */
10590
+ async getById(id) {
10591
+ return this.apiClient.get(`${this.basePath}/${id}`);
10592
+ }
10593
+ /**
10594
+ * Create a new booking
10595
+ *
10596
+ * @param data - Booking creation data
10597
+ * @returns Promise resolving to created booking
10598
+ */
10599
+ async create(data) {
10600
+ return this.apiClient.post(this.basePath, data);
10601
+ }
10602
+ /**
10603
+ * Update an existing booking
10604
+ *
10605
+ * @param id - Booking UUID
10606
+ * @param data - Booking update data
10607
+ * @returns Promise resolving to updated booking
10608
+ */
10609
+ async update(id, data) {
10610
+ return this.apiClient.put(`${this.basePath}/${id}`, data);
10611
+ }
10612
+ /**
10613
+ * Delete a booking
10614
+ *
10615
+ * @param id - Booking UUID
10616
+ * @returns Promise resolving to success status
10617
+ */
10618
+ async delete(id) {
10619
+ return this.apiClient.delete(`${this.basePath}/${id}`);
10620
+ }
10621
+ }
10622
+
10623
+ /**
10624
+ * Booking Service - Business logic layer for booking operations
10625
+ *
10626
+ * Provides booking management functionality with validation and
10627
+ * business rule enforcement.
10628
+ *
10629
+ * @internal
10630
+ */
10631
+ class BookingService {
10632
+ constructor(bookingApi) {
10633
+ this.bookingApi = bookingApi;
10634
+ }
10635
+ /**
10636
+ * Get all bookings with optional filters
10637
+ *
10638
+ * @param options - Filter options
10639
+ * @returns Promise resolving to array of bookings
10640
+ */
10641
+ async getAll(options) {
10642
+ return this.bookingApi.getAll(options);
10643
+ }
10644
+ /**
10645
+ * Get bookings for a specific user
10646
+ *
10647
+ * @param userId - User ID to filter by
10648
+ * @param status - Optional status filter
10649
+ * @returns Promise resolving to user's bookings
10650
+ */
10651
+ async getByUser(userId, status) {
10652
+ return this.bookingApi.getAll({ userId, status });
10653
+ }
10654
+ /**
10655
+ * Get bookings for a specific business
10656
+ *
10657
+ * @param businessId - Business ID to filter by
10658
+ * @param status - Optional status filter
10659
+ * @returns Promise resolving to business's bookings
10660
+ */
10661
+ async getByBusiness(businessId, status) {
10662
+ return this.bookingApi.getAll({ businessId, status });
10663
+ }
10664
+ /**
10665
+ * Get a single booking by ID
10666
+ *
10667
+ * @param id - Booking UUID
10668
+ * @returns Promise resolving to booking data
10669
+ */
10670
+ async getById(id) {
10671
+ return this.bookingApi.getById(id);
10672
+ }
10673
+ /**
10674
+ * Create a new booking
10675
+ *
10676
+ * @param data - Booking creation data
10677
+ * @returns Promise resolving to created booking
10678
+ */
10679
+ async create(data) {
10680
+ // Validate check-out is after check-in
10681
+ if (data.checkInDate && data.checkOutDate) {
10682
+ const checkIn = new Date(data.checkInDate);
10683
+ const checkOut = new Date(data.checkOutDate);
10684
+ if (checkOut <= checkIn) {
10685
+ throw new Error('Check-out date must be after check-in date');
10686
+ }
10687
+ }
10688
+ return this.bookingApi.create(data);
10689
+ }
10690
+ /**
10691
+ * Update an existing booking
10692
+ *
10693
+ * @param id - Booking UUID
10694
+ * @param data - Booking update data
10695
+ * @returns Promise resolving to updated booking
10696
+ */
10697
+ async update(id, data) {
10698
+ // Validate dates if both provided
10699
+ if (data.checkInDate && data.checkOutDate) {
10700
+ const checkIn = new Date(data.checkInDate);
10701
+ const checkOut = new Date(data.checkOutDate);
10702
+ if (checkOut <= checkIn) {
10703
+ throw new Error('Check-out date must be after check-in date');
10704
+ }
10705
+ }
10706
+ return this.bookingApi.update(id, data);
10707
+ }
10708
+ /**
10709
+ * Delete a booking
10710
+ *
10711
+ * @param id - Booking UUID
10712
+ * @returns Promise resolving to success status
10713
+ */
10714
+ async delete(id) {
10715
+ return this.bookingApi.delete(id);
10716
+ }
10717
+ /**
10718
+ * Check if a user has an active or future booking
10719
+ *
10720
+ * Useful for eligibility checks on redemptions.
10721
+ *
10722
+ * @param userId - User ID to check
10723
+ * @param options - Validation options (status filter, business filter)
10724
+ * @returns Promise resolving to true if user has valid booking
10725
+ */
10726
+ async hasValidBooking(userId, options) {
10727
+ const queryOptions = {
10728
+ userId,
10729
+ businessId: options?.businessId
10730
+ };
10731
+ // If a specific status is requested, use it
10732
+ if (options?.status && options.status !== 'active_future') {
10733
+ queryOptions.status = options.status === 'any' ? undefined : options.status;
10734
+ const bookings = await this.bookingApi.getAll(queryOptions);
10735
+ return bookings.length > 0;
10736
+ }
10737
+ // Default: check active+future (active_future or undefined)
10738
+ const activeBookings = await this.bookingApi.getAll({ ...queryOptions, status: 'active' });
10739
+ if (activeBookings.length > 0)
10740
+ return true;
10741
+ const futureBookings = await this.bookingApi.getAll({ ...queryOptions, status: 'future' });
10742
+ return futureBookings.length > 0;
10743
+ }
10744
+ }
10745
+
10746
+ /**
10747
+ * Booking Manager - High-level interface for booking operations
10748
+ *
10749
+ * Provides a simplified API for managing bookings (hotel stays, reservations, etc.)
10750
+ * Used for tracking user stays and eligibility checks on redemptions.
10751
+ *
10752
+ * @group Managers
10753
+ * @category Booking Management
10754
+ *
10755
+ * @example List Bookings
10756
+ * ```typescript
10757
+ * // Get all bookings
10758
+ * const allBookings = await sdk.bookings.getAll();
10759
+ *
10760
+ * // Filter by user
10761
+ * const userBookings = await sdk.bookings.getAll({ userId: 'user-123' });
10762
+ *
10763
+ * // Filter by status
10764
+ * const activeBookings = await sdk.bookings.getAll({ status: 'active' });
10765
+ * ```
10766
+ *
10767
+ * @example Create Booking
10768
+ * ```typescript
10769
+ * const booking = await sdk.bookings.create({
10770
+ * userId: 'user-123',
10771
+ * locationName: 'Grand Hotel',
10772
+ * checkInDate: '2026-06-01',
10773
+ * checkOutDate: '2026-06-05',
10774
+ * guests: 2
10775
+ * });
10776
+ * ```
10777
+ *
10778
+ * @example Check Eligibility
10779
+ * ```typescript
10780
+ * // Check if user has valid (active or future) booking
10781
+ * const hasBooking = await sdk.bookings.hasValidBooking('user-123');
10782
+ * if (hasBooking) {
10783
+ * // User is eligible for booking-required redemption
10784
+ * }
10785
+ * ```
10786
+ */
10787
+ class BookingManager {
10788
+ constructor(apiClient, events) {
10789
+ this.apiClient = apiClient;
10790
+ this.events = events;
10791
+ const bookingApi = new BookingApi(apiClient);
10792
+ this.bookingService = new BookingService(bookingApi);
10793
+ }
10794
+ /**
10795
+ * Get all bookings with optional filters
10796
+ *
10797
+ * @param options - Filter options (userId, businessId, status)
10798
+ * @returns Promise resolving to array of bookings
10799
+ *
10800
+ * @example Basic Usage
10801
+ * ```typescript
10802
+ * // All bookings
10803
+ * const bookings = await sdk.bookings.getAll();
10804
+ *
10805
+ * // Filter by user
10806
+ * const userBookings = await sdk.bookings.getAll({ userId: 'user-123' });
10807
+ *
10808
+ * // Filter by status
10809
+ * const activeBookings = await sdk.bookings.getAll({ status: 'active' });
10810
+ * const futureBookings = await sdk.bookings.getAll({ status: 'future' });
10811
+ * const pastBookings = await sdk.bookings.getAll({ status: 'past' });
10812
+ * ```
10813
+ */
10814
+ async getAll(options) {
10815
+ return this.bookingService.getAll(options);
10816
+ }
10817
+ /**
10818
+ * Get bookings for a specific user
10819
+ *
10820
+ * Convenience method for filtering bookings by user ID.
10821
+ *
10822
+ * @param userId - User ID to filter by
10823
+ * @param status - Optional status filter
10824
+ * @returns Promise resolving to user's bookings
10825
+ */
10826
+ async getByUser(userId, status) {
10827
+ return this.bookingService.getByUser(userId, status);
10828
+ }
10829
+ /**
10830
+ * Get bookings for a specific business
10831
+ *
10832
+ * Convenience method for filtering bookings by business ID.
10833
+ *
10834
+ * @param businessId - Business ID to filter by
10835
+ * @param status - Optional status filter
10836
+ * @returns Promise resolving to business's bookings
10837
+ */
10838
+ async getByBusiness(businessId, status) {
10839
+ return this.bookingService.getByBusiness(businessId, status);
10840
+ }
10841
+ /**
10842
+ * Get a single booking by ID
10843
+ *
10844
+ * @param id - Booking UUID
10845
+ * @returns Promise resolving to booking data
10846
+ * @throws {PersApiError} When booking not found
10847
+ */
10848
+ async getById(id) {
10849
+ return this.bookingService.getById(id);
10850
+ }
10851
+ /**
10852
+ * Create a new booking
10853
+ *
10854
+ * Creates a booking for a user at a specific location. Used for tracking
10855
+ * hotel stays, reservations, etc. for eligibility checks.
10856
+ *
10857
+ * @param data - Booking creation data
10858
+ * @returns Promise resolving to created booking
10859
+ * @throws {Error} When check-out date is not after check-in date
10860
+ *
10861
+ * @example Create Hotel Booking
10862
+ * ```typescript
10863
+ * const booking = await sdk.bookings.create({
10864
+ * userId: 'user-123',
10865
+ * locationName: 'Grand Hotel',
10866
+ * locationType: 'hotel',
10867
+ * checkInDate: '2026-06-01',
10868
+ * checkOutDate: '2026-06-05',
10869
+ * confirmationNumber: 'CONF123',
10870
+ * guests: 2,
10871
+ * notes: 'Ocean view room'
10872
+ * });
10873
+ * ```
10874
+ */
10875
+ async create(data) {
10876
+ const result = await this.bookingService.create(data);
10877
+ // TODO: Add event emission when 'booking' domain is added to pers-shared
10878
+ // this.events?.emitSuccess({ domain: 'booking', type: 'booking_created', ... });
10879
+ return result;
10880
+ }
10881
+ /**
10882
+ * Update an existing booking
10883
+ *
10884
+ * @param id - Booking UUID
10885
+ * @param data - Booking update data (partial update supported)
10886
+ * @returns Promise resolving to updated booking
10887
+ * @throws {PersApiError} When booking not found
10888
+ * @throws {Error} When check-out date is not after check-in date
10889
+ *
10890
+ * @example Update Booking Dates
10891
+ * ```typescript
10892
+ * const updated = await sdk.bookings.update('booking-123', {
10893
+ * checkInDate: '2026-06-02',
10894
+ * checkOutDate: '2026-06-07'
10895
+ * });
10896
+ * ```
10897
+ */
10898
+ async update(id, data) {
10899
+ const result = await this.bookingService.update(id, data);
10900
+ // TODO: Add event emission when 'booking' domain is added to pers-shared
10901
+ // this.events?.emitSuccess({ domain: 'booking', type: 'booking_updated', ... });
10902
+ return result;
10903
+ }
10904
+ /**
10905
+ * Delete a booking
10906
+ *
10907
+ * @param id - Booking UUID
10908
+ * @returns Promise resolving to success status
10909
+ * @throws {PersApiError} When booking not found
10910
+ */
10911
+ async delete(id) {
10912
+ const result = await this.bookingService.delete(id);
10913
+ // TODO: Add event emission when 'booking' domain is added to pers-shared
10914
+ // this.events?.emitSuccess({ domain: 'booking', type: 'booking_deleted', ... });
10915
+ return result;
10916
+ }
10917
+ /**
10918
+ * Check if a user has a valid (active or future) booking
10919
+ *
10920
+ * Useful for eligibility checks on redemptions that require a valid booking.
10921
+ *
10922
+ * @param userId - User ID to check
10923
+ * @param options - Validation options (status filter, business filter)
10924
+ * @returns Promise resolving to true if user has valid booking
10925
+ *
10926
+ * @example Eligibility Check
10927
+ * ```typescript
10928
+ * const hasBooking = await sdk.bookings.hasValidBooking('user-123');
10929
+ *
10930
+ * if (!hasBooking) {
10931
+ * console.log('User must have an active or upcoming booking');
10932
+ * }
10933
+ *
10934
+ * // Check for active booking only
10935
+ * const hasActive = await sdk.bookings.hasValidBooking('user-123', { status: 'active' });
10936
+ *
10937
+ * // Check for booking at specific business
10938
+ * const hasHotelBooking = await sdk.bookings.hasValidBooking('user-123', {
10939
+ * businessId: 'hotel-123'
10940
+ * });
10941
+ * ```
10942
+ */
10943
+ async hasValidBooking(userId, options) {
10944
+ return this.bookingService.hasValidBooking(userId, options);
10945
+ }
10946
+ /**
10947
+ * Get the booking service for advanced operations
10948
+ *
10949
+ * @returns BookingService instance with full API access
10950
+ */
10951
+ getBookingService() {
10952
+ return this.bookingService;
10953
+ }
10954
+ }
10955
+
10532
10956
  /**
10533
10957
  * @fileoverview PERS SDK - Platform-agnostic TypeScript SDK with High-Level Managers
10534
10958
  *
@@ -11248,6 +11672,47 @@ class PersSDK {
11248
11672
  }
11249
11673
  return this._customFields;
11250
11674
  }
11675
+ /**
11676
+ * Booking manager - High-level booking operations
11677
+ *
11678
+ * Provides methods for managing user bookings (hotel stays, reservations, etc.)
11679
+ * Used for eligibility checks on redemptions that require valid bookings.
11680
+ *
11681
+ * @returns BookingManager instance
11682
+ *
11683
+ * @example List User Bookings
11684
+ * ```typescript
11685
+ * // Get all bookings for a user
11686
+ * const bookings = await sdk.bookings.getByUser('user-123');
11687
+ *
11688
+ * // Filter by status
11689
+ * const activeBookings = await sdk.bookings.getAll({ status: 'active' });
11690
+ * ```
11691
+ *
11692
+ * @example Create Booking
11693
+ * ```typescript
11694
+ * const booking = await sdk.bookings.create({
11695
+ * userId: 'user-123',
11696
+ * locationName: 'Grand Hotel',
11697
+ * checkInDate: '2026-06-01',
11698
+ * checkOutDate: '2026-06-05'
11699
+ * });
11700
+ * ```
11701
+ *
11702
+ * @example Eligibility Check
11703
+ * ```typescript
11704
+ * const hasBooking = await sdk.bookings.hasValidBooking('user-123');
11705
+ * if (hasBooking) {
11706
+ * // User is eligible for booking-required redemption
11707
+ * }
11708
+ * ```
11709
+ */
11710
+ get bookings() {
11711
+ if (!this._bookings) {
11712
+ this._bookings = new BookingManager(this.apiClient, this._events);
11713
+ }
11714
+ return this._bookings;
11715
+ }
11251
11716
  /**
11252
11717
  * Wallet Events Manager - Real-time blockchain events for user's wallets
11253
11718
  *
@@ -11354,5 +11819,5 @@ function createPersSDK(httpClient, config) {
11354
11819
  return new PersSDK(httpClient, config);
11355
11820
  }
11356
11821
 
11357
- export { AuthTokenManager as A, BusinessManager as B, CampaignManager as C, DefaultAuthProvider as D, WalletEventsManager as E, FATAL_AUTH_CODES as F, CustomFieldDefinitionManager as G, AuthStatus as H, IndexedDBTokenStorage as I, FileApi as J, FileService as K, LocalStorageTokenStorage as L, MemoryTokenStorage as M, ApiKeyApi as N, WebhookApi as O, PersSDK as P, WebhookService as Q, RedemptionManager as R, SDK_NAME as S, TokenManager as T, UserManager as U, PersEventsClient as V, WebDPoPCryptoProvider as W, createPersEventsClient as X, AUTH_STORAGE_KEYS as a, DPOP_STORAGE_KEYS as b, SDK_VERSION as c, SDK_USER_AGENT as d, createPersSDK as e, PersApiClient as f, DEFAULT_PERS_CONFIG as g, buildApiRoot as h, buildWalletEventsWsUrl as i, StaticJwtAuthProvider as j, AuthApi as k, isFatalAuthErrorInMessage as l, mergeWithDefaults as m, AuthService as n, DPoPManager as o, PersEventEmitter as p, AuthManager as q, UserStatusManager as r, TransactionManager as s, PurchaseManager as t, FileManager as u, ApiKeyManager as v, AnalyticsManager as w, DonationManager as x, TriggerSourceManager as y, WebhookManager as z };
11358
- //# sourceMappingURL=pers-sdk-CBRtrG03.js.map
11822
+ export { AuthTokenManager as A, BusinessManager as B, CampaignManager as C, DefaultAuthProvider as D, WalletEventsManager as E, FATAL_AUTH_CODES as F, CustomFieldDefinitionManager as G, BookingManager as H, IndexedDBTokenStorage as I, AuthStatus as J, FileApi as K, LocalStorageTokenStorage as L, MemoryTokenStorage as M, FileService as N, ApiKeyApi as O, PersSDK as P, WebhookApi as Q, RedemptionManager as R, SDK_NAME as S, TokenManager as T, UserManager as U, WebhookService as V, WebDPoPCryptoProvider as W, BookingApi as X, BookingService as Y, PersEventsClient as Z, createPersEventsClient as _, AUTH_STORAGE_KEYS as a, DPOP_STORAGE_KEYS as b, SDK_VERSION as c, SDK_USER_AGENT as d, createPersSDK as e, PersApiClient as f, DEFAULT_PERS_CONFIG as g, buildApiRoot as h, buildWalletEventsWsUrl as i, StaticJwtAuthProvider as j, AuthApi as k, isFatalAuthErrorInMessage as l, mergeWithDefaults as m, AuthService as n, DPoPManager as o, PersEventEmitter as p, AuthManager as q, UserStatusManager as r, TransactionManager as s, PurchaseManager as t, FileManager as u, ApiKeyManager as v, AnalyticsManager as w, DonationManager as x, TriggerSourceManager as y, WebhookManager as z };
11823
+ //# sourceMappingURL=pers-sdk-C01Z2nmP.js.map